|
| 1 | +.. _pydicom-and-highdicom: |
| 2 | + |
| 3 | +Highdicom and Pydicom |
| 4 | +===================== |
| 5 | + |
| 6 | +The ``highdicom`` library is built on top of ``pydicom``. This page summarizes |
| 7 | +the relationship between the two. |
| 8 | + |
| 9 | +Pydicom |
| 10 | +------- |
| 11 | + |
| 12 | +`pydicom`_ is a widely-used Python package for working with DICOM files in |
| 13 | +Python. It uses a fundamental class, ``pydicom.Dataset``, to represent DICOM |
| 14 | +objects within Python programs. It handles operations such as: |
| 15 | + |
| 16 | +- Reading and writing ``Dataset`` objects to/from files. |
| 17 | +- Accessing and setting individual attributes on ``Dataset`` objects. |
| 18 | +- Decoding pixel data within DICOM files to NumPy arrays, and encoding pixel |
| 19 | + data from NumPy to raw bytes to store within ``Dataset`` objects. |
| 20 | + |
| 21 | + |
| 22 | +Highdicom |
| 23 | +--------- |
| 24 | + |
| 25 | +There is a wide variety of DICOM objects defined in the standard, covering many |
| 26 | +types of images (X-Ray, CT, MRI, Microscopy, Ophthalmic images) as well as |
| 27 | +various types of image-derived information, such as Structured Reports, |
| 28 | +Annotations, Presentation States, Segmentations, and Parametric Maps. Formally, |
| 29 | +these "types" are known as Information Object Definitions (IODs). The standard |
| 30 | +requires different combinations of attributes are required for different IODs |
| 31 | +(e.g. the "Echo Time" attribute exists with the *MRImage* IOD but not within |
| 32 | +the *CTImage* IOD) ``pydicom`` represents all of these objects using a general |
| 33 | +``Dataset`` class, which implements behavior that is common to all of these |
| 34 | +objects. However, it does not attempt to specialize its representation to |
| 35 | +implement specific behaviors of these various IODs, leaving it up to the user |
| 36 | +to interpret the individual attributes in the file in each case. |
| 37 | + |
| 38 | +The purpose of ``highdicom`` is to build upon ``pydicom`` to implement specific |
| 39 | +behaviors for various IODs, to make it easier to correctly create and work with |
| 40 | +**specific** types of DICOM object. ``highdicom`` defines sub-classes of |
| 41 | +``pydicom.Dataset`` that implement particular IODs, for example: |
| 42 | + |
| 43 | +- :class:`highdicom.Image` (this actually covers many IODs) |
| 44 | +- :class:`highdicom.seg.Segmentation` |
| 45 | +- :class:`highdicom.sr.EnhancedSR` |
| 46 | +- :class:`highdicom.sr.ComprehensiveSR` |
| 47 | +- :class:`highdicom.sr.Comprehensive3DSR` |
| 48 | +- :class:`highdicom.pm.ParametricMap` |
| 49 | +- :class:`highdicom.pr.GrayscaleSoftcopyPresentationState` |
| 50 | +- :class:`highdicom.pr.PseudoColorSoftcopyPresentationState` |
| 51 | +- :class:`highdicom.pr.AdvancedBlendingPresentationState` |
| 52 | +- :class:`highdicom.ko.KeyObjectSelectionDocument` |
| 53 | +- :class:`highdicom.ann.MicroscopyBulkSimpleAnnotations` |
| 54 | +- :class:`highdicom.sc.SCImage` |
| 55 | + |
| 56 | +Since each of these objects are sub-classes of ``pydicom.Dataset``, they all |
| 57 | +inherit its behaviors for accessing and setting individual attributes and |
| 58 | +writing to file. They should also be interoperable with ``pydicom.Dataset``, |
| 59 | +such that they can be used anywhere a ``pydicom.Dataset`` is expected. However |
| 60 | +they also have: |
| 61 | + |
| 62 | +- A constructor that dramatically simplifies the creation of the objects while |
| 63 | + ensuring correctness. The constructors guide you through which attributes are |
| 64 | + required and enforce inter-relationships between them required by the |
| 65 | + standard. |
| 66 | +- Several of these IODs also have further methods that allow you to search, |
| 67 | + filter, and access the information within them more easily. |
| 68 | + |
| 69 | +However, not all classes within ``highdicom`` are DICOM objects, and such |
| 70 | +objects are not sub-classes of ``pydicom.Dataset``. Notable examples include |
| 71 | +:class:`highdicom.Volume`, |
| 72 | +:class:`highdicom.spatial.ImageToReferenceTransformer` (and other similar |
| 73 | +objects), :class:`highdicom.io.ImageFileReader`. |
| 74 | + |
| 75 | +.. _`pydicom`: https://pydicom.github.io/pydicom/stable/index.html |
0 commit comments