Dicom.DeIdentification (Dicom v0.5.1)

Copy Markdown View Source

DICOM De-identification / Anonymization (PS3.15 Table E.1-1).

Implements a best-effort Basic Application Level Confidentiality Profile for the supported tag set, with 10 profile flags that affect behavior. Supports action codes D, Z, X, K, C, and U.

retain_private_tags retains all private tags. The older retain_safe_private flag is supported as a compatibility alias for the same behavior, but it does not implement PS3.15 safe-private semantics.

When multiple profile flags overlap, the implementation prefers the more conservative override. For temporal tags, retain_long_full_dates wins over retain_long_modified_dates.

Action Codes

  • D — Replace with dummy value (per VR)
  • Z — Replace with zero-length value
  • X — Remove the element
  • K — Keep (no change)
  • C — Clean (remove identifying text from descriptions)
  • U — Replace UID with consistent new UID

Usage

{:ok, deidentified, uid_map} = Dicom.DeIdentification.apply(data_set)

# With options
profile = %Dicom.DeIdentification.Profile{retain_uids: true}
{:ok, result, uid_map} = Dicom.DeIdentification.apply(data_set, profile: profile)

# Direct flags are also accepted
{:ok, result, uid_map} =
  Dicom.DeIdentification.apply(data_set, retain_uids: true, retain_private_tags: true)

Reference: DICOM PS3.15 Annex E.

Summary

Functions

Returns the action code for a tag given a profile.

Applies de-identification to a data set.

Returns the default de-identification profile.

Functions

action_for(tag, profile)

@spec action_for(Dicom.Tag.t(), Dicom.DeIdentification.Profile.t()) ::
  :D | :Z | :X | :K | :C | :U | :M

Returns the action code for a tag given a profile.

apply(ds, opts \\ [])

@spec apply(
  Dicom.DataSet.t(),
  keyword()
) :: {:ok, Dicom.DataSet.t(), map()}

Applies de-identification to a data set.

Returns {:ok, deidentified_data_set, uid_map} where uid_map maps original UIDs to their replacements.

Options

  • profile — a DeIdentification.Profile struct (default: basic_profile())
  • direct boolean profile flags such as retain_uids: true or retain_private_tags: true; these override the supplied profile, if any

basic_profile()

@spec basic_profile() :: Dicom.DeIdentification.Profile.t()

Returns the default de-identification profile.