diff --git a/java/pom.xml b/java/pom.xml index d1be1f9..8b2e3d5 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.micro-manager.ndtiffstorage NDTiffStorage - 2.9.34 + 2.10.0 jar NDTiff Storage file format Java-based writer and reader used for NDTiffStorage format diff --git a/java/src/main/java/org/micromanager/ndtiffstorage/IndexEntryData.java b/java/src/main/java/org/micromanager/ndtiffstorage/IndexEntryData.java index 17ee022..fb49380 100644 --- a/java/src/main/java/org/micromanager/ndtiffstorage/IndexEntryData.java +++ b/java/src/main/java/org/micromanager/ndtiffstorage/IndexEntryData.java @@ -26,6 +26,7 @@ public class IndexEntryData { public static final int TEN_BIT = 3; public static final int TWELVE_BIT = 4; public static final int FOURTEEN_BIT = 5; + public static final int ELEVEN_BIT = 6; public static final int UNCOMPRESSED = 0; @@ -137,7 +138,7 @@ public boolean isRGB() { public int getByteDepth() { if (pixelType_ == SIXTEEN_BIT || pixelType_ == FOURTEEN_BIT || pixelType_ == TWELVE_BIT || - pixelType_ == TEN_BIT) { + pixelType_ == TEN_BIT || pixelType_ == ELEVEN_BIT) { return 2; } return 1; @@ -156,6 +157,8 @@ public int getBitDepth() { return 16; } else if (pixelType_ == EIGHT_BIT_RGB) { return 8; + } else if (pixelType_ == ELEVEN_BIT) { + return 11; } else { throw new RuntimeException("Unknown pixel type"); } diff --git a/java/src/main/java/org/micromanager/ndtiffstorage/NDTiffReader.java b/java/src/main/java/org/micromanager/ndtiffstorage/NDTiffReader.java index 7240c64..4a5cba1 100644 --- a/java/src/main/java/org/micromanager/ndtiffstorage/NDTiffReader.java +++ b/java/src/main/java/org/micromanager/ndtiffstorage/NDTiffReader.java @@ -288,6 +288,9 @@ private TaggedImage readTaggedImage(IndexEntryData data) throws IOException { } else if (data.pixelType_ == IndexEntryData.EIGHT_BIT_RGB) { bytesPerPixelOnDisk = 3; bytesPerPixelReturned = 4; + } else if (data.pixelType_ == IndexEntryData.ELEVEN_BIT) { + bytesPerPixelOnDisk = 2; + bytesPerPixelReturned = 2; } else { throw new RuntimeException("Unknown pixel type"); } diff --git a/java/src/main/java/org/micromanager/ndtiffstorage/NDTiffWriter.java b/java/src/main/java/org/micromanager/ndtiffstorage/NDTiffWriter.java index a84d6fe..e69c3cf 100644 --- a/java/src/main/java/org/micromanager/ndtiffstorage/NDTiffWriter.java +++ b/java/src/main/java/org/micromanager/ndtiffstorage/NDTiffWriter.java @@ -400,6 +400,8 @@ private IndexEntryData writeIFD(String indexKey, Object pixels, byte[] metadata, pixelType = IndexEntryData.FOURTEEN_BIT; } else if (bitDepth == 16) { pixelType = IndexEntryData.SIXTEEN_BIT; + } else if (bitDepth == 11) { + pixelType = IndexEntryData.ELEVEN_BIT; } else { throw new RuntimeException("Unknown pixel type"); } diff --git a/python/ndtiff/_version.py b/python/ndtiff/_version.py index cac3bc1..c2224d4 100644 --- a/python/ndtiff/_version.py +++ b/python/ndtiff/_version.py @@ -1,2 +1,2 @@ -version_info = (1, 10, 0) +version_info = (1, 11, 0) __version__ = ".".join(map(str, version_info)) diff --git a/python/ndtiff/nd_tiff_current.py b/python/ndtiff/nd_tiff_current.py index f843774..08de256 100644 --- a/python/ndtiff/nd_tiff_current.py +++ b/python/ndtiff/nd_tiff_current.py @@ -48,6 +48,7 @@ class _SingleNDTiffReader: TEN_BIT_MONOCHROME = 3 TWELVE_BIT_MONOCHROME = 4 FOURTEEN_BIT_MONOCHROME = 5 + ELEVEN_BIT_MONOCHROME = 6 UNCOMPRESSED = 0 @@ -126,7 +127,8 @@ def read_image(self, index): elif index["pixel_type"] == self.SIXTEEN_BIT_MONOCHROME or \ index["pixel_type"] == self.TEN_BIT_MONOCHROME or \ index["pixel_type"] == self.TWELVE_BIT_MONOCHROME or \ - index["pixel_type"] == self.FOURTEEN_BIT_MONOCHROME: + index["pixel_type"] == self.FOURTEEN_BIT_MONOCHROME or \ + index["pixel_type"] == self.ELEVEN_BIT_MONOCHROME: bytes_per_pixel = 2 dtype = np.uint16 else: @@ -509,7 +511,8 @@ def _parse_first_index(self, first_index): elif first_index["pixel_type"] == _SingleNDTiffReader.SIXTEEN_BIT_MONOCHROME or \ first_index["pixel_type"] == _SingleNDTiffReader.FOURTEEN_BIT_MONOCHROME or \ first_index["pixel_type"] == _SingleNDTiffReader.TWELVE_BIT_MONOCHROME or \ - first_index["pixel_type"] == _SingleNDTiffReader.TEN_BIT_MONOCHROME: + first_index["pixel_type"] == _SingleNDTiffReader.TEN_BIT_MONOCHROME or \ + first_index["pixel_type"] == _SingleNDTiffReader.ELEVEN_BIT_MONOCHROME: self.bytes_per_pixel = 2 self.dtype = np.uint16 diff --git a/python/ndtiff/test/data_loading_test.py b/python/ndtiff/test/data_loading_test.py index e2469aa..3794fcd 100644 --- a/python/ndtiff/test/data_loading_test.py +++ b/python/ndtiff/test/data_loading_test.py @@ -83,3 +83,9 @@ def test_v3_2_12bit_pycromanager_data(test_data_path): data_path = os.path.join(test_data_path, 'v3', '12_bit_pycromanager_mda') dataset = Dataset(data_path) assert(dataset.read_image(time=0, channel='DAPI').dtype == np.uint16) + +def test_v3_2_11bit_data(test_data_path): + data_path = os.path.join(test_data_path, 'v3', 'ndtiff3.2_11bit_1') + dataset = Dataset(data_path) + assert(dataset.read_metadata(time=0)['BitDepth'] == 11) + assert(dataset.read_image(time=0).dtype == np.uint16) diff --git a/test_data/v3/ndtiff3.2_11bit_1/NDTiff.index b/test_data/v3/ndtiff3.2_11bit_1/NDTiff.index new file mode 100644 index 0000000..473251c Binary files /dev/null and b/test_data/v3/ndtiff3.2_11bit_1/NDTiff.index differ diff --git a/test_data/v3/ndtiff3.2_11bit_1/ndtiff3.2_11bit_NDTiffStack.tif b/test_data/v3/ndtiff3.2_11bit_1/ndtiff3.2_11bit_NDTiffStack.tif new file mode 100644 index 0000000..197bb85 Binary files /dev/null and b/test_data/v3/ndtiff3.2_11bit_1/ndtiff3.2_11bit_NDTiffStack.tif differ