nerve_anatomy.m - ceiber-uom/ViNERS GitHub Wiki
models.nerve_anatomy(geometry, ...)
runs the electroanatomical model implemented using EIDORS for electrical stimulation & recording from a peripheral nerve, including meshing the model in GMSH and generating any necessary thin-layers
This is iteration 3 of this code, which has fixed issues with lost mesh points and uses ~/source/planar-array.geo.template
. Future versions will have more ways of customising the models.
"geometry" is a struct which defines the stimulating / recording electrode geometry, some meshing parameters, and which fascicle set to use (from the default splines.dat, see read_dat_file). If "geometry" is not supplied, it's read from tools.cache('path','elec-geom.mat')
and the resulting parsed geometry is saved to tools.cache('path','elec-geom.mat')
which is assumed to exist by some of the functions in +mesh.
The output of models.nerve_anatomy
is saved to ~\eidors\
sensitivity.mat and ~\eidors\
stimulus.mat.
models.nerve_anatomy
is part of package +models
-
-regenerate
: if set, the mesh is regenerated even if tools.cache('path','*.msh.mat') exists. (usually calltools.cache('reset')
before running -
-template [template-file]
: select the array architecture to generate. Currently only ~/source/array/planar-array.geo.template is implemented. -
-make-opts
: additional arguments passed to tools.make_from_template -
-mesh
: generate mesh only and exit without running EIDORS. -
-fascicle
: which fascicles from file get simulated (default: all). -
-reference
: set reference electrode configuration. Default:[ COUNTER = 1mm, -1, d=2 GROUND = 1mm, -1, d=3 ]
-
-common
: use the COUNTER for both COUNTER and GROUND. Not recommended. -
-output
: sets output file, defaulteidors~/sensitivity (%d).mat
-
-set-zc [val]
: set model.electrode.z_contact toval
-
-sigma [sigma-struct]
: set the volume conductivities for the different regions of the model. Defaults. -
-eit-model
: Import volume conductivities from an impedance image computed using EIDORS.
-
-direct:
: compute sensitivity function directly by putting current sources at every point within each fascicle and perineurium. Preserved for backwards-compatability; This was how the sensitivity function was computed before the Reciprocity Theorem was brought to my attention. Very slow. -
-verify
: make verification pattern, internal bipolar current flow rather than relative to a distant reference -
-stimulus
: compute the electrode-tissue relationship for (bipolar, unless-mono
set) electrical stimuli (if not set, this code computes recording sensitivity - NOTE this was revised to by default )
To regenerate this graph, call plots.view_sensitivity('-3d')
. See plots.view_sensitivity for more options for visualising the output of models.nerve_anatomy
.
The output of models.nerve_anatomy
is saved to ~\eidors\
sensitivity.mat and ~\eidors\
stimulus.mat.
- Mesh generation package: +mesh
- Reciprocity Theorem
The output of the GMSH meshing process is displayed in the MATLAB console (and can be saved to a log file using diary. If there are errors in mesh generation inside of GMSH, it may be the case that your fascicles are too close together, overlapping, overlapping with the electrode carrier, or otherwise not where they are supposed to be. You might also have mesh size issues. For straight fascicles, visualising the input pattern using plots.preview_fascicles can help debug these issues. Opening the .geo
file directly in GMSH can help diagnose more complicated cases:
gmsh_cmd = tools.configuration('gmsh');
geo_file = tools.file('get',tools.cache('path','*.geo'));
system([ gmsh_cmd ' "' geo_file '"' ]) % start GMSH (interactive), open file
% or winopen( geo_file ) on PC
ViNERS is compatible with ASCII version 4.1. GMSH .msh
files. If GMSH exits successfully (without errors) but EIDORS fails to import the gmsh .msh
file, you may need to change the default mesh export settings of GMSH. An example of an error needing this fix:
Reading "C:\Users\Awesome-Tester\AppData\Local\Temp\pn-mdl-17468\nerve+array.msh" ...
Index exceeds the number of array elements (1).
Error in mesh.gmsh_read_mesh>parse_msh_nodes (line 154)
node.xyz = zeros(n_obj(2),3);
Error in mesh.gmsh_read_mesh (line 43)
case '$Nodes', nodes = parse_msh_nodes( fid );
Error in mesh.make_gmsh_thinLayer (line 26)
[~,nodes,~,object] = mesh.gmsh_read_mesh(filename,true); % <<<< EIDORS call