Skip to content

Commit

Permalink
Merge pull request #23 from ArcanaFramework/dicom-read-metadata
Browse files Browse the repository at this point in the history
Reworked to use "category-less" classifiers
  • Loading branch information
tclose authored Jan 15, 2024
2 parents a93cbdc + 8877595 commit fa39819
Show file tree
Hide file tree
Showing 14 changed files with 127 additions and 19 deletions.
50 changes: 50 additions & 0 deletions fileformats/medimage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,53 @@
from .surface import (
Gifti # noqa: F401
)
from .contents.imaging.modality import ( # noqa: F401
ImagingModality,
CombinedModalities,
DualEnergyXrayAbsorptiometry,
Fluoroscopy,
MrFluoroscopy,
RadioFluoroscopy,
MagneticResonanceImaging,
DiffusionTensorImaging,
DynamicContrast,
EnhancedMagneticResonanceImaging,
FunctionalMagneticResonanceImaging,
MagneticResonanceAngiography,
MagneticResonanceSpectroscopy,
NuclearMedicineImaging,
PositronEmissionTomography,
PanographicRadiograph,
ProjectionRadiography,
ComputedRadiography,
DigitalRadiography,
DualEnergySubtractionRadiograpgy,
Mammography,
ScreenFilmRadiography,
Stereoscopy,
StereotacticRadiography,
Spectroscopy,
Tomography,
ComputedTomography,
Ultrasound,
MRI,
PET,
CR,
CT,
DX,
MG,
MR,
NM,
PT,
PX,
RF,
RG,
US,
)
from .contents.imaging.derivatives import (
Derivative,
Mask
)
from .contents.anatomical_entity.material_anatomical_entity.anatomical_structure import (
Brain, SpinalCord
)
9 changes: 8 additions & 1 deletion fileformats/medimage/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
import logging
from fileformats.generic import FileSet
from fileformats.core import hook
from fileformats.core.mixin import WithClassifiers
from .contents import ContentsClassifier
from .contents.imaging.modality import ImagingModality
from .contents.imaging.derivatives import Derivative
from .contents.anatomical_entity.material_anatomical_entity import AnatomicalEntity

logger = logging.getLogger("fileformats")

Expand All @@ -11,12 +16,14 @@
# =====================================================================


class MedicalImage(FileSet):
class MedicalImage(WithClassifiers, FileSet):

iana_mime: ty.Optional[str] = None
INCLUDE_HDR_KEYS = None
IGNORE_HDR_KEYS = None
binary = True
allowed_classifiers = (ContentsClassifier,)
exclusive_classifiers = (ImagingModality, AnatomicalEntity, Derivative)

@hook.extra
def read_array(self) -> "numpy.ndarray": # noqa
Expand Down
5 changes: 5 additions & 0 deletions fileformats/medimage/contents/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from fileformats.core import Classifier


class ContentsClassifier(Classifier):
pass
5 changes: 5 additions & 0 deletions fileformats/medimage/contents/anatomical_entity/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .. import ContentsClassifier


class AnatomicalEntity(ContentsClassifier):
pass
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .. import AnatomicalEntity


class MaterialAnatomicalEntity(AnatomicalEntity):
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from . import MaterialAnatomicalEntity


class AnatomicalStructure(MaterialAnatomicalEntity):
pass


class CardinalOrganPart(AnatomicalStructure):
pass


class OrganRegion(CardinalOrganPart):
pass


class OrganSegment(OrganRegion):
pass


class SegmentOfNeuraxis(OrganRegion):
pass


class Brain(SegmentOfNeuraxis):
pass


class SpinalCord(SegmentOfNeuraxis):
pass
5 changes: 5 additions & 0 deletions fileformats/medimage/contents/imaging/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .. import ContentsClassifier


class ImagingSpecialty(ContentsClassifier):
pass
17 changes: 17 additions & 0 deletions fileformats/medimage/contents/imaging/derivatives.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from .. import ContentsClassifier


class Derivative(ContentsClassifier):
"""An image type that is derived from other images"""


class Mask(Derivative):
"""A binary image that is multiplied with a real-valued image to select sections
of the image for analysis"""


class FibreOrientationDistribution(Derivative):
pass


FOD = FibreOrientationDistribution
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from fileformats.core import ClassifierCategory
from .. import ContentsClassifier


class ImagingModality(ClassifierCategory):
class ImagingModality(ContentsClassifier):
ontology_link = 'http://www.radlex.org/RID/RID10311'
description = 'Form of imaging that depends on the way the image is produced'
dicom_modality = None
Expand Down Expand Up @@ -144,6 +144,7 @@ class ScreenFilmRadiography(ProjectionRadiography):
description = 'Conventional radiography'
dicom_modality = 'RG'


class Stereoscopy(ProjectionRadiography):
ontology_link = 'http://www.radlex.org/RID/RID50131'
description = None
Expand Down
6 changes: 0 additions & 6 deletions fileformats/medimage/radlex/__init__.py

This file was deleted.

5 changes: 0 additions & 5 deletions fileformats/medimage/radlex/anatomical/__init__.py

This file was deleted.

5 changes: 0 additions & 5 deletions fileformats/medimage/radlex/imaging/__init__.py

This file was deleted.

0 comments on commit fa39819

Please sign in to comment.