11# JNIfTI Toolbox - Fast and portable NIfTI-1/2 reader and NIfTI-to-JNIfTI converter
22
3+ * Copyright (C) 2019 Qianqian Fang <q.fang at neu.edu>
4+ * License: GNU General Public License version 3 (GPL v3) or Apache License 2.0, see License* .txt
5+ * Version: 0.5 (Ascendence)
6+ * URL: http://github.com/fangq/jnifti
7+
38## Overview
49
510This is a fully functional NIfTI-1/2 reader/writer that supports both
@@ -27,7 +32,7 @@ The JNIfTI toolbox is also capable of reading/writing gzip-compressed NIfTI and
2732Analyze7.5 files (.nii.gz, .hdr.gz, .img.gz). This feature is supported in MATLAB
2833directly without needing another toolbox (MATLAB must be in the JVM-enabled mode).
2934
30- To process gzip-compressed NIfTI/Analyze files in Octave and MATLAB with -nojvm,
35+ To process gzip-compressed NIfTI/Analyze files in Octave and MATLAB with ` -nojvm ` ,
3136one need to install the open-source JSONLab and ZMat toolboxes, both supporting
3237MATLAB and Octave. They can be downloaded at
3338
@@ -39,3 +44,40 @@ data format supports internal compression (as oppose to external compression suc
3944as \* .gz files). To create or read compressed JNIfTI files in Octave, one must
4045install the ZMat toolbox, as listed above.
4146
47+ ## Usage
48+
49+ ### ` nii2jnii ` - To convert a NIfTI-1/2 file to a JNIfTI file or data structure
50+ Example:
51+ ```
52+ nii=nii2jnii('test.nii', 'nii'); % read a .nii file as a nii structure
53+ nii=nii2jnii('test.nii.gz'); % read a .nii.gz file as a jnii structure
54+ nii2jnii('test.nii.gz', 'newdata.jnii') ;% read a .nii.gz file and convert to a text-JNIfTI file
55+ nii2jnii('test.nii.gz', 'newdata.bnii','compression','zlib'); % read a .nii.gz file and convert to a binary-JNIfTI file with compression
56+ ```
57+ ### ` loadnifti ` - To read a NIfTI-1/2 (.nii or .nii.gz) file (alias to ` nii2jnii ` )
58+ Example:
59+ ```
60+ nii=loadnifti('test.nii.gz'); % read a .nii.gz file as a jnii structure
61+ nii=loadnifti('test.nii', 'nii'); % read a .nii file as a nii structure
62+ ```
63+ ### ` savenifti ` - To write an image as NIfTI-1/2 (.nii or .nii.gz) file
64+ Example:
65+ ```
66+ savenifti(img,'test.nii.gz'); % save an array img to a compressed nifti file
67+ savenifti(img, 'test.nii', 'nifti2'); % save an array img to a nifti-2 file file
68+ savenifti(img, 'test.nii', header); % save an array img with an existing header
69+ ```
70+ ### ` loadjnifti ` - To read a JNIfTI (.jnii or .bnii) file
71+ Example:
72+ ```
73+ jnii=nii2jnii('test.nii.gz');
74+ savejnifti(jnii, 'magic10.bnii','Compression','gzip');
75+ newjnii=loadjnifti('magic10.bnii');
76+ ```
77+ ### ` savejnifti ` - To write a JNIfTI structure into a file (.jnii or .bnii)
78+ Example:
79+ ```
80+ jnii=jnifticreate(uint8(magic(10)),'Name','10x10 magic matrix');
81+ savejnifti(jnii, 'magic10.jnii');
82+ savejnifti(jnii, 'magic10_debug.bnii','Compression','gzip');
83+ ```
0 commit comments