Fmriprep: correction of surface extracted from Freesurfer (--anat-only)

Dear fmriprep experts,

As provided by Freesurfer, there is a way to manual editing volumes and automatically relaunch recon-all steps in order to correct surface errors (segmentation, brainmask,…): https://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/TroubleshootingDataV6.0

Using fmriprep anatomical pipeline, is there an easy way to correct for these potential errors and regenerate surfaces and associated files ?

Best,
Matthieu

Once you’ve created the FreeSurfer derivatives, you may edit as you typically would with FreeSurfer. If you then re-run fMRIPrep with a new working directory (-w flag), you will take advantage of those edits. If you want to be a little more computationally efficient, you can remove the single_subject_*_wf/anat_preproc_wf/surface_recon_wf subdirectory.

1 Like

Thanks for this trick @effigies !

Similarly to Freesurfer editing is it possible to relaunch with fMRIPrep only the needed parts of recon-all according to the manual correction applied, or have we to recompute the whole recon-all process ?

If a freesurfer/ directory exists in the output directory, fMRIPrep will use it. If it has been completely run, then it will skip processing. If there are missing outputs, the necessary steps will be run. This is true on the first run through fMRIPrep, or if you delete the parts of the working directory and rerun.

But, to be clear, fMRIPrep’s FreeSurfer interface will not detect edits and re-run appropriately; that still needs to be done via the normal FreeSurfer approach.

Thanks for this clarification.

Could you tell me wether the whole recon-all Freesurfer process is equivalent to the anatomical fmriPrep pipeline ? In case I use fmriPrep for the first run then Freesurfer for manual editing corrections, wouldn’t it cause problems ?

It is not the precise equivalent. We inject the ANTs skull-stripping result, rather than using mri_watershed, and if you’re using multiple T1w images, you might get a slightly differently aligned image.

But we account for the possibility that recon-all was run separately from fMRIPrep, and register the T1w image to the FreeSurfer T1.mgz, to ensure that transforms are correctly adjusted. (I can elaborate, if this is unclear, but the upshot is: No, this shouldn’t cause problems as long as your original T1w images are the same.)

Thanks glad to hear that.

So if I run both native Freesurfer recon-all and fmriprep anatomical pipeline based on same original T1w that should match ?
Where is saved the Tw1 to T1.mgz rigid registration ?

Yes.

<output-dir>/fmriprep/sub-*/anat/sub-*_T1w_target-fsnative_affine.txt

@effigies actually removing the single_subject_*_wf/anat_preproc_wf/surface_recon_wf subdirectory has recreated this folder and also the outputs inside the fMRIPrep/sub-****/anat subdirectory.

However, I wanted to recompute the outputs of freesurfer/sub-**** directories based on manual editing done. How would it be possible ?

Secondly, loading under freeview the subject pial surface sub-****_T1w_pial.L.surf.gii, I couldn’t see the differences with thelh.pial surface from thefreesurfer/surf directory

I may not be clear. You’re editing freesurfer/sub-****, and performing any updates with recon-all, and then running fMRIPrep again with the single_subject_*_wf/anat_preproc_wf/surface_recon_wf directory removed? What then isn’t being done that you want done?

These should be the same.

Thank you @effigies I forgot to relaunch recon-all before running fmriprep again.

Concerning the pial surfaces I thought that T1w_pial surface was in original T1w space contrary to lh.pial which is in Freesurfer T1 space.

I also keep running into this issue, where Dura tissue gets put into the brain mask, erroneously increasing the GM segmentation. Would it be possible to give fmriprep an extra “non-brain-mask” input, consisting of e.g. a dura mask, that automatically gets discarded from all brain masks?

I actually make such non-brain masks, but now I have to run fmriprep twice to make it use it…

Concerning the pial surfaces I thought that T1w_pial surface was in original T1w space contrary to lh.pial which is in Freesurfer T1 space.

It’s aligned to the FreeSurfer T1 space (which should be effectively the same as the T1w image except in some rare cases). The reasoning was that if you’re working on the surface, the ability to work directly with the FreeSurfer directory would be more important. The registration between the subject space and its corresponding fsnative space is taken into account when sampling BOLD data to the surface.

I’ll have a look at the docs to see whether we explicitly say this.

This seems like a reasonable addition, and I could review a pull request implementing this functionality.

hi,

I am using the smriprep anatomical preprocessing wf and when running it, i can see that all dataset we need for surface_recon_wf inputnode (bias-corrected T1, Ants_segmentation and skull-stripped T1) are being generated. However, during the first step of recon-all (autorecon1) i get the mghRead error that says its not able to open the file brainmask.mgz under mri folder. which make sense since we are running it with -noskullstrip option, so it wont be generated. Is there a way to fix this error ?

Thank
Shervin