Open firupolat opened 1 year ago
@bthirion or @Remi-Gau any intuition about this? Could it be an alignment issue? My narrow understanding of fmriprep and what is described here is that the data and mask resulting from the preprocessing should align with the Yeo atlas in nilearn which is in the same MNI space
realignment is probably worth checking but I would be surprised if it were the issue in this case
i have tried different things, for example using an other template, resampling image, using a different background image. but nothing worked :(
I think that the issue is related to the brain mask you use. Is it exactly the brain mask provided with Nilearn ? Did you resample it somehow ? Can you share it ?
do you mean mask_img that i used? its the one that was generated by fmriprep automatically for each subject and scan.
This is probably the culprit. I would advise to use a fixed (independent from dataset) MNI brain template.
but for example for the function image.clean_img the mask_img has to match the fmri_img and has be binary, otherwise i have an error message. i had used MNI brain template (using templetflow) as background image of the plots, but this still didnt work and i had signals from the scull or outside the scull. how else could i use the MNI brain template?
You can reinterpolate the MNI brain mask to your data, using nearest neighbor interpolation to keep it binary.
@firupolat to do that you can use resample_to_img
mask_img = image.resample_to_img(mni_brain_mask, fmri_img, interpolation="nearest")
at the beginning of your pipeline.
mask_img = image.resample_to_img(mni_brain_mask, fmri_img, interpolation="nearest")
Okay thank you with this it works generally. But why do I have to perform the steps in this direction and not vice versa. With that I mean, could I not change the order of the image and the mask so that my functional scan is the source image and the mni_brain_mask is the target image?
mask_img = image.resample_to_img(fmri_img, mni_brain_mask, interpolation="nearest")
To me, that makes more sense if it works because I would want to use the resampled functional scan also for other softwares and it would be much easier to just have the same brain size for every scan I have, i.e. that every scan is exactly in the shape of the MNI152Lin2009cAysm brain.
@ymzayek
@firupolat that was just an example suggestion following from the discussion but yes you could do the inverse. Note also that NiftiLabelsMasker has some built in resampling functionality that defaults to resample the labels image and mask image to your data; if you choose 'labels' as the target it resamples the mask_img and data to the labels image. If none is chosen it requires you to take care of the resampling beforehand as suggested. See the resampling_target
parameter here: https://nilearn.github.io/stable/modules/generated/nilearn.maskers.NiftiLabelsMasker.html#nilearn.maskers.NiftiLabelsMasker
Is there an existing issue for this?
Operating system
Operating system version
For example one of the following:
Python version
nilearn version
0.10.2
Expected behavior
I did first and then second level glm with my resting state data, and the plots always dont match the brain image from the background. see attached the firstlevel glm plot ob subject40 with contrast yeo network 7, as well as second level glm plot from 40 participants pre and post intervention with contrast drug vs. placebo
Current behavior & error messages
This is what I got:
i dont have any error messages but the plots that i get are not good, since they show significant signal from outside the brain. and also the significant results that i get are not even making sense sometimes. see the plots that i postet in the section above for the analysis of yeo network 7. maybe this happens bc i have preprocessed the data with fmriprep and have all the data in the MNI152NLin2009cAsym and this doesnt allign with the MNI space of nilearn.
Steps and code to reproduce bug