User Tools

Site Tools


Quick Navigation:








Converting from DICOM to NIFTI

Most scanners generate DICOM files coming off the scanner. While these can be useful when paired with a DICOM reader, most software packages in fMRI (e.g. AFNI, FSL, SPM) expect the data to be formatted as NIFTI files.

DICOM Converters

You have several options for converting DICOM files to NIFTI files.

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 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.

3. AFNI's Dimon/to3d

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, which can be as simple as calling the AFNI script. Alternatively, you can 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 like the following:

for each in path/to/dicoms
 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}"
 cp ${each} path/to/outputs/SORTED/${seriesID};

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.

5. Freesurfer's unpacksdcmdir

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.


We 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 find both tools to be very easily scripted and as most people know – I try to have everything scripted.

dicom2nifti.txt · Last modified: 2014/06/24 09:27 by pmolfese