Changeset 6112


Ignore:
Timestamp:
04/09/10 12:55:41 (10 years ago)
Author:
melissa
Message:

Updated several readers to respect MetadataOptions.

Location:
trunk/components/bio-formats/src/loci/formats/in
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/bio-formats/src/loci/formats/in/APNGReader.java

    r6107 r6112  
    2828import java.awt.image.WritableRaster; 
    2929import java.io.BufferedInputStream; 
     30import java.io.ByteArrayOutputStream; 
    3031import java.io.DataInputStream; 
    3132import java.io.IOException; 
     
    4041import loci.formats.FormatTools; 
    4142import loci.formats.MetadataTools; 
    42 import loci.formats.codec.ByteVector; 
    4343import loci.formats.gui.AWTImageTools; 
    4444import loci.formats.meta.FilterMetadata; 
     
    5959  // -- Constants -- 
    6060 
    61   // Valid values for dispose operation field: 
    62   //private static final int DISPOSE_OP_NONE = 0; 
    63   //private static final int DISPOSE_OP_BACKGROUND = 1; 
    64   //private static final int DISPOSE_OP_PREVIOUS = 2; 
    65  
    6661  private static final byte[] PNG_SIGNATURE = new byte[] { 
    6762    (byte) 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a 
     
    10499    } 
    105100 
    106     ByteVector stream = new ByteVector(); 
    107     stream.add(PNG_SIGNATURE); 
     101    ByteArrayOutputStream stream = new ByteArrayOutputStream(); 
     102    stream.write(PNG_SIGNATURE); 
    108103 
    109104    boolean fdatValid = false; 
     
    128123        int crc = (int) computeCRC(b, b.length - 4); 
    129124        DataTools.unpackBytes(crc, b, b.length - 4, 4, isLittleEndian()); 
    130         stream.add(b); 
     125        stream.write(b); 
    131126        b = null; 
    132127      } 
     
    147142          int crc = (int) computeCRC(b, b.length - 4); 
    148143          DataTools.unpackBytes(crc, b, b.length - 4, 4, isLittleEndian()); 
    149           stream.add(b); 
     144          stream.write(b); 
    150145          b = null; 
    151146        } 
  • trunk/components/bio-formats/src/loci/formats/in/ARFReader.java

    r6026 r6112  
    4848public class ARFReader extends FormatReader { 
    4949 
     50  // -- Constants -- 
     51 
     52  private static final long PIXELS_OFFSET = 524; 
     53 
    5054  // -- Constructor -- 
    5155 
     
    6569    byte endian2 = stream.readByte(); 
    6670    return ((endian1 == 1 && endian2 == 0) || (endian1 == 0 && endian2 == 1)) && 
    67       stream.readString(2).startsWith("AR"); 
     71      stream.readString(2).equals("AR"); 
    6872  } 
    6973 
     
    7680    FormatTools.checkPlaneParameters(this, no, buf.length, x, y, w, h); 
    7781 
    78     in.seek(524 + no * FormatTools.getPlaneSize(this)); 
     82    in.seek(PIXELS_OFFSET + no * FormatTools.getPlaneSize(this)); 
    7983    readPlane(in, x, y, w, h, buf); 
    8084 
     
    135139    core[0].metadataComplete = true; 
    136140 
    137     // populate original metadata 
     141    if (getMetadataOptions().getMetadataLevel() == MetadataLevel.ALL) { 
     142      // populate original metadata 
    138143 
    139     addGlobalMeta("Endianness", little ? "little" : "big"); 
    140     addGlobalMeta("Version", version); 
    141     addGlobalMeta("Width", width); 
    142     addGlobalMeta("Height", height); 
    143     addGlobalMeta("Bits per pixel", bitsPerPixel); 
    144     addGlobalMeta("Image count", numImages); 
     144      addGlobalMeta("Endianness", little ? "little" : "big"); 
     145      addGlobalMeta("Version", version); 
     146      addGlobalMeta("Width", width); 
     147      addGlobalMeta("Height", height); 
     148      addGlobalMeta("Bits per pixel", bitsPerPixel); 
     149      addGlobalMeta("Image count", numImages); 
     150    } 
    145151 
    146152    // populate OME metadata 
  • trunk/components/bio-formats/src/loci/formats/in/AliconaReader.java

    r6055 r6112  
    199199    MetadataTools.setDefaultCreationDate(store, id, 0); 
    200200 
    201     // link Image and Instrument 
    202     String instrumentID = MetadataTools.createLSID("Instrument", 0); 
    203     store.setInstrumentID(instrumentID, 0); 
    204     store.setImageInstrumentRef(instrumentID, 0); 
    205  
    206     // populate Detector data 
    207  
    208     // According to the spec, the voltage and magnification values are those 
    209     // used when the dataset was acquired, i.e. detector settings. 
    210     if (voltage != null) { 
    211       store.setDetectorSettingsVoltage(new Double(voltage), 0, 0); 
    212  
    213       // link DetectorSettings to an actual Detector 
    214       String detectorID = MetadataTools.createLSID("Detector", 0, 0); 
    215       store.setDetectorID(detectorID, 0, 0); 
    216       store.setDetectorSettingsDetector(detectorID, 0, 0); 
    217  
    218       // set required Detector type 
    219       store.setDetectorType("Unknown", 0, 0); 
    220     } 
    221  
    222     // populate Objective data 
    223  
    224     if (magnification != null) { 
    225       store.setObjectiveCalibratedMagnification( 
    226         new Double(magnification), 0, 0); 
    227     } 
    228  
    229     if (workingDistance != null) { 
    230       store.setObjectiveWorkingDistance(new Double(workingDistance), 0, 0); 
    231     } 
    232  
    233     store.setObjectiveCorrection("Unknown", 0, 0); 
    234     store.setObjectiveImmersion("Unknown", 0, 0); 
    235  
    236     // link Objective to an Image using ObjectiveSettings 
    237     String objectiveID = MetadataTools.createLSID("Objective", 0, 0); 
    238     store.setObjectiveID(objectiveID, 0, 0); 
    239     store.setObjectiveSettingsObjective(objectiveID, 0); 
    240  
    241     // populate Dimensions data 
    242  
    243     if (pntX != null && pntY != null) { 
    244       double pixelSizeX = Double.parseDouble(pntX) * 1000000; 
    245       double pixelSizeY = Double.parseDouble(pntY) * 1000000; 
    246  
    247       store.setDimensionsPhysicalSizeX(pixelSizeX, 0, 0); 
    248       store.setDimensionsPhysicalSizeY(pixelSizeY, 0, 0); 
     201    if (getMetadataOptions().getMetadataLevel() == MetadataLevel.ALL) { 
     202      // link Image and Instrument 
     203      String instrumentID = MetadataTools.createLSID("Instrument", 0); 
     204      store.setInstrumentID(instrumentID, 0); 
     205      store.setImageInstrumentRef(instrumentID, 0); 
     206 
     207      // populate Detector data 
     208 
     209      // According to the spec, the voltage and magnification values are those 
     210      // used when the dataset was acquired, i.e. detector settings. 
     211      if (voltage != null) { 
     212        store.setDetectorSettingsVoltage(new Double(voltage), 0, 0); 
     213 
     214        // link DetectorSettings to an actual Detector 
     215        String detectorID = MetadataTools.createLSID("Detector", 0, 0); 
     216        store.setDetectorID(detectorID, 0, 0); 
     217        store.setDetectorSettingsDetector(detectorID, 0, 0); 
     218 
     219        // set required Detector type 
     220        store.setDetectorType("Unknown", 0, 0); 
     221      } 
     222 
     223      // populate Objective data 
     224 
     225      if (magnification != null) { 
     226        store.setObjectiveCalibratedMagnification( 
     227          new Double(magnification), 0, 0); 
     228      } 
     229 
     230      if (workingDistance != null) { 
     231        store.setObjectiveWorkingDistance(new Double(workingDistance), 0, 0); 
     232      } 
     233 
     234      store.setObjectiveCorrection("Unknown", 0, 0); 
     235      store.setObjectiveImmersion("Unknown", 0, 0); 
     236 
     237      // link Objective to an Image using ObjectiveSettings 
     238      String objectiveID = MetadataTools.createLSID("Objective", 0, 0); 
     239      store.setObjectiveID(objectiveID, 0, 0); 
     240      store.setObjectiveSettingsObjective(objectiveID, 0); 
     241 
     242      // populate Dimensions data 
     243 
     244      if (pntX != null && pntY != null) { 
     245        double pixelSizeX = Double.parseDouble(pntX) * 1000000; 
     246        double pixelSizeY = Double.parseDouble(pntY) * 1000000; 
     247 
     248        store.setDimensionsPhysicalSizeX(pixelSizeX, 0, 0); 
     249        store.setDimensionsPhysicalSizeY(pixelSizeY, 0, 0); 
     250      } 
    249251    } 
    250252  } 
  • trunk/components/bio-formats/src/loci/formats/in/AnalyzeReader.java

    r6055 r6112  
    152152 
    153153    String imageName = in.readString(18); 
    154     addGlobalMeta("Database name", imageName); 
    155154    in.skipBytes(8); 
    156155 
    157156    int ndims = in.readShort(); 
    158     addGlobalMeta("Number of dimensions", ndims); 
    159157 
    160158    int x = in.readShort(); 
     
    166164 
    167165    int dataType = in.readShort(); 
    168  
    169166    int nBitsPerPixel = in.readShort(); 
    170167 
    171     addGlobalMeta("Data type", dataType); 
    172     addGlobalMeta("Number of bits per pixel", nBitsPerPixel); 
    173  
    174     in.skipBytes(6); 
    175  
    176     float voxelWidth = in.readFloat(); 
    177     float voxelHeight = in.readFloat(); 
    178     float sliceThickness = in.readFloat(); 
    179     float deltaT = in.readFloat(); 
    180  
    181     addGlobalMeta("Voxel width", voxelWidth); 
    182     addGlobalMeta("Voxel height", voxelHeight); 
    183     addGlobalMeta("Slice thickness", sliceThickness); 
    184     addGlobalMeta("Exposure time", deltaT); 
    185  
    186     in.skipBytes(12); 
    187  
    188     pixelOffset = (int) in.readFloat(); 
    189  
    190     addGlobalMeta("Pixel offset", pixelOffset); 
    191  
    192     in.skipBytes(12); 
    193  
    194     float calibratedMax = in.readFloat(); 
    195     float calibratedMin = in.readFloat(); 
    196     float compressed = in.readFloat(); 
    197     float verified = in.readFloat(); 
    198     float pixelMax = in.readFloat(); 
    199     float pixelMin = in.readFloat(); 
    200  
    201     addGlobalMeta("Calibrated maximum", calibratedMax); 
    202     addGlobalMeta("Calibrated minimum", calibratedMin); 
    203     addGlobalMeta("Compressed", compressed); 
    204     addGlobalMeta("Verified", verified); 
    205     addGlobalMeta("Pixel maximum", pixelMax); 
    206     addGlobalMeta("Pixel minimum", pixelMin); 
    207  
    208     String description = in.readString(80); 
    209     String auxFile = in.readString(24); 
    210     char orient = in.readChar(); 
    211     String originator = in.readString(10); 
    212     String generated = in.readString(10); 
    213     String scannum = in.readString(10); 
    214     String patientID = in.readString(10); 
    215     String expDate = in.readString(10); 
    216     String expTime = in.readString(10); 
    217  
    218     in.skipBytes(3); 
    219  
    220     int views = in.readInt(); 
    221     int volsAdded = in.readInt(); 
    222     int startField = in.readInt(); 
    223     int fieldSkip = in.readInt(); 
    224     int omax = in.readInt(); 
    225     int omin = in.readInt(); 
    226     int smax = in.readInt(); 
    227     int smin = in.readInt(); 
    228  
    229     addGlobalMeta("Description", description); 
    230     addGlobalMeta("Auxiliary file", auxFile); 
    231     addGlobalMeta("Orientation", orient); 
    232     addGlobalMeta("Originator", originator); 
    233     addGlobalMeta("Generated", generated); 
    234     addGlobalMeta("Scan Number", scannum); 
    235     addGlobalMeta("Patient ID", patientID); 
    236     addGlobalMeta("Acquisition Date", expDate); 
    237     addGlobalMeta("Acquisition Time", expTime); 
     168    String description = null; 
     169    double voxelWidth = 0d, voxelHeight = 0d, sliceThickness = 0d, deltaT = 0d; 
     170 
     171    if (getMetadataOptions().getMetadataLevel() == MetadataLevel.ALL) { 
     172      in.skipBytes(6); 
     173 
     174      voxelWidth = in.readFloat(); 
     175      voxelHeight = in.readFloat(); 
     176      sliceThickness = in.readFloat(); 
     177      deltaT = in.readFloat(); 
     178 
     179      in.skipBytes(12); 
     180 
     181      pixelOffset = (int) in.readFloat(); 
     182      in.skipBytes(12); 
     183 
     184      float calibratedMax = in.readFloat(); 
     185      float calibratedMin = in.readFloat(); 
     186      float compressed = in.readFloat(); 
     187      float verified = in.readFloat(); 
     188      float pixelMax = in.readFloat(); 
     189      float pixelMin = in.readFloat(); 
     190 
     191      description = in.readString(80); 
     192      String auxFile = in.readString(24); 
     193      char orient = (char) in.readByte(); 
     194      String originator = in.readString(10); 
     195      String generated = in.readString(10); 
     196      String scannum = in.readString(10); 
     197      String patientID = in.readString(10); 
     198      String expDate = in.readString(10); 
     199      String expTime = in.readString(10); 
     200 
     201      in.skipBytes(3); 
     202 
     203      int views = in.readInt(); 
     204      int volsAdded = in.readInt(); 
     205      int startField = in.readInt(); 
     206      int fieldSkip = in.readInt(); 
     207      int omax = in.readInt(); 
     208      int omin = in.readInt(); 
     209      int smax = in.readInt(); 
     210      int smin = in.readInt(); 
     211 
     212      addGlobalMeta("Database name", imageName); 
     213      addGlobalMeta("Number of dimensions", ndims); 
     214      addGlobalMeta("Data type", dataType); 
     215      addGlobalMeta("Number of bits per pixel", nBitsPerPixel); 
     216      addGlobalMeta("Voxel width", voxelWidth); 
     217      addGlobalMeta("Voxel height", voxelHeight); 
     218      addGlobalMeta("Slice thickness", sliceThickness); 
     219      addGlobalMeta("Exposure time", deltaT); 
     220      addGlobalMeta("Pixel offset", pixelOffset); 
     221      addGlobalMeta("Calibrated maximum", calibratedMax); 
     222      addGlobalMeta("Calibrated minimum", calibratedMin); 
     223      addGlobalMeta("Compressed", compressed); 
     224      addGlobalMeta("Verified", verified); 
     225      addGlobalMeta("Pixel maximum", pixelMax); 
     226      addGlobalMeta("Pixel minimum", pixelMin); 
     227      addGlobalMeta("Description", description); 
     228      addGlobalMeta("Auxiliary file", auxFile); 
     229      addGlobalMeta("Orientation", orient); 
     230      addGlobalMeta("Originator", originator); 
     231      addGlobalMeta("Generated", generated); 
     232      addGlobalMeta("Scan Number", scannum); 
     233      addGlobalMeta("Patient ID", patientID); 
     234      addGlobalMeta("Acquisition Date", expDate); 
     235      addGlobalMeta("Acquisition Time", expTime); 
     236    } 
     237    else { 
     238      in.skipBytes(34); 
     239      pixelOffset = (int) in.readFloat(); 
     240    } 
    238241 
    239242    LOGGER.info("Populating core metadata"); 
     
    287290 
    288291    store.setImageName(imageName, 0); 
    289     store.setImageDescription(description, 0); 
    290  
    291     store.setDimensionsPhysicalSizeX(voxelWidth * 0.001, 0, 0); 
    292     store.setDimensionsPhysicalSizeY(voxelHeight * 0.001, 0, 0); 
    293     store.setDimensionsPhysicalSizeZ(sliceThickness * 0.001, 0, 0); 
    294     store.setDimensionsTimeIncrement(new Double(deltaT * 1000), 0, 0); 
     292 
     293    if (getMetadataOptions().getMetadataLevel() == MetadataLevel.ALL) { 
     294      store.setImageDescription(description, 0); 
     295      store.setDimensionsPhysicalSizeX(voxelWidth * 0.001, 0, 0); 
     296      store.setDimensionsPhysicalSizeY(voxelHeight * 0.001, 0, 0); 
     297      store.setDimensionsPhysicalSizeZ(sliceThickness * 0.001, 0, 0); 
     298      store.setDimensionsTimeIncrement(new Double(deltaT * 1000), 0, 0); 
     299    } 
    295300  } 
    296301 
  • trunk/components/bio-formats/src/loci/formats/in/BMPReader.java

    r6055 r6112  
    6161  // -- Fields -- 
    6262 
    63   /** Offset to the image data. */ 
    64   private int offset; 
    65  
    6663  /** Number of bits per pixel. */ 
    6764  private int bpp; 
     
    133130    BitBuffer bb = new BitBuffer(rawPlane); 
    134131 
    135     if ((palette != null && palette[0].length > 0) || getSizeC() == 1) { 
    136       for (int row=h-1; row>=0; row--) { 
    137         bb.skipBits(x * bpp); 
    138         for (int i=0; i<w; i++) { 
    139           buf[row*w + i] = (byte) (bb.getBits(bpp) & 0xff); 
    140         } 
    141         if (row > 0) bb.skipBits((getSizeX() - w - x) * bpp + pad * 8); 
    142       } 
    143     } 
    144     else { 
    145       int len = getSizeX() * getSizeC(); 
    146       for (int row=h-1; row>=y; row--) { 
    147         bb.skipBits(x * getSizeC() * bpp); 
    148         for (int i=0; i<w*getSizeC(); i++) { 
    149           buf[row*w*getSizeC() + i] = (byte) (bb.getBits(bpp) & 0xff); 
    150         } 
    151         bb.skipBits(getSizeC() * bpp * (getSizeX() - w - x) + pad * 8); 
    152       } 
     132    int effectiveC = palette != null && palette[0].length > 0 ? 1 : getSizeC(); 
     133    for (int row=h-1; row>=y; row--) { 
     134      bb.skipBits(x * bpp * effectiveC); 
     135      for (int i=0; i<w*effectiveC; i++) { 
     136        buf[row * w * effectiveC + i] = (byte) (bb.getBits(bpp) & 0xff); 
     137      } 
     138      if (row > y) { 
     139        bb.skipBits((getSizeX() - w - x) * bpp * effectiveC + pad*8); 
     140      } 
     141    } 
     142 
     143    if (getRGBChannelCount() > 1) { 
    153144      ImageTools.bgrToRgb(buf, isInterleaved(), 1, getRGBChannelCount()); 
    154145    } 
     
    160151    super.close(fileOnly); 
    161152    if (!fileOnly) { 
    162       offset = bpp = compression = 0; 
     153      bpp = compression = 0; 
    163154      global = 0; 
    164155      palette = null; 
     
    182173 
    183174    addGlobalMeta("File size (in bytes)", in.readInt()); 
    184     in.skipBytes(4); // reserved 
    185  
    186     // read the offset to the image data 
    187     offset = in.readInt(); 
     175    in.skipBytes(8); // reserved 
    188176 
    189177    // read the second header - 40 bytes 
     
    200188        getSizeX() + " x " + getSizeY()); 
    201189    } 
    202     addGlobalMeta("Image width", getSizeX()); 
    203     addGlobalMeta("Image height", getSizeY()); 
    204190 
    205191    addGlobalMeta("Color planes", in.readShort()); 
    206192    bpp = in.readShort(); 
    207     addGlobalMeta("Bits per pixel", bpp); 
    208193 
    209194    compression = in.readInt(); 
    210     String comp = "invalid"; 
    211  
    212     switch (compression) { 
    213       case RAW: 
    214         comp = "None"; 
    215         break; 
    216       case RLE_8: 
    217         comp = "8 bit run length encoding"; 
    218         break; 
    219       case RLE_4: 
    220         comp = "4 bit run length encoding"; 
    221         break; 
    222       case RGB_MASK: 
    223         comp = "RGB bitmap with mask"; 
    224         break; 
    225     } 
    226  
    227     addGlobalMeta("Compression type", comp); 
    228195 
    229196    in.skipBytes(4); 
    230197    int pixelSizeX = in.readInt(); 
    231198    int pixelSizeY = in.readInt(); 
    232     addGlobalMeta("X resolution", pixelSizeX); 
    233     addGlobalMeta("Y resolution", pixelSizeY); 
    234199    int nColors = in.readInt(); 
    235200    if (nColors == 0 && bpp != 32 && bpp != 24) { 
     
    253218 
    254219    global = in.getFilePointer(); 
    255  
    256     addGlobalMeta("Indexed color", palette != null); 
    257220 
    258221    LOGGER.info("Populating metadata"); 
     
    288251    core[0].falseColor = false; 
    289252 
     253    if (getMetadataOptions().getMetadataLevel() == MetadataLevel.ALL) { 
     254      addGlobalMeta("Indexed color", palette != null); 
     255      addGlobalMeta("Image width", getSizeX()); 
     256      addGlobalMeta("Image height", getSizeY()); 
     257      addGlobalMeta("Bits per pixel", bpp); 
     258      String comp = "invalid"; 
     259 
     260      switch (compression) { 
     261        case RAW: 
     262          comp = "None"; 
     263          break; 
     264        case RLE_8: 
     265          comp = "8 bit run length encoding"; 
     266          break; 
     267        case RLE_4: 
     268          comp = "4 bit run length encoding"; 
     269          break; 
     270        case RGB_MASK: 
     271          comp = "RGB bitmap with mask"; 
     272          break; 
     273      } 
     274 
     275      addGlobalMeta("Compression type", comp); 
     276      addGlobalMeta("X resolution", pixelSizeX); 
     277      addGlobalMeta("Y resolution", pixelSizeY); 
     278    } 
     279 
    290280    // Populate metadata store. 
    291281 
     
    295285    MetadataTools.setDefaultCreationDate(store, id, 0); 
    296286 
    297     // resolution is stored as pixels per meter; we want to convert to 
    298     // microns per pixel 
    299  
    300     double correctedX = pixelSizeX == 0 ? 0.0 : 1000000.0 / pixelSizeX; 
    301     double correctedY = pixelSizeY == 0 ? 0.0 : 1000000.0 / pixelSizeY; 
    302  
    303     store.setDimensionsPhysicalSizeX(correctedX, 0, 0); 
    304     store.setDimensionsPhysicalSizeY(correctedY, 0, 0); 
     287    if (getMetadataOptions().getMetadataLevel() == MetadataLevel.ALL) { 
     288      // resolution is stored as pixels per meter; we want to convert to 
     289      // microns per pixel 
     290 
     291      double correctedX = pixelSizeX == 0 ? 0.0 : 1000000.0 / pixelSizeX; 
     292      double correctedY = pixelSizeY == 0 ? 0.0 : 1000000.0 / pixelSizeY; 
     293 
     294      store.setDimensionsPhysicalSizeX(correctedX, 0, 0); 
     295      store.setDimensionsPhysicalSizeY(correctedY, 0, 0); 
     296    } 
    305297  } 
    306298 
  • trunk/components/bio-formats/src/loci/formats/in/BaseTiffReader.java

    r6055 r6112  
    8484   */ 
    8585  protected void initStandardMetadata() throws FormatException, IOException { 
     86    if (getMetadataOptions().getMetadataLevel() != MetadataLevel.ALL) { 
     87      return; 
     88    } 
    8689    IFD firstIFD = ifds.get(0); 
    8790    put("ImageWidth", firstIFD, IFD.IMAGE_WIDTH); 
     
    355358    put("BitsPerSample", bps); 
    356359    put("NumberOfChannels", numC); 
    357  
    358     int samples = firstIFD.getSamplesPerPixel(); 
    359     core[0].rgb = samples > 1 || photo == PhotoInterp.RGB; 
    360     core[0].interleaved = false; 
    361     core[0].littleEndian = firstIFD.isLittleEndian(); 
    362  
    363     core[0].sizeX = (int) firstIFD.getImageWidth(); 
    364     core[0].sizeY = (int) firstIFD.getImageLength(); 
    365     core[0].sizeZ = 1; 
    366     core[0].sizeC = isRGB() ? samples : 1; 
    367     core[0].sizeT = ifds.size(); 
    368     core[0].metadataComplete = true; 
    369     core[0].indexed = photo == PhotoInterp.RGB_PALETTE && 
    370       (get8BitLookupTable() != null || get16BitLookupTable() != null); 
    371     if (isIndexed()) { 
    372       core[0].sizeC = 1; 
    373       core[0].rgb = false; 
    374     } 
    375     if (getSizeC() == 1 && !isIndexed()) core[0].rgb = false; 
    376     core[0].falseColor = false; 
    377     core[0].dimensionOrder = "XYCZT"; 
    378     core[0].pixelType = firstIFD.getPixelType(); 
    379360  } 
    380361 
     
    398379    IFD firstIFD = ifds.get(0); 
    399380 
    400     // populate Experimenter 
    401     String artist = firstIFD.getIFDTextValue(IFD.ARTIST); 
    402  
    403     if (artist != null) { 
    404       String firstName = null, lastName = null; 
    405       int ndx = artist.indexOf(" "); 
    406       if (ndx < 0) lastName = artist; 
    407       else { 
    408         firstName = artist.substring(0, ndx); 
    409         lastName = artist.substring(ndx + 1); 
    410       } 
    411       String email = firstIFD.getIFDStringValue(IFD.HOST_COMPUTER); 
    412       store.setExperimenterFirstName(firstName, 0); 
    413       store.setExperimenterLastName(lastName, 0); 
    414       store.setExperimenterEmail(email, 0); 
    415     } 
    416  
    417381    // format the creation date to ISO 8601 
    418382 
     
    432396       MetadataTools.setDefaultCreationDate(store, getCurrentFile(), 0); 
    433397    } 
    434     store.setImageDescription(firstIFD.getComment(), 0); 
    435  
    436     // set the X and Y pixel dimensions 
    437  
    438     int resolutionUnit = firstIFD.getIFDIntValue(IFD.RESOLUTION_UNIT); 
    439     TiffRational xResolution = firstIFD.getIFDRationalValue(IFD.X_RESOLUTION); 
    440     TiffRational yResolution = firstIFD.getIFDRationalValue(IFD.Y_RESOLUTION); 
    441     double pixX = xResolution == null ? 0 : 1 / xResolution.doubleValue(); 
    442     double pixY = yResolution == null ? 0 : 1 / yResolution.doubleValue(); 
    443  
    444     switch (resolutionUnit) { 
    445       case 2: 
    446         // resolution is expressed in pixels per inch 
    447         pixX *= 25400; 
    448         pixY *= 25400; 
    449         break; 
    450       case 3: 
    451         // resolution is expressed in pixels per centimeter 
    452         pixX *= 10000; 
    453         pixY *= 10000; 
    454         break; 
    455     } 
    456  
    457     store.setDimensionsPhysicalSizeX(pixX, 0, 0); 
    458     store.setDimensionsPhysicalSizeY(pixY, 0, 0); 
    459     store.setDimensionsPhysicalSizeZ(0.0, 0, 0); 
     398 
     399    if (getMetadataOptions().getMetadataLevel() == MetadataLevel.ALL) { 
     400      // populate Experimenter 
     401      String artist = firstIFD.getIFDTextValue(IFD.ARTIST); 
     402 
     403      if (artist != null) { 
     404        String firstName = null, lastName = null; 
     405        int ndx = artist.indexOf(" "); 
     406        if (ndx < 0) lastName = artist; 
     407        else { 
     408          firstName = artist.substring(0, ndx); 
     409          lastName = artist.substring(ndx + 1); 
     410        } 
     411        String email = firstIFD.getIFDStringValue(IFD.HOST_COMPUTER); 
     412        store.setExperimenterFirstName(firstName, 0); 
     413        store.setExperimenterLastName(lastName, 0); 
     414        store.setExperimenterEmail(email, 0); 
     415      } 
     416 
     417      store.setImageDescription(firstIFD.getComment(), 0); 
     418 
     419      // set the X and Y pixel dimensions 
     420 
     421      int resolutionUnit = firstIFD.getIFDIntValue(IFD.RESOLUTION_UNIT); 
     422      TiffRational xResolution = firstIFD.getIFDRationalValue(IFD.X_RESOLUTION); 
     423      TiffRational yResolution = firstIFD.getIFDRationalValue(IFD.Y_RESOLUTION); 
     424      double pixX = xResolution == null ? 0 : 1 / xResolution.doubleValue(); 
     425      double pixY = yResolution == null ? 0 : 1 / yResolution.doubleValue(); 
     426 
     427      switch (resolutionUnit) { 
     428        case 2: 
     429          // resolution is expressed in pixels per inch 
     430          pixX *= 25400; 
     431          pixY *= 25400; 
     432          break; 
     433        case 3: 
     434          // resolution is expressed in pixels per centimeter 
     435          pixX *= 10000; 
     436          pixY *= 10000; 
     437          break; 
     438      } 
     439 
     440      store.setDimensionsPhysicalSizeX(pixX, 0, 0); 
     441      store.setDimensionsPhysicalSizeY(pixY, 0, 0); 
     442      store.setDimensionsPhysicalSizeZ(0.0, 0, 0); 
     443    } 
    460444  } 
    461445 
  • trunk/components/bio-formats/src/loci/formats/in/BurleighReader.java

    r6055 r6112  
    106106 
    107107    double xSize = 0d, ySize = 0d, zSize = 0d; 
    108     double timePerPixel = 0d; 
    109     int mode = 0, gain = 0, mag = 0; 
    110     double sampleVolts = 0d, tunnelCurrent = 0d; 
    111108 
    112     if (version == 1) { 
    113       in.seek(in.length() - 40); 
    114       in.skipBytes(12); 
    115       xSize = in.readInt(); 
    116       ySize = in.readInt(); 
    117       zSize = in.readInt(); 
    118       timePerPixel = in.readShort() * 50; 
    119       mag = in.readShort(); 
     109    pixelsOffset = version == 1 ? 8 : 260; 
    120110 
    121       switch (mag) { 
    122         case 3: 
    123           mag = 10; 
    124           break; 
    125         case 4: 
    126           mag = 50; 
    127           break; 
    128         case 5: 
    129           mag = 250; 
    130           break; 
     111    if (getMetadataOptions().getMetadataLevel() == MetadataLevel.ALL) { 
     112      double timePerPixel = 0d; 
     113      int mode = 0, gain = 0, mag = 0; 
     114      double sampleVolts = 0d, tunnelCurrent = 0d; 
     115      if (version == 1) { 
     116        in.seek(in.length() - 40); 
     117        in.skipBytes(12); 
     118        xSize = in.readInt(); 
     119        ySize = in.readInt(); 
     120        zSize = in.readInt(); 
     121        timePerPixel = in.readShort() * 50; 
     122        mag = in.readShort(); 
     123 
     124        switch (mag) { 
     125          case 3: 
     126            mag = 10; 
     127            break; 
     128          case 4: 
     129            mag = 50; 
     130            break; 
     131          case 5: 
     132            mag = 250; 
     133            break; 
     134        } 
     135        xSize /= mag; 
     136        ySize /= mag; 
     137        zSize /= mag; 
     138 
     139        mode = in.readShort(); 
     140        gain = in.readShort(); 
     141        sampleVolts = in.readFloat() / 1000; 
     142        tunnelCurrent = in.readFloat(); 
    131143      } 
    132       xSize /= mag; 
    133       ySize /= mag; 
    134       zSize /= mag; 
     144      else if (version == 2) { 
     145        in.skipBytes(14); 
     146        xSize = in.readInt(); 
     147        ySize = in.readInt(); 
     148        zSize = in.readInt(); 
     149        mode = in.readShort(); 
     150        in.skipBytes(4); 
     151        gain = in.readShort(); 
     152        timePerPixel = in.readShort() * 50; 
     153        in.skipBytes(12); 
     154        sampleVolts = in.readFloat(); 
     155        tunnelCurrent = in.readFloat(); 
     156        addGlobalMeta("Force", in.readFloat()); 
     157      } 
    135158 
    136       mode = in.readShort(); 
    137       gain = in.readShort(); 
    138       sampleVolts = in.readFloat() / 1000; 
    139       tunnelCurrent = in.readFloat(); 
    140       pixelsOffset = 8; 
     159      addGlobalMeta("Version", version); 
     160      addGlobalMeta("Image mode", mode); 
     161      addGlobalMeta("Z gain", gain); 
     162      addGlobalMeta("Time per pixel (s)", timePerPixel); 
     163      addGlobalMeta("Sample volts", sampleVolts); 
     164      addGlobalMeta("Tunnel current", tunnelCurrent); 
     165      addGlobalMeta("Magnification", mag); 
    141166    } 
    142     else if (version == 2) { 
    143       in.skipBytes(14); 
    144       xSize = in.readInt(); 
    145       ySize = in.readInt(); 
    146       zSize = in.readInt(); 
    147       mode = in.readShort(); 
    148       in.skipBytes(4); 
    149       gain = in.readShort(); 
    150       timePerPixel = in.readShort() * 50; 
    151       in.skipBytes(12); 
    152       sampleVolts = in.readFloat(); 
    153       tunnelCurrent = in.readFloat(); 
    154       double force = in.readFloat(); 
    155  
    156       addGlobalMeta("Force", force); 
    157       pixelsOffset = 260; 
    158     } 
    159  
    160     addGlobalMeta("Version", version); 
    161     addGlobalMeta("Image mode", mode); 
    162     addGlobalMeta("Z gain", gain); 
    163     addGlobalMeta("Time per pixel (s)", timePerPixel); 
    164     addGlobalMeta("Sample volts", sampleVolts); 
    165     addGlobalMeta("Tunnel current", tunnelCurrent); 
    166     addGlobalMeta("Magnification", mag); 
    167167 
    168168    core[0].pixelType = FormatTools.UINT16; 
     
    178178    MetadataTools.setDefaultCreationDate(store, id, 0); 
    179179 
    180     store.setDimensionsPhysicalSizeX(xSize / getSizeX(), 0, 0); 
    181     store.setDimensionsPhysicalSizeY(ySize / getSizeY(), 0, 0); 
    182     store.setDimensionsPhysicalSizeZ(zSize / getSizeZ(), 0, 0); 
     180    if (getMetadataOptions().getMetadataLevel() == MetadataLevel.ALL) { 
     181      store.setDimensionsPhysicalSizeX(xSize / getSizeX(), 0, 0); 
     182      store.setDimensionsPhysicalSizeY(ySize / getSizeY(), 0, 0); 
     183      store.setDimensionsPhysicalSizeZ(zSize / getSizeZ(), 0, 0); 
     184    } 
    183185  } 
    184186 
  • trunk/components/bio-formats/src/loci/formats/in/CellomicsReader.java

    r6055 r6112  
    119119 
    120120    in.skipBytes(4); 
    121     int pixelWidth = in.readInt(); 
    122     int pixelHeight = in.readInt(); 
    123     int colorUsed = in.readInt(); 
    124     int colorImportant = in.readInt(); 
     121    int pixelWidth = 0, pixelHeight = 0; 
    125122 
    126     LOGGER.info("Populating metadata hashtable"); 
     123    if (getMetadataOptions().getMetadataLevel() == MetadataLevel.ALL) { 
     124      pixelWidth = in.readInt(); 
     125      pixelHeight = in.readInt(); 
     126      int colorUsed = in.readInt(); 
     127      int colorImportant = in.readInt(); 
    127128 
    128     addGlobalMeta("Image width", x); 
    129     addGlobalMeta("Image height", y); 
    130     addGlobalMeta("Number of planes", nPlanes); 
    131     addGlobalMeta("Bits per pixel", nBits); 
    132     addGlobalMeta("Compression", compression); 
    133     addGlobalMeta("Pixels per meter (X)", pixelWidth); 
    134     addGlobalMeta("Pixels per meter (Y)", pixelHeight); 
    135     addGlobalMeta("Color used", colorUsed); 
    136     addGlobalMeta("Color important", colorImportant); 
     129      LOGGER.info("Populating metadata hashtable"); 
     130 
     131      addGlobalMeta("Image width", x); 
     132      addGlobalMeta("Image height", y); 
     133      addGlobalMeta("Number of planes", nPlanes); 
     134      addGlobalMeta("Bits per pixel", nBits); 
     135      addGlobalMeta("Compression", compression); 
     136      addGlobalMeta("Pixels per meter (X)", pixelWidth); 
     137      addGlobalMeta("Pixels per meter (Y)", pixelHeight); 
     138      addGlobalMeta("Color used", colorUsed); 
     139      addGlobalMeta("Color important", colorImportant); 
     140    } 
    137141 
    138142    LOGGER.info("Populating core metadata"); 
     
    165169    MetadataTools.setDefaultCreationDate(store, id, 0); 
    166170 
    167     // physical dimensions are stored as pixels per meter - we want them 
    168     // in microns per pixel 
    169     double width = pixelWidth == 0 ? 0.0 : 1000000.0 / pixelWidth; 
    170     double height = pixelHeight == 0 ? 0.0 : 1000000.0 / pixelHeight; 
     171    if (getMetadataOptions().getMetadataLevel() == MetadataLevel.ALL) { 
     172      // physical dimensions are stored as pixels per meter - we want them 
     173      // in microns per pixel 
     174      double width = pixelWidth == 0 ? 0.0 : 1000000.0 / pixelWidth; 
     175      double height = pixelHeight == 0 ? 0.0 : 1000000.0 / pixelHeight; 
    171176 
    172     store.setDimensionsPhysicalSizeX(width, 0, 0); 
    173     store.setDimensionsPhysicalSizeY(height, 0, 0); 
     177      store.setDimensionsPhysicalSizeX(width, 0, 0); 
     178      store.setDimensionsPhysicalSizeY(height, 0, 0); 
     179    } 
    174180  } 
    175181 
Note: See TracChangeset for help on using the changeset viewer.