niworkflows
niworkflows copied to clipboard
Improve robustness of brain extraction pipeline
What happened?
While inspecting fmriprep 21.0.2 results I ran into this failed tissue segmentation, while it was succesful in 20.2.6. Any idea how I can fix this for the current scan?
21.0.2
20.2.6
What command did you use?
/opt/conda/bin/fmriprep /data /out participant --participant-label sub-p1651 --fs-no-reconall --nprocs 4 --low-mem --fs-license-file /opt/freesurfer/license.txt -t hands2 -w /scratch --me-output-echos
What version of fMRIPrep are you running?
21.0.2
How are you running fMRIPrep?
Docker
Is your data BIDS valid?
Yes
Are you reusing any previously computed results?
No
Please copy and paste any relevant log output.
No response
Additional information / screenshots
No response
@jrdalenberg I had similar issues in this post. After rerunning fmriprep, it got better. Maybe this is not related to fmriprep versions, but rather the way ANTs extract the brain mask. Not sure what's the exact reason and how to fix it.
@jrdalenberg I had similar issues in this post. After rerunning fmriprep, it got better. Maybe this is not related to fmriprep versions, but rather the way ANTs extract the brain mask. Not sure what's the exact reason and how to fix it.
Hmm weird. I’ll rerun it when my whole data set is done, and see what happens.
Rerunning the exact same analysis did indeed fix the problem. Pretty weird.
If it's BET for brain extraction, it is understandable since there might be a random initialization of the center of the brain, but fMRIprep is using ANTs which is templated-based brain extraction. Maybe the developers know much more details and there is something I did not notice and made a mistake. @jrdalenberg what is the approximate portion of cases with such issues in your first run? In my case, I have 37/106 (using 20.0.5). Certainly, this is not any test-retest at all, and my dataset has a long time span from 2007 to 2022 which is hard to expect the absence of special cases after running any pipeline. However, it would be nice to learn the trick :)
ANTs is template-based, but there are random initializations for the registration of the template. I don't have a strong intuition on why you would get such a significant departure, but it seems like it could stand some work to make it more robust.
I will move this issue over to niworkflows, where the brain extraction pipeline is implemented.
Thanks for the clarification @effigies. Do you think it is possible to run a few brain extractions (e.g., 5) in the pipeline before proceeding and just select, by checking the similarity of these 5 masks, a common initialization or directly a mask or an averaged mask after removing outliers or even more complex like a probability mask? Since a few brain extractions are not that computationally expensive, especially the rest nodes after brain extractions will be wasted if the mask is not good just due to the initialization.
If it's BET for brain extraction, it is understandable since there might be a random initialization of the center of the brain, but fMRIprep is using ANTs which is templated-based brain extraction. Maybe the developers know much more details and there is something I did not notice and made a mistake. @jrdalenberg what is the approximate portion of cases with such issues in your first run? In my case, I have 37/106 (using 20.0.5). Certainly, this is not any test-retest at all, and my dataset has a long time span from 2007 to 2022 which is hard to expect the absence of special cases after running any pipeline. However, it would be nice to learn the trick :)
2 out of 95.
Just to update this issue. I realized one can specify the brain extraction template in fmriprep. So I tried https://github.com/templateflow/tpl-MNI152NLin2009cAsym, --skull-strip-template MNI152NLin2009cAsym
. The brain extraction is still not good. I understand there is a random initialization in ANTs brain extraction parameter prior, but after 3 runs (using both 21.0.2 and 22.0.0rc2) I never get a good brain mask, for instance,
On the other hand, I tried standalone ANTs antsBrainExtraction.sh as follows, 3 runs all provided acceptable brain masks
antsBrainExtraction.sh -d 3 -a sub-xx_T1w.nii.gz -e tpl-MNI152NLin2009cAsym_res-01_T1w.nii.gz -m tpl-MNI152NLin2009cAsym_res-01_desc-brain_probseg.nii.gz -o sub-xx_T1w_brain
Maybe I could just extract brain masks before fmriprep for those cases without good brain extraction after the 1st fmriprep run, but it would be nice to have everything done in the same way for the whole data set.
Thanks