# doc-cache created by Octave 10.3.0
# name: cache
# type: cell
# rows: 3
# columns: 15
# name: <cell-element>
# type: sq_string
# elements: 1
# length: 12
jnifticreate


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 844

    jnii=jnifticreate
       or
    jnii=jnifticreate('header1', value1, 'header2', value2, ...)
    jnii=jnifticreate(img, 'header1', value1, ...)

    Create a default JNIfTI structure with default header and image volume

    author: Qianqian Fang (q.fang <at> neu.edu)

    input:
        img: set the jnii.NIFTIData section
        'header_i': the header subfield name defined in the JNIfTI
                    specification, see https://github.com/fangq/jnifti
        value_i: set the value for the specified JNIfTI header field

    output:
        jnii: without any input, jnii gives the default jnii header
              if img is given, jnii also includes the NIFTIData field


    this file is part of JNIfTI specification: https://github.com/fangq/jnifti

    License: Apache 2.0, see https://github.com/fangq/jnifti for details




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80

    jnii=jnifticreate
       or
    jnii=jnifticreate('header1', value1, 'he...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 10
loadjnifti


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1662

    jnii=loadjnifti(inputfile)
       or
    jnii=loadjnifti(inputfile, 'Param1',value1, 'Param2',value2,...)

    Load a standard NIFTI-1/2 file or text or binary JNIfTI file with
    format defined in JNIfTI specification: https://github.com/fangq/jnifti

    author: Qianqian Fang (q.fang <at> neu.edu)

    input:
        inputfile: the output file name to the JNIfTI or NIFTI-1/2 file
                *.bnii for binary JNIfTI file
                *.jnii for text JNIfTI file
                *.nii  for NIFTI-1/2 files
        options: (optional) if loading from a .bnii file, please see the options for
               loadubjson.m (part of JSONLab); if loading from a .jnii, please see the 
               supported options for loadjson.m (part of JSONLab).

    output:
        jnii: a structure (array) or cell (array). The data structure can
            be completely generic or auxilary data without any JNIfTI
            constructs. However, if a JNIfTI object is included, it shall
            contain the below subfields (can appear within any depth of the
            structure)
                jnii.NIFTIHeader -  a structure containing the 1-to-1 mapped NIFTI-1/2 header
                jnii.NIFTIData - the main image data array
                jnii.NIFTIExtension - a cell array contaiing the extension data buffers

    example:
        jnii=jnifticreate(uint8(magic(10)),'Name','10x10 magic matrix');
        savejnifti(jnii, 'magic10.jnii')
        newjnii=loadjnifti('magic10.jnii');

    this file is part of JNIfTI specification: https://github.com/fangq/jnifti

    License: Apache 2.0, see https://github.com/fangq/jnifti for details




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80

    jnii=loadjnifti(inputfile)
       or
    jnii=loadjnifti(inputfile, 'Par...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 9
loadnifti


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 488

    jnii=loadnifti(filename)
        or
    nii=loadnifti(filename,option)

    Read a NIfTI-1/2 (*.nii/.nii.gz) or Analyze 7.5 (*.hdr/*.img/.hdr.gz/.img.gz) 
    image file.

    author: Qianqian Fang (q.fang <at> neu.edu)

    Please run `help nii2jnii` to see the input output outputs.
    This function is an alias to nii2jnii


    this file is part of JNIfTI specification: https://github.com/fangq/jnifti

    License: Apache 2.0, see https://github.com/fangq/jnifti for details




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 75

    jnii=loadnifti(filename)
        or
    nii=loadnifti(filename,option)



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 12
memmapstream


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1600

    outstruct=memmapstream(bytes, format)

    Map a byte-array (in char array or uint8/int8 array) into a structure
    using a dictionary (format is compatible with memmapfile in MATLAB)

    This function is compatible with both MATLAB and GNU Octave. 

    author: Qianqian Fang (q.fang <at> neu.edu)

    input:
        bytes: a char, int8 or uint8 vector or array
        format: a 3-column cell array in the format compatible with the
              'Format' parameter of memmapfile in MATLAB. It has the
              following structure

             column 1: data type string, it can be one of the following
                'int8','int16','int32','int64',
                'uint8','uint16','uint32','uint64',
                'single','double','logical'
             column 2: an integer vector denoting the size of the data
             column 3: a string denoting the fieldname in the output struct

             For example format={'int8',[1,8],'key'; 'float',[1,1],'value'}
             reads the first 8 bytes from 'bytes' as the first subfield
             'key' and the following 4 bytes as the floating point 'value'
             subfield.

    output:
        outstruct: a structure containing the required field

    example:
        bytestream=['Andy' 5 'JT'];
        format={'uint8', [1,4], 'name',
              'uint8', [1,1], 'age',
              'uint8', [1,2], 'school'};
        data=memmapstream(bytestream,format);

    this file is part of JNIfTI specification: https://github.com/fangq/jnifti

    License: Apache 2.0, see https://github.com/fangq/jnifti for details




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 42

    outstruct=memmapstream(bytes, format)



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 11
nifticreate


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 506

    header=nifticreate(img)
       or
    header=nifticreate(img,format)

    Create a default NIfTI header

    author: Qianqian Fang (q.fang <at> neu.edu)

    input:
        img: the image data matching the header
        format: can only be 'nifti1'. can be ignored

    output:
        header: a struct that is byte-wise compatible with NIfTI-1

    this file is part of JNIfTI specification: https://github.com/fangq/jnifti

    License: Apache 2.0, see https://github.com/fangq/jnifti for details




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 73

    header=nifticreate(img)
       or
    header=nifticreate(img,format)



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 9
niftiinfo


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 355
 -- Function File: niftiinfo (FILENAME)
     Read the metadata from a NIfTI-1/2 and Analyze7.5 formatted image
     file

     Parsing the metadata in a NIfTI-1/2 file or a two-part NIfTI or
     Analyze7.5 header file specified by FILENAME.  The accepted file
     suffixes include .nii, .nii.gz, .hdr, and .hdr.gz.

     See also: niftiread, niftiwrite.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 70
Read the metadata from a NIfTI-1/2 and Analyze7.5 formatted image file



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 9
niftiread


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 461
 -- Function File: niftiread (FILENAME)
 -- Function File: niftiread (HEADERFILE, IMAGEFILE)
 -- Function File: niftiread (INFO)
     Read image data from a NIfTI-1/2 and Analyze7.5 formatted image
     file

     Loading a NIfTI-1/2 file specified by FILENAME, or a two-part NIfTI
     or Analyze7.5 files using HEADERFILE and IMAGEFILE.  The accepted
     file suffixes include .nii, .nii.gz, .hdr, .hdr.gz, .img, img.gz

     See also: niftiinfo, niftiwrite.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 68
Read image data from a NIfTI-1/2 and Analyze7.5 formatted image file



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 10
niftiwrite


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 474
 -- Function File: niftiwrite (IMG, FILENAME)
 -- Function File: niftiwrite (IMG, FILENAME, INFO)
 -- Function File: niftiwrite (IMG, FILENAME, INFO,...)
     Write image data and metadata to a NIfTI-1/2 and Analyze7.5
     formatted image file

     Writing image data IMG and metadata INFO to a NIfTI-1 file or a
     two-part NIfTI or Analyze7.5 files specified by FILENAME.  The
     accepted file suffixes include .nii and .nii.gz.

     See also: niftiinfo, niftiread.


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
Write image data and metadata to a NIfTI-1/2 and Analyze7.5 formatted
image f...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 8
nii2jnii


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 3381

    nii=nii2jnii(niifile, format, options)
       or
    nii2jnii(niifile, jniifile, options)
    nii=nii2jnii(niifile)

    A fast and portable NIFTI-1/2 and Analyze7.5 file parser and converter
    to the text and binary JNIfTI formats defined in JNIfTI specification:
    https://github.com/fangq/jnifti  

    This function is compatible with both MATLAB and GNU Octave. 
    It accepts .nii, .nii.gz, .hdr/.img and .hdr.gz/.img.gz input files

    author: Qianqian Fang (q.fang <at> neu.edu)

    input:
        fname: the file name to the .nii, .nii.gz, .hdr/.img or .hdr.gz/.img.gz file
        format:'nii' for reading the NIfTI-1/2/Analyze files; 
               'jnii' to convert the nii data into an in-memory JNIfTI structure.
               'niiheader' return only the nii header without the image data

               if format is not listed above and nii2jnii is called without 
               an output, format must be a string specifying the output JNIfTI
               file name - *.jnii for text-based JNIfTI, or *.bnii for the 
               binary version
        options: (optional) if saving to a .bnii file, please see the options for
               saveubjson.m (part of JSONLab); if saving to .jnii, please see the 
               supported options for savejson.m (part of JSONLab).

    output:
        if the output is a JNIfTI data structure, it has the following subfield:
          nii.NIFTIHeader -  a structure containing the 1-to-1 mapped NIFTI-1/2 header
          nii.NIFTIData - the main image data array
          nii.NIFTIExtension - a cell array contaiing the extension data buffers

        when calling as nii=nii2jnii(file,'nii'), the output is a NIFTI object containing
          nii.img: the data volume read from the nii file
          nii.datatype: the data type of the voxel, in matlab data type string
          nii.datalen: data count per voxel - for example RGB data has 3x
                    uint8 per voxel, so datatype='uint8', datalen=3
          nii.voxelbyte: total number of bytes per voxel: for RGB data,
                    voxelbyte=3; also voxelbyte=header.bitpix/8
          nii.hdr: file header info, a structure has the full nii header
                    key subfileds include

              sizeof_hdr: must be 348 (for NIFTI-1) or 540 (for NIFTI-2)
              dim: short array, dim(2: dim(1)+1) defines the array size
              datatype: the type of data stored in each voxel
              bitpix: total bits per voxel
              magic: must be 'ni1\0' or 'n+1\0'

              For the detailed nii header, please see 
              https://nifti.nimh.nih.gov/pub/dist/src/niftilib/nifti1.h

    dependency:
          No external dependency if reading .nii/.hdr/.img files;

          To load gzipped input files (.nii.gz/.hdr.gz/.img.gz), one must
          install the ZMat Toolbox (http://github.com/fangq/zmat) and
          JSONLab Toolbox (http://github.com/fangq/jsonlab);

          To save files into the text/binary JNIfTI formatted files, one
          need to install JSONLab (http://github.com/fangq/jsonlab).

    this file was initially developed for the MCX project: https://github.com/fangq/mcx/blob/master/utils/mcxloadnii.m

    this file is part of JNIfTI specification: https://github.com/fangq/jnifti

    License: Apache 2.0, see https://github.com/fangq/jnifti for details




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80

    nii=nii2jnii(niifile, format, options)
       or
    nii2jnii(niifile, j...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 10
niicodemap


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1275

    newval=niicodemap(name, value)

    Bi-directional conversion from NIFTI codes to human-readable JNIfTI 
    header string values

    author: Qianqian Fang (q.fang <at> neu.edu)

    input:
        name: a header name as a string, currently support the below nii
              headers: 'intent_code', 'slice_code', 'datatype', 'qform',
              'sform' and 'xyzt_units' and their corresponding JNIfTI
              headers:
              'Intent','SliceType','DataType','QForm','SForm','Unit'
        value:the current header value, if it is a code, newval will
              output the string version; if it is a string, newval will
              return the code

    output:
        newval: the converted header value

        For the detailed nii header codes, please see 
        https://nifti.nimh.nih.gov/pub/dist/src/niftilib/nifti1.h

    example:
        newval=niicodemap('slice_code', '')
        newval=niicodemap('datatype', 'uint64')
        newval=niicodemap('datatype', 2)

    this file was initially developed for the MCX project: https://github.com/fangq/mcx/blob/master/utils/mcxloadnii.m

    this file is part of JNIfTI specification: https://github.com/fangq/jnifti

    License: Apache 2.0, see https://github.com/fangq/jnifti for details




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 35

    newval=niicodemap(name, value)



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 9
niiformat


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1012

    niiheader=niiformat(format)

    Return a NIfTI header format descriptor as an Nx3 cell array

    author: Qianqian Fang (q.fang <at> neu.edu)

    input:
        format:'nifti1' - return the header descriptor for NIfTI-1 format
               'nifti2' - return the header descriptor for NIfTI-2 format

    output:
        niiheader: an Nx3 cell array in the format similar to the 'Format'
             specifier of the memmapfile.m function in MATLAB
             It has the following structure:

             column 1: data type string, it can be one of the following
                'int8','int16','int32','int64',
                'uint8','uint16','uint32','uint64',
                'single','double'
             column 2: an integer vector denoting the size of the data
             column 3: a string denoting the fieldname in the output struct

    this file is part of JNIfTI specification: https://github.com/fangq/jnifti

    License: Apache 2.0, see https://github.com/fangq/jnifti for details




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 32

    niiheader=niiformat(format)



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 8
savebnii


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1423

    savebnii(jniidata, bniifile)
       or
    savebnii(jniidata, bniifile, 'Param1',value1, 'Param2',value2,...)

    Save an in-memory JNIfTI structure into a binary-JNIfTI file with format
    defined in JNIfTI specification: https://github.com/fangq/jnifti

    author: Qianqian Fang (q.fang <at> neu.edu)

    input:
        jnii: a structure (array) or cell (array). The data structure can
            be completely generic or auxilary data without any JNIfTI
            constructs. However, if a JNIfTI object is included, it shall
            contain the below subfields (can appear within any depth of the
            structure)
                jnii.NIFTIHeader -  a structure containing the 1-to-1 mapped NIFTI-1/2 header
                jnii.NIFTIData - the main image data array
                jnii.NIFTIExtension - a cell array contaiing the extension data buffers
        filename: the output file name to the binary-JNIfTI file (.bnii)
        options: (optional) if saving to .bnii, please see the 
               supported options for saveubjson.m (part of JSONLab).

    example:
        jnii=jnifticreate(uint8(magic(10)),'Name','10x10 magic matrix');
        savebnii(jnii, 'magic10.bnii')
        savebnii(jnii, 'magic10_debug.bnii','Debug',1)

    this file is part of JNIfTI specification: https://github.com/fangq/jnifti

    License: Apache 2.0, see https://github.com/fangq/jnifti for details




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80

    savebnii(jniidata, bniifile)
       or
    savebnii(jniidata, bniifile, ...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 10
savejnifti


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1597

    savejnifti(jnii, outputfile)
       or
    savejnifti(jnii, outputfile, 'Param1',value1, 'Param2',value2,...)

    Save an in-memory JNIfTI structure into a JNIfTI file with format
    defined in JNIfTI specification: https://github.com/fangq/jnifti

    author: Qianqian Fang (q.fang <at> neu.edu)

    input:
        jnii: a structure (array) or cell (array). The data structure can
            be completely generic or auxilary data without any JNIfTI
            constructs. However, if a JNIfTI object is included, it shall
            contain the below subfields (can appear within any depth of the
            structure)
                jnii.NIFTIHeader -  a structure containing the 1-to-1 mapped NIFTI-1/2 header
                jnii.NIFTIData - the main image data array
                jnii.NIFTIExtension - a cell array contaiing the extension data buffers
        outputfile: the output file name to the JNIfTI file 
                *.bnii for binary JNIfTI file
                *.jnii for text JNIfTI file
        options: (optional) if saving to a .bnii file, please see the options for
               saveubjson.m (part of JSONLab); if saving to .jnii, please see the 
               supported options for savejson.m (part of JSONLab).

    example:
        jnii=jnifticreate(uint8(magic(10)),'Name','10x10 magic matrix');
        savejnifti(jnii, 'magic10.jnii')
        savejnifti(jnii, 'magic10_debug.bnii','Debug',1)

    this file is part of JNIfTI specification: https://github.com/fangq/jnifti

    License: Apache 2.0, see https://github.com/fangq/jnifti for details




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80

    savejnifti(jnii, outputfile)
       or
    savejnifti(jnii, outputfile, ...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 8
savejnii


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1421

    savejnii(jniidata, jniifile)
       or
    savejnii(jniidata, jniifile, 'Param1',value1, 'Param2',value2,...)

    Save an in-memory JNIfTI structure into a text-JNIfTI file with format
    defined in JNIfTI specification: https://github.com/fangq/jnifti

    author: Qianqian Fang (q.fang <at> neu.edu)

    input:
        jnii: a structure (array) or cell (array). The data structure can
            be completely generic or auxilary data without any JNIfTI
            constructs. However, if a JNIfTI object is included, it shall
            contain the below subfields (can appear within any depth of the
            structure)
                jnii.NIFTIHeader -  a structure containing the 1-to-1 mapped NIFTI-1/2 header
                jnii.NIFTIData - the main image data array
                jnii.NIFTIExtension - a cell array contaiing the extension data buffers
        filename: the output file name to the text-JNIfTI file (.jnii)
        options: (optional) if saving to .jnii, please see the 
               supported options for savejson.m (part of JSONLab).

    example:
        jnii=jnifticreate(uint8(magic(10)),'Name','10x10 magic matrix');
        savejnii(jnii, 'magic10.jnii')
        savejnii(jnii, 'magic10_compact.jnii','Compact',1)

    this file is part of JNIfTI specification: https://github.com/fangq/jnifti

    License: Apache 2.0, see https://github.com/fangq/jnifti for details




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80

    savejnii(jniidata, jniifile)
       or
    savejnii(jniidata, jniifile, ...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 9
savenifti


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1301

    savenifti(img, filename)
        or
    savenifti(img, filename, rawhdr)
    savenifti(img, filename, 'nifti2')
    bytestream=savenifti(img)

    Write an image to a NIfTI (*.nii) or compressed NIfTI file (.nii.gz)

    author: Qianqian Fang (q.fang <at> neu.edu)

    input:
        img: this is a numerical array to be stored in the NIfTI file
        filename: output file name, can have a suffix of '.nii' or '.nii.gz'
                 if a .gz suffix is used, this function needs the JSONLab 
                 (http://gitlab.com/fangq/jsonlab) and ZMat (http://gitlab.com/fangq/zmat)
                 to perform the compression.
        rawhdr (optional): a struct, as a pre-created/loaded NIfTI header data structure
                if rawhdr is 'nifti1' or 'nifti2', this function calls 
                nifticreate to create a default header.
    output:
        bytestream (optional): the output file byte stream. it only returns this output if
                no filename is given. 

    example:
        a=single(rand(10,20,30));
        savenifti(a,'randnii.nii');
        savenifti(a,'randnii2.nii.gz','nifti2'); % needs zmat


    this file is part of JNIfTI specification: https://github.com/fangq/jnifti

    License: Apache 2.0, see https://github.com/fangq/jnifti for details




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80

    savenifti(img, filename)
        or
    savenifti(img, filename, rawhdr)...





