vibbits / nis2pyr

Python utility and library for converting Nikon .nd2 files to pyramidal OME TIFF.
BSD 3-Clause "New" or "Revised" License
8 stars 1 forks source link

Incorrect output with diagonal pattern and wrong color #3

Closed SilverViking closed 3 years ago

SilverViking commented 3 years ago

Reproduce with python nis2pyr.py "g:\xx\Testfiles\BF\RGB-8bit\Slide2-3-1_ChannelBrightfield_Seq0001.nd2" e:\temp\bug.ome.tif

Part of the nd2 metadata:

{'width': 12730, 'width_bytes': 38192, 'height': 5039, 'components': 3, 'bitsize_memory': 8, 
'bitsize_significant': 8, 'sequence_count': 1, 'tile_width': 12730, 'tile_height': 5039,  ...}

Note that width_bytes != components * width so perhaps the bug is related to nd2reader not handling padding bytes correctly?

SilverViking commented 3 years ago

g:\xx\Testfiles\Fluo\3x-16bit\SlideExpress20x.nd2 has the same problem: colors are wrong, and there is a diagonal pattern (and horizontal stripes). Zoom in on the top left corner of the image to see them.

The nd2 metadata {'width': 5735, 'width_bytes': 34412, 'height': 7563, 'components': 3, 'bitsize_memory': 16,...} again shows that width_bytes != 3 components * 2 bytes/component * width in pixels.

SilverViking commented 3 years ago

Solved (in nis2pyr >= v0.4.0) by switching from pims_nd2 to the more robust nd2 library for reading ND2 files.