Changeset 6822


Ignore:
Timestamp:
08/19/10 12:52:15 (9 years ago)
Author:
melissa
Message:

Prevent extra (Logical)Channel objects from being populated.

Files:
3 edited

Legend:

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

    r6687 r6822  
    653653          MetadataTools.createLSID("Detector", numDatasets, nextChannel); 
    654654 
    655         if (m != null) { 
     655        /* debug */ 
     656        System.out.println("nextChannel = " + nextChannel); 
     657        System.out.println("  channel = " + channel); 
     658        System.out.println("  numChannels = " + numChannels); 
     659        System.out.println("  core.sizeC = " + core.get(numDatasets).sizeC); 
     660        /* end debug */ 
     661 
     662        boolean validChannel = numChannels <= 0 || nextChannel < numChannels; 
     663 
     664        if (m != null && validChannel) { 
    656665          store.setLogicalChannelName(m.dyeName, numDatasets, nextChannel); 
    657666 
     
    674683        } 
    675684 
    676         if (detector != null) { 
     685        if (detector != null && validChannel) { 
    677686          store.setDetectorID(id, numDatasets, nextChannel); 
    678687          store.setDetectorSettingsGain(gain, numDatasets, nextChannel); 
     
    687696        } 
    688697 
    689         if (laser != null && laser.intensity > 0) { 
     698        if (laser != null && laser.intensity > 0 && validChannel) { 
    690699          store.setLightSourceSettingsLightSource(laser.id, numDatasets, 
    691700            nextChannel); 
  • branches/4.2/components/bio-formats/src/loci/formats/in/LIFReader.java

    r6534 r6822  
    3131import loci.common.DataTools; 
    3232import loci.common.RandomAccessInputStream; 
     33import loci.common.services.DependencyException; 
     34import loci.common.services.ServiceFactory; 
    3335import loci.common.xml.XMLTools; 
    3436import loci.formats.CoreMetadata; 
     
    3941import loci.formats.MetadataTools; 
    4042import loci.formats.meta.MetadataStore; 
     43import loci.formats.services.OMEXMLService; 
     44 
     45import ome.xml.model.Channel; 
     46import ome.xml.model.OME; 
     47import ome.xml.model.Pixels; 
    4148 
    4249/** 
     
    378385 
    379386    MetadataTools.populatePixels(store, this, true, false); 
     387 
     388    // remove any Channels that do not have an ID 
     389 
     390    OMEXMLService service = null; 
     391    try { 
     392      service = new ServiceFactory().getInstance(OMEXMLService.class); 
     393      if (service.isOMEXMLRoot(store.getRoot())) { 
     394        OME root = (OME) store.getRoot(); 
     395        for (int i=0; i<getSeriesCount(); i++) { 
     396          setSeries(i); 
     397          Pixels img = root.getImage(i).getPixels(); 
     398          for (int c=0; c<img.sizeOfChannelList(); c++) { 
     399            Channel channel = img.getChannel(c); 
     400            if (channel.getID() == null || c >= getEffectiveSizeC()) { 
     401              img.removeChannel(channel); 
     402            } 
     403          } 
     404        } 
     405        setSeries(0); 
     406      } 
     407    } 
     408    catch (DependencyException e) { 
     409      LOGGER.trace("Failed to remove channels", e); 
     410    } 
    380411  } 
    381412 
  • trunk/components/bio-formats/src/loci/formats/in/LIFReader.java

    r6796 r6822  
    394394        OME root = (OME) store.getRoot(); 
    395395        for (int i=0; i<getSeriesCount(); i++) { 
     396          setSeries(i); 
    396397          Pixels img = root.getImage(i).getPixels(); 
    397398          for (int c=0; c<img.sizeOfChannelList(); c++) { 
    398399            Channel channel = img.getChannel(c); 
    399             if (channel.getID() == null) img.removeChannel(channel); 
     400            if (channel.getID() == null || c >= getEffectiveSizeC()) { 
     401              img.removeChannel(channel); 
     402            } 
    400403          } 
    401404        } 
     405        setSeries(0); 
    402406      } 
    403407    } 
Note: See TracChangeset for help on using the changeset viewer.