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
46 stars 29 forks source link

KeyError when opening nd2 file #48

Closed dkeekstra closed 3 years ago

dkeekstra commented 3 years ago

When i'm opening a nd2 file I get a key error and a return 0. Far before that there is a warning about Z-levels: UserWarning: Z-levels details missing in metadata. Using Z-coordinates instead. Unfortunately I cant share the file but it contains a 500 frames long video of a microscope. The file is about 1gb.

Here is a part of the trackback:

nd2reader\raw_metadata.py:171: UserWarning: Z-levels details missing in metadata. Using Z-coordinates instead. warnings.warn("Z-levels details missing in metadata. Using Z-coordinates instead.") ... my call to nd2 nd2reader\parser.py", line 36, in init self._parse_metadata() nd2reader\parser.py", line 143, in _parse_metadata self.metadata = self._raw_metadata.dict nd2reader\raw_metadata.py", line 27, in dict return self.get_parsed_metadata() nd2reader\raw_metadata.py", line 58, in get_parsed_metadata self._parse_experiment_metadata() nd2reader\raw_metadata.py", line 332, in _parse_experiment_metadata self._metadata_parsed['experiment']['loops'] = self._parse_loop_data(raw_data[six.b('uLoopPars')]) nd2reader\raw_metadata.py", line 344, in _parse_loop_data loops = get_loops_from_data(loop_data) nd2reader\common_raw_metadata.py", line 54, in get_loops_from_data loops = [loops[i] for i in range(len(loops)) if loop_data[six.b('pPeriodValid')][i] == 1] nd2reader\common_raw_metadata.py", line 54, in loops = [loops[i] for i in range(len(loops)) if loop_data[six.b('pPeriodValid')][i] == 1] KeyError: 0

dkeekstra commented 3 years ago

I copied the master from GitHub and used it locally in my repository now it works strangely...