Skip to content

Commit

Permalink
One more very temporary fix that prevents too many Channels from bein…
Browse files Browse the repository at this point in the history
…g populated. Hopefully closes #2939.
  • Loading branch information
melissalinkert committed Oct 5, 2010
1 parent a1215cc commit 6888dd8
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions components/bio-formats/src/loci/formats/in/LIFReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import loci.formats.FormatTools;
import loci.formats.ImageTools;
import loci.formats.MetadataTools;
import loci.formats.meta.IMetadata;
import loci.formats.meta.MetadataStore;
import loci.formats.services.OMEXMLService;

Expand Down Expand Up @@ -333,9 +334,10 @@ protected void initFile(String id) throws FormatException, IOException {

/** Parses a string of XML and puts the values in a Hashtable. */
private void initMetadata(String xml) throws FormatException, IOException {
IMetadata omexml = MetadataTools.createOMEXMLMetadata();
MetadataStore store = makeFilterMetadata();
MetadataLevel level = getMetadataOptions().getMetadataLevel();
LeicaHandler handler = new LeicaHandler(store, level);
LeicaHandler handler = new LeicaHandler(omexml, level);

// the XML blocks stored in a LIF file are invalid,
// because they don't have a root node
Expand Down Expand Up @@ -384,15 +386,13 @@ private void initMetadata(String xml) throws FormatException, IOException {
}
}

MetadataTools.populatePixels(store, this, true, false);

// remove any Channels that do not have an ID

OMEXMLService service = null;
try {
service = new ServiceFactory().getInstance(OMEXMLService.class);
if (service.isOMEXMLRoot(store.getRoot())) {
OME root = (OME) store.getRoot();
if (service.isOMEXMLRoot(omexml.getRoot())) {
OME root = (OME) omexml.getRoot();
for (int i=0; i<getSeriesCount(); i++) {
setSeries(i);
Pixels img = root.getImage(i).getPixels();
Expand All @@ -406,12 +406,15 @@ private void initMetadata(String xml) throws FormatException, IOException {
}
}
setSeries(0);
store.setRoot(root);
omexml.setRoot(root);
service.convertMetadata(omexml, store);
}
}
catch (DependencyException e) {
LOGGER.trace("Failed to remove channels", e);
}

MetadataTools.populatePixels(store, this, true, false);
}

}

0 comments on commit 6888dd8

Please sign in to comment.