From 40ceefa72043e02149bf2b6eb40ceb37c16fce5f Mon Sep 17 00:00:00 2001 From: marcobitplane <139451784+marcobitplane@users.noreply.github.com> Date: Thu, 24 Oct 2024 09:48:20 +0200 Subject: [PATCH 01/17] Added LZ4 filter provider for NetCDF-Java --- .../services/ucar.nc2.filter.FilterProvider | 1 + .../src/ucar/nc2/filter/LZ4Filter.java | 81 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 components/formats-gpl/src/META-INF/services/ucar.nc2.filter.FilterProvider create mode 100644 components/formats-gpl/src/ucar/nc2/filter/LZ4Filter.java diff --git a/components/formats-gpl/src/META-INF/services/ucar.nc2.filter.FilterProvider b/components/formats-gpl/src/META-INF/services/ucar.nc2.filter.FilterProvider new file mode 100644 index 00000000000..17c3e445dd3 --- /dev/null +++ b/components/formats-gpl/src/META-INF/services/ucar.nc2.filter.FilterProvider @@ -0,0 +1 @@ +ucar.nc2.filter.LZ4Filter$LZ4FilterProvider \ No newline at end of file diff --git a/components/formats-gpl/src/ucar/nc2/filter/LZ4Filter.java b/components/formats-gpl/src/ucar/nc2/filter/LZ4Filter.java new file mode 100644 index 00000000000..841bd131ca1 --- /dev/null +++ b/components/formats-gpl/src/ucar/nc2/filter/LZ4Filter.java @@ -0,0 +1,81 @@ +package ucar.nc2.filter; + +import ucar.nc2.filter.FilterProvider; +import ucar.nc2.filter.Filter; + +// import io.airlift.compress.v3.lz4.Lz4NativeDecompressor; +// import io.airlift.compress.v3.lz4.Lz4JavaCompressor; +// import io.airlift.compress.v3.Decompressor; +// import io.airlift.compress.v3.Compressor; +import net.jpountz.lz4.LZ4Factory; +import net.jpountz.lz4.LZ4FastDecompressor; + +import java.util.Map; +import java.io.IOException; +import java.nio.ByteBuffer; + +public class LZ4Filter extends Filter { + + static final String name = "LZ4 filter"; + static final int id = 32004; + private LZ4FastDecompressor decompressor; + + public LZ4Filter(Map properties) { + LZ4Factory factory = LZ4Factory.fastestInstance(); + decompressor = factory.fastDecompressor(); + } + + @Override + public String getName() { + return name; + } + + @Override + public int getId() { + return id; + } + + @Override + public byte[] encode(byte[] dataIn) throws IOException { + // only decoding implementation needed for reading + byte[] dataOut = dataIn; + return dataOut; + } + + @Override + public byte[] decode(byte[] dataIn) throws IOException { + ByteBuffer byteBuffer = ByteBuffer.wrap(dataIn); + + long totalDecompressedSize = byteBuffer.getLong(); + int decompressedBlockSize = byteBuffer.getInt(); + int compressedBlockSize = byteBuffer.getInt(); + + byte[] decompressedBlock = new byte[Math.toIntExact(totalDecompressedSize)]; + byte[] compressedBlock = new byte[compressedBlockSize]; + + byteBuffer.get(compressedBlock, 0, compressedBlockSize); + decompressor.decompress(compressedBlock, 0, decompressedBlock, 0, decompressedBlockSize); + + return decompressedBlock; + } + + public static class LZ4FilterProvider implements FilterProvider { + + @Override + public String getName() { + return name; + } + + @Override + public int getId() { + return id; + } + + @Override + public Filter create(Map properties) { + return new LZ4Filter(properties); + } + + } + +} From 37cba6027b8107360dbd270d3a944d88f347e762 Mon Sep 17 00:00:00 2001 From: marcobitplane <139451784+marcobitplane@users.noreply.github.com> Date: Thu, 24 Oct 2024 09:51:22 +0200 Subject: [PATCH 02/17] Add lz4-java dependency to pom.xml --- components/formats-gpl/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/formats-gpl/pom.xml b/components/formats-gpl/pom.xml index 89468428974..c7bab1fc25d 100644 --- a/components/formats-gpl/pom.xml +++ b/components/formats-gpl/pom.xml @@ -120,6 +120,11 @@ kryo ${kryo.version} + + org.lz4 + lz4-java + 1.8.0 + From 8941acca5d11c9940b7264647a35b63ab973c104 Mon Sep 17 00:00:00 2001 From: marcobitplane <139451784+marcobitplane@users.noreply.github.com> Date: Thu, 24 Oct 2024 09:56:31 +0200 Subject: [PATCH 03/17] Update NetCDFServiceImpl.java to use the new version of NetCDF-Java --- .../src/loci/formats/services/NetCDFServiceImpl.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/formats-gpl/src/loci/formats/services/NetCDFServiceImpl.java b/components/formats-gpl/src/loci/formats/services/NetCDFServiceImpl.java index bf24c751883..122ce64c238 100644 --- a/components/formats-gpl/src/loci/formats/services/NetCDFServiceImpl.java +++ b/components/formats-gpl/src/loci/formats/services/NetCDFServiceImpl.java @@ -45,6 +45,7 @@ import ucar.nc2.Attribute; import ucar.nc2.Group; import ucar.nc2.NetcdfFile; +import ucar.nc2.NetcdfFiles; import ucar.nc2.Variable; import com.esotericsoftware.kryo.Kryo; @@ -52,6 +53,8 @@ import com.esotericsoftware.kryo.io.Input; import com.esotericsoftware.kryo.io.Output; +import com.google.common.collect.ImmutableList; + /** * Utility class for working with NetCDF/HDF files. Uses reflection to * call the NetCDF Java library. @@ -247,7 +250,7 @@ private void parseAttributesAndVariables(List groups) { if (!groupName.endsWith("/")) variableName = "/" + variableName; variableList.add(variableName); } - groups = group.getGroups(); + groups = (List) group.getGroups(); parseAttributesAndVariables(groups); } } @@ -307,7 +310,7 @@ public void print(String s) { } }; System.setOut(throwaway); throwaway.close(); - netCDFFile = NetcdfFile.open(currentId); + netCDFFile = NetcdfFiles.open(currentId); System.setOut(outStream); root = netCDFFile.getRootGroup(); } From db73caf4591540abdd81ce8dc6a7e74578c537cb Mon Sep 17 00:00:00 2001 From: marcobitplane <139451784+marcobitplane@users.noreply.github.com> Date: Thu, 24 Oct 2024 10:03:29 +0200 Subject: [PATCH 04/17] Add caching to ImarisHDFReader.java --- .../src/loci/formats/in/ImarisHDFReader.java | 117 ++++++++++++++++-- 1 file changed, 109 insertions(+), 8 deletions(-) diff --git a/components/formats-gpl/src/loci/formats/in/ImarisHDFReader.java b/components/formats-gpl/src/loci/formats/in/ImarisHDFReader.java index 930ce7f80c8..bc35b7f3b89 100644 --- a/components/formats-gpl/src/loci/formats/in/ImarisHDFReader.java +++ b/components/formats-gpl/src/loci/formats/in/ImarisHDFReader.java @@ -28,6 +28,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.Hashtable; import loci.common.DataTools; import loci.common.Location; @@ -71,6 +72,15 @@ public class ImarisHDFReader extends SubResolutionFormatReader { private List colors; private int lastChannel = 0; + // caching parameters + private long maxBufferSize = 1024 * 1024 * 1024; + private Object[] buffer = null; + private int[] blockSizeZPerResolution; + private int lastMinZ = 0; + private int lastMaxZ = 0; + private int lastRes = 0; + private int lastT = 0; + // -- Constructor -- /** Constructs a new Imaris HDF reader. */ @@ -223,6 +233,10 @@ public void close(boolean fileOnly) throws IOException { pixelSizeX = pixelSizeY = pixelSizeZ = 0; minX = minY = minZ = maxX = maxY = maxZ = 0; + lastRes = lastT = lastMinZ = lastMaxZ = 0; + buffer = null; + blockSizeZPerResolution = null; + if (netcdf != null) netcdf.close(); netcdf = null; @@ -300,6 +314,16 @@ protected void initFile(String id) throws FormatException, IOException { ms0.thumbnail = false; ms0.dimensionOrder = "XYZCT"; + // read block sizes for caching + blockSizeZPerResolution = new int[seriesCount]; + for (int res = 0; res < seriesCount; res++) { + String datasetPath = "DataSet/ResolutionLevel_" + res + "/TimePoint_0/Channel_0/Data"; + Hashtable table = netcdf.getVariableAttributes(datasetPath); + String chunkSizesString = (String) table.get("_ChunkSizes"); + String[] sizes = chunkSizesString.split(" "); + blockSizeZPerResolution[res] = Integer.parseInt(sizes[0]); + } + // determine pixel type - this isn't stored in the metadata, so we need // to check the pixels themselves @@ -434,8 +458,7 @@ private Object getImageData(int no, int x, int y, int width, int height) throws FormatException { int[] zct = getZCTCoords(no); - String path = "/DataSet/ResolutionLevel_" + getCoreIndex() + "/TimePoint_" + - zct[2] + "/Channel_" + zct[1] + "/Data"; + int resolutionIndex = getCoreIndex(); Object image = null; // the width and height cannot be 1, because then netCDF will give us a @@ -467,14 +490,92 @@ private Object getImageData(int no, int x, int y, int width, int height) x = (getSizeX() / 2) - 1; } - int[] dimensions = new int[] {1, height, width}; - int[] indices = new int[] {zct[0], y, x}; - try { - image = netcdf.getArray(path, indices, dimensions); + // cache dataset blocks to avoid multiple reads. + // use caching for 3D datasets and only if the size of the required buffer is < maxBufferSize + if (getSizeZ() > 1 && getSizeX() * getSizeY() * blockSizeZPerResolution[resolutionIndex] * getSizeC() * FormatTools.getBytesPerPixel(getPixelType()) < maxBufferSize) { + // update buffer if needed + if (zct[0] < lastMinZ || zct[0] > lastMaxZ || zct[2] != lastT || resolutionIndex != lastRes || buffer == null) { + buffer = new Object[getSizeC()]; + if (resolutionIndex != lastRes) { + lastRes = resolutionIndex; + lastT = zct[2]; + } + if (zct[2] != lastT) { + lastT = zct[2]; + } + + int blockNumber = zct[0] / blockSizeZPerResolution[resolutionIndex]; + int[] dims = new int[] {blockSizeZPerResolution[resolutionIndex], getSizeY(), getSizeX()}; + int[] idcs = new int[] {blockNumber * blockSizeZPerResolution[resolutionIndex], 0, 0}; + try { + String path; + for (int ch = 0; ch < getSizeC(); ch++) { + path = "/DataSet/ResolutionLevel_" + resolutionIndex + "/TimePoint_" + zct[2] + "/Channel_" + ch + "/Data"; + buffer[ch] = netcdf.getArray(path, idcs, dims); + } + } + catch (ServiceException e) { + throw new FormatException(e); + } + + lastMinZ = blockNumber * blockSizeZPerResolution[resolutionIndex]; + lastMaxZ = lastMinZ + blockSizeZPerResolution[resolutionIndex] - 1; + } + + // read from buffer + if (buffer[zct[1]] instanceof byte[][][]) { + byte[][][] byteBuffer = (byte[][][]) buffer[zct[1]]; + byte[][] slice = new byte[height][width]; + for (int i = y; i < y + height; i++) { + for (int j = x; j < x + width; j++) { + slice[i - y][j - x] = byteBuffer[zct[0] - lastMinZ][i][j]; + } + } + image = (Object) slice; + } + else if (buffer[zct[1]] instanceof short[][][]) { + short[][][] shortBuffer = (short[][][]) buffer[zct[1]]; + short[][] slice = new short[height][width]; + for (int i = y; i < y + height; i++) { + for (int j = x; j < x + width; j++) { + slice[i - y][j - x] = shortBuffer[zct[0] - lastMinZ][i][j]; + } + } + image = (Object) slice; + } + else if (buffer[zct[1]] instanceof int[][][]) { + int[][][] intBuffer = (int[][][]) buffer[zct[1]]; + int[][] slice = new int[height][width]; + for (int i = y; i < y + height; i++) { + for (int j = x; j < x + width; j++) { + slice[i - y][j - x] = intBuffer[zct[0] - lastMinZ][i][j]; + } + } + image = (Object) slice; + } + else if (buffer[zct[1]] instanceof float[][][]) { + float[][][] floatBuffer = (float[][][]) buffer[zct[1]]; + float[][] slice = new float[height][width]; + for (int i = y; i < y + height; i++) { + for (int j = x; j < x + width; j++) { + slice[i - y][j - x] = floatBuffer[zct[0] - lastMinZ][i][j]; + } + } + image = (Object) slice; + } } - catch (ServiceException e) { - throw new FormatException(e); + else { + int[] dimensions = new int[] {1, height, width}; + int[] indices = new int[] {zct[0], y, x}; + try { + String path = "/DataSet/ResolutionLevel_" + resolutionIndex + "/TimePoint_" + zct[2] + "/Channel_" + zct[1] + "/Data"; + image = netcdf.getArray(path, indices, dimensions); + } + catch (ServiceException e) { + throw new FormatException(e); + } } + return image; } From 60a1cfe40ffab79ebdeda32f2cc78dca9042e8d7 Mon Sep 17 00:00:00 2001 From: marcobitplane <139451784+marcobitplane@users.noreply.github.com> Date: Thu, 24 Oct 2024 14:10:10 +0200 Subject: [PATCH 05/17] Clean up LZ4Filter.java --- components/formats-gpl/src/ucar/nc2/filter/LZ4Filter.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/components/formats-gpl/src/ucar/nc2/filter/LZ4Filter.java b/components/formats-gpl/src/ucar/nc2/filter/LZ4Filter.java index 841bd131ca1..a3ce684dc26 100644 --- a/components/formats-gpl/src/ucar/nc2/filter/LZ4Filter.java +++ b/components/formats-gpl/src/ucar/nc2/filter/LZ4Filter.java @@ -3,10 +3,6 @@ import ucar.nc2.filter.FilterProvider; import ucar.nc2.filter.Filter; -// import io.airlift.compress.v3.lz4.Lz4NativeDecompressor; -// import io.airlift.compress.v3.lz4.Lz4JavaCompressor; -// import io.airlift.compress.v3.Decompressor; -// import io.airlift.compress.v3.Compressor; import net.jpountz.lz4.LZ4Factory; import net.jpountz.lz4.LZ4FastDecompressor; From 2afc6200f18c9fb3da84f88c8ea13fe079503eec Mon Sep 17 00:00:00 2001 From: marcobitplane <139451784+marcobitplane@users.noreply.github.com> Date: Thu, 24 Oct 2024 14:49:30 +0200 Subject: [PATCH 06/17] Clean up LZ4Filter.java formatting --- components/formats-gpl/src/ucar/nc2/filter/LZ4Filter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/formats-gpl/src/ucar/nc2/filter/LZ4Filter.java b/components/formats-gpl/src/ucar/nc2/filter/LZ4Filter.java index a3ce684dc26..90429427796 100644 --- a/components/formats-gpl/src/ucar/nc2/filter/LZ4Filter.java +++ b/components/formats-gpl/src/ucar/nc2/filter/LZ4Filter.java @@ -42,8 +42,8 @@ public byte[] encode(byte[] dataIn) throws IOException { public byte[] decode(byte[] dataIn) throws IOException { ByteBuffer byteBuffer = ByteBuffer.wrap(dataIn); - long totalDecompressedSize = byteBuffer.getLong(); - int decompressedBlockSize = byteBuffer.getInt(); + long totalDecompressedSize = byteBuffer.getLong(); + int decompressedBlockSize = byteBuffer.getInt(); int compressedBlockSize = byteBuffer.getInt(); byte[] decompressedBlock = new byte[Math.toIntExact(totalDecompressedSize)]; From d15e63355fc4bba905f750f31123da388bb44560 Mon Sep 17 00:00:00 2001 From: marcobitplane <139451784+marcobitplane@users.noreply.github.com> Date: Tue, 5 Nov 2024 14:46:31 +0100 Subject: [PATCH 07/17] Aircompressor dependency instead of lz4-java --- components/formats-gpl/pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/formats-gpl/pom.xml b/components/formats-gpl/pom.xml index c7bab1fc25d..1712043ae04 100644 --- a/components/formats-gpl/pom.xml +++ b/components/formats-gpl/pom.xml @@ -121,9 +121,9 @@ ${kryo.version} - org.lz4 - lz4-java - 1.8.0 + io.airlift + aircompressor + 0.27 From 4760003bd2dbb6f85d3bab20551d412926e65fbe Mon Sep 17 00:00:00 2001 From: marcobitplane <139451784+marcobitplane@users.noreply.github.com> Date: Tue, 5 Nov 2024 14:49:46 +0100 Subject: [PATCH 08/17] Delete components/formats-gpl/src/ucar directory --- .../src/ucar/nc2/filter/LZ4Filter.java | 77 ------------------- 1 file changed, 77 deletions(-) delete mode 100644 components/formats-gpl/src/ucar/nc2/filter/LZ4Filter.java diff --git a/components/formats-gpl/src/ucar/nc2/filter/LZ4Filter.java b/components/formats-gpl/src/ucar/nc2/filter/LZ4Filter.java deleted file mode 100644 index 90429427796..00000000000 --- a/components/formats-gpl/src/ucar/nc2/filter/LZ4Filter.java +++ /dev/null @@ -1,77 +0,0 @@ -package ucar.nc2.filter; - -import ucar.nc2.filter.FilterProvider; -import ucar.nc2.filter.Filter; - -import net.jpountz.lz4.LZ4Factory; -import net.jpountz.lz4.LZ4FastDecompressor; - -import java.util.Map; -import java.io.IOException; -import java.nio.ByteBuffer; - -public class LZ4Filter extends Filter { - - static final String name = "LZ4 filter"; - static final int id = 32004; - private LZ4FastDecompressor decompressor; - - public LZ4Filter(Map properties) { - LZ4Factory factory = LZ4Factory.fastestInstance(); - decompressor = factory.fastDecompressor(); - } - - @Override - public String getName() { - return name; - } - - @Override - public int getId() { - return id; - } - - @Override - public byte[] encode(byte[] dataIn) throws IOException { - // only decoding implementation needed for reading - byte[] dataOut = dataIn; - return dataOut; - } - - @Override - public byte[] decode(byte[] dataIn) throws IOException { - ByteBuffer byteBuffer = ByteBuffer.wrap(dataIn); - - long totalDecompressedSize = byteBuffer.getLong(); - int decompressedBlockSize = byteBuffer.getInt(); - int compressedBlockSize = byteBuffer.getInt(); - - byte[] decompressedBlock = new byte[Math.toIntExact(totalDecompressedSize)]; - byte[] compressedBlock = new byte[compressedBlockSize]; - - byteBuffer.get(compressedBlock, 0, compressedBlockSize); - decompressor.decompress(compressedBlock, 0, decompressedBlock, 0, decompressedBlockSize); - - return decompressedBlock; - } - - public static class LZ4FilterProvider implements FilterProvider { - - @Override - public String getName() { - return name; - } - - @Override - public int getId() { - return id; - } - - @Override - public Filter create(Map properties) { - return new LZ4Filter(properties); - } - - } - -} From a550ffee1420b64a0d81f8bb218484f788459315 Mon Sep 17 00:00:00 2001 From: marcobitplane <139451784+marcobitplane@users.noreply.github.com> Date: Tue, 5 Nov 2024 14:52:15 +0100 Subject: [PATCH 09/17] Add filter directory and LZ4Filter --- .../src/loci/formats/filter/LZ4Filter.java | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 components/formats-gpl/src/loci/formats/filter/LZ4Filter.java diff --git a/components/formats-gpl/src/loci/formats/filter/LZ4Filter.java b/components/formats-gpl/src/loci/formats/filter/LZ4Filter.java new file mode 100644 index 00000000000..8ee36e766a8 --- /dev/null +++ b/components/formats-gpl/src/loci/formats/filter/LZ4Filter.java @@ -0,0 +1,75 @@ +package loci.formats.filter; + +import ucar.nc2.filter.FilterProvider; +import ucar.nc2.filter.Filter; + +import io.airlift.compress.lz4.Lz4Decompressor; + +import java.util.Map; +import java.io.IOException; +import java.nio.ByteBuffer; + +public class LZ4Filter extends Filter { + + static final String name = "LZ4 filter"; + static final int id = 32004; + private Lz4Decompressor decompressor; + + public LZ4Filter(Map properties) { + decompressor = new Lz4Decompressor(); + } + + @Override + public String getName() { + return name; + } + + @Override + public int getId() { + return id; + } + + @Override + public byte[] encode(byte[] dataIn) throws IOException { + // only decoding implementation needed for reading + byte[] dataOut = dataIn; + return dataOut; + } + + @Override + public byte[] decode(byte[] dataIn) throws IOException { + ByteBuffer byteBuffer = ByteBuffer.wrap(dataIn); + + long totalDecompressedSize = byteBuffer.getLong(); + int decompressedBlockSize = byteBuffer.getInt(); + int compressedBlockSize = byteBuffer.getInt(); + + byte[] decompressedBlock = new byte[Math.toIntExact(totalDecompressedSize)]; + byte[] compressedBlock = new byte[compressedBlockSize]; + + byteBuffer.get(compressedBlock, 0, compressedBlockSize); + decompressor.decompress(compressedBlock, 0, compressedBlockSize, decompressedBlock, 0, decompressedBlockSize); + + return decompressedBlock; + } + + public static class LZ4FilterProvider implements FilterProvider { + + @Override + public String getName() { + return name; + } + + @Override + public int getId() { + return id; + } + + @Override + public Filter create(Map properties) { + return new LZ4Filter(properties); + } + + } + +} From 32bcfcc094b61279f229312c8258f033f22e7d4a Mon Sep 17 00:00:00 2001 From: marcobitplane <139451784+marcobitplane@users.noreply.github.com> Date: Tue, 5 Nov 2024 14:54:54 +0100 Subject: [PATCH 10/17] Update ucar.nc2.filter.FilterProvider to the new location loci/formats/filter --- .../src/META-INF/services/ucar.nc2.filter.FilterProvider | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/formats-gpl/src/META-INF/services/ucar.nc2.filter.FilterProvider b/components/formats-gpl/src/META-INF/services/ucar.nc2.filter.FilterProvider index 17c3e445dd3..90fa9817eaa 100644 --- a/components/formats-gpl/src/META-INF/services/ucar.nc2.filter.FilterProvider +++ b/components/formats-gpl/src/META-INF/services/ucar.nc2.filter.FilterProvider @@ -1 +1 @@ -ucar.nc2.filter.LZ4Filter$LZ4FilterProvider \ No newline at end of file +loci.formats.filter.LZ4Filter$LZ4FilterProvider From 2c4dfbde6e85fecfeef789e1b4ddbd1a7a7e90b7 Mon Sep 17 00:00:00 2001 From: marcobitplane <139451784+marcobitplane@users.noreply.github.com> Date: Tue, 19 Nov 2024 10:31:06 +0100 Subject: [PATCH 11/17] Update assembly.xml to ensure META-INF/services files are merged --- components/bundles/bioformats_package/assembly.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/bundles/bioformats_package/assembly.xml b/components/bundles/bioformats_package/assembly.xml index b46896c4601..46c2e893cfd 100644 --- a/components/bundles/bioformats_package/assembly.xml +++ b/components/bundles/bioformats_package/assembly.xml @@ -36,4 +36,9 @@ false + + + metaInf-services + + From f0a07113495879922cce276dbfb321df9e866781 Mon Sep 17 00:00:00 2001 From: marcobitplane <139451784+marcobitplane@users.noreply.github.com> Date: Thu, 21 Nov 2024 10:37:34 +0100 Subject: [PATCH 12/17] Ant build fix: add ucar.nc2.filter.FilterProvider to formats-gpl jar --- components/formats-gpl/build.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/formats-gpl/build.properties b/components/formats-gpl/build.properties index 51586ed4bf5..d49efc442ad 100644 --- a/components/formats-gpl/build.properties +++ b/components/formats-gpl/build.properties @@ -14,7 +14,8 @@ component.deprecation = true component.resources-bin = loci/formats/bio-formats-logo.png \ loci/formats/utests/2008-09.ome \ - lib/**/*.dll + lib/**/*.dll \ + META-INF/services/ucar.nc2.filter.FilterProvider component.resources-text = component.main-class = loci.formats.gui.ImageViewer From 58e5dfdf359b52633f6e55091bcdde8217347914 Mon Sep 17 00:00:00 2001 From: marcobitplane <139451784+marcobitplane@users.noreply.github.com> Date: Thu, 21 Nov 2024 10:40:26 +0100 Subject: [PATCH 13/17] Ant build fix: merge ucar.nc2.filter.FilterProvider files --- ant/java.xml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/ant/java.xml b/ant/java.xml index a9566591401..64058451b55 100644 --- a/ant/java.xml +++ b/ant/java.xml @@ -220,6 +220,30 @@ your FindBugs installation's lib directory. E.g.: + + + ${runtimePaths.string} + + + + + + + + + + + + + + + + + + + + + From 860b334c142ec65df123246fa821ec6287543629 Mon Sep 17 00:00:00 2001 From: marcobitplane <139451784+marcobitplane@users.noreply.github.com> Date: Fri, 22 Nov 2024 09:42:21 +0100 Subject: [PATCH 14/17] Add copyright statement to LZ4Filter.java --- .../src/loci/formats/filter/LZ4Filter.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/components/formats-gpl/src/loci/formats/filter/LZ4Filter.java b/components/formats-gpl/src/loci/formats/filter/LZ4Filter.java index 8ee36e766a8..3d867db5235 100644 --- a/components/formats-gpl/src/loci/formats/filter/LZ4Filter.java +++ b/components/formats-gpl/src/loci/formats/filter/LZ4Filter.java @@ -1,3 +1,28 @@ +/* + * #%L + * OME Bio-Formats package for reading and converting biological file formats. + * %% + * Copyright (C) 2005 - 2017 Open Microscopy Environment: + * - Board of Regents of the University of Wisconsin-Madison + * - Glencoe Software, Inc. + * - University of Dundee + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * . + * #L% + */ + package loci.formats.filter; import ucar.nc2.filter.FilterProvider; From fc379cc7ba163ac9f332560bd925f3ec0cc67e6c Mon Sep 17 00:00:00 2001 From: marcobitplane <139451784+marcobitplane@users.noreply.github.com> Date: Fri, 22 Nov 2024 09:45:46 +0100 Subject: [PATCH 15/17] Throw UnsupportedOperationException instead of just returning input array. --- components/formats-gpl/src/loci/formats/filter/LZ4Filter.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/components/formats-gpl/src/loci/formats/filter/LZ4Filter.java b/components/formats-gpl/src/loci/formats/filter/LZ4Filter.java index 3d867db5235..c130f347734 100644 --- a/components/formats-gpl/src/loci/formats/filter/LZ4Filter.java +++ b/components/formats-gpl/src/loci/formats/filter/LZ4Filter.java @@ -56,9 +56,7 @@ public int getId() { @Override public byte[] encode(byte[] dataIn) throws IOException { - // only decoding implementation needed for reading - byte[] dataOut = dataIn; - return dataOut; + throw new UnsupportedOperationException("LZ4Filter does not support data compression"); } @Override From 50de137de1e4f3c98710dff4a38b09995c33abb0 Mon Sep 17 00:00:00 2001 From: marcobitplane <139451784+marcobitplane@users.noreply.github.com> Date: Fri, 22 Nov 2024 09:47:22 +0100 Subject: [PATCH 16/17] Remove unnecessary import. --- .../src/loci/formats/services/NetCDFServiceImpl.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/components/formats-gpl/src/loci/formats/services/NetCDFServiceImpl.java b/components/formats-gpl/src/loci/formats/services/NetCDFServiceImpl.java index 122ce64c238..48af84a42fb 100644 --- a/components/formats-gpl/src/loci/formats/services/NetCDFServiceImpl.java +++ b/components/formats-gpl/src/loci/formats/services/NetCDFServiceImpl.java @@ -53,8 +53,6 @@ import com.esotericsoftware.kryo.io.Input; import com.esotericsoftware.kryo.io.Output; -import com.google.common.collect.ImmutableList; - /** * Utility class for working with NetCDF/HDF files. Uses reflection to * call the NetCDF Java library. 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 17/17] 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);