Skip to content

Commit f5ea181

Browse files
committed
sync with the version in jnifti repo
1 parent d590fb3 commit f5ea181

5 files changed

Lines changed: 23 additions & 15 deletions

File tree

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
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>
3+
* Copyright (C) 2019-2020 Qianqian Fang <q.fang at neu.edu>
44
* License: GNU General Public License version 3 (GPL v3) or Apache License 2.0, see License*.txt
5-
* Version: 0.5 (Ascendence)
5+
* Version: 0.6 (Epica)
66
* URL: http://github.com/fangq/jnifti
77

88
## Overview
99

1010
This is a fully functional NIfTI-1/2 reader/writer that supports both
1111
MATLAB and GNU Octave, and is capable of reading/writing both non-compressed
12-
and compressed NIfTI files (.nii, .nii.gz) as well as two-part Analyze7.5/NIfTI
13-
files (.hdr/.img and .hdr.gz/.img.gz).
12+
and compressed NIfTI files (`.nii, .nii.gz`) as well as two-part Analyze7.5/NIfTI
13+
files (`.hdr/.img` and `.hdr.gz/.img.gz`).
1414

1515
More importantly, this is a toolbox that converts NIfTI data to its JSON-based
16-
replacement, JNIfTI (.jnii for text-based and .bnii for binary-based), defined
16+
replacement, JNIfTI (`.jnii` for text-based and `.bnii` for binary-based), defined
1717
by the JNIfTI specification (http://github.com/fangq/jnifti). JNIfTI is a
1818
much more flexible, human-readable and extensible file format compared to the
1919
more rigid and opaque NIfTI format, making the data much easier to manipulate
@@ -29,7 +29,7 @@ utilizes `memmapfile`-based disk-reading, making it very fast. For Octave,
2929
`memmapfile` is currently not implemented, so, a full reading is required.
3030

3131
The JNIfTI toolbox is also capable of reading/writing gzip-compressed NIfTI and
32-
Analyze7.5 files (.nii.gz, .hdr.gz, .img.gz). This feature is supported in MATLAB
32+
Analyze7.5 files (`.nii.gz, .hdr.gz, .img.gz`). This feature is supported in MATLAB
3333
directly without needing another toolbox (MATLAB must be in the JVM-enabled mode).
3434

3535
To process gzip-compressed NIfTI/Analyze files in Octave and MATLAB with `-nojvm`,
@@ -41,7 +41,7 @@ MATLAB and Octave. They can be downloaded at
4141

4242
To save NIfTI-1/2 data as JNIfTI files, one needs to install JSONLab. The JNIfTI
4343
data 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
44+
as `*.gz` files). To create or read compressed JNIfTI files in Octave, one must
4545
install the ZMat toolbox, as listed above.
4646

4747
## Usage
@@ -81,3 +81,11 @@ Example:
8181
savejnifti(jnii, 'magic10.jnii');
8282
savejnifti(jnii, 'magic10_debug.bnii','Compression','gzip');
8383
```
84+
### `jnii2nii` - To convert a JNIfTI file or data structure to a NIfTI-1/2 file
85+
Example:
86+
```
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
89+
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+
```

loadjnifti.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
% *.jnii for text JNIfTI file
1616
% *.nii for NIFTI-1/2 files
1717
% options: (optional) if loading from a .bnii file, please see the options for
18-
% loadubjson.m (part of JSONLab); if loading from a .jnii, please see the
18+
% loadbj.m (part of JSONLab); if loading from a .jnii, please see the
1919
% supported options for loadjson.m (part of JSONLab).
2020
%
2121
% output:
@@ -51,7 +51,7 @@
5151
elseif(regexp(filename,'\.jnii$'))
5252
jnii=loadjson(filename,varargin{:});
5353
elseif(regexp(filename,'\.bnii$'))
54-
jnii=loadubjson(filename,varargin{:});
54+
jnii=loadbj(filename,varargin{:});
5555
else
5656
error('file suffix must be .jnii for text JNIfTI, .bnii for binary JNIfTI or .nii for NIFTI-1/2 files');
5757
end

nii2jnii.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
% file name - *.jnii for text-based JNIfTI, or *.bnii for the
2626
% binary version
2727
% options: (optional) if saving to a .bnii file, please see the options for
28-
% saveubjson.m (part of JSONLab); if saving to .jnii, please see the
28+
% savebj.m (part of JSONLab); if saving to .jnii, please see the
2929
% supported options for savejson.m (part of JSONLab).
3030
%
3131
% output:
@@ -338,7 +338,7 @@
338338
if(regexp(format,'\.jnii$'))
339339
savejson('',nii,'FileName',format,varargin{:});
340340
elseif(regexp(format,'\.bnii$'))
341-
saveubjson('',nii,'FileName',format,varargin{:});
341+
savebj('',nii,'FileName',format,varargin{:});
342342
else
343343
error('file suffix must be .jnii for text JNIfTI or .bnii for binary JNIfTI');
344344
end

savebnii.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function savebnii(jnii, filename, varargin)
2020
% jnii.NIFTIExtension - a cell array contaiing the extension data buffers
2121
% filename: the output file name to the binary-JNIfTI file (.bnii)
2222
% options: (optional) if saving to .bnii, please see the
23-
% supported options for saveubjson.m (part of JSONLab).
23+
% supported options for savebj.m (part of JSONLab).
2424
%
2525
% example:
2626
% jnii=jnifticreate(uint8(magic(10)),'Name','10x10 magic matrix');
@@ -36,8 +36,8 @@ function savebnii(jnii, filename, varargin)
3636
error('you must provide data and output file name');
3737
end
3838

39-
if(~exist('saveubjson','file'))
39+
if(~exist('savebj','file'))
4040
error('you must first install JSONLab from http://github.com/fangq/jsonlab/');
4141
end
4242

43-
saveubjson('',jnii,'FileName',filename,varargin{:});
43+
savebj('',jnii,'FileName',filename,varargin{:});

savejnifti.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function savejnifti(jnii, filename, varargin)
2222
% *.bnii for binary JNIfTI file
2323
% *.jnii for text JNIfTI file
2424
% options: (optional) if saving to a .bnii file, please see the options for
25-
% saveubjson.m (part of JSONLab); if saving to .jnii, please see the
25+
% savebj.m (part of JSONLab); if saving to .jnii, please see the
2626
% supported options for savejson.m (part of JSONLab).
2727
%
2828
% example:

0 commit comments

Comments
 (0)