polyseminar

Home / Video labs / CIIP

Anonymize a DICOM study

A DICOM header can say the patient's identity was removed while the image still shows the patient's name. You use Orthanc with its pixels masker plugin to anonymize a public CT study with the Basic profile from the DICOM standard, check every tag that changed, and mask the text the profile left in a screen capture.

Playing loads the video from YouTube, which then receives your IP address and may store data on your device. See the privacy notice, or watch on YouTube.

Get the lab files on GitHub →

Published

Never load real patient data, including your own scans, and never point these tools at a hospital system without permission. The script is not a validated de-identification tool, and this page is not legal advice.

What you will do

  • Anonymize a study in Orthanc with the Basic profile from DICOM PS3.15, Annex E.
  • Match each change in the header to one of the profile's actions.
  • Mask text burned into an image, and set Burned In Annotation to NO.
  • Check the profile, the pixels, the private tags, and the link back before you share a study.

What you need

  • Docker: Docker Desktop on Windows 11 or macOS, or Docker Engine with the Compose plugin on Linux. Docker Desktop is free for personal use, education, and small businesses, and larger organizations need a paid subscription, so ask your IT team before you install it on a work computer.
  • At least 8 GB of RAM and about 3.5 GB of free disk space.
  • Stop any earlier lab first, with docker compose down in its folder. All the labs use ports 8042 and 4242.

Why de-identify a study

Studies leave the hospital for a vendor's support team, a research group, a teaching file, or an AI project. Each of them needs the images and has no need for the patient's identity. In the US, HIPAA's minimum necessary standard says to share only what the other side needs, and the GDPR's data minimisation principle says much the same.

Start the lab and load the study

Start the PACS, download the study, and load it

load sends the newer CT study to the PACS, with a screen capture that has the patient's name, ID, and study date written into the image, the way some workstations label one.

docker compose up -d
docker compose run --rm download
docker compose run --rm tools load
Sent 226 CT images and 1 screen capture to the PACS

Open http://localhost:8042 and sign in with user orthanc and password orthanc. The list shows one study, patient PAN_03. PAN_03 is the data set's code, and the dates were shifted before publication.

Anonymize the study

Click the study to open it, then click Anonymize, the button with a person on it. Keep the new name and ID that Orthanc fills in. Clear the StudyDescription field: the dialog copies it from the original, although the profile removes that tag. Delete the text itself, because the trash icon next to the field doesn't stop the dialog from sending the value.

Click Anonymize in the dialog, wait for the bar to fill, click Close, and refresh the page. Orthanc applies the Basic Application Level Confidentiality Profile, writes the result as a new study, and keeps the original, so the list now shows two studies.

The profile gives each attribute one of these actions, from its Table E.1-1. Options in PS3.15, E.3, keep more, such as dates for research that follows a patient over time, or clean more, such as text in the pixels.

ActionWhat it does
DReplaces the value with a dummy
ZEmpties the value, or replaces it with a dummy
XRemoves the attribute
KKeeps it
CCleans it: replaces identifying values with similar ones that don't identify
UReplaces a UID with a new one, the same new one wherever it appears

Check what changed

CT image 111 went from 215 tags to 78. Private tags are vendor data the standard can't list one by one, so the Basic profile removes them all.

TagsWhat happenedAction
Patient's name and IDReplaced with new valuesZ
Study date and time, patient's sexEmptiedZ
Study descriptionEmptied by hand in the dialogX in the profile
Patient's age, series description, other dates, private tagsRemoved: 137 tags in all, 122 of them privateX
Every UIDReplaced with a new oneU

Compare the original and the copy

compare reads CT image 111 and the screen capture from both studies and lists what happened to each tag.

docker compose run --rm tools compare
CT image 111: 215 tags before, 78 after
  Replaced  PatientName    PAN_03 → Anonymized 1a52a67e
  Replaced  PatientID      PAN_03 → 1a52a67e-ddab-42b9-919f-55179722b724
  Emptied   StudyDate, ContentDate, StudyTime, ContentTime, StudyDescription, PatientSex
  ...
Screen capture: 30 tags before, 32 after
  ...
  Added     PatientIdentityRemoved    YES
  Kept      BurnedInAnnotation        YES

Your new name, ID, and UIDs differ, because the dialog makes a random ID each time.

Text in the pixels

Open the anonymized study, then its OT series, the screen capture, and its preview. The header is clean, but the image still shows PAN_03 PAN_03 20040110 across the top, and Burned In Annotation still says YES. The profile changes tags and doesn't look at pixels.

Removing that text is the Clean Pixel Data option, PS3.15, E.3.1. It doesn't say how to remove the text, only that it has to go and that Burned In Annotation then says NO. Screen captures, scanned forms, and ultrasound images often carry text like this.

Mask the text

Black out the label

mask takes a box as x0 y0 x1 y1, in pixels from the top left corner. Here the label fits in a box 320 pixels wide and 40 high. Orthanc's pixels masker plugin fills the box with black and doesn't find the text itself, so you have to tell it where to look.

docker compose run --rm tools mask 0 0 320 40
docker compose run --rm tools compare
Replaced BurnedInAnnotation YES → NO

Refresh the browser and open the capture again. The text is gone.

Before you share a study

CheckWhat to look for
The profileThe Basic one, plus the options this recipient needs
The pixelsEvery image that might carry text
The private tagsRemoved, unless you've checked what's in them
The link backOrthanc keeps the original next to the copy, so the PACS operator can still match the two. Under the GDPR, data that can be linked back is pseudonymised, and still personal data.

If it doesn't work

What you seeWhat to do
load fails at once, before SentDownload the study first, with docker compose run --rm download.
No anonymized study yet from compare or maskAnonymize the study in the browser first.
compare shows the old study after a second anonymizationIt compares the newest anonymized copy. Delete older copies in the browser, or reset with docker compose down -v and run load again.
port is already allocatedAnother program uses port 8042 or 4242, often the PACS from an earlier lab. Run docker compose down in that lab's folder.
no configuration file provided: not foundThe terminal is not in the lab folder. Open it in the folder with compose.yaml.
Cannot connect to the Docker daemonStart Docker Desktop and wait until the engine is running. On Linux, start the Docker service.

Next lab: Follow an exam through the modality worklist →

Sources: The current DICOM standard, PS3.15 Annex E; Orthanc anonymization; Orthanc pixels masker plugin; HIPAA minimum necessary, 45 CFR 164.502(b); GDPR, Articles 4(5) and 5(1)(c), and Recital 26; Chen, L., et al. (2022). CTpred-Sunitinib-panNET. The Cancer Imaging Archive; Docker Desktop license terms. Polyseminar is an independent publisher. See the independence notice.