dicom_parser package¶
Subpackages¶
- dicom_parser.data_elements package
- Submodules
- dicom_parser.data_elements.age_string module
- dicom_parser.data_elements.application_entity module
- dicom_parser.data_elements.attribute_tag module
- dicom_parser.data_elements.code_string module
- dicom_parser.data_elements.date module
- dicom_parser.data_elements.date_time module
- dicom_parser.data_elements.decimal_string module
- dicom_parser.data_elements.floating_point_double module
- dicom_parser.data_elements.floating_point_single module
- dicom_parser.data_elements.integer_string module
- dicom_parser.data_elements.long_string module
- dicom_parser.data_elements.long_text module
- dicom_parser.data_elements.other_64bit_very_long module
- dicom_parser.data_elements.other_byte module
- dicom_parser.data_elements.other_double module
- dicom_parser.data_elements.other_float module
- dicom_parser.data_elements.other_long module
- dicom_parser.data_elements.other_word module
- dicom_parser.data_elements.person_name module
- dicom_parser.data_elements.private_data_element module
- dicom_parser.data_elements.sequence_of_items module
- dicom_parser.data_elements.short_string module
- dicom_parser.data_elements.short_text module
- dicom_parser.data_elements.signed_64bit_very_long module
- dicom_parser.data_elements.signed_long module
- dicom_parser.data_elements.signed_short module
- dicom_parser.data_elements.time module
- dicom_parser.data_elements.unique_identifier module
- dicom_parser.data_elements.unlimited_characters module
- dicom_parser.data_elements.unlimited_text module
- dicom_parser.data_elements.unsigned_64bit_very_long module
- dicom_parser.data_elements.unsigned_long module
- dicom_parser.data_elements.unsigned_short module
- dicom_parser.data_elements.url module
- Module contents
- dicom_parser.utils package
- Subpackages
- Submodules
- dicom_parser.utils.choice_enum module
- dicom_parser.utils.format_header_df module
- dicom_parser.utils.parse_tag module
- dicom_parser.utils.peek module
- dicom_parser.utils.private_tags module
- dicom_parser.utils.read_file module
- dicom_parser.utils.value_representation module
- dicom_parser.utils.vr_to_data_element module
- Module contents
Submodules¶
dicom_parser.data_element module¶
A wrapper around pydicom’s DataElement
class.
-
class
dicom_parser.data_element.
DataElement
(raw: pydicom.dataelem.DataElement)¶ Bases:
object
-
PRIVATE_ELEMENT_DESCRIPTION_PATTERN
= '\\[(.*)\\]|Private Creator'¶
-
VALUE_REPRESENTATION
: dicom_parser.utils.value_representation.ValueRepresentation = None¶
-
property
is_private
¶
-
property
is_public
¶
-
parse_keyword
()¶
-
parse_value
(value)¶
-
parse_values
()¶
-
to_series
() → pandas.core.series.Series¶
-
property
value
¶
-
dicom_parser.header module¶
Definition of the Header class, which extends the functionality of pydicom.
-
class
dicom_parser.header.
Header
(raw: Union[pydicom.dataset.FileDataset, str, pathlib.Path], sequence_detector=<class 'dicom_parser.utils.sequence_detector.sequence_detector.SequenceDetector'>)¶ Bases:
object
Facilitates access to DICOM header information from pydicom’s FileDataset.
-
DATAFRAME_COLUMNS
= ('Tag', 'Keyword', 'VR', 'VM', 'Value')¶
-
DATAFRAME_INDEX
= 'Tag'¶
-
property
as_dict
¶
-
property
data_elements
¶
-
detect_sequence
() → str¶ Returns the detected imaging sequence using the modality’s sequence identifying header information.
- Returns
Imaging sequence name
- Return type
-
get
(tag_or_keyword, default=None, parsed: bool = True, missing_ok: bool = True, as_json: bool = False) → Any¶ Returns the value of a pydicom data element, selected by tag (tuple) or keyword (str). Input may also be a list of such identifiers, in which case a dictionary will be returned with the identifiers as keys and header information as values.
- Parameters
- Returns
The requested data element value (or a dict for multiple values)
- Return type
Any
-
get_data_element
(tag_or_keyword) → dicom_parser.data_element.DataElement¶
-
get_parsed_value
(tag_or_keyword) → Any¶ Returns the parsed value of pydicom data element using the this class’s parser attribute. The data element may be represented by tag or by its pydicom keyword. If none is found will return None.
-
get_private_tag
(keyword: str) → tuple¶ Returns a vendor-specific private tag corresponding to the provided keyword, if the tag is registered (see the
private_tags
module). This is required because pydicom does not offer keyword access to private tags.
-
get_raw_element
(tag_or_keyword) → pydicom.dataelem.DataElement¶ Returns a pydicom PydicomDataElement from the associated FileDataset either by tag (passed as a tuple) or a keyword (passed as a string). If none found or the tag or keyword are invalid, returns None.
-
get_raw_element_by_keyword
(keyword: str) → pydicom.dataelem.DataElement¶ Returns a pydicom PydicomDataElement from the header (FileDataset isntance) by keyword.
- Parameters
keyword (str) – The keyword representing the DICOM data element in pydicom
- Returns
The requested data element
- Return type
PydicomDataElement
-
get_raw_element_by_tag
(tag: tuple) → pydicom.dataelem.DataElement¶ Returns a pydicom PydicomDataElement from the header (FileDataset isntance) by tag.
- Parameters
tag (tuple) – The DICOM tag of the desired data element
- Returns
The requested data element
- Return type
PydicomDataElement
-
get_raw_value
(tag_or_keyword)¶ Returns the raw value for the requested data element, as returned by pydicom. If none is found will return None.
-
property
keys
¶
-
sequence_identifiers
= {'Magnetic Resonance': ['ScanningSequence', 'SequenceVariant']}¶
-
dicom_parser.image module¶
Definition of the Image
class, representing a single pair of
Header
and data (3D NumPy
array).
-
class
dicom_parser.image.
Image
(raw: Union[pydicom.dataset.FileDataset, str, pathlib.Path])¶ Bases:
object
This class represents a single DICOM image (i.e. .dcm file) and provides unified access to it’s header information and data.
-
property
data
¶ Returns the pixel data array after having applied any required transformations.
- Returns
Pixel data array
- Return type
np.ndarray
-
property
default_relative_path
¶
-
fix_data
() → numpy.ndarray¶ Applies any required transformation to the data.
- Returns
Pixel array data
- Return type
np.ndarray
-
get_default_relative_path
() → pathlib.Path¶
-
property
is_fmri
¶ Returns True for fMRI images according to their header information.
- Returns
Whether this image represents fMRI data
- Return type
-
property
is_mosaic
¶ Checks whether a 3D volume is encoded as a 2D Mosaic. For more information, see the
Mosaic
class.- Returns
Whether the image is a mosaic encoded volume
- Return type
-
read_raw_data
() → numpy.ndarray¶ Reads the pixel array data as returned by pydicom.
- Returns
Pixel array data
- Return type
np.ndarray
-
property
dicom_parser.messages module¶
dicom_parser.series module¶
Definition of the Series
class.
-
class
dicom_parser.series.
Series
(path: pathlib.Path)¶ Bases:
object
This class represents a complete collection of Image instances originating from a single directory and ordered by InstanceNumber.
-
check_path
(path) → pathlib.Path¶ Converts to a
Path
instance if required and checks that it represents an existing directory.- Parameters
path (str or Path) – The provided path.
- Returns
A pathlib.Path instance representing an existing directory
- Return type
Path
- Raises
ValueError – If the provided path is not an existing directory
-
property
data
¶ Caches the stacked 3D array containing the entire series’ data.
- Returns
Series 3D data
- Return type
np.ndarray
-
get
(tag_or_keyword, default=None, parsed: bool = True, missing_ok: bool = True) → Any¶ Returns header information from the
Image
that compose this series. If one distinct value is returned from all the images’ headers, returns that value. Otherwise, returns a list of the values (ordered the same as the images attribute, by instance number).
-
get_dcm_paths
() → generator¶ Returns a generator of .dcm files within the provided directory path.
- Returns
DICOM images (.dcm files) generator
- Return type
GeneratorType
- Raises
FileNotFoundError – No DICOM images found under provided directory
-