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

Prevent extra (Logical)Channel objects from being populated.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 
Note: See TracChangeset for help on using the changeset viewer.