-
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(brain_extraction): Remove duplicated code, problematic deviation from antsBrainExtraction #931
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #931 +/- ##
==========================================
+ Coverage 69.37% 71.12% +1.74%
==========================================
Files 86 87 +1
Lines 8474 8477 +3
Branches 1057 1057
==========================================
+ Hits 5879 6029 +150
+ Misses 2373 2220 -153
- Partials 222 228 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@mgxd I would appreciate a review here. |
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.
Looks reasonable to me - tests inspire confidence.
I personally find this logic easier to follow and compare between the conditions.
Agreed, though I noticed there are still 2disconnect
s remaining. Do you want to tackle that refactor in this PR as well?
antsBrainExtraction.sh passes the original N4 corrected image to Atropos, where we have been running a masked N4 before Atropos. We have examples where this difference leads to failures that do not occur in the original ANTs workflow. Further, if we do run Atropos, then this result is discarded and N4 is run using a white-matter mask. This patch therefore simply passes the original N4 image to the Atropos workflow, but otherwise leaves the workflow unchanged.
0ba6838
to
f8a20dc
Compare
Sure. I also changed |
f8a20dc
to
5aa974d
Compare
5aa974d
to
4483782
Compare
niworkflows/anat/ants.py
Outdated
# Check ANTs version | ||
try: | ||
inu_n4_final.inputs.rescale_intensities = True | ||
except ValueError: | ||
warn( | ||
"N4BiasFieldCorrection's --rescale-intensities option was added in ANTS 2.1.0 " | ||
f'({inu_n4.interface.version} found.) Please consider upgrading.', | ||
UserWarning, | ||
stacklevel=1, | ||
) |
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.
Rebased to re-add this check, which was removed in passing. If we want to remove these, that can be a separate PR.
@mgxd Good to go? |
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.
very minor commment, LGTM
Co-authored-by: Mathias Goncalves <[email protected]>
1.13.0 (March 20, 2025) New feature release in the 1.13.x series. This release restructures the ANTs brain extraction workflow. This should be a backwards compatible change, but a minor release is used out of caution. * FIX: Remove duplicated code, problematic deviation from antsBrainExtraction (#931) * FIX: Listify numbers (#925) * ENH: Allow + symbol in label entities (#926, #927) * STY: Apply various ruff checks (#913, #915, #917, #918, #919, #930)
As discussed in #928, running a masked N4 before calling Atropos can lead to failures, although I don't fully understand why. Nonetheless, passing the output of the first N4 correction resolves the issue in the case I'm looking at as well as brings the workflow into line with
antsBrainExtraction.sh
, which does not do this step.Furthermore, if
atropos_wf
is called, then N4 is called using the white matter mask at the end, which means this is duplicated effort. This PR rearranges the workflow so that the second top-level N4 is only called ifatropos_wf
isn't created. It also shifts from the pattern:to:
I personally find this logic easier to follow and compare between the conditions.
One thing that I discovered was that the
lap_{tmpl,target}
andmrg_{tmpl,target}
nodes were defined twice, but only connected ifuse_laplacian
. Here we always define and connectmrg_{tmpl,target}
, and only create and connectlap_{tmpl,target}
ifuse_laplacian
.