Open-Science-Tools / nd2reader

Pure Python library for reading NIS Elements ND2 images and metadata
http://www.lighthacking.nl/nd2reader
GNU General Public License v3.0
45 stars 28 forks source link

Bad reader sizes are parsed. #38

Open joaomamede opened 4 years ago

joaomamede commented 4 years ago

Hi, nd2reader is having trouble reading a file as it finds "Zs" that are not there.

Image was acquired with triggered imaging 1 Z, 120T, 2044 Y, 2048 X, 24 Visit Points.

pims_nd2readerSDK and pims.bioformats read the file fine. I can share but this file is 20GB. It did this to 2 files from two different experiments. I'll try to crop the data to a small XY, if it replicates I'll share.

%matplotlib inline
import pims
from nd2reader import ND2Reader
from pims import ND2_Reader as nd2_sdk

# fname = 'igfp1_caruby5_continue001trigger003.nd2'
fname = '../Data/igfp1_caruby5_VOG002.nd2'
# fname = 'igfp3_caruby3_rutin_bvd_f2_2days_xy02.nd2'
# fname = '/tmp/test.ome.tiff'

frames =  ND2Reader(fname)
frames_sdk = nd2_sdk(fname)
frames_bioformats = pims.bioformats.BioformatsReader(fname)
# frames.iter_axes = 't'  # 't' is the default already.
# frames.bundle_axes = 'zyx'  # when 'z' is available, this will be default

print(frames.sizes)
print(frames_sdk.sizes)
print(frames_bioformats.sizes)

{'x': 2048, 'y': 2044, 'c': 2, 't': 51, 'z': 1224, 'v': 24} {'x': 2048, 'y': 2044, 'c': 2, 't': 51, 'm': 24} {'x': 2048, 'y': 2044, 'c': 2, 't': 51}

rbnvrw commented 3 years ago

Thank you @joaomamede. Could you please test this again with the latest master version? There was a small error in the parsing code that might affect this issue as well (see #50). Thanks!