Skip to content

Conversation

@vvihorev
Copy link
Contributor

Problem

When a multi-slot item containing multiple DICOM slots is exported as a nifti volume, only the first slot is exported.

Solution

Iterate over all slots when exporting a file. If there are more than one slot, create a separate AnnotationFile for each slot, thus generating a separate output volume for each mask in each slot.

Changelog

Fix nifti export broken for multi-slotted items

Copilot AI review requested due to automatic review settings April 29, 2025 16:25
@linear
Copy link

linear bot commented Apr 29, 2025

Copy link
Contributor

Copilot AI left a 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 fixes the issue with nifti export for multi-slotted items by iterating over all DICOM slots and generating a separate output volume for each mask.

  • Updated test fixtures to include a multi-slotted dicom payload in e2e_tests/objects.py.
  • Added proper error handling for export responses in e2e_tests/helpers.py and new tests for multi-slotted items in the CLI tests.
  • Modified JSON parsing (_parse_darwin_v2) in darwin/utils/utils.py to support an additional slot_index parameter and adjust filenames accordingly.

Reviewed Changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
e2e_tests/objects.py Added multi_slotted_dicom payload with two DICOM slots for testing.
e2e_tests/helpers.py Added response.raise_for_status() to ensure export errors are caught immediately.
e2e_tests/cli/test_import.py Added a new test for importing annotations from multi-slotted DICOM items.
e2e_tests/cli/test_convert.py Extended test cases to cover new nifti multislot conversion.
darwin/utils/utils.py Modified parse_darwin_json and _parse_darwin_v2 to support per-slot parsing and adjusted filename generation.
Files not reviewed (1)
  • e2e_tests/data/import/multi_slotted_annotations_with_dicom_slots/multi_slotted_dicom_item.json: Language not supported
Comments suppressed due to low confidence (1)

darwin/utils/utils.py:612

  • [nitpick] In _parse_darwin_v2, annotations are filtered by checking if annotation.slot_names[0] equals the current slot's name. This may unintentionally omit annotations that are associated with multiple slots; please verify that this behavior is intentional.
annotations = [

Copy link
Collaborator

@umbertoDifa umbertoDifa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@vvihorev vvihorev merged commit d2c55d3 into master May 6, 2025
35 checks passed
@vvihorev vvihorev deleted the dar-6239-bug-nifti-export-is-broken-for-multi-slotted-items branch May 6, 2025 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants