Package: dicognito
Dicognito is aPythonmodule and command-line utility that anonymizesDICOMfiles.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 isavailable on pypiand can be installed from the command line by typingpip install dicognitoAnonymizing from the command lineOnce installed, adicognitocommand 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-directoryout-dir.# Anonymize all files in the current directory with the dcm extension# (-o is an alias for --output-directory).dicognito-oout-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*.dcmGet more help viadicognito --help.Anonymizing from within PythonTo anonymize a bunch of DICOM objects from within a Python program, import the objects usingpydicomand use theAnonymizerclass:importpydicomimportdicognito.anonymizeranonymizer=dicognito.anonymizer.Anonymizer()fororiginal_filenamein("original1.dcm","original2.dcm"):withpydicom.dcmread(original_filename)asdataset:anonymizer.anonymize(dataset)dataset.save_as("clean-"+original_filename)Use a singleAnonymizeron 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 theAnonymizerviaadd_element_handlerto augment
or override builtin behavior.Exactly what does dicognito do?Using the default settings, dicognito willAdd "DICOGNITO" to DeidentificationMethodRemove BranchOfServiceRemove MedicalRecordLocatorRemove MilitaryRankRemove OccupationRemove PatientInsurancePlanCodeSequenceRemove PatientReligiousPreferenceRemove PatientTelecomInformationRemove PatientTelephoneNumbersRemove ReferencedPatientPhotoSequenceRemove ResponsibleOrganizationReplace AccessionNumber with anonymized valuesReplace CountryOfResidence with anonymized valuesReplace CurrentPatientLocation with ""Replace FillerOrderNumberImagingServiceRequest with anonymized valuesReplace FillerOrderNumberImagingServiceRequestRetired with anonymized valuesReplace FillerOrderNumberProcedure with anonymized valuesReplace InstitutionAddress with anonymized values (only if replacing matching InstitutionName element)Replace InstitutionName with anonymized valuesReplace InstitutionalDepartmentName with "RADIOLOGY"Replace IssuerOfPatientID with "DICOGNITO"Replace OtherPatientIDs with anonymized valuesReplace PatientAddress with anonymized valuesReplace PatientID with anonymized valuesReplace PerformedProcedureStepID with anonymized valuesReplace PlacerOrderNumberImagingServiceRequest with anonymized valuesReplace PlacerOrderNumberImagingServiceRequestRetired with anonymized valuesReplace PlacerOrderNumberProcedure with anonymized valuesReplace RegionOfResidence with anonymized valuesReplace RequestedProcedureID with anonymized valuesReplace RequestingService with ""Replace ScheduledProcedureStepID with anonymized valuesReplace StationName with anonymized valuesReplace StudyID with anonymized valuesReplace all DA elements with anonymized values that precede the originalsReplace all DT elements with anonymized values that precede the originalsReplace all PN elements with anonymized valuesReplace all TM elements with anonymized values that precede the originals (only if replacing matching DA element)Replace all UI elements with anonymized valuesReplace private "MITRA LINKED ATTRIBUTES 1.0" element "Global Patient ID" with anonymized valuesSet PatientIdentityRemoved to "YES" if BurnedInAnnotation is "NO"Logo: Remixed fromRadiologybypriyankaandIncognitobyd͡ʒɛrmi Goodfromthe Noun Project.