Skip to content

Commit

Permalink
Merge pull request #156 from melissalinkert/metadataonly
Browse files Browse the repository at this point in the history
Add MetadataOnly to METADATA.ome.xml
  • Loading branch information
chris-allan committed May 19, 2022
2 parents c267819 + 748b06e commit 6ee2587
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,13 @@ public void convert()
}

if (!noOMEMeta) {
String xml = getService().getOMEXML(meta);
OMEXMLService service = getService();
service.removeBinData((OMEXMLMetadata) meta);
service.removeTiffData((OMEXMLMetadata) meta);
for (int s=0; s<meta.getImageCount(); s++) {
service.addMetadataOnly((OMEXMLMetadata) meta, s, s == 0);
}
String xml = service.getOMEXML(meta);

// write the original OME-XML to a file
Path metadataPath = getRootPath().resolve("OME");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,12 @@ public void testMultiSeries() throws Exception {
series1.read(tile, shape);
seriesPlaneNumberZCT = FakeReader.readSpecialPixels(tile);
assertArrayEquals(new int[] {1, 0, 0, 0, 0}, seriesPlaneNumberZCT);

OME ome = getOMEMetadata();
assertEquals(2, ome.sizeOfImageList());
for (int i=0; i<ome.sizeOfImageList(); i++) {
assertNotNull(ome.getImage(i).getPixels().getMetadataOnly());
}
}

/**
Expand Down Expand Up @@ -1768,7 +1774,8 @@ private OME getOMEMetadata() throws Exception {
Path xml = output.resolve("OME").resolve("METADATA.ome.xml");
ServiceFactory sf = new ServiceFactory();
OMEXMLService xmlService = sf.getInstance(OMEXMLService.class);
return (OME) xmlService.createOMEXMLRoot(
new String(Files.readAllBytes(xml), StandardCharsets.UTF_8));
String omexml = new String(Files.readAllBytes(xml), StandardCharsets.UTF_8);
assertTrue(xmlService.validateOMEXML(omexml));
return (OME) xmlService.createOMEXMLRoot(omexml);
}
}

0 comments on commit 6ee2587

Please sign in to comment.