Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch/11bit #102

Merged
merged 4 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.micro-manager.ndtiffstorage</groupId>
<artifactId>NDTiffStorage</artifactId>
<version>2.9.34</version>
<version>2.10.0</version>
<packaging>jar</packaging>
<name>NDTiff Storage file format</name>
<description>Java-based writer and reader used for NDTiffStorage format</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
2 changes: 1 addition & 1 deletion python/ndtiff/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version_info = (1, 10, 0)
version_info = (1, 11, 0)
__version__ = ".".join(map(str, version_info))
7 changes: 5 additions & 2 deletions python/ndtiff/nd_tiff_current.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class _SingleNDTiffReader:
TEN_BIT_MONOCHROME = 3
TWELVE_BIT_MONOCHROME = 4
FOURTEEN_BIT_MONOCHROME = 5
ELEVEN_BIT_MONOCHROME = 6

UNCOMPRESSED = 0

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions python/ndtiff/test/data_loading_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Binary file added test_data/v3/ndtiff3.2_11bit_1/NDTiff.index
Binary file not shown.
Binary file not shown.