| File Information |
| Description |
http://www.rotman-baycrest.on.ca/~jimmy/NIfTI for detail descriptions
http://www.rotman-baycrest.on.ca/~jimmy/NIfTI/FAQ.htm for frequently asked questions
http://www.rotman-baycrest.on.ca/~jimmy/UseANALYZE.htm if you are using ANALYZE images
Basic Programs:
1. load_nii.m: Load N-Dimensional NIfTI data (where N can be from 3 to 7) or ANALYZE data (where N can be from 3 to 4), and apply header info (e.g. affine geometric transform, voxel intensity scaling, etc.) to the data. If your data has more than 3-Dimension (e.g. time series etc.), you can also specify a range to extract only 1 or several volumes.
2. save_nii.m: Save N-Dimensional NIfTI data (where N can be from 3 to 7) that is loaded by "load_nii.m" or made by "make_nii.m".
3. make_nii.m: Make N-Dimensional NIfTI data (where N can be from 3 to 7) based on the N-Dimensional matrix and other optional parameters (e.g. voxel_size, origin, etc.). Using "save_nii" command, the NIfTI data that is made by "make_nii" can be saved into a NIfTI file.
4. make_ana.m: Make 3D ANALYZE data based on the 3D matrix and other optional parameters (e.g. voxel_size, origin, etc.). Using "save_untouch_nii" command, the ANALYZE data that is made by "make_ana" can be saved into an ANALYZE file in order to be compatible with some ANALYZE only programs.
5. reslice_nii.m: Reslice 3D (or 4D) NIfTI data or ANALYZE data with affine matrix M in .mat file. The program will base on the affine matrix, which is especially useful for oblique images with non-orthogonal rotation or shearing that cannot be loaded with "load_nii.m". You can also specify voxel_size, etc. It will not cause negative effect, as long as you remember not to do slice time correction after using "reslice_nii.m".
6. view_nii.m: View 3D (or 4D) NIfTI data or ANALYZE data that is loaded by "load_nii.m" or made by "make_nii.m". Activation map, ROI, etc. can be overlaid on top of a background image (see above picture). Plotted view can be embedded into your existing figure window. See detail at http://www.rotman-baycrest.on.ca/~jimmy/NIfTI/examples.txt.
7. load_untouch_nii.m: Load N-Dimensional NIfTI data (where N can be from 3 to 7) or ANALYZE data (where N can be from 3 to 4), but do not apply any changes indicated in the header. (Warning: Do not apply "view_nii.m" to the dataset loaded with "load_untouch_nii.m".
8. save_untouch_nii.m: Save N-Dimensional NIfTI data (where N can be from 3 to 7) or ANALYZE data (where N can be from 3 to 4) that is loaded by "load_untouch_nii.m" or made by "make_ana.m". If you do not modify the loaded dataset, the header and data in the new saved file should be the same as those in the original file.
Other Programs:
1. collapse_nii_scan.m: Integrate multiple single-scan NIfTI or ANALYZE files into a multiple-scan NIfTI file.
2. expand_nii_scan.m: Break a multiple-scan NIfTI file into multiple single-scan NIfTI files.
3. flip_lr.m: Convert ANALYZE or NIfTI file to an L-R flipped NIfTI file. (Warning: please use this program with caution!).
4. get_nii_frame.m: Return number of time frames of a NIfTI dataset.
5. load_nii_ext.m: Load NIfTI header extension.
6. mat_into_hdr.m: Integrate the affine matrix in old SPM MATLAB file into its .hdr header file to become NIfTI format file. |
| Acknowledgements |
The author wishes to acknowledge the following in the creation of this submission:
MRI Analyze tools
This submission has inspired the following:
Siemens DICOM sort and convert to NIfTI, Bipolar Colormap
|
| MATLAB release |
MATLAB 5.3.1 (R11.1)
|
| Zip File Content |
|
| Other Files |
affine.m, bipolar.m, bresenham_line3d.m, collapse_nii_scan.m, examples.txt, expand_nii_scan.m, extra_nii_hdr.m, flip_lr.m, get_nii_frame.m, license.txt, load_nii.m, load_nii_ext.m, load_nii_hdr.m, load_nii_img.m, load_untouch0_nii_hdr.m, load_untouch_nii.m, load_untouch_nii_hdr.m, load_untouch_nii_img.m, make_ana.m, make_nii.m, mat_into_hdr.m, reslice_nii.m, rri_file_menu.m, rri_orient.m, rri_orient_ui.m, rri_xhair.m, rri_zoom_menu.m, save_nii.m, save_nii_ext.m, save_nii_hdr.m, save_untouch0_nii_hdr.m, save_untouch_nii.m, save_untouch_nii_hdr.m, unxform_nii.m, verify_nii_ext.m, view_nii.m, view_nii_menu.m, xform_nii.m
|
| Updates |
| 09 Nov 2005 |
Images whose cardinal planes are slightly off Cartesian coordinates will also be loaded. See detail in 'xform_nii.m'. |
| 11 Nov 2005 |
I didn't see the 'xform_nii.m' was updated in File Exchange. So, I uploaded again with another zip filename. |
| 17 Nov 2005 |
It now supports both new_RGB24 (RGB triple) and old_RGB24 (used by Analyze 6.0 from AnalyzeDirect Inc). Help file "view_nii_hlp.txt" is also modified. |
| 17 Nov 2005 |
It now supports both new_RGB (RGB triple) & old_RGB (used by Analyze 6.0 from AnalyzeDirect Inc). Help file "view_nii_hlp.txt" is also modified. |
| 22 Nov 2005 |
Updated help file "view_nii_hlp.txt" |
| 22 Nov 2005 |
Updated help file "view_nii_hlp.txt". |
| 22 Nov 2005 |
Menu bar is added to convert image to standard RAS orientation and to display image information. |
| 28 Nov 2005 |
Modified display format for RGB24 data value. |
| 28 Nov 2005 |
Updated code |
| 29 Nov 2005 |
NIFTI_20051128 is tested from MATLAB version R11 to R14 on both PC & Linux |
| 15 Dec 2005 |
1. fix a bug for the initial display of coronal & sagittal view
2. added a function to expand a multiple-scan NIFTI file into multiple single-scan NIFTI files |
| 24 Feb 2006 |
Fixed a bug to reorder "pixdim" field when performing sform/qform transform. Thanks to Jeff Gunter from Mayo Clinic who reported this bug. |
| 27 Feb 2006 |
1. Fixed a bug to reorder "pixdim" and "originator" field for some NIFTI data. 2. Added "rot_orient" and "flip_orient" fields under "hdr.hist" if package make conversion of the NIFTI data into RAS orientation system. |
| 01 Mar 2006 |
set "rot_orient" and "flip_orient" fields under "hdr.hist" to empty for old ANALYZE 7.5 format or if the NIFTI data is already in RAS orientation. |
| 08 Mar 2006 |
Image data type will be converted to "double" in the case that "scl_slope" is used. |
| 13 Mar 2006 |
"nii.hdr.scl_slope" will take "avw.hdr.roi_scale" value, which is a non-ANALYZE7.5 field but exclusively used by SPM. |
| 23 Mar 2006 |
It now supports both COMPLEX64 and COMPLEX128 data type. |
| 23 Mar 2006 |
It now supports both COMPLEX64 and COMPLEX128 data type. |
| 20 Apr 2006 |
Size of some image data is incorrectly larger than what specified in "hdr.dime.dim" field. So it caused problem to load image data. Image data is now always loaded according to the size that is specified in its header. |
| 06 Jun 2006 |
1. There was a bug in converting some permuted images to RAS orientation. It has been fixed now. Thanks to Jeff Gunter from Mayo Clinic who reported this bug.
2. hdr.dime.glmax and glmin are updated if hdr.dime.scl_slope is non-zero. |
| 28 Jun 2006 |
1. "unxform_nii" from Jeff is included to provide an option of putting image orientation back to its original status. 2. "expand_nii_scan" is modified so the expanded image files will be appended with a 4-digit number. |
| 05 Jul 2006 |
Thanks to Michael Harms from WUSTL who reported and fixed some bugs in loading and making RGB data. He also added codes to save AnalyzeDirect compatible RGB data. |
| 27 Jul 2006 |
Due to round-off of quaternions (quatern_b/c/d), sqrt(1.0-(b*b+c*c+d*d)) may become complex because value inside sqrt may go below 0 (e.g. -1e-6). Instead of complex, now 0 will be used in this case. Thanks to Jeff Gunter who reported this issue. |
| 25 Sep 2006 |
Added "mat_into_hdr.m" script to convert the ANALYZE 7.5 SPM Reoriented image file into NIfTI format, and integrate the affine matrix in its matlab file into its header file. |
| 18 Dec 2006 |
Improved data scaling process, and fixed a bug in calculating origin position. Detail will be posted on http://www.rotman-baycrest.on.ca/~jimmy/NIFTI |
| 21 Dec 2006 |
1. "Save displayed image as ..." is added in the "File" menu of "view_nii" window. 2. Removed integer rounding for "hdr.hist.originator". Please check more detail in: http://www.rotman-baycrest.on.ca/~jimmy/NIFTI/#update. |
| 23 Apr 2007 |
1. Automatically integrate affine matrix in .mat file of earlier versions of SPM into .hdr structure. 2. fixed a bug in "mat_into_hdr.m". Please check more detail in: http://www.rotman-baycrest.on.ca/~jimmy/NIFTI/#update |
| 27 Apr 2007 |
1. Modified save_nii command, so earlier versions of SPM can also open it with correct originator. 2. Modified http://www.rotman-baycrest.on.ca/~jimmy/NIFTI/FAQ.htm with several categories |
| 03 May 2007 |
Thanks to Ning Cao from UKY who reported and fixed a bug in view_nii.m file. Please check more detail at: http://www.rotman-baycrest.on.ca/~jimmy/NIFTI/#update |
| 04 Feb 2008 |
Thanks to Jeff Gunter from Mayo who suggested to display a warning message instead of throwing an error for a very oblique image. Especially thanks to his code of checking qform rotation before applying voxel size modulation. |
| 09 Apr 2008 |
Added a new feature to load and save NIfTI's header extension (added "load_nii_ext.m" and moified "save_nii.m"), and fixed a bug when loading qform data, which was introduced on 01-FEB-2008. |
| 09 Jul 2008 |
Thanks to the feedback of Holger Krause from Heinrich-Heine University Dusseldorf, the bug in "mat_into_hdr.m" when input file containing a path has been fixed. |
| 20 Aug 2008 |
1. New program reslice_nii.m is provided to perform any 3D affine transform and to generate an isotropic image. 2. New program flip_lr.m is provided for L-R flipping. Please check more detail at: http://www.rotman-baycrest.on.ca/~jimmy/NIFTI/#update |
| 22 Aug 2008 |
Added a "verbose" parameter for "reslice_nii.m" to provide an opportunity to disable the progress display. |
| 29 Aug 2008 |
Added "load_untouch_nii.m" and "save_untouch_nii.m" program pair. See detail in Description above and FAQ at http://www.rotman-baycrest.on.ca/~jimmy/NIfTI/FAQ.htm. |
| 05 Sep 2008 |
Extended Load / Save / Make programs to N-Dimension, where N can be from 3 to 7 for NIfTI data and from 3 to 4 for ANALYZE data. |
| 23 Oct 2008 |
1. Properly handle fread/'*char' problem with foreign characters in MATLAB 7 and above; 2. Reordered input parameters for 'reslice_nii.m' program; |
| 24 Oct 2008 |
update didn't show up |
| 04 Dec 2008 |
Fixed a bug in fliplr.m when reading files. |
| 05 Dec 2008 |
Default data type for 'make_nii.m' now follows the data type of 'img' matrix, instead of float32. |
| 17 Mar 2009 |
1. Thanks to the feedback of Bryce Wilkins from USC, a typo in one of my message display is fixed.
2. Thanks to the suggestion of Ashish Raj from Cornell, 'expand_nii_scan.m' is modified and 'collapse_nii_scan.m' is added.
|
| 25 Mar 2009 |
Thanks to the feedback of Kate Fissell from University of Pittsburgh, transformation matrix M will no longer be saved by save_untouch_nii.m. |
| 18 Jun 2009 |
Just receive warning from MATLAB: "If I do not license my code with BSD, my code will be removed." |
| 03 Jul 2009 |
Fixed several bugs, and posted informative table:
http://www.rotman-baycrest.on.ca/~jimmy/UseANALYZE.htm
|
| 09 Sep 2009 |
While an N-Dimensional matrix can be saved into a NIfTI file using "make_nii / save_nii" command pair, a 3D matrix can also be saved into an ANALYZE file using "make_ana / save_untouch_nii" in order to be compatible with some ANALYZE only programs. |
| 05 Jan 2010 |
"load_untouch_nii" now supports loading specific slices of NIfTI or Analyze format. |
| 06 Jan 2010 |
1. "load_untouch_nii" now supports loading specific slices of NIfTI or Analyze format.
2. MATLAB ask me to remove any "under GNU license" phrase in any file.
|