underflow encountered when using RescaleIntensity
See original GitHub issue🐛Bug
To reproduce
Download this file, and attempt to rescale between -1, and 1. output.nii.gz
import torchio as tio
import nibabel as nib
# PATH to output.nii.gz
Resection_name = 'output.nii.gz'
Resection_img = tio.ScalarImage(Resection_name)
Rescale = tio.RescaleIntensity( (-1,1) )
Resection_img = Rescale(Resection_img)
Expected behavior
Expected to Resection_img.data to be a torch tensor which has minimum -1 and maximum of 1
Actual behavior
Traceback (most recent call last):
File "test.py", line 19, in <module>
Resection_img = Rescale(Resection_img)
File "/Users/gabriellakamlish/anaconda3/envs/my_Env/lib/python3.8/site-packages/torchio/transforms/transform.py", line 121, in __call__
transformed = self.apply_transform(subject)
File "/Users/gabriellakamlish/anaconda3/envs/my_Env/lib/python3.8/site-packages/torchio/transforms/preprocessing/intensity/normalization_transform.py", line 53, in apply_transform
self.apply_normalization(subject, image_name, mask)
File "/Users/gabriellakamlish/anaconda3/envs/my_Env/lib/python3.8/site-packages/torchio/transforms/preprocessing/intensity/rescale.py", line 54, in apply_normalization
image.set_data(self.rescale(image.data, mask, image_name))
File "/Users/gabriellakamlish/anaconda3/envs/my_Env/lib/python3.8/site-packages/torchio/transforms/preprocessing/intensity/rescale.py", line 77, in rescale
array /= array_max # [0, 1]
FloatingPointError: underflow encountered in true_divide
System info
Output of python <(curl -s https://raw.githubusercontent.com/fepegar/torchio/master/print_system.py)
:
Platform: macOS-10.13.6-x86_64-i386-64bit
TorchIO: 0.18.29
PyTorch: 1.6.0
NumPy: 1.19.4
Python: 3.8.5 (default, Sep 4 2020, 02:22:02)
[Clang 10.0.0 ]
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Numpy error: underflow encountered in exp - Stack Overflow
FloatingPointError : underflow encountered in exp. The array I'm trying to define is as follows: time = np.arange(length) window ...
Read more >What is the significance of underflow during parameter update ...
I am getting an underflow error when the model is calculating how much to update parameters by multiplying learning rate, momentum, velocity, ...
Read more >Issues · fepegar/torchio · GitHub
... Topics Collections Trending Skills GitHub Sponsors Open source guides Connect with others The ReadME Project Events Community forum GitHub Education...
Read more >oblique illumination for live cell nanoscale imaging - bioRxiv
ABSTRACT To determine the molecular and/or mechanical basis of cell migration using live. 19 cell imaging tools, it is necessary to ...
Read more >UC San Diego - eScholarship.org
B: rescale intensity. ... vessels under flow, stained with MitoTracker Red. ... also has been found to have protective effect towards rat SMC...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@romainVala you’re right! It is the same error. Apparently, an underflow happens when a value is too small to be represented by the computer. I suppose the implemented workaround is to use the actual smallest number that can be represented. Anyway, it’s very low-level and doesn’t seem to be a problem for us.
@GabriellaKamlish, this will be solved in
v0.18.33
. Please upgrade and try again.@all-contributors please add @GabriellaKamlish for bug
@fepegar
I’ve put up a pull request to add @GabriellaKamlish! 🎉