Changeset 7157


Ignore:
Timestamp:
11/05/10 12:42:16 (9 years ago)
Author:
melissa
Message:

Remove any extra channels from OME-TIFF files. See  omero:#3250, QA #2973.

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/4.2/components/bio-formats/src/loci/formats/in/OMETiffReader.java

    r7126 r7157  
    267267 
    268268    hasSPW = meta.getPlateCount() > 0; 
     269 
     270    for (int i=0; i<meta.getImageCount(); i++) { 
     271      int sizeC = meta.getPixelsSizeC(i).getValue().intValue(); 
     272      service.removeChannels(meta, i, sizeC); 
     273    } 
    269274 
    270275    // TODO 
  • branches/4.2/components/bio-formats/src/loci/formats/services/OMEXMLService.java

    r7067 r7157  
    201201 
    202202  /** 
     203   * Remove all but the first sizeC valid Channel elements from the given 
     204   * OME-XML metadata object. 
     205   */ 
     206  public void removeChannels(OMEXMLMetadata omexmlMeta, int image, int sizeC); 
     207 
     208  /** 
    203209   * Insert a MetadataOnly element under the Image specified by 'index' in the 
    204210   * given OME-XML metadata object. 
  • branches/4.2/components/bio-formats/src/loci/formats/services/OMEXMLServiceImpl.java

    r7149 r7157  
    4545import ome.xml.OMEXMLFactory; 
    4646import ome.xml.model.BinData; 
     47import ome.xml.model.Channel; 
    4748import ome.xml.model.Image; 
    4849import ome.xml.model.MetadataOnly; 
     
    431432  } 
    432433 
     434  /** @see OMEXMLService#removeChannels(OMEXMLMetadata, int, int) */ 
     435  public void removeChannels(OMEXMLMetadata omexmlMeta, int image, int sizeC) { 
     436    OME root = (OME) omexmlMeta.getRoot(); 
     437    Pixels img = root.getImage(image).getPixels(); 
     438    List<Channel> channels = img.copyChannelList(); 
     439 
     440    for (int c=0; c<channels.size(); c++) { 
     441      Channel channel = channels.get(c); 
     442      if (channel.getID() == null || c >= sizeC) { 
     443        img.removeChannel(channel); 
     444      } 
     445    } 
     446    omexmlMeta.setRoot(root); 
     447  } 
     448 
    433449  /** @see OMEXMLService#addMetadataOnly(OMEXMLMetadata, int) */ 
    434450  public void addMetadataOnly(OMEXMLMetadata omexmlMeta, int image) { 
  • trunk/components/bio-formats/src/loci/formats/in/OMETiffReader.java

    r7126 r7157  
    267267 
    268268    hasSPW = meta.getPlateCount() > 0; 
     269 
     270    for (int i=0; i<meta.getImageCount(); i++) { 
     271      int sizeC = meta.getPixelsSizeC(i).getValue().intValue(); 
     272      service.removeChannels(meta, i, sizeC); 
     273    } 
    269274 
    270275    // TODO 
  • trunk/components/bio-formats/src/loci/formats/services/OMEXMLService.java

    r7038 r7157  
    201201 
    202202  /** 
     203   * Remove all but the first sizeC valid Channel elements from the given 
     204   * OME-XML metadata object. 
     205   */ 
     206  public void removeChannels(OMEXMLMetadata omexmlMeta, int image, int sizeC); 
     207 
     208  /** 
    203209   * Insert a MetadataOnly element under the Image specified by 'index' in the 
    204210   * given OME-XML metadata object. 
  • trunk/components/bio-formats/src/loci/formats/services/OMEXMLServiceImpl.java

    r7149 r7157  
    4545import ome.xml.OMEXMLFactory; 
    4646import ome.xml.model.BinData; 
     47import ome.xml.model.Channel; 
    4748import ome.xml.model.Image; 
    4849import ome.xml.model.MetadataOnly; 
     
    431432  } 
    432433 
     434  /** @see OMEXMLService#removeChannels(OMEXMLMetadata, int, int) */ 
     435  public void removeChannels(OMEXMLMetadata omexmlMeta, int image, int sizeC) { 
     436    OME root = (OME) omexmlMeta.getRoot(); 
     437    Pixels img = root.getImage(image).getPixels(); 
     438    List<Channel> channels = img.copyChannelList(); 
     439 
     440    for (int c=0; c<channels.size(); c++) { 
     441      Channel channel = channels.get(c); 
     442      if (channel.getID() == null || c >= sizeC) { 
     443        img.removeChannel(channel); 
     444      } 
     445    } 
     446    omexmlMeta.setRoot(root); 
     447  } 
     448 
    433449  /** @see OMEXMLService#addMetadataOnly(OMEXMLMetadata, int) */ 
    434450  public void addMetadataOnly(OMEXMLMetadata omexmlMeta, int image) { 
Note: See TracChangeset for help on using the changeset viewer.