tlambert03 / nd2

Full-featured nd2 (Nikon NIS Elements) file reader for python. Outputs to numpy, dask, and xarray. Exhaustive metadata extraction
https://tlambert03.github.io/nd2
BSD 3-Clause "New" or "Revised" License
54 stars 15 forks source link

fix: Fix images where widthPx x Bytes is not the same as expected width Bytes #90

Closed tlambert03 closed 2 years ago

tlambert03 commented 2 years ago

fixes #88 (which was also showing in a couple datasets).

Occasionally, attributes.widthPx will not be the same as attributes.widthBytes // (attributes.componentCount * attributes.bitsPerComponentInMemory // 8), as was the case with @aaristov's dataset in #88.

In those cases both the sdk reader and the native memmap reader result in skewed images (see #88). Oddly enough, the NIS elements viewer is fine with these files, suggesting they don't directly use the SDK reader internally :/

This PR catches those cases, emits a warning, and forces the image width in pixels to be widthBytes // (componentCount * bitsPerComponentInMemory // 8)