Skip to content

dcm2nii DICOM to NIfTI converter: compiled versions available from NITRC

License

Notifications You must be signed in to change notification settings

sailfish009/dcm2niix

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Build status

About

dcm2niix is a designed to convert neuroimaging data from the DICOM format to the NIfTI format. This web page hosts the developmental source code - a compiled version for Linux, MacOS, and Windows of the most recent stable release is included with MRIcroGL. A full manual for this software is available in the form of a NITRC wiki.

License

This software is open source. The bulk of the code is covered by the BSD license. Some units are either public domain (nifti*.*, miniz.c) or use the MIT license (ujpeg.cpp). See the license.txt file for more details.

Dependencies

This software should run on macOS, Linux and Windows typically without requiring any other software. However, if you use dcm2niix to create gz-compressed images it will be faster if you have pigz installed. You can get a version of both dcm2niix and pigz compiled for your operating system by downloading MRIcroGL.

Image Conversion and Compression

DICOM provides many ways to store/compress image data, known as transfer syntaxes. The COMPILE.md file describes details on how to enable different options to provide support for more formats.

  • The base code includes support for raw, run-length encoded, and classic JPEG lossless decoding.
  • Lossy JPEG is handled by the included NanoJPEG. This support is modular: you can compile for libjpeg-turbo or disable it altogether.
  • JPEG-LS lossless support is optional, and can be provided by using CharLS.
  • JPEG2000 lossy and lossless support is optional, and can be provided using OpenJPEG or Jasper.
  • GZ compression (e.g. creating .nii.gz images) is optional, and can be provided using either the included miniz or the popular zlib. Of particular note, the Cloudflare zlib exploits modern hardware (available since 2008) for very rapid compression. Alternatively, you can compile dcm2niix without a gzip compressor. Regardless of how you compile dcm2niix, it can use the external program pigz for parallel compression.

Versions

See the VERSIONS.md file for details on releases.

Running

Command line usage is described in the NITRC wiki. The minimal command line call would be dcm2niix /path/to/dicom/folder. However, you may want to invoke additional options, for example the call dcm2niix -z y -f %p_%t_%s -o /path/ouput /path/to/dicom/folder will save data as gzip compressed, with the filename based on the protocol name (%p) acquisition time (%t) and DICOM series number (%s), with all files saved to the folder "output". For more help see help: dcm2niix -h.

See the BATCH.md file for instructions on using the batch processing version.

Install

There are a couple ways to install dcm2niix

  • Github Releases provides the latest compiled executables. This is an excellent option for MacOS and Windows users. However, the provided Linux executable requires a recent version of Linux, so the provided Unix executable is not suitable for all distributions.
  • Run the following command to get the latest version for Linux, Macintosh or Windows:
    • curl -fLO https://github.com/rordenlab/dcm2niix/releases/latest/download/dcm2niix_lnx.zip
    • curl -fLO https://github.com/rordenlab/dcm2niix/releases/latest/download/dcm2niix_mac.zip
    • curl -fLO https://github.com/rordenlab/dcm2niix/releases/latest/download/dcm2niix_win.zip
  • MRIcroGL (NITRC) or MRIcroGL (GitHub) includes dcm2niix that can be run from the command line or from the graphical user interface (select the Import menu item). The Linux version of dcm2niix is compiled on a holy build box, so it should run on any Linux distribution.
  • If you have a MacOS computer with Homebrew you can run brew install dcm2niix.
  • If you have Conda, conda install -c conda-forge dcm2niix on Linux, MacOS or Windows.
  • On Debian Linux computers you can run sudo apt-get install dcm2niix.

Build from source

It is often easier to download and install a precompiled version. However, you can also build from source.

Build command line version with cmake (Linux, MacOS, Windows)

cmake and pkg-config (optional) can be installed as follows:

Ubuntu: sudo apt-get install cmake pkg-config

MacOS: brew install cmake pkg-config

Basic build:

git clone https://github.com/rordenlab/dcm2niix.git
cd dcm2niix
mkdir build && cd build
cmake ..
make

dcm2niix will be created in the bin subfolder. To install on the system run make install instead of make - this will copy the executable to your path so you do not have to provide the full path to the executable.

In rare case if cmake fails with the message like "Generator: execution of make failed", it could be fixed by sudo ln -s `which make` /usr/bin/gmake.

Advanced build:

As noted in the Image Conversion and Compression Support section, the software provides many optional modules with enhanced features. A common choice might be to include support for JPEG2000, JPEG-LS (this option requires a c++14 compiler), as well as using the high performance Cloudflare zlib library (this option requires a CPU built after 2008). To build with these options simply request them when configuring cmake:

git clone https://github.com/rordenlab/dcm2niix.git
cd dcm2niix
mkdir build && cd build
cmake -DZLIB_IMPLEMENTATION=Cloudflare -DUSE_JPEGLS=ON -DUSE_OPENJPEG=ON ..
make

optional batch processing version:

The batch processing binary dcm2niibatch is optional. To build dcm2niibatch as well change the cmake command to cmake -DBATCH_VERSION=ON ... This requires a compiler that supports c++11.

Building the command line version without cmake

If you have any problems with the cmake build script described above or want to customize the software see the COMPILE.md file for details on manual compilation.

Referencing

  • Li X, Morgan PS, Ashburner J, Smith J, Rorden C (2016) The first step for neuroimaging data analysis: DICOM to NIfTI conversion. J Neurosci Methods. 264:47-56. doi: 10.1016/j.jneumeth.2016.03.001. PMID: 26945974

Alternatives

  • dcm2nii is the predecessor of dcm2niix. It is deprecated for modern images, but does handle image formats that predate DICOM (proprietary Elscint, GE and Siemens formats).
  • dicm2nii is written in Matlab. The Matlab language makes this very scriptable.
  • dicom2nifti uses the scriptable Python wrapper utilizes the high performance GDCMCONV executables.
  • dicomtonifti leverages VTK.
  • dinifti is focused on conversion of Siemens data.
  • DWIConvert converts DICOM images to NRRD and NIfTI formats.
  • mcverter has great support for various vendors.
  • mri_convert is part of the popular FreeSurfer package. In my limited experience this tool works well for GE and Siemens data, but fails with Philips 4D datasets.
  • MRtrix mrconvert is a useful general purpose image converter and handles DTI data well. It is an outstanding tool for modern Philips enhanced images.
  • Plastimatch is a Swiss Army knife - it computes registration, image processing, statistics and it has a basic image format converter that can convert some DICOM images to NIfTI or NRRD.
  • SPM12 is one of the most popular tools in the field. It includes DICOM to NIfTI conversion. Being based on Matlab it is easy to script.
  • dcm2niix is largely used for converting MRI and CT DICOMs. While it should in theory support ultra sound (US) images stored as DICOMs, vendors tend to use private tags. The SlicerHeart extension is specifically designed to help 3D Slicer support this modality.

Links

The following tools exploit dcm2niix

About

dcm2nii DICOM to NIfTI converter: compiled versions available from NITRC

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 71.3%
  • C 25.3%
  • CMake 3.0%
  • Other 0.4%