From 4f15c0d94bf76e1da1c22addd1857144e57f2f48 Mon Sep 17 00:00:00 2001 From: Yoshihiro OKUMURA Date: Tue, 12 Jul 2022 18:28:51 +0900 Subject: [PATCH] disabled to output metadata of empty annotations. --- .../neurodata/tools/BioFormatsImageInfo.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/jp/riken/neurodata/tools/BioFormatsImageInfo.java b/src/main/java/jp/riken/neurodata/tools/BioFormatsImageInfo.java index f0ee980..2f3073f 100644 --- a/src/main/java/jp/riken/neurodata/tools/BioFormatsImageInfo.java +++ b/src/main/java/jp/riken/neurodata/tools/BioFormatsImageInfo.java @@ -33,14 +33,13 @@ public class BioFormatsImageInfo { MetadataStore ms = reader.getMetadataStore(); MetadataRetrieve mr = ms instanceof MetadataRetrieve ? (MetadataRetrieve) ms : null; for (int j = 0; j < seriesCount; j++) { + + // read basic metadata for series #j reader.setSeries(j); Map seriesMetadata = new LinkedHashMap(); - // read basic metadata for series #j int imageCount = reader.getImageCount(); int resolutionCount = reader.getResolutionCount(); - - // output basic metadata for series #i String seriesName = mr == null ? null : mr.getImageName(j); if (seriesName != null) { seriesMetadata.put("name", seriesName); @@ -174,8 +173,8 @@ public class BioFormatsImageInfo { return ret; } - protected static LinkedHashMap makeRectangle(int width, int height) { - LinkedHashMap ret = new LinkedHashMap(); + protected static Map makeRectangle(int width, int height) { + Map ret = new LinkedHashMap(); ret.put("width", width); ret.put("height", height); return ret; @@ -185,8 +184,8 @@ public class BioFormatsImageInfo { ObjectMapper mapper = new ObjectMapper(); String json = null; try { - json = mapper.writeValueAsString(map); // json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(map); + json = mapper.writeValueAsString(map); } catch (Exception e) { // return "null" if conversion error occured json = "null"; @@ -223,7 +222,10 @@ public class BioFormatsImageInfo { reader.setResolution(0); // info.printGlobalMetadata(); // info.printOriginalMetadata(); - metadata.put("annotations", readAnnotations(reader)); + Map annotations = readAnnotations(reader); + if (!annotations.isEmpty()) { + metadata.put("annotations", annotations); + } } catch (Exception e) { throw new BioFormatsImageException(e); } finally {