Update: Please refer to the comments below to read about updated versions of the software (https://www.nitrc.org/frs/?group_id=889). 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/).
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.