Brain mask generation in fmriprep

Hello,

First off, thank you for the fantastic software! I recently applied fmriprep (version: 23.2.0) via the singularity container (version: 3.11.1), on a list of subjects, using the following command:

singularity run -B $FREESURFER_HOME \\
               $fmriprep \\
               $bids_dir $output_dir participant \\
               --fs-license-file $FREESURFER_HOME/license.txt \\
               --fs-subjects-dir $output_dir/sourcedata/freesurfer \\
               --participant-label $subj \\
               --force-no-bbr \\
               --use-syn-sdc \\
               --skip-bids-validation \\
               --output-spaces anat MNI152NLin2009cAsym:res-2 \\
               --stop-on-first-crash \\
               -w $work_dir

Overall, it worked exactly as hoped, with one caveat: the brain mask generated after the susceptibility distortion step (green contour in the pic below) appeared severely constricted:

It also seems that this constricted brain mask (red contour in the pic below) was used for the subsequent CompCor analysis, potentially limiting the identification of nuisance regressors (magenta and blue ROIs):

Interestingly, I also ran the same script as above, but without the fieldmap-less correction flag (–use-syn-sdc), and the identified brain mask used for the CompCor analysis appeared to be accurate:

I would still prefer to use the fieldmap-less correction, if possible, since it led to slightly better co-registrations between the EPIs and T1w, and was thus wondering what you would recommend the next steps be:

  1. Is the constricted brain mask generated by --use-syn-sdc expected, given that the areas that were excluded displayed some levels of signal dropout/increased susceptibility distortion artifact (from what I can tell from the figures above)?

  2. Would it be ok to manually fix the brain mask, by let’s say resampling the anatomical brain mask (anat/sub*_ses*_space-MNI152NLin2009cAsym_desc-brain_mask.nii.gz) into func/ sub*_ses*_task-*_space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz space, as previously suggested (fMRIprep BOLD brain mask issue - #12 by jsein)? If I did this step though, how could I have fmriprep run all subsequent steps (including CompCor) with the correct mask—should I just replace the brain mask in the working dir and rerun fmriprep?

  3. Or should I replace the brain mask as described in (2) after fmriprep has run, and just use the “correct” mask for all future postprocessing steps, without re-running fmriprep?

Thank you very much in advance!

Best,

Panos

Hi @pfotiad, and welcome to neurostars!

I think syn-sdc has been known to be buggy in this version (e.g., fieldmap-less SDC in v. 23.2.0a2 producing odd/distorted results · Issue #3158 · nipreps/fmriprep · GitHub). You could try rolling back to 23.1.4 and see if that helps (or even 20.2.7, the latest Long Term Support series release). You might also try running without --force-no-bbr flag.

Unrelated, but I also recommend running singularity with additional -e --containall --writable-tmpfs flags, in general.

Best,
Steven

Thank you so much, @Steven, for your extremely prompt response! I’ll go ahead and use 23.1.4 (with and without --force-no-bbr) and let you know how it goes (will also add the extra flags you mentioned)!

Best,
Panos

Hi @pfotiad,

Sounds good, keep us updated!

Something like this might work, by using the new --levels argument of fMRIPrep in 23.2.0, which facilitates using precomputed derivatives. I think @effigies would be the authority on that though.

I suppose that would work if you do not want to use aCompCor, but I think going for a more stable and permanent fix would be preferred.

Best,
Steven

Here the thing to do would be to run with --level minimal, fix up the mask manually, and then pass the first round of derivatives to a new run with --derivatives outputs/round1 (or whatever you choose to name that output).