From 153a466deb98f698d1b8b581d9e25043e2c51292 Mon Sep 17 00:00:00 2001 From: David Gault Date: Thu, 8 Feb 2024 17:50:13 +0000 Subject: [PATCH 1/3] Reduce number of fields in memo file --- src/loci/formats/in/ZarrReader.java | 35 ++++++++++++++++------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/loci/formats/in/ZarrReader.java b/src/loci/formats/in/ZarrReader.java index 450706c..21abcde 100644 --- a/src/loci/formats/in/ZarrReader.java +++ b/src/loci/formats/in/ZarrReader.java @@ -99,15 +99,18 @@ public class ZarrReader extends FormatReader { public static final boolean INCLUDE_LABELS_DEFAULT = false; protected transient ZarrService zarrService; private ArrayList arrayPaths = new ArrayList(); - private ArrayList groupKeys = new ArrayList(); - private HashMap> resSeries = new HashMap>(); - private HashMap resCounts = new HashMap(); - private HashSet uniqueResCounts = new HashSet(); - private HashMap resIndexes = new HashMap(); + + // The below fields are only required for initialization and are not required to be serialized + private transient ArrayList groupKeys = new ArrayList(); + private transient HashMap> resSeries = new HashMap>(); // can be removed + private transient HashMap resCounts = new HashMap(); // can be removed + private transient HashSet uniqueResCounts = new HashSet(); // can be removed + private transient HashMap resIndexes = new HashMap(); // can be removed + private transient HashMap> pathArrayDimensions = new HashMap>(); // can be removed + private String dimensionOrder = "XYZCT"; private int wellCount = 0; private int wellSamplesCount = 0; - private HashMap> pathArrayDimensions = new HashMap>(); private boolean planesPrePopulated = false; private boolean hasSPW = false; private transient int currentOpenZarr = -1; @@ -200,15 +203,17 @@ protected void initFile(String id) throws FormatException, IOException { if (attr != null && !attr.isEmpty()) { parseResolutionCount(zarrRootPath, "", attr); parseOmeroMetadata(zarrRootPath, attr); - String jsonAttr; - try { - jsonAttr = ZarrUtils.toJson(attr, true); - store.setXMLAnnotationValue(jsonAttr, attrIndex); - String xml_id = MetadataTools.createLSID("Annotation", attrIndex); - store.setXMLAnnotationID(xml_id, attrIndex); - } catch (JZarrException e) { - LOGGER.warn("Failed to convert attributes to JSON"); - e.printStackTrace(); + if (saveAnnotations()) { + String jsonAttr; + try { + jsonAttr = ZarrUtils.toJson(attr, true); + store.setXMLAnnotationValue(jsonAttr, attrIndex); + String xml_id = MetadataTools.createLSID("Annotation", attrIndex); + store.setXMLAnnotationID(xml_id, attrIndex); + } catch (JZarrException e) { + LOGGER.warn("Failed to convert attributes to JSON"); + e.printStackTrace(); + } } } generateGroupKeys(attr, canonicalPath); From 0130777e5ec5b63a9004116ceba47282d1290dca Mon Sep 17 00:00:00 2001 From: David Gault Date: Sun, 11 Feb 2024 23:26:27 +0000 Subject: [PATCH 2/3] Don't populate originalMetadata by default --- src/loci/formats/in/ZarrReader.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/loci/formats/in/ZarrReader.java b/src/loci/formats/in/ZarrReader.java index 21abcde..21ab8b5 100644 --- a/src/loci/formats/in/ZarrReader.java +++ b/src/loci/formats/in/ZarrReader.java @@ -966,8 +966,10 @@ private void parseOMEXML(Location omeMetaFile, MetadataStore store, ArrayList Date: Sun, 11 Feb 2024 23:37:54 +0000 Subject: [PATCH 3/3] Don't copy over any original annotations --- src/loci/formats/in/ZarrReader.java | 38 +++++++++++++++++------------ 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/loci/formats/in/ZarrReader.java b/src/loci/formats/in/ZarrReader.java index 21ab8b5..5bfc736 100644 --- a/src/loci/formats/in/ZarrReader.java +++ b/src/loci/formats/in/ZarrReader.java @@ -1041,24 +1041,32 @@ private void parseOMEXML(Location omeMetaFile, MetadataStore store, ArrayList