Behavior and Neuroimaging Core User Manual
  • About
  • Infrastructure Overview
  • XNAT
    • Getting Started
    • Accessing XNAT
    • BIDS Ready Protocols
    • New XNAT projects
    • Uploading Data
    • Downloading Data
  • Demo Dataset
    • Introduction
    • How to access it
    • Protocol Information
    • Basic analysis example: checks task
  • XNAT to BIDS
    • Getting Started
    • XNAT2BIDS Software
    • Exporting to BIDS using Oscar
      • Oscar Utility Script
        • Running xnat2bids using default configuration
        • Running xnat2bids with a custom configuration
        • Syncing your XNAT project & Oscar data directory
        • Extra tools & features
      • Step-wise via Interact Session
    • BIDS Validation
      • Oscar
      • Docker
    • Converting non-MR data
      • Physiological data
      • EEG data
  • XNAT TO BIDS (Legacy)
    • Oscar SBATCH Scripts
  • BIDS and BIDS Containers
    • Introduction to BIDS
    • mriqc
    • fmriprep
    • BIDS to NIMH Data Archive (NDA)
  • Analysis Pipelines
    • Freesurfer
    • 🚧CONN Toolbox
    • FSL topup and eddy
    • Tractography: DSI Studio
    • Brown University MRS Data Collection and Preprocessing Protocol
    • LC Model
      • Installation
      • Example Run
      • Running LCModel on your own data
    • Quantitative Susceptibility Mapping (QSM)
  • Standalone Tools
    • Multi-session spectroscopy with voxalign
    • dicomsort: a tool to organize DICOM files
    • ironmap
    • convert enhanced multi-frame DICOMs to legacy single-frame
    • DICOM anonymization
  • MRF GUIDES
    • MRI simulator room
      • Motion Trainer: Balloon Task
      • Simulating scanner triggers
    • Stimulus display & response collection
    • Eyetracking at the scanner
    • Exporting data via scannershare
    • EEG in the scanner
    • Exporting spectroscopy RDA files
  • Community
    • MRF/BNC user community meetings
Powered by GitBook
On this page
  • Overview
  • Setup
  • Execution

Was this helpful?

  1. Standalone Tools

DICOM anonymization

This script copies a directory of DICOMs, making modifications to the DICOM headers as specified in a configuration .csv file

Previousconvert enhanced multi-frame DICOMs to legacy single-frameNextMRI simulator room

Last updated 8 months ago

Was this helpful?

Overview

This script reads a configuration csv file like this, and then makes the specified edits to the headers of all DICOMs in the input directory, writing the modified DICOMs to a separate output directory.

Tag
Value

PatientBirthDate

CLEAR

PerformingPhysician

DELETE

PatientID

Anonymous

In this configuration file, you'll need a new row for any DICOM tag you want to change, and you can either:

  1. specify CLEAR to keep the tag in your DICOM but set its value to empty (as we did here with the birthdate)

  2. specify DELETE to delete the tag from the DICOM (although only some DICOM tags can be deleted and still yield a valid DICOM)

  3. specify a new value to change it to (here, I changed the Patient ID to "Anonymous").

Setup

  1. First, we need to be in a python environment that contains the package pydicom. You can set up your own environment and pip install pydicom, or on Oscar you can simply open a terminal and activate an environment we have already created: source /oscar/data/bnc/src/python_venvs/pydicom/bin/activate You will be able to tell that this environment is activated because it will say (pydicom) at the beginning of your terminal command prompt.

  2. Create your configuration .csv file (and copy it to Oscar if running there).

Execution

Finally, we can run the script with:

python anonymize_dicoms.py -input_dir orig_data -output_dir anonymized_data -config_path demo_config.csv

This will read all DICOMs in the folder "orig_data", make the changes specified in the configuration file, and write them out to a new folder "anonymized_data".

When you are done, you can deactivate the python environment with deactivate.

89B
demo_config.csv