sequence_detector

Submodules

dicom_parser.utils.sequence_detector.messages module

Strings and string formatting templates used in this module.

dicom_parser.utils.sequence_detector.sequence_detector module

Definition of the SequenceDetector class.

class dicom_parser.utils.sequence_detector.sequence_detector.SequenceDetector(rules: Optional[dict] = None)

Bases: object

Default data types detector implementation.

DEFAULT_LOOKUP: str = 'exact'
DEFAULT_OPERATOR: str = 'all'
LOOKUP_KEY: str = 'lookup'
OPERATOR_KEY: str = 'operator'
REQUIRED_RULE_KEYS: Tuple[str] = ('key', 'value')
RULES_KEY: str = 'rules'
check_definition(definition, header_fields: dict, verbose: bool = False) bool

Checks whether the specified header information values satisfy the provided definition.

Parameters
  • definition (dict or list) – The imaging sequence definition, as a dict or list of dict instances

  • header_fields (dict) – Header information provided for the comparison

  • verbose (bool) – Whether to show evaluation logs

Returns

Whether the given header information fits the definition.

Return type

bool

Raises

TypeError – Encountered a definition of an invalid type.

detect(modality: str, values: dict, verbose: bool = False) str

Tries to detect the imaging sequence according to the modality and provided header information.

Parameters
  • modality (str) – The imaging modality as described in the DICOM header

  • values (dict) – Sequence identifying header elements

  • verbose (bool) – Whether to show evaluation logs

Returns

The detected sequence name or None.

Return type

str

evaluate_rule(rule: dict, header_fields: dict, verbose: bool = False) bool

Evaluates a single sequence categorization rule.

Parameters
  • rule (dict) – Sequence categorization rule

  • header_fields (dict) – Header information

  • verbose (bool) – Whether to show evaluation logs

Returns

Whether the sequence satisfies the given rule or not

Return type

bool

get_modality_rules(modality: str) dict

Returns a dictionary of imaging sequence definitions.

Parameters

modality (str) – The modality for which to return imaging sequence defitions

Returns

Imaging sequence definitions

Return type

dict

Raises

NotImplementedError – The sequences dictionary does not include the provided modality

retreive_lookup(rule: dict) Callable

Returns the appropriate lookup function for the given rule.

Parameters

rule (dict) – Sequence detection rule

Returns

Lookup function

Return type

Callable

Raises

NotImplementedError – No lookup function found

retreive_operator(rule: dict) Callable

Returns the appropriate operator function for the given rule.

Parameters

rule (dict) – Sequence detection rule

Returns

Operator function

Return type

Callable

Raises

NotImplementedError – No operator function found

validate_rule_keys(rule: dict) None

Checks whether the given rule contains all required keys.

Parameters

rule (dict) – Sequence detection rule

Raises

ValueError – Missing mandatory rule key

dicom_parser.utils.sequence_detector.sequences module

Sequence type definitions.

Module contents

Default sequence detector implementation used for automatic sequence interpretation.