Skip to content

Commit

Permalink
added content types into DicomCollection subclasses after TypedCollec…
Browse files Browse the repository at this point in the history
…tion refactor
  • Loading branch information
tclose committed Sep 24, 2024
1 parent 26e8bae commit 25cdb20
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 25 deletions.
23 changes: 0 additions & 23 deletions extras/fileformats/extras/medimage/tests/test_dicom_metadata.py

This file was deleted.

5 changes: 4 additions & 1 deletion fileformats/medimage/dicom.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class DicomCollection(MedicalImage, TypedCollection):
directory (DicomDir) or presented as a flat list (DicomSeries)
"""

content_types = (Dicom,)

def __len__(self) -> int:
return len(self.contents)

Expand All @@ -43,7 +45,6 @@ def series_number(self) -> str:


class DicomDir(TypedDirectory, DicomCollection):

content_types = (Dicom,)

@mtime_cached_property
Expand All @@ -52,6 +53,8 @@ def contents(self) -> ty.List[Dicom]:


class DicomSeries(TypedSet, DicomCollection):
content_types = (Dicom,)

@classmethod
def from_paths(
cls,
Expand Down
13 changes: 12 additions & 1 deletion fileformats/medimage/tests/test_dicom.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import itertools
import pytest
from medimages4tests.dummy.dicom.mri.t1w.siemens.skyra.syngo_d13c import get_image as get_dicom
from medimages4tests.dummy.dicom.mri.t1w.siemens.skyra.syngo_d13c import (
get_image as get_dicom,
)
from medimages4tests.dummy.nifti import get_image as get_nifti
from fileformats.core.exceptions import FormatMismatchError
from fileformats.core import from_paths
Expand Down Expand Up @@ -37,3 +39,12 @@ def test_dicom_series_metadata(tmp_path):
assert not isinstance(series.metadata["SeriesNumber"], list)
# check the SOP Instance ID has been converted into a list
assert isinstance(series.metadata["SOPInstanceUID"], list)


def test_dicom_dir_metadata(tmp_path):
series = DicomDir.sample(tmp_path)

# Check series number is not a list
assert not isinstance(series.metadata["SeriesNumber"], list)
# check the SOP Instance ID has been converted into a list
assert isinstance(series.metadata["SOPInstanceUID"], list)

0 comments on commit 25cdb20

Please sign in to comment.