Nilearn mask API don't support per-run mask

Hi,

I have masks computed in fmriprep, but nilearn’s api don’t support array of masks, but only- one mask, or computed mask (which is obviously less exact than the per-scan brain mask computed in fmriprep).
So- how much worse are the masks computed in nilearn comparing the fmriprep masks calculated per scan?
nilearn should update the objects’ API to allow mask array (one mask per run).

(Would be able to contribute this functionality (for inclusion as an author of nilearn :wink: )

Thanks!

(@GaelVaroquaux, @ChrisGorgolewski )

1 Like

The purpose of the NiftiMasker is to give arrays uniformely encoded, so that they can be put in a statistical model. It is by design that it can take only one mask: different masks would give different array sizes and different correspondences between index number in the array and voxel number. A statistical model could not run on these.

You can merge the different masks that you have with nilearn.masking.intersect_masks:
https://nilearn.github.io/modules/generated/nilearn.masking.intersect_masks.html

1 Like

Thank you!!!

(Though this could have happened inside, of course. I understand that you prefer to force the user to gain more control)

BTW- Statistical model can run on these, employing some imputation strategy.
It makes no sense to throw away a voxel, if it is missing in one scan (intersection strategy).
A better strategy would be to receive the masks and handle the voxels missing in one scan in a more gentle way than simply throwing away the voxel, but I can understand that it isn’t currently prioritized.
What do you think?
Thank you!

I think: if you’d rather be inclusive than exclusive (which is perfectly fine), don’t apply the individual masks, that way you don’t loose information, that you could after have to impute. Then, when you extract the data, use a high “threshold” in intersect_mask.

You have all the freedom and tools to do these choices easily in nilearn. However, they are opinionated (not saying that I disagree with you), so we cannot make them by default.

1 Like