Skip to main content
DICOM files may contain sensitive and personally identifiable information (PII) about patients, including their name, date of birth, medical record number. In these cases it is essential to anonymize each file, to protect patient privacy and comply with legal and ethical regulations related to healthcare data.
This is a premium feature and running it incurs additional costs. Contact us at support@encord.com to learn about pricing.
In this tutorial you will learn how to anonymize / de-identify DICOM files in two steps:
  1. Setting up the de-identification function.
  2. Using the de-identification function.
Finally, you will learn how to interpret the JSON output of the de-identification process.
Redacted tag values are completely removed.

Set up the de-identification function

Adjust the de-identification function found here to suit your needs.

De-identifying

The Python code below is used to add criteria and call the de-identification function.
An SSH public / private key pair is required to use the sample script below. To learn how to generate one, see our documentation here.
Make sure to edit the criteria used to evaluate each file to suit your needs - any number of criteria can be used.

Setting evaluation criteria

Evaluation criteria are conditions that determine whether a file will be de-identified or not. Criteria can take many forms, but will always return either ‘true’ or ‘false’.
All strings and inputs into the criteria functions are case-insensitive.
There are two distinct criteria functions:
  • “SaveDeidentifiedDicomConditionNotSubstr” will return ‘true’ if the first argument (PRIMARY in the example above), is not contained in the second argument (ImageType in the example above). In plain English, the example above checks whether the file’s ImageType doesn’t contain the word ‘Primary’, and returns ‘true’ if this condition is fulfilled.
  • “SaveDeidentifiedDicomConditionIn” will return ‘true’ if the first argument ([“ct”,“pt”,“nm”,“mr”,“mg”,“pt”] in the example above) is contained in the second argument Modality. In plain English, the example above checks whether any of the strings contained in the list are contained within the file’s Modality. If any one of them is, the function returns ‘true’.

Output

This section will explain the output of the de-identification function. Click the dropdown below to see a sample output file