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


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

 output = base64decode(input)

 Decoding a Base64-encoded byte-stream to recover the original data
 This function depends on JVM in MATLAB or, can optionally use the ZMat
 toolbox (http://github.com/NeuroJSON/zmat)

 Copyright (c) 2012, Kota Yamaguchi
 URL: https://www.mathworks.com/matlabcentral/fileexchange/39526-byte-encoding-utilities

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

 input:
      input: a base64-encoded string

 output:
      output: the decoded binary byte-stream as a uint8 vector

 examples:
      bytes=base64encode('Test JSONLab');
      orig=char(base64decode(bytes))

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 output = base64decode(input)



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


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

 output = base64encode(input)

 Encoding a binary vector or array using Base64

 This function depends on JVM in MATLAB or, can optionally use the ZMat
 toolbox (http://github.com/NeuroJSON/zmat)

 Copyright (c) 2012, Kota Yamaguchi
 URL: https://www.mathworks.com/matlabcentral/fileexchange/39526-byte-encoding-utilities

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

 input:
      input: a base64-encoded string

 output:
      output: the decoded binary byte-stream as a uint8 vector

 examples:
      bytes=base64encode('Test JSONLab');
      orig=char(base64decode(bytes))

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 output = base64encode(input)



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


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

 output = blosc2decode(input,codec)
 output = blosc2decode(input)
    or
 output = blosc2decode(input,info)

 Decompressing an blosc2-compressed byte-stream to recover the original data
 This function depends on the ZMat toolbox (http://github.com/NeuroJSON/zmat)

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

 input:
      input: a string, int8/uint8 vector or numerical array to store blosc2-compressed data
      codec: if the 2nd input is a string, it is treated as a compression method that
           blosc2 supports, it can be one of:
            'blosc2blosclz', 'blosc2lz4', 'blosc2lz4hc', 'blosc2zlib' and 'blosc2zstd'
           if no codec is specified, 'blosc2blosclz' method is assumed
      info (optional): a struct produced by the zmat/blosc2encode function during
            compression; if not given, the inputs/outputs will be treated as a
            1-D vector

 output:
      output: the decompressed byte stream stored in a uint8 vector; if info is
            given, output will restore the original data's type and dimensions

 examples:
      [bytes, info]=blosc2encode(eye(10));
      orig=blosc2decode(bytes,info);

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 output = blosc2decode(input,codec)
 output = blosc2decode(input)
    or
 ou...



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


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

 output = blosc2encode(input)
    or
 [output, info] = blosc2encode(input)

 Compress a string or a numerical array using LZ4-compression

 This function depends on the ZMat toolbox (http://github.com/NeuroJSON/zmat)

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

 input:
      input: the original data, can be a string, a numerical vector or array

 output:
      output: the compressed byte stream stored in a uint8 vector
      info: (optional) a struct storing the metadata of the input, see "help zmat" for details

 examples:
      [bytes, info]=blosc2encode(eye(10));
      orig=blosc2decode(bytes,info);

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 output = blosc2encode(input)
    or
 [output, info] = blosc2encode(input)



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


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

    newname = decodevarname(name)

    Decode a hex-encoded variable name (from encodevarname) and restore
    its original form

    This function is sensitive to the default charset
    settings in MATLAB, please call feature('DefaultCharacterSet','utf8')
    to set the encoding to UTF-8 before calling this function.

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

    input:
        name: a string output from encodevarname, which converts the leading non-ascii
              letter into "x0xHH_" and non-ascii letters into "_0xHH_"
              format, where hex key HH stores the ascii (or Unicode) value
              of the character.

    output:
        newname: the restored original string

    example:
        decodevarname('x0x5F_a')   % returns _a
        decodevarname('a_')   % returns a_ as it is a valid variable name
        decodevarname('x0xE58F98__0xE9878F_')  % returns '变量'

    this file is part of EasyH5 Toolbox: https://github.com/NeuroJSON/easyh5

    License: GPLv3 or 3-clause BSD license, see https://github.com/NeuroJSON/easyh5 for details




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

    newname = decodevarname(name)



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


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

    newname = encodevarname(name)

    Encode an invalid variable name using a hex-format for bi-directional
    conversions.



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

    newname = encodevarname(name)



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


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

 [endpos, maxlevel] = fast_match_bracket(key,pos,startpos,brackets)

 A fast function to find the position of a closing bracket token in a string

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

 input:
      key: a preprocessed string containing only relevant opening/closing
           bracket characters for accelerating the search.
      pos: a 1D integer vector with a length matching the length of key,
           recording the corresponding position of each char. in the original string.
      startpos: the index in the original string as the start position to search; the
               startpos must be at least 1 greater than the opening bracket position
      brackets: (optional), a string of length 2, with the first character
               being the opening token and the 2nd being the closing token.
               if not given, brackets is set to '[]' to find matching square-brackets;
               for example, '{}' looks for a matching closing curly-bracket in
               the string key(pos(startpos,:end))

 output:
      endpos: if a matching bracket is found, return its position in the original
              string
      maxlevel: return the depth of the enclosed brackets between the searched pair,
              including the searching pair. For example, the matching closing-bracket
              of the 1st square bracket (startpos=2) in  '[[[]],[]]' returns a
              position of 9, with a maximum depth of 3; searching for the closing
              bracket for the 2nd square bracket (startpos=3) returns a position of
              5 and max-depth of 2.

 example:
      str='[[ [1,2], 1], 10, [5,10] ]';
      pos=find(str=='[' | str==']')
      key=str(pos)
      [p1,dep]=fast_match_bracket(key,1:length(key),3)
      [p2,dep]=fast_match_bracket(key,pos,2)
      [p3,dep]=fast_match_bracket(key,pos,3)

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 [endpos, maxlevel] = fast_match_bracket(key,pos,startpos,brackets)



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


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

 mmap=filterjsonmmap(mmap, patterns, isinclude)

 filter JSON mmap keys based on inclusive or exclusive string patterns

 authors:Qianqian Fang (q.fang <at> neu.edu)
 initially created on 2022/02/13

 input:
      mmap: memory-map returned by loadjson/loadbj of the same data
            important: mmap must be produced from the same file/string,
            otherwise calling this function may cause data corruption
      patterns: a string or a cell array of strings, each string will
            be tested to match the JSONPath keys in mmap
      isinclude: 1 (default) to include all mmap entries that match at
            least one of the patterns, and 0 - exclude those that match

 output:
      mmap: a filtered JSON mmap

 examples:
      str='{"arr":[[1,2],"a",{"c":2}],"obj":{"k":"test"}}';
      [dat, mmap]=loadjson(str);
      savejson('',mmap)
      newmmap=filterjsonmmap(mmap,{'arr[1]', 'obj.k'});
      savejson('',newmmap)

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 mmap=filterjsonmmap(mmap, patterns, isinclude)



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


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

 p=getvarfrom(ws,name)

 get variable value by name from specified work-space

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

 input:
    ws: name of the work-space, for example, 'base'
    name: name string of the variable

 output:
    p: the value of the specified variable, if the variable does not
       exist, return empty array

 -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)




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

 p=getvarfrom(ws,name)



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


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

 output = gzipdecode(input)
    or
 output = gzipdecode(input,info)

 Decompressing a GZIP-compressed byte-stream to recover the original data
 This function depends on JVM in MATLAB or, can optionally use the ZMat
 toolbox (http://github.com/NeuroJSON/zmat)

 Copyright (c) 2012, Kota Yamaguchi
 URL: https://www.mathworks.com/matlabcentral/fileexchange/39526-byte-encoding-utilities

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

 input:
      input: a string, int8/uint8 vector or numerical array to store the GZIP-compressed data
      info (optional): a struct produced by the zmat/lz4hcencode function during
            compression; if not given, the inputs/outputs will be treated as a
            1-D vector

 output:
      output: the decompressed byte stream stored in a uint8 vector; if info is
            given, output will restore the original data's type and dimensions

 examples:
      [bytes, info]=gzipencode(eye(10));
      orig=gzipdecode(bytes,info);

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 output = gzipdecode(input)
    or
 output = gzipdecode(input,info)



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


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

 output = gzipencode(input)
    or
 [output, info] = gzipencode(input)

 Compress a string or numerical array using the GZIP-compression

 This function depends on JVM in MATLAB or, can optionally use the ZMat
 toolbox (http://github.com/NeuroJSON/zmat)

 Copyright (c) 2012, Kota Yamaguchi
 URL: https://www.mathworks.com/matlabcentral/fileexchange/39526-byte-encoding-utilities

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

 input:
      input: the original data, can be a string, a numerical vector or array

 output:
      output: the decompressed byte stream stored in a uint8 vector; if info is
            given, output will restore the original data's type and dimensions

 examples:
      [bytes, info]=gzipencode(eye(10));
      orig=gzipdecode(bytes,info);

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 output = gzipencode(input)
    or
 [output, info] = gzipencode(input)



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


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

 [isoctave verinfo]=isoctavemesh

 determine whether the code is running in octave

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

 output:
   isoctave: 1 if in octave, otherwise 0
   verinfo: a string, showing the version of octave (OCTAVE_VERSION)

 -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)




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

 [isoctave verinfo]=isoctavemesh



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


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

 newdata=jdatadecode(data,opt,...)

 Convert all JData object (in the form of a struct array) into an array
 (accepts JData objects loaded from either loadjson/loadubjson or
 jsondecode for MATLAB R2016b or later)

 This function implements the JData Specification Draft 3 (Jun. 2020)
 see http://github.com/NeuroJSON/jdata for details

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

 input:
      data: a struct array. If data contains JData keywords in the first
            level children, these fields are parsed and regrouped into a
            data object (arrays, trees, graphs etc) based on JData
            specification. The JData keywords are
               "_ArrayType_", "_ArraySize_", "_ArrayData_"
               "_ArrayIsSparse_", "_ArrayIsComplex_",
               "_ArrayZipType_", "_ArrayZipSize", "_ArrayZipData_"
      opt: (optional) a list of 'Param',value pairs for additional options
           The supported options include
               Recursive: [1|0] if set to 1, will apply the conversion to
                            every child; 0 to disable
               Base64: [0|1] if set to 1, _ArrayZipData_ is assumed to
                         be encoded with base64 format and need to be
                         decoded first. This is needed for JSON but not
                         UBJSON data
               Prefix: ['x0x5F'|'x'] for JData files loaded via loadjson/loadubjson, the
                         default JData keyword prefix is 'x0x5F'; if the
                         json file is loaded using matlab2018's
                         jsondecode(), the prefix is 'x'; this function
                         attempts to automatically determine the prefix;
                         for octave, the default value is an empty string ''.
               FullArrayShape: [0|1] if set to 1, converting _ArrayShape_
                         objects to full matrices, otherwise, stay sparse
               MaxLinkLevel: [0|int] When expanding _DataLink_ pointers,
                         this sets the maximum level of recursion
               FormatVersion: [2|float]: set the JSONLab output version;
                         since v2.0, JSONLab uses JData specification Draft 1
                         for output format, it is incompatible with all
                         previous releases; if old output is desired,
                         please set FormatVersion to 1

 output:
      newdata: the converted data if the input data does contain a JData
               structure; otherwise, the same as the input.

 examples:
      obj={[],{'test'},true,struct('sparse',sparse(2,3),'magic',uint8(magic(5)))}
      jdata=jdatadecode(jdataencode(obj))
      isequaln(obj,jdata)

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 newdata=jdatadecode(data,opt,...)



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


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

 jdata=jdataencode(data)
    or
 jdata=jdataencode(data, options)
 jdata=jdataencode(data, 'Param1',value1, 'Param2',value2,...)

 Annotate a MATLAB struct or cell array into a JData-compliant data
 structure as defined in the JData spec: http://github.com/NeuroJSON/jdata.
 This encoded form servers as an intermediate format that allows unambiguous
 storage, exchange of complex data structures and easy-to-serialize by
 json encoders such as savejson and jsonencode (MATLAB R2016b or newer)

 This function implements the JData Specification Draft 3 (Jun. 2020)
 see http://github.com/NeuroJSON/jdata for details

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

 input:
     data: a structure (array) or cell (array) to be encoded.
     options: (optional) a struct or Param/value pairs for user
              specified options (first in [.|.] is the default)
         AnnotateArray: [0|1] - if set to 1, convert all 1D/2D matrices
              to the annotated JData array format to preserve data types;
              N-D (N>2), complex and sparse arrays are encoded using the
              annotated format by default. Please set this option to 1 if
              you intend to use MATLAB's jsonencode to convert to JSON.
         Base64: [0|1] if set to 1, _ArrayZipData_ is assumed to
                  be encoded with base64 format and need to be
                  decoded first. This is needed for JSON but not
                  UBJSON data
         Prefix: ['x0x5F'|'x'] for JData files loaded via loadjson/loadubjson, the
                      default JData keyword prefix is 'x0x5F'; if the
                      json file is loaded using matlab2018's
                      jsondecode(), the prefix is 'x'; this function
                      attempts to automatically determine the prefix;
                      for octave, the default value is an empty string ''.
         UseArrayZipSize: [1|0] if set to 1, _ArrayZipSize_ will be added to
                  store the "pre-processed" data dimensions, i.e.
                  the original data stored in _ArrayData_, and then flaten
                  _ArrayData_ into a row vector using row-major
                  order; if set to 0, a 2D _ArrayData_ will be used
         UseArrayShape: [0|1] if set to 1, a matrix will be tested by
                  to determine if it is diagonal, triangular, banded or
                  toeplitz, and use _ArrayShape_ to encode the matrix
         MapAsStruct: [0|1] if set to 1, convert containers.Map into
                  struct; otherwise, keep it as map
         Compression: ['zlib'|'gzip','lzma','lz4','lz4hc'] - use zlib method
                  to compress data array
         CompressArraySize: [100|int]: only to compress an array if the
                  total element count is larger than this number.
         FormatVersion [2|float]: set the JSONLab output version; since
                  v2.0, JSONLab uses JData specification Draft 1
                  for output format, it is incompatible with all
                  previous releases; if old output is desired,
                  please set FormatVersion to 1.9 or earlier.

 example:
     jd=jdataencode(struct('a',rand(5)+1i*rand(5),'b',[],'c',sparse(5,5)))

     encodedmat=jdataencode(single(magic(5)),'annotatearray',1,'prefix','x')
     jdatadecode(jsondecode(jsonencode(encodedmat)))  % serialize by jsonencode
     jdatadecode(loadjson(savejson('',encodedmat)))   % serialize by savejson

     encodedtoeplitz=jdataencode(uint8(toeplitz([1,2,3,4],[1,5,6])),'usearrayshape',1,'prefix','x')
     jdatadecode(jsondecode(jsonencode(encodedtoeplitz)))  % serialize by jsonencode
     jdatadecode(loadjson(savejson('',encodedtoeplitz)))   % serialize by savejson

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 jdata=jdataencode(data)
    or
 jdata=jdataencode(data, options)
 jdata=jda...



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


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

    key = jdatahash(data)
        or
    key = jdatahash(data, algorithm)
    key = jdatahash(data, algorithm, 'param1', value1, ...)

    computing the hash key for a string or a numeric array (data elements
    are serialized in the row-major order first)

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

    input:
        data: a string or a numeric array
        algorithm: a string denoting the data hashing algorithm (case
              insensitive); default is 'sha-256'; supported options include

        for both MATLAB/Octave: 'sha-256' (default), 'sha-1' ,'sha-384', 'sha-512', 'md2', 'md5'
        Octave-only: 'md4'

    examples:
        sha256key = jdatahash('neurojson')
        md5key = jdatahash('reusable data', 'md5')

    license:
        BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

    key = jdatahash(data)
        or
    key = jdatahash(data, algorithm)
  ...



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


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

    data = jdlink(uripath)
       or
    [data, fname, cachepath] = jdlink(uripath, 'param1', value1, ...)

    Download linked data files from URLs and store those in cached folders

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

    input:
        uripath: a single string or a cell array of strings, containing
                the http:// or https:// links pointing to the linked
                resources
        'param'/value pairs: (optional) additional options are supported,
                including
            showlink: [1]: print URL or cached file; 0 do not print.
            showsize: [1]: print the total size of the linked files; 0 do not print.
            regex: a regular expression that is used to filter the URL
                 cell array; only those matching the pattern are being
                 downloaded; this has no effect to a single URL input

    output:
        data: a cell array storing the parsed data of each linked file
        fname: a cell array listing the path to each locally cached files
        cachepath: a cell array listing the cache search path orders

    examples:
        data = loadjson('https://neurojson.io:7777/openneuro/ds000001');
        anatfiles = jsonpath(data, '$..anat.._DataLink_');
        data = jdlink(anatfiles, 'regex', 'sub-0[12].*\.nii');
        jsonpath(data, '$..Dim')

    license:
        BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

    data = jdlink(uripath)
       or
    [data, fname, cachepath] = jdlink(u...



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


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

 jload
   or
 jload(fname)
 varlist=jload(fname)
 [varlist, header]=jload(fname)
 varlist=jload(fname,'param1',value1,'param2',value2,...)

 Load variables from a JSON or binary JSON file to a workspace

 authors:Qianqian Fang (q.fang <at> neu.edu)
 created on 2020/05/31

 input:
      fname: (optional) input file name; if not given, load 'default.pmat'
           if fname has a '.json' or '.jdt' suffix, a text-based
           JSON/JData file will be expected; if the suffix is '.pmat' or
           '.jdb', a Binary JData file will be expected.
      opt: (optional) a struct to store parsing options, opt can be replaced by
           a list of ('param',value) pairs - the param string is equivalent
           to a field in opt. opt can have the following
           fields (first in [.|.] is the default)

           ws ['caller'|'base']: the name of the workspace in which the
                         variables are to be saved
           vars [{'var1','var2',...}]: list of variables to be saved
           header [0|1]: if set to 1, return the metadata of the variables
                         stored in the file
           matlab [0|1] if set to 1, use matlab's built-in jsondecode to
                         parse the json file and then decode the output by
                         jdatadecode; input file must have a suffix of .jdt

           all options for loadbj/loadjson (depends on file suffix)
           can be used to adjust the parsing options

 output:
      varlist: a struct with each subfield a variable stored in the file,
               if output is ignored, the variables will be loaded to the
               workspace specified by the 'ws' option, which by default
               load the variables to the current workspace ('caller')

 examples:
      jload  % load all variables in default.pmat to the 'caller' workspace
      jload mydat.pmat
      jload('mydat.pmat','vars', {'v1','v2',...}) % load selected variables
      varlist=jload('mydat.pmat','simplifycell',1)

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://openjdata.org/jsonlab)




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

 jload
   or
 jload(fname)
 varlist=jload(fname)
 [varlist, header]=jload(fn...



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


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

 jsave
   or
 jsave(fname)
 varlist=jsave(fname,'param1',value1,'param2',value2,...)

 Store variables in a workspace to a JSON or binary JSON file

 authors:Qianqian Fang (q.fang <at> neu.edu)
 created on 2020/05/31

 input:
      fname: (optional) output file name; if not given, save to 'default.pmat'
           if fname has a '.json' or '.jdt' suffix, a text-based
           JSON/JData file will be created (slow); if the suffix is '.pmat' or
           '.jdb', a Binary JData (https://github.com/NeuroJSON/bjdata/) file will be created.
      opt: (optional) a struct to store parsing options, opt can be replaced by
           a list of ('param',value) pairs - the param string is equivalent
           to a field in opt. opt can have the following
           fields (first in [.|.] is the default)

           ws ['caller'|'base']: the name of the workspace in which the
                         variables are to be saved
           vars [{'var1','var2',...}]: cell array of variable names to be saved
           matlab [0|1] if set to 1, use matlab's built-in jsonencode to
                         store encoded data to a json file; output file
                         must have a suffix of .jdt

           all options for savebj/savejson (depends on file suffix)
           can be used to adjust the output unless "'matlab',1" is used

 output:
      varlist: a list of variables loaded

 examples:
      jsave  % save all variables in the 'caller' workspace to jamdata.pmat
      jsave('mydat.pmat','vars', {'v1','v2',...}) % save selected variables
      jsave('mydat.pmat','compression','lzma')

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://openjdata.org/jsonlab)




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

 jsave
   or
 jsave(fname)
 varlist=jsave(fname,'param1',value1,'param2',val...



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


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

    json2couch(jsonfile, servername, dbname, docname, options)

    uploading JSON-encoded data to a CouchDB database (a NoSQL database)
    as a document

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

    input:
        jsonfile: the path to the .json file
        couchdburl: the URL of the CouchDB server, usually it is
                  http://servername:5984 where servername is your own
                  server's domain name
        dbname: the database for whcih the file is uploaded to, must be
                  created first
        docname: the document name for the uploaded JSON data
        options: a options structure created by weboptions(), defining
                 Username, Password, ContentType when such information is
                 desired to access the server; by default,
                 options.ContentType is set to 'json' and
                 options.RequestMethod is set to 'POST'

                 if options is a string, it defines a template for a curl
                 command, for example 'curl -X PUT -d @$f $u/$d/$s'.
                 Variables (start with $) are expanded as
                   $f -> path of the json file (first input)
                   $u -> couchdb full URL (second input)
                   $d -> database name (third input)
                   $s -> document name (forth input)

    examples:
        values = inputdlg({'Username:', 'Password:'});
        options = weboptions('ContentType', 'json', 'RequestMethod', 'POST', 'Username',values{1},'Password',values{2});
        json2couch('ds001.json', 'https://example.com:5984', 'bids-samples', 'ds001', options)
        json2couch('ds001.json', sprintf('https://%s:%s@example.com:5984', values{1}, values{2}), 'bids-samples', 'ds001', 'curl -X PUT -d @$f $u/$d/$s')

    license:
        BSD license, see LICENSE_BSD.txt files for details

 -- this function is part of JBIDS toolbox (https://neurojson.org/#software)




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

    json2couch(jsonfile, servername, dbname, docname, options)



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


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

 cachepaths=jsoncache()
 [cachepath, filename]=jsoncache(hyperlink)
 [cachepath, tf]=jsoncache(filename)
 cachepath=jsoncache(dbname, docname, filename, domain)

 return the JSON cache folder where _DataLink_ hyperlinked data files are downloaded

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

 input:
    hyperlink: if a single input is provided, the function check if it is
               a hyperlink starting with http://, https:// or ftp://, if
               so, it trys to extract the database name, document name and
               file name using NeuroJSON's standard link format as

    https://neurojson.org/io/stat.cgi?dbname=..&docname=..&file=..&size=..

               if the URL does not follow the above format, a SHA-256 hash
               will be computed based on the full URL to produce filename;
               dbname is set as the first 2 letters of the hash and
               docname is set to the 3rd/4th letters of the hash; the
               domain name is also extracted from the URL; if the URL
               contains the file's suffix, it is appended to the filename.

               if the string does not contain a link, or the link starts
               with file://, it is treated as a local file path
    dbname: the name of the NeuroJSON database (must exist)
    docname: the name of the NeuroJSON dataset document (must exist)
    filename: the name of the data file - may contain a relative folder
    domain: optional, if not given, 'default' is used; otherwise, user can
            specify customized domain name

 output:
    cachepaths: if the linked file is found in any of the cache folders,
            this returns the full path of the found file as a string;
            otherwise, this stores a cell array listing the searched cache
            folders in the search order
    tf: if a file is found in the cache folder, this returns true;
            otherwise, this contains the extracted file name.

    the cached data files will be searched in the following order

    [pwd '/.neurojson']             | on all OSes
    /home/USERNAME/.neurojson       | on all OSes (per-user)
    /home/USERNAME/.cache/neurojson | if on Linux (per-user)
    /var/cache/neurojson            | if on Linux (system wide)
    /home/USERNAME/Library/neurojson| if on MacOS (per-user)
    /Library/neurojson              | if on MacOS (system wide)
    C:\ProgramData\neurojson        | if on Windows (system wide)

    if a global variable NEUROJSON_CACHE is set in 'base', it will be
    used instead of the above search paths


 example:
    [cachepath, filename] = jsoncache('https://neurojson.org/io/stat.cgi?action=get&db=openneuro&doc=ds000001&file=sub-01/anat/sub-01_inplaneT2.nii.gz&size=669578')
    [cachepath, filename] = jsoncache('https://raw.githubusercontent.com/fangq/jsonlab/master/examples/example1.json')
    [cachepath, filename] = jsoncache('https://neurojson.io:7777/adhd200/Brown')
    [cachepath, filename] = jsoncache('https://neurojson.io:7777/openneuro/ds003805')

 -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)




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

 cachepaths=jsoncache()
 [cachepath, filename]=jsoncache(hyperlink)
 [cachep...



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


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

 json=jsonget(fname,mmap,'$.jsonpath1','$.jsonpath2',...)

 Fast reading of JSON data records using memory-map (mmap) returned by
 loadjson and JSONPath-like keys

 authors:Qianqian Fang (q.fang <at> neu.edu)
 initially created on 2022/02/02

 input:
      fname: a JSON/BJData/UBJSON string or stream, or a file name
      mmap: memory-map returned by loadjson/loadbj of the same data
            important: mmap must be produced from the same file/string,
            otherwise calling this function may cause data corruption
      '$.jsonpath1,2,3,...':  a series of strings in the form of JSONPath
            as the key to each of the record to be retrieved; if no paths
            are given, all items in mmap are retrieved

 output:
      json: a cell array, made of elements {'$.jsonpath_i',json_string_i}

 examples:
      str='[[1,2],"a",{"c":2}]{"k":"test"}';
      [dat, mmap]=loadjson(str);
      savejson('',dat,'filename','mydata.json','compact',1);
      json=jsonget(str,mmap,'$[0]','$[2].c')
      json=jsonget('mydata.json',mmap,'$[0]','$[2].c')

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 json=jsonget(fname,mmap,'$.jsonpath1','$.jsonpath2',...)



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


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

 val=jsonopt(key,default,optstruct)

 setting options based on a struct. The struct can be produced
 by varargin2struct from a list of 'param','value' pairs

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

 input:
      key: a string with which one look up a value from a struct
      default: if the key does not exist, return default
      optstruct: a struct where each sub-field is a key

 output:
      val: if key exists, val=optstruct.key; otherwise val=default

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 val=jsonopt(key,default,optstruct)



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


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

    obj=jsonpath(root, jpath)

    Query and retrieve elements from matlab data structures using JSONPath

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

    input:
        root: a matlab data structure like an array, cell, struct, etc
        jpath: a string in the format of JSONPath, see loadjson help

    output:
        obj: if the specified element exist, obj returns the result

    example:
        jsonpath(struct('a',[1,2,3]), '$.a[1]')      % returns 2

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

    obj=jsonpath(root, jpath)



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


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

 json=jsonset(fname,mmap,'$.jsonpath1',newval1,'$.jsonpath2','newval2',...)

 Fast writing of JSON data records to stream or disk using memory-map
 (mmap) returned by loadjson/loadbj and JSONPath-like keys

 authors:Qianqian Fang (q.fang <at> neu.edu)
 initially created on 2022/02/02

 input:
      fname: a JSON/BJData/UBJSON string or stream, or a file name
      mmap: memory-map returned by loadjson/loadbj of the same data
            important: mmap must be produced from the same file/string,
            otherwise calling this function may cause data corruption
      '$.jsonpath1,2,3,...':  a series of strings in the form of JSONPath
            as the key to each of the record to be written

 output:
      json: the modified JSON string or, in the case fname is a filename,
            the cell string made of jsonpaths that are successfully
            written

 examples:
      % create test data
       d.arr={[1,2],'a',struct('c',2)}; d.obj=struct('k','test')
      % convert to json string
       str=savejson('',d,'compact',1)
      % parse and return mmap
       [dat, mmap]=loadjson(str);
      % display mmap entries
       savejson('',mmap)
      % replace value using mmap
       json=jsonset(str,mmap,'$.arr[2].c','5')
      % save same json string to file (must set savebinary 1)
       savejson('',d,'filename','file.json','compact',1,'savebinary',1);
      % fast write to file
       json=jsonset('file.json',mmap,'$.arr[2].c','5')

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 json=jsonset(fname,mmap,'$.jsonpath1',newval1,'$.jsonpath2','newval2',...)



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


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

    data = loadbidstsv(tsvfile)
       or
    data = loadbidstsv(tsvfile, delim)

    Loading a BIDS-formatted .tsv (tab-separated values) or .tsv.gz file as a
    struct; numerical fields are converted to floating-point data records
    when possible; the header of the file is parsed to define sub-field
    names

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

    input:
        tsvfile: the path to the .tsv file
        delim: (optional) if not set, tab ('\t') is used as column delimiter

    examples:
        data = loadbidstsv('participants.tsv');

    license:
        BSD license, see LICENSE_BSD.txt files for details

 -- this function is part of JBIDS toolbox (https://neurojson.org/#software)




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

    data = loadbidstsv(tsvfile)
       or
    data = loadbidstsv(tsvfile, de...



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


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

 data=loadbj(fname,opt)
    or
 [data, mmap]=loadbj(fname,'param1',value1,'param2',value2,...)

 Parse a Binary JData (BJData v1 Draft-2, defined in https://github.com/NeuroJSON/bjdata)
 file or memory buffer and convert into a MATLAB data structure

 By default, this function parses BJD-compliant output. The BJD
 specification is largely similar to UBJSON, with additional data types
 including uint16(u), uint32(m), uint64(M) and half-precision float (h).
 Starting from BJD Draft-2 (JSONLab 3.0 beta or later), all integer and
 floating-point numbers are parsed in Little-Endian as opposed to
 Big-Endian form as in BJD Draft-1/UBJSON Draft-12 (JSONLab 2.0 or older)

 authors:Qianqian Fang (q.fang <at> neu.edu)
 initially created on 2013/08/01

 input:
      fname: input file name, if fname contains "{}" or "[]", fname
             will be interpreted as a BJData/UBJSON string
      opt: a struct to store parsing options, opt can be replaced by
           a list of ('param',value) pairs - the param string is equivalent
           to a field in opt. opt can have the following
           fields (first in [.|.] is the default)

           SimplifyCell [1|0]: if set to 1, loadbj will call cell2mat
                         for each element of the JSON data, and group
                         arrays based on the cell2mat rules.
           Endian ['L'|'B']: specify the endianness of the numbers
                         in the BJData/UBJSON input data. Default: 'L'.

                         Starting from JSONLab 2.9, BJData by default uses
                         [L] Little-Endian for both integers and floating
                         point numbers. This is a major departure from the
                         UBJSON specification, where 'B' - Big-Endian -
                         format is used for integer fields. UBJSON does
                         not specifically define Endianness for
                         floating-point numbers, resulting in mixed
                         implementations. JSONLab 2.0-2.1 used 'B' for
                         integers and floating-points; JSONLab 1.x uses
                         'B' for integers and native-endianness for
                         floating-point numbers.
           NameIsString [0|1]: for UBJSON Specification Draft 8 or
                         earlier versions (JSONLab 1.0 final or earlier),
                         the "name" tag is treated as a string. To load
                         these UBJSON data, you need to manually set this
                         flag to 1.
           UseMap [0|1]: if set to 1, loadbj uses a containers.Map to
                         store map objects; otherwise use a struct object
           ObjectID [0|integer or list]: if set to a positive number,
                         it returns the specified JSON object by index
                         in a multi-JSON document; if set to a vector,
                         it returns a list of specified objects.
           FormatVersion [2|float]: set the JSONLab format version; since
                         v2.0, JSONLab uses JData specification Draft 1
                         for output format, it is incompatible with all
                         previous releases; if old output is desired,
                         please set FormatVersion to 1.9 or earlier.
           MmapOnly [0|1]: if set to 1, this function only returns mmap
           MMapInclude 'str1' or  {'str1','str2',..}: if provided, the
                         returned mmap will be filtered by only keeping
                         entries containing any one of the string patterns
                         provided in a cell
           MMapExclude 'str1' or  {'str1','str2',..}: if provided, the
                         returned mmap will be filtered by removing
                         entries containing any one of the string patterns
                         provided in a cell

 output:
      dat: a cell array, where {...} blocks are converted into cell arrays,
           and [...] are converted to arrays
      mmap: (optional) a cell array in the form of
           {{jsonpath1,[start,length]}, {jsonpath2,[start,length]}, ...}
           where jsonpath_i is a string in the form of JSONPath, and
           start is an integer referring to the offset from the beginning
           of the stream, and length is the JSON object string length.
           For more details, please see the help section of loadjson.m

           The format of the mmap table returned from this function
           follows the JSON-Mmap Specification Draft 1 [3] defined by the
           NeuroJSON project, see https://neurojson.org/jsonmmap/draft1/

 examples:
      obj=struct('string','value','array',[1 2 3]);
      ubjdata=savebj('obj',obj);
      dat=loadbj(ubjdata)
      dat=loadbj(['examples' filesep 'example1.bjd'])
      dat=loadbj(['examples' filesep 'example1.bjd'],'SimplifyCell',0)

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 data=loadbj(fname,opt)
    or
 [data, mmap]=loadbj(fname,'param1',value1,'p...



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


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

    [data, meta] = loadh5(filename)
    [data, meta] = loadh5(root_id)
    [data, meta] = loadh5(filename, rootpath)
    [data, meta] = loadh5(filename, rootpath, options)
    [data, meta] = loadh5(filename, options)
    [data, meta] = loadh5(filename, 'Param1',value1, 'Param2',value2,...)

    Load data in an HDF5 file to a MATLAB structure.

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

    input
        filename
            Name of the file to load data from
        root_id: an HDF5 handle (of type 'H5ML.id' in MATLAB)
        rootpath : (optional)
            Root path to read part of the HDF5 file to load
        options: (optional) a struct or Param/value pairs for user specified options
            Order: 'creation' - creation order (default), or 'alphabet' - alphabetic
            Regroup: [0|1]: if 1, call regrouph5() to combine indexed
                  groups into a cell array
            PackHex: [1|0]: convert invalid characters in the group/dataset
                  names to 0x[hex code] by calling encodevarname.m;
                  if set to 0, call getvarname
            ComplexFormat: {'realKey','imagKey'}: use 'realKey' and 'imagKey'
                  as possible keywords for the real and the imaginary part
                  of a complex array, respectively (sparse arrays not supported);
                  a common list of keypairs is used even without this option
            Transpose: [1|0] - if set to 1 (default), the row-majored HDF5
                  datasets are transposed (to column-major) so that the
                  output MATLAB array has the same dimensions as in the
                  HDF5 dataset header.

    output
        data: a structure (array) or cell (array)
        meta: optional output to store the attributes stored in the file

    example:
        a={rand(2), struct('va',1,'vb','string'), 1+2i};
        saveh5(a,'test.h5');
        a2=loadh5('test.h5')
        a3=loadh5('test.h5','regroup',1)
        isequaln(a,a3.a)
        a4=loadh5('test.h5','/a1')

    This function was adapted from h5load.m by Pauli Virtanen <pav at iki.fi>
    This file is part of EasyH5 Toolbox: https://github.com/NeuroJSON/easyh5

    License: GPLv3 or 3-clause BSD license, see https://github.com/NeuroJSON/easyh5 for details




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

    [data, meta] = loadh5(filename)
    [data, meta] = loadh5(root_id)
    [...



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


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

    data=loadjd(inputfile)
       or
    [data, mmap]=loadjd(inputfile, 'Param1',value1, 'Param2',value2,...)

    Parse a hierarchical container data file, including JSON,
    binary JSON (BJData/UBJSON/MessagePack) and HDF5, and output
    the parsed data in a MATLAB/Octave data structure

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

    input:
        inputfile: the input hierarchical container data file, supporting:
                *.json,.jnii,.jdt,.jmsh,.jnirs,.jbids: JSON/JData based data files, see https://neurojson.org/jdata/draft2
                *.bjd,.bnii,.jdb,.bmsh,.bnirs,.pmat: binary JData (BJData) files, see https://neurojson.org/bjdata/draft2
                *.ubj: UBJSON-encoded files, see http://ubjson.org
                *.msgpack: MessagePack-encoded files, see http://msgpack.org
                *.h5,.hdf5,.snirf,.nwb: HDF5 files, see https://www.hdfgroup.org/
                *.nii,.nii.gz: NIfTI files, need http://github.com/NeuroJSON/jnifty
                *.tsv,.tsv.gz,.csv,.csv.gz: TSV/CSV files, need http://github.com/NeuroJSON/jbids
                *.bval,.bvec: EEG .bval and .bvec files
                *.mat: MATLAB/Octave .mat files
        options: (optional) for JSON/JData files, these are optional 'param',value pairs
                supported by loadjson.m; for BJData/UBJSON/MessagePack files, these are
                options supported by loadbj.m; for HDF5 files, these are options
                supported by loadh5.m (part of EasyH5 toolbox, http://github.com/NeuroJSON/easyh5/)

    output:
        data: a structure (array) or cell (array) storing the hierarchical data
              in the container data file
        mmap: (optional) output storing the JSON/binary JSON memory-map table for fast
              disk access. see help info for loadjson or loadbj for more details.

    examples:
        obj=struct('string','value','array',[1 2 3]);
        savejd('obj', obj, 'datafile.json')
        newobj=loadjd('datafile.json');

    license:
        BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

    data=loadjd(inputfile)
       or
    [data, mmap]=loadjd(inputfile, 'Par...



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


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

    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/NeuroJSON/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
               loadbj.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/NeuroJSON/jnifti

    License: Apache 2.0, see https://github.com/NeuroJSON/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: 8
loadjson


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

 data=loadjson(fname,opt)
    or
 [data, mmap]=loadjson(fname,'param1',value1,'param2',value2,...)

 parse a JSON (JavaScript Object Notation) file or string and return a
 matlab data structure with optional memory-map (mmap) table

 authors:Qianqian Fang (q.fang <at> neu.edu)
 created on 2011/09/09, including previous works from

         Nedialko Krouchev: http://www.mathworks.com/matlabcentral/fileexchange/25713
            created on 2009/11/02
         François Glineur: http://www.mathworks.com/matlabcentral/fileexchange/23393
            created on  2009/03/22
         Joel Feenstra:
         http://www.mathworks.com/matlabcentral/fileexchange/20565
            created on 2008/07/03

 input:
      fname: input file name; if fname contains "{}" or "[]", fname
             will be interpreted as a JSON string
      opt: (optional) a struct to store parsing options, opt can be replaced by
           a list of ('param',value) pairs - the param string is equivalent
           to a field in opt. opt can have the following
           fields (first in [.|.] is the default)

           SimplifyCell [1|0]: if set to 1, loadjson will call cell2mat
                         for each element of the JSON data, and group
                         arrays based on the cell2mat rules.
           FastArrayParser [1|0 or integer]: if set to 1, use a
                         speed-optimized array parser when loading an
                         array object. The fast array parser may
                         collapse block arrays into a single large
                         array similar to rules defined in cell2mat; 0 to
                         use a legacy parser; if set to a larger-than-1
                         value, this option will specify the minimum
                         dimension to enable the fast array parser. For
                         example, if the input is a 3D array, setting
                         FastArrayParser to 1 will return a 3D array;
                         setting to 2 will return a cell array of 2D
                         arrays; setting to 3 will return to a 2D cell
                         array of 1D vectors; setting to 4 will return a
                         3D cell array.
           UseMap [0|1]: if set to 1, loadjson uses a containers.Map to
                         store map objects; otherwise use a struct object
           ShowProgress [0|1]: if set to 1, loadjson displays a progress bar.
           ParseStringArray [0|1]: if set to 0, loadjson converts "string arrays"
                         (introduced in MATLAB R2016b) to char arrays; if set to 1,
                         loadjson skips this conversion.
           FormatVersion [3|float]: set the JSONLab format version; since
                         v2.0, JSONLab uses JData specification Draft 1
                         for output format, it is incompatible with all
                         previous releases; if old output is desired,
                         please set FormatVersion to 1.9 or earlier.
           Encoding ['']: json file encoding. Support all encodings of
                         fopen() function
           ObjectID [0|integer or list]: if set to a positive number,
                         it returns the specified JSON object by index
                         in a multi-JSON document; if set to a vector,
                         it returns a list of specified objects.
           JDataDecode [1|0]: if set to 1, call jdatadecode to decode
                         JData structures defined in the JData
                         Specification.
           BuiltinJSON [0|1]: if set to 1, this function attempts to call
                         jsondecode, if presents (MATLAB R2016b or Octave
                         6) first. If jsondecode does not exist or failed,
                         this function falls back to the jsonlab parser
           MmapOnly [0|1]: if set to 1, this function only returns mmap
           MMapInclude 'str1' or  {'str1','str2',..}: if provided, the
                         returned mmap will be filtered by only keeping
                         entries containing any one of the string patterns
                         provided in a cell
           MMapExclude 'str1' or  {'str1','str2',..}: if provided, the
                         returned mmap will be filtered by removing
                         entries containing any one of the string patterns
                         provided in a cell

 output:
      dat: a cell array, where {...} blocks are converted into cell arrays,
           and [...] are converted to arrays
      mmap: (optional) a cell array as memory-mapping table in the form of
             {{jsonpath1,[start,length,<whitespace_pre>]},
              {jsonpath2,[start,length,<whitespace_pre>]}, ...}
           where jsonpath_i is a string in the JSONPath [1,2] format, and
           "start" is an integer referring to the offset from the beginning
           of the stream, and "length" is the JSON object string length.
           An optional 3rd integer "whitespace_pre" may appear to record
           the preceding whitespace length in case expansion of the data
           record is needed when using the mmap.

           The format of the mmap table returned from this function
           follows the JSON-Mmap Specification Draft 1 [3] defined by the
           NeuroJSON project, see https://neurojson.org/jsonmmap/draft1/

           Memory-mapping table (mmap) is useful when fast reading/writing
           specific data records inside a large JSON file without needing
           to load/parse/overwrite the entire file.

           The JSONPath keys used in mmap is largely compatible to the
           upstream specification defined in [1], with a slight extension
           to handle concatenated JSON files.

           In the mmap jsonpath key, a '$' denotes the root object, a '.'
           denotes a child of the preceding element; '.key' points to the
           value segment of the child named "key" of the preceding
           object; '[i]' denotes the (i+1)th member of the preceding
           element, which must be an array. For example, a key

           $.obj1.obj2[0].obj3

           defines the memory-map of the "value" section in the below
           hierarchy:
             {
                "obj1":{
                    "obj2":[
                       {"obj3":value},
                       ...
                    ],
                    ...
                 }
             }
           Please note that "value" can be any valid JSON value, including
           an array, an object, a string or numerical value.

           To handle concatenated JSON objects (including ndjson,
           http://ndjson.org/), such as

             {"root1": {"obj1": ...}}
             ["root2", value1, value2, {"obj2": ...}]
             {"root3": ...}

           we use '$' or '$0' for the first root-object, and '$1' refers
           to the 2nd root object (["root2",...]) and '$2' refers to the
           3rd root object, and so on. Please note that this syntax is an
           extension from the JSONPath documentation [1,2]

           [1] https://goessner.net/articles/JsonPath/
           [2] http://jsonpath.herokuapp.com/
           [3] https://neurojson.org/jsonmmap/draft1/

 examples:
      dat=loadjson('{"obj":{"string":"value","array":[1,2,3]}}')
      dat=loadjson(['examples' filesep 'example1.json'])
      [dat, mmap]=loadjson(['examples' filesep 'example1.json'],'SimplifyCell',0)

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 data=loadjson(fname,opt)
    or
 [data, mmap]=loadjson(fname,'param1',value...



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


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

   data = loadmsgpack(fname,varargin)

 LOADMSGPACK parses a msgpack byte buffer into Matlab data structures
 LOADMSGPACK(BYTES)
    reads BYTES as msgpack data, and creates Matlab data structures
    from it.
    - strings are converted to strings
    - numbers are converted to appropriate numeric values
    - true, false are converted to logical 1, 0
    - nil is converted to []
    - arrays are converted to cell arrays
    - maps are converted to containers.Map

 (c) 2016 Bastian Bechtold
 modified by Qianqian Fang <q.fang at neu.edu>

 license:
     BSD 3-clause license or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

   data = loadmsgpack(fname,varargin)



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


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

    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/NeuroJSON/jnifti

    License: Apache 2.0, see https://github.com/NeuroJSON/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: 10
loadubjson


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

 data=loadubjson(fname,opt)
    or
 data=loadubjson(fname,'param1',value1,'param2',value2,...)

 Parse a UBJSON file or string and store the output into a MATLAB variable

 author: Qianqian Fang (q.fang <at> neu.edu)
 initially created on 2019/06/08

 This function is an alias to loadbj

 input:
      fname: input file name, if the file with such name exists, it will
             be read, otherwise, this function will attempt to parse the
             string in fname as a UBJSON stream
      opt: a struct to store parsing options, opt can be replaced by
           a list of ('param',value) pairs - the param string is equivalent
           to a field in opt. The supported options can be found by typing
           "help loadbj".

 output:
      data: a cell array, where {...} blocks are converted into cell arrays,
           and [...] are converted to arrays

 examples:
      obj=struct('string','value','array',[1 2 3]);
      ubjdata=saveubjson('obj',obj);
      dat=loadubjson(ubjdata)
      dat=loadubjson(['examples' filesep 'example1.ubj'])
      dat=loadubjson(['examples' filesep 'example1.ubj'],'SimplifyCell',0)

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 data=loadubjson(fname,opt)
    or
 data=loadubjson(fname,'param1',value1,'p...



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


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

 output = lz4decode(input)
    or
 output = lz4decode(input,info)

 Decompressing an LZ4-compressed byte-stream to recover the original data
 This function depends on the ZMat toolbox (http://github.com/NeuroJSON/zmat)

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

 input:
      input: a string, int8/uint8 vector or numerical array to store LZ4-compressed data
      info (optional): a struct produced by the zmat/lz4encode function during
            compression; if not given, the inputs/outputs will be treated as a
            1-D vector

 output:
      output: the decompressed byte stream stored in a uint8 vector; if info is
            given, output will restore the original data's type and dimensions

 examples:
      [bytes, info]=lz4encode(eye(10));
      orig=lz4decode(bytes,info);

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 output = lz4decode(input)
    or
 output = lz4decode(input,info)



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


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

 output = lz4encode(input)
    or
 [output, info] = lz4encode(input)

 Compress a string or a numerical array using LZ4-compression

 This function depends on the ZMat toolbox (http://github.com/NeuroJSON/zmat)

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

 input:
      input: the original data, can be a string, a numerical vector or array

 output:
      output: the compressed byte stream stored in a uint8 vector
      info: (optional) a struct storing the metadata of the input, see "help zmat" for details

 examples:
      [bytes, info]=lz4encode(eye(10));
      orig=lz4decode(bytes,info);

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 output = lz4encode(input)
    or
 [output, info] = lz4encode(input)



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


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

 output = lz4hcdecode(input)
    or
 output = lz4hcdecode(input,info)

 Decompressing an LZ4HC-compressed byte-stream to recover the original data
 This function depends on the ZMat toolbox (http://github.com/NeuroJSON/zmat)

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

 input:
      input: a string, int8/uint8 vector or numerical array to store LZ4HC-compressed data
      info (optional): a struct produced by the zmat/lz4hcencode function during
            compression; if not given, the inputs/outputs will be treated as a
            1-D vector

 output:
      output: the decompressed byte stream stored in a uint8 vector; if info is
            given, output will restore the original data's type and dimensions

 examples:
      [bytes, info]=lz4hcencode(eye(10));
      orig=lz4hcdecode(bytes,info);

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 output = lz4hcdecode(input)
    or
 output = lz4hcdecode(input,info)



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


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

 output = lz4hcencode(input)
    or
 [output, info] = lz4hcencode(input)

 Compress a string or a numerical array using LZ4HC-compression

 This function depends on the ZMat toolbox (http://github.com/NeuroJSON/zmat)

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

 input:
      input: the original data, can be a string, a numerical vector or array

 output:
      output: the compressed byte stream stored in a uint8 vector
      info: (optional) a struct storing the metadata of the input, see "help zmat" for details

 examples:
      [bytes, info]=lz4hcencode(eye(10));
      orig=lz4hcdecode(bytes,info);

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 output = lz4hcencode(input)
    or
 [output, info] = lz4hcencode(input)



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


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

 output = lzipdecode(input)
    or
 output = lzipdecode(input,info)

 Decompressing an Lzip-compressed byte-stream to recover the original data
 This function depends on the ZMat toolbox (http://github.com/NeuroJSON/zmat)

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

 input:
      input: a string, int8/uint8 vector or numerical array to store Lzip-compressed data
      info (optional): a struct produced by the zmat/lzipencode function during
            compression; if not given, the inputs/outputs will be treated as a
            1-D vector

 output:
      output: the decompressed byte stream stored in a uint8 vector; if info is
            given, output will restore the original data's type and dimensions

 examples:
      [bytes, info]=lzipencode(eye(10));
      orig=lzipdecode(bytes,info);

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 output = lzipdecode(input)
    or
 output = lzipdecode(input,info)



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


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

 output = lzipencode(input)
    or
 [output, info] = lzipencode(input)

 Compress a string or a numerical array using LZip-compression

 This function depends on the ZMat toolbox (http://github.com/NeuroJSON/zmat)

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

 input:
      input: the original data, can be a string, a numerical vector or array

 output:
      output: the compressed byte stream stored in a uint8 vector
      info: (optional) a struct storing the metadata of the input, see "help zmat" for details

 examples:
      [bytes, info]=lzipencode(eye(10));
      orig=lzipdecode(bytes,info);

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 output = lzipencode(input)
    or
 [output, info] = lzipencode(input)



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


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

 output = lzmadecode(input)
    or
 output = lzmadecode(input,info)

 Decompressing an LZMA-compressed byte-stream to recover the original data
 This function depends on the ZMat toolbox (http://github.com/NeuroJSON/zmat)

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

 input:
      input: a string, int8/uint8 vector or numerical array to store LZMA-compressed data
      info (optional): a struct produced by the zmat/lzmaencode function during
            compression; if not given, the inputs/outputs will be treated as a
            1-D vector

 output:
      output: the decompressed byte stream stored in a uint8 vector; if info is
            given, output will restore the original data's type and dimensions

 examples:
      [bytes, info]=lzmaencode(eye(10));
      orig=lzmadecode(bytes,info);

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 output = lzmadecode(input)
    or
 output = lzmadecode(input,info)



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


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

 output = lzmaencode(input)
    or
 [output, info] = lzmaencode(input)

 Compress a string or a numerical array using LZMA-compression

 This function depends on the ZMat toolbox (http://github.com/NeuroJSON/zmat)

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

 input:
      input: the original data, can be a string, a numerical vector or array

 output:
      output: the compressed byte stream stored in a uint8 vector
      info: (optional) a struct storing the metadata of the input, see "help zmat" for details

 examples:
      [bytes, info]=lzmaencode(eye(10));
      orig=lzmadecode(bytes,info);

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 output = lzmaencode(input)
    or
 [output, info] = lzmaencode(input)



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


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

 [endpos, maxlevel] = match_bracket(str,startpos,brackets)

 Looking for the position of a closing bracket token in a string

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

 input:
      str: the full string to be searched
      startpos: the index in the string as the start position to search; the
               startpos must be at least 1 greater than the opening bracket position
      brackets: (optional), a string of length 2, with the first character
               being the opening token and the 2nd being the closing token.
               if not given, brackets is set to '[]' to find matching square-brackets;
               for example, '{}' looks for a matching closing curly-bracket in
               the string key(pos(startpos,:end))

 output:
      endpos: if a matching bracket is found, return its position in the original
              string
      maxlevel: return the depth of the enclosed brackets between the searched pair,
              including the searching pair. For example, the matching closing-bracket
              of the 1st square bracket (startpos=2) in  '[[[]],[]]' returns a
              position of 9, with a maximum depth of 3; searching for the closing
              bracket for the 2nd square bracket (startpos=3) returns a position of
              5 and max-depth of 2.

 example:
      str='[[ [1,2], 1], 10, [5,10] ]';
      [p1,dep]=match_bracket(str,3)
      [p2,dep]=match_bracket(str,2)
      [p3,dep]=match_bracket(str,3)

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 [endpos, maxlevel] = match_bracket(str,startpos,brackets)



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


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

    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/NeuroJSON/jnifti

    License: Apache 2.0, see https://github.com/NeuroJSON/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
mergestruct


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

 s=mergestruct(s1,s2)

 merge two struct objects into one

 authors:Qianqian Fang (q.fang <at> neu.edu)
 date: 2012/12/22

 input:
      s1,s2: a struct object, s1 and s2 can not be arrays

 output:
      s: the merged struct object. fields in s1 and s2 will be combined in s.

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 s=mergestruct(s1,s2)



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


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

 [dims, isndarray, maxlevel, count] = nestbracket2dim(str,brackets)

 Extracting the dimension vector of a JSON string formatted array
 by analyzing the pairs of opening/closing bracket tokenss; this function
 only returns valid dimension information when the array is an N-D array

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

 input:
      str: a string-formatted JSON array using square-brackets for enclosing
           elements and comma as separators between elements
      brackets: (optional), a string of length 2, with the first character
               being the opening token and the 2nd being the closing token.
               if not given, brackets is set to '[]' to find matching square-brackets;
               for example, '{}' looks for a matching closing curly-bracket in
               the string key(pos(startpos,:end))
      testndarray: (optional), 1 to test if the input string contains an
               ND array, i.e. with uniform element lengths (recursively)

 output:
      dims: the speculated dimension vector with the length matching the maximum
            depth of the embedded bracket pairs. When the input string encodes an
            N-D array, the dims vector contains all integers; however, returning
            an all-integer dims vector does not mean the array is
            rectangular. if testndarray is set to 1, dims returns isndarray
      isndarray: 1 to indicate the input string contains an ND array,
            otherwise, 0
      maxlevel: return the depth of the enclosed brackets in the string, i.e. the
            length of the dims vector.
      count: the relative depth from the level 0 - scanning from the left
            to right of the string, an opening token increases the level by 1
            and a closing token decreases the level by 1; a zero indicates
            the positions of a matching bracket of the same level.

 example:
      str='[[ [1,2,3], [4,2,1]], [ [10,1,0], [2,5,10]] ]'; % an N-D array
      [dim,dep]=nestbracket2dim(str)
      str='[[ [1,2,3], [4,2,1]], [ [10,1,0], [2,5]] ]'; % an invalid N-D array
      [dim,dep]=nestbracket2dim(str)

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 [dims, isndarray, maxlevel, count] = nestbracket2dim(str,brackets)



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


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

    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/NeuroJSON/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
               savebj.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/NeuroJSON/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/NeuroJSON/jnifti

    License: Apache 2.0, see https://github.com/NeuroJSON/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: 1281

    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/NeuroJSON/jnifti

    License: Apache 2.0, see https://github.com/NeuroJSON/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: 1020

    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/NeuroJSON/jnifti

    License: Apache 2.0, see https://github.com/NeuroJSON/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: 14
niiheader2jnii


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 50
undocumented function: nii = niiheader2jnii (nii0)


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 50
undocumented function: nii = niiheader2jnii (nii0)



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


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

 output = octavezmat(input, iscompress, zipmethod)
    or
 [output, info] = octavezmat(input, iscompress, zipmethod)
 unzipdata = octavezmat(zipdata, info)

 Compress or decompress zlib and gzip memory buffers using zip/unzip/gzip/gunzip on Octave
 in case ZMat toolbox (http://github.com/NeuroJSON/zmat) was not installed (ZMat is much faster)

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

 input:
      input: the input data (can be either compressed or before compression),
             can be a string, a numerical vector or array
      iscompress: (optional) if iscompress is 1, zmat compresses/encodes the input,
             if 0, it decompresses/decodes the input. Default value is 1.

             if iscompress is set to a negative integer, (-iscompress) specifies
             the compression level. For zlib/gzip, default level is 6 (1-9); for
             lzma/lzip, default level is 5 (1-9); for lz4hc, default level is 8 (1-16).
             the default compression level is used if iscompress is set to 1.

             zmat removes the trailing newline when iscompress=2 and method='base64'
             all newlines are kept when iscompress=3 and method='base64'

             if one defines iscompress as the info struct (2nd output of zmat), zmat
             will perform a decoding/decompression operation and recover the original
             input using the info stored in the info structure.
      method: (optional) compression method, only the below two methods are supported
             'zlib': zlib/zip based data compression (default)
             'gzip': gzip formatted data compression

 output:
      output: the decompressed byte stream stored in a uint8 vector; if info is
            given, output will restore the original data's type and dimensions
      info: (optional) a struct storing additional info regarding the input data, may have
            'type': the class of the input array
            'size': the dimensions of the input array
            'byte': the number of bytes per element in the input array
            'method': a copy of the 3rd input indicating the encoding method
            'status': the zlib/lzma/lz4 compression/decompression function return value,
                    including potential error codes; see documentation of the respective
                    libraries for details
            'level': a copy of the iscompress flag; if non-zero, specifying compression
                    level, see above

 examples:
      NO_ZMAT=1  % by setting this flag to 1 in the caller or global workspace, octavezmat won't warn zmat is missing
      [ss,info]=octavezmat(ones(10))
      orig=octavezmat(ss,info)

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 output = octavezmat(input, iscompress, zipmethod)
    or
 [output, info] = ...



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


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

    data=regrouph5(root)
       or
    data=regrouph5(root,type)
    data=regrouph5(root,{'nameA','nameB',...})

    Processing a loadh5 restored data and merge "indexed datasets", whose
    names start with an ASCII string followed by a contiguous integer
    sequence number starting from 1, into a cell array. For example,
    datasets {data.a1, data.a2, data.a3} will be merged into a cell/struct
    array data.a with 3 elements.

    A single subfield .name1 will be renamed as .name. Items with
    non-contigous numbering will not be grouped. If .name and
    .name1/.name2 co-exist in the input struct, no grouping will be done.

    The grouped subfield will appear at the position of the first
    pre-grouped item in the original input structure.

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

    input:
        root: the raw input HDF5 data structure (loaded from loadh5.m)
        type: if type is set as a cell array of strings, it restrict the
              grouping only to the subset of field names in this list;
              if type is a string as 'snirf', it is the same as setting
              type as {'aux','data','nirs','stim','measurementList'}.

    output:
        data: a reorganized matlab structure.

    example:
        a=struct('a1',rand(5),'a2','string','a3',true,'d',2+3i,'e',{'test',[],1:5});
        regrouph5(a)
        saveh5(a,'test.h5');
        rawdata=loadh5('test.h5')
        data=regrouph5(rawdata)

    this file is part of EasyH5 Toolbox: https://github.com/NeuroJSON/easyh5

    License: GPLv3 or 3-clause BSD license, see https://github.com/NeuroJSON/easyh5 for details




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

    data=regrouph5(root)
       or
    data=regrouph5(root,type)
    data=re...



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


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

 bjd=savebj(obj)
    or
 bjd=savebj(rootname,obj,filename)
 bjd=savebj(rootname,obj,opt)
 bjd=savebj(rootname,obj,'param1',value1,'param2',value2,...)

 Convert a MATLAB object  (cell, struct, array, table, map, handles ...)
 into a Binary JData (BJData v1 Draft-2), Universal Binary JSON (UBJSON,
 Draft-12) or a MessagePack binary stream

 author: Qianqian Fang (q.fang <at> neu.edu)
 initially created on 2013/08/17

 By default, this function creates BJD-compliant output. The BJD
 specification is largely similar to UBJSON, with additional data types
 including uint16(u), uint32(m), uint64(M) and half-precision float (h).
 Starting from BJD Draft-2 (JSONLab 3.0 beta or later), all integer and
 floating-point numbers are stored in Little-Endian as opposed to
 Big-Endian form as in BJD Draft-1/UBJSON Draft-12 (JSONLab 2.1 or older)

 Format specifications:
    Binary JData (BJD):   https://github.com/NeuroJSON/bjdata
    UBJSON:               https://github.com/ubjson/universal-binary-json
    MessagePack:          https://github.com/msgpack/msgpack

 input:
      rootname: the name of the root-object, when set to '', the root name
           is ignored, however, when opt.ForceRootName is set to 1 (see below),
           the MATLAB variable name will be used as the root name.
      obj: a MATLAB object (array, cell, cell array, struct, struct array,
           class instance)
      filename: a string for the file name to save the output UBJSON data
      opt: a struct for additional options, ignore to use default values.
           opt can have the following fields (first in [.|.] is the default)

           FileName [''|string]: a file name to save the output JSON data
           ArrayToStruct[0|1]: when set to 0, savebj outputs 1D/2D
                         array in JSON array format; if sets to 1, an
                         array will be shown as a struct with fields
                         "_ArrayType_", "_ArraySize_" and "_ArrayData_"; for
                         sparse arrays, the non-zero elements will be
                         saved to "_ArrayData_" field in triplet-format i.e.
                         (ix,iy,val) and "_ArrayIsSparse_":true will be added
                         with a value of 1; for a complex array, the
                         "_ArrayData_" array will include two rows
                         (4 for sparse) to record the real and imaginary
                         parts, and also "_ArrayIsComplex_":true is added.
                         Other annotations include "_ArrayShape_" and
                         "_ArrayOrder_", "_ArrayZipLevel_" etc.
          NestArray    [0|1]: If set to 1, use nested array constructs
                         to store N-dimensional arrays (compatible with
                         UBJSON specification Draft 12); if set to 0,
                         use the JData (v0.5) optimized N-D array header;
                         NestArray is automatically set to 1 when
                         MessagePack is set to 1
          ParseLogical [1|0]: if this is set to 1, logical array elem
                         will use true/false rather than 1/0.
          SingletArray [0|1]: if this is set to 1, arrays with a single
                         numerical element will be shown without a square
                         bracket, unless it is the root object; if 0, square
                         brackets are forced for any numerical arrays.
          SingletCell  [1|0]: if 1, always enclose a cell with "[]"
                         even it has only one element; if 0, brackets
                         are ignored when a cell has only 1 element.
          ForceRootName [0|1]: when set to 1 and rootname is empty, savebj
                         will use the name of the passed obj variable as the
                         root object name; if obj is an expression and
                         does not have a name, 'root' will be used; if this
                         is set to 0 and rootname is empty, the root level
                         will be merged down to the lower level.
          JSONP [''|string]: to generate a JSONP output (JSON with padding),
                         for example, if opt.JSON='foo', the JSON data is
                         wrapped inside a function call as 'foo(...);'
          UnpackHex [1|0]: convert the 0x[hex code] output by loadjson
                         back to the string form
          Compression  'zlib', 'gzip', 'lzma', 'lzip', 'lz4' or 'lz4hc': specify array
                         compression method; currently only supports 6 methods. The
                         data compression only applicable to numerical arrays
                         in 3D or higher dimensions, or when ArrayToStruct
                         is 1 for 1D or 2D arrays. If one wants to
                         compress a long string, one must convert
                         it to uint8 or int8 array first. The compressed
                         array uses three extra fields
                         "_ArrayZipType_": the opt.Compression value.
                         "_ArrayZipSize_": a 1D integer array to
                            store the pre-compressed (but post-processed)
                            array dimensions, and
                         "_ArrayZipData_": the binary stream of
                            the compressed binary array data WITHOUT
                            'base64' encoding
          CompressArraySize [100|int]: only to compress an array if the total
                         element count is larger than this number.
          CompressStringSize [inf|int]: only to compress a string if the total
                         element count is larger than this number.
          MessagePack [0|1]: output MessagePack (https://msgpack.org/)
                         binary stream instead of BJD/UBJSON
          UBJSON [0|1]: 0: (default)-encode data based on BJData Draft 1
                         (supports uint16(u)/uint32(m)/uint64(M)/half(h) markers)
                        1: encode data based on UBJSON Draft 12 (without
                         u/m/M/h markers);all numeric values are stored in
                         the Big-Endian byte order according to Draft-12
          FormatVersion [2|float]: set the JSONLab output version; since
                         v2.0, JSONLab uses JData specification Draft 3
                         for output format, it is incompatible with releases
                         older than v1.9.8; if old output is desired,
                         please set FormatVersion to 1.9 or earlier.
          KeepType [0|1]: if set to 1, use the original data type to store
                         integers instead of converting to the integer type
                         of the minimum length without losing accuracy (default)
          Debug [0|1]: output binary numbers in <%g> format for debugging
          Append [0|1]: if set to 1, append a new object at the end of the file.
          Endian ['L'|'B']: specify the endianness of the numbers
                         in the BJData/UBJSON input data. Default: 'L'.

                         Starting from JSONLab 2.9, BJData by default uses
                         [L] Little-Endian for both integers and floating
                         point numbers. This is a major departure from the
                         UBJSON specification, where 'B' - Big-Endian -
                         format is used for integer fields. UBJSON does
                         not specifically define Endianness for
                         floating-point numbers, resulting in mixed
                         implementations. JSONLab 2.0-2.1 used 'B' for
                         integers and floating-points; JSONLab 1.x uses
                         'B' for integers and native-endianness for
                         floating-point numbers.
          FileEndian ['n'|'b','l']: Endianness of the output file ('n': native,
                         'b': big endian, 'l': little-endian)
          PreEncode [1|0]: if set to 1, call jdataencode first to preprocess
                         the input data before saving

        opt can be replaced by a list of ('param',value) pairs. The param
        string is equivalent to a field in opt and is case sensitive.
 output:
      bjd: a binary string in the UBJSON format (see http://ubjson.org)

 examples:
      jsonmesh=struct('MeshVertex3',[0 0 0;1 0 0;0 1 0;1 1 0;0 0 1;1 0 1;0 1 1;1 1 1],...
               'MeshTet4',[1 2 4 8;1 3 4 8;1 2 6 8;1 5 6 8;1 5 7 8;1 3 7 8],...
               'MeshTri3',[1 2 4;1 2 6;1 3 4;1 3 7;1 5 6;1 5 7;...
                          2 8 4;2 8 6;3 8 4;3 8 7;5 8 6;5 8 7],...
               'MeshCreator','FangQ','MeshTitle','T6 Cube',...
               'SpecialData',[nan, inf, -inf]);
      savebj(jsonmesh)
      savebj('',jsonmesh,'debug',1)
      savebj('',jsonmesh,'meshdata.bjd')
      savebj('mesh1',jsonmesh,'FileName','meshdata.msgpk','MessagePack',1)
      savebj('',jsonmesh,'ubjson',1)

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 bjd=savebj(obj)
    or
 bjd=savebj(rootname,obj,filename)
 bjd=savebj(rootn...



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


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

    savejd(rootname, obj, outputfile)
       or
    buffer=savejd(obj)
    buffer=savejd(rootname, obj)
    savejd(rootname, obj, opt)
    savejd(rootname, obj, 'filename', outputfile, 'Param1',value1, 'Param2',value2,...)

    Save a complex MATLAB/Octave data structure to a hierarchical
    container data file including JSON, binary JSON
    (BJData/UBJSON/MessagePack) and HDF5

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

    input:
        rootname: the name of the root-object, when set to '', the root name
           is ignored, however, when opt.ForceRootName is set to 1 (see help savejson),
           the MATLAB variable name will be used as the root name.
        obj: a MATLAB object (array, cell, cell array, struct, struct array,
             class instance).
        outputfile: the output file name to the hierarchical container file
                *.json,.jnii,.jdt,.jmsh,.jnirs,.jbids: JSON/JData based data files, see https://neurojson.org/jdata/draft2
                *.bjd,.bnii,.jdb,.bmsh,.bnirs,.pmat: binary JData (BJData) files, see https://neurojson.org/bjdata/draft2
                *.ubj: UBJSON-encoded files, see http://ubjson.org
                *.msgpack: MessagePack-encoded files, see http://msgpack.org
                *.h5,.hdf5,.snirf: HDF5 files, see https://www.hdfgroup.org/
        opt: (optional) for JSON/JData files, these are optional 'param',value pairs
                supported by loadjson.m; for BJData/UBJSON/MessagePack files, these are
                options supported by loadbj.m; for HDF5 files, these are options
                supported by loadh5.m (part of EasyH5 toolbox, http://github.com/NeuroJSON/easyh5/)

    output:
        data: a structure (array) or cell (array) storing the hierarchical data
              in the container data file
        mmap: optional output storing the JSON/binary JSON memory-map table for fast
              disk access. see help info for loadjson or loadbj for more details.

    examples:
        obj=struct('string','value','array',[1 2 3]);
        savejd('obj', obj, 'datafile.json')
        newobj=loadjd('datafile.json');

    license:
        BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

    savejd(rootname, obj, outputfile)
       or
    buffer=savejd(obj)
    b...



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


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

 json=savejson(obj)
    or
 json=savejson(rootname,obj,filename)
 json=savejson(rootname,obj,opt)
 json=savejson(rootname,obj,'param1',value1,'param2',value2,...)

 convert a MATLAB object (cell, struct or array) into a JSON (JavaScript
 Object Notation) string

 author: Qianqian Fang (q.fang <at> neu.edu)
 initially created on 2011/09/09

 input:
      rootname: the name of the root-object, when set to '', the root name
           is ignored, however, when opt.ForceRootName is set to 1 (see below),
           the MATLAB variable name will be used as the root name.
      obj: a MATLAB object (array, cell, cell array, struct, struct array,
           class instance).
      filename: a string for the file name to save the output JSON data.
      opt: a struct for additional options, ignore to use default values.
           opt can have the following fields (first in [.|.] is the default)

           FileName [''|string]: a file name to save the output JSON data
           FloatFormat ['%.16g'|string]: format to show each numeric element
                         of a 1D/2D array;
           IntFormat ['%.0f'|string]: format to display integer elements
                         of a 1D/2D array;
           ArrayIndent [1|0]: if 1, output explicit data array with
                         precedent indentation; if 0, no indentation
           ArrayToStruct[0|1]: when set to 0, savejson outputs 1D/2D
                         array in JSON array format; if sets to 1, an
                         array will be shown as a struct with fields
                         "_ArrayType_", "_ArraySize_" and "_ArrayData_"; for
                         sparse arrays, the non-zero elements will be
                         saved to _ArrayData_ field in triplet-format i.e.
                         (ix,iy,val) and "_ArrayIsSparse_" will be added
                         with a value of 1; for a complex array, the
                         _ArrayData_ array will include two columns
                         (4 for sparse) to record the real and imaginary
                         parts, and also "_ArrayIsComplex_":1 is added.
           NestArray    [0|1]: If set to 1, use nested array constructs
                         to store N-dimensional arrays; if set to 0,
                         use the annotated array format defined in the
                         JData Specification (Draft 1 or later).
           ParseLogical [0|1]: if this is set to 1, logical array elem
                         will use true/false rather than 1/0.
           SingletArray [0|1]: if this is set to 1, arrays with a single
                         numerical element will be shown without a square
                         bracket, unless it is the root object; if 0, square
                         brackets are forced for any numerical arrays.
           SingletCell  [1|0]: if 1, always enclose a cell with "[]"
                         even it has only one element; if 0, brackets
                         are ignored when a cell has only 1 element.
           EmptyArrayAsNull  [0|1]: if set to 1, convert an empty array to
                         JSON null object; empty cells remain mapped to []
           ForceRootName [0|1]: when set to 1 and rootname is empty, savejson
                         will use the name of the passed obj variable as the
                         root object name; if obj is an expression and
                         does not have a name, 'root' will be used; if this
                         is set to 0 and rootname is empty, the root level
                         will be merged down to the lower level.
           Inf ['"$1_Inf_"'|string]: a customized regular expression pattern
                         to represent +/-Inf. The matched pattern is '([-+]*)Inf'
                         and $1 represents the sign. For those who want to use
                         1e999 to represent Inf, they can set opt.Inf to '$11e999'
           NaN ['"_NaN_"'|string]: a customized regular expression pattern
                         to represent NaN
           JSONP [''|string]: to generate a JSONP output (JSON with padding),
                         for example, if opt.JSONP='foo', the JSON data is
                         wrapped inside a function call as 'foo(...);'
           UnpackHex [1|0]: convert the 0x[hex code] output by loadjson
                         back to the string form
           SaveBinary [1|0]: 1 - save the JSON file in binary mode; 0 - text mode.
           Compact [0|1]: 1- out compact JSON format (remove all newlines and tabs)
           Compression  'zlib', 'gzip', 'lzma', 'lzip', 'lz4' or 'lz4hc': specify array
                         compression method; currently only supports 6 methods. The
                         data compression only applicable to numerical arrays
                         in 3D or higher dimensions, or when ArrayToStruct
                         is 1 for 1D or 2D arrays. If one wants to
                         compress a long string, one must convert
                         it to uint8 or int8 array first. The compressed
                         array uses three extra fields
                         "_ArrayZipType_": the opt.Compression value.
                         "_ArrayZipSize_": a 1D integer array to
                            store the pre-compressed (but post-processed)
                            array dimensions, and
                         "_ArrayZipData_": the "base64" encoded
                             compressed binary array data.
           CompressArraySize [100|int]: only to compress an array if the total
                         element count is larger than this number.
           CompressStringSize [inf|int]: only to compress a string if the total
                         element count is larger than this number.
           FormatVersion [3|float]: set the JSONLab output version; since
                         v2.0, JSONLab uses JData specification Draft 1
                         for output format, it is incompatible with all
                         previous releases; if old output is desired,
                         please set FormatVersion to 1.9 or earlier.
           Encoding ['']: json file encoding. Support all encodings of
                         fopen() function
           Append [0|1]: if set to 1, append a new object at the end of the file.
           Endian ['n'|'b','l']: Endianness of the output file ('n': native,
                         'b': big endian, 'l': little-endian)
           PreEncode [1|0]: if set to 1, call jdataencode first to preprocess
                         the input data before saving
           BuiltinJSON [0|1]: if set to 1, this function attempts to call
                         jsonencode, if presents (MATLAB R2016b or Octave
                         6) first. If jsonencode does not exist or failed,
                         this function falls back to the jsonlab savejson

        opt can be replaced by a list of ('param',value) pairs. The param
        string is equivalent to a field in opt and is case sensitive.
 output:
      json: a string in the JSON format (see http://json.org)

 examples:
      jsonmesh=struct('MeshNode',[0 0 0;1 0 0;0 1 0;1 1 0;0 0 1;1 0 1;0 1 1;1 1 1],...
               'MeshElem',[1 2 4 8;1 3 4 8;1 2 6 8;1 5 6 8;1 5 7 8;1 3 7 8],...
               'MeshSurf',[1 2 4;1 2 6;1 3 4;1 3 7;1 5 6;1 5 7;...
                          2 8 4;2 8 6;3 8 4;3 8 7;5 8 6;5 8 7],...
               'MeshCreator','FangQ','MeshTitle','T6 Cube',...
               'SpecialData',[nan, inf, -inf]);
      savejson('jmesh',jsonmesh)
      savejson('',jsonmesh,'ArrayIndent',0,'FloatFormat','\t%.5g')

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 json=savejson(obj)
    or
 json=savejson(rootname,obj,filename)
 json=savej...



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


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

 msgpk=savemsgpack(obj)
    or
 msgpk=savemsgpack(rootname,obj,filename)
 msgpk=savemsgpack(rootname,obj,opt)
 msgpk=savemsgpack(rootname,obj,'param1',value1,'param2',value2,...)

 convert a MATLAB object (cell, struct, array, table, map, handles ...)
 into a MessagePack binary stream

 author: Qianqian Fang (q.fang <at> neu.edu)
 initially created on 2019/05/20

 This function is the same as calling savebj(...,'MessagePack',1)

 Please type "help savebj" for details for the supported inputs and outputs.

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 msgpk=savemsgpack(obj)
    or
 msgpk=savemsgpack(rootname,obj,filename)
 ms...



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


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

 ubj=saveubjson(obj)
    or
 ubj=saveubjson(rootname,obj,filename)
 ubj=saveubjson(rootname,obj,opt)
 ubj=saveubjson(rootname,obj,'param1',value1,'param2',value2,...)

 Convert a MATLAB object  (cell, struct, array, table, map, graphs ...)
 into a Universal Binary JSON (UBJSON, Draft-12) or a MessagePack binary stream

 author: Qianqian Fang (q.fang <at> neu.edu)
 initially created on 2013/08/17

 Format specifications:
    Binary JData (BJData):https://github.com/NeuroJSON/bjdata
    UBJSON:               https://github.com/ubjson/universal-binary-json
    MessagePack:          https://github.com/msgpack/msgpack

 This function is the same as calling "savebj(..,'ubjson',1,'endian','B')"
 By default this function creates UBJSON-compliant output without the
 newly added uint16(u), uint32(m), uint64(M) and half-precision float (h)
 data types and use Big-Endian for all numerical values as in UBJSON
 Draft-12.

 This function by default still enables an optimized ND-array format for efficient
 array storage. To ensure the output compatible to UBJSON Draft-12, one should use
 "saveubjson(...,'NestArray',1)" or "savebj(...,'ubjson',1,'NestArray',1)"

 input:
      rootname: the name of the root-object, when set to '', the root name
           is ignored, however, when opt.ForceRootName is set to 1 (see below),
           the MATLAB variable name will be used as the root name.
      obj: a MATLAB object (array, cell, cell array, struct, struct array,
           class instance)
      filename: a string for the file name to save the output UBJSON data
      opt: a struct for additional options, ignore to use default values.
           opt can have the following fields (first in [.|.] is the default)

           opt can be replaced by a list of ('param',value) pairs. The param
           string is equivalent to a field in opt and is case sensitive.

           Please type "help savebj" for details for all supported options.

 output:
      ubj: a binary string in the UBJSON format (see http://ubjson.org)

 examples:
      jsonmesh=struct('MeshVertex3',[0 0 0;1 0 0;0 1 0;1 1 0;0 0 1;1 0 1;0 1 1;1 1 1],...
               'MeshTet4',[1 2 4 8;1 3 4 8;1 2 6 8;1 5 6 8;1 5 7 8;1 3 7 8],...
               'MeshTri3',[1 2 4;1 2 6;1 3 4;1 3 7;1 5 6;1 5 7;...
                          2 8 4;2 8 6;3 8 4;3 8 7;5 8 6;5 8 7],...
               'MeshCreator','FangQ','MeshTitle','T6 Cube',...
               'SpecialData',[nan, inf, -inf]);
      saveubjson(jsonmesh)
      saveubjson('',jsonmesh,'meshdata.ubj')
      saveubjson('mesh1',jsonmesh,'FileName','meshdata.msgpk','MessagePack',1)
      saveubjson('',jsonmesh,'KeepType',1)

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 ubj=saveubjson(obj)
    or
 ubj=saveubjson(rootname,obj,filename)
 ubj=save...



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


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

    data=transposemat(input)

    Iterate over struct/cell and transpose 2D or higher-dimensional numerical
    array to match Octave loaded HDF5 array elements with loadh5 default setting

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

    input:
        name: a matlab variable, can be a cell, struct, containers.Map, numeric array or strings

    output:
        newname: the restored original string

    example:
        a=struct('a', ones(2,3), 'b', 'a string', 'c', uint8(zeros(2,3,4)));
        b=transposemat(a)

    this file is part of EasyH5 Toolbox: https://github.com/NeuroJSON/easyh5

    License: GPLv3 or 3-clause BSD license, see https://github.com/NeuroJSON/easyh5 for details




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

    data=transposemat(input)



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


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

 opt=varargin2struct('param1',value1,'param2',value2,...)
   or
 opt=varargin2struct(...,optstruct,...)

 convert a series of input parameters into a structure

 authors:Qianqian Fang (q.fang <at> neu.edu)
 date: 2012/12/22

 input:
      'param', value: the input parameters should be pairs of a string and a value
       optstruct: if a parameter is a struct, the fields will be merged to the output struct

 output:
      opt: a struct where opt.param1=value1, opt.param2=value2 ...

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 opt=varargin2struct('param1',value1,'param2',value2,...)
   or
 opt=varargi...



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


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

 output = zlibdecode(input)
    or
 output = zlibdecode(input,info)

 Decompressing a ZLIB-compressed byte-stream to recover the original data
 This function depends on JVM in MATLAB or, can optionally use the ZMat
 toolbox (http://github.com/NeuroJSON/zmat)

 Copyright (c) 2012, Kota Yamaguchi
 URL: https://www.mathworks.com/matlabcentral/fileexchange/39526-byte-encoding-utilities

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

 input:
      input: a string, int8/uint8 vector or numerical array to store ZLIB-compressed data
      info (optional): a struct produced by the zmat/lz4hcencode function during
            compression; if not given, the inputs/outputs will be treated as a
            1-D vector

 output:
      output: the decompressed byte stream stored in a uint8 vector; if info is
            given, output will restore the original data's type and dimensions

 examples:
      [bytes, info]=zlibencode(eye(10));
      orig=zlibdecode(bytes,info);

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 output = zlibdecode(input)
    or
 output = zlibdecode(input,info)



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


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

 output = zlibencode(input)
    or
 [output, info] = zlibencode(input)

 Compress a string or numerical array using the ZLIB-compression

 This function depends on JVM in MATLAB or, can optionally use the ZMat
 toolbox (http://github.com/NeuroJSON/zmat)

 Copyright (c) 2012, Kota Yamaguchi
 URL: https://www.mathworks.com/matlabcentral/fileexchange/39526-byte-encoding-utilities

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

 input:
      input: the original data, can be a string, a numerical vector or array

 output:
      output: the decompressed byte stream stored in a uint8 vector; if info is
            given, output will restore the original data's type and dimensions

 examples:
      [bytes, info]=zlibencode(eye(10));
      orig=zlibdecode(bytes,info);

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 output = zlibencode(input)
    or
 [output, info] = zlibencode(input)



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


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

 output = zstddecode(input)
    or
 output = zstddecode(input,info)

 Decompressing an Zstd-compressed byte-stream to recover the original data
 This function depends on the ZMat toolbox (http://github.com/NeuroJSON/zmat)

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

 input:
      input: a string, int8/uint8 vector or numerical array to store Zstd-compressed data
      info (optional): a struct produced by the zmat/zstdencode function during
            compression; if not given, the inputs/outputs will be treated as a
            1-D vector

 output:
      output: the decompressed byte stream stored in a uint8 vector; if info is
            given, output will restore the original data's type and dimensions

 examples:
      [bytes, info]=zstdencode(eye(10));
      orig=zstddecode(bytes,info);

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 output = zstddecode(input)
    or
 output = zstddecode(input,info)



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


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

 output = zstddecode(input)
    or
 output = zstddecode(input,info)

 Decompressing an Zstd-compressed byte-stream to recover the original data
 This function depends on the ZMat toolbox (http://github.com/NeuroJSON/zmat)

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

 input:
      input: a string, int8/uint8 vector or numerical array to store Zstd-compressed data
      info (optional): a struct produced by the zmat/zstdencode function during
            compression; if not given, the inputs/outputs will be treated as a
            1-D vector

 output:
      output: the decompressed byte stream stored in a uint8 vector; if info is
            given, output will restore the original data's type and dimensions

 examples:
      [bytes, info]=zstdencode(eye(10));
      orig=zstddecode(bytes,info);

 license:
     BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details

 -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)




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

 output = zstddecode(input)
    or
 output = zstddecode(input,info)





