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

problem applying niftimasker #2512

Closed
LCD12345 opened this issue Jun 2, 2020 · 2 comments
Closed

problem applying niftimasker #2512

LCD12345 opened this issue Jun 2, 2020 · 2 comments
Labels
Usage Usage-related questions, to be forwarded to NeuroStars.

Comments

@LCD12345
Copy link

LCD12345 commented Jun 2, 2020

Hi

I am trying to learn about MVPA and nilearn and am encountering a problem. I have an event-related design so I followed the recommendation to create trial-specific regressors (used SPM 12), which gave me a beta image for each trial event.

I created a mask using SPM 12 neuromorphometric atlas in order to restrict the analysis to an ROI. When I come to use NiftiMasker to apply this mask to any of the beta images it provides this warning:

C:\Users\L\AppData\Roaming\Python\Python37\site-packages\nilearn\image\resampling.py:584: RuntimeWarning: NaNs or infinite values are present in the data passed to resample. This is a bad thing as they make resampling ill-defined and much slower.
  fill_value=fill_value)
C:\Users\L\AppData\Roaming\Python\Python37\site-packages\nilearn\image\resampling.py:591: RuntimeWarning: invalid value encountered in greater
  vmin = min(data.min(), 0)
C:\Users\L\AppData\Roaming\Python\Python37\site-packages\nilearn\image\resampling.py:592: RuntimeWarning: invalid value encountered in less
  vmax = max(data.max(), 0)
C:\Users\L\AppData\Roaming\Python\Python37\site-packages\nilearn\signal.py:61: UserWarning: Standardization of 3D signal has been requested but would lead to zero values. Skipping.
  warnings.warn('Standardization of 3D signal has been requested but '

I believe this has something to do with how SPM 12 uses NaN to represent the values outside of the brain, but I could be wrong. I tried nilearn.image.clean_img() but received an error because this expects a 4D array - my data are 3D betas since it was event related. In any case, I see that there is the argument ensure_finite when calling the apply_mask() which is by default True, so then I'm not sure why I receive this warning/error.

I guess I could read in the data using nibabel.load() and then manually set the NaN values to zeros but I want to apply the mask to all of my betas and the NiftiMasker expects a filename rather than an array. Maybe I could do this and re-save the beta file.

I am unable to attach a couple of my beta.nii but happy to email if it helps. Here is a link to a notebook that has a minimal example with outputs to see - hope it is helpful.

@bthirion
Copy link
Member

bthirion commented Jun 2, 2020

Normally, if you run nilearn.image.clean_img() on the list of all images,this is equivalent to running it on a 4D image. This should do the trick. Can you confirm ?
Also, we should have this kind of discussion on the Neurostars site rather than the Nilearn issue tracker.
Best,

@LCD12345
Copy link
Author

LCD12345 commented Jun 3, 2020

Also, we should have this kind of discussion on the Neurostars site rather than the Nilearn issue tracker.
Best,

Ok, going back to the thread.

@LCD12345 LCD12345 closed this as completed Jun 3, 2020
@tsalo tsalo added the Usage Usage-related questions, to be forwarded to NeuroStars. label Sep 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Usage Usage-related questions, to be forwarded to NeuroStars.
Projects
None yet
Development

No branches or pull requests

3 participants