nrv.fmod.FEM.mesh_creator package
Submodules
nrv.fmod.FEM.mesh_creator.MshCreator module
- class nrv.fmod.FEM.mesh_creator.MshCreator.MshCreator(D=3, ver_level=None)[source]
Bases:
NRV_class
Class handeling the creation of a gmsh mesh (https://gmsh.info/doc/texinfo/gmsh.html) Contains methodes dealing with the mesh geometries, physical domains and feilds
- add_box(x=0, y=0, z=0, ax=5, ay=1, az=1)[source]
add a box to the mesh
- Parameters:
x (float) – x position of the first face center
y (float) – y position of the first face center
z (float) – z position of the first face center
ax (float) – Box length along x
ay (float) – Box length along y
az (float) – Box length along z
- Returns:
box – id of the added object
- Return type:
int
- add_cylinder(x=0, y=0, z=0, L=5, R=1)[source]
add a x-oriented cylinder to mesh entities
- Parameters:
x (float) – x position of the first face center
y (float) – y position of the first face center
z (float) – z position of the first face center
L (float) – Cylinder length along x
R (float) – Cylinder radius
- Returns:
cyl – id of the added object
- Return type:
int
- add_domains(obj_IDs, phys_ID, dim=None, name=None)[source]
add domains (ID + name) to a goupe of entities Caution: as to be used after all entities are placed
- Parameters:
fname (str) – path and name of saving file. If ends with “.msh” only save in “.msh” file
- add_line(X0, X1)[source]
add a line to the mesh
- Parameters:
X0 (int or tupple(3)) – x position of the first face center
X1 (int or tupple(3)) – y position of the first face center
- Returns:
line – id of the added object
- Return type:
int
- add_point(x=0, y=0, z=0)[source]
add a point to the mesh
- Parameters:
x (float) – x position of the first face center
y (float) – y position of the first face center
z (float) – z position of the first face center
- Returns:
point – id of the added object
- Return type:
int
- fragment(IDs=None, dim=3, verbose=True)[source]
Fragmentation of the mesh important to link entities to each other
- Parameters:
IDs (list or None) – list of IDs of the element to fragments, if None all dim dimension elements are fragmented, by default None
dim (int) – dimension of the elements considerated, by default 3
verbose (bool) – print or not the verbose on the temrminal, by default False
- get_faces(com=False, bd=False)[source]
update and return list of mesh face (optional: with their center of mass)
- Returns:
self.faces
- Return type:
list[tuple]
- get_res()[source]
return the global resolution saved (usefull when no field are set)
- Returns:
res – global resolution saved in the object
- Return type:
float
- get_volumes(com=False, bd=False)[source]
update and return list of mesh volumes (optional: with their center of mass)
- Returns:
self.faces
- Return type:
list[tuple]
- refine_entities(ent_ID, res_in, dim, res_out=None, IncludeBoundary=True)[source]
refine mesh resolution in a list of faces or volumes IDs
- Parameters:
ent_ID (list[int] or int) – ID or list of ID of the entities where the resolution should be changed
res_in (float) – resolution inside the entities
dim (int (2 or 3)) – dimention of the considerated entities
res_out (float) – resolution outside the entities if None take self.res, default None
IncludeBoundary (bool) – include the boundaries for the refinment, default True
- refine_min(feild_IDs)[source]
refine mesh resolution taking the minimum value for a list of refinment fields
- Parameters:
feild_IDs (list[int]) – list of field from wich the minimum should be taken
- refine_threshold(ent_ID, dim, dist_min, dist_max, res_min, res_max=None, N_samples=100)[source]
refine mesh resolution in a list of faces or volumes IDs
- Parameters:
ent_ID (list[int] or int) – ID or list of ID of the entities where the resolution should be changed
res_in (float) – resolution inside the entities
dim (int (2 or 3)) – dimention of the considerated entities
res_out (float) – resolution outside the entities if None take self.res, default None
IncludeBoundary (bool) – include the boundaries for the refinment, default True
- refinement_callback(meshSizeCallback)[source]
Add a call back function which is apply to the mesh size defined by fields and return the final mesh size
- Parameters:
meshSizeCallback (nrv.utils.MeshCallBack) –
- rotate(volume, angle, x=0, y=0, z=0, ax=0, ay=0, az=0, rad=True)[source]
rotate volume
- Parameters:
volume (int) – gmsh id of the volume
angle (: float) – angle of the rotation
x (float) – x-position of the center of the rotation, by default 0
y (float) – y-position of the center of the rotation, by default 0
z (float) – z-position of the center of the rotation, by default 0
ax (float) – x-coefficient of the rotation axis direction vector, by default 0
ay (float) – y-coefficient of the rotation axis direction vector, by default 0
az (float) – z-coefficient of the rotation axis direction vector, by default 0
rad (bool) – if true angle considered in rad, else in degree, by default 0
- save(fname, generate=True)[source]
Save mesh in fname in “.msh”
- Parameters:
fname (str) – path and name of saving file. If ends with “.msh” only save in “.msh” file
- set_chara_blen(i=0)[source]
from gmsh: Extend characteristic lengths from the boundaries inside the surface/volume
- Parameters:
i (int, float, bool) – Parameter value, by default 0
- set_res(new_res)[source]
set the global resolution saved (usefull when no field are set)
- Parameters:
new_res (float) – global resolution to set the object
nrv.fmod.FEM.mesh_creator.NRV_Msh module
- nrv.fmod.FEM.mesh_creator.NRV_Msh.mesh_from_electrode(elec, mesh=None, Length=10000, Outer_D=5, Nerve_D=4000, y_c=0, z_c=0, res='default')[source]
returns the corresponding mesh from a nrv.facsicle
nrv.fmod.FEM.mesh_creator.NerveMshCreator module
- class nrv.fmod.FEM.mesh_creator.NerveMshCreator.NerveMshCreator(Length=10000, Outer_D=5, Nerve_D=4000, y_c=0, z_c=0, ver_level=2)[source]
Bases:
MshCreator
Class allowing to generate Nerve shape 3D gmsh mesh with labeled physical domain Contains methodes dealing with the mesh geometries, physical domains and feilds Inherit from MshCreator class. see MshCreator for further detail
- add_CUFF(ID=None, x_c=0, contact_length=100, is_volume=True, contact_thickness=None, insulator=True, insulator_thickness=None, insulator_length=None, insulator_offset=0)[source]
Add CUFF electrode to the mesh
- Parameters:
ID (int) – if not none and ID exist, change electrod ID,by defalt None
x_c (float) – x-position of the CUFF center in um, by default 0 length of the CUFF electrod in um, by default 100
contact_length (float) – length along x of the contact site in um, by default 100
is_volume (bool) – if True the contact is kept on the mesh as a volume, by default True
contact_thickness (float) – thickness of the contact site in um, by default 5
insulator (bool) – remove insulator ring from the mesh (no conductivity), by default True
insulator_thickness (float) – thickness of the insulator ring in um, by default 20
insulator_length (float) – length along x of the insulator ring in um, by default 1000
- add_CUFF_MEA(ID=None, N=4, x_c=0, y_c=0, z_c=0, size=None, thickness=100, inactive=True, inactive_th=None, inactive_L=None)[source]
- add_CUFF_MP(ID=None, N=4, x_c=0, contact_width=None, contact_length=100, is_volume=True, contact_thickness=None, insulator=True, insulator_thickness=None, insulator_length=None, insulator_offset=0)[source]
Add MultiPolar CUFF electrodes to the mesh
- Parameters:
ID (int) – if not none and ID exist, change electrod ID,by defalt None
N (int) – Number of active site, by default 4
x_c (float) – x-position of the CUFF center in um, by default 0 length of the CUFF electrod in um, by default 100
contact_width (float or None) – width of the active sites around the nerve, if None set to cover 4/5 of the perimeter with active sites
contact_length (float) – length along x of the contact site in um, by default 100
is_volume (bool) – if True the contact is kept on the mesh as a volume, by default True
contact_thickness (float) – thickness of the contact site in um, by default 5
insulator (bool) – remove insulator ring from the mesh (no conductivity), by default True
insulator_thickness (float) – thickness of the insulator ring in um, by default 20
insulator_length (float) – length along x of the insulator ring in um, by default 1000
- add_LIFE(ID=None, x_c=0, y_c=0, z_c=0, length=1000, D=25, is_volume=False)[source]
Add LIFE electrode to the mesh
- Parameters:
ID (int) – electrod ID, ,by defalt None
x_c (float) – x-position of the LIFE center in um, by default 0
y_c (float) – y-position of the LIFE center in um, by default 0
z_c (float) – z-position of the LIFE center in um, by default 0
length (float) – length of the LIFE electrod in um, by default 1000
D (float) – diameter of the LIFE electrod in um, by default 25
is_volume (bool) – if True in cylinder of the LIFE is kept on the mesh
- load(data, mshfname=None, blacklist={}, **kwargs)[source]
Generic loading method for NRV class instance
- Parameters:
data (dict) – Dictionary containing the NRV object
blacklist (dict, optional) – Dictionary containing the keys to be excluded from the load
**kwargs (dict, optional) – Additional arguments to be passed to the load method of the NRV object
- remove_fascicles(ID=None)[source]
remove a fascicle of the FEM simulation
- Parameters:
ID (int, None) – ID number of the fascicle to remove, if None, remove all fascicles, by default None
- reshape_axon(D, y_c=0, z_c=0, ID=None, res='default')[source]
Reshape a axon of the FEM simulation
- Parameters:
Fascicle_D (float) – Fascicle diameter, in um
y_c (float) – Fascicle center y-coodinate in um, 0 by default
z_c (float) – Fascicle center y-coodinate in um, 0 by default
ID (int) – If the simulation contains more than one fascicles, ID number of the fascicle to reshape as in COMSOL
- reshape_fascicle(D, y_c=0, z_c=0, ID=None, res='default')[source]
Reshape a fascicle of the FEM simulation
- Parameters:
Fascicle_D (float) – Fascicle diameter, in um
y_c (float) – Fascicle center y-coodinate in um, 0 by default
z_c (float) – Fascicle center y-coodinate in um, 0 by default
ID (int) – If the simulation contains more than one fascicles, ID number of the fascicle to reshape as in COMSOL
- reshape_nerve(Nerve_D=None, Length=None, y_c=None, z_c=None, res='default')[source]
Reshape the nerve of the FEM simulation
- Parameters:
Nerve_D (float) – Nerve diameter, in um
Length (float) – Nerve length, in um
y_c (float) – Nerve center y-coordinate in um, 0 by default
z_c (float) – Nerve z-coordinate center in um, 0 by default
- reshape_outerBox(Outer_D=None, res='default', tresholded_res=None)[source]
Reshape the size of the FEM simulation outer box
- Parameters:
outer_D (float) – FEM simulation outer box diameter, in mm, WARNING, this is the only parameter in mm !
- save(fname='nervemshcreator.json', save=True, mshfname=None, blacklist=[], **kwargs)[source]
Return extracellular context as dictionary and eventually save it as json file NB: caution, first argument is fname to match with MshCreator.save arguments
- Parameters:
save (bool) – if True, save in json files
fname (str) – Path and Name of the saving file, by default “extracel_context.json”
- Returns:
context_dic – dictionary containing all information
- Return type:
dict
- set_gnd_facet(outfacet=None, lfacet=None, rfacet=None)[source]
Set which of the outer facet should be the ground (element 1)
- Parameters:
outfacet (bool or None) – if true outer ring facet is included to the element 1, if None not modified by default None
lfacet (bool or None) – if true left facet is included to the element 1, if None not modified by default None
rfacet (bool or None) – if true right facet is included to the element 1, if None not modified by default None
Module contents
NeuRon Virtualizer, large scale modeling of Peripheral Nervous System with random stimulation waveforms