From d742ade336d4a419772a52576dd8c8c1698a5a80 Mon Sep 17 00:00:00 2001 From: marcobitplane <139451784+marcobitplane@users.noreply.github.com> Date: Tue, 3 Dec 2024 17:33:57 +0100 Subject: [PATCH] Avoid caching data when determining pixel type in initFile --- .../src/loci/formats/in/ImarisHDFReader.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/components/formats-gpl/src/loci/formats/in/ImarisHDFReader.java b/components/formats-gpl/src/loci/formats/in/ImarisHDFReader.java index bc35b7f3b89..13827c8c2f0 100644 --- a/components/formats-gpl/src/loci/formats/in/ImarisHDFReader.java +++ b/components/formats-gpl/src/loci/formats/in/ImarisHDFReader.java @@ -329,7 +329,7 @@ protected void initFile(String id) throws FormatException, IOException { int type = -1; - Object pix = getImageData(0, 0, 0, 1, 1); + Object pix = getSampleData(); if (pix instanceof byte[][]) type = FormatTools.UINT8; else if (pix instanceof short[][]) type = FormatTools.UINT16; else if (pix instanceof int[][]) type = FormatTools.UINT32; @@ -579,6 +579,24 @@ else if (buffer[zct[1]] instanceof float[][][]) { return image; } + private Object getSampleData() + throws FormatException + { + int resolutionIndex = getCoreIndex(); + Object image = null; + int[] dimensions = new int[] {1, 2, 2}; + int[] indices = new int[] {0, 0, 0}; + try { + String path = "/DataSet/ResolutionLevel_" + resolutionIndex + "/TimePoint_0/Channel_0/Data"; + image = netcdf.getArray(path, indices, dimensions); + } + catch (ServiceException e) { + throw new FormatException(e); + } + + return image; + } + private void parseAttributes() { final List attributes = netcdf.getAttributeList(); CoreMetadata ms0 = core.get(0, 0);