Anonymizer

class icometrix_sdk.anonymizer.anonymizer.Anonymizer(policy, group_policy, hash_algo)
Parameters:
anonymize(dataset)
Parameters:

dataset (Dataset)

Return type:

Dataset

default_policy: TagPolicy = TagPolicy(action='empty', description='Default', replace_fn=None)
class icometrix_sdk.anonymizer.hash_factory.HashFactory
static create_hash_method(algo, size=512, salt=None)
Parameters:

algo (Literal['sha3', 'md5', 'short_md5'])

class icometrix_sdk.anonymizer.hash_factory.HashMethod
calculate_hash(input_obj, encoding='utf-8')
Parameters:

input_obj (str)

Return type:

str

abstract calculate_hash_from_bytes(input_obj)
Parameters:

input_obj (bytes)

Return type:

str

class icometrix_sdk.anonymizer.hash_factory.MD5
calculate_hash_from_bytes(input_obj)
Parameters:

input_obj (bytes)

class icometrix_sdk.anonymizer.hash_factory.SHA3(size=256)
calculate_hash_from_bytes(input_obj)
Parameters:

input_obj (bytes)

class icometrix_sdk.anonymizer.hash_factory.ShortMD5

MD5 that is re-based to base10.

calculate_hash(input_obj, encoding='utf-8')
Parameters:

input_obj (str)

Return type:

str

calculate_hash_from_bytes(input_obj)
Parameters:

input_obj (bytes)

class icometrix_sdk.anonymizer.models.TagPolicy(action, description, replace_fn=None)

represents a DICOM tag anonymization policy, defining how individual tags or groups should be anonymized.

Param:

Action to be performed on the tag (keep, remove, replace, hash, round)

Param:

Description of the tag anonymization policy.

Param:

Replace Function to be used when the action is “replace” (optional).

Parameters:
  • action (Literal['keep', 'empty', 'remove', 'replace', 'hash', 'round'])

  • description (str)

  • replace_fn (Callable[[DataElement, Dataset], None])

Actions: - keep: Keep the original tag value. - remove: Remove the tag from the DICOM dataset. - replace: Replace the tag value with a specified value. - hash: Hash the tag value using a specified algorithm. - round: Round the tag value to the nearest value. (currently only dates VRs are supported)

action: Literal['keep', 'empty', 'remove', 'replace', 'hash', 'round']
description: str
replace_fn: Callable[[DataElement, Dataset], None] = None
icometrix_sdk.anonymizer.utils.add_de_identification_tags(dataset)
Parameters:

dataset (Dataset)

Return type:

Dataset

icometrix_sdk.anonymizer.utils.empty_tag(element)

Empties the value of the DICOM element. For numeric VRs, sets the value to 0. For other VRs, sets the value to an empty string.

Parameters:

element (DataElement)

icometrix_sdk.anonymizer.utils.hash_tag(element, hash_method)

Calculates the hash of the value of the DICOM element

Parameters:

element (DataElement)

icometrix_sdk.anonymizer.utils.is_group(tag)
Parameters:

tag (int)

Return type:

bool

icometrix_sdk.anonymizer.utils.is_tag(tag)
Parameters:

tag (int)

Return type:

bool

icometrix_sdk.anonymizer.utils.remove_if_birthday(element, ds)
Parameters:
  • element (DataElement)

  • ds (Dataset)

icometrix_sdk.anonymizer.utils.remove_tag(element, dataset)

Removes the tag from a dataset

Parameters:
  • element (DataElement)

  • dataset (Dataset)

icometrix_sdk.anonymizer.utils.replace_tag(element, dataset, replace_fn)

Replaces the value of the DICOM element with a new value. Raises an ValueError Exception if the new value is not compatible with the VR of the DICOM element.

value: The new value to replace the current value of the DICOM element.

Parameters:
  • element (DataElement)

  • dataset (Dataset)

  • replace_fn (Callable[[DataElement, Dataset], None])

icometrix_sdk.anonymizer.utils.round_tag(element)
Parameters:

element (DataElement)

icometrix_sdk.anonymizer.utils.short_md5_hash(element, _)
Parameters:

element (DataElement)

icometrix_sdk.anonymizer.utils.short_sha3_hash(element, _)
Parameters:

element (DataElement)

exception icometrix_sdk.anonymizer.exceptions.HashAlgorithmException
exception icometrix_sdk.anonymizer.exceptions.HashSizeException
exception icometrix_sdk.anonymizer.exceptions.IcometrixException
exception icometrix_sdk.anonymizer.exceptions.PolicyException