-
Notifications
You must be signed in to change notification settings - Fork 184
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
5ttgen: Add Deep Atropos algorithm #3057
base: dev
Are you sure you want to change the base?
Conversation
Thanks for the contribution @LucSam. See if you're able to get the command executing correctly on The other thing I'd like to include here is a test. If ANTs |
Thank you very much for your help Rob. I've updated and tested the command with sub-01 from the test data repository on |
File erroneously preserved in 25a2fec as part of MRtrix3#3057.
- Add capability take as input the concatenated tissue probability images as an alternative to the segmentation label image. - Change default allocation of brain stem to be the 5th volume, in line with 5ttgen hsvs behaviour; this can be overridden using the -white-stem option. - Change allocation of cerebellum to be subcortical grey matter. - Import updated script test data, and add tests for the new command. - Add RS to command author list.
b90c14f
to
c411b25
Compare
I succeeded in running deep atropos on my own system on a T1w from the existing test data. I noticed that in addition to the "segmentation image", which is an integer label image, it also yields for each voxel the probability ascribed to each component of the model. While these are not technically partial volume fractions, they can nevertheless be interpreted as such to produce a 5TT image that doesn't have the sharp jagged edges that you get from a label image. So I've added a code path to use those data. I have generated the outputs from the command under various configurations, and integrated them into tests (which don't run as part of CI but can be run locally). The test data are here. Note that as per comments in c411b25 I have changed the mapping of deep atropos components to 5TT tissue classes to fit what I think is best for tractography. Here's the difference in conversion from discrete segmentation vs. probability maps: I am activating the CI workflows for the CI. @LucSam you should see that there's a bunch of tests that will fail. Some of those will require that I propagate the changes in #3054 from |
- Added MRtrix3 copyright license header (2025) - Fixed indentation issues throughout file to conform with MRtrix3's two-space standardz - Fixed pylint warnings: - Corrected bad indentation (changed 4/8 spaces to 2/4 spaces) - Added pylint disable statement for unused variables in usage and execute - Addressed f-string error - Verified functionality through testing: - All deep_atropos tests passing (fromseg and fromprob with default and whitestem) Related to MRtrix3#3057
Dear @Lestropie, I was able to mimic your
as well as with
I've pushed these changes to the add_deep_atropos branch. Could you please review when you have a chance and/or instruct me with further steps? Best, Lucius |
I found it slightly clunky to get the data from antspynet out to NIfTIs for use here.
It might be useful to have example usages that show the steps necessary to get the images out; in particular if there's a way within antspynet to concatenate the 7 probability volumes into an output NIfTI rather than having to do it after the fact. There's some outstanding independent CI issues currently that are precluding assessment of the proposal; I need to merge CI fixes from |
4f03dce
to
81f5d21
Compare
I've updated the
This produces a single
which can be used directly with When trying to run
It might be related to macOS using |
@daljit46: Are you able to look into |
- Fix use of single vs double quotes so that examples can be copy-pasted into a terminal and executed successfully. - Load the input image a second time using nibabel to get the affine transformation; the ANTsImage class modifies both the content and the representation of this information, and does not contain a member variable ".affine" as utilised in the original example.
@LucSam is correct in that our documentation generation script only works on Linux because
|
686e3b1
to
cd0307e
Compare
cd0307e
to
4470cf1
Compare
Don't worry about needing to re-run the documentation generation script here: I've replaced your commit with one that fixes the typo both in the source code as you did, and in the documentation (which is all that script does). But yes, we should rectify the operation of that script in a separate PR. This should be ready to merge once I have rectified the CI tests via #3061; I'm just having a fight with Docker trying to update the container dependencies. |
This PR introduces a new option to the 5ttgen script: 5ttgen deep_atropos.
It may need syntax updates to match the dev branch structure and I welcome guidance on making those changes.
Summary of Changes:
A new script: lib/mrtrix3/_5ttgen/deep_atropos.py.
This option leverages ANTsPyNet’s antspynet.deep_atropos for tissue segmentation, addressing challenges with lesion-affected T1-weighted images.
Tissue intensity mappings in the generated deep_atropos.nii.gz are as follows:
1 = CSF
2 = GM
3 = WM
4 = SCGM
5 = Brainstem (BS)
6 = Cerebellum (CER)
Brainstem (BS) and Cerebellum (CER) are treated as white matter (WM) to align with the nature of the segmentation results.
Why This Is Useful:
Lesion-affected or clinical quality brain images may produce poor results or are difficult to achieve (e.g. via recon-all due to pathology or quality) with existing 5ttgen options such as:
5ttgen fsl
5ttgen freesurfer
5ttgen hsvs
These methods could fail to correctly segment grey matter (GM) due to lesion intensity changes, resulting in incorrect tissue assignments.
The deep_atropos option could provide a robust alternative for T1 images in such cases.
Testing and Feedback:
The changes have been tested, but further validation and review by others would be highly appreciated to confirm reliability across various datasets.