diff --git a/components/test-suite/src/loci/tests/testng/Configuration.java b/components/test-suite/src/loci/tests/testng/Configuration.java index efb2b391b88..6a4b26d35a4 100644 --- a/components/test-suite/src/loci/tests/testng/Configuration.java +++ b/components/test-suite/src/loci/tests/testng/Configuration.java @@ -42,8 +42,9 @@ import loci.formats.FormatTools; import loci.formats.IFormatReader; import loci.formats.ImageReader; -import loci.formats.in.DynamicMetadataOptions; +import loci.formats.MetadataTools; import loci.formats.ReaderWrapper; +import loci.formats.in.DynamicMetadataOptions; import loci.formats.meta.IMetadata; import ome.xml.model.primitives.PositiveInteger; @@ -108,6 +109,7 @@ public class Configuration { private static final String EXCITATION_WAVELENGTH_UNIT = "ExcitationWavelengthUnit_"; private static final String DETECTOR = "Detector_"; private static final String NAME = "Name"; + private static final String UNFLATTENED_NAME = "Unflattened_Name"; private static final String DESCRIPTION = "Description"; private static final String SERIES_COUNT = "series_count"; private static final String RESOLUTION_COUNT = "resolution_count"; @@ -418,6 +420,10 @@ public String getImageName() { return currentTable.get(NAME); } + public String getUnflattenedImageName() { + return currentTable.get(UNFLATTENED_NAME); + } + public boolean hasImageDescription() { return currentTable.containsKey(DESCRIPTION); } @@ -548,17 +554,16 @@ private void populateINI(IFormatReader reader) { putTableName(globalTable, reader, " global"); int seriesCount = reader.getSeriesCount(); - IFormatReader unflattenedReader = reader; - if (seriesCount > 1) { - unflattenedReader = new ImageReader(); - unflattenedReader.setFlattenedResolutions(false); - unflattenedReader.setMetadataOptions(new DynamicMetadataOptions()); - try { - unflattenedReader.setId(reader.getCurrentFile()); - } - catch (FormatException | IOException e) { } - seriesCount = unflattenedReader.getSeriesCount(); + IFormatReader unflattenedReader = new ImageReader(); + unflattenedReader.setMetadataStore(MetadataTools.createOMEXMLMetadata()); + unflattenedReader.setFlattenedResolutions(false); + unflattenedReader.setMetadataOptions(new DynamicMetadataOptions()); + try { + unflattenedReader.setId(reader.getCurrentFile()); } + catch (FormatException | IOException e) { } + seriesCount = unflattenedReader.getSeriesCount(); + IMetadata unflattenedRetrieve = (IMetadata) unflattenedReader.getMetadataStore(); globalTable.put(SERIES_COUNT, String.valueOf(seriesCount)); @@ -649,7 +654,12 @@ else if (r instanceof ReaderWrapper) { // TODO } - seriesTable.put(NAME, retrieve.getImageName(index)); + String flattenedName = retrieve.getImageName(index); + seriesTable.put(NAME, flattenedName); + String unflattenedName = unflattenedRetrieve.getImageName(series); + if ((flattenedName == null && unflattenedName != null) || !flattenedName.equals(unflattenedName)) { + seriesTable.put(UNFLATTENED_NAME, unflattenedName); + } seriesTable.put(DESCRIPTION, retrieve.getImageDescription(index)); Length physicalX = retrieve.getPixelsPhysicalSizeX(index); diff --git a/components/test-suite/src/loci/tests/testng/FormatReaderTest.java b/components/test-suite/src/loci/tests/testng/FormatReaderTest.java index b0d1219a212..a7b91ab8b9b 100644 --- a/components/test-suite/src/loci/tests/testng/FormatReaderTest.java +++ b/components/test-suite/src/loci/tests/testng/FormatReaderTest.java @@ -963,7 +963,7 @@ private boolean isEqual(String expected, String real) { if (expected == null && real == null) { return true; - } else if (expected.equals("null") && real == null) { + } else if ("null".equals(expected) && real == null) { return true; } else if (expected == null) { return false; @@ -1421,6 +1421,51 @@ public void testImageNames() { result(testName, true); } + @Test(groups = {"all", "fast", "automated"}) + public void testUnflattenedImageNames() { + if (config == null) throw new SkipException("No config tree"); + String testName = "testUnflattenedImageNames"; + if (!initFile()) result(testName, false, "initFile"); + + boolean success = true; + String msg = null; + IFormatReader resolutionReader = setupReader(false, true); + try { + IMetadata retrieve = (IMetadata) resolutionReader.getMetadataStore(); + + if (resolutionReader.getSeriesCount() != config.getSeriesCount(false)) { + success = false; + msg = "incorrect unflattened series count"; + } + + for (int i=0; i