-
Notifications
You must be signed in to change notification settings - Fork 47
[DAR-7134][External] Add multi-segment nifti export support #1086
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
Conversation
Modify nifti exporter to create an additional nifti file that contains all segments of the annotated volume
Fix pixel offset in anisotropic test data Add sagittal and axial test data
Add test ensuring correct import of multi-label nifti file, by asserting no error is produced in the process, and that the number of unique values in the produced array is coherent with the nifti file
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.
Pull Request Overview
This PR implements multi-segment NIfTI export functionality, allowing the exporter to generate a single multi-label NIfTI file per slot containing all segments, in addition to the existing individual files per label.
- Adds support for creating multi-segment NIfTI files with "_Segments" suffix
- Implements test coverage for the new multi-segment export functionality
- Includes test data with Darwin JSON annotations and ground truth NIfTI files
Reviewed Changes
Copilot reviewed 6 out of 9 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
tests/darwin/importer/formats/import_nifti_test.py |
Adds test to verify multi-label NIfTI import processing |
tests/darwin/exporter/formats/export_darwin_test.py |
Adds comprehensive test for multi-segment NIfTI export with ground truth comparison |
tests/darwin/data/nifti/multi_segment/*/darwin.json |
Test data files containing Darwin JSON annotations for different anatomical planes |
darwin/exporter/formats/nifti.py |
Core implementation adding multi-segment export logic and constants |
Comments suppressed due to low confidence (2)
darwin/exporter/formats/nifti.py:62
- The variable name 'multi_segments_label' is misleading as it contains an ID value, not a label. Consider renaming to 'MULTI_SEGMENTS_ID' or 'ALL_SEGMENTS_ID' and make it a constant.
multi_segments_label = "0"
darwin/exporter/formats/nifti.py:63
- Variable should follow constant naming convention. Rename to 'MULTI_SEGMENTS_NAME' to indicate it's a module-level constant.
multi_segments_name = "Segments"
Copy of the original PR #1082 by @Jo-Byr, to run our CI
Problem
The current nifti exporter creates one nifti file per slot and label, it would be useful to generate one multi-label nifti per slot.
Solution
This solution merges all generated nifti file into one, while maintaining the previous ones, with the suffix "Segments".
Modified nifti exporter to do the above.
Added unit test comparing produced multi-label nifti's array to a manually generated nifti
Changelog
Add multi-segment nifti export support