Skip to content

De-Identify DICOM Files Using the CLI

Introduction

It is important to remove personal health information (PHI) or de-identify data before importing it to Flywheel. The Flywheel de-identification profile allows you to configure de-identification settings for each DICOM field. Use the profile when you import existing DICOM files via the Flywheel CLI. See our De-Identification Overview guide for more information on de-identifying data in Flywheel.

This article explains how to use a de-ID profile to de-identify data that is uploaded using the Flywheel CLI. This de-identification method is recommended if your dataset has unique de-identification needs. Otherwise, you can add a de-ID profile directly to a project, group, or your entire site so all data is de-identified the same.

Instruction Steps

Step 1: Create a De-ID Profile

A de-ID profile is a set of instructions for what to do with metadata that may include PHI. De-id profiles can transform or remove standard DICOM tags such as PatientName, StudyDate, and PatientAge, as well as private tags unique to your institution.

Learn how to create your own de-ID profile.

Step 2: Test your De-Identification Profile

We recommend testing the profile on your computer before uploading data. This makes sure Personal health information (PHI) is not uploaded to Flywheel.

Test your de-ID profile using the fw deid command.

Step 3: Add your De-ID Profile to the CLI Config

The most robust way for implementing your de-ID profile is to add it to the CLI config file:

  1. Copy and paste the following config template into a plain text editor such as TextEdit, notepad, or Sublime:

    #####
    # Template and Group/Project Settings
    #####
    
    template:
    
    #####
    # Optional includes/excludes for directories and files 
    #####
    
    # Patterns of directories to include
    # include-dirs:  
    #   - "*-DCM"
    
    # Patterns of filenames to exclude
    # exclude:  
    #   - "*.txt"
    #   - "*.xml"
    
    #####
    # De-Identification Settings
    #####
    
    deid-profile: custom
    
    deid-profiles:
      - name: custom
    
      dicom:
        #Add de-ID profile here.
    
  2. Under the De-Identification Settings section, add the de-ID profile you created and tested in steps 1 and 2.

  3. Save the config as a YAML file. For example, config.yaml Verify that your config is valid YAML using an online validator tool.

Step 4: Upload your Data

  1. To use this config file in your command:

    fw ingest template ~/Documents/DataToImport TemplateExample --config-file ~/Documents/ExampleConfig.yaml
    
  2. You'll see the following output when the Flywheel CLI is using the config file:

    1
    2
    3
    fw ingest template ~/Documents/DataToImport TemplateExample --config-file ~/Documents/ExampleConfig.yaml
    
    Reading config options from: Users/AvaFranklin/Documents/ExampleConfig.yaml
    

Overrides

CLI arguments override anything set in the config file. For example, if you add the flag --group Psychology , but the config file includes the line group: PsychLab, Flywheel will use Psychology as the group name.