Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in read_txrm #85

Closed
Skielex opened this issue Feb 7, 2020 · 0 comments
Closed

Bug in read_txrm #85

Skielex opened this issue Feb 7, 2020 · 0 comments

Comments

@Skielex
Copy link
Contributor

Skielex commented Feb 7, 2020

Hey,

I came across a bug in the read_txrm function related to slicing, as well as a type issue. I'll start with the bug. If you try to read out a portion of the images you get an exception due to a bug in the code.

Example:

reader.read_txm(file_path, slice_range=(slice(10, 11, None), slice(None), slice(None)))

Throws:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-4-7cc0a3c63f99> in <module>
----> 1 reader.read_txm(file_path, slice_range=(slice(10, 11, None), slice(None), slice(None)))

C:\Anaconda\envs\py37\lib\site-packages\dxchange\reader.py in read_txm(file_name, slice_range)
    357     """
    358 
--> 359     return read_txrm(file_name, slice_range)
    360 
    361 

C:\Anaconda\envs\py37\lib\site-packages\dxchange\reader.py in read_txrm(file_name, slice_range)
    322         img_string = "ImageData{}/Image{}".format(
    323             int(np.ceil((i + 1) / 100.0)), int(i + 1))
--> 324         array_of_images[i] = _read_ole_image(ole, img_string, metadata)[slice_range[1:]]
    325 
    326     reference = metadata['reference']

IndexError: index 10 is out of bounds for axis 0 with size 1

This issue is that the index i is 10 while the size of the array_of_images is just one in this case. Because of this it is not possible to use slices on the first axis, except if you start at 0 and step with 1.

There's also a smaller issue related to the data type. The array_of_images is always created using float32, so even though the _read_ole_image function correctly returns data as uint16 in my case, it is changed changed to float32 before being returned, which is actually very significant when working with +30GB data files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant