1- # JNIfTI Toolbox - Fast and portable NIfTI-1/2 reader and NIfTI-to-JNIfTI converter
1+ ![ image ] ( https://neurojson.org/wiki/upload/neurojson_banner_long.png )
22
3- * Copyright (C) 2019-2024 Qianqian Fang <q.fang at neu.edu>
3+ # JNIfTI Toolbox - Fast and portable NIfTI-1/2 reader/writer for MATLAB and Octave
4+
5+ * Copyright (C) 2019-2025 Qianqian Fang <q.fang at neu.edu>
46* License: GNU General Public License version 3 (GPL v3) or Apache License 2.0, see License* .txt
5- * Version: 0.6 (Epica)
6- * URL: http://github.com/NeuroJSON/jnifti
7+ * Version: 0.8 (Tree of Life)
8+ * URL: https://github.com/NeuroJSON/jnifty
9+ * Compatibility: MATLAB R2008a or newer, or Octave 4.0 and newer
10+ * JNIfTI Specification Version: V1 Draft-2 (https://neurojson.org/jnifti/draft2 )
11+ * Acknowledgement: This project is supported by US National Institute of Health (NIH)
12+ grant [ U24-NS124027 (NeuroJSON)] ( https://reporter.nih.gov/project-details/10308329 )
713
814## Overview
915
@@ -14,7 +20,7 @@ files (`.hdr/.img` and `.hdr.gz/.img.gz`).
1420
1521More importantly, this is a toolbox that converts NIfTI data to its JSON-based
1622replacement, JNIfTI (` .jnii ` for text-based and ` .bnii ` for binary-based), defined
17- by the JNIfTI specification (http ://github.com/NeuroJSON/jnifti ). JNIfTI is a
23+ by the JNIfTI specification (https ://github.com/NeuroJSON/jnift ). JNIfTI is a
1824much more flexible, human-readable and extensible file format compared to the
1925more rigid and opaque NIfTI format, making the data much easier to manipulate
2026and share.
@@ -24,25 +30,20 @@ and share.
2430The JNIfTI toolbox includes a stand-alone NIfTI-1/2 parser that works on both
2531MATLAB and GNU Octave without needing additional components. To just reading and
2632writing the un-compressed NIfTI and Analyze7.5 files (.nii, .hdr/.img), one
27- only needs to run ` addpath('/path/to/jnifti ') ` . For MATLAB, JNIfTI toolbox
33+ only needs to run ` addpath('/path/to/jnifty ') ` . For MATLAB, JNIfTI toolbox
2834utilizes ` memmapfile ` -based disk-reading, making it very fast. For Octave,
2935` memmapfile ` is currently not implemented, so, a full reading is required.
3036
3137The JNIfTI toolbox is also capable of reading/writing gzip-compressed NIfTI and
3238Analyze7.5 files (` .nii.gz, .hdr.gz, .img.gz ` ). This feature is supported in MATLAB
3339directly without needing another toolbox (MATLAB must be in the JVM-enabled mode).
3440
35- To process gzip-compressed NIfTI/Analyze files in Octave and MATLAB with ` -nojvm ` ,
36- one need to install the open-source JSONLab and ZMat toolboxes, both supporting
37- MATLAB and Octave. They can be downloaded at
38-
39- * JSONLab: http://github.com/NeuroJSON/jsonlab
40- * ZMat: http://github.com/NeuroJSON/zmat
41-
4241To save NIfTI-1/2 data as JNIfTI files, one needs to install JSONLab. The JNIfTI
4342data format supports internal compression (as oppose to external compression such
44- as ` *.gz ` files). To create or read compressed JNIfTI files in Octave, one must
45- install the ZMat toolbox, as listed above.
43+ as ` *.gz ` files).
44+
45+ To create or read compressed NIfTI/JNIfTI files in Octave, one may install the
46+ ZMat toolbox (https://github.com/NeuroJSON/zmat ), although it is optional.
4647
4748## Usage
4849
@@ -63,29 +64,29 @@ Example:
6364### ` savenifti ` - To write an image as NIfTI-1/2 (.nii or .nii.gz) file
6465Example:
6566```
66- savenifti(img,'test.nii.gz'); % save an array img to a compressed nifti file
67+ savenifti(img, 'test.nii.gz'); % save an array img to a compressed nifti file
6768 savenifti(img, 'test.nii', 'nifti2'); % save an array img to a nifti-2 file file
6869 savenifti(img, 'test.nii', header); % save an array img with an existing header
6970```
7071### ` loadjnifti ` - To read a JNIfTI (.jnii or .bnii) file
7172Example:
7273```
73- jnii= nii2jnii('test.nii.gz');
74- savejnifti(jnii, 'magic10.bnii','Compression','gzip');
75- newjnii= loadjnifti('magic10.bnii');
74+ jnii = nii2jnii('test.nii.gz');
75+ savejnifti(jnii, 'magic10.bnii', 'Compression', 'gzip');
76+ newjnii = loadjnifti('magic10.bnii');
7677```
7778### ` savejnifti ` - To write a JNIfTI structure into a file (.jnii or .bnii)
7879Example:
7980```
80- jnii= jnifticreate(uint8(magic(10)),'Name','10x10 magic matrix');
81+ jnii = jnifticreate(uint8(magic(10)), 'Name', '10x10 magic matrix');
8182 savejnifti(jnii, 'magic10.jnii');
82- savejnifti(jnii, 'magic10_debug.bnii','Compression','gzip');
83+ savejnifti(jnii, 'magic10_debug.bnii', 'Compression', 'gzip');
8384```
8485### ` jnii2nii ` - To convert a JNIfTI file or data structure to a NIfTI-1/2 file
8586Example:
8687```
87- nii= jnii2nii('test.jnii'); % read a .jnii file as an nii structure
88- nii= jnii2nii('test.bnii'); % read a .bnii file as an nii structure
88+ nii = jnii2nii('test.jnii'); % read a .jnii file as an nii structure
89+ nii = jnii2nii('test.bnii'); % read a .bnii file as an nii structure
8990 jnii2nii('test.jnii', 'newdata.nii.gz'); % read a text-JNIfTI file to an .nii.gz file
90- jnii2nii('test.bnii', 'newdata.nii'); % read a text-JNIfTI file to an .nii file
91+ jnii2nii('test.bnii', 'newdata.nii'); % read a text-JNIfTI file to an .nii file
9192```
0 commit comments