GithubHelp home page GithubHelp logo

rmsandu / dams-dicom-anonymizer Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 61 KB

DAMS aka DICOM-Anomymization-Mapping-Script

License: MIT License

Python 100.00%
dicom dicom-anonymization dicom-standard dicom-images dicom-anon segmentation xml-processing

dams-dicom-anonymizer's Introduction

DAMS

DAMS aka DICOM-Anomymization-Mapping-Script

Description

These scripts perform some simple DICOM encoding (anonymization) and mapping between the source CT images and the segmentation masks that were derived from them (optional) by reading the DICOM files one by one using the PyDicom library and saving them to disk.

My data also contains XML files with patient related info in them so I anonymized those as well (see DAMSanonymizer/XML/anonymization_xml_logs.py). My anonymization is not anonymization per-se, but encoding of the patient specific details with a mapping key. Since I later need to relate the image information (radiomics) with clinical data I need a specific key for each patient. Of course, you can generate random keys or leave the tags empty (None), if you do not need to know the patient mapping. Moreover, you can also edit (anonymize) more fields.

The following DICOM metatags are encoded/anonymized:

  • PatientName (0010,0010) - Encoded
  • PatientID (0010,0020) - Encoded
  • PatientBirthDate (0010,0030) - Encoded

The following DICOM fields were deleted (i.e. replaced with None value).

  • PatientSex
  • InstitutionName
  • InstitutionAddress
  • InstitutionalDepartmentName
  • StudyName
  • OperatorsName
  • ReferringPhysicianName
  • DeviceSerialNumber
  • AcquisitionTime
  • AcquisitionDateTime
  • StudyTime
  • ContentTime
  • ContentDate

External Libraries

  • PyDicom (for DICOM processing)
  • Untagle (for XML files processing)

Usage for Single Patient Folder

To avoid errors keep all the files associated with 1 patient and 1 study (multiple series possible) in one folder, otherwise the de-identification will be inconsistent. The original files will be modified and also will remain grouped in their original patients, studies, and series. Careful about overwriting original raw data.

To execute the de-identification run the __main__.py script.

 python -m DAMSdicomanonymizer --i "C:\patientfolder\PAT_M001" --patient_name "MEVR001" --patient_id "R001" --patient_dob "19500101" 

or use the short names:

python -m DAMSdicomanonymizer -i "C:\Patients\Pat_M07" -n "MAVM07" -u "M07" -d "194901001"

The following functions are then called:

  • get_args()
  • anonymizer_dicom.encode_dcm_files_patient(args["rootdir"], args["patient_name"], args["patient_id"], args["patient_dob"])

Batch Processing (multiple patients)

This option reads an Excel file using Pandas and goes row by row in the field Patient_ID and Patient_Dir_Paths. That's the only difference from the single patient folder processing.

Output

Anonymized DICOM files re-written to disk. Careful, this script overwrites the original data. If you want to save it somewhere else, modify the scipt. PyDicom has the save_as(filepath) option for each individual DICOM slice (which I also used).

dams-dicom-anonymizer's People

Contributors

dependabot[bot] avatar rmsandu avatar

Watchers

 avatar

Forkers

chadkowski

dams-dicom-anonymizer's Issues

Add unit tests

add unit tests to check that the de-identification was performed correctly for both XMLs and DICOM

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.