From 5868aeb38ecdcdf03a0450de60a5816522771e74 Mon Sep 17 00:00:00 2001 From: Ulysse Rubens Date: Fri, 15 May 2020 11:19:16 +0200 Subject: [PATCH] Add channel names in properties --- build.gradle | 2 +- .../worker/PropertyExtractor.groovy | 44 ++++++++++++++++--- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 2c70cee..bdac22e 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { } group 'be.cytomine.bioformats' -version '2.3.0' +version '2.3.1' sourceCompatibility = 1.8 diff --git a/src/main/groovy/be/cytomine/bioformats/worker/PropertyExtractor.groovy b/src/main/groovy/be/cytomine/bioformats/worker/PropertyExtractor.groovy index e8e2c3e..f71e71d 100644 --- a/src/main/groovy/be/cytomine/bioformats/worker/PropertyExtractor.groovy +++ b/src/main/groovy/be/cytomine/bioformats/worker/PropertyExtractor.groovy @@ -22,10 +22,16 @@ package be.cytomine.bioformats.worker import be.cytomine.bioformats.BioFormatsUtils import loci.common.DebugTools +import loci.common.services.DependencyException +import loci.common.services.ServiceException import loci.common.services.ServiceFactory import loci.formats.ImageReader -import loci.formats.meta.IMetadata +import loci.formats.MissingLibraryException +import loci.formats.meta.DummyMetadata +import loci.formats.meta.MetadataRetrieve +import loci.formats.meta.MetadataStore import loci.formats.services.OMEXMLService +import loci.formats.services.OMEXMLServiceImpl import ome.units.UNITS class PropertyExtractor extends Worker { @@ -48,15 +54,26 @@ class PropertyExtractor extends Worker { reader.setOriginalMetadataPopulated(true) // create OME-XML metadata store - ServiceFactory factory = new ServiceFactory() - OMEXMLService service = factory.getInstance(OMEXMLService.class) - IMetadata meta = service.createOMEXMLMetadata() - reader.setMetadataStore(meta) + try { + ServiceFactory factory = new ServiceFactory() + OMEXMLService service = factory.getInstance(OMEXMLService.class) + reader.setMetadataStore(service.createOMEXMLMetadata()) + } + catch (DependencyException de) { + throw new MissingLibraryException(OMEXMLServiceImpl.NO_OME_XML_MSG, de) + } + catch (ServiceException se) { + throw new loci.formats.FormatException(se) + } reader.setId(file.absolutePath) def biggestSeries = BioFormatsUtils.getBiggestSeries(reader) reader.setSeries(biggestSeries) + MetadataStore store = reader.getMetadataStore() + MetadataRetrieve meta = store instanceof MetadataRetrieve ? + (MetadataRetrieve) store : new DummyMetadata() + def physicalSizeX = null try { physicalSizeX = meta.getPixelsPhysicalSizeX(biggestSeries) @@ -99,6 +116,20 @@ class PropertyExtractor extends Worker { } catch (Exception ignored) {} + def channelNames = [:] + try { + (0..