DICOM to NifTI conversion
The scanner and the PACS store images in DICOM format. Fsl, MRICron and SPM use NifTI. There are several tools that will convert from DICOM to NIfTI. This short guide covers using MRIConvert and dcm2nii.
A brief introduction to NifTI
Why use NifTI? DICOM is too complex. DICOM adds processing overhead. DICOM does not support floating-point numbers and is missing attributes useful for neuroimaging. NifTI makes up for these shortcomings.
NifTI comes in several variations. NifTI data can be packaged in a single .nii file or as a *.hdr and *.img pair of files. Most programs work with .nii files. A NifTI file may contain 2D slice, a 3D image or a 4D time series of images.
FSL works with 4D data. SPM prefers a collection of 3D images. MRIConvert and dcm2nii both output a series as either a single 4D .nii file or several 3D .nii files. Dcm2nii can convert between 4D and 3D NifTI. FSL includes tools to convert between 3D and 4D data.
The fsl tools are:
- Fslsplit converts 4D to 3D for SPM.
- Fslslice converts 3D to 2D slices along the z-axis
- Fslmerge concatenates a collection of nD images to n+1D. This concatenation can be in time, X, Y or Z.
MRIConvert is available for MacOS, Windows and linux. Download from http://lcni.uoregon.edu/~jolinda/MRIConvert/ Windows users: download and unzip. With MacOS, download and run the installer. Next, launch MRIConvert.
Click on the Add folder button. This will bring up a directory selector dialog. Choose a directory containing a study or series to convert. All DICOM files in this directory and its subdirectories will be added to the "DICOM input" panel. A progress dialog will appear. When complete a log dialog will pop up. Click Okay to close the log dialog.
Choose the conversion format from the pop up menu middle. For FSL, choose FSL NifTI. For SPM, choose NifTI. Do not use output format SPM/Analyze, it is for very old versions SPM.
Click on the Options button
Tick Save each series in a separate directory, Apply rescale slope and intercept to data and save as .nii file. In the unlikely case you need .hdr and .img pairs, leave Save as .nii file unchecked. Click Okay.
Click Directory and Choose a location for the converted files. Click Convert all.
Compress the converted files. NifTI files are about 70% of the size of the original DICOM. Compressing with gzip will reduce that to 20% or less. FSL will read gzipped files automatically. SPM will not directly read gzipped files but you can manually unzip them. To compress on a Mac, open a terminal window, cd to the directory containing the nii files and type gzip *.nii.
mcverter is the command line version of MRI Convert. It is installed automatically when you install MRIConvert. For MacOS El Capitain, use the version linked here as the version bundled with MRIConvert will not work.
If you have a large number of files to converter, Andrew can help with shell scripts for mcverter.
dcm2nii converts several types of proprietary scanner image formats to NifTI. While it does accept DICOM, dcm2nii has trouble converting some of the images from our scanner. It doesn't support JPEG 2000. When fed JPEG-2000 compressed DICOM, dcm2nii will spit out cryptic "Unsupported Transfer Syntax 1.2.840.10008.1.2.4.90" messages.
Dcm2nii is no longer in active development. For all new studies, we recommend using dcm2niix, MRIConvert or mcverter.
dcm2niix is a DICOM to NifTI converter from Chris Rorden at NITRC. Compared to the other tools, dcm2niix has better support for images from other modalities like CT. If you do attempt to convert CT images, carefully examine the output as NifTI imposes restrictions that are not a good fit for CT.
The MacOS version is able to convert JPEG-2000 compressed DICOM. If other tools throw an Unsupported Transfer Syntax error, try dcm2niix. You can download it as part of MRIcroGL here.
dcm2niix is a command line tool. However, MRIcroGL contains a graphical interface wrapper: launch MRIcroGL and choose the Import/ConvertDICOMtoNIfTI menu item. A new window appears that allows you to drag and drop files to convert. You can also use the graphical interface to set conversion options. A nice feature of the graphical interface is that when you select options it displays the corresponding command line instruction. That way you can use the graphical interface to design command line instructions. For the command line, installation consists of downloading MRIcroGL and moving dcm2niix somewhere in the search path. The windows command line version supports dragging files to convert onto the application. MacOS does not.