Converting DICOM Images to NIFTI Images

Update: Please refer to the comments below to read about updated versions of the software ( Neuroimaging software is frequently advancing so check with man pages or other documentation for options and changes.

Note: While I will try to be verbose in my how-to guides of imaging, I assume any readers have at least basic knowledge of the command line (Terminal) and bash. If you feel lost with some of the bash references and need some additional info, here is a good beginner’s guide to bash.

Usually the first step to process structural MRI data is to convert the DICOM files from the MR scanner into a more useable format. The current “best” format for files is NIfTI. There are other formats but this is a file format that is widely used and very useable. There are problems with it (specifically with how some software deal handle it but that is a topic for a later time).

One of the best tools to convert DICOM files to NIfTI is Chris Rorden’s dcm2nii (see also his profile on the NITRC website for contact info). This is a command line tool (there is also a graphical user interface version) that wil convert just about any DICOM image to an appropriate NIfTI. dcm2nii is part of the MRIcron package – the most recent version of the software can be downloaded from this link from the NITRC website. There are Linux, Macintosh, and Windows versions of the software (as well as source code if you care to build your own version). This software is available to download for free.

After the software is downloaded and extracted, it can be run from wherever its location is. In other words, this is not “installed” software, it is run from whatever location it is saved to (for example, it could be saved in /Applications/mricronmac/ or in /Users/bbunny/neuroimaging/).

See the screenshot for an example of dcm2nii location.

In order to run dcm2nii from Terminal, move into the directory where dcm2nii is (e.g., using the command line type: cd /Applications/mricronmac/ – again, this should be where the actual dcm2nii program is on your computer).

Next, in Terminal type: ./dcm2nii and press return (enter).

This will bring up some text like this:

It gives an example of how to run the program. Also notice my default preferences. I edited the dcm2nii.ini file to have those defaults because I’ve found that they work the best for the work I do. You can also run dcm2nii from anywhere in Terminal by typing: /[path to mricronmac]/dcm2nii where [path to mricronmac is replaced with the full path to where dcm2nii is – e.g., /Applications/mricronmac/ (check out this post to see how to be able to run a program without typing in the whole path to it). I’ve found it easiest to run dcm2nii from within the folder of DICOM files I want to convert to NIfTI images. To do this first you need to move to the directory where your raw DICOMs are (I typically make a temporary copy of the files so I am not doing anything with the originals, just to prevent any potential issues): for example, /Users/Shared/DWI/blindnum001/DATA/64dir_DWI. Now from within this directory you can run dcm2nii and convert the images with the following command (or whatever is the equivalent on your computer):

/Applications/mricronmac/dcm2nii –a y –d n –e n –f y –g y –i n –r n –x n /Users/Shared/DWI/blindnum001/DATA/64dir_DWI/image001.dcm

Note: you do not need to include all those options (–a y –d n –e n –f y –g y –i n –r n –x n), I included them just to show what are the defaults that I run with dcm2nii. If you have edited the dcm2nii.ini file or if you want to use other defaults or options, go ahead – those are just the options I prefer. After the conversion completes you should have one or more NIfTI files in the same directory where your dicoms are. For diffusion weighted data you should have three files: the .nii.gz (if you selected the gzip option), a .bval, and a .bvec. The only times I’ve not had dcm2nii create bval or bvec files (and I have verified that the dicom files are not corrupted) is when I did not change the default options for dcm2nii, which resulted in overly long NIfTI file names; that, for some reason, prevented the bval and bvec files from being created. That is why I make sure output filename is only the input filename. I’ve never had any conversion issues since setting that option.

There is your conversion. You are all done with this step of neuroimaging!

Alternatively, you can use the graphical user interface for dcm2nii:

First you want to make sure your preferences look something like this (if these are the preferences you want; I prefer just to keep the input filename because it tends to be descriptive but fairly short; I typically rename my files later):

In the GUI under File select DICOM to NifTi and locate the dicoms you wish to convert in the dialogue box that appears. After you select the files and push Open the conversion will run. When it is finished verify that you have a .nii.gz file and .bvec and .bval files. The bval file is a simple text file that includes all the b-values of the diffusion scan (e.g., for a 64 direction scan with one b0 image there will be 65 numbers in there – one 0 and 64 1000s or whatever your b weighting was for your scan. 1000 is pretty typical). I prefer using the command line because it can speed up the process but either way will result in NIfTI images.

Now we are ready to move on to another step in image processing.

About Jared Tanner

I have a PhD in Clinical and Health Psychology with an emphasis in neuropsychology at the University of Florida. I previously studied at Brigham Young University. I am currently a Research Assistant Professor at the University of Florida. I spend the bulk of my research time dealing with structural magnetic resonance images of the brain. My specialty is with traditional structural MR images, such as T1-weighted and T2-weighted images, as well as diffusion weighted images. I also look at the cognitive and behavioral functioning of individuals with PD and older adults undergoing orthopedic surgery. Funding for the images came from NINDS K23NS060660 (awarded to Catherine Price, University of Florida). Brain images may not be used without my written permission (grant and software requirements).

12 comments on “Converting DICOM Images to NIFTI Images

  1. ** Important!! **

    dcm2niigui *needs* to be run under Rosetta on Snow Leopard.

    good luck,


  2. Thanks for the tip about length of DTI file names. I was wondering why the conversion suddenly wasn’t outputting bval and bvec files. Thanks.

  3. Jared:

    When using dcm2nii, I always obtain – for each T1 image – three .nii.gz files: one for coronal, one for sagittal, and another for axial.
    Is there a way to output that as a single file to work on, for example, to segment using FSL’s FIRST?

    Any ideas would be greatly appreciated.

  4. Are each of the .nii.gz files complete? It’s possible that the preferences of your dcm2nii are creating the multiple files. By default dcm2nii will create a reoriented image orthogonal to the acquisition plane as well as a cropped image. Are these the images you are getting out?

  5. Hello Jared,
    sorry about my BIG delay.
    I’m getting three images, all three of them contain the full brain but only one of them won’t contain the neck, and another will not be in the classic “order” starting by the axial but the saggital cut first on fslview.
    I can get FSL to segment only two of those, and they measure different… So I’m not sure of which should I use as a trustable measure. Any ideas?

    Thanks a lot in advance!

  6. Ignacio-
    I suspect you are getting three images (coronal, sagittal, axial) for your localizer scan. These rapid scout scans only acquire a few (often one) slice in each orthogonal plane. These scans are used to plan your other scans, and do not sample large parts of your brain. dcm2nii will save each of these orientations separately. Standard T1-scans (TFE, MP-RAGE) will acquire many slices with the same orientation. dcm2nii will stack these as a single file. It will typically also create a ‘co’ (cropped orthogonal) image that attempts to remove excess neck that can disrupt spatial preprocessing.

  7. Jared-
    Thanks for writing this guide for dcm2nii. Please note that this web page describes the legacy dcm2nii (August 2014 and earlier). This older version is stable, mature, and not currently under active development. Users may want to consider the newer versions available for download with MRIcroGL ( The options have changed a little bit. The new version includes new features, but does remove support for ancient (pre-DICOM) MRI/CT formats.

  8. Thanks for the update. It’s a fantastic piece of software I use every week, sometimes every day.

  9. Thanks for posting . :- ) now i use dcm2nii on all terminal !

    I want reorient the RAS coordinate how can i do that?

    Thanks ~

  10. Hi

    Wondering if anyone knows this. I’m trying to convert a difussions det of dicoms into niftis. However it gives me 4 files file.nii, xfile.nii, file.bvec, xfile.bval. Does anyone know why it comes up with the x infront of the filename? Also file.nii and xfile.nii are different sizes which puzzles me even more. file.nii is bigger than xfile.nii. Thank you for any help.


  11. Sorry, just saw this. The xfile might be cropped or orthogonalized. Check your conversion settings.

Leave a Reply

Your email address will not be published. Required fields are marked *