Changeset 3368


Ignore:
Timestamp:
11/14/07 11:22:07 (12 years ago)
Author:
melissa
Message:
  • Removed several hacks that were designed to correct for POI deficiencies.
  • 16 bit RGB images (e.g. zeiss-zvi/cecilia/*) now display correctly
File:
1 edited

Legend:

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

    r3366 r3368  
    103103  private int tileRows, tileColumns; 
    104104  private boolean isJPEG; 
    105   private int alphaIndex; 
    106  
    107   // -- debug -- 
    108  
    109   private Vector directories = new Vector(); 
    110105 
    111106  // -- Constructor -- 
     
    138133    FormatTools.checkPlaneNumber(this, no); 
    139134    FormatTools.checkBufferSize(this, buf.length); 
    140  
    141     /* 
    142     int[] zct = FormatTools.getZCTCoords(this, no); 
    143     if (alphaIndex != -1) { 
    144       if ((alphaIndex == 3 && (zct[1] == 0 || zct[1] == 2)) || 
    145         (alphaIndex == 0 && (zct[1] == 1 || zct[1] == 3))) 
    146       { 
    147         zct[1] = 2 - zct[1]; 
    148         no = FormatTools.getIndex(this, zct[0], zct[1], zct[2]); 
    149       } 
    150     } 
    151     */ 
    152135 
    153136    try { 
     
    221204 
    222205      if (bpp > 6) bpp = 1; 
    223       if (bpp == 3) { 
     206      if (bpp == 3 || bpp == 6) { 
    224207        // reverse bytes in groups of 3 to account for BGR storage 
    225         for (int i=0; i<buf.length; i+=3) { 
    226           byte b = buf[i + 2]; 
    227           buf[i + 2] = buf[i]; 
    228           buf[i] = b; 
     208        byte[] bb = new byte[bpp / 3]; 
     209        int bp = bpp / 3; 
     210        for (int i=0; i<buf.length; i+=bpp) { 
     211          System.arraycopy(buf, i + 2*bp, bb, 0, bp); 
     212          System.arraycopy(buf, i, buf, i + 2*bp, bp); 
     213          System.arraycopy(bb, 0, buf, i, bp); 
    229214        } 
    230215      } 
     
    440425    } 
    441426 
    442     // correct emission/excitation wavelengths, if necessary 
    443  
    444     if (metadata.size() > 0) { 
    445       // HACK 
    446       String lastEM = 
    447         (String) getMeta("Emission Wavelength " + (core.sizeC[0] - 1)); 
    448       String nextToLastEM = 
    449         (String) getMeta("Emission Wavelength " + (core.sizeC[0] - 2)); 
    450       if (lastEM == null || nextToLastEM == null || 
    451         lastEM.equals(nextToLastEM)) 
    452       { 
    453         String lastDye = (String) getMeta("Reflector " + (core.sizeC[0] - 1)); 
    454         String nextToLastDye = 
    455           (String) getMeta("Reflector " + (core.sizeC[0] - 2)); 
    456         if (lastDye == null) lastDye = ""; 
    457         if (nextToLastDye == null) nextToLastDye = ""; 
    458  
    459         lastDye = DataTools.stripString(lastDye); 
    460         nextToLastDye = DataTools.stripString(nextToLastDye); 
    461  
    462         if (nextToLastDye.indexOf("Rhodamine") != -1) { 
    463           addMeta("Emission Wavelength " + (core.sizeC[0] - 2), "580"); 
    464           addMeta("Excitation Wavelength " + (core.sizeC[0] - 2), "540"); 
    465         } 
    466         else if (nextToLastDye.indexOf("DAPI") != -1) { 
    467           addMeta("Emission Wavelength " + (core.sizeC[0] - 2), "461"); 
    468           addMeta("Excitation Wavelength " + (core.sizeC[0] - 2), "359"); 
    469         } 
    470         else if (nextToLastDye.startsWith("Alexa Fluor")) { 
    471           addMeta("Emission Wavelength " + (core.sizeC[0] - 2), "519"); 
    472           addMeta("Excitation Wavelength " + (core.sizeC[0] - 2), "495"); 
    473         } 
    474         else if (nextToLastDye.indexOf("Alexa Fluor") != -1) { 
    475           addMeta("Emission Wavelength " + (core.sizeC[0] - 2), "668"); 
    476           addMeta("Excitation Wavelength " + (core.sizeC[0] - 2), "650"); 
    477         } 
    478  
    479         if (lastDye.indexOf("Rhodamine") != -1) { 
    480           addMeta("Emission Wavelength " + (core.sizeC[0] - 1), "580"); 
    481           addMeta("Excitation Wavelength " + (core.sizeC[0] - 1), "540"); 
    482         } 
    483         else if (lastDye.indexOf("DAPI") != -1) { 
    484           addMeta("Emission Wavelength " + (core.sizeC[0] - 1), "461"); 
    485           addMeta("Excitation Wavelength " + (core.sizeC[0] - 1), "359"); 
    486         } 
    487         else if (lastDye.startsWith("Alexa Fluor")) { 
    488           addMeta("Emission Wavelength " + (core.sizeC[0] - 1), "519"); 
    489           addMeta("Excitation Wavelength " + (core.sizeC[0] - 1), "495"); 
    490         } 
    491         else if (lastDye.indexOf("Alexa Fluor") != -1) { 
    492           addMeta("Emission Wavelength " + (core.sizeC[0] - 1), "668"); 
    493           addMeta("Excitation Wavelength " + (core.sizeC[0] - 1), "650"); 
    494         } 
    495       } 
    496     } 
    497  
    498427    try { 
    499428      initMetadata(); 
     
    504433    catch (IOException exc) { 
    505434      if (debug) trace(exc); 
    506     } 
    507  
    508     // remove extra (invalid) metadata 
    509  
    510     String[] keys = (String[]) metadata.keySet().toArray(new String[0]); 
    511     for (int i=0; i<keys.length; i++) { 
    512       String n = keys[i]; 
    513       if (n.indexOf(" ") != -1) { 
    514         n = n.substring(n.lastIndexOf(" ") + 1); 
    515         try { 
    516           int ndx = Integer.parseInt(n); 
    517           if (ndx >= core.sizeC[0]) metadata.remove(keys[i]); 
    518         } 
    519         catch (NumberFormatException e) { } 
    520       } 
    521435    } 
    522436  } 
     
    626540    Iterator iter = (Iterator) r.getVar("iter"); 
    627541    String dirName = (String) r.getVar("dirName"); 
    628     directories.add(dirName); 
    629542    while (iter.hasNext()) { 
    630543      r.setVar("entry", iter.next()); 
     
    637550 
    638551      if (isInstance)  { 
    639         status("Parsing embedded folder (" + (depth + 1) + ")"); 
    640552        parseDir(depth + 1, r.getVar("entry")); 
    641553      } 
    642554      else if (isDocument) { 
    643         status("Parsing embedded file (" + depth + ")"); 
    644555        r.exec("entryName = entry.getName()"); 
    645556        if (debug) { 
     
    797708      } 
    798709    } 
    799     directories.remove(dirName); 
    800710  } 
    801711 
     
    932842      } 
    933843 
    934       if (metadata.get(key) != null || metadata.get(key + " 0") != null) { 
    935         if (metadata.get(key) != null) { 
    936           Object v = metadata.remove(key); 
    937           metadata.put(key + " 0", v); 
    938         } 
    939  
    940         int ndx = 0; 
    941         while (metadata.get(key + " " + ndx) != null) ndx++; 
    942         key += " " + ndx; 
    943       } 
    944  
    945844      if (key.indexOf("ImageTile") != -1) isTiled = true; 
    946       addMeta(key, value); 
     845      if (cIndex != -1) addMeta(key + " " + cIndex, value); 
     846      else addMeta(key, value); 
    947847    } 
    948848  } 
Note: See TracChangeset for help on using the changeset viewer.