Nilearn CanICA Cannot Generate ICs from Resting State res4d Image

(pardon any formatting problems or missing information, first time posting here and haven’t quite gotten the hang of it)

We are looking to pull group component masks from pre-processed functional MRI data. All 27 subjects have been run through fMRIPrep and the resulting images (sub-001_task-restingstate_space-MNI152NLin2009cAsym_desc-smoothAROMAnonaggr_bold.nii.gz) were then run through FEAT first level analysis (BET brain extraction, 7mm smoothing. 100s highpass filter, and a custom model of one column of 1s). The oddity of the model is due to us wanting to look at the unexplained variance in our resting state signal (residual signal, res4d). Originally, we tried empty (all zeros) but all ones provided better results.

Following all of this, we looked to take the residual signal, unexplained by the model (our stats/res4d.nii.gz image) and extract group level components via ICA. Attempts with nilearn’s CanICA and Dictionary ICA fail, reporting “ValueError: The mask is invalid as it is empty: it masks all data.”

Further attempts to extract components via MELODIC fail at the Stats stage, reporting “No convergence after 500 steps”. Nilearn does not produce any images and MELODIC simply produces a completely empty filtered_func_data.ica/mask.nii.gz file.

What could be preventing these programs from extracting components out of the res4d image? Running the exact same steps on different outputs from FEAT (i.e. filtered_func_data.nii.gz) provides components with no errors at all, but this image (filtered_func_data.nii.gz) is not the signal we are looking for. Why is an empty mask always computed from res4d.nii.gz?

In nilearn, have you tried supplying a mask to CanICA? This might solve your problem.

I see the mask parameter in the CanICA function, and I get that supplying a mask of my own would bypass the mask generation step that is failing with my runs, but what exactly would my provided mask do? The image is already skull stripped so it would not be a brain mask I am supplying, what kind of mask would be given as an argument?

Use a brain mask, even if your image is skull stripped.

All the images are in MNI space, so I used the MNI 2mm brain mask and it worked great! Thank you for the help