From d33b071c587c9f2ac26c8b8994c3997191279ebf Mon Sep 17 00:00:00 2001 From: John Wilkie Date: Wed, 5 Jun 2024 13:37:02 +0100 Subject: [PATCH 1/4] Fixed issue when exporting NifTI annotations without polygons --- darwin/exporter/formats/nifti.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/darwin/exporter/formats/nifti.py b/darwin/exporter/formats/nifti.py index 64dcb353b..c88b36eb9 100644 --- a/darwin/exporter/formats/nifti.py +++ b/darwin/exporter/formats/nifti.py @@ -83,9 +83,10 @@ def export(annotation_files: Iterable[dt.AnnotationFile], output_dir: Path) -> N for ann in video_annotation.annotations if ann.annotation_class.annotation_type == "polygon" ] - populate_output_volumes_from_polygons( - polygon_annotations, slot_map, output_volumes - ) + if polygon_annotations: + populate_output_volumes_from_polygons( + polygon_annotations, slot_map, output_volumes + ) write_output_volume_to_disk( output_volumes, image_id=image_id, output_dir=output_dir ) @@ -350,7 +351,6 @@ def populate_output_volumes_from_polygons( plane, frame_idx, ) - return volume def populate_output_volumes_from_raster_layer( From d3b8e94c1ba3377162b0b75ef2ae5767143a8a40 Mon Sep 17 00:00:00 2001 From: John Wilkie Date: Wed, 5 Jun 2024 13:58:26 +0100 Subject: [PATCH 2/4] Added tests --- .../exporter/formats/export_nifti_test.py | 47 +++++++++++++++++- tests/data.zip | Bin 244083 -> 248307 bytes 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/tests/darwin/exporter/formats/export_nifti_test.py b/tests/darwin/exporter/formats/export_nifti_test.py index d21c8d596..648e1ed72 100644 --- a/tests/darwin/exporter/formats/export_nifti_test.py +++ b/tests/darwin/exporter/formats/export_nifti_test.py @@ -1,5 +1,6 @@ import tempfile from pathlib import Path +from unittest.mock import patch from zipfile import ZipFile import nibabel as nib @@ -77,7 +78,7 @@ def test_video_annotation_nifti_export_mpr(team_slug_darwin_json_v2: str): video_annotations = list( darwin_to_dt_gen(video_annotation_filepaths, False) ) - nifti.export(video_annotations, output_dir=tmpdir) + nifti.export(video_annotations, output_dir=Path(tmpdir)) export_im = nib.load( annotations_dir / "hippocampus_001_mpr_1_test_hippo.nii.gz" ).get_fdata() @@ -85,3 +86,47 @@ def test_video_annotation_nifti_export_mpr(team_slug_darwin_json_v2: str): annotations_dir / "hippocampus_001_mpr_1_test_hippo.nii.gz" ).get_fdata() assert np.allclose(export_im, expected_im) + + +def test_export_calls_populate_output_volumes_from_polygons( + team_slug_darwin_json_v2: str, +): + with patch( + "darwin.exporter.formats.nifti.populate_output_volumes_from_polygons" + ) as mock: + with tempfile.TemporaryDirectory() as tmpdir: + with ZipFile("tests/data.zip") as zfile: + zfile.extractall(tmpdir) + annotations_dir = ( + Path(tmpdir) + / team_slug_darwin_json_v2 + / "nifti/releases/latest/annotations" + ) + video_annotation_filepaths = [annotations_dir / "polygon_no_mask.json"] + video_annotations = list( + darwin_to_dt_gen(video_annotation_filepaths, False) + ) + nifti.export(video_annotations, output_dir=Path(tmpdir)) + mock.assert_called() + + +def test_export_calls_populate_output_volumes_from_raster_layer( + team_slug_darwin_json_v2: str, +): + with patch( + "darwin.exporter.formats.nifti.populate_output_volumes_from_raster_layer" + ) as mock: + with tempfile.TemporaryDirectory() as tmpdir: + with ZipFile("tests/data.zip") as zfile: + zfile.extractall(tmpdir) + annotations_dir = ( + Path(tmpdir) + / team_slug_darwin_json_v2 + / "nifti/releases/latest/annotations" + ) + video_annotation_filepaths = [annotations_dir / "mask_no_polygon.json"] + video_annotations = list( + darwin_to_dt_gen(video_annotation_filepaths, False) + ) + nifti.export(video_annotations, output_dir=Path(tmpdir)) + mock.assert_called() diff --git a/tests/data.zip b/tests/data.zip index 5713fff0f8350e8c994f42bea948c70827469182..dedd46487114a5342ef71297481f94041cde0824 100644 GIT binary patch delta 19549 zcmb7r2_O~S8@IWG?7Qp|DalSm$sV#~%@VRJd#O~aYb%m9G@{Zbl!(f0l_jl~%3DH- z7TT0jDx&Yq40GpR_5Huk`+9rl{C?;6oaH&^IWy;J4a_RSg8r05H0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^s5}_LUT4t@R!d(7zF{RaoqrZd8yPY1o3lc=UoC?Dj2RfG z`@3d={Zg8e(qC*K59Q-9p^KJvXj$&T;?wBPSZ61+QGrlG&74s{Cw-nhXI1bVhu0&D zizPz|+D@v7?h9?y&=mBEABQ**Z6kglUC$x-+F%Ao*)9@=2sK=!DL-r(3c5atVA~j> zBOd1wXUH&yQ+Qrz4QF6{e+m{_nQ;M8^6VK((hf8gqFoTt2Q=lqBSW#d$T5P_ z&k%-OL@PRJ6imJ-%$64yk>D<8MsRQq(mhkCd(kCCx#Pl6YA6^l`M{IOa%@z*xHO3X=Ya;Suypi@xZW u2ZHI({0&h?xzid(K-XhrAJOhtQcA;bq^{ZvnHMr!mdeO9Oe9f Date: Wed, 5 Jun 2024 14:26:55 +0100 Subject: [PATCH 3/4] Docstring updates --- darwin/exporter/formats/nifti.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/darwin/exporter/formats/nifti.py b/darwin/exporter/formats/nifti.py index c88b36eb9..3d8914c90 100644 --- a/darwin/exporter/formats/nifti.py +++ b/darwin/exporter/formats/nifti.py @@ -295,23 +295,17 @@ def populate_output_volumes_from_polygons( output_volumes: Dict, ) -> Dict: """ - Exports the given ``AnnotationFile``\\s into nifti format inside of the given - ``output_dir``. Deletes everything within ``output_dir/masks`` before writting to it. + Populates the output volumes with the given polygon annotations. The annotations are converted into masks + and added to the corresponding volume based on the series instance UID. Parameters ---------- - annotation : Union[dt.Annotation, dt.VideoAnnotation] - The Union of these two files used to populate the volume with + annotations : List[Union[dt.Annotation, dt.VideoAnnotation]] + List of polygon annotations used to populate the volume with slot_map : Dict Dictionary of the different slots within the annotation file output_volumes : Dict - volumes created from the build_output_volumes file - - Returns - ------- - volume : dict - Returns dict of volumes with class names as keys and volumes as values - + Volumes created from the build_output_volumes file """ for annotation in annotations: slot_name = annotation.slot_names[0] From e9bd835db4666df46876dbb3cbe291e05b5d50a1 Mon Sep 17 00:00:00 2001 From: John Wilkie Date: Wed, 5 Jun 2024 14:29:54 +0100 Subject: [PATCH 4/4] Docstring updates --- darwin/exporter/formats/nifti.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/darwin/exporter/formats/nifti.py b/darwin/exporter/formats/nifti.py index 3d8914c90..65576952a 100644 --- a/darwin/exporter/formats/nifti.py +++ b/darwin/exporter/formats/nifti.py @@ -293,7 +293,7 @@ def populate_output_volumes_from_polygons( annotations: List[Union[dt.Annotation, dt.VideoAnnotation]], slot_map: Dict, output_volumes: Dict, -) -> Dict: +): """ Populates the output volumes with the given polygon annotations. The annotations are converted into masks and added to the corresponding volume based on the series instance UID.