From 153a466deb98f698d1b8b581d9e25043e2c51292 Mon Sep 17 00:00:00 2001 From: David Gault Date: Thu, 8 Feb 2024 17:50:13 +0000 Subject: [PATCH] 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);