From cf579baf987321e82ee42eebd975365549f3aee8 Mon Sep 17 00:00:00 2001 From: Melissa Linkert Date: Thu, 11 Jul 2024 12:36:50 -0500 Subject: [PATCH 1/5] Update to Bio-Formats 7.3.1 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 0f5eb07..f84e8fa 100644 --- a/build.gradle +++ b/build.gradle @@ -37,7 +37,7 @@ configurations.all { dependencies { implementation 'net.java.dev.jna:jna:5.10.0' - implementation 'ome:formats-gpl:7.3.0' + implementation 'ome:formats-gpl:7.3.1' implementation 'info.picocli:picocli:4.7.5' implementation 'com.univocity:univocity-parsers:2.8.4' implementation 'dev.zarr:jzarr:0.4.2' From bc5ec8fafa7eec961862f7004bd5ad3bd21fd226 Mon Sep 17 00:00:00 2001 From: Melissa Linkert Date: Tue, 6 Aug 2024 11:53:14 -0500 Subject: [PATCH 2/5] MCD: calculate channel count based on metadata, not pixel bytes In some cases, the number of pixel bytes stored for a particular acquisition may not match the expected number of bytes, so calculating the channel count based on the stored number of pixel bytes will cause problems. Instead of throwing an exception, this sets the channel count to the number of channels linked to the acquisition, and logs that some image data may be blank. This more closely matches the behavior of MCDViewer (the vendor software). --- .../bioformats2raw/MCDReader.java | 41 ++++++++++++++----- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/glencoesoftware/bioformats2raw/MCDReader.java b/src/main/java/com/glencoesoftware/bioformats2raw/MCDReader.java index eec3891..8172427 100644 --- a/src/main/java/com/glencoesoftware/bioformats2raw/MCDReader.java +++ b/src/main/java/com/glencoesoftware/bioformats2raw/MCDReader.java @@ -219,35 +219,48 @@ protected void initFile(String id) throws FormatException, IOException { m.sizeZ = 1; m.sizeT = 1; + LOGGER.debug("Acquisition size: {} x {}, {} bytes per pixel", + acq.sizeX, acq.sizeY, acq.bpp); + int plane = acq.sizeX * acq.sizeY * acq.bpp; long totalBytes = acq.end - acq.start; + LOGGER.debug("Total pixel bytes: {}", totalBytes); if (totalBytes <= 0) { LOGGER.debug( - "Skipping acquistiion {} with 0 pixel bytes", acq.description); + "Skipping acquisition {} with 0 pixel bytes", acq.description); acquisitions.remove(acq); a--; continue; } long totalPlanes = totalBytes / plane; + LOGGER.debug("Detected {} planes in acquisition", totalPlanes); if (totalPlanes > Integer.MAX_VALUE) { throw new FormatException( "Too many channels (" + totalPlanes + ") for series " + core.size()); } - m.sizeC = (int) totalPlanes; - m.imageCount = m.sizeC * m.sizeZ * m.sizeT; - m.dimensionOrder = "XYCZT"; - m.littleEndian = true; - core.add(m); // the XML defines a big list of all channels across all acquisitions // map each channel to the correct location in the correct acquisition - acq.channelIndexes = new int[m.sizeC]; + acq.channelIndexes = new ArrayList(); for (int c=0; c= acq.channelIndexes.size()) { + acq.channelIndexes.add(-1); + } + acq.channelIndexes.set(channel.index, c); + m.sizeC++; } } + + m.imageCount = m.sizeC * m.sizeZ * m.sizeT; + if (totalPlanes < m.imageCount) { + LOGGER.warn("Not enough pixel bytes in file; images may be blank"); + } + + m.dimensionOrder = "XYCZT"; + m.littleEndian = true; + core.add(m); } MetadataStore store = makeFilterMetadata(); @@ -263,8 +276,14 @@ protected void initFile(String id) throws FormatException, IOException { Acquisition acq = acquisitions.get(a); store.setImageName(acq.description, imageIndex); - for (int c=0; c channelIndexes; } /** From bd42c7ca86e840eb48488211d324518c43a5b89d Mon Sep 17 00:00:00 2001 From: Melissa Linkert Date: Tue, 6 Aug 2024 15:52:30 -0500 Subject: [PATCH 3/5] MCD: don't allow openBytes to read beyond the end of an acquisition This prevents incorrect data from being read when the number of stored pixel bytes is smaller than expected. --- .../bioformats2raw/MCDReader.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/glencoesoftware/bioformats2raw/MCDReader.java b/src/main/java/com/glencoesoftware/bioformats2raw/MCDReader.java index 8172427..199f65a 100644 --- a/src/main/java/com/glencoesoftware/bioformats2raw/MCDReader.java +++ b/src/main/java/com/glencoesoftware/bioformats2raw/MCDReader.java @@ -76,7 +76,8 @@ public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) } LOGGER.debug("Reading raw acquisition #{}", getSeries() - panoramas.size()); - in.seek(acquisitions.get(getSeries() - panoramas.size()).start); + Acquisition currentAcq = acquisitions.get(getSeries() - panoramas.size()); + in.seek(currentAcq.start); LOGGER.debug("File offset = {}", in.getFilePointer()); int bpp = FormatTools.getBytesPerPixel(getPixelType()); @@ -91,10 +92,20 @@ public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) for (int row=0; row= currentAcq.end) { + break; + } } return buf; From f1ae5301786aec98432d97ee2c68f0cce77e875b Mon Sep 17 00:00:00 2001 From: Melissa Linkert Date: Wed, 7 Aug 2024 15:23:30 -0500 Subject: [PATCH 4/5] Release 0.9.4 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index f84e8fa..7923285 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { } group = 'com.glencoesoftware' -version = '0.10.0-SNAPSHOT' +version = '0.9.4' mainClassName = 'com.glencoesoftware.bioformats2raw.Converter' sourceCompatibility = 1.8 From ece12b667021fe8e43ef9af270574c46b555f6f8 Mon Sep 17 00:00:00 2001 From: Melissa Linkert Date: Wed, 7 Aug 2024 15:24:31 -0500 Subject: [PATCH 5/5] Bump version to 0.10.0-SNAPSHOT --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 7923285..f84e8fa 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { } group = 'com.glencoesoftware' -version = '0.9.4' +version = '0.10.0-SNAPSHOT' mainClassName = 'com.glencoesoftware.bioformats2raw.Converter' sourceCompatibility = 1.8