# doc-cache created by Octave 10.3.0
# name: cache
# type: cell
# rows: 3
# columns: 27
# name: <cell-element>
# type: sq_string
# elements: 1
# length: 11
cwdiffusion


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

  [Phi r] = cwdiffusion(mua, musp, Reff, srcpos,detpos)

  semi-infinite medium analytical solution to diffusion model

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

    input:
        mua:   the absorption coefficients in 1/mm
        musp:  the reduced scattering coefficients in 1/mm
        Reff:  the effective reflection coeff.
        srcpos:array for the source positions (x,y,z)
        detpos:array for the detector positions (x,y,z)

    output:
        Phi:  the output fluence for all source/detector pairs
        r: (optional) source detector separations

    this file is part of Monte Carlo eXtreme (MCX)
    License: GPLv3, see http://mcx.sf.net for details
    see Boas2002, Haskell1994




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

  [Phi r] = cwdiffusion(mua, musp, Reff, srcpos,detpos)



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


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 588
  separation=getdistance(srcpos,detpos)

  compute the source/detector separation from the positions

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

    input:
        srcpos:array for the source positions (x,y,z)
        detpos:array for the detector positions (x,y,z)

    output:
        separation:  the distance matrix between all combinations
              of sources and detectors. separation has the number
              of source rows, and number of detector of columns.

    this file is part of Monte Carlo eXtreme (MCX)
    License: GPLv3, see http://mcx.sf.net for details



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 39
  separation=getdistance(srcpos,detpos)



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


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2207
 HOBBYSPLINES Draws open or closed smooth curves from keypoints

 Q = hobbysplines({[x1 y1], [x2 y2],... ,[xN yN]},[opts]);
 Q = hobbysplines({[x1 y1 z1], [x2 y2 z2],... ,[xN yN zN]},[opts]);

 Draws an open or cyclic curve through keypoints 1 to N.
 Points are output as matrix "Q".
 Keypoints may be specified with optional slopes and tension parameters.
 The syntax to do this (replacing `[x1 y1]` above, say) is

 2D:
    { [x1 y1] s1 t1 }
    { [x1 y1] s1 t1_in t1_out }
    { [x1 y1] [u1 v1] ... }

 3D:
    { [x1 y1 z1] [u1 v1 w1] t1 }
    { [x1 y1 z1] [u1 v1 w1] t1_in t1_out }

 where `s1` is the slope in degrees of the curve through `[x1 y1]`,
 `[u1 v1 w1]` is the unit vector describing the slope of the curve,
 and `t1_out` & `t1_in` are the "exit" and "entry" tensions of the curve
 approaching that point. If `t1` only is specified, this is both the
 entry and the exit tension.

 Use '' to indicate default values here; for example, for a default slope
 but specified "entry" tension of 2.0, use

    { [x1 y1] '' 2.0 ''}

 and note that trailing optional arguments can also be omitted.
 According to Hobby, tensions should not be specified less than 0.75.
 This software does not enforce this restriction.
 Note that a tension of 1 creates approximately circular plots.

 Optional arguments given by [opts] can be any combination of the
 following:

   OPTION       DEFAULT            DESCRIPTION
   ------       -------            -----------
   'tension'    [1]                default tension between points
   'offset'     [0 0 0]            offset to add to each control point
   'cycle'      true               whether to draw a cyclic curve
   'debug'      false              draw and label keypoints on the curve
   'linestyle'  {'linewidth',1}    line style option(s)
   'color'      'black'            colour of the curve
   'bezierpoints' 50               number of points in each bezier segment
   'plot'       true               whether to actually draw anything

 Distributed under the terms and conditions of the 2-clause BSD license:
 <http://opensource.org/licenses/bsd-license.php>

 Copyright 2013, 2015 Will Robertson and The University of Adelaide
 All rights reserved.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 63
 HOBBYSPLINES Draws open or closed smooth curves from keypoints



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


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 3649
 Display a 2-D image in Matlab xyz 3-D space
 h = image3i(C, IJ2XYZ, handle)

 C is an image, encoded with scalars or rgb-values, i.e. the dimensions of
 C are either N x M or N x M x 3. Scalars correspond to indices in the
 current colormap and rgb-values should be within the closed
 interval [0,1]. Similar to the image command, image3i will treat scalars
 differently depending on if they are doubles or uint8/uint16. Doubles are
 indexed starting at 1 and uint8/uint16 start at 0. By setting the
 property CDataMapping for h, different behaviours can be obtained, e.g.
 usage of the whole range of the colormap by setting it to 'scaled'.

 The image is indexed by two positive integers, i and j, which correspond
 to the first and second index of C. Thus i belongs to [1,N] and j belongs
 to [1,M]. Each coordinate correspond to a pixel center.

 IJ2XYZ is a transformation matrix from image coordinates to 3-D world
 coordinates. The transformation is described in homogeneous coordinates,
 i.e. we have added one dimension to each coordinate that is always 1.

 If u = [i,j,1]' and r = [x,y,z,1]', the transformation is

     r = IJ2XYZ * u

 Thus IJ2XYZ = [ix jx cx;iy jy cy; iz jz cz; 0 0 1], where cx,cy and cz
 encode the translation of the image. The ones and zeroes ensure that
 the result of the transformation is also a homogeneous coordinate. Yes,
 you can skip that last row of IJ2XYZ and image3i will not care about
 it. :-)

 The function returns a handle, h, which is a handle to a surf object. Use
 this handle to e.g. modify the image, make it transparent or delete it.
 The handle can also be used as an optional argument to the image3i
 command. In this case, the the image patch is recycled, which is an
 efficient way of e.g. changing the image data or move the image to
 another location.

 Image3 can mimic Matlabs ordinary image command, e.g.
     prel = image; C = get(prel,'CData'); delete(prel);
     colormap(jet(64));
     image(C);
     view(0,90);
     axis ij;
     axis image;
 is equivalent to:
     prel = image; C = get(prel,'CData'); delete(prel);
     colormap(jet(64));
     image3i(C,[0 1 0;1 0 0; 0 0 0]);
     view(0,90);
     axis ij;
     axis image;
 In the above example it _is_ important to hardcode the axis settings
 to compare image and image3i, otherwise Matlabs does some magic that make
 them look different.

 Some examples of use:

 %% Display an image with (1,1) located at (10,20,5).
 C = rand(8,4)*64;                              % a small random image
 R = [1 0; 0 1; 0 0];
 t = [10-1;20-1;5];
 h = image3i(C,[R t]); axis equal
 view(30,45);


 %% Reuse the image h from the previous example, move (1,1) to (7,17,2).
 %% This technique is useful in interactive applications.
 h = image3i(C,[R t-3],h); axis equal


 %% Display an image centered at (15,10,0), rotated 30 degrees ccw in the
 %% image plane.
 C = rand(8,4)*64;                              % a small random image
 alpha = 30;                                    % rotation, in ccw degrees
 cx = 15; cy = 10; cz = 0;                      % the center position
 R = [+cos(alpha/180*pi) -sin(alpha/180*pi);    % new x coordinate
      +sin(alpha/180*pi) +cos(alpha/180*pi);    % new y coordinate
      0 0];                                     % z = 0.
 t = [cx;cy;cz] - R * [size(C,1)/2+0.5; size(C,2)/2+0.5]; % fix center
 h = image3i(C,[R t]); axis equal

 To see and manipulate the properties of the image object, use get and set

 get(h)
 set(h,'FaceAlpha',0.25) % Make the image transparent
 set(h,'EdgeColor','black');
 set(h,'LineStyle','-');

 SEE ALSO: imagesc3, surf

 Author: Anders Brun, anders@cb.uu.se (2008)



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 76
 Display a 2-D image in Matlab xyz 3-D space
 h = image3i(C, IJ2XYZ, handle)



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


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

    h = islicer(vol);
       or
    h = islicer(vol,T);

    author: Anders Brun, anders@cb.uu.se (2009)
    url: https://www.mathworks.com/matlabcentral/fileexchange/25923-myslicer-make-mouse-interactive-slices-of-a-3-d-volume
    original version: v1.1 (accessed on 07/25/2017)

    input:
        vol:  the 3-D or 4-D data being loaded
        T: a 4x4 transformation matrix; if missing, T is a 4x4 identity
           matrix

    output:
        h: the handles to the 3 surfaces plotted along the x/y/z
           planes

    this file is part of Monte Carlo eXtreme (MCX)
    License: GPLv3, see http://mcx.sf.net for details




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

    h = islicer(vol);
       or
    h = islicer(vol,T);



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


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

 Format:
    cfg=json2mcx(filename)

 Convert a JSON file for MCX binary to an MCXLAB configuration structure

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

 Input:
    filename: the JSON input file

 Output:
    cfg: a struct defining the parameters associated with a simulation.
         Please run 'help mcxlab' or 'help mmclab' to see details.

 Dependency:
    this function depends on the savejson/loadjson functions from the
    Iso2Mesh toolbox (http://iso2mesh.sf.net) or JSONlab toolbox
    (http://iso2mesh.sf.net/jsonlab)

 This function is part of Monte Carlo eXtreme (MCX) URL: http://mcx.space

 License: GNU General Public License version 3, please read LICENSE.txt for details




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

 Format:
    cfg=json2mcx(filename)



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


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

    data=loadmc2(fname,dim,format)
       or
    [data dref]=loadmc2(fname,dim,format)

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

    input:
        fname: the file name to the output .mc2 file
        dim:   an array to specify the output data dimension
               normally, dim=[nx,ny,nz,nt]
        format:a string to indicate the format used to save
               the .mc2 file; if omitted, it is set to 'float'

    output:
        data:  the output MCX solution data array, in the
               same dimension specified by dim
        dref(optional): diffuse reflectance at the surface of the domain.
               if this output is not given while diffuse reflectance
               is recorded, dref is shown as the negative values in
               the data output.

    this file is part of Monte Carlo eXtreme (MCX)
    License: GPLv3, see http://mcx.sf.net for details




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

    data=loadmc2(fname,dim,format)
       or
    [data dref]=loadmc2(fname,d...



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


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

    [data, header]=loadmch(fname,format,endian)

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

    input:
        fname: the file name to the output .mch file
        format:a string to indicate the format used to save
               the .mch file; if omitted, it is set to 'float'
        endian: optional, specifying the endianness of the binary file
               can be either 'ieee-be' or 'ieee-le' (default)

    output:
        data:   the output detected photon data array
                data has at least M*2+2 columns (M=header.medium), the first column is the
                ID of the detector; columns 2 to M+1 store the number of
                scattering events for every tissue region; the following M
                columns are the partial path lengths (in mm) for each medium type;
                the last column is the initial weight at launch time of each detecetd
                photon; when the momentum transfer is recorded, M columns of
                momentum tranfer for each medium is inserted after the partial path;
                when the exit photon position/dir are recorded, 6 additional columns
                are inserted before the last column, first 3 columns represent the
                exiting position (x/y/z); the next 3 columns are the dir vector (vx/vy/vz).
                in other words, data is stored in the follow format
                    [detid(1) nscat(M) ppath(M) mom(M) p(3) v(3) w0(1)]
        header: file header info, a structure has the following fields
                [version,medianum,detnum,recordnum,totalphoton,detectedphoton,
                 savedphoton,lengthunit,seedbyte,normalizer,respin,srcnum,savedetflag]
        photonseed: (optional) if the mch file contains a seed section, this
                returns the seed data for each detected photon. Each row of
                photonseed is a byte array, which can be used to initialize a
                seeded simulation. Note that the seed is RNG specific. You must use
                the an identical RNG to utilize these seeds for a new simulation.

    this file is part of Monte Carlo eXtreme (MCX)
    License: GPLv3, see http://mcx.sf.net for details




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

    [data, header]=loadmch(fname,format,endian)



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


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

 Format:
    mcx2json(cfg,filestub)

 Save MCXLAB simulation configuration to a JSON file for MCX binary

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

 Input:
    cfg: a struct defining the parameters associated with a simulation.
         Please run 'help mcxlab' or 'help mmclab' to see the details.
         mcxpreview supports the cfg input for both mcxlab and mmclab.
    filestub: the filestub is the name stub for all output files,including
         filestub.json: the JSON input file
         filestub_vol.bin: the volume file if cfg.vol is defined
         filestub_shapes.json: the domain shape file if cfg.shapes is defined
         filestub_pattern.bin: the domain shape file if cfg.pattern is defined

 Dependency:
    this function depends on the savejson/saveubjson functions from the
    Iso2Mesh toolbox (http://iso2mesh.sf.net) or JSONlab toolbox
    (http://iso2mesh.sf.net/jsonlab)

 This function is part of Monte Carlo eXtreme (MCX) URL: http://mcx.space

 License: GNU General Public License version 3, please read LICENSE.txt for details




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

 Format:
    mcx2json(cfg,filestub)



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


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

   [tau,g1]=mcxdcsg1(detps,tau, disp_model, DV, lambda, format)

   Compute simulated electric-field auto-correlation function using
   simulated photon pathlengths and scattering momentum transfer

   author: Stefan Carp (carp <at> nmr.mgh.harvard.edu)

   input:
       detps:      the file name of the output .mch file or the 2nd output from mcxlab
       tau:        correlation times at which to compute g1
                   (default: 1e-7 to 1e-1 seconds, log equidistant)
       disp_model: displacement model ('brownian', 'random_flow', <custom>)
                   (default: brownian, see further explanation below)
       disp_var:   value of displacement variable using mm as unit of
                   length and s as unit of time
                   (default: 1e-7 mm^2/s, see further explanation below)
       lambda:     wavelenght of light used in nm
                   (default: 785)
       format:     the format used to save the .mch file
                   (default: 'float')

   output:

       tau:        correlation times at which g1 was computed provided for
                   convenience (copied from input if set, otherwise
                   outputs default)
       g1:         field auto-correlation curves, one for each detector

   The displacement model indicates the formula used to compute the root
   mean square displacement of scattering particles during a given delay

   brownian:       RMS= 6 * DV * tau;
                   DV(displacement variable)=Db (brownian diffusion coeff)
   random_flow:    RMS= DV^2 * tau^2;
                   DV = V (first moment of velocity distribution)
   <custom>:       any string other than 'brownian' or 'random_flow' will
                   be evaluate as is using Matlab evalf, make sure it uses
                   'DV' as the flow related independent variable, tau is
                   indexed as tau(J). Any additional parameters can be
                   sent via "varargin"

   This file is part of Mesh-Based Monte Carlo
   License: GPLv3, see http://mcx.space for details




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

   [tau,g1]=mcxdcsg1(detps,tau, disp_model, DV, lambda, format)



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


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 94
undocumented function: newdetp = mcxdetphoton (detp, medianum, savedetflag, issaveref, srcnum)


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
undocumented function: newdetp = mcxdetphoton (detp, medianum, savedetflag, i...



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


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

 dett=mcxdetweight(detp,prop)

 Recalculate the detected photon time using partial path data and
 optical properties (for perturbation Monte Carlo or detector readings)

 author: Qianqian Fang (q.fang <at> neu.edu)
     Ruoyang Yao (yaor <at> rpi.edu)

 input:
     detp: the 2nd output from mcxlab. detp must be a struct
     prop: optical property list, as defined in the cfg.prop field of mcxlab's input

 output:
     dett: re-caculated detected photon time based on the partial path data and optical property table

 this file is copied from Mesh-based Monte Carlo (MMC)

 License: GPLv3, see http://mcx.space/ for details




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

 dett=mcxdetweight(detp,prop)



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


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

 tpsf=mcxdettpsf(detp,detnum,prop,time)

 Calculate the temporal point spread function curve of a specified detector
 given the partial path data, optical properties, and distribution of time bins

 author: Qianqian Fang (q.fang <at> neu.edu)
     Ruoyang Yao (yaor <at> rpi.edu)

 input:
     detp: the 2nd output from mcxlab. detp must be a struct with detid and ppath subfields
     detnum: specified detector number
     prop: optical property list, as defined in the cfg.prop field of mcxlab's input
     time: distribution of time bins, a 1*3 vector [tstart tend tstep]
           could be defined different from in the cfg of mcxlab's input
 output:
     tpsf: caculated temporal point spread function curve of the specified detector

 this file is copied from Mesh-based Monte Carlo (MMC)

 License: GPLv3, see http://mcx.space/ for details




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

 tpsf=mcxdettpsf(detp,detnum,prop,time)



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


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

 detw=mcxdetweight(detp,prop)

 Recalculate the detected photon weight using partial path data and
 optical properties (for perturbation Monte Carlo or detector readings)

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

 input:
     detp: the 2nd output from mcxlab. detp must a struct
     prop: optical property list, as defined in the cfg.prop field of mcxlab's input

 output:
     detw: re-caculated detected photon weight based on the partial path data and optical property table

 this file is copied from Mesh-based Monte Carlo (MMC)

 License: GPLv3, see http://mcx.space/ for details




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

 detw=mcxdetweight(detp,prop)



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


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

 output=mcxfluence2energy(flux,cfg)
    or
 output=mcxfluence2energy(flux,vol,prop,tstep)

 Calculate energy deposition (1/mm^3) use fluence rate (1/mm^2/s) or vice versa

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

 input:
     flux: the 1st output from mcxlab. flux can be either a struct or an array (flux.data)
     cfg:  the input used in mcxlab
        or, you can use
     vol:  if cfg is not given, user must provide the volume, i.e. cfg.vol, and
     prop: the property list, i.e. cfg.prop, as well as
     tstep: the time-step of the
 output:
     output: if cfg.output is 'flux', the output is the energy deposition (1/mm^3)
             if cfg.output is 'energy', the output is the fluence rate (1/mm^2)

 this file is part of Monte Carlo eXtreme (MCX)

 License: GPLv3, see http://mcx.space/ for details




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

 output=mcxfluence2energy(flux,cfg)
    or
 output=mcxfluence2energy(flux,vo...



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


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

 ====================================================================
      MCXLAB-CL - Monte Carlo eXtreme (MCX) for MATLAB/GNU Octave
 --------------------------------------------------------------------
       Copyright (c) 2018-2023 Qianqian Fang <q.fang at neu.edu>
                      URL: http://mcx.space
 ====================================================================

 Format:
    fluence=mcxlabcl(cfg);
       or
    [fluence,detphoton,vol,seed,trajectory]=mcxlabcl(cfg);
    [fluence,detphoton,vol,seed,trajectory]=mcxlabcl(cfg, option);

 Input:
    cfg: a struct, or struct array. Each element of cfg defines
         the parameters associated with a simulation.
         if cfg='gpuinfo': return the supported GPUs and their parameters,
         if cfg='version': return the version of MCXLABCL as a string,
         see sample script at the bottom
    option: (optional), options is a string, specifying additional options
         option='preview': this plots the domain configuration using mcxpreview(cfg)
         option='opencl':  force using mcxcl.mex* instead of mcx.mex* on NVIDIA/AMD/Intel hardware
         option='cuda':    force using mcx.mex* instead of mcxcl.mex* on NVIDIA GPUs

    if one defines USE_MCXCL=1 in MATLAB command line window, all following
    mcxlab and mcxlabcl calls will use mcxcl.mex; by setting option='cuda', one can
    force both mcxlab and mcxlabcl to use mcx (cuda version). Similarly, if
    USE_MCXCL=0, all mcxlabcl and mcxlab call will use mcx.mex by default, unless
    one set option='opencl'.

    cfg may contain the following fields:

 == Required ==
     *cfg.nphoton:    the total number of photons to be simulated (integer)
                      maximum supported value is 2^63-1
     *cfg.vol:        a 3D array specifying the media index in the domain.
                      can be uint8, uint16, uint32, single or double
                      arrays.
                      2D simulations are supported if cfg.vol has a singleton
                      dimension (in x or y); srcpos/srcdir must belong to
                      the 2D plane in such case.
                      for 2D simulations, Example: <demo_mcxlab_2d.m>

                      MCXLAB also accepts 4D arrays to define continuously varying media.
                      The following formats are accepted
                        1 x Nx x Ny x Nz float32 array: mua values for each voxel (must use permute to make 1st dimension singleton)
                        2 x Nx x Ny x Nz float32 array: mua/mus values for each voxel (g/n use prop(2,:))
                        4 x Nx x Ny x Nz uint8 array: mua/mus/g/n gray-scale (0-255) interpolating between prop(2,:) and prop(3,:)
                        2 x Nx x Ny x Nz uint16 array: mua/mus gray-scale (0-65535) interpolating between prop(2,:) and prop(3,:)
                        Example: <demo_continuous_mua_mus.m>. If voxel-based media are used, partial-path/momentum outputs are disabled
     *cfg.prop:       an N by 4 array, each row specifies [mua, mus, g, n] in order.
                      the first row corresponds to medium type 0
                      (background) which is typically [0 0 1 1]. The
                      second row is type 1, and so on. The background
                      medium (type 0) has special meanings: a photon
                      terminates when moving from a non-zero to zero voxel.
     *cfg.tstart:     starting time of the simulation (in seconds)
     *cfg.tstep:      time-gate width of the simulation (in seconds)
     *cfg.tend:       ending time of the simulation (in second)
     *cfg.srcpos:     a 1 by 3 vector, the position of the source in grid unit
     *cfg.srcdir:     a 1 by 3 vector, specifying the incident vector; if srcdir
                      contains a 4th element, it specifies the focal length of
                      the source (only valid for focuable src, such as planar, disk,
                      fourier, gaussian, pattern, slit, etc); if the focal length
                      is nan, all photons will be launched isotropically regardless
                      of the srcdir direction.

 == MC simulation settings ==
      cfg.seed:       seed for the random number generator (integer) [0]
                      if set to a uint8 array, the binary data in each column is used
                      to seed a photon (i.e. the "replay" mode)
                      Example: <demo_mcxlab_replay.m>
      cfg.respin:     repeat simulation for the given time (integer) [1]
                      if negative, divide the total photon number into respin subsets
      cfg.isreflect:  [1]-consider refractive index mismatch, 0-matched index
      cfg.bc          per-face boundary condition (BC), a strig of 6 letters (case insensitive) for
                      bounding box faces at -x,-y,-z,+x,+y,+z axes;
                      overwrite cfg.isreflect if given.
                      each letter can be one of the following:
                      '_': undefined, fallback to cfg.isreflect
                      'r': like cfg.isreflect=1, Fresnel reflection BC
                      'a': like cfg.isreflect=0, total absorption BC
                      'm': mirror or total reflection BC
                      'c': cyclic BC, enter from opposite face

                      in addition, cfg.bc can contain up to 12 characters,
                      with the 7-12 characters indicating bounding box
                      facets -x,-y,-z,+x,+y,+z are used as a detector. The
                      acceptable characters for digits 7-12 include
                      '0': this face is not used to detector photons
                      '1': this face is used to capture photons (if output detphoton)
                      see <demo_bc_det.m>
      cfg.isnormalized:[1]-normalize the output fluence to unitary source, 0-no reflection
      cfg.isspecular: 1-calculate specular reflection if source is outside, [0] no specular reflection
      cfg.maxgate:    the num of time-gates per simulation
      cfg.minenergy:  terminate photon when weight less than this level (float) [0.0]
      cfg.unitinmm:   defines the length unit for a grid edge length [1.0]
                      Example: <demo_sphere_cube_subpixel.m>
      cfg.shapes:     a JSON string for additional shapes in the grid
                      Example: <demo_mcxyz_skinvessel.m>
      cfg.invcdf:     user-specified scattering phase function. To use this, one must define
                      a vector with monotonically increasing value between -1 and 1
                      defining the discretized inverse function of the cummulative density function (CDF)
                      of u=cos(theta), i.e. inv(CDF(u))=inv(CDF(cos(theta))), where theta [0-pi] is the
                      zenith angle of the scattering event, and u=cos(theta) is between -1 and 1.
                      Please note that the defined inv(CDF) is relative to u, not to theta. This is because
                      it is relatively easy to compute as P(u) is the primary form of phase function
                      see <demo_mcxlab_phasefun.m>
      cfg.angleinvcdf: user-specified launch angle distribution. To use this, one must define
                      a vector with monotonically increasing value between 0 and 1
                      defining the discretized inverse function of the
                      cummulative density function (CDF) of (theta/pi),
                      i.e. inv(CDF(theta/pi)), where theta in the range of
                      [0-pi] is the zenith angle of the launch angle relative to cfg.srcdir.

                      when source focal-length, cfg.srcdir(4), is set to 0
                      (default), the angleinvcdf is randomly sampled with
                      linear interpolation, i.e. every sample uses two
                      elements to interpolate the desired launch angle;
                      this is suited when the distribution is continuous.

                      when cfg.srcdir(4) is set to 1, the angleinvcdf
                      vector is randomly sampled without interpolation
                      (i.e. only return the theta/pi values specified
                      inside this array); this is best suited for discrete
                      angular distribution.
                      see <demo_mcxlab_launchangle.m>
      cfg.gscatter:   after a photon completes the specified number of
                      scattering events, mcx then ignores anisotropy g
                      and only performs isotropic scattering for speed [1e9]
      cfg.detphotons: detected photon data for replay. In the replay mode (cfg.seed
                      is set as the 4th output of the baseline simulation), cfg.detphotons
                      should be set to the 2nd output (detphoton) of the baseline simulation
                      or detphoton.data subfield (as a 2D array). cfg.detphotons can use
                      a subset of the detected photon selected by the user.
                      Example: <demo_mcxlab_replay.m>

 == GPU settings ==
      cfg.autopilot:  1-automatically set threads and blocks, [0]-use nthread/nblocksize
      cfg.nblocksize: how many CUDA thread blocks to be used [64]
      cfg.nthread:    the total CUDA thread number [2048]
      cfg.gpuid:      which GPU to use (run 'mcx -L' to list all GPUs) [1]
                      if set to an integer, gpuid specifies the index (starts at 1)
                      of the GPU for the simulation; if set to a binary string made
                      of 1s and 0s, it enables multiple GPUs. For example, '1101'
                      allows to use the 1st, 2nd and 4th GPUs together.
                      Example: <mcx_gpu_benchmarks.m>
      cfg.workload    an array denoting the relative loads of each selected GPU.
                      for example, [50,20,30] allocates 50%, 20% and 30% photons to the
                      3 selected GPUs, respectively; [10,10] evenly divides the load
                      between 2 active GPUs. A simple load balancing strategy is to
                      use the GPU core counts as the weight.
      cfg.isgpuinfo:  1-print GPU info, [0]-do not print

 == Source-detector parameters ==
      cfg.detpos:     an N by 4 array, each row specifying a detector: [x,y,z,radius]
      cfg.maxdetphoton:   maximum number of photons saved by the detectors [1000000]
      cfg.srctype:    source type, the parameters of the src are specified by cfg.srcparam{1,2}
                              Example: <demo_mcxlab_srctype.m>
                      'pencil' - default, pencil beam, no param needed
                      'isotropic' - isotropic source, no param needed
                      'cone' - uniform cone beam, srcparam1(1) is the half-angle in radian
                      'gaussian' [*] - a collimated gaussian beam, srcparam1(1) specifies the waist radius (in voxels)
                      'planar' [*] - a 3D quadrilateral uniform planar source, with three corners specified
                                by srcpos, srcpos+srcparam1(1:3) and srcpos+srcparam2(1:3)
                      'pattern' [*] - a 3D quadrilateral pattern illumination, same as above, except
                                srcparam1(4) and srcparam2(4) specify the pattern array x/y dimensions,
                                and srcpattern is a floating-point pattern array, with values between [0-1].
                                if cfg.srcnum>1, srcpattern must be a floating-point array with
                                a dimension of [srcnum srcparam1(4) srcparam2(4)]
                                Example: <demo_photon_sharing.m>
                      'pattern3d' [*] - a 3D illumination pattern. srcparam1{x,y,z} defines the dimensions,
                                and srcpattern is a floating-point pattern array, with values between [0-1].
                      'fourier' [*] - spatial frequency domain source, similar to 'planar', except
                                the integer parts of srcparam1(4) and srcparam2(4) represent
                                the x/y frequencies; the fraction part of srcparam1(4) multiplies
                                2*pi represents the phase shift (phi0); 1.0 minus the fraction part of
                                srcparam2(4) is the modulation depth (M). Put in equations:
                                    S=0.5*[1+M*cos(2*pi*(fx*x+fy*y)+phi0)], (0<=x,y,M<=1)
                      'arcsine' - similar to isotropic, except the zenith angle is uniform
                                distribution, rather than a sine distribution.
                      'disk' [*] - a uniform disk source pointing along srcdir; the radius is
                               set by srcparam1(1) (in grid unit)
                      'fourierx' [*] - a general Fourier source, the parameters are
                               srcparam1: [v1x,v1y,v1z,|v2|], srcparam2: [kx,ky,phi0,M]
                               normalized vectors satisfy: srcdir cross v1=v2
                               the phase shift is phi0*2*pi
                      'fourierx2d' [*] - a general 2D Fourier basis, parameters
                               srcparam1: [v1x,v1y,v1z,|v2|], srcparam2: [kx,ky,phix,phiy]
                               the phase shift is phi{x,y}*2*pi
                      'zgaussian' - an angular gaussian beam, srcparam1(1) specifies the variance in the zenith angle
                      'line' - a line source, emitting from the line segment between
                               cfg.srcpos and cfg.srcpos+cfg.srcparam(1:3), radiating
                               uniformly in the perpendicular direction
                      'slit' [*] - a colimated slit beam emitting from the line segment between
                               cfg.srcpos and cfg.srcpos+cfg.srcparam(1:3), with the initial
                               dir specified by cfg.srcdir
                      'pencilarray' - a rectangular array of pencil beams. The srcparam1 and srcparam2
                               are defined similarly to 'fourier', except that srcparam1(4) and srcparam2(4)
                               are both integers, denoting the element counts in the x/y dimensions, respectively.
                               For exp., srcparam1=[10 0 0 4] and srcparam2[0 20 0 5] represent a 4x5 pencil beam array
                               spanning 10 grids in the x-axis and 20 grids in the y-axis (5-voxel spacing)
                      source types marked with [*] can be focused using the
                      focal length parameter (4th element of cfg.srcdir)
      cfg.{srcparam1,srcparam2}: 1x4 vectors, see cfg.srctype for details
      cfg.srcpattern: see cfg.srctype for details
      cfg.srcnum:     the number of source patterns that are
                      simultaneously simulated; only works for 'pattern'
                      source, see cfg.srctype='pattern' for details
                      Example <demo_photon_sharing.m>
      cfg.issrcfrom0: 1-first voxel is [0 0 0], [0]- first voxel is [1 1 1]
      cfg.replaydet:  only works when cfg.outputtype is 'jacobian', 'wl', 'nscat', or 'wp' and cfg.seed is an array
                      -1 replay all detectors and save in separate volumes (output has 5 dimensions)
                       0 replay all detectors and sum all Jacobians into one volume
                       a positive number: the index of the detector to replay and obtain Jacobians
      cfg.voidtime:   for wide-field sources, [1]-start timer at launch, or 0-when entering
                      the first non-zero voxel

 == Output control ==
      cfg.savedetflag: ['dp'] - a string (case insensitive) controlling the output detected photon data fields
                          1 d  output detector ID (1)
                          2 s  output partial scat. even counts (#media)
                          4 p  output partial path-lengths (#media)
                          8 m  output momentum transfer (#media)
                         16 x  output exit position (3)
                         32 v  output exit direction (3)
                         64 w  output initial weight (1)
                      combine multiple items by using a string, or add selected numbers together
                      by default, mcx only saves detector ID (d) and partial-path data (p)
      cfg.issaveexit: [0]-save the position (x,y,z) and (vx,vy,vz) for a detected photon
                      same as adding 'xv' to cfg.savedetflag. Example: <demo_lambertian_exit_angle.m>
      cfg.ismomentum: 1 to save photon momentum transfer,[0] not to save.
                      save as adding 'M' to cfg.savedetflag string
      cfg.issaveref:  [0]-save diffuse reflectance/transmittance in the non-zero voxels
                      next to a boundary voxel. The reflectance data are stored as
                      negative values; must pad zeros next to boundaries
                      Example: see the demo script at the bottom
      cfg.issavedet:  if the 2nd output is requested, this will be set to 1; in such case, user can force
                      setting it to 3 to enable early termination of simulation if the detected photon
                      buffer (length controlled by cfg.maxdetphoton) is filled; if the 2nd output is not
                      present, this will be set to 0 regardless user input.
      cfg.outputtype: 'flux' - fluence-rate, (default value)
                      'fluence' - fluence integrated over each time gate,
                      'energy' - energy deposit per voxel
                      'jacobian' or 'wl' - mua Jacobian (replay mode),
                      'nscat' or 'wp' - weighted scattering counts for computing Jacobian for mus (replay mode)
                      'wm' - weighted momentum transfer for a source/detector pair (replay mode)
                      'length' total pathlengths accumulated per voxel,
                      for type jacobian/wl/wp, example: <demo_mcxlab_replay.m>
                      and  <demo_replay_timedomain.m>
      cfg.session:    a string for output file names (only used when no return variables)

 == Debug ==
      cfg.debuglevel:  debug flag string (case insensitive), one or a combination of ['R','M','P','T'], no space
                    'R':  debug RNG, output fluence.data is filled with 0-1 random numbers
                    'M':  return photon trajectory data as the 5th output
                    'P':  show progress bar
                    'T':  save photon trajectory data only, as the 1st output, disable flux/detp/seeds outputs
      cfg.maxjumpdebug: [10000000|int] when trajectory is requested in the output,
                     use this parameter to set the maximum position stored. By default,
                     only the first 1e6 positions are stored.

      fields with * are required; options in [] are the default values

 Output:
            For each element of fluence,
            fluence(i).data is a 4D array with
                 dimensions specified by [size(vol) total-time-gates].
                 The content of the array is the normalized fluence at
                 each voxel of each time-gate.

                 when cfg.debuglevel contains 'T', fluence(i).data stores trajectory
                 output, see below
            fluence(i).dref is a 4D array with the same dimension as fluence(i).data
                 if cfg.issaveref is set to 1, containing only non-zero values in the
                 layer of voxels immediately next to the non-zero voxels in cfg.vol,
                 storing the normalized total diffuse reflectance (summation of the weights
                 of all escaped photon to the background regardless of their direction);
                 it is an empty array [] when if cfg.issaveref is 0.
            fluence(i).stat is a structure storing additional information, including
                 runtime: total simulation run-time in millisecond
                 nphoton: total simulated photon number
                 energytot: total initial weight/energy of all launched photons
                 energyabs: total absorbed weight/energy of all photons
                 normalizer: normalization factor
                 unitinmm: same as cfg.unitinmm, voxel edge-length in mm

      detphoton: (optional) a struct array, with a length equals to that of cfg.
            Starting from v2018, the detphoton contains the below subfields:
              detphoton.detid: the ID(>0) of the detector that captures the photon
              detphoton.nscat: cummulative scattering event counts in each medium
              detphoton.ppath: cummulative path lengths in each medium (partial pathlength)
                   one need to multiply cfg.unitinmm with ppath to convert it to mm.
              detphoton.mom: cummulative cos_theta for momentum transfer in each medium
              detphoton.p or .v: exit position and direction, when cfg.issaveexit=1
              detphoton.w0: photon initial weight at launch time
              detphoton.prop: optical properties, a copy of cfg.prop
              detphoton.data: a concatenated and transposed array in the order of
                    [detid nscat ppath mom p v w0]'
              "data" is the is the only subfield in all MCXLAB before 2018
      vol: (optional) a struct array, each element is a preprocessed volume
            corresponding to each instance of cfg. Each volume is a 3D int32 array.
      seeds: (optional), if give, mcxlab returns the seeds, in the form of
            a byte array (uint8) for each detected photon. The column number
            of seed equals that of detphoton.
      trajectory: (optional), if given, mcxlab returns the trajectory data for
            each simulated photon. The output has 6 rows, the meanings are
               id:  1:    index of the photon packet
               pos: 2-4:  x/y/z/ of each trajectory position
                    5:    current photon packet weight
                    6:    reserved
            By default, mcxlab only records the first 1e7 positions along all
            simulated photons; change cfg.maxjumpdebug to define a different limit.


 Example:
      % first query if you have supported GPU(s)
      info=mcxlabcl('gpuinfo')

      % define the simulation using a struct
      cfg.nphoton=1e7;
      cfg.vol=uint8(ones(60,60,60));
      cfg.vol(20:40,20:40,10:30)=2;    % add an inclusion
      cfg.prop=[0 0 1 1;0.005 1 0 1.37; 0.2 10 0.9 1.37]; % [mua,mus,g,n]
      cfg.issrcfrom0=1;
      cfg.srcpos=[30 30 1];
      cfg.srcdir=[0 0 1];
      cfg.detpos=[30 20 1 1;30 40 1 1;20 30 1 1;40 30 1 1];
      cfg.vol(:,:,1)=0;   % pad a layer of 0s to get diffuse reflectance
      cfg.issaveref=1;
      cfg.gpuid=1;
      cfg.autopilot=1;
      cfg.tstart=0;
      cfg.tend=5e-9;
      cfg.tstep=5e-10;
      % calculate the fluence distribution with the given config
      [fluence,detpt,vol,seeds,traj]=mcxlabcl(cfg);

      % integrate time-axis (4th dimension) to get CW solutions
      cwfluence=sum(fluence.data,4);  % fluence rate
      cwdref=sum(fluence.dref,4);     % diffuse reflectance
      % plot configuration and results
      subplot(231);
      mcxpreview(cfg);title('domain preview');
      subplot(232);
      imagesc(squeeze(log(cwfluence(:,30,:))));title('fluence at y=30');
      subplot(233);
      hist(detpt.ppath(:,1),50); title('partial path tissue#1');
      subplot(234);
      plot(squeeze(fluence.data(30,30,30,:)),'-o');title('TPSF at [30,30,30]');
      subplot(235);
      newtraj=mcxplotphotons(traj);title('photon trajectories')
      subplot(236);
      imagesc(squeeze(log(cwdref(:,:,1))));title('diffuse refle. at z=1');

 This function is part of Monte Carlo eXtreme (MCX) URL: http://mcx.space

 License: GNU General Public License version 3, please read LICENSE.txt for details




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

 ====================================================================
      ...



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


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

    [data, header]=mcxloadfile(fname)
       or
    [data, header]=mcxloadfile(fname,dim,format)

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

    input:
        fname: the file name to the output .mc2/.nii/binary volume file
        dim:   an array to specify the output data dimension
               normally, dim=[nx,ny,nz,nt]
        format:a string to indicate the format used to save
               the .mc2 file; if omitted, it is set to 'float'

    output:
        data:  the 3-D or 4-D data being loaded
        header: a structure recording the metadata of the file

    this file is part of Monte Carlo eXtreme (MCX)
    License: GPLv3, see http://mcx.sf.net for details




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

    [data, header]=mcxloadfile(fname)
       or
    [data, header]=mcxloadfi...



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


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

    nii=mcxloadnii(filename)

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

    input:
        fname: the file name to the .nii file

    output:
        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
              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

    this file is part of Monte Carlo eXtreme (MCX)
    License: GPLv3, see http://mcx.sf.net for details




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

    nii=mcxloadnii(filename)



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


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

 avgpath=mcxmeanpath(detp,prop)

 Calculate the average pathlengths for each tissue type for a given source-detector pair

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

 input:
     detp: the 2nd output from mcxlab. detp can be either a struct or an array (detp.data)
     prop: optical property list, as defined in the cfg.prop field of mcxlab's input

 output:
     avepath: the average pathlength for each tissue type

 this file is copied from Mesh-based Monte Carlo (MMC)

 License: GPLv3, see http://mcx.space/ for details




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

 avgpath=mcxmeanpath(detp,prop)



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


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

 avgnscat=mcxmeanscat(detp,prop)

 Calculate the average scattering event counts for each tissue type for a given source-detector pair

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

 input:
     detp: the 2nd output from mcxlab. detp can be either a struct or an array (detp.data)
     prop: optical property list, as defined in the cfg.prop field of mcxlab's input

 output:
     avgnscat: the average scattering event count for each tissue type

 this file is copied from Mesh-based Monte Carlo (MMC)

 License: GPLv3, see http://mcx.space/ for details




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

 avgnscat=mcxmeanscat(detp,prop)



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


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

    mcxplotphotons(traj)
       or
    mcxplotphotons(traj, 'color','r','marker','o')
    [sorted, linehandle]=mcxplotphotons(traj)

    Plot photon trajectories from MCXLAB's output

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

    input:
        traj: the 5th output of mcxlab, storing the photon trajectory info
           traj.id: the photon index being recorded
           traj.pos: the 3D position of the photon; for each photon, the
                  positions are stored in serial order
           traj.data: the combined output, in the form of
                [id,pos,weight,reserved]'

    output:
        sorted: a structure to store the sorted trajectory info
        sorted.id: the sorted vector of photon id, staring from 0
        sorted.pos: the sorted position vector of each photon, only
                 recording the scattering sites.

    this file is part of Monte Carlo eXtreme (MCX)
    License: GPLv3, see http://mcx.sf.net for details




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

    mcxplotphotons(traj)
       or
    mcxplotphotons(traj, 'color','r','mar...



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


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

    [dat, filename, handles]=mcxplotvol()
       or
    [dat, filename, handles]=mcxplotvol(fname)
    [dat, filename, handles]=mcxplotvol(data)
    [dat, filename, handles]=mcxplotvol(fname,dim,format)

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

    input:
        fname: the file name to the output .mc2/.nii/binary volume file
        data:  if the first input is an array, it is treated as the data
               to be plotted
        dim:   an array to specify the output data dimension
               normally, dim=[nx,ny,nz,nt]
        format:a string to indicate the format used to save
               the .mc2 file; if omitted, it is set to 'float'

    output:
        dat:(optional)  the 3-D or 4-D data being plotted
        filename: (optional) the name of the file being plotted
        handles:(optional) the handles to the slice surface object

    this file is part of Monte Carlo eXtreme (MCX)
    License: GPLv3, see http://mcx.sf.net for details




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

    [dat, filename, handles]=mcxplotvol()
       or
    [dat, filename, hand...



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


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

 phi=normalizemcx(data,mua,Vvox,dt,energyabsorbed,energytotal)

 Normalization of fluence distributions from Monte-Carlo simulations

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

 input:
    data: a 3D or 4D array for the raw output from MCX (probability)
    mua:  absorption coeff, with the same dimensions as data
    Vvox: volume of a voxel (1/mm^3)
    dt:   time-gate width of MC simulation (s)
    energyabsorbed: total energy being absorbed in the simulation
    energytotal:    total photon energy launched in the simulation

 output:
    phi: the fluence under a unitary source

 For tMCimg output, set energyabsorbed to -1 and energytotal to
 the total photon numbers

 This subroutine of part of Monte-Carlo eXtreme (mcx) package




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

 phi=normalizemcx(data,mua,Vvox,dt,energyabsorbed,energytotal)



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


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 549
  report=serialcorr(randomseq,maxshift)

  serial correlation function in a random sequence at a range of separations

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

    input:
        randomseq: a random sequence (1D array)
        maxshift:  the maximum separation to test with

    output:
        report: the corr. coeff for the sequence between randomseq
            and randomseq(i:end) where i<=maxshift

    this file is part of Monte Carlo eXtreme (MCX)
    License: GPLv3, see http://mcx.sf.net for details
    see Boas2002, Heskell1996



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 39
  report=serialcorr(randomseq,maxshift)



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


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1112
 Display a slice from a volume in 3-D
 h = slice3(vol, I2X, slicedim, sliceidx, handle)

 Vol is either a scalar or RGB volume, e.g. N x M x K or N x M x K x 3.
 I2X is a transformation matrix from volume coordinates to xyz 3-D world
 coordinates, similar to the transform used by image3i.

     [x y z 1]' = I2X * [i j k 1]'

 slicedim  is 1, 2 or 3 and corresponds to i, j and k.
 sliceidx  the index of the slice along slicedim
 handle    an optional handle to a previous slice to reuse
 h         the handle to the created slice.

 Example:

 load mri;
 T = [1 0 0 0;0 1 0 0;0 0 2.5 0];
 h1 = slice3i(squeeze(D),T,1,64);
 h2 = slice3i(squeeze(D),T,2,64);
 h3 = slice3i(squeeze(D),T,3,14);
 colormap gray(88);
 view(30,45); axis equal;

 SEE ALSO: image3i, imagesc3

 Author: Anders Brun, anders@cb.uu.se (2009)

 Modified by Qianqian Fang, q.fang at neu.edu

 Features added:
    1) compatible with octave 4.0 or newer
    2) start 3D rotation by clicking/holding the middle mouse key
    3) adjust colormap levels by dragging with the right mouse key
    4) support 4-D data (up/down key to change frames)




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
 Display a slice from a volume in 3-D
 h = slice3(vol, I2X, slicedim, sliceid...



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


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 47
undocumented function: h = stacked_bar3 (array)


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 47
undocumented function: h = stacked_bar3 (array)



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


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

  Phi = tddiffusion(mua, musp, v, Reff, srcpos,detpos, t)

  semi-infinite medium analytical solution to diffusion model

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

    input:
        mua:   the absorption coefficients in 1/mm
        musp:  the reduced scattering coefficients in 1/mm
        v:     the speed of light
        Reff:  the effective reflection coeff.
        srcpos:array for the source positions (x,y,z)
        detpos:array for the detector positions (x,y,z)
        t:     a list of time in s at which to evaluate the
               analytical diffusion solution

    output:
        Phi:  the output fluence for all time points

    this file is part of Monte Carlo eXtreme (MCX)
    License: GPLv3, see http://mcx.sf.net for details
    see Boas2002




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

  Phi = tddiffusion(mua, musp, v, Reff, srcpos,detpos, t)





