Changeset 6687


Ignore:
Timestamp:
07/10/10 09:44:20 (9 years ago)
Author:
melissa
Message:

Fixed channel data is parsed from Leica LIF files that have had one or more channels removed after acquisition.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.1/components/bio-formats/src/loci/formats/in/LeicaHandler.java

    r6111 r6687  
    8787  private Vector<Detector> detectors = new Vector<Detector>(); 
    8888  private Vector<Laser> lasers = new Vector<Laser>(); 
     89  private Hashtable<String, Channel> channels = 
     90    new Hashtable<String, Channel>(); 
    8991 
    9092  // -- Constructor -- 
     
    186188      } 
    187189 
     190      String[] keys = channels.keySet().toArray(new String[0]); 
     191      Arrays.sort(keys); 
     192      for (int c=0; c<keys.length; c++) { 
     193        Channel ch = channels.get(keys[c]); 
     194        store.setDetectorSettingsDetector(ch.detector, numDatasets, c); 
     195        store.setLogicalChannelExWave(ch.exWave, numDatasets, c); 
     196        store.setLogicalChannelName(ch.name, numDatasets, c); 
     197        store.setDetectorSettingsGain(ch.gain, numDatasets, c); 
     198      } 
     199 
     200      channels.clear(); 
    188201      xPos.clear(); 
    189202      yPos.clear(); 
     
    450463        } 
    451464        catch (NumberFormatException e) { } 
     465        Channel channel = channels.get(numDatasets + "-" + c); 
     466        if (channel == null) channel = new Channel(); 
    452467        if (id.endsWith("ExposureTime")) { 
    453468          store.setPlaneTimingExposureTime(new Float(value), 
     
    455470        } 
    456471        else if (id.endsWith("Gain")) { 
    457           store.setDetectorSettingsGain(new Float(value), numDatasets, c); 
     472          channel.gain = new Float(value); 
    458473 
    459474          String detectorID = 
    460475            MetadataTools.createLSID("Detector", numDatasets, 0); 
    461476 
    462           store.setDetectorSettingsDetector(detectorID, numDatasets, c); 
     477          channel.detector = detectorID; 
    463478          store.setDetectorID(detectorID, numDatasets, 0); 
    464479          store.setDetectorType("CCD", numDatasets, 0); 
    465480        } 
    466481        else if (id.endsWith("WaveLength")) { 
    467           store.setLogicalChannelExWave(new Integer(value), numDatasets, c); 
     482          channel.exWave = new Integer(value); 
    468483        } 
    469484        // NB: "UesrDefName" is not a typo. 
    470485        else if (id.endsWith("UesrDefName") && !value.equals("None")) { 
    471           store.setLogicalChannelName(value, numDatasets, c); 
    472         } 
     486          channel.name = value; 
     487        } 
     488        channels.put(numDatasets + "-" + c, channel); 
    473489      } 
    474490    } 
     
    775791      multiBands.add(m); 
    776792    } 
     793    else if (qName.equals("ChannelInfo")) { 
     794      int index = Integer.parseInt(attributes.getValue("Index")); 
     795      channels.remove(numDatasets + "-" + index); 
     796    } 
    777797    else count = 0; 
    778798    storeSeriesHashtable(numDatasets, h); 
     
    964984  } 
    965985 
     986  class Channel { 
     987    public String detector; 
     988    public Float gain; 
     989    public Integer exWave; 
     990    public String name; 
     991  } 
     992 
    966993} 
  • branches/4.2/components/bio-formats/src/loci/formats/in/LeicaHandler.java

    r6663 r6687  
    104104  private Vector<Detector> detectors = new Vector<Detector>(); 
    105105  private Vector<Laser> lasers = new Vector<Laser>(); 
     106  private Hashtable<String, Channel> channels = 
     107    new Hashtable<String, Channel>(); 
    106108 
    107109  private MetadataLevel level; 
     
    208210          store.setDetectorSettingsID(id, numDatasets, c); 
    209211        } 
    210       } 
    211  
     212 
     213        String[] keys = channels.keySet().toArray(new String[0]); 
     214        Arrays.sort(keys); 
     215        for (int c=0; c<keys.length; c++) { 
     216          Channel ch = channels.get(keys[c]); 
     217          store.setDetectorSettingsID(ch.detector, numDatasets, c); 
     218          store.setChannelExcitationWavelength(ch.exWave, numDatasets, c); 
     219          store.setChannelName(ch.name, numDatasets, c); 
     220          store.setDetectorSettingsGain(ch.gain, numDatasets, c); 
     221        } 
     222      } 
     223 
     224      channels.clear(); 
    212225      xPos.clear(); 
    213226      yPos.clear(); 
     
    490503        } 
    491504        catch (NumberFormatException e) { } 
     505        Channel channel = channels.get(numDatasets + "-" + c); 
     506        if (channel == null) channel = new Channel(); 
    492507        if (id.endsWith("ExposureTime")) { 
    493508          store.setPlaneExposureTime(new Double(value), numDatasets, c); 
    494509        } 
    495510        else if (id.endsWith("Gain")) { 
    496           store.setDetectorSettingsGain(new Double(value), numDatasets, c); 
     511          channel.gain = new Double(value); 
    497512 
    498513          String detectorID = 
    499514            MetadataTools.createLSID("Detector", numDatasets, 0); 
    500  
    501           store.setDetectorSettingsID(detectorID, numDatasets, c); 
     515          channel.detector = detectorID; 
    502516          store.setDetectorID(detectorID, numDatasets, 0); 
    503517          store.setDetectorType(DetectorType.CCD, numDatasets, 0); 
    504518        } 
    505519        else if (id.endsWith("WaveLength")) { 
    506           store.setChannelExcitationWavelength( 
    507             new PositiveInteger(new Integer(value)), numDatasets, c); 
     520          channel.exWave = new PositiveInteger(new Integer(value)); 
    508521        } 
    509522        // NB: "UesrDefName" is not a typo. 
    510523        else if (id.endsWith("UesrDefName") && !value.equals("None")) { 
    511           store.setChannelName(value, numDatasets, c); 
    512         } 
     524          channel.name = value; 
     525        } 
     526        channels.put(numDatasets + "-" + c, channel); 
    513527      } 
    514528    } 
     
    862876      multiBands.add(m); 
    863877    } 
     878    else if (qName.equals("ChannelInfo")) { 
     879      int index = Integer.parseInt(attributes.getValue("Index")); 
     880      channels.remove(numDatasets + "-" + index); 
     881    } 
    864882    else count = 0; 
    865883    if (numDatasets == oldSeriesCount) storeSeriesHashtable(numDatasets, h); 
     
    10531071  } 
    10541072 
     1073  class Channel { 
     1074    public String detector; 
     1075    public Double gain; 
     1076    public PositiveInteger exWave; 
     1077    public String name; 
     1078  } 
     1079 
    10551080} 
  • trunk/components/bio-formats/src/loci/formats/in/LeicaHandler.java

    r6655 r6687  
    104104  private Vector<Detector> detectors = new Vector<Detector>(); 
    105105  private Vector<Laser> lasers = new Vector<Laser>(); 
     106  private Hashtable<String, Channel> channels = 
     107    new Hashtable<String, Channel>(); 
    106108 
    107109  private MetadataLevel level; 
     
    208210          store.setDetectorSettingsID(id, numDatasets, c); 
    209211        } 
    210       } 
    211  
     212 
     213        String[] keys = channels.keySet().toArray(new String[0]); 
     214        Arrays.sort(keys); 
     215        for (int c=0; c<keys.length; c++) { 
     216          Channel ch = channels.get(keys[c]); 
     217          store.setDetectorSettingsID(ch.detector, numDatasets, c); 
     218          store.setChannelExcitationWavelength(ch.exWave, numDatasets, c); 
     219          store.setChannelName(ch.name, numDatasets, c); 
     220          store.setDetectorSettingsGain(ch.gain, numDatasets, c); 
     221        } 
     222      } 
     223 
     224      channels.clear(); 
    212225      xPos.clear(); 
    213226      yPos.clear(); 
     
    490503        } 
    491504        catch (NumberFormatException e) { } 
     505        Channel channel = channels.get(numDatasets + "-" + c); 
     506        if (channel == null) channel = new Channel(); 
    492507        if (id.endsWith("ExposureTime")) { 
    493508          store.setPlaneExposureTime(new Double(value), numDatasets, c); 
    494509        } 
    495510        else if (id.endsWith("Gain")) { 
    496           store.setDetectorSettingsGain(new Double(value), numDatasets, c); 
     511          channel.gain = new Double(value); 
    497512 
    498513          String detectorID = 
    499514            MetadataTools.createLSID("Detector", numDatasets, 0); 
    500  
    501           store.setDetectorSettingsID(detectorID, numDatasets, c); 
     515          channel.detector = detectorID; 
    502516          store.setDetectorID(detectorID, numDatasets, 0); 
    503517          store.setDetectorType(DetectorType.CCD, numDatasets, 0); 
    504518        } 
    505519        else if (id.endsWith("WaveLength")) { 
    506           store.setChannelExcitationWavelength( 
    507             new PositiveInteger(new Integer(value)), numDatasets, c); 
     520          channel.exWave = new PositiveInteger(new Integer(value)); 
    508521        } 
    509522        // NB: "UesrDefName" is not a typo. 
    510523        else if (id.endsWith("UesrDefName") && !value.equals("None")) { 
    511           store.setChannelName(value, numDatasets, c); 
    512         } 
     524          channel.name = value; 
     525        } 
     526        channels.put(numDatasets + "-" + c, channel); 
    513527      } 
    514528    } 
     
    862876      multiBands.add(m); 
    863877    } 
     878    else if (qName.equals("ChannelInfo")) { 
     879      int index = Integer.parseInt(attributes.getValue("Index")); 
     880      channels.remove(numDatasets + "-" + index); 
     881    } 
    864882    else count = 0; 
    865883    if (numDatasets == oldSeriesCount) storeSeriesHashtable(numDatasets, h); 
     
    10531071  } 
    10541072 
     1073  class Channel { 
     1074    public String detector; 
     1075    public Double gain; 
     1076    public PositiveInteger exWave; 
     1077    public String name; 
     1078  } 
     1079 
    10551080} 
Note: See TracChangeset for help on using the changeset viewer.