Extract WM and CSF signal from fmriprep output

Hi all,

I would like to use WM and CSF average signal as nuisance regressors for my task-based fmri data. As I have used ICA-AROMA, I cannot use the WM and CSF averages in the confounds files. I want to extract the average WM and CSF signal from my unsmoothened ICA-AROMA data with the WM and CSF masks provided by fmriprep in the anat folder. I assume these masks are already eroded, but I am not sure about this. Could anyone tell me if the masks in the anat folder are already eroded?

Also, I was wondering how fmriprep extracts the WM/CSF averages. I have tried different methods (fslmeants/Marsbar/rex) to replicate the output in the confounds file, but always got slightly different output. Is there a prefered way for extracting WM/CSF signals?

Kind regards,

Hi all,

I would like to follow up on this. I am still not sure how to extract WM and CSF regressors from my data. Would it be correct to extract average beta-weights per time point from my CSF and WM masks and use this is a nuisance regressor? Or are CSF/WM regressors calculated in an other way? Any help would be greatly appreciated.


Hi @Bauke

I can’t quite provide a solution to your question, but can offer some insights that I’ve noticed and tried working through myself.

Regarding the WM and CSF probseg.nii.gz in the anat folder, those are generated from FSL FAST. These are probabilistic masks, and from visual inspection, do not appear to be eroded. You could erode them however in two steps. The first would be to threshold them in a way such that only voxels over a specified threshold are kept. For me, I like to only keep voxels with a value of 1, so that can be accomplished as such (using fslmaths)

fslmaths WM_probseg.nii.gz -thr 1.0 WM_eroded_mask.nii.gz

Note that since since I’m using a threshold (thr) of 1, the mask is binarized. If the threshold were set to a value <1, then you would want to include the bin option to binarize the masks. From here you could further erode the masks. I like using the AFNI 3dmask_tool command with the -dilate_input option (e.g -dilate_input -2). As you’ve alluded to, you probably wouldn’t want to use these eroded masks on the smoother ICA-AROMA output, but I haven’t quite figured out how to do it with the unsmoothed output. I suppose if you were going to use the masks on the smoothed ICA-AROMA data, you would need to heavily erode the masks, but in my experience, heavily eroding the CSF mask will often times leave no voxels that survive the thresholding & erosion.

That said, this comment may be helpful.

Hope this helps somewhat.

1 Like

Thanks for your answer @dlevitas, I really appreciate it! I think you made a very nice suggestion. I have continued with figuring this out since I have posted my questions. I tried to erode with fslmaths and the -ero option, however I was not sure if this was correct and how many times I should erode - so I looked further to see if there was any software I could use.

So in the end I used the CONN toolbox to extract WM and CSF regressors from my unsmoothened ICA-AROMA data. I used the ICA-AROMA noise components from fmriprep and regressed this out of my unsmoothend data. From these images I extracted WM and CSF average signal with CONN. CONN produced nice eroded masks and also the average WM and CSF time-series. I then smoothened these images again. I have added the WM and CSF average signal as regressors in my first level, on my smoothened ICA-AROMA images.

@Bauke that’s interesting, I initially took the path of least resistance and performed ICA-AROMA aggressive denoising by applying the ICA-AROMA noise components, global_signal, WM, CSF, and cosineXX confounds to my preproc_bold.nii.gz files; however, I’ve generally preferred the nonaggressive ICA-AROMA path.

To clarify your approach, by “unsmoothed ICA-AROMA” data you’re using fsl_regfit to perform nonaggressive ICA-AROMA denoising in the T1w space?

Yes, the _space-MNI152NLin2009cAsym_desc-preproc_bold_AROMA.nii.gz

HI @Bauke,

Thank you very much for this recomendation. I have been actually trying to replicate this strategy with CONN, but I can’t seem to find how to extract the regressors of CSF and WM. Did you have to write a script to extract these values or is there a way to automatically extract these in CONN? Would you be able to assist with this in any way?

Thank you once more,