-
Notifications
You must be signed in to change notification settings - Fork 52
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
FIX: Revision of antsBrainExtraction
, better handling edge cases
#567
Conversation
This commit: - [x] Updates the nodes with pure python interfaces based on nibabel, minimizing the need for the new ``copy_header`` of ANTs' nipype interfaces. - [x] Reorganizes the workflow so that the Atropos refinement is completely self contained. These are the first two steps to address nipreps/smriprep#125.
Best reviewed: commit by commit
Optimal code review plan (2 warnings)
|
This commit introduces two changes: - [x] If a WM prior is found within the template's structure, then it is mapped on to the individual's brain and fed as ``weight_image`` in the N4 correction. - [x] Adds regularization of the WM posterior estimated with ATROPOS, by multiplying with the WM prior mapped from the template. In the future, an easy check could be implemented here to dismiss the ATROPOS refinement if the prior and the posterior do not overlap sufficiently (i.e., the WM was not correctly labeled or segmented) Resolves: nipreps/smriprep#125 (at least for ds005/sub-08).
1e42b52
to
d4ea1f5
Compare
Codecov Report
@@ Coverage Diff @@
## master #567 +/- ##
==========================================
- Coverage 64.62% 59.23% -5.39%
==========================================
Files 43 42 -1
Lines 5215 5264 +49
Branches 760 765 +5
==========================================
- Hits 3370 3118 -252
- Misses 1688 2009 +321
+ Partials 157 137 -20
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
(init_aff, norm, [("output_transform", "initial_moving_transform")]), | ||
(norm, map_brainmask, [ | ||
("reverse_transforms", "transforms"), | ||
("reverse_invert_flags", "invert_transform_flags"), | ||
]), | ||
(map_brainmask, thr_brainmask, [("output_image", "input_image")]), | ||
(thr_brainmask, dil_brainmask, [("output_image", "op1")]), | ||
(dil_brainmask, get_brainmask, [("output_image", "op1")]), | ||
(map_brainmask, inu_n4_final, [("output_image", "weight_image")]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having trouble tracing how this originally connected through...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although not ideal, this might actually help -> https://1942-74174878-gh.circle-artifacts.com/0/docs/_build/no_version_html/html/api/niworkflows.anat.ants.html#niworkflows.anat.ants.init_brain_extraction_wf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, so it looks like we're no longer using Atropos to select white matter at all. What purpose does it now serve?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we still use ATROPOS:
- To refine the binary mask (as originally done by antsBrainExtraction.sh)
- To obtain the WM posterior (i.e., select the WM).
In some sense, now we use it even more :D
However, it is a bit implicit - see the disconnect()
call below, to replace the final outputs of the brain-extraction workflow with those coming from the ATROPOS workflow.
Addresses issues like nipreps#567 (comment)
The latest commit includes changes to make the workflow more reliable overall, fixing the problems (at least for sub-100003) I detected on ds054. I will re-run a good bunch of datasets, including the two originally identified as failing (ds005/sub-08 and ds051/sub-06) and ds054. |
I have visually confirmed that after a05dddc, the posterior most overlapping with the WM prior is correctly selected for ds051/sub-06. |
and set it as weights image in the final N4.
Addresses issues like nipreps#567 (comment)
89d3531
to
3464b24
Compare
Hello @oesteban, Thank you for updating! Cheers! There are no style issues detected in this Pull Request. 🍻 To test for issues locally, Comment last updated at 2020-09-22 18:51:16 UTC |
76445d5
to
eecfc6b
Compare
eecfc6b
to
7b9ea4f
Compare
e5b4a80
to
70fbadf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty good (looking at the before/after pictures)
Co-authored-by: Mathias Goncalves <goncalves.mathias@gmail.com>
3898340
to
ffbb03e
Compare
Good to go? |
Hey @bpinsard, I'd like to squish this into an RC2 before the LTS is cut (and preferably, cut the RC as soon as possible). Do you want to take a look into it before we go ahead? We would like to hear your opinion before merging since you'll be maintaining the LTS. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I roughly follow what happened here. No obvious problems.
I'll take @bpinsard's silence as no-opposition. The sooner we start testing this, the better. |
1.3.1 Bug-fix release in the 1.3.x series. Addresses longstanding issues in the anatomical MRI brain extraction workflow. * FIX: Revision of ``antsBrainExtraction``, better handling edge cases (nipreps#567)
This PR introduces changes to better handle the copying of headers within the workflow, which is a potential source for nipreps/smriprep#127, and addresses some problems that surface when the ATROPOS refinement step fails (nipreps/smriprep#125).
This refactor could be considered a preliminary work on #531.
copy_header
of ANTs' nipype interfaces.weight_image
in the N4 correction.