Most people who are processing MRI/fMRI data will need to convert data from the scanner format DICOM to a more usable NIFTI format that is used by a variety of neuroimaging software packages (e.g. AFNI, FSL, SPM). As with most things in neuroimaging, there are a variety of options and here are a few (though not an exhaustive list):
1) dcm2nii
dcm2nii is a part of mricron (the NIFTI version of mricro). It’s free to download, it was programmed in Delphi (object-oriented Pascal). It’s a great multipurpose DICOM converter that can meet the needs of people using any neuroimaging software. It comes with both a command-line and GUI interface for easy scripting – and it runs on Windows (in addition to Mac and Linux) for those who might need this functionality.
2) MRIConvert
MRIConvert is very similar to dcm2nii and may fit your workflows better. It also runs on Mac/Linux/Windows.
AFNI comes with (at least) two programs for easily converting DICOM files to NIFTI. Dimon really ends up calling to3d with the correct options, but I know a lot of old school users who prefer to use to3d directly with their own options. Dimon requires the DICOM files to be organized by sequence, you can do this with a sorting script (like the one on MRIConvert’s page). However you can also use other AFNI tools (dicom_hdr – shows entire header of DICOM files; dicom_hinfo – shows a specific field in the DICOM header) to create your own sorting mechanism.
Code to sort to separate runs:
for each in path/to/dicoms do seriesID=`dicom_hdr ${each} | grep "Series Number" | awk -F"//" '{print $3}'`; if [ ! -e path/to/outputs/SORTED/${seriesID} ]; then mkdir -p path/to/outputs/SORTED/${seriesID}; echo "Series ${seriesID}" fi; cp ${each} path/to/outputs/SORTED/${seriesID}; done
From here you can run Dimon on each folder. If you wanted to get the protocol, you could then do something like this (you may need to modify the number after -tag to meet your DICOM specs, you can figure out that number via dicom_hdr):
cd /path/to/outputs/SORTED/2/ SubjID=`ls | sort -n | head -1 | xargs dicom_hinfo -last -tag 0010,0020 | awk '{print $1}'` Protocol=`ls | sort -n | head -1 | xargs dicom_hinfo -last -tag 0018,1030 | awk '{print $1}'` Dimon -infile_prefix /path/to/outputs/SORTED/2/ -gert_create_dataset -gert_write_as_nifti -dicom_org mv OutBrick* ${SubjID}_${Protocol}.nii
And this could of course easily be scripted to run through each folder in the SORTED folder to convert each sequence.
4) SPM
SPM has a DICOM converter via the graphical user interface. If you’re creative, you can make both 3D and 4D volumes, though this can require using commands directly to matlab batch.
Freesurfer has a nice utility for unpacking DICOM directories, particularly unsorted directories. I tend to use the tool mostly to see what is actually in a folder without converting it.
unpacksdcmdir -src /path/to/dicom -targ /path/to/output -scanonly mytextoutput.txt
Summary
I usually use either dcm2nii or AFNI’s Dimon/to3d. I’ve found a few cases where dcm2nii gives me an incorrectly oriented brain (upside down) where AFNI’s tools are correct. I often appreciate that to3d/Dimon are not black boxes, you can usually see what Dimon is doing and if you don’t think the options are correct – you can go back and change them. I find both tools to be very easily scripted and as most people know – I try to have everything scripted.