Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve robustness of brain extraction pipeline #734

Open
jrdalenberg opened this issue Jul 19, 2022 · 8 comments
Open

Improve robustness of brain extraction pipeline #734

jrdalenberg opened this issue Jul 19, 2022 · 8 comments

Comments

@jrdalenberg
Copy link

jrdalenberg commented Jul 19, 2022

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
sub-p1651_dseg

20.2.6
sub-p1651_dseg

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

@zhengchencai
Copy link

@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
Copy link
Author

@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.

@jrdalenberg
Copy link
Author

Rerunning the exact same analysis did indeed fix the problem. Pretty weird.

@zhengchencai
Copy link

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 :)

@effigies
Copy link
Member

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.

@effigies effigies added enhancement and removed bug labels Jul 22, 2022
@effigies effigies transferred this issue from nipreps/fmriprep Jul 22, 2022
@effigies effigies changed the title Failed tissue segmentation and normalization fmriprep 21.0.2 Improve robustness of brain extraction pipeline Jul 22, 2022
@zhengchencai
Copy link

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.

@jrdalenberg
Copy link
Author

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.

@zhengchencai
Copy link

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,

image

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

image

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

3 participants