From 8877595ba7f2684d39994ca4c6572e6121e48cca Mon Sep 17 00:00:00 2001 From: Tom Close Date: Mon, 15 Jan 2024 14:40:23 +1100 Subject: [PATCH] touching up classifiers --- fileformats/medimage/__init__.py | 9 +++--- fileformats/medimage/base.py | 4 +++ .../__init__.py | 0 .../anatomical_entity/anatomical_set.py | 0 .../immaterial_anatomical_entity.py | 0 .../material_anatomical_entity/__init__.py | 5 ++++ .../anatomical_structure.py | 29 +++++++++++++++++++ fileformats/medimage/contents/derivatives.py | 6 ---- .../medimage/contents/imaging/derivatives.py | 17 +++++++++++ 9 files changed, 60 insertions(+), 10 deletions(-) rename fileformats/medimage/contents/{anatomical => anatomical_entity}/__init__.py (100%) create mode 100644 fileformats/medimage/contents/anatomical_entity/anatomical_set.py create mode 100644 fileformats/medimage/contents/anatomical_entity/immaterial_anatomical_entity.py create mode 100644 fileformats/medimage/contents/anatomical_entity/material_anatomical_entity/__init__.py create mode 100644 fileformats/medimage/contents/anatomical_entity/material_anatomical_entity/anatomical_structure.py delete mode 100644 fileformats/medimage/contents/derivatives.py create mode 100644 fileformats/medimage/contents/imaging/derivatives.py diff --git a/fileformats/medimage/__init__.py b/fileformats/medimage/__init__.py index 4bc47f5..ca8becb 100644 --- a/fileformats/medimage/__init__.py +++ b/fileformats/medimage/__init__.py @@ -46,9 +46,6 @@ from .surface import ( Gifti # noqa: F401 ) -from .contents.anatomical import ( - AnatomicalEntity # noqa: F401 -) from .contents.imaging.modality import ( # noqa: F401 ImagingModality, CombinedModalities, @@ -92,6 +89,10 @@ RG, US, ) -from .contents.derivatives import ( +from .contents.imaging.derivatives import ( + Derivative, Mask ) +from .contents.anatomical_entity.material_anatomical_entity.anatomical_structure import ( + Brain, SpinalCord +) \ No newline at end of file diff --git a/fileformats/medimage/base.py b/fileformats/medimage/base.py index d5a8958..93910ad 100644 --- a/fileformats/medimage/base.py +++ b/fileformats/medimage/base.py @@ -4,6 +4,9 @@ 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") @@ -20,6 +23,7 @@ class MedicalImage(WithClassifiers, FileSet): IGNORE_HDR_KEYS = None binary = True allowed_classifiers = (ContentsClassifier,) + exclusive_classifiers = (ImagingModality, AnatomicalEntity, Derivative) @hook.extra def read_array(self) -> "numpy.ndarray": # noqa diff --git a/fileformats/medimage/contents/anatomical/__init__.py b/fileformats/medimage/contents/anatomical_entity/__init__.py similarity index 100% rename from fileformats/medimage/contents/anatomical/__init__.py rename to fileformats/medimage/contents/anatomical_entity/__init__.py diff --git a/fileformats/medimage/contents/anatomical_entity/anatomical_set.py b/fileformats/medimage/contents/anatomical_entity/anatomical_set.py new file mode 100644 index 0000000..e69de29 diff --git a/fileformats/medimage/contents/anatomical_entity/immaterial_anatomical_entity.py b/fileformats/medimage/contents/anatomical_entity/immaterial_anatomical_entity.py new file mode 100644 index 0000000..e69de29 diff --git a/fileformats/medimage/contents/anatomical_entity/material_anatomical_entity/__init__.py b/fileformats/medimage/contents/anatomical_entity/material_anatomical_entity/__init__.py new file mode 100644 index 0000000..33a255c --- /dev/null +++ b/fileformats/medimage/contents/anatomical_entity/material_anatomical_entity/__init__.py @@ -0,0 +1,5 @@ +from .. import AnatomicalEntity + + +class MaterialAnatomicalEntity(AnatomicalEntity): + pass diff --git a/fileformats/medimage/contents/anatomical_entity/material_anatomical_entity/anatomical_structure.py b/fileformats/medimage/contents/anatomical_entity/material_anatomical_entity/anatomical_structure.py new file mode 100644 index 0000000..f1068b5 --- /dev/null +++ b/fileformats/medimage/contents/anatomical_entity/material_anatomical_entity/anatomical_structure.py @@ -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 diff --git a/fileformats/medimage/contents/derivatives.py b/fileformats/medimage/contents/derivatives.py deleted file mode 100644 index 82f6051..0000000 --- a/fileformats/medimage/contents/derivatives.py +++ /dev/null @@ -1,6 +0,0 @@ -from . import ContentsClassifier - - -class Mask(ContentsClassifier): - """A binary image that is multiplied with a real-valued image to select sections - of the image for analysis""" diff --git a/fileformats/medimage/contents/imaging/derivatives.py b/fileformats/medimage/contents/imaging/derivatives.py new file mode 100644 index 0000000..f3480d5 --- /dev/null +++ b/fileformats/medimage/contents/imaging/derivatives.py @@ -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