Changeset 2916


Ignore:
Timestamp:
06/27/07 15:41:39 (12 years ago)
Author:
melissa
Message:

Added multi-series support.

File:
1 edited

Legend:

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

    r2811 r2916  
    4949 
    5050  /** Constructs a new Slidebook reader. */ 
    51   public SlidebookReader() { super("Intelligent Imaging Slidebook", "sld"); } 
     51  public SlidebookReader() { super("Olympus Slidebook", "sld"); } 
    5252 
    5353  // -- IFormatReader API methods -- 
     
    6363  public byte[] openBytes(int no) throws FormatException, IOException { 
    6464    FormatTools.assertId(currentId, true, 1); 
    65     byte[] buf = new byte[core.sizeX[0] * core.sizeY[0] * 2]; 
     65    byte[] buf = new byte[core.sizeX[series] * core.sizeY[series] * 2]; 
    6666    return openBytes(no, buf); 
    6767  } 
     
    7575      throw new FormatException("Invalid image number: " + no); 
    7676    } 
    77     if (buf.length < core.sizeX[0] * core.sizeY[0] * 2) { 
     77    if (buf.length < core.sizeX[series] * core.sizeY[series] * 2) { 
    7878      throw new FormatException("Buffer too small."); 
    7979    } 
    8080 
    81     int plane = core.sizeX[0] * core.sizeY[0] * 2; 
     81    int plane = core.sizeX[series] * core.sizeY[series] * 2; 
    8282   
    8383    long relativeOffset = plane * no; 
    84     int ndx = 0; 
    85     long bytes = 0; 
    86  
    87     int oldNo = no; 
    88     while (relativeOffset - bytes > 4) { 
    89       long len = ((Long) pixelLengths.get(ndx)).longValue(); 
    90       double planes = (double) len / plane; 
    91       if ((int) planes < planes) len += 2;  
    92        
    93       if (bytes + len <= relativeOffset) { 
    94         ndx++; 
    95         no -= (len / plane);  
    96       } 
    97       bytes += len;  
    98     } 
    99  
    100     long offset = ((Long) pixelOffsets.get(ndx)).longValue() + plane * no; 
     84    long offset = ((Long) pixelOffsets.get(series)).longValue() + plane * no; 
    10185    in.seek(offset);  
    10286    in.read(buf); 
     
    144128        in.seek(fp); 
    145129        int len = in.read(); 
    146         if (len > 0 && len < 32) {  
     130        if (len > 0 && len <= 32) {  
    147131          byte[] b = new byte[len]; 
    148132          in.read(b); 
     
    170154            in.skipBytes(52);  
    171155          }  
     156        } 
     157        else if (s != null && s.indexOf("Decon") != -1) { 
     158          in.seek(fp); 
     159          while (in.read() != ']'); 
    172160        } 
    173161        else { 
     
    207195    } 
    208196 
     197    core = new CoreMetadata(pixelOffsets.size() - 1); 
     198 
    209199    status("Determining dimensions"); 
    210200 
     
    298288    if (core.sizeY[0] == 0) core.sizeY[0] = 512; 
    299289  
    300     core.imageCount[0] = core.sizeC[0] * core.sizeZ[0] * core.sizeT[0]; 
    301     
    302     core.currentOrder[0] = "XYZCT";  
    303     core.pixelType[0] = FormatTools.UINT16;  
    304     core.littleEndian[0] = true;  
     290    for (int i=0; i<core.sizeX.length; i++) { 
     291      core.sizeX[i] = core.sizeX[0]; 
     292      core.sizeY[i] = core.sizeY[0]; 
     293      core.currentOrder[i] = "XYZCT";  
     294      core.pixelType[i] = FormatTools.UINT16;  
     295      core.littleEndian[i] = true;  
     296     
     297      core.sizeC[i] = core.sizeC[0]; 
     298      core.sizeT[i] = core.sizeT[0]; 
     299      long len = ((Long) pixelLengths.get(i)).longValue(); 
     300      core.sizeZ[i] =  
     301        (int) (len / (core.sizeX[i] * core.sizeY[i] * 2 * core.sizeC[i])); 
     302        
     303      core.imageCount[i] = core.sizeC[i] * core.sizeZ[i] * core.sizeT[i];  
     304    }  
    305305  } 
    306306 
Note: See TracChangeset for help on using the changeset viewer.