When fMRIPrep generates the CSF mask for aCompCor, is the (dilated) gray matter mask subtracted from the CSF mask?

I’m trying to ensure that I’m describing fMRIPrep’s implementation of aCompCor correctly, but I am unsure about one step in the CSF mask generation. The boilerplate description of my run (fMRIPrep version 20.2.3, using FreeSurfer) says

For aCompCor, three probabilistic masks (CSF, WM and combined CSF+WM) are generated in anatomical space. The implementation differs from that of Behzadi et al. in that instead of eroding the masks by 2 pixels on BOLD space, the aCompCor masks are subtracted a mask of pixels that likely contain a volume fraction of GM. This mask is obtained by dilating a GM mask extracted from the FreeSurfer’s aseg segmentation, and it ensures components are not extracted from voxels containing a minimal fraction of GM. Finally, these masks are resampled into BOLD space and binarized by thresholding at 0.99 (as in the original implementation)

I think that the relevant dilation and extraction are done here (fmriprep/confounds.py at 469384ea47f1a7105705df0382ad3e6ddf116eca · nipreps/fmriprep · GitHub), where I see a subtraction of gray from white matter and gray from the combined mask. But I’m not seeing gray subtracted from CSF.

When fMRIPrep generates the CSF mask for aCompCor, is the (dilated) gray matter mask subtracted from the CSF mask (e.g., somewhere else)?

Thanks!

Very good question! Indeed, looking at the code it seems that no GM subtraction is done to the CSF mask! Subtraction is only done to WM and combined WM+CSF masks in this code.

Sounds good! Thanks for double-checking.

With the subsequent thresholding and binarization, I would believe that the subtraction would only barely change the CSF mask (if at all?). Also, the lack of a reduction of that mask’s size matches the Behzadi et al. implementation (they didn’t erode the CSF mask).

Some history about the discussions that preceded this implementation in FMRIPREP:

This behavior of not reducing the CSF mask matches indeed the Behzadi et al. implementation:

Since CSF regions are typically small compared to white matter regions mask, erosion was not applied.