Synthetic DICOM test data and PS3.15 de-identification
- Synthetic DICOM data carries zero privacy risk and is the right choice for CI and daily development testing.
- DICOM PS3.15 Annex E defines required per-tag actions, such as Remove, Zero, Dummy, and Replace UID, for de-identification.
- Committing real patient DICOM files to git creates a reportable breach that persists in repository history.
- Burned-in pixel text and private vendor tags can leak patient identifiers even after metadata is scrubbed.
- DCMTK's dump2dcm can generate synthetic DICOM files, and dcmodify can sanitize existing files with scripted edits.
Safe test DICOM data comes in two forms: synthetic files built from scratch, or real clinical studies scrubbed under formal de-identification rules. For automated tests and continuous integration (CI), synthetic data is the better choice. It carries zero privacy risk and needs no clinical review.
Reserve real clinical studies for algorithmic validation, where you must follow the strict de-identification rules of DICOM PS3.15 Annex E.
Synthetic DICOM test data vs de-identification: which approach should you choose?
Choose synthetic data for your daily development workflows and continuous integration suites. Synthetic files are clean by construction. You generate them with mock patient names, random IDs, and artificial pixel arrays. Because no real patient ever touched the data, you can commit synthetic fixtures directly into your git repository without violating privacy laws.
De-identification takes the opposite path. You start with an actual hospital scan and attempt to strip out every piece of Protected Health Information (PHI). This process is difficult, fragile, and incomplete by default. If your stripping script misses a single tag among hundreds of metadata attributes, you have created a data leak.
| Evaluation factor | Synthetic test data | PS3.15 Annex E de-identification |
|---|---|---|
| Privacy and legal risk | Zero risk of PHI leak | Residual risk of hidden tags or pixel text |
| Safe for public git repos | Yes, completely safe | No, never commit clinical scans |
| Setup complexity | Low; generate with scripts | High; requires multi-step tag parsing |
| Data fidelity | Basic geometric patterns | Real anatomical structures |
| Primary use case | CI/CD, unit tests, protocol testing | AI model training, clinical validation |
When you choose synthetic data, you give up anatomical complexity. A synthetic CT scan generated from a script cannot test how your deep learning model detects lung nodules. But you gain speed, safety, and reproducibility. You can generate 1,000 synthetic studies in seconds to test association negotiation, DICOMweb endpoints, or parser logic.
Why is a fixture with real patient data never an acceptable shortcut?
Engineers under tight deadlines often copy a real .dcm file from a test PACS into their source code repository. They might change tag (0010,0010) (Patient’s Name) to ANONYMOUS and tag (0010,0020) (Patient ID) to TEST001. They assume the file is now safe.
This shortcut is dangerous. Under the Health Insurance Portability and Accountability Act (HIPAA) and the General Data Protection Regulation (GDPR), committing unverified patient data to git creates a reportable breach.
Git preserves commit history forever. Even if you delete the file in a subsequent commit, the patient data remains in repository history, local developer clones, and cloud backups. Purging that data requires rewriting git history across your entire team.
Ad-hoc tag editing fails because PHI hides across multiple DICOM layers. Tags like StudyInstanceUID (0020,000d) and SOPInstanceUID (0008,0018) link directly back to hospital records. Anyone with access to the hospital PACS audit trail can match that UID back to the original patient.
Modality vendors also store patient details inside unlisted private tags with odd group numbers, such as (0009,xxxx). Technicians often type clinical notes or accession numbers into these fields. Worse, ultrasound and secondary capture scanners frequently burn patient names, dates of birth, and medical record numbers directly into the image pixels. Blanking metadata tags leaves those burned-in pixels completely exposed.
What does DICOM PS3.15 Annex E require for safe de-identification?
If you must use clinical images for validation, you cannot rely on ad-hoc shell scripts. You must implement the Basic Application Level Confidentiality Profile defined in DICOM PS3.15 Annex E.
Table E.1-1 of Annex E specifies normative action codes for each attribute in the dataset. Your de-identification engine must execute one of these standard actions for every tag:
| Action code | Name | Required processing |
|---|---|---|
| X | Remove | Drops the attribute entirely from the dataset |
| Z | Zero or dummy | Replaces value with zero length or consistent dummy value |
| D | Dummy value | Replaces attribute with a non-zero dummy value |
| U | Replace UID | Replaces attribute with a locally generated, consistent UID |
| K | Keep | Retains attribute undisturbed under a specific profile option |
| C | Clean | Replaces identifying substrings while keeping semantic meaning |
Beyond the basic profile, Annex E defines explicit security options in PS3.15 Section E.3. The Clean Pixel Data Option requires you to detect and redact burned-in text within the pixel data array (7fe0,0010). The Retain Safe Private Option forbids keeping any private attribute unless you have documented proof that the vendor tag contains no PHI. The Clean Recognizable Visual Features Option mandates defacing 3D facial contours on head CT and MRI scans, preventing facial recognition attacks against volume renderings.
How do you generate synthetic DICOM test files with DCMTK?
The cleanest way to test ingestion pipelines is to synthesize test files from scratch. The OFFIS DCMTK toolkit provides a utility called dump2dcm. It converts plain text descriptions into valid binary DICOM files complying with PS3.10 Chapter 7.
This workflow uses DCMTK 3.7.0. You can install it on macOS with brew install dcmtk or on Ubuntu with apt install dcmtk.
First, create a text dump file named synthetic-image.dump. Define the minimum attributes required for a valid Secondary Capture image:
# Minimal Synthetic DICOM Secondary Capture Image
(0008,0016) UI =SecondaryCaptureImageStorage
(0008,0018) UI [1.2.826.0.1.3680043.2.1125.1.3]
(0010,0010) PN [SYNTHETIC^STUDY]
(0010,0020) LO [TEST-CASE-01]
(0010,0030) DA [20260101]
(0010,0040) CS [O]
(0020,000d) UI [1.2.826.0.1.3680043.2.1125.1.1]
(0020,000e) UI [1.2.826.0.1.3680043.2.1125.1.2]
(0020,0013) IS [1]
(0028,0002) US 1
(0028,0004) CS [MONOCHROME2]
(0028,0010) US 4
(0028,0011) US 4
(0028,0100) US 16
(0028,0101) US 16
(0028,0102) US 15
(0028,0103) US 0
(7fe0,0010) OW 0000\0020\0040\0080\0020\0040\0080\0100\0040\0080\0100\0200\0080\0100\0200\0400
Convert this dump file into a binary DICOM file using dump2dcm:
dump2dcm synthetic-image.dump synthetic-image.dcm
Verify the generated file structure using dcmdump:
dcmdump synthetic-image.dcm
The command outputs the complete file meta information header and dataset:
# Dicom-File-Format
# Dicom-Meta-Information-Header
# Used TransferSyntax: Little Endian Explicit
(0002,0000) UL 174 # 4, 1 FileMetaInformationGroupLength
(0002,0001) OB 00\01 # 2, 1 FileMetaInformationVersion
(0002,0002) UI =SecondaryCaptureImageStorage # 26, 1 MediaStorageSOPClassUID
(0002,0003) UI [1.2.826.0.1.3680043.2.1125.1.3] # 30, 1 MediaStorageSOPInstanceUID
(0002,0010) UI =LittleEndianExplicit # 20, 1 TransferSyntaxUID
(0002,0012) UI [1.2.276.0.7230010.3.0.3.7.0] # 28, 1 ImplementationClassUID
(0002,0013) SH [OFFIS_DCMTK_370] # 16, 1 ImplementationVersionName
# Dicom-Data-Set
# Used TransferSyntax: Little Endian Explicit
(0008,0016) UI =SecondaryCaptureImageStorage # 26, 1 SOPClassUID
(0008,0018) UI [1.2.826.0.1.3680043.2.1125.1.3] # 30, 1 SOPInstanceUID
(0010,0010) PN [SYNTHETIC^STUDY] # 16, 1 PatientName
(0010,0020) LO [TEST-CASE-01] # 12, 1 PatientID
(0010,0030) DA [20260101] # 8, 1 PatientBirthDate
(0010,0040) CS [O] # 2, 1 PatientSex
(0020,000d) UI [1.2.826.0.1.3680043.2.1125.1.1] # 30, 1 StudyInstanceUID
(0020,000e) UI [1.2.826.0.1.3680043.2.1125.1.2] # 30, 1 SeriesInstanceUID
(0020,0013) IS [1] # 2, 1 InstanceNumber
(0028,0002) US 1 # 2, 1 SamplesPerPixel
(0028,0004) CS [MONOCHROME2] # 12, 1 PhotometricInterpretation
(0028,0010) US 4 # 2, 1 Rows
(0028,0011) US 4 # 2, 1 Columns
(0028,0100) US 16 # 2, 1 BitsAllocated
(0028,0101) US 16 # 2, 1 BitsStored
(0028,0102) US 15 # 2, 1 HighBit
(0028,0103) US 0 # 2, 1 PixelRepresentation
(7fe0,0010) OW 0000\0020\0040\0080\0020\0040... # 32, 1 PixelData
This synthetic file contains zero patient identifiers. You can safely commit it into your test fixtures or send it through a Docker-based DICOM test lab. When testing connectivity, you can also send a test image yourself to confirm your network route without touching real hospital data.
How do you sanitize existing DICOM files with dcmodify?
When you need to de-identify existing files for a test environment, DCMTK command-line utilities provide dcmodify. While dcmodify does not automate the full Table E.1-1 action list, it lets you script targeted modifications and erase dangerous tags.
Always strip private tags first. Modality vendors frequently hide patient identifiers in uncataloged attributes. Use the -ep flag to strip all private attributes in one step:
dcmodify -nb -ep test-image.dcm
Next, modify identifying patient attributes and erase dates:
dcmodify -nb \
-m "(0010,0010)=ANONYMOUS" \
-m "(0010,0020)=TEST-ID-01" \
-e "(0010,0030)" \
-e "(0008,0050)" \
-m "(0020,000d)=1.2.826.0.1.3680043.2.1125.10.1" \
-m "(0020,000e)=1.2.826.0.1.3680043.2.1125.10.2" \
-m "(0008,0018)=1.2.826.0.1.3680043.2.1125.10.3" \
test-image.dcm
The -nb flag disables backup .bak files. Without -nb, dcmodify leaves a backup file containing original patient tags on your disk, defeating the de-identification effort.
Inspect the result with dcmdump to verify the modified values:
dcmdump test-image.dcm | grep -E "PatientName|PatientID|AccessionNumber"
Output:
(0010,0010) PN [ANONYMOUS] # 10, 1 PatientName
(0010,0020) LO [TEST-ID-01] # 10, 1 PatientID
Check the tag (0028,0301) (Burned In Annotation). If this attribute equals YES, text overlays exist inside the pixel array (7fe0,0010). Command-line metadata editors like dcmodify cannot alter pixel values. You must discard the file or run optical character recognition (OCR) redaction before using it.
What are the limits of synthetic DICOM data?
Synthetic DICOM data solves compliance and logistics for integration testing. Still, it has one major limitation: it cannot validate clinical algorithms.
A 4x4 pixel array or an artificial test pattern proves that your parser unpacks transfer syntaxes. It confirms your listener receives associations on port 104 and routes datasets to downstream webhooks. But it tells you nothing about how a machine learning model responds to real soft-tissue contrast, motion artifacts, or scanner noise.
When validating AI models, use established public research repositories instead of ad-hoc hospital exports. Datasets from the National Cancer Institute’s Cancer Imaging Archive (TCIA) have undergone professional de-identification under institutional oversight. This keeps your engineering pipelines safe from data breach liability while providing the clinical realism your algorithms need.
Before connecting a DICOM sender in production, test every failure mode with synthetic studies. Synthetic data gives your engineering team confidence that pipelines handle malformed tags, oversized frames, and unusual transfer syntaxes safely without ever handling protected patient records.
Dicomly builds infrastructure for healthcare software teams that receive DICOM studies from hospitals. Why we built Dicomly →