You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some nd2 images has images seem to miss one data point, making it impossible to reshape their array which also makes the file non-iterable.
Notably 18105583 == 18105584 - 1, where 18105584 == 3892 * 4651 so it would seem one data point is missing.
NIS-viewer can open the file without issues.
Error
ValueError: cannot reshape array of size 18105583 into shape (3892,4651)
Code to reproduce
#! /bin/python3
from nd2reader import ND2Reader
INPUT = "/Users/tobiasfrick/PycharmProjects/demos/test-data/multiple-channels.nd2"
def iterate():
with ND2Reader(INPUT) as images:
for _ in images:
pass
if __name__ == '__main__':
iterate()
python main.py
Traceback (most recent call last):
File "/Users/tobiasfrick/miniconda3/envs/demos/lib/python3.8/site-packages/nd2reader/parser.py", line 277, in _get_raw_image_data
image_data = np.reshape(image_group_data[image_data_start::number_of_true_channels], (height, width))
File "<__array_function__ internals>", line 5, in reshape
File "/Users/tobiasfrick/miniconda3/envs/demos/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 298, in reshape
return _wrapfunc(a, 'reshape', newshape, order=order)
File "/Users/tobiasfrick/miniconda3/envs/demos/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 54, in _wrapfunc
return _wrapit(obj, method, *args, **kwds)
File "/Users/tobiasfrick/miniconda3/envs/demos/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 43, in _wrapit
result = getattr(asarray(obj), method)(*args, **kwds)
ValueError: cannot reshape array of size 18105583 into shape (3892,4652)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 18, in <module>
main()
File "main.py", line 13, in main
for i in images:
File "/Users/tobiasfrick/miniconda3/envs/demos/lib/python3.8/site-packages/slicerator/__init__.py", line 227, in <genexpr>
return (self._get(i) for i in self.indices)
File "/Users/tobiasfrick/miniconda3/envs/demos/lib/python3.8/site-packages/slicerator/__init__.py", line 207, in _get
return self._ancestor[key]
File "/Users/tobiasfrick/miniconda3/envs/demos/lib/python3.8/site-packages/slicerator/__init__.py", line 188, in __getitem__
return self._get(indices)
File "/Users/tobiasfrick/miniconda3/envs/demos/lib/python3.8/site-packages/pims/base_frames.py", line 98, in __getitem__
return self.get_frame(key)
File "/Users/tobiasfrick/miniconda3/envs/demos/lib/python3.8/site-packages/pims/base_frames.py", line 592, in get_frame
result = self._get_frame_wrapped(**coords)
File "/Users/tobiasfrick/miniconda3/envs/demos/lib/python3.8/site-packages/nd2reader/reader.py", line 88, in get_frame_2D
return self._parser.get_image_by_attributes(t, v, c, z, y, x)
File "/Users/tobiasfrick/miniconda3/envs/demos/lib/python3.8/site-packages/nd2reader/parser.py", line 103, in get_image_by_attributes
timestamp, raw_image_data = self._get_raw_image_data(image_group_number, channel,
File "/Users/tobiasfrick/miniconda3/envs/demos/lib/python3.8/site-packages/nd2reader/parser.py", line 280, in _get_raw_image_data
image_data = np.reshape(image_group_data[image_data_start::number_of_true_channels], (height, new_width))
File "<__array_function__ internals>", line 5, in reshape
File "/Users/tobiasfrick/miniconda3/envs/demos/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 298, in reshape
return _wrapfunc(a, 'reshape', newshape, order=order)
File "/Users/tobiasfrick/miniconda3/envs/demos/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 54, in _wrapfunc
return _wrapit(obj, method, *args, **kwds)
File "/Users/tobiasfrick/miniconda3/envs/demos/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 43, in _wrapit
result = getattr(asarray(obj), method)(*args, **kwds)
ValueError: cannot reshape array of size 18105583 into shape (3892,4651)
The text was updated successfully, but these errors were encountered:
Some nd2 images has images seem to miss one data point, making it impossible to reshape their array which also makes the file non-iterable.
Notably
18105583 == 18105584 - 1
, where18105584 == 3892 * 4651
so it would seem one data point is missing.NIS-viewer can open the file without issues.
Error
Code to reproduce
Versions
Traceback
The text was updated successfully, but these errors were encountered: