Hi ,
I want to plot a 3D .nii fmri data with nilearn, but this error occures:
AttributeError: module ‘nibabel’ has no attribute ‘spatialimages’
my fmri data is prepossessed with afni .
Hi ,
I want to plot a 3D .nii fmri data with nilearn, but this error occures:
AttributeError: module ‘nibabel’ has no attribute ‘spatialimages’
my fmri data is prepossessed with afni .
Hum, that’s strange. I wonder if you do not have a very old version of nibabel. What’s your nibabel version? You can find this out with:
import nibabel
nibabel.__version__
Would you mind trying this: converting using https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dAFNItoNIFTI.html and then try to plot with Nilearn.
If it works then may be we should handle AFNI images by converting them.
the version is : ‘2.0.2’
I cannot reproduce, even with nibabel 2.0.2.
Can you post the full traceback.
File “”, line 18, in
display = plotting.plot_glass_brain(result_img)#,cmap=‘cool’,colorbar=True,plot_abs=True)
File “C:\Users\Mansooreh\Anaconda3\lib\site-packages\nilearn\plotting\img_plotting.py”, line 1130, in plot_glass_brain
stat_map_img = _utils.check_niimg_3d(stat_map_img, dtype=‘auto’)
File “C:\Users\Mansooreh\Anaconda3\lib\site-packages\nilearn_utils\niimg_conversions.py”, line 322, in check_niimg_3d
return check_niimg(niimg, ensure_ndim=3, dtype=dtype)
File “C:\Users\Mansooreh\Anaconda3\lib\site-packages\nilearn_utils\niimg_conversions.py”, line 271, in check_niimg
niimg = load_niimg(niimg, dtype=dtype)
File “C:\Users\Mansooreh\Anaconda3\lib\site-packages\nilearn_utils\niimg.py”, line 111, in load_niimg
elif not isinstance(niimg, nibabel.spatialimages.SpatialImage):
AttributeError: module ‘nibabel’ has no attribute ‘spatialimages’
I’ve tried reproducing this in an anaconda environment (Python: 3.5, nibabel: 2.0.2), and had no troubles finding nibabel.spatialimages.SpatialImage:
Python 3.5.6 |Anaconda, Inc.| (default, Aug 26 2018, 16:30:03)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import nibabel
>>> nibabel.spatialimages.SpatialImage
<class 'nibabel.spatialimages.SpatialImage'>
Perhaps there’s an issue with your install. Could you try conda update nibabel?
The problem is solved with updating nibabel !!!
Thank you very much for your help.
Thank you for your help. The problem is solved with updating nibabel.
MANAGED BY INCF