tag:github.com,2008:https://github.com/NeuroJSON/jnifti/releases Release notes from jnifti 2020-06-24T02:18:43Z tag:github.com,2008:Repository/190789303/v0.6 2020-06-24T02:26:39Z JNIfTI Toolbox v0.6 - Epica <h1>JNIfTI Toolbox - Fast and portable NIfTI-1/2 reader and NIfTI-to-JNIfTI converter</h1> <ul> <li>Copyright (C) 2019-2020 Qianqian Fang &lt;q.fang at neu.edu&gt;</li> <li>License: GNU General Public License version 3 (GPL v3) or Apache License 2.0, see License*.txt</li> <li>Version: 0.6 (Epica)</li> <li>URL: <a href="https://github.com/fangq/jnifti">http://github.com/fangq/jnifti</a></li> </ul> <h2>Overview</h2> <p>This is a fully functional NIfTI-1/2 reader/writer that supports both<br> MATLAB and GNU Octave, and is capable of reading/writing both non-compressed<br> and compressed NIfTI files (<code>.nii, .nii.gz</code>) as well as two-part Analyze7.5/NIfTI<br> files (<code>.hdr/.img</code> and <code>.hdr.gz/.img.gz</code>).</p> <p>More importantly, this is a toolbox that converts NIfTI data to its JSON-based<br> replacement, JNIfTI (<code>.jnii</code> for text-based and <code>.bnii</code> for binary-based), defined<br> by the JNIfTI specification (<a href="https://github.com/fangq/jnifti">http://github.com/fangq/jnifti</a>). JNIfTI is a<br> much more flexible, human-readable and extensible file format compared to the<br> more rigid and opaque NIfTI format, making the data much easier to manipulate<br> and share.</p> <h2>Installation</h2> <p>The JNIfTI toolbox includes a stand-alone NIfTI-1/2 parser that works on both<br> MATLAB and GNU Octave without needing additional components. To just reading and<br> writing the un-compressed NIfTI and Analyze7.5 files (.nii, .hdr/.img), one<br> only needs to run <code>addpath('/path/to/jnifti')</code>. For MATLAB, JNIfTI toolbox<br> utilizes <code>memmapfile</code>-based disk-reading, making it very fast. For Octave,<br> <code>memmapfile</code> is currently not implemented, so, a full reading is required.</p> <p>The JNIfTI toolbox is also capable of reading/writing gzip-compressed NIfTI and<br> Analyze7.5 files (<code>.nii.gz, .hdr.gz, .img.gz</code>). This feature is supported in MATLAB<br> directly without needing another toolbox (MATLAB must be in the JVM-enabled mode).</p> <p>To process gzip-compressed NIfTI/Analyze files in Octave and MATLAB with <code>-nojvm</code>,<br> one need to install the open-source JSONLab and ZMat toolboxes, both supporting<br> MATLAB and Octave. They can be downloaded at</p> <ul> <li>JSONLab: <a href="https://github.com/fangq/jsonlab">http://github.com/fangq/jsonlab</a></li> <li>ZMat: <a href="https://github.com/fangq/zmat">http://github.com/fangq/zmat</a></li> </ul> <p>To save NIfTI-1/2 data as JNIfTI files, one needs to install JSONLab. The JNIfTI<br> data format supports internal compression (as oppose to external compression such<br> as <code>*.gz</code> files). To create or read compressed JNIfTI files in Octave, one must<br> install the ZMat toolbox, as listed above.</p> <h2>Usage</h2> <h3><code>nii2jnii</code> - To convert a NIfTI-1/2 file to a JNIfTI file or data structure</h3> <p>Example:</p> <div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" 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"><pre class="notranslate"><code> 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 </code></pre></div> <h3><code>loadnifti</code> - To read a NIfTI-1/2 (.nii or .nii.gz) file (alias to <code>nii2jnii</code>)</h3> <p>Example:</p> <div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" 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"><pre class="notranslate"><code> 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 </code></pre></div> <h3><code>savenifti</code> - To write an image as NIfTI-1/2 (.nii or .nii.gz) file</h3> <p>Example:</p> <div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" 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"><pre class="notranslate"><code> 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 </code></pre></div> <h3><code>loadjnifti</code> - To read a JNIfTI (.jnii or .bnii) file</h3> <p>Example:</p> <div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" jnii=nii2jnii('test.nii.gz'); savejnifti(jnii, 'magic10.bnii','Compression','gzip'); newjnii=loadjnifti('magic10.bnii');"><pre class="notranslate"><code> jnii=nii2jnii('test.nii.gz'); savejnifti(jnii, 'magic10.bnii','Compression','gzip'); newjnii=loadjnifti('magic10.bnii'); </code></pre></div> <h3><code>savejnifti</code> - To write a JNIfTI structure into a file (.jnii or .bnii)</h3> <p>Example:</p> <div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" jnii=jnifticreate(uint8(magic(10)),'Name','10x10 magic matrix'); savejnifti(jnii, 'magic10.jnii'); savejnifti(jnii, 'magic10_debug.bnii','Compression','gzip');"><pre class="notranslate"><code> jnii=jnifticreate(uint8(magic(10)),'Name','10x10 magic matrix'); savejnifti(jnii, 'magic10.jnii'); savejnifti(jnii, 'magic10_debug.bnii','Compression','gzip'); </code></pre></div> <h3><code>jnii2nii</code> - To convert a JNIfTI file or data structure to a NIfTI-1/2 file</h3> <p>Example:</p> <div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" 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"><pre class="notranslate"><code> 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 </code></pre></div> fangq tag:github.com,2008:Repository/190789303/v0.5 2019-09-14T05:48:16Z v0.5 <p>change comment markers to make it compatible for both matlab and octave</p> fangq tag:github.com,2008:Repository/190789303/jnifti_toobox_v0.5 2019-09-15T18:03:02Z JNIfTI Toolbox v0.5 - Ascendance <h1>JNIfTI Toolbox - Fast and portable NIfTI-1/2 reader and NIfTI-to-JNIfTI converter</h1> <ul> <li>Copyright (C) 2019 Qianqian Fang &lt;q.fang at neu.edu&gt;</li> <li>License: GNU General Public License version 3 (GPL v3) or Apache License 2.0, see License*.txt</li> <li>Version: 0.5 (Ascendence)</li> <li>URL: <a href="https://github.com/fangq/jnifti">http://github.com/fangq/jnifti</a></li> </ul> <h2>Overview</h2> <p>This is a fully functional NIfTI-1/2 reader/writer that supports both<br> MATLAB and GNU Octave, and is capable of reading/writing both non-compressed<br> and compressed NIfTI files (.nii, .nii.gz) as well as two-part Analyze7.5/NIfTI<br> files (.hdr/.img and .hdr.gz/.img.gz).</p> <p>More importantly, this is a toolbox that converts NIfTI data to its JSON-based<br> replacement, JNIfTI (.jnii for text-based and .bnii for binary-based), defined<br> by the JNIfTI specification (<a href="https://github.com/fangq/jnifti">http://github.com/fangq/jnifti</a>). JNIfTI is a<br> much more flexible, human-readable and extensible file format compared to the<br> more rigid and opaque NIfTI format, making the data much easier to manipulate<br> and share.</p> <h2>Installation</h2> <p>The JNIfTI toolbox includes a stand-alone NIfTI-1/2 parser that works on both<br> MATLAB and GNU Octave without needing additional components. To just reading and<br> writing the un-compressed NIfTI and Analyze7.5 files (.nii, .hdr/.img), one<br> only needs to run <code>addpath('/path/to/jnifti')</code>. For MATLAB, JNIfTI toolbox<br> utilizes <code>memmapfile</code>-based disk-reading, making it very fast. For Octave,<br> <code>memmapfile</code> is currently not implemented, so, a full reading is required.</p> <p>The JNIfTI toolbox is also capable of reading/writing gzip-compressed NIfTI and<br> Analyze7.5 files (.nii.gz, .hdr.gz, .img.gz). This feature is supported in MATLAB<br> directly without needing another toolbox (MATLAB must be in the JVM-enabled mode).</p> <p>To process gzip-compressed NIfTI/Analyze files in Octave and MATLAB with <code>-nojvm</code>,<br> one need to install the open-source JSONLab and ZMat toolboxes, both supporting<br> MATLAB and Octave. They can be downloaded at</p> <ul> <li>JSONLab: <a href="https://github.com/fangq/jsonlab">http://github.com/fangq/jsonlab</a></li> <li>ZMat: <a href="https://github.com/fangq/zmat">http://github.com/fangq/zmat</a></li> </ul> <p>To save NIfTI-1/2 data as JNIfTI files, one needs to install JSONLab. The JNIfTI<br> data format supports internal compression (as oppose to external compression such<br> as *.gz files). To create or read compressed JNIfTI files in Octave, one must<br> install the ZMat toolbox, as listed above.</p> <h2>Usage</h2> <h3><code>nii2jnii</code> - To convert a NIfTI-1/2 file to a JNIfTI file or data structure</h3> <p>Example:</p> <div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" 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"><pre class="notranslate"><code> 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 </code></pre></div> <h3><code>loadnifti</code> - To read a NIfTI-1/2 (.nii or .nii.gz) file (alias to <code>nii2jnii</code>)</h3> <p>Example:</p> <div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" 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"><pre class="notranslate"><code> 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 </code></pre></div> <h3><code>savenifti</code> - To write an image as NIfTI-1/2 (.nii or .nii.gz) file</h3> <p>Example:</p> <div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" 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"><pre class="notranslate"><code> 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 </code></pre></div> <h3><code>loadjnifti</code> - To read a JNIfTI (.jnii or .bnii) file</h3> <p>Example:</p> <div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" jnii=nii2jnii('test.nii.gz'); savejnifti(jnii, 'magic10.bnii','Compression','gzip'); newjnii=loadjnifti('magic10.bnii');"><pre class="notranslate"><code> jnii=nii2jnii('test.nii.gz'); savejnifti(jnii, 'magic10.bnii','Compression','gzip'); newjnii=loadjnifti('magic10.bnii'); </code></pre></div> <h3><code>savejnifti</code> - To write a JNIfTI structure into a file (.jnii or .bnii)</h3> <p>Example:</p> <div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" jnii=jnifticreate(uint8(magic(10)),'Name','10x10 magic matrix'); savejnifti(jnii, 'magic10.jnii'); savejnifti(jnii, 'magic10_debug.bnii','Compression','gzip');"><pre class="notranslate"><code> jnii=jnifticreate(uint8(magic(10)),'Name','10x10 magic matrix'); savejnifti(jnii, 'magic10.jnii'); savejnifti(jnii, 'magic10_debug.bnii','Compression','gzip'); </code></pre></div> fangq