Extractors
extractors
#
CTMetadataExtractor
#
Bases: imgtools.dicom.dicom_metadata.extractor_base.ModalityMetadataExtractor
Metadata extractor for CT modality DICOM datasets.
This subclass defines modality-specific tags and computed fields relevant to CT (Computed Tomography) imaging. It extends the base metadata extractor with CT-specific acquisition and reconstruction parameters.
Methods:
Name | Description |
---|---|
computed_fields |
A mapping of metadata field names to callables that compute their values. |
extract |
Extract metadata tags and computed fields from a DICOM dataset. |
metadata_keys |
Return a predictable, sorted list of metadata field names. |
modality |
The DICOM modality handled by this extractor (e.g., "CT", "MR"). |
modality_tags |
A set of DICOM tags specific to the modality handled by this extractor. |
computed_fields
#
computed_fields() -> typing.Mapping[
str,
imgtools.dicom.dicom_metadata.extractor_base.ComputedField,
]
A mapping of metadata field names to callables that compute their values.
The callable should accept a pydicom Dataset and return a value.
Returns:
Type | Description |
---|---|
dict[str, Callable[[pydicom.Dataset], imgtools.dicom.dicom_metadata.extractor_base.ComputedValue]]
|
Mapping of field names to computation functions. |
CT-specific computed fields.
|
|
Returns:
Type | Description |
---|---|
typing.Mapping[str, imgtools.dicom.dicom_metadata.extractor_base.ComputedField]
|
Mapping of field names to functions that compute values from DICOM datasets. |
Source code in src/imgtools/dicom/dicom_metadata/extractors.py
extract
classmethod
#
extract(
dicom: imgtools.dicom.DicomInput,
extra_tags: list[str] | None = None,
) -> (
imgtools.dicom.dicom_metadata.extractor_base.ExtractedFields
)
Extract metadata tags and computed fields from a DICOM dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
imgtools.dicom.DicomInput
|
A path, byte stream, or pydicom FileDataset. |
required |
|
list[str] | None
|
Additional DICOM tags to extract, by default None |
None
|
Returns:
Type | Description |
---|---|
dict[str, imgtools.dicom.dicom_metadata.extractor_base.ComputedValue]
|
A dictionary mapping metadata field names to values. Values may be strings, numbers, dictionaries, or lists of these types. Missing tags or errors during computation will result in an empty string. |
Notes
Be aware that using extra_tags may lead to unexpected results if the extra tags are not compatible with the modality or if they are not present in the DICOM file. The extractor will not validate the extra tags against the modality, so it's the user's responsibility to ensure that the extra tags are relevant and valid for the given DICOM file.
Source code in src/imgtools/dicom/dicom_metadata/extractor_base.py
metadata_keys
classmethod
#
Return a predictable, sorted list of metadata field names.
This includes both direct DICOM tag names and any computed metadata keys.
Returns:
Type | Description |
---|---|
list[str]
|
All metadata keys produced by this extractor. |
Source code in src/imgtools/dicom/dicom_metadata/extractor_base.py
modality
classmethod
#
modality_tags
#
A set of DICOM tags specific to the modality handled by this extractor.
Returns:
Type | Description |
---|---|
set[str]
|
Set of DICOM tag names. |
CT-specific DICOM tag names.
|
|
Returns:
Type | Description |
---|---|
set[str]
|
CT acquisition and reconstruction-related DICOM tags. |
Source code in src/imgtools/dicom/dicom_metadata/extractors.py
FallbackMetadataExtractor
#
Bases: imgtools.dicom.dicom_metadata.extractor_base.ModalityMetadataExtractor
Generic fallback extractor for unsupported or uncommon DICOM modalities.
This extractor uses only the base tags defined in the superclass and defines no modality-specific tags or computed fields. It allows graceful handling of modalities not yet explicitly supported.
Methods:
Name | Description |
---|---|
computed_fields |
A mapping of metadata field names to callables that compute their values. |
extract |
Extract metadata tags and computed fields from a DICOM dataset. |
metadata_keys |
Return a predictable, sorted list of metadata field names. |
modality |
The DICOM modality handled by this extractor (e.g., "CT", "MR"). |
modality_tags |
A set of DICOM tags specific to the modality handled by this extractor. |
computed_fields
#
computed_fields() -> typing.Mapping[
str,
imgtools.dicom.dicom_metadata.extractor_base.ComputedField,
]
A mapping of metadata field names to callables that compute their values.
The callable should accept a pydicom Dataset and return a value.
Returns:
Type | Description |
---|---|
dict[str, Callable[[pydicom.Dataset], imgtools.dicom.dicom_metadata.extractor_base.ComputedValue]]
|
Mapping of field names to computation functions. |
Returns an empty mapping since no computed fields are defined.
|
|
Returns:
Type | Description |
---|---|
typing.Mapping[str, imgtools.dicom.dicom_metadata.extractor_base.ComputedField]
|
Empty mapping. |
Source code in src/imgtools/dicom/dicom_metadata/extractors.py
extract
classmethod
#
extract(
dicom: imgtools.dicom.DicomInput,
extra_tags: list[str] | None = None,
) -> (
imgtools.dicom.dicom_metadata.extractor_base.ExtractedFields
)
Extract metadata tags and computed fields from a DICOM dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
imgtools.dicom.DicomInput
|
A path, byte stream, or pydicom FileDataset. |
required |
|
list[str] | None
|
Additional DICOM tags to extract, by default None |
None
|
Returns:
Type | Description |
---|---|
dict[str, imgtools.dicom.dicom_metadata.extractor_base.ComputedValue]
|
A dictionary mapping metadata field names to values. Values may be strings, numbers, dictionaries, or lists of these types. Missing tags or errors during computation will result in an empty string. |
Notes
Be aware that using extra_tags may lead to unexpected results if the extra tags are not compatible with the modality or if they are not present in the DICOM file. The extractor will not validate the extra tags against the modality, so it's the user's responsibility to ensure that the extra tags are relevant and valid for the given DICOM file.
Source code in src/imgtools/dicom/dicom_metadata/extractor_base.py
metadata_keys
classmethod
#
Return a predictable, sorted list of metadata field names.
This includes both direct DICOM tag names and any computed metadata keys.
Returns:
Type | Description |
---|---|
list[str]
|
All metadata keys produced by this extractor. |
Source code in src/imgtools/dicom/dicom_metadata/extractor_base.py
modality
classmethod
#
modality_tags
#
A set of DICOM tags specific to the modality handled by this extractor.
Returns:
Type | Description |
---|---|
set[str]
|
Set of DICOM tag names. |
Returns an empty set since no modality-specific tags are defined.
|
|
Returns:
Type | Description |
---|---|
set[str]
|
Empty set. |
MRMetadataExtractor
#
Bases: imgtools.dicom.dicom_metadata.extractor_base.ModalityMetadataExtractor
Methods:
Name | Description |
---|---|
computed_fields |
A mapping of metadata field names to callables that compute their values. |
extract |
Extract metadata tags and computed fields from a DICOM dataset. |
metadata_keys |
Return a predictable, sorted list of metadata field names. |
modality |
The DICOM modality handled by this extractor (e.g., "CT", "MR"). |
modality_tags |
A set of DICOM tags specific to the modality handled by this extractor. |
computed_fields
#
computed_fields() -> typing.Mapping[
str,
imgtools.dicom.dicom_metadata.extractor_base.ComputedField,
]
A mapping of metadata field names to callables that compute their values.
The callable should accept a pydicom Dataset and return a value.
Returns:
Type | Description |
---|---|
dict[str, Callable[[pydicom.Dataset], imgtools.dicom.dicom_metadata.extractor_base.ComputedValue]]
|
Mapping of field names to computation functions. |
MR-specific computed fields.
|
|
Returns:
Type | Description |
---|---|
typing.Mapping[str, imgtools.dicom.dicom_metadata.extractor_base.ComputedField]
|
Mapping of field names to functions that compute values from DICOM datasets. |
Source code in src/imgtools/dicom/dicom_metadata/extractors.py
extract
classmethod
#
extract(
dicom: imgtools.dicom.DicomInput,
extra_tags: list[str] | None = None,
) -> (
imgtools.dicom.dicom_metadata.extractor_base.ExtractedFields
)
Extract metadata tags and computed fields from a DICOM dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
imgtools.dicom.DicomInput
|
A path, byte stream, or pydicom FileDataset. |
required |
|
list[str] | None
|
Additional DICOM tags to extract, by default None |
None
|
Returns:
Type | Description |
---|---|
dict[str, imgtools.dicom.dicom_metadata.extractor_base.ComputedValue]
|
A dictionary mapping metadata field names to values. Values may be strings, numbers, dictionaries, or lists of these types. Missing tags or errors during computation will result in an empty string. |
Notes
Be aware that using extra_tags may lead to unexpected results if the extra tags are not compatible with the modality or if they are not present in the DICOM file. The extractor will not validate the extra tags against the modality, so it's the user's responsibility to ensure that the extra tags are relevant and valid for the given DICOM file.
Source code in src/imgtools/dicom/dicom_metadata/extractor_base.py
metadata_keys
classmethod
#
Return a predictable, sorted list of metadata field names.
This includes both direct DICOM tag names and any computed metadata keys.
Returns:
Type | Description |
---|---|
list[str]
|
All metadata keys produced by this extractor. |
Source code in src/imgtools/dicom/dicom_metadata/extractor_base.py
modality
classmethod
#
modality_tags
#
A set of DICOM tags specific to the modality handled by this extractor.
Returns:
Type | Description |
---|---|
set[str]
|
Set of DICOM tag names. |
Source code in src/imgtools/dicom/dicom_metadata/extractors.py
PTMetadataExtractor
#
Bases: imgtools.dicom.dicom_metadata.extractor_base.ModalityMetadataExtractor
Methods:
Name | Description |
---|---|
computed_fields |
A mapping of metadata field names to callables that compute their values. |
extract |
Extract metadata tags and computed fields from a DICOM dataset. |
metadata_keys |
Return a predictable, sorted list of metadata field names. |
modality |
The DICOM modality handled by this extractor (e.g., "CT", "MR"). |
modality_tags |
A set of DICOM tags specific to the modality handled by this extractor. |
computed_fields
#
computed_fields() -> typing.Mapping[
str,
imgtools.dicom.dicom_metadata.extractor_base.ComputedField,
]
A mapping of metadata field names to callables that compute their values.
The callable should accept a pydicom Dataset and return a value.
Returns:
Type | Description |
---|---|
dict[str, Callable[[pydicom.Dataset], imgtools.dicom.dicom_metadata.extractor_base.ComputedValue]]
|
Mapping of field names to computation functions. |
PET-specific computed fields.
|
|
Returns:
Type | Description |
---|---|
typing.Mapping[str, imgtools.dicom.dicom_metadata.extractor_base.ComputedField]
|
Mapping of field names to functions that compute values from DICOM datasets. |
Source code in src/imgtools/dicom/dicom_metadata/extractors.py
extract
classmethod
#
extract(
dicom: imgtools.dicom.DicomInput,
extra_tags: list[str] | None = None,
) -> (
imgtools.dicom.dicom_metadata.extractor_base.ExtractedFields
)
Extract metadata tags and computed fields from a DICOM dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
imgtools.dicom.DicomInput
|
A path, byte stream, or pydicom FileDataset. |
required |
|
list[str] | None
|
Additional DICOM tags to extract, by default None |
None
|
Returns:
Type | Description |
---|---|
dict[str, imgtools.dicom.dicom_metadata.extractor_base.ComputedValue]
|
A dictionary mapping metadata field names to values. Values may be strings, numbers, dictionaries, or lists of these types. Missing tags or errors during computation will result in an empty string. |
Notes
Be aware that using extra_tags may lead to unexpected results if the extra tags are not compatible with the modality or if they are not present in the DICOM file. The extractor will not validate the extra tags against the modality, so it's the user's responsibility to ensure that the extra tags are relevant and valid for the given DICOM file.
Source code in src/imgtools/dicom/dicom_metadata/extractor_base.py
metadata_keys
classmethod
#
Return a predictable, sorted list of metadata field names.
This includes both direct DICOM tag names and any computed metadata keys.
Returns:
Type | Description |
---|---|
list[str]
|
All metadata keys produced by this extractor. |
Source code in src/imgtools/dicom/dicom_metadata/extractor_base.py
modality
classmethod
#
modality_tags
#
A set of DICOM tags specific to the modality handled by this extractor.
Returns:
Type | Description |
---|---|
set[str]
|
Set of DICOM tag names. |
Source code in src/imgtools/dicom/dicom_metadata/extractors.py
RTDOSEMetadataExtractor
#
Bases: imgtools.dicom.dicom_metadata.extractor_base.ModalityMetadataExtractor
Metadata extractor for RTDOSE modality DICOM datasets.
Extracts direct and computed reference UIDs from dose DICOM files.
Methods:
Name | Description |
---|---|
computed_fields |
A mapping of metadata field names to callables that compute their values. |
extract |
Extract metadata tags and computed fields from a DICOM dataset. |
metadata_keys |
Return a predictable, sorted list of metadata field names. |
modality |
The DICOM modality handled by this extractor (e.g., "CT", "MR"). |
modality_tags |
A set of DICOM tags specific to the modality handled by this extractor. |
computed_fields
#
computed_fields() -> typing.Mapping[
str,
imgtools.dicom.dicom_metadata.extractor_base.ComputedField,
]
A mapping of metadata field names to callables that compute their values.
The callable should accept a pydicom Dataset and return a value.
Returns:
Type | Description |
---|---|
dict[str, Callable[[pydicom.Dataset], imgtools.dicom.dicom_metadata.extractor_base.ComputedValue]]
|
Mapping of field names to computation functions. |
Source code in src/imgtools/dicom/dicom_metadata/extractors.py
extract
classmethod
#
extract(
dicom: imgtools.dicom.DicomInput,
extra_tags: list[str] | None = None,
) -> (
imgtools.dicom.dicom_metadata.extractor_base.ExtractedFields
)
Extract metadata tags and computed fields from a DICOM dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
imgtools.dicom.DicomInput
|
A path, byte stream, or pydicom FileDataset. |
required |
|
list[str] | None
|
Additional DICOM tags to extract, by default None |
None
|
Returns:
Type | Description |
---|---|
dict[str, imgtools.dicom.dicom_metadata.extractor_base.ComputedValue]
|
A dictionary mapping metadata field names to values. Values may be strings, numbers, dictionaries, or lists of these types. Missing tags or errors during computation will result in an empty string. |
Notes
Be aware that using extra_tags may lead to unexpected results if the extra tags are not compatible with the modality or if they are not present in the DICOM file. The extractor will not validate the extra tags against the modality, so it's the user's responsibility to ensure that the extra tags are relevant and valid for the given DICOM file.
Source code in src/imgtools/dicom/dicom_metadata/extractor_base.py
metadata_keys
classmethod
#
Return a predictable, sorted list of metadata field names.
This includes both direct DICOM tag names and any computed metadata keys.
Returns:
Type | Description |
---|---|
list[str]
|
All metadata keys produced by this extractor. |
Source code in src/imgtools/dicom/dicom_metadata/extractor_base.py
modality
classmethod
#
modality_tags
#
A set of DICOM tags specific to the modality handled by this extractor.
Returns:
Type | Description |
---|---|
set[str]
|
Set of DICOM tag names. |
RTPLANMetadataExtractor
#
Bases: imgtools.dicom.dicom_metadata.extractor_base.ModalityMetadataExtractor
Metadata extractor for RTPLAN modality DICOM datasets.
Extracts basic DICOM tags and reference to an RTSTRUCT UID.
Methods:
Name | Description |
---|---|
computed_fields |
A mapping of metadata field names to callables that compute their values. |
extract |
Extract metadata tags and computed fields from a DICOM dataset. |
metadata_keys |
Return a predictable, sorted list of metadata field names. |
modality |
The DICOM modality handled by this extractor (e.g., "CT", "MR"). |
modality_tags |
A set of DICOM tags specific to the modality handled by this extractor. |
computed_fields
#
computed_fields() -> typing.Mapping[
str,
imgtools.dicom.dicom_metadata.extractor_base.ComputedField,
]
A mapping of metadata field names to callables that compute their values.
The callable should accept a pydicom Dataset and return a value.
Returns:
Type | Description |
---|---|
dict[str, Callable[[pydicom.Dataset], imgtools.dicom.dicom_metadata.extractor_base.ComputedValue]]
|
Mapping of field names to computation functions. |
Source code in src/imgtools/dicom/dicom_metadata/extractors.py
extract
classmethod
#
extract(
dicom: imgtools.dicom.DicomInput,
extra_tags: list[str] | None = None,
) -> (
imgtools.dicom.dicom_metadata.extractor_base.ExtractedFields
)
Extract metadata tags and computed fields from a DICOM dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
imgtools.dicom.DicomInput
|
A path, byte stream, or pydicom FileDataset. |
required |
|
list[str] | None
|
Additional DICOM tags to extract, by default None |
None
|
Returns:
Type | Description |
---|---|
dict[str, imgtools.dicom.dicom_metadata.extractor_base.ComputedValue]
|
A dictionary mapping metadata field names to values. Values may be strings, numbers, dictionaries, or lists of these types. Missing tags or errors during computation will result in an empty string. |
Notes
Be aware that using extra_tags may lead to unexpected results if the extra tags are not compatible with the modality or if they are not present in the DICOM file. The extractor will not validate the extra tags against the modality, so it's the user's responsibility to ensure that the extra tags are relevant and valid for the given DICOM file.
Source code in src/imgtools/dicom/dicom_metadata/extractor_base.py
metadata_keys
classmethod
#
Return a predictable, sorted list of metadata field names.
This includes both direct DICOM tag names and any computed metadata keys.
Returns:
Type | Description |
---|---|
list[str]
|
All metadata keys produced by this extractor. |
Source code in src/imgtools/dicom/dicom_metadata/extractor_base.py
modality
classmethod
#
modality_tags
#
A set of DICOM tags specific to the modality handled by this extractor.
Returns:
Type | Description |
---|---|
set[str]
|
Set of DICOM tag names. |
RTSTRUCTMetadataExtractor
#
Bases: imgtools.dicom.dicom_metadata.extractor_base.ModalityMetadataExtractor
Metadata extractor for RTSTRUCT modality DICOM datasets.
This class uses computed fields to extract ROI metadata and reference UIDs.
Methods:
Name | Description |
---|---|
computed_fields |
A mapping of metadata field names to callables that compute their values. |
extract |
Extract metadata tags and computed fields from a DICOM dataset. |
metadata_keys |
Return a predictable, sorted list of metadata field names. |
modality |
The DICOM modality handled by this extractor (e.g., "CT", "MR"). |
modality_tags |
A set of DICOM tags specific to the modality handled by this extractor. |
computed_fields
#
computed_fields() -> typing.Mapping[
str,
imgtools.dicom.dicom_metadata.extractor_base.ComputedField,
]
A mapping of metadata field names to callables that compute their values.
The callable should accept a pydicom Dataset and return a value.
Returns:
Type | Description |
---|---|
dict[str, Callable[[pydicom.Dataset], imgtools.dicom.dicom_metadata.extractor_base.ComputedValue]]
|
Mapping of field names to computation functions. |
RTSTRUCT-specific computed fields.
|
|
Returns:
Type | Description |
---|---|
typing.Mapping[str, imgtools.dicom.dicom_metadata.extractor_base.ComputedField]
|
Field names mapped to functions that extract computed values. |
Source code in src/imgtools/dicom/dicom_metadata/extractors.py
extract
classmethod
#
extract(
dicom: imgtools.dicom.DicomInput,
extra_tags: list[str] | None = None,
) -> (
imgtools.dicom.dicom_metadata.extractor_base.ExtractedFields
)
Extract metadata tags and computed fields from a DICOM dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
imgtools.dicom.DicomInput
|
A path, byte stream, or pydicom FileDataset. |
required |
|
list[str] | None
|
Additional DICOM tags to extract, by default None |
None
|
Returns:
Type | Description |
---|---|
dict[str, imgtools.dicom.dicom_metadata.extractor_base.ComputedValue]
|
A dictionary mapping metadata field names to values. Values may be strings, numbers, dictionaries, or lists of these types. Missing tags or errors during computation will result in an empty string. |
Notes
Be aware that using extra_tags may lead to unexpected results if the extra tags are not compatible with the modality or if they are not present in the DICOM file. The extractor will not validate the extra tags against the modality, so it's the user's responsibility to ensure that the extra tags are relevant and valid for the given DICOM file.
Source code in src/imgtools/dicom/dicom_metadata/extractor_base.py
metadata_keys
classmethod
#
Return a predictable, sorted list of metadata field names.
This includes both direct DICOM tag names and any computed metadata keys.
Returns:
Type | Description |
---|---|
list[str]
|
All metadata keys produced by this extractor. |
Source code in src/imgtools/dicom/dicom_metadata/extractor_base.py
modality
classmethod
#
modality_tags
#
A set of DICOM tags specific to the modality handled by this extractor.
Returns:
Type | Description |
---|---|
set[str]
|
Set of DICOM tag names. |
RTSTRUCT-specific direct tags (generally minimal).
|
|
Returns:
Type | Description |
---|---|
set[str]
|
A set of directly accessible RTSTRUCT tag names. |
Source code in src/imgtools/dicom/dicom_metadata/extractors.py
SEGMetadataExtractor
#
Bases: imgtools.dicom.dicom_metadata.extractor_base.ModalityMetadataExtractor
See Also
https://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.8.20.2.html
Methods:
Name | Description |
---|---|
computed_fields |
A mapping of metadata field names to callables that compute their values. |
extract |
Extract metadata tags and computed fields from a DICOM dataset. |
metadata_keys |
Return a predictable, sorted list of metadata field names. |
modality |
The DICOM modality handled by this extractor (e.g., "CT", "MR"). |
modality_tags |
A set of DICOM tags specific to the modality handled by this extractor. |
computed_fields
#
computed_fields() -> typing.Mapping[
str,
imgtools.dicom.dicom_metadata.extractor_base.ComputedField,
]
A mapping of metadata field names to callables that compute their values.
The callable should accept a pydicom Dataset and return a value.
Returns:
Type | Description |
---|---|
dict[str, Callable[[pydicom.Dataset], imgtools.dicom.dicom_metadata.extractor_base.ComputedValue]]
|
Mapping of field names to computation functions. |
SEG-specific computed fields.
|
|
Each computed field is a function that takes a pydicom.Dataset as input
|
|
and returns a computed value. The functions are defined to extract
|
|
relevant information from the DICOM dataset.
|
|
Returns:
Type | Description |
---|---|
typing.Mapping[str, imgtools.dicom.dicom_metadata.extractor_base.ComputedField]
|
Mapping of field names to functions that compute values from DICOM datasets. |
Source code in src/imgtools/dicom/dicom_metadata/extractors.py
extract
classmethod
#
extract(
dicom: imgtools.dicom.DicomInput,
extra_tags: list[str] | None = None,
) -> (
imgtools.dicom.dicom_metadata.extractor_base.ExtractedFields
)
Extract metadata tags and computed fields from a DICOM dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
imgtools.dicom.DicomInput
|
A path, byte stream, or pydicom FileDataset. |
required |
|
list[str] | None
|
Additional DICOM tags to extract, by default None |
None
|
Returns:
Type | Description |
---|---|
dict[str, imgtools.dicom.dicom_metadata.extractor_base.ComputedValue]
|
A dictionary mapping metadata field names to values. Values may be strings, numbers, dictionaries, or lists of these types. Missing tags or errors during computation will result in an empty string. |
Notes
Be aware that using extra_tags may lead to unexpected results if the extra tags are not compatible with the modality or if they are not present in the DICOM file. The extractor will not validate the extra tags against the modality, so it's the user's responsibility to ensure that the extra tags are relevant and valid for the given DICOM file.
Source code in src/imgtools/dicom/dicom_metadata/extractor_base.py
metadata_keys
classmethod
#
Return a predictable, sorted list of metadata field names.
This includes both direct DICOM tag names and any computed metadata keys.
Returns:
Type | Description |
---|---|
list[str]
|
All metadata keys produced by this extractor. |
Source code in src/imgtools/dicom/dicom_metadata/extractor_base.py
modality
classmethod
#
modality_tags
#
A set of DICOM tags specific to the modality handled by this extractor.
Returns:
Type | Description |
---|---|
set[str]
|
Set of DICOM tag names. |
Source code in src/imgtools/dicom/dicom_metadata/extractors.py
SRMetadataExtractor
#
Bases: imgtools.dicom.dicom_metadata.extractor_base.ModalityMetadataExtractor
Metadata extractor for SR (Structured Report) modality DICOM datasets.
Extracts referenced SeriesInstanceUIDs and SOPInstanceUIDs from structured reports.
Methods:
Name | Description |
---|---|
computed_fields |
A mapping of metadata field names to callables that compute their values. |
extract |
Extract metadata tags and computed fields from a DICOM dataset. |
metadata_keys |
Return a predictable, sorted list of metadata field names. |
modality |
The DICOM modality handled by this extractor (e.g., "CT", "MR"). |
modality_tags |
A set of DICOM tags specific to the modality handled by this extractor. |
computed_fields
#
computed_fields() -> typing.Mapping[
str,
imgtools.dicom.dicom_metadata.extractor_base.ComputedField,
]
A mapping of metadata field names to callables that compute their values.
The callable should accept a pydicom Dataset and return a value.
Returns:
Type | Description |
---|---|
dict[str, Callable[[pydicom.Dataset], imgtools.dicom.dicom_metadata.extractor_base.ComputedValue]]
|
Mapping of field names to computation functions. |
Source code in src/imgtools/dicom/dicom_metadata/extractors.py
extract
classmethod
#
extract(
dicom: imgtools.dicom.DicomInput,
extra_tags: list[str] | None = None,
) -> (
imgtools.dicom.dicom_metadata.extractor_base.ExtractedFields
)
Extract metadata tags and computed fields from a DICOM dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
imgtools.dicom.DicomInput
|
A path, byte stream, or pydicom FileDataset. |
required |
|
list[str] | None
|
Additional DICOM tags to extract, by default None |
None
|
Returns:
Type | Description |
---|---|
dict[str, imgtools.dicom.dicom_metadata.extractor_base.ComputedValue]
|
A dictionary mapping metadata field names to values. Values may be strings, numbers, dictionaries, or lists of these types. Missing tags or errors during computation will result in an empty string. |
Notes
Be aware that using extra_tags may lead to unexpected results if the extra tags are not compatible with the modality or if they are not present in the DICOM file. The extractor will not validate the extra tags against the modality, so it's the user's responsibility to ensure that the extra tags are relevant and valid for the given DICOM file.
Source code in src/imgtools/dicom/dicom_metadata/extractor_base.py
metadata_keys
classmethod
#
Return a predictable, sorted list of metadata field names.
This includes both direct DICOM tag names and any computed metadata keys.
Returns:
Type | Description |
---|---|
list[str]
|
All metadata keys produced by this extractor. |
Source code in src/imgtools/dicom/dicom_metadata/extractor_base.py
modality
classmethod
#
modality_tags
#
A set of DICOM tags specific to the modality handled by this extractor.
Returns:
Type | Description |
---|---|
set[str]
|
Set of DICOM tag names. |