Changeset 4234


Ignore:
Timestamp:
07/23/08 11:36:13 (11 years ago)
Author:
melissa
Message:

Fixed axis size calculations.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/in/PCIReader.java

    r4205 r4234  
    4545  private Vector imageFiles; 
    4646  private POITools poi; 
     47  private Vector timestamps; 
    4748 
    4849  // -- Constructor -- 
     
    7374 
    7475    RandomAccessStream s = poi.getDocumentStream((String) imageFiles.get(no)); 
     76    int planeSize = getSizeX() * getSizeY() * getRGBChannelCount() * 
     77      FormatTools.getBytesPerPixel(getPixelType()); 
     78    s.skipBytes((int) (s.length() - planeSize)); 
    7579    DataTools.readPlane(s, x, y, w, h, this, buf); 
    7680    s.close(); 
     
    8589    super.close(); 
    8690    imageFiles = null; 
     91    timestamps = null; 
    8792    if (poi != null) poi.close(); 
    8893    poi = null; 
     
    98103 
    99104    imageFiles = new Vector(); 
     105    timestamps = new Vector(); 
    100106 
    101107    poi = new POITools(Location.getMappedId(currentId)); 
     
    140146        } 
    141147      } 
    142       else if (relativePath.startsWith("Bitmap")) { 
     148      else if (relativePath.startsWith("Bitmap") || relativePath.equals("Data")) 
     149      { 
    143150        String parent = name.substring(0, name.lastIndexOf(File.separator)); 
    144151        int space = parent.lastIndexOf(" ") + 1; 
     152        if (space >= parent.length()) continue; 
    145153        int num = Integer.parseInt(parent.substring(space, 
    146154          parent.indexOf(File.separator, space))) - 1; 
     
    167175      else if (relativePath.indexOf("Image_Depth") != -1) { 
    168176        byte[] b = poi.getDocumentBytes(name, 8); 
    169         int bits = (int) (DataTools.bytesToLong(b, 0, false) & 0xff) >> 2; 
     177        int bits = 
     178          (int) Double.longBitsToDouble(DataTools.bytesToLong(b, 0, true)); 
    170179        while (bits % 8 != 0 || bits == 0) bits++; 
    171180        switch (bits) { 
     
    179188            core.pixelType[0] = FormatTools.UINT32; 
    180189            break; 
     190          case 48: 
     191            core.pixelType[0] = FormatTools.UINT16; 
     192            break; 
    181193          default: 
    182194            throw new FormatException("Unsupported bits per pixel : " + bits); 
     
    185197      else if (relativePath.indexOf("Image_Height") != -1 && getSizeY() == 0) { 
    186198        byte[] b = poi.getDocumentBytes(name, 8); 
    187         byte val = b[6]; 
    188         byte mul = (byte) (val << 2); 
    189         if (mul == 0) mul = 32; 
    190         core.sizeY[0] = mul * 16; 
     199        core.sizeY[0] = 
     200          (int) Double.longBitsToDouble(DataTools.bytesToLong(b, 0, true)); 
    191201      } 
    192202      else if (relativePath.indexOf("Image_Width") != -1 && getSizeX() == 0) { 
    193203        byte[] b = poi.getDocumentBytes(name, 8); 
    194         byte val = b[6]; 
    195         byte mul = (byte) (val << 2); 
    196         if (mul == 0) mul = 32; 
    197         core.sizeX[0] = mul * 16; 
     204        core.sizeX[0] = 
     205          (int) Double.longBitsToDouble(DataTools.bytesToLong(b, 0, true)); 
     206      } 
     207      else if (relativePath.indexOf("Time_From_Start") != -1) { 
     208        byte[] b = poi.getDocumentBytes(name, 8); 
     209        double v = Double.longBitsToDouble(DataTools.bytesToLong(b, 0, true)); 
     210        if (!timestamps.contains(new Double(v))) timestamps.add(new Double(v)); 
    198211      } 
    199212    } 
     
    201214    if (getSizeC() == 0) core.sizeC[0] = 1; 
    202215 
    203     core.sizeZ[0] = getImageCount(); 
    204     core.sizeT[0] = 1; 
     216    if (timestamps.size() > 0) { 
     217      core.sizeZ[0] = getImageCount() / timestamps.size(); 
     218      core.sizeT[0] = timestamps.size(); 
     219    } 
     220    if (timestamps.size() == 0 || getSizeZ() * getSizeT() != getImageCount()) { 
     221      core.sizeZ[0] = getImageCount(); 
     222      core.sizeT[0] = 1; 
     223    } 
    205224    core.rgb[0] = getSizeC() > 1; 
    206225    core.interleaved[0] = false; 
    207     core.currentOrder[0] = "XYCZT"; 
     226    core.currentOrder[0] = "XYCTZ"; 
    208227    core.littleEndian[0] = true; 
    209228    core.indexed[0] = false; 
Note: See TracChangeset for help on using the changeset viewer.