Changeset 3462


Ignore:
Timestamp:
12/11/07 10:04:46 (12 years ago)
Author:
melissa
Message:

Added support for multi-series datasets and fixed a bug with single-timepoint datasets.

File:
1 edited

Legend:

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

    r3427 r3462  
    6464    FormatTools.checkBufferSize(this, buf.length); 
    6565 
    66     int plane = core.sizeX[0] * core.sizeY[0] * 
    67       FormatTools.getBytesPerPixel(core.pixelType[0]); 
    68  
    69     int div = core.sizeZ[0] * core.sizeT[0]; 
    70     int fileIndex = no / div; 
     66    int plane = core.sizeX[series] * core.sizeY[series] * 
     67      FormatTools.getBytesPerPixel(core.pixelType[series]); 
     68 
     69    int div = core.sizeZ[series] * core.sizeT[series]; 
     70    int fileIndex = (series * core.sizeC[series]) + no / div; 
    7171    int planeIndex = no % div; 
    7272 
    7373    String file = (String) files.get(fileIndex); 
    7474    RandomAccessStream s = new RandomAccessStream(file); 
    75     s.skipBytes(374); 
     75    s.seek(374); 
    7676    while (s.read() != (byte) 0xf0); 
    77     s.skipBytes((plane + 164) * planeIndex + 1); 
     77    s.skipBytes(1); 
     78    if (s.readInt() == 0) s.skipBytes(4 + ((plane + 164) * planeIndex)); 
     79    else { 
     80      if (planeIndex == 0) s.seek(s.getFilePointer() - 4); 
     81      else s.skipBytes((plane + 164) * planeIndex - 4); 
     82    } 
    7883    s.read(buf); 
    7984    s.close(); 
     
    131136    StringTokenizer st = new StringTokenizer(s, "\n"); 
    132137    String token = null, key = null, value = null; 
     138    int numSeries = 0; 
    133139    while (st.hasMoreTokens()) { 
    134140      token = st.nextToken().trim(); 
     
    169175            core.sizeC[0]++; 
    170176          } 
     177          else if (key.startsWith("Microscope XY")) { 
     178            numSeries++; 
     179          } 
    171180          addMeta(key, value); 
    172181        } 
     
    187196    if (core.sizeT[0] == 0) { 
    188197      core.sizeT[0] = core.imageCount[0] / (core.sizeZ[0] * core.sizeC[0]); 
     198      if (core.sizeT[0] == 0) core.sizeT[0] = 1; 
    189199    } 
    190200    if (core.imageCount[0] == 0) { 
    191201      core.imageCount[0] = core.sizeZ[0] * core.sizeC[0] * core.sizeT[0]; 
    192202    } 
    193     core.rgb[0] = false; 
    194     core.currentOrder[0] = "XYZTC"; 
    195     core.interleaved[0] = false; 
    196     core.littleEndian[0] = true; 
    197     core.indexed[0] = false; 
    198     core.falseColor[0] = false; 
    199     core.metadataComplete[0] = true; 
     203 
     204    if (numSeries > 1) { 
     205      int x = core.sizeX[0]; 
     206      int y = core.sizeY[0]; 
     207      int z = core.sizeZ[0]; 
     208      int c = core.sizeC[0] / numSeries; 
     209      int t = core.sizeT[0]; 
     210      int count = z * c * t; 
     211      int ptype = core.pixelType[0]; 
     212      core = new CoreMetadata(numSeries); 
     213      Arrays.fill(core.sizeX, x); 
     214      Arrays.fill(core.sizeY, y); 
     215      Arrays.fill(core.sizeZ, z); 
     216      Arrays.fill(core.sizeC, c); 
     217      Arrays.fill(core.sizeT, t); 
     218      Arrays.fill(core.imageCount, count); 
     219      Arrays.fill(core.pixelType, ptype); 
     220    } 
     221 
     222    Arrays.fill(core.rgb, false); 
     223    Arrays.fill(core.currentOrder, "XYZTC"); 
     224    Arrays.fill(core.interleaved, false); 
     225    Arrays.fill(core.littleEndian, true); 
     226    Arrays.fill(core.indexed, false); 
     227    Arrays.fill(core.falseColor, false); 
     228    Arrays.fill(core.metadataComplete, true); 
    200229 
    201230    // find pixels files - we think there is one channel per file 
     
    208237    File f = new File(currentId).getAbsoluteFile(); 
    209238 
    210     for (int i=0; i<core.sizeC[0]; i++) { 
     239    if (numSeries == 0) numSeries = 1; 
     240    for (int i=0; i<core.sizeC[0]*numSeries; i++) { 
    211241      files.add((f.exists() ? f.getParent() + File.separator : "") + base + 
    212242        " " + (i + 1) + ".xys"); 
Note: See TracChangeset for help on using the changeset viewer.