i2nii converts several scientific and medical imaging formats to the popular NIfTI format. NIfTI is used by many neuroimaging tools including FSL, SPM, and AFNI. Note that this tool will not convert images from DICOM format, though the companion dcm2niix will. Likewise, it will not convert TIFF or many microscopy formats, though the Bio-Formats module of ImageJ/Fiji can convert these.
i2nii shares the image reading functions of the MRIcroGL viewer. If you prefer a drag-and-drop graphical user interface, you should use MRIcroGL. In contrast, i2nii is designed to be used from the command line. Compiled excutables are provided for Linux, MacOS and Windows. The source code should compile on a wide range of operating systems.
You can get i2nii using two methods:
- (Recommended) Download latest compiled release from Github release web page.
- (Recommended) You can also download from the command line for Linux, MacOS and Windows:
curl -fLO https://github.com/rordenlab/i2nii/releases/latest/download/i2nii_lnx.zip
curl -fLO https://github.com/rordenlab/i2nii/releases/latest/download/i2nii_mac.zip
curl -fLO https://github.com/rordenlab/i2nii/releases/latest/download/i2nii_win.zip
- (Developers) Download the source code from GitHub.
Chris Rorden's i2nii v1.0.20191007
usage: i2nii [options] <in_file(s)>
Options :
-h : show help
-o : output directory (omit to save to input folder)
-r : rotation (l/r/n, LAS/RAS/native default n)
caution: rotation can disrupt slice time correction
-z : gz compress images (y/n, default n)
Examples :
i2nii -z y ecat.v
i2nii img1.pic img2.pic
i2nii -o ~/out "spaces in name.bvox"
i2nii ./test/sivic.idf
i2nii -o "~/my out" "input.nrrd"
This software is provided as is. There are clear limitations.
- Many of the file formats are poorly documented. In particular with respect to spatial scale and orientation. Some of these problems are inherent to the format (e.g. Blender Voxel data contains no spatial information at all). In other cases, this software could be improved to better handle these formats. It is open source, so feel free to contribute. However, due to these limitations, one should take care using this software.
- The NIfTI format is explicitly designed to store spatial images. Some supported formats handle a much wider range of data. For example, Interfile can encode both raw PET data as well as reconstructed PET spatial images. The NIfTI format is not well suited for the former, though it can cope with the latter.
Note that the -r
option allows you to specify whether the raw data is stored in native, LAS, or RAS. If rotation is requested, the voxel data is copied losslessly. The image dimensions are permuted and flipped to the orthogonal orientation that best matches the desired storage order. For oblique acquisitions (where the slice angulation is not orthogonal to the scanner bore), the residual rotation is stored in the NIfTI SForm and QForm. Therefore, for software that uses the SForm and QForm information, each of these storage orientations is identical. The pupose of these commands is for simple tools that require specified spatial storage. A limitation of this option is that many supported image formats do not record spatial orientation (as reported in the previous paragraph).
It is generally recommended that download a pre-compiled executable (see previous section). However, you can compile your own copy from source code.
- Download and install FreePascal for your operating system. For Debian-based unix this may be as easy as
sudo apt-get install fp-compiler
. For other operating systems, you may simply want to install FreePascal from the latest Lazarus distribution. - From the terminal, go inside the directory with the source files and run the following commands to build and validate your compilation:
fpc i2nii
./i2nii -o ./test/afni.BRIK+orig.BRIK
./i2nii ./test/mgh.mgz
./i2nii ./test/mha.mha
./i2nii ./test/nrrd.nhdr
./i2nii -o ./test/sivic.idf
./i2nii ./test/spr.spr
./i2nii ./test/vtk.vtk
i2nii should automatically detect and convert the following image formats. Be aware that not all these formats have spatial transformations. Further, support for all features of these formats may be incomplete.
- AFNI Brik(.head).
- AIM Scanco Medical µCT or HRpQCT(.aim).
- Analyze(.hdr).
- Bio-Rad PIC(.pic).
- Blender Voxel data(.bvox).
- BrainVoyager VMR(.vmr, .v16).
- Concorde/Siemens µPET(.img.hdr,.img)
- DAT format(.dat).
- DeltaVision(.dv).
- ECAT(.v).
- FreeSurfer MGH/MGZ Volume(.mgh/.mgz).
- Guys Image Processing Lab(.gipl).
- ICS Image Cytometry Standard(.ics).
- Interfile(.varies, limited support).
- PVL (Processed VoLume) from Drishti(.nc)
- ITK MHA/MHD(.mha/.mhd).
- MRC volume(.mrc).
- MRTrix volume(.mif/.mih; not all variants supported).
- NIfTI(.hdr/.nii/.nii.gz/.voi).
- NRRD(.nhdr/.nrrd).
- PGM(.pgm).
- POV-Ray Density_File(.df3).
- Spectroscopic Imaging, Visualization and Computing (SIVIC)(.idf).
- Stimulate Sdt(.spr/.sdt)
- Vaa3D(.v3draw).
- VFF format from ncaa(.vff).
- VTK Legacy Voxel Format(.vtk).
- VTK VTI format(.vti).
- XRAW MagicaVoxel minecraft(.xraw).
If your image format is not supported directly by MRIcroGL, you may want to see if it is supported by the Bio-Formats module of ImageJ/Fiji. If so, you can open the image with the module and save it as NIfTI or NRRD to read it with MRIcroGL.