Skip to main content

Dicognito logo

Dicognito is a Python module and command-line utility that anonymizes DICOM files.

Use it to anonymize one or more DICOM files belonging to one or any number of patients. Objects will remain grouped in their original patients, studies, and series.

Anonymization causes significant elements, such as identifiers, names, and addresses, to be replaced by new values. Dates and times will be shifted into the past, but their order will remain consistent within and across the files.

The package is available on pypi and can be installed from the command line by typing

pip install dicognito

Anonymizing from the command line

Once installed, a dicognito command will be added to your Python scripts directory. You can run it on entire filesystem trees or a collection of files specified by glob like so:

# Recurse down the filesystem, anonymizing all found DICOM files.
# Anonymized files will be placed in out-dir, named by new SOP
# instance UID.
dicognito --output-directory out-dir .

# Anonymize all files in the current directory with the dcm extension
# (-o is an alias for --output-directory).
dicognito -o out-dir *.dcm

# Anonymize all files in the current directory with the dcm extension
# but overwrite the original files.
# Note: repeatedly anonymizing the same files will cause date elements
# to  move farther into the past.
dicognito --in-place *.dcm

Get more help via dicognito --help.

Anonymizing from within Python

To anonymize a bunch of DICOM objects from within a Python program, import the objects using pydicom and use the Anonymizer class:

import pydicom
import dicognito.anonymizer

anonymizer = dicognito.anonymizer.Anonymizer()

for original_filename in ("original1.dcm", "original2.dcm"):
    with pydicom.dcmread(original_filename) as dataset:
        anonymizer.anonymize(dataset)
        dataset.save_as("clean-" + original_filename)

Use a single Anonymizer on datasets that might be part of the same series, or the identifiers will not be consistent across objects.

Additional (even custom) element handlers can be added to the Anonymizer via add_element_handler to augment or override builtin behavior.

Exactly what does dicognito do?

Using the default settings, dicognito will

  • Add "DICOGNITO" to DeidentificationMethod
  • Remove BranchOfService
  • Remove MedicalRecordLocator
  • Remove MilitaryRank
  • Remove Occupation
  • Remove PatientInsurancePlanCodeSequence
  • Remove PatientReligiousPreference
  • Remove PatientTelecomInformation
  • Remove PatientTelephoneNumbers
  • Remove ReferencedPatientPhotoSequence
  • Remove ResponsibleOrganization
  • Replace AccessionNumber with anonymized values
  • Replace CountryOfResidence with anonymized values
  • Replace CurrentPatientLocation with ""
  • Replace FillerOrderNumberImagingServiceRequest with anonymized values
  • Replace FillerOrderNumberImagingServiceRequestRetired with anonymized values
  • Replace FillerOrderNumberProcedure with anonymized values
  • Replace InstitutionAddress with anonymized values (only if replacing matching InstitutionName element)
  • Replace InstitutionName with anonymized values
  • Replace InstitutionalDepartmentName with "RADIOLOGY"
  • Replace IssuerOfPatientID with "DICOGNITO"
  • Replace OtherPatientIDs with anonymized values
  • Replace PatientAddress with anonymized values
  • Replace PatientID with anonymized values
  • Replace PerformedProcedureStepID with anonymized values
  • Replace PlacerOrderNumberImagingServiceRequest with anonymized values
  • Replace PlacerOrderNumberImagingServiceRequestRetired with anonymized values
  • Replace PlacerOrderNumberProcedure with anonymized values
  • Replace RegionOfResidence with anonymized values
  • Replace RequestedProcedureID with anonymized values
  • Replace RequestingService with ""
  • Replace ScheduledProcedureStepID with anonymized values
  • Replace StationName with anonymized values
  • Replace StudyID with anonymized values
  • Replace all DA elements with anonymized values that precede the originals
  • Replace all DT elements with anonymized values that precede the originals
  • Replace all PN elements with anonymized values
  • Replace all TM elements with anonymized values that precede the originals (only if replacing matching DA element)
  • Replace all UI elements with anonymized values
  • Replace private "MITRA LINKED ATTRIBUTES 1.0" element "Global Patient ID" with anonymized values
  • Set PatientIdentityRemoved to "YES" if BurnedInAnnotation is "NO"

Logo: Remixed from Radiology by priyanka and Incognito by d͡ʒɛrmi Good from the Noun Project.

Release files for dicognito 0.19.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dicognito 0.19.0
File Size Uploaded
dicognito-0.19.0.tar.gz 183.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dicognito 0.19.0
File Interpreter ABI Platform
dicognito-0.19.0-py3-none-any.whl Python 3 none any Details

Total release size: 225.8 kB

Release files / dicognito-0.19.0.tar.gz

Download URL dicognito-0.19.0.tar.gz
Size 183.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ccce8119c8ba63e372e08997da715cb9ecfb272b27b98f2df01ed2ad956a64b3
BLAKE2b-256 checksum
How to use checksums
044bab7731354bc7491dd38387437e3a2aedd669bed05158472ac09c92e069a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 10, 2025.

Transparency log

Release files / dicognito-0.19.0-py3-none-any.whl

Download URL dicognito-0.19.0-py3-none-any.whl
Size 42.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2e4d5bcf568fb86a525c464a76b4bfa1be77f4ae51168f183424de6635bb0008
BLAKE2b-256 checksum
How to use checksums
553f1b8bef0b63d43c64e42103af5696d0dd8cdafeec1ea06beaf39d8930b5b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 10, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.19.0 This release

2 release files

0.18.0

2 release files

0.17.0

2 release files

0.15.0

2 release files

0.14.0

2 release files

0.13.0

2 release files

0.12.0

2 release files

0.10.0

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page