Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion darwin/exporter/formats/nifti.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ def export(
medical_metadata = video_annotation.slots[0].metadata
legacy = not medical_metadata.get("handler") == "MONAI" # type: ignore
plane_map = medical_metadata.get("plane_map", {slot_name: "AXIAL"})
primary_plane = plane_map.get(slot_name, "AXIAL")
primary_plane = medical_metadata.get(
"primary_plane", plane_map.get(slot_name, "AXIAL")
)
except (KeyError, AttributeError):
legacy = True
primary_plane = "AXIAL"
Expand Down
11 changes: 9 additions & 2 deletions tests/darwin/exporter/formats/export_nifti_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import tempfile
from pathlib import Path
from unittest.mock import patch, MagicMock
from unittest.mock import patch, MagicMock, ANY
from zipfile import ZipFile

import nibabel as nib
Expand Down Expand Up @@ -129,12 +129,19 @@ def test_export_calls_populate_output_volumes_from_raster_layer(
/ team_slug_darwin_json_v2
/ "nifti/releases/latest/annotations"
)
video_annotation_filepaths = [annotations_dir / "mask_only.json"]
video_annotation_filepaths = [annotations_dir / "non_axial_mask_only.json"]
video_annotations = list(
darwin_to_dt_gen(video_annotation_filepaths, False)
)
nifti.export(video_annotations, output_dir=Path(tmpdir))
mock.assert_called()
mock.assert_called_with(
annotation=ANY,
mask_id_to_classname=ANY,
slot_map=ANY,
output_volumes=ANY,
primary_plane="CORONAL",
)


def test_export_creates_file_for_polygons_and_masks(
Expand Down
Binary file modified tests/data.zip
Binary file not shown.