Releases: NeuroJSON/jnifty
JNIfTI Toolbox v0.8 - Tree of Life
JNIfTI Toolbox - Fast and portable NIfTI-1/2 reader/writer for MATLAB and Octave
Click here to register and download JNIfTI Toolbox v0.8
- Copyright (C) 2019-2025 Qianqian Fang <q.fang at neu.edu>
- License: GNU General Public License version 3 (GPL v3) or Apache License 2.0, see License*.txt
- Version: 0.8 (Tree of Life)
- URL: https://github.com/NeuroJSON/jnifty
- Compatibility: MATLAB R2008a or newer, or Octave 4.0 and newer
- JNIfTI Specification Version: V1 Draft-2 (https://neurojson.org/jnifti/draft2)
- Acknowledgement: This project is supported by US National Institute of Health (NIH)
grant U24-NS124027 (NeuroJSON)
ChangeLog
JNIFTY v0.8 (Tree of Life), FangQ <q.fang (a) neu.edu> ==
2025-03-23 [e243cc7] [doc] update README, make examples self-contained
2025-03-23*[905f87e] [release] update all units for v0.8 release, use 'z' flag in octavezmat, support JNIFTI Draft 2
2025-02-05 [1faaf18] [bug] fix int16 type typo, fangq/iso2mesh#83
2024-10-02 [096136c] [doc] update upstream repository to NeuroJSON
2024-03-27 [f3a535d] [doc] add DESCRIPTION and INDEX
2024-03-27*[aec438c] [format] reformat the code with miss_hit
2024-01-15*[ce0d20a] [bug] fix loading nii.gz with extension
2023-02-23*[1aa7dcf] make jnifty compatible with MATLAB R2010b
2023-02-21 [4c2185f] separate nii header to jnii header conversion
2022-03-12 [e61b802] remove redundant line
2022-03-11 [f062d50] add DataInfo header, add usemap option to memmapstream
Overview
This is a fully functional NIfTI-1/2 reader/writer that supports both
MATLAB and GNU Octave, and is capable of reading/writing both non-compressed
and compressed NIfTI files (.nii, .nii.gz) as well as two-part Analyze7.5/NIfTI
files (.hdr/.img and .hdr.gz/.img.gz).
More importantly, this is a toolbox that converts NIfTI data to its JSON-based
replacement, JNIfTI (.jnii for text-based and .bnii for binary-based), defined
by the JNIfTI specification (https://github.com/NeuroJSON/jnifti). JNIfTI is a
much more flexible, human-readable and extensible file format compared to the
more rigid and opaque NIfTI format, making the data much easier to manipulate
and share.
Installation
The JNIfTI toolbox includes a stand-alone NIfTI-1/2 parser that works on both
MATLAB and GNU Octave without needing additional components. To just reading and
writing the un-compressed NIfTI and Analyze7.5 files (.nii, .hdr/.img), one
only needs to run addpath('/path/to/jnifty'). For MATLAB, JNIfTI toolbox
utilizes memmapfile-based disk-reading, making it very fast. For Octave,
memmapfile is currently not implemented, so, a full reading is required.
The JNIfTI toolbox is also capable of reading/writing gzip-compressed NIfTI and
Analyze7.5 files (.nii.gz, .hdr.gz, .img.gz). This feature is supported in MATLAB
directly without needing another toolbox (MATLAB must be in the JVM-enabled mode).
To save NIfTI-1/2 data as JNIfTI files, one needs to install JSONLab. The JNIfTI
data format supports internal compression (as oppose to external compression such
as *.gz files).
To create or read compressed NIfTI/JNIfTI files in Octave, one may install the
ZMat toolbox (https://github.com/NeuroJSON/zmat), although it is optional.
Usage
nii2jnii - To convert a NIfTI-1/2 file to a JNIfTI file or data structure
Example:
img = uint16(reshape(1:10*30*20, [10, 30, 20])); % create sample data
savenifti(img, 'test.nii'); % save sample data as an example nii file
savenifti(img, 'test.nii.gz'); % save sample data as an example nii.gz file
nii=nii2jnii('test.nii', 'nii'); % read a .nii file as a nii structure
nii=nii2jnii('test.nii.gz'); % read a .nii.gz file as a jnii structure
nii2jnii('test.nii.gz', 'newdata.jnii') ;% read a .nii.gz file and convert to a text-JNIfTI file
nii2jnii('test.nii.gz', 'newdata.bnii','compression','zlib'); % read a .nii.gz file and convert to a binary-JNIfTI file with compression
loadnifti - To read a NIfTI-1/2 (.nii or .nii.gz) file (alias to nii2jnii)
Example:
nii=loadnifti('test.nii.gz'); % read a .nii.gz file as a jnii structure
nii=loadnifti('test.nii', 'nii'); % read a .nii file as a nii structure
savenifti - To write an image as NIfTI-1/2 (.nii or .nii.gz) file
Example:
savenifti(img, 'test.nii.gz'); % save an array img to a compressed nifti file
savenifti(img, 'test.nii', 'nifti2'); % save an array img to a nifti-2 file file
savenifti(img, 'test.nii', nii.hdr); % save an array img with an existing header
loadjnifti - To read a JNIfTI (.jnii or .bnii) file
Example:
jnii = nii2jnii('test.nii.gz');
savejnifti(jnii, 'magic10.bnii', 'Compression', 'gzip');
newjnii = loadjnifti('magic10.bnii');
savejnifti - To write a JNIfTI structure into a file (.jnii or .bnii)
Example:
jnii = jnifticreate(uint8(magic(10)), 'Name', '10x10 magic matrix');
savejnifti(jnii, 'magic10.jnii');
savejnifti(jnii, 'magic10_debug.bnii', 'Compression', 'gzip');
savejnifti(jnii, 'test.jnii', 'Compression', 'zlib');
savejnifti(jnii, 'test.bnii', 'Compression', 'zlib');
jnii2nii - To convert a JNIfTI file or data structure to a NIfTI-1/2 file
Example:
nii = jnii2nii('test.jnii'); % read a .jnii file as an nii structure
nii = jnii2nii('test.bnii'); % read a .bnii file as an nii structure
jnii2nii('test.jnii', 'newdata.nii.gz'); % read a text-JNIfTI file to an .nii.gz file
jnii2nii('test.bnii', 'newdata.nii'); % read a text-JNIfTI file to an .nii file
JNIfTI Toolbox v0.6 - Epica
JNIfTI Toolbox - Fast and portable NIfTI-1/2 reader and NIfTI-to-JNIfTI converter
Click here to register and download JNIfTI Toolbox v0.6
- Copyright (C) 2019-2020 Qianqian Fang <q.fang at neu.edu>
- License: GNU General Public License version 3 (GPL v3) or Apache License 2.0, see License*.txt
- Version: 0.6 (Epica)
- URL: http://github.com/fangq/jnifti
ChangeLog
JNIFTY v0.6 (Epica), FangQ <q.fang (a) neu.edu> ==
2022-02-09 [f5ea181] sync with the version in jnifti repo
2019-11-29 [d590fb3] add jnii2nii to convert jnii back to nii for compatibility
Overview
This is a fully functional NIfTI-1/2 reader/writer that supports both
MATLAB and GNU Octave, and is capable of reading/writing both non-compressed
and compressed NIfTI files (.nii, .nii.gz) as well as two-part Analyze7.5/NIfTI
files (.hdr/.img and .hdr.gz/.img.gz).
More importantly, this is a toolbox that converts NIfTI data to its JSON-based
replacement, JNIfTI (.jnii for text-based and .bnii for binary-based), defined
by the JNIfTI specification (http://github.com/fangq/jnifti). JNIfTI is a
much more flexible, human-readable and extensible file format compared to the
more rigid and opaque NIfTI format, making the data much easier to manipulate
and share.
Installation
The JNIfTI toolbox includes a stand-alone NIfTI-1/2 parser that works on both
MATLAB and GNU Octave without needing additional components. To just reading and
writing the un-compressed NIfTI and Analyze7.5 files (.nii, .hdr/.img), one
only needs to run addpath('/path/to/jnifti'). For MATLAB, JNIfTI toolbox
utilizes memmapfile-based disk-reading, making it very fast. For Octave,
memmapfile is currently not implemented, so, a full reading is required.
The JNIfTI toolbox is also capable of reading/writing gzip-compressed NIfTI and
Analyze7.5 files (.nii.gz, .hdr.gz, .img.gz). This feature is supported in MATLAB
directly without needing another toolbox (MATLAB must be in the JVM-enabled mode).
To process gzip-compressed NIfTI/Analyze files in Octave and MATLAB with -nojvm,
one need to install the open-source JSONLab and ZMat toolboxes, both supporting
MATLAB and Octave. They can be downloaded at
- JSONLab: http://github.com/fangq/jsonlab
- ZMat: http://github.com/fangq/zmat
To save NIfTI-1/2 data as JNIfTI files, one needs to install JSONLab. The JNIfTI
data format supports internal compression (as oppose to external compression such
as *.gz files). To create or read compressed JNIfTI files in Octave, one must
install the ZMat toolbox, as listed above.
Usage
nii2jnii - To convert a NIfTI-1/2 file to a JNIfTI file or data structure
Example:
nii=nii2jnii('test.nii', 'nii'); % read a .nii file as a nii structure
nii=nii2jnii('test.nii.gz'); % read a .nii.gz file as a jnii structure
nii2jnii('test.nii.gz', 'newdata.jnii') ;% read a .nii.gz file and convert to a text-JNIfTI file
nii2jnii('test.nii.gz', 'newdata.bnii','compression','zlib'); % read a .nii.gz file and convert to a binary-JNIfTI file with compression
loadnifti - To read a NIfTI-1/2 (.nii or .nii.gz) file (alias to nii2jnii)
Example:
nii=loadnifti('test.nii.gz'); % read a .nii.gz file as a jnii structure
nii=loadnifti('test.nii', 'nii'); % read a .nii file as a nii structure
savenifti - To write an image as NIfTI-1/2 (.nii or .nii.gz) file
Example:
savenifti(img,'test.nii.gz'); % save an array img to a compressed nifti file
savenifti(img, 'test.nii', 'nifti2'); % save an array img to a nifti-2 file file
savenifti(img, 'test.nii', header); % save an array img with an existing header
loadjnifti - To read a JNIfTI (.jnii or .bnii) file
Example:
jnii=nii2jnii('test.nii.gz');
savejnifti(jnii, 'magic10.bnii','Compression','gzip');
newjnii=loadjnifti('magic10.bnii');
savejnifti - To write a JNIfTI structure into a file (.jnii or .bnii)
Example:
jnii=jnifticreate(uint8(magic(10)),'Name','10x10 magic matrix');
savejnifti(jnii, 'magic10.jnii');
savejnifti(jnii, 'magic10_debug.bnii','Compression','gzip');
jnii2nii - To convert a JNIfTI file or data structure to a NIfTI-1/2 file
Example:
nii=jnii2nii('test.jnii'); % read a .jnii file as an nii structure
nii=jnii2nii('test.bnii'); % read a .bnii file as an nii structure
jnii2nii('test.jnii', 'newdata.nii.gz'); % read a text-JNIfTI file to an .nii.gz file
jnii2nii('test.bnii', 'newdata.nii'); % read a text-JNIfTI file to an .nii file
JNIfTI Toolbox v0.5 - Ascendance
JNIfTI Toolbox - Fast and portable NIfTI-1/2 reader and NIfTI-to-JNIfTI converter
Click here to register and download JNIfTI Toolbox v0.5
- Copyright (C) 2019 Qianqian Fang <q.fang at neu.edu>
- License: GNU General Public License version 3 (GPL v3) or Apache License 2.0, see License*.txt
- Version: 0.5 (Ascendence)
- URL: http://github.com/fangq/jnifti
ChangeLog
JNIFTY v0.5 (Ascendance), FangQ <q.fang (a) neu.edu> ==
2019-09-13 [c3aa8bf] jnifti toolbox v0.5
2019-09-13 [fdfaa23] change gitlab links to github
2019-09-13 [214f099] add README for the JNIfTI toolbox
2019-09-12 [5b9e0d8] complete nifti toolbox for reading and writing, will submit to octave
2019-09-11 [bd863c5] add help info to memmapstream
2019-09-11 [afef46d] JNIFTI MATLAB library is now supports .nii.gz and Octave
2019-06-21 [64268f3] handle endianness,add bilateral mapping from code to human-readable strings
2019-06-18 [e4a701e] update jnifti encoder and decoder and all examples with the new header names
2019-06-18 [bd367ef] define string forms for SliceType, Intent, add meaningful Orientation, merge Quatern into structs
2019-06-18 [5d825f6] depreciate NIIHeaderSize and NIIByteOffset in new JNIfTI files
2019-06-18 [8329e8c] depreciates DataTypeName, rename to A75DataTypeName
2019-06-18 [8d1bb44] add nifti-2 example
2019-06-18 [044bf2a] properly read NIFTI-2 extension flags
2019-06-14 [2283985] add origin for nii2jnii.m
2019-06-14 [a8b0095] convert all sample code using the new unified save/load interfaces
2019-06-14 [6370991] add importer and exporter for jnifti files
2019-06-14 [4301bee] jnifticreate header only mode
2019-06-14 [b088f4e] polishing help info for nii2jnii
2019-06-14 [089a703] support nift-2 in nii2jnii, add headct example from mricrogl sample data
2019-06-13 [a1c932c] add matlab file to create jnii header, add 3 examples
2019-06-13 [03c5568] add matlab converter from nii to jnifti
Overview
This is a fully functional NIfTI-1/2 reader/writer that supports both
MATLAB and GNU Octave, and is capable of reading/writing both non-compressed
and compressed NIfTI files (.nii, .nii.gz) as well as two-part Analyze7.5/NIfTI
files (.hdr/.img and .hdr.gz/.img.gz).
More importantly, this is a toolbox that converts NIfTI data to its JSON-based
replacement, JNIfTI (.jnii for text-based and .bnii for binary-based), defined
by the JNIfTI specification (http://github.com/fangq/jnifti). JNIfTI is a
much more flexible, human-readable and extensible file format compared to the
more rigid and opaque NIfTI format, making the data much easier to manipulate
and share.
Installation
The JNIfTI toolbox includes a stand-alone NIfTI-1/2 parser that works on both
MATLAB and GNU Octave without needing additional components. To just reading and
writing the un-compressed NIfTI and Analyze7.5 files (.nii, .hdr/.img), one
only needs to run addpath('/path/to/jnifti'). For MATLAB, JNIfTI toolbox
utilizes memmapfile-based disk-reading, making it very fast. For Octave,
memmapfile is currently not implemented, so, a full reading is required.
The JNIfTI toolbox is also capable of reading/writing gzip-compressed NIfTI and
Analyze7.5 files (.nii.gz, .hdr.gz, .img.gz). This feature is supported in MATLAB
directly without needing another toolbox (MATLAB must be in the JVM-enabled mode).
To process gzip-compressed NIfTI/Analyze files in Octave and MATLAB with -nojvm,
one need to install the open-source JSONLab and ZMat toolboxes, both supporting
MATLAB and Octave. They can be downloaded at
- JSONLab: http://github.com/fangq/jsonlab
- ZMat: http://github.com/fangq/zmat
To save NIfTI-1/2 data as JNIfTI files, one needs to install JSONLab. The JNIfTI
data format supports internal compression (as oppose to external compression such
as *.gz files). To create or read compressed JNIfTI files in Octave, one must
install the ZMat toolbox, as listed above.
Usage
nii2jnii - To convert a NIfTI-1/2 file to a JNIfTI file or data structure
Example:
nii=nii2jnii('test.nii', 'nii'); % read a .nii file as a nii structure
nii=nii2jnii('test.nii.gz'); % read a .nii.gz file as a jnii structure
nii2jnii('test.nii.gz', 'newdata.jnii') ;% read a .nii.gz file and convert to a text-JNIfTI file
nii2jnii('test.nii.gz', 'newdata.bnii','compression','zlib'); % read a .nii.gz file and convert to a binary-JNIfTI file with compression
loadnifti - To read a NIfTI-1/2 (.nii or .nii.gz) file (alias to nii2jnii)
Example:
nii=loadnifti('test.nii.gz'); % read a .nii.gz file as a jnii structure
nii=loadnifti('test.nii', 'nii'); % read a .nii file as a nii structure
savenifti - To write an image as NIfTI-1/2 (.nii or .nii.gz) file
Example:
savenifti(img,'test.nii.gz'); % save an array img to a compressed nifti file
savenifti(img, 'test.nii', 'nifti2'); % save an array img to a nifti-2 file file
savenifti(img, 'test.nii', header); % save an array img with an existing header
loadjnifti - To read a JNIfTI (.jnii or .bnii) file
Example:
jnii=nii2jnii('test.nii.gz');
savejnifti(jnii, 'magic10.bnii','Compression','gzip');
newjnii=loadjnifti('magic10.bnii');
savejnifti - To write a JNIfTI structure into a file (.jnii or .bnii)
Example:
jnii=jnifticreate(uint8(magic(10)),'Name','10x10 magic matrix');
savejnifti(jnii, 'magic10.jnii');
savejnifti(jnii, 'magic10_debug.bnii','Compression','gzip');
