-
Notifications
You must be signed in to change notification settings - Fork 51
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
The nrrd.read() function returns a read-only numpy array if the input file is compressed #99
Comments
Hello, Thanks for the issue. I fixed something similar to this by switching from It will be a bit before I have some time to work on this myself, as always, PRs are welcome. Follow the same setup as my PR, add some unit tests that demonstrate the problem is fixed. |
Hello, Many thanks for your prompt reply. You actually fixed the issue with 6b158c6 but you reverted this change when improving the performances of If |
Hm, well the odd thing is that the unit tests should have failed after reverting that change. |
Indeed, they are all passing. I assumed mistakenly that I was using the latest version of This is not the case with version You can safely close this issue. I apologize for the trouble. |
The problem has been definitively fixed since version |
Imagine that you need to load into memory a very large image file which has for instance a
gzip
encoding.Using the following snippet
you would get the following output
This means that the
numpy
array namedimg
is read-only and hence a deep copy is required for any write operation on this array. Hence we need to double the allocated memory every time we want to write on anumpy
array loaded from a compressednrrd
file.If the file is not compressed, e.g., its encoding is
raw
, the output is:In this case, the returned
numpy
array is writeable, which is not consistent with the previous behavior.The issue may come from line 446 in reader.py:
If
data
is generated from a non-writeable buffer,np.frombuffer
returns a read-onlynumpy
array.The text was updated successfully, but these errors were encountered: