Home

Awesome

dicomConversionToNiftiHCC

This python script facilitates standardized conversion of DICOM studies into nifti format by doing the following:

Currently can be used for conversion of pre- and post-treatment MRI abdomen studies AND CT angiography studies by using the appropriate config file

Dependencies

SimpleITK
Numpy
PyDicom
NiPype
Slugify

Usage

Script assumes a nested folder eg tree study-->series-->DICOM (standard when exportingw with Osirix or Horos). This should easily by adapted for other folder structures if working with exported images from other DICOM viewers/PACS servers.

There are two script calls needed:.

  1. Grab Metadata: create a .csv with relevant metadata in table for tagging of desired series by domain expert (or algorithm in future)

  2. Convert From Table: conversion, deidentification and standardized naming of converted sequences using the annotated tag column from 1) Metadata table.

Grab Metadata into Table

python osirix_dicom_to_nifti.py --grabMetadata --tablePath ./path/to/metadata/table.csv --dicomDir ./path/to/folder/containing/study/folders

This will generate a .csv file with columns of metadata for each series of an MRI study meant to allow inference of which series' are desired for conversion.

Heads up: this can be a lot of rows as modern MRI studies generate a lot of series!

An empty tag column will be generated and with some domain knowledge the user must fill-in with the appropriate tag number.

Example is as follows (take note of the number inputted in the tag column):

MRNACCMachineSeries PathAcq TimeSeries NumberSeries DescTag(0=pre,1=ea,2=ea_sub,3=la,4=la_sub,5=pv,6=pv_sub,7=ev,8=ev_sub,9=adc)
9999999000001Avanto./Y90_Seg/name/body-mt-sinai-protocols-abdomen/trufisp-loc-1110028.6251Trufisp_Loc
9999999000001Avanto./Y90_Seg/name/body-mt-sinai-protocols-abdomen/cor-haste-2110142.8752COR HASTE
9999999000001Avanto./Y90_Seg/name/body-mt-sinai-protocols-abdomen/3point-dixon-t2-star-031511-fa10-modified-6611-opp-6110544.732563-point Dixon_T2 star_03-15-11_FA10_modified 6/6/11_opp
9999999000001Avanto./Y90_Seg/name/body-mt-sinai-protocols-abdomen/3point-dixon-t2-star-031511-fa10-modified-6611-in-5110544.73553-point Dixon_T2 star_03-15-11_FA10_modified 6/6/11_in
9999999000001Avanto./Y90_Seg/name/body-mt-sinai-protocols-abdomen/ax-vibe-pre-62612-13110828.962513AX VIBE PRE (6/26/12)0
9999999000001Avanto./Y90_Seg/name/body-mt-sinai-protocols-abdomen/ax-vibe-post-2art-1min-3min-equ-14111014.057514AX VIBE POST 2ART,1MIN,3MIN EQU1
9999999000001Avanto./Y90_Seg/name/body-mt-sinai-protocols-abdomen/ax-vibe-post-2art-1min-3min-equ-sub-15111014.057515AX VIBE POST 2ART,1MIN,3MIN EQU_SUB2
9999999000001Avanto./Y90_Seg/name/body-mt-sinai-protocols-abdomen/ax-vibe-post-2art-1min-3min-equ-16111035.227516AX VIBE POST 2ART,1MIN,3MIN EQU3
9999999000001Avanto./Y90_Seg/name/body-mt-sinai-protocols-abdomen/ax-vibe-post-2art-1min-3min-equ-sub-17111035.227517AX VIBE POST 2ART,1MIN,3MIN EQU_SUB4
9999999000001Avanto./Y90_Seg/name/body-mt-sinai-protocols-abdomen/ax-vibe-post-2art-1min-3min-equ-18111114.4718AX VIBE POST 2ART,1MIN,3MIN EQU5
9999999000001Avanto./Y90_Seg/name/body-mt-sinai-protocols-abdomen/ax-vibe-post-2art-1min-3min-equ-sub-19111114.4719AX VIBE POST 2ART,1MIN,3MIN EQU_SUB6
9999999000001Avanto./Y90_Seg/name/body-mt-sinai-protocols-abdomen/ax-vibe-post-2art-1min-3min-equ-500111131.799500AX VIBE POST 2ART,1MIN,3MIN EQU
9999999000001Avanto./Y90_Seg/name/body-mt-sinai-protocols-abdomen/ax-vibe-post-2art-1min-3min-equ-20111316.0420AX VIBE POST 2ART,1MIN,3MIN EQU7
9999999000001Avanto./Y90_Seg/name/body-mt-sinai-protocols-abdomen/ax-vibe-post-2art-1min-3min-equ-sub-21111316.0421AX VIBE POST 2ART,1MIN,3MIN EQU_SUB8
9999999000001Avanto./Y90_Seg/name/body-mt-sinai-protocols-abdomen/cor-vibe-post-3-min-22111407.5222000001Avanto
9999999000001Avanto./Y90_Seg/name/body-mt-sinai-protocols-abdomen/pace-diffusion-50400800-10113-adc-29112810.83529PACE Diffusion 50-400-800 10-1-13_ADC9
9999999

Convert DICOM to Nifti Using Tagged Metadata Table

Once the table above is properly annotated with the correct tags for the desired series, the second step is conversion.

python osirix_dicom_to_nifti.py --convertFromTable --tablePath ./path/to/metadata/table.csv --dicomDir ./path/to/folder/containing/study/folders --niftiDir ./path/to/nifti/output/folder

Study folders within designated nifti output folder will be named according to accession number for study, so conversion of these folder names to random strings using a secure look-up table is encouraged for thorough de-identification.