Extract WM and CSF signal from fmriprep output

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