Changeset 6995


Ignore:
Timestamp:
09/28/10 10:48:34 (9 years ago)
Author:
melissa
Message:

Merged recent ScanR changes: r6720, r6810, r6838, r6959, and r6967.

Location:
branches/4.2
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/4.2

  • branches/4.2/components/bio-formats/src/loci/formats/in

  • branches/4.2/components/bio-formats/src/loci/formats/in/ScanrReader.java

    r6910 r6995  
    2525 
    2626import java.io.IOException; 
     27import java.nio.ByteOrder; 
    2728import java.util.Hashtable; 
    2829import java.util.Vector; 
    2930 
     31import loci.common.ByteArrayHandle; 
    3032import loci.common.DataTools; 
    3133import loci.common.Location; 
     
    5052 * 
    5153 * <dl><dt><b>Source code:</b></dt> 
    52  * <dd><a href="https://skyking.microscopy.wisc.edu/trac/java/browser/trunk/components/bio-formats/src/loci/formats/in/ScanrReader.java">Trac</a>, 
    53  * <a href="https://skyking.microscopy.wisc.edu/svn/java/trunk/components/bio-formats/src/loci/formats/in/ScanrReader.java">SVN</a></dd></dl> 
     54 * <dd><a href="http://dev.loci.wisc.edu/trac/java/browser/trunk/components/bio-formats/src/loci/formats/in/ScanrReader.java">Trac</a>, 
     55 * <a href="http://dev.loci.wisc.edu/svn/java/trunk/components/bio-formats/src/loci/formats/in/ScanrReader.java">SVN</a></dd></dl> 
    5456 * 
    5557 * @author Melissa Linkert melissa at glencoesoftware.com 
     
    6264  private static final String EXPERIMENT_FILE = "experiment_descriptor.dat"; 
    6365  private static final String ACQUISITION_FILE = "AcquisitionLog.dat"; 
     66  private static final String[] METADATA_SUFFIXES = new String[] {"dat", "xml"}; 
    6467 
    6568  // -- Fields -- 
     
    7275  private Hashtable<String, Integer> wellLabels = 
    7376    new Hashtable<String, Integer>(); 
     77  private Hashtable<Integer, Integer> wellNumbers = 
     78    new Hashtable<Integer, Integer>(); 
    7479  private String plateName; 
     80  private Double pixelSize; 
    7581 
    7682  private String[] tiffs; 
     
    169175      metadataFiles.clear(); 
    170176      wellLabels.clear(); 
     177      wellNumbers.clear(); 
    171178      wellCount = 0; 
     179      pixelSize = null; 
    172180    } 
    173181  } 
     
    186194      reader.openBytes(0, buf, x, y, w, h); 
    187195      reader.close(); 
     196 
     197      // mask out the sign bit 
     198      ByteArrayHandle pixels = new ByteArrayHandle(buf); 
     199      pixels.setOrder( 
     200        isLittleEndian() ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); 
     201      for (int i=0; i<buf.length; i+=2) { 
     202        pixels.seek(i); 
     203        short value = pixels.readShort(); 
     204        value = (short) (value & 0xfff); 
     205        pixels.seek(i); 
     206        pixels.writeShort(value); 
     207      } 
     208      buf = pixels.getBytes(); 
     209      pixels.close(); 
    188210    } 
    189211 
     
    244266    for (String file : list) { 
    245267      Location f = new Location(dir, file); 
    246       if (!f.isDirectory()) { 
     268      if (!f.isDirectory() && checkSuffix(file, METADATA_SUFFIXES)) { 
    247269        metadataFiles.add(f.getAbsolutePath()); 
    248270      } 
     
    279301    wellColumns = uniqueColumns.size(); 
    280302 
    281     if (wellRows * wellColumns == 0) { 
    282       if (wellCount <= 96) { 
    283         wellColumns = 12; 
    284       } 
    285       else if (wellCount <= 384) { 
    286         wellColumns = 24; 
    287       } 
    288       wellRows = wellCount / wellColumns; 
    289       if (wellRows * wellColumns < wellCount) wellRows++; 
     303    if (wellRows * wellColumns != wellCount) { 
     304      adjustWellDimensions(); 
    290305    } 
    291306 
     
    294309    int nSlices = getSizeZ() == 0 ? 1 : getSizeZ(); 
    295310    int nTimepoints = getSizeT(); 
    296     int nWells = wellRows * wellColumns; 
     311    int nWells = wellCount; 
    297312    int nPos = fieldRows * fieldColumns; 
    298313    if (nPos == 0) nPos = 1; 
     
    307322    } 
    308323    else dir = dataDir; 
    309     if (nTimepoints == 0) { 
     324    if (nTimepoints == 0 || 
     325      list.length < nTimepoints * nChannels * nSlices * nWells * nPos) 
     326    { 
    310327      nTimepoints = list.length / (nChannels * nWells * nPos * nSlices); 
    311328      if (nTimepoints == 0) nTimepoints = 1; 
     
    318335    int realPosCount = 0; 
    319336    for (int well=0; well<nWells; well++) { 
    320       String wellPos = getBlock(well + 1, "W"); 
     337      int wellIndex = wellNumbers.get(well); 
     338      String wellPos = getBlock(wellIndex, "W"); 
    321339      int originalIndex = next; 
    322340 
     
    346364        if (posIndex != next) realPosCount++; 
    347365      } 
    348       if (next == originalIndex) { 
     366      if (next == originalIndex && well < keys.length) { 
    349367        wellLabels.remove(keys[well]); 
    350368      } 
     
    364382      } 
    365383 
    366       wellRows = uniqueRows.size(); 
    367       wellColumns = uniqueColumns.size(); 
    368       nWells = wellRows * wellColumns; 
     384      nWells = uniqueRows.size() * uniqueColumns.size(); 
     385      adjustWellDimensions(); 
    369386    } 
    370387    if (realPosCount < nPos) { 
     
    385402        pixelType = FormatTools.UINT8; 
    386403        break; 
    387       case FormatTools.UINT8: 
    388         pixelType = FormatTools.INT8; 
    389         break; 
    390404      case FormatTools.INT16: 
    391405        pixelType = FormatTools.UINT16; 
    392         break; 
    393       case FormatTools.UINT16: 
    394         pixelType = FormatTools.INT16; 
    395406        break; 
    396407    } 
     
    418429      core[i].dimensionOrder = "XYCTZ"; 
    419430      core[i].imageCount = nSlices * nTimepoints * nChannels; 
     431      core[i].bitsPerPixel = 12; 
    420432    } 
    421433 
     
    432444      int field = i % nFields; 
    433445      int well = i / nFields; 
    434  
    435       int wellRow = well / wellColumns; 
    436       int wellCol = well % wellColumns; 
     446      int wellIndex = wellNumbers.get(well) - 1; 
     447 
     448      int wellRow = wellIndex / wellColumns; 
     449      int wellCol = wellIndex % wellColumns; 
    437450 
    438451      store.setWellID(MetadataTools.createLSID("Well", 0, well), 0, well); 
     
    448461      store.setImageID(imageID, i); 
    449462 
    450       String name = "Well " + (well + 1) + ", Field " + (field +1) + " (Spot " + 
    451         (i + 1) + ")"; 
     463      String name = "Well " + (wellIndex + 1) + ", Field " + (field + 1) + 
     464        " (Spot " + (i + 1) + ")"; 
    452465      store.setImageName(name, i); 
    453466    } 
     
    459472        for (int c=0; c<getSizeC(); c++) { 
    460473          store.setChannelName(channelNames.get(c), i, c); 
     474        } 
     475        if (pixelSize != null) { 
     476          store.setPixelsPhysicalSizeX(pixelSize, i); 
     477          store.setPixelsPhysicalSizeY(pixelSize, i); 
    461478        } 
    462479      } 
     
    502519        else if (key.equals("timeloop real")) { 
    503520          core[0].sizeT = Integer.parseInt(value); 
     521        } 
     522        else if (key.equals("timeloop count")) { 
     523          core[0].sizeT = Integer.parseInt(value) + 1; 
    504524        } 
    505525        else if (key.equals("name")) { 
     
    521541          if (Character.isDigit(value.charAt(0))) { 
    522542            wellIndex = value; 
     543            wellNumbers.put(new Integer(wellCount), new Integer(value)); 
    523544            wellCount++; 
    524545          } 
     
    527548          } 
    528549        } 
     550        else if (key.equals("conversion factor um/pixel")) { 
     551          pixelSize = new Double(value); 
     552        } 
    529553      } 
    530554    } 
     
    546570  } 
    547571 
     572  private void adjustWellDimensions() { 
     573    if (wellCount <= 8) { 
     574      wellColumns = 2; 
     575      wellRows = 4; 
     576    } 
     577    else if (wellCount <= 96) { 
     578      wellColumns = 12; 
     579      wellRows = 8; 
     580    } 
     581    else if (wellCount <= 384) { 
     582      wellColumns = 24; 
     583      wellRows = 16; 
     584    } 
     585  } 
     586 
    548587} 
  • branches/4.2/components/bio-formats/src/loci/formats/meta

  • branches/4.2/components/bio-formats/src/loci/formats/ome

  • branches/4.2/components/bio-formats/src/loci/formats/tiff

  • branches/4.2/components/bio-formats/test/loci/formats/utests

  • branches/4.2/components/loci-plugins

  • branches/4.2/components/loci-plugins/src/loci/plugins

  • branches/4.2/components/loci-plugins/src/loci/plugins/in/Calibrator.java

  • branches/4.2/components/ome-xml

Note: See TracChangeset for help on using the changeset viewer.