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

brain_extraction_wf.inu_n4_final can be affected by extreme values #928

Open
effigies opened this issue Mar 1, 2025 · 1 comment
Open
Labels

Comments

@effigies
Copy link
Member

effigies commented Mar 1, 2025

What happened?

I've been debugging an Atropos crash that occurs for brain_extraction_wf in niworkflows 1.3.x (LTS) and 1.12.x (dev) but does not occur for antsBrainExtraction.sh in ANTs 2.3.4 (LTS) or 2.5.4 (latest).

Walking through step-by-step, here are the abbreviated inputs to Atropos:

antsBrainExtraction.sh:

graph TD;
    T1w --"TruncateImageIntensity"--> maskedN4Truncated0.nii.gz	--N4--> maskedN4Corrected0.nii.gz --> Atropos
    probseg --"resample and threshold"---> maskedBrainExtractionPriorWarped.nii.gz --> Atropos
Loading

brain_extraction_wf:

graph TD;
    T1w --"TruncateImageIntensity"--> trunc --N4--> inu_n4
    T1w --N4----> inu_n4_final --> Atropos
    thr_brainmask --N4--> inu_n4_final
    probseg --resample--> map_brainmask --threshold--> thr_brainmask --> Atropos
Loading

There is no equivalent to inu_n4_final in the antsBrainExtraction.sh workflow, so that seemed to be the most likely culprit. Re-running with verbose:

Running Atropos for 3-dimensional images.

Progress: 

itk::ExceptionObject (0x561d6f98af30)
Location: "unknown" 
File: /home/conda/feedstock_root/build_artifacts/ants_1732704629105/work/ImageSegmentation/antsGaussianListSampleFunction.hxx
Line: 100
Description: ITK ERROR: GaussianListSampleFunction(0x561d6f98c2b0): Covariance is singular (determinant = 8.91523e-07 < 1.0e-6)

If I switch the inu_n4_final image for inu_n4 in the same shell command, the run succeeds. By taking the difference of the original image and the truncated image, and using the mask passed to atropos, we can see that an extreme value lies just inside the mask:

Image

None of the extreme values occur inside brain tissue, so it does not seem problematic to pass the truncated image to inu_n4_final, like:

graph TD;
    T1w --"TruncateImageIntensity"--> trunc --N4--> inu_n4
    trunc --N4---> inu_n4_final --> Atropos
    thr_brainmask --N4--> inu_n4_final
    probseg --resample--> map_brainmask --threshold--> thr_brainmask --> Atropos
Loading

I will make this minimal patch updating the input image to inu_n4_final. If that resolves the issue I will propose it to the LTS branch and the dev branch.

What command did you use?

See above.

What version of the software are you running?

LTS and latest

How are you running this software?

Docker

Is your data BIDS valid?

Yes

Are you reusing any previously computed results?

No

Please copy and paste any relevant log output.

Additional information / screenshots

No response

@effigies effigies added the bug label Mar 1, 2025
@effigies
Copy link
Member Author

effigies commented Mar 1, 2025

Quick update: Running inu_n4_final on the truncated image did not resolve the problem.

Since atropos_wf does its own inu_n4_final and Atropos succeeds on the inu_n4 outputs, I'm passing inu_n4 outputs instead of inu_n4_final outputs. This will now more closely match the ANTs workflow, and is passing so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant