Changeset 6959


Ignore:
Timestamp:
09/20/10 11:16:47 (9 years ago)
Author:
melissa
Message:

Fixed well dimension parsing and calculation, so that the ScanR reader no longer assumes that wells form a square. Closes #550.

File:
1 edited

Legend:

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

    r6890 r6959  
    7575  private Hashtable<String, Integer> wellLabels = 
    7676    new Hashtable<String, Integer>(); 
     77  private Hashtable<Integer, Integer> wellNumbers = 
     78    new Hashtable<Integer, Integer>(); 
    7779  private String plateName; 
    7880  private Double pixelSize; 
     
    173175      metadataFiles.clear(); 
    174176      wellLabels.clear(); 
     177      wellNumbers.clear(); 
    175178      wellCount = 0; 
    176179      pixelSize = null; 
     
    299302 
    300303    if (wellRows * wellColumns != wellCount) { 
    301       if (wellCount <= 8) { 
    302         wellColumns = 2; 
    303         wellRows = 4; 
    304       } 
    305       else if (wellCount <= 96) { 
    306         wellColumns = 12; 
    307         wellRows = 8; 
    308       } 
    309       else if (wellCount <= 384) { 
    310         wellColumns = 24; 
    311         wellRows = 16; 
    312       } 
     304      adjustWellDimensions(); 
    313305    } 
    314306 
     
    317309    int nSlices = getSizeZ() == 0 ? 1 : getSizeZ(); 
    318310    int nTimepoints = getSizeT(); 
    319     int nWells = wellRows * wellColumns; 
     311    int nWells = wellCount; 
    320312    int nPos = fieldRows * fieldColumns; 
    321313    if (nPos == 0) nPos = 1; 
     
    341333    int realPosCount = 0; 
    342334    for (int well=0; well<nWells; well++) { 
    343       String wellPos = getBlock(well + 1, "W"); 
     335      int wellIndex = wellNumbers.get(well); 
     336      String wellPos = getBlock(wellIndex, "W"); 
    344337      int originalIndex = next; 
    345338 
     
    387380      } 
    388381 
    389       wellRows = uniqueRows.size(); 
    390       wellColumns = uniqueColumns.size(); 
    391       nWells = wellRows * wellColumns; 
     382      nWells = uniqueRows.size() * uniqueColumns.size(); 
     383      adjustWellDimensions(); 
    392384    } 
    393385    if (realPosCount < nPos) { 
     
    450442      int field = i % nFields; 
    451443      int well = i / nFields; 
    452  
    453       int wellRow = well / wellColumns; 
    454       int wellCol = well % wellColumns; 
     444      int wellIndex = wellNumbers.get(well) - 1; 
     445 
     446      int wellRow = wellIndex / wellColumns; 
     447      int wellCol = wellIndex % wellColumns; 
    455448 
    456449      store.setWellID(MetadataTools.createLSID("Well", 0, well), 0, well); 
     
    466459      store.setImageID(imageID, i); 
    467460 
    468       String name = "Well " + (well + 1) + ", Field " + (field +1) + " (Spot " + 
    469         (i + 1) + ")"; 
     461      String name = "Well " + (wellIndex + 1) + ", Field " + (field + 1) + 
     462        " (Spot " + (i + 1) + ")"; 
    470463      store.setImageName(name, i); 
    471464    } 
     
    526519        } 
    527520        else if (key.equals("timeloop count")) { 
    528           core[0].sizeT = Integer.parseInt(value) + 1; 
     521          core[0].sizeT = Integer.parseInt(value); 
     522          if (getSizeT() == 0) core[0].sizeT = 1; 
    529523        } 
    530524        else if (key.equals("name")) { 
     
    546540          if (Character.isDigit(value.charAt(0))) { 
    547541            wellIndex = value; 
     542            wellNumbers.put(new Integer(wellCount), new Integer(value)); 
    548543            wellCount++; 
    549544          } 
     
    574569  } 
    575570 
     571  private void adjustWellDimensions() { 
     572    if (wellCount <= 8) { 
     573      wellColumns = 2; 
     574      wellRows = 4; 
     575    } 
     576    else if (wellCount <= 96) { 
     577      wellColumns = 12; 
     578      wellRows = 8; 
     579    } 
     580    else if (wellCount <= 384) { 
     581      wellColumns = 24; 
     582      wellRows = 16; 
     583    } 
     584  } 
     585 
    576586} 
Note: See TracChangeset for help on using the changeset viewer.