miykael / atlasreader

Python interface for generating coordinate tables and region labels from statistical MRI images
BSD 3-Clause "New" or "Revised" License
88 stars 32 forks source link

ENH: removes some more numpy warnings #82

Closed miykael closed 5 years ago

miykael commented 5 years ago

While running atlasreader in my system, I've encountered multiple numpy warnings:

~/anaconda3/lib/python3.6/site-packages/numpy/core/_methods.py:26:
  RuntimeWarning: invalid value encountered in reduce
  return umr_maximum(a, axis, None, out, keepdims)

This PR takes care of these.

Issue 1

I'm not sure why image.index_img(img_4d, 0) threw this error if the img_4d originally was only a 3D image, but the changes take care of this error.

Issue 2

The second correction is more important. I had to add a nan_to_num transformation, as some niftis might include nan. Especially the ones from SPM. This means that the if condition voxel_thresh > np.abs(stat_img.get_data()).max() was always False, the moment stat_img contains nan.

codecov-io commented 5 years ago

Codecov Report

Merging #82 into master will decrease coverage by 0.2%. The diff coverage is 80%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #82      +/-   ##
==========================================
- Coverage   91.89%   91.68%   -0.21%     
==========================================
  Files           6        6              
  Lines         358      361       +3     
==========================================
+ Hits          329      331       +2     
- Misses         29       30       +1
Impacted Files Coverage Δ
atlasreader/atlasreader.py 97.5% <80%> (-0.4%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 1ab5324...0551579. Read the comment docs.

miykael commented 5 years ago

The last commit takes care of the issue under https://github.com/miykael/atlasreader/issues/75.

The new empty mask UserWarning now just says: UserWarning: The thresholded image is empty! No clusters detected.

miykael commented 5 years ago

Correct: I had to revert the last commit. The try/except part was somehow preventing plot_glass_brain to create the glass_brain figure. So the older UserWarning is back.

miykael commented 5 years ago

This seems good to go and the only check fails are code coverage. Will merge this.