nrv.nmod package
Submodules
nrv.nmod.axons module
NRV-axons Authors: Florian Kolbl / Roland Giraud / Louis Regnacq / Thomas Couppey (c) ETIS - University Cergy-Pontoise - CNRS
- class nrv.nmod.axons.axon(y=0, z=0, d=1, L=100, dt=0.001, Nseg_per_sec=0, freq=100, freq_min=0, mesh_shape='plateau_sigmoid', alpha_max=0.3, d_lambda=0.1, v_init=None, T=None, ID=0, threshold=-40, **kwarks)[source]
Bases:
NRV_simulable
Axon is a generic object to describe an axonal fiber, (soma and interconnection are not taken into account, all axons are independant from others) From user perspective, call myelinated, unmylinated or thin_myelinated classes for robust code. All axons are supposed to be along the x-axis, as Neuron would do when creatnig a basic longitudinal geometry.
WARNING: do not create more than one axon at a time for one process, to prevent from parameters overlaps in Neuron
- attach_extracellular_recorder(rec)[source]
attach an extracellular recorder to the axon
- Parameters:
rec (recorder object) – see Recording.recorder help for more details
- attach_extracellular_stimulation(stim)[source]
attach a extracellular context of simulation for an axon
- Parameters:
stim (stimulation object) – see Extracellular.stimulation help for more details
- change_stimulus_from_elecrode(ID_elec, stimulus)[source]
Change the stimulus of the ID_elec electrods
Parameters:
- ID_elecint
ID of the electrode which should be changed
- stimulusstimulus
New stimulus to set
- get_electrodes_footprints_on_axon(save_ftp_only=False, filename='electrodes_footprint.ftpt')[source]
get electrodes footprints on each axon segment
- Parameters:
save_ftp_only (bool) – if true save_ftp_only result in a .ftpt file
filename (str) – saving file name and path
- Returns:
footprints (dict)
Dictionnary composed of extracellular footprint array, the keys are int value
of the corresponding electrode ID
- load(data, extracel_context=False, intracel_context=False, rec_context=False, blacklist=[])[source]
Load all axon properties from a dictionary or a json file
- Parameters:
data (str or dict) – json file path or dictionary containing axon information
- save(save=False, fname='axon.json', extracel_context=False, intracel_context=False, rec_context=False, blacklist=[])[source]
Return axon as dictionary and eventually save it as json file WARNING to use BEFORE stimulation, (for post simulation savings use save_axon_results_as_json on results dictionary
- Parameters:
save (bool) – if True, save in json files
fname (str) – Path and Name of the saving file, by default “axon.json”
- Returns:
ax_dic – dictionary containing all information
- Return type:
dict
- save_axon(save=False, fname='axon.json', extracel_context=False, intracel_context=False, rec_context=False)[source]
- simulate(**kwargs)[source]
Simulates the axon using neuron framework
- Parameters:
t_sim (float) – total simulation time (ms), by default 20 ms
self.record_V_mem (bool) –
- if true, the membrane voltage is recorded, set to True by default
see unmyelinated/myelinated to see where recording occur results stored with the key “V_mem”
self.record_I_mem (bool) – if true, the membrane current is recorded, set to False by default
self.record_I_ions (bool) – if true, the ionic currents are recorded, set to False by default
record_particules (bool) – if true, the marticule states are recorded, set to False by default
self.loaded_footprints (dict or bool) –
array (Dictionnary composed of extracellular footprint) –
value (the keys are int) –
ID (of the corresponding electrode) –
None (if) –
simulation (footprints calculated during the) –
:param : :param set to None by default:
- Returns:
axon_sim – all informations on neuron, segment position and all simulation results
- Return type:
dictionnary
- class nrv.nmod.axons.axon_test(y, z, d, L, dt=0.001, Nseg_per_sec=0, freq=100, freq_min=0, mesh_shape='plateau_sigmoid', alpha_max=0.3, d_lambda=0.1, v_init=None, T=None, ID=0, threshold=-40)[source]
Bases:
axon
TO DO
- nrv.nmod.axons.create_Nseg_freq_shape(N_sec, shape, freq, freq_min, alpha_max)[source]
creates a vector with the size of N_sec, a number of section to create an axon, and creates a shape of frequency to use with the d-lambda rule along the axon.
- nrv.nmod.axons.Nsec
the number of sections that will be used to implement the axon
- Type:
int
- nrv.nmod.axons.shape
- shape of the output vector, pick between:
“pyramidal” -> min frequencies on both sides and linear increase up to the middle at the maximum frequency “sigmoid” -> same a befor with sigmoid increase instead of linear “plateau” -> sale as pyramidal except the max frequency is holded on a central plateau “plateau_sigmoid” -> same as previous with sigmoid increase
- Type:
str
- nrv.nmod.axons.freq
maximum value of the frequency for the d-lambda rule
- Type:
float
- nrv.nmod.axons.freq_min
minimum value of the frequency for the d-lambda rule
- Type:
float
- nrv.nmod.axons.alpha_max
proportion of the axon at the maximum frequency for plateau shapes
- Type:
float
- Returns:
freqs – vector of frequency to apply to a multi-sections axon
- Return type:
np.array
- nrv.nmod.axons.d_lambda_rule(L, d_lambda, f, sec)[source]
computes the d_lambda rule for a sections and returns the number of segments.
- nrv.nmod.axons.L
length of the section (um)
- Type:
int
- nrv.nmod.axons.d_lambda
d_lambda value, usually between 0.1 and 0.3
- Type:
float
- nrv.nmod.axons.f
maximal ionic current frequency (Hz)
- Type:
float
- nrv.nmod.axons.sec
current neuron section on which to compute dlambda rule
- Type:
neuron section
- Returns:
Nseg – number of segment recommended to the section
- Return type:
int
nrv.nmod.fascicle_generator module
NRV-fascicule generator Authors: Florian Kolbl / Roland Giraud / Louis Regnacq (c) ETIS - University Cergy-Pontoise - CNRS
- nrv.nmod.fascicle_generator.axon_packer(diameters, Delta=0, y_gc=0, z_gc=0, max_iter=20000, probe=100, monitor=False, monitoring_Folder='', monitoring_Niter=100, v_att=0.01, v_rep=0.1)[source]
Axon Packing algorithm: this operation takes a vector of diameter (random population) and places it at best. The used algorithm is largely based on [1]
- Parameters:
diameters (np.array) – Array containing all the diameters of the axon population to pack
Delta (float) – minimal inter-axon distance to respect before considering collision, in um
y_gc (float) – y coordinate of the gravity center for the packing, in um
z_gc (float) – z coordinate of the gravity center for the packing, in um
max_iter (int) – Max. number of iterations
probe (int) – Number of iterations between two Fiber Volume Fraction probing
monitor (bool) – if True, the packing process will be monitored and some steps are plotted and saved
monitoring_Folder (str) – in case of monitoring, folder where the images of the packing process are stored
monitoring_Niter (str) – in case of monitoring, number of iterations between two monitoring images
v_att (float) – vector norm for attraction velocity, in um per iteration
v_rep (float) – vector norm for repulsion velocity, in um per iteration
- Returns:
y_axons (np.array) – Array containing the y coordinates of axons, in um
z_axons (np.array) – Array containing the z coordinates of axons, in um
iteration (int) – number of iterations performed
FVF (np.array) – probed values for the Fiber Volume Fraction
probed_iter (np.array) – index of the FVF probed iterations
Note
- scientific reference
[1] Mingasson, T., Duval, T., Stikov, N., and Cohen-Adad, J. (2017). AxonPacking: an open-source software to simulate arrangements of axons in white matter. Frontiers in neuroinformatics, 11, 5.
- dev Note
the algorithm perform a fixed number of iteration, the code could evoluate to tke into account the FVF convergence, however this value depends on the range on number of axons.
- nrv.nmod.fascicle_generator.compute_P_fast(diameters, y_axons, z_axons, Delta)[source]
Compyte the proximity matrix for axon packing. Based on numpy and scipy. Slower (just a bit) than JIT version on dev. For internal use only
- nrv.nmod.fascicle_generator.create_axon_population(N, percent_unmyel=0.7, M_stat='Schellens_1', U_stat='Ochoa_U')[source]
Create a virtual population of axons (no Neuron implementation, axon class not called) of a controled number, with controlled statistics.
- Parameters:
N (int) – Number of axon to generate for the population (Unmyelinated and myelinated)
percent_unmyel (float) – ratio of unmyelinated axons in the population. Should be between 0 and 1.
M_stat (str) – name of the statistic in the librairy or path to a new librairy in csv for myelinated diameters repartition
U_stat (str) – name of the statistic in the librairy or path to a new librairy in csv for unmyelinated diameters repartition
- Returns:
axons_diameters (np.array) – Array of length N, containing all the diameters of the generated axon population
axons_type (np.array) – Array of length N, containing a ‘1’ value for indexes where the axon is myelinated (A-delta or not), else ‘0’
M_diam_list (np.array) – list of myelinated only diameters
U_diam_list (np.array) – list of unmyelinated only diamters
- nrv.nmod.fascicle_generator.create_generator_from_stat(stat, myelinated=True, dmin=None, dmax=None)[source]
Create a statistical generator (type rv_continuous) for a given statistic.
- Parameters:
stat (str) – name of the statistic in the librairy or path to a new librairy in csv
myelinated (bool) – True if the statistic is describing myelinated diameters, esle False. If the statisticis in the librairy, this will be automatically chosen.
dmin (float) – minimal diameter to consider, in um. If None, the minimal value of the statistic is taken
dmax (float) – minimal diameter to consider, in um. If None, the maximal value of the statistic plus bin size is taken
- Returns:
generator – Generator object corresponding to the statistic.
- Return type:
rv_continuous
- nrv.nmod.fascicle_generator.delete_collisions(axons_diameters, axons_type, y_axons, z_axons, Delta=0)[source]
Delete collision cases in a placed population. In case of a detected collision, the axon or smaller diameter is removed.
- Parameters:
axons_diameters (np.array) – array containing the axons diameters
axons_type (np.array) – array containing the axons type (‘1’ for myelinated, ‘0’ for unmyelinated)
y_axons (np.array) – y coordinate of the axons to store, in um
z_axons (np.array) – z coordinate of the axons to store, in um
Delta (float) – space between axon fibers under which collision is considered, in um
- Returns:
new_axons_diameters (np.array) – array containing the axons diameters without collisions
new_axons_type (np.array) – array containing the axons type (‘1’ for myelinated, ‘0’ for unmyelinated)
new_y_axons (np.array) – y coordinate of the axons to store, in um
new_z_axons (np.array) – z coordinate of the axons to store, in um
- nrv.nmod.fascicle_generator.fill_area_with_axons(A, percent_unmyel=0.7, FVF=0.55, M_stat='Schellens_1', U_stat='Ochoa_U')[source]
Create a virtual population of axons (no Neuron implementation, axon class not called) to fill a specified area, with controlled statistics.
- Parameters:
A (float) – surface area to fill, in um**2
percent_unmyel (float) – ratio of unmyelinated axons in the population. Should be between 0 and 1.
FVF – Fiber Volume Fraction estimated for the area. By default set to 0.55
M_stat (str) – name of the statistic in the librairy or path to a new librairy in csv for myelinated diameters repartition
U_stat (str) – name of the statistic in the librairy or path to a new librairy in csv for unmyelinated diameters repartition
- Returns:
axons_diameters (np.array) – Array containing all the diameters of the generated axon population
axons_type (np.array) – Array containing a ‘1’ value for indexes where the axon is myelinated (A-delta or not), else ‘0’
M_diam_list (np.array) – list of myelinated only diameters
U_diam_list (np.array) – list of unmyelinated only diamters
- nrv.nmod.fascicle_generator.load_axon_population(f_name)[source]
Load a population from a file
- Parameters:
f_name (str) – name of the file where the population is stored
- Returns:
axons_diameters (np.array) – Array containing all the diameters of the generated axon population
axons_type (np.array) – Array containing a ‘1’ value for indexes where the axon is myelinated (A-delta or not), else ‘0’
M_diam_list (np.array) – list of myelinated only diameters
U_diam_list (np.array) – list of unmyelinated only diamters
- nrv.nmod.fascicle_generator.load_placed_axon_population(f_name)[source]
Load a placed population from a file
- Parameters:
f_name (str) – name of the file where the population is stored
- Returns:
axons_diameters (np.array) – Array containing all the diameters of the generated axon population
axons_type (np.array) – Array containing a ‘1’ value for indexes where the axon is myelinated (A-delta or not), else ‘0’
y_axons (np.array) – y coordinate of the axons, in um
z_axons (np.array) – z coordinate of the axons, in um
M_diam_list (np.array) – list of myelinated only diameters
U_diam_list (np.array) – list of unmyelinated only diamters
- nrv.nmod.fascicle_generator.load_stat(stat_name)[source]
Load a statistic stored in the included librairy or specified by the user in a csv file (first corlumn: axon diameter bin start - second corlumn: proportion)
- Parameters:
stat_name (str) – name of the statistic in the librairy or path to a new librairy in csv
- Returns:
diameters (list) – diameters as start of bins of the histogram
presence (list) – quantities of presence of each bin in the histogram
- nrv.nmod.fascicle_generator.one_Gamma(x, a1, beta1, c1)[source]
Gamma function, mono-modal, to interpolate unmyelinated statistics.
- Parameters:
x (float) – variable of the Gamma function, will correspond to diameter
a1 (float) – shape parameter
beta1 (float) – scale parameter
c1 (float) – gain applied to the gamma function
Note
location of the gamma pdf function is fixed to 0.2, diameters will be interpolated above this minimal value.
- nrv.nmod.fascicle_generator.plot_situation(diameters, y_axons, z_axons, size, title=None, y_gc=0, z_gc=0)[source]
Discplay a population of axons. Doesn’t return but declares a matplotlib figure
- Parameters:
diameters (np.array) – diamters of the axons to display, in um
y_axons (np.array) – y coordinate of the axons to display, in um
z_axons (np.array) – z coordinate of the axons to display, in um
size (float) – size of the window as a square side, in um
title (str) – title of the figure
y_gc (float) – y coordinate of the gravity, in um
z_gc (float) – z coordinate of the gravity, in um
- nrv.nmod.fascicle_generator.save_axon_population(f_name, axons_diameters, axons_type, comment=None)[source]
Save an axonal population to a file
- Parameters:
f_name (str) – name of the file to store the population
axons_diameters (np.array) – array containing the axons diameters
axons_type (np.array) – array containing the axons type (‘1’ for myelinated, ‘0’ for unmyelinated)
comment (str) – comment added in the header of the file, optional
- nrv.nmod.fascicle_generator.save_placed_axon_population(f_name, axons_diameters, axons_type, y_axons, z_axons, comment=None)[source]
Save a placed axonal population to a file
- Parameters:
f_name (str) – name of the file to store the population
axons_diameters (np.array) – array containing the axons diameters
axons_type (np.array) – array containing the axons type (‘1’ for myelinated, ‘0’ for unmyelinated)
y_axons (np.array) – y coordinate of the axons to store, in um
z_axons (np.array) – z coordinate of the axons to store, in um
comment (str) – comment added in the header of the file, optional
- nrv.nmod.fascicle_generator.shuffle_population(axons_diameters, axons_type)[source]
Shuffle an axonal population
- Parameters:
axons_diameters (np.array) – array containing the axons diameters
axons_type (np.array) – array containing the axons type (‘1’ for myelinated, ‘0’ for unmyelinated)
- Returns:
axons_diameters (np.array) – shuffled axons diamters
axons_type (np.array) – corrresponding axons type
- nrv.nmod.fascicle_generator.two_Gamma(x, a1, beta1, c1, a2, beta2, c2, transition)[source]
Gamma function, bi-modal, to interpolate myelinated statistics.
- Parameters:
x (float) – variable of the Gamma function, will correspond to diameter
a1 (float) – shape parameter on the first (lowest) lobe
beta1 (float) – scale parameter on the first (lowest) lobe
c1 (float) – gain applied to the gamma function on the first (lowest) lobe
a2 (float) – shape parameter on the second (highest) lobe
beta2 (float) – scale parameter on the second (highest) lobe
c2 (float) – gain applied to the gamma function on the second (highest) lobe
transition (float) – diameter value at the transition between the two lobes
Note
location of the gamma pdf first function is fixed to 2, diameters will be interpolated above this minimal value. This corresponds to the minimal A-delta diamter tolerated value.
nrv.nmod.fascicles module
NRV-fascicles Authors: Florian Kolbl / Roland Giraud / Louis Regnacq / Thomas Couppey (c) ETIS - University Cergy-Pontoise - CNRS
- class nrv.nmod.fascicles.fascicle(ID=0, **kwargs)[source]
Bases:
NRV_simulable
Class for Fascicle, defined as a group of axons near one to the other in the same Perineurium Sheath. All axons are independant of each other, no ephaptic coupling.
- attach_extracellular_recorder(rec)[source]
attach an extracellular recorder to the axon
- Parameters:
rec (recorder object) – see Recording.recorder help for more details
- attach_extracellular_stimulation(stimulation)[source]
attach a extracellular context of simulation for an axon.
parameters:
stimulation : stimulation object, see Extracellular.stimulation help for more details
- change_stimulus_from_elecrode(ID_elec, stimulus)[source]
Change the stimulus of the ID_elec electrods
parameters:
- ID_elecint
ID of the electrode which should be changed
- stimulusstimulus
new stimulus to set
- clear_context(extracel_context=True, intracel_context=True, rec_context=True)[source]
Clear all stimulation and recording mecanism
- compute_electrodes_footprints(save_ftp_only=False, filename='electrodes_footprint.ftpt', **kwargs)[source]
get electrodes footprints on each segment of each axon
- Parameters:
save_ftp_only (bool) – if true save result in a .ftpt file
filename (str) – saving file name and path
Unmyelinated_model (str) – model for unmyelinated fibers, by default ‘Rattay_Aberham’
Adelta_model (str) – model for A-delta thin myelinated fibers, by default’extended_Gaines’
Myelinated_model (str) – model for myelinated fibers, by default ‘MRG’
myelinated_nseg_per_sec (int) – number of segment per section for myelinated axons
- Returns:
footprints – Dictionnary composed of axon footprint dictionary, the keys are int value of the corresponding axon ID
- Return type:
dict
- define_circular_contour(D, y_c=None, z_c=None, N_vertices=100)[source]
Define a circular countour to the fascicle
- Parameters:
D (float) – diameter of the circular fascicle contour, in um
y_c (float) – y coordinate of the circular contour center, in um
z_c (float) – z coordinate of the circular contour center, in um
N_vertices (int) – Number of vertice in the compute the contour
- define_length(L)[source]
set the length over the x axis of the fascicle
- Parameters:
L (float) – length of the fascicle in um
- fill(parallel=True, percent_unmyel=0.7, FVF=0.55, M_stat='Schellens_1', U_stat='Ochoa_U', ppop_fname=None, pop_fname=None)[source]
Fill a geometricaly defined contour with axons
- Parameters:
parallel (bool) – if True, the generation process (quite long) is split over multiples cores, if False everything is perfrmed by the master.
percent_unmyel (float) – ratio of unmyelinated axons in the population. Should be between 0 and 1.
FVF (float) – Fiber Volume Fraction estimated for the area. By default set to 0.55
M_stat (str) – name of the statistic in the librairy or path to a new librairy in csv for myelinated diameters repartition
U_stat (str) – name of the statistic in the librairy or path to a new librairy in csv for unmyelinated diameters repartition
ppop_fname (str) – optional, if specified, name file to store the placed population generated
pop_fname (str) – optional, if specified, name file to store the population generated
- fill_with_placed_population(axons_diameter, axons_type, axons_y, axons_z, check_inside=True, check_collision=True, ppop_fname=None)[source]
Fill a geometricaly defined contour with an already generated axon population
- Parameters:
axons_diameters (np.array) – Array containing all the diameters of the axon population
axons_type (np.array) – Array containing a ‘1’ value for indexes where the axon is myelinated (A-delta or not), else ‘0’
axons_y (np.array) – y coordinate of the axons, in um
axons_z (np.array) – z coordinate of the axons, in um
check_inside (bool) – if True the placed axons position are checked to ensure all remaining axons at the end are inside the fascicle
check_collision (bool) – if True, possible remaining collisions are check in the loaded population, and thiner axons are deleted
ppop_fname (str) – optional, if specified, name file to store the placed population generated
- fill_with_population(axons_diameter, axons_type, Delta=0.1, ppop_fname=None, FVF=0.55)[source]
Fill a geometricaly defined contour with an already generated axon population
- Parameters:
axons_diameters (np.array) – Array containing all the diameters of the axon population
axons_type (np.array) – Array containing a ‘1’ value for indexes where the axon is myelinated (A-delta or not), else ‘0’
ppop_fname (str) – optional, if specified, name file to store the placed population generated
FVF (float) – Fiber Volume Fraction estimated for the area. By default set to 0.55
- fit_circular_contour(y_c=None, z_c=None, Delta=0.1, N_vertices=100)[source]
Define a circular countour to the fascicle
- Parameters:
y_c (float) – y coordinate of the circular contour center, in um
z_c (float) – z coordinate of the circular contour center, in um
Delta (float) – distance between farest axon and contour, in um
N_vertices (int) – Number of vertice in the compute the contour
- generate_ligned_NoR_position(x=0)[source]
Generates Node of Ranvier shifts to aligned a node of each axon to x postition.
- Parameters:
x (float) – x axsis value (um) on which node are lined, by default 0
- generate_random_NoR_position()[source]
Generates radom Node of Ranvier shifts to prevent from axons with the same diamters to be aligned.
- get_axons_parameters(unmyelinated_only=False, myelinated_only=False)[source]
get parameters of axons in the fascicle
- Parameters:
unmyelinated_only (bool) – modification will only
myelinated_only (bool) – modification will only
- get_circular_contour()[source]
Returns the properties of the fascicle contour considered as a circle (y and z center and diameter)
- Returns:
D (float) – diameter of the contour, in um. Set to 0 if not applicable
y (float) – y position of the contour center, in um
z (float) – z position of the contour center, in um
- get_electrodes_footprints_on_axons(save_ftp_only=False, filename='electrodes_footprint.ftpt', **kwargs)[source]
- insert_I_Clamp(position, t_start, duration, amplitude, ax_list=None)[source]
Insert a IC clamp stimulation
- Parameters:
position (float) – relative position over the fascicle. Note that all thin myelinated and myelinated will be stimulated in the nearest node of Ranvier around the clamp specified position
t_start (float) – starting time, in ms
duration (float) – duration of the pulse, in ms
amplitude (float) – amplitude of the pulse (nA)
ax_list (list, array, np.array) – list of axons to insert the clamp on, if None, all axons are stimulated
- load(data, extracel_context=False, intracel_context=False, rec_context=False, blacklist=[])[source]
Load a fascicle configuration from a json file
- Parameters:
fname (str) – path to the json file describing a fascicle
extracel_context (bool) – if True, load the extracellular context as well
intracel_context (bool) – if True, load the intracellular context as well
rec_context (bool) – if True, load the recording context as well
blacklist (list[str]) – key to exclude from loading
- load_fascicle_configuration(fname, extracel_context=False, intracel_context=False, rec_context=False)[source]
- plot(fig, axes, contour_color='k', myel_color='r', unmyel_color='b', num=False)[source]
plot the fascicle in the Y-Z plane (transverse section)
- Parameters:
fig (matplotlib.figure) – figure to display the fascicle
axes (matplotlib.axes) – axes of the figure to display the fascicle
contour_color (str) – matplotlib color string applied to the contour. Black by default
myel_color (str) – matplotlib color string applied to the myelinated axons. Red by default
unmyel_color (str) – matplotlib color string applied to the myelinated axons. Blue by default
num (bool) – if True, the index of each axon is displayed on top of the circle
- plot_x(fig, axes, myel_color='r', unmyel_color='b', Myelinated_model='MRG')[source]
plot the fascicle’s axons along Xline (longitudinal)
- Parameters:
fig (matplotlib.figure) – figure to display the fascicle
axes (matplotlib.axes) – axes of the figure to display the fascicle
myel_color (str) – matplotlib color string applied to the myelinated axons. Red by default
unmyel_color (str) – matplotlib color string applied to the myelinated axons. Blue by default
Myelinated_model (str) – model use for myelinated axon (use to calulated node position)
- remove_axons_electrode_overlap(electrode)[source]
Remove the axons that could overlap an electrode
- Parameters:
electrode (object) – electrode instance, see electrodes for more details
- remove_axons_size_threshold(d, min=True)[source]
Remove fibers with diameters below/above a threshold
- rotate_axons(theta, y_c=0, z_c=0)[source]
Move axons only in a fascicle by group rotation
- Parameters:
theta (float) – angular value of the translation, in rad
y_c (float) – y axis value of the rotation center in um, by default set to 0
z_c (float) – z axis value for the rotation center in um, by default set to 0
- rotate_fascicle(theta, y_c=0, z_c=0)[source]
Rotate a complete fascicle
- Parameters:
theta (float) – angular value of the translation, in rad
y_c (float) – y axis value of the rotation center in um, by default set to 0
z_c (float) – z axis value for the rotation center in um, by default set to 0
- save(fname='fascicle.json', extracel_context=False, intracel_context=False, rec_context=False, save=True, _fasc_save=True, blacklist=[])[source]
Save a fascicle in a json file
- Parameters:
fname (str) – name of the file to save the fascicle
extracel_context (bool) – if True, add the extracellular context to the saving
intracel_context (bool) – if True, add the intracellular context to the saving
rec_context (bool) – if True, add the recording context to the saving
blacklist (list[str]) – key to exclude from saving
save (bool) – if false only return the dictionary
- Returns:
key_dict – Pyhton dictionary containing all the fascicle information
- Return type:
dict
- save_fascicle_configuration(fname, extracel_context=False, intracel_context=False, rec_context=False)[source]
- set_axons_parameters(unmyelinated_only=False, myelinated_only=False, **kwargs)[source]
set parameters of axons in the fascicle
- Parameters:
unmyelinated_only (bool) – if true modification only done for unmyelinated axons parameters, by default False
myelinated_only (bool) – if true modification only done for myelinated axons parameters, by default False
kwargs – parameters to modify (see myelinated and unmyelinated)
- simulate(PostProc_Filtering=None, save_V_mem=False, **kwargs)[source]
Simulates the fascicle using neuron framework. Parallel computing friendly. Does not return results (possibly too large in memory and complex with parallel computing), but instead creates a folder and store fascicle configuration and all axons results. On the fly post processing is possible by specifying an additional script.
- Parameters:
t_sim (float) – total simulation time (ms), by default 20 ms
record_V_mem (bool) – if true, the membrane voltage is recorded, set to True by default
record_I_mem (bool) – if true, the membrane current is recorded, set to False by default
record_I_ions (bool) – if true, the ionic currents are recorded, set to False by default
record_particules (bool) – if true, the marticule states are recorded, set to False by default
loaded_footprints (dict or bool) – Dictionnary composed of axon footprint dictionary, the keys are int value of the corresponding axon ID. if type is bool, fascicle footprints attribute is used if None, footprins calculated during the simulation, by default None
save_V_mem (bool) – if true, all membrane voltages values are stored in results whe basic postprocessing is applied. Can be heavy ! False by default
save_path (str) – name of the folder to store results of the fascicle simulation.
Unmyelinated_model (str) – model for unmyelinated fibers, by default ‘Rattay_Aberham’
Myelinated_model (str) – model for myelinated fibers, by default ‘MRG’
myelinated_seg_per_sec (int) – number of segment per section for myelinated axons
PostProc_Filtering (float, list, array, np.array) – value or iterable values for basic post proc filtering. If None specified, no filtering is performed
postproc_script (str) – path to a postprocessing file. If specified, the basic post processing is not performed, and all postprocessing have to be handled by user. The specified script can access global and local variables. Can also be key word (‘Vmem_plot’ or ‘scarter’) to use script saved in OTF_PP folder, use with caution
return_parameters_only (bool) – if True the results of axon simulations are integrated into fasc_sim return after simulation use with caution: can increase a lot computational memory
save_results (bool) – if False disable the result storage can only be False if return_parameters_only is False
- Returns:
fasc_sim – results of the simulation
- Return type:
sim_results
nrv.nmod.myelinated module
NRV-myelinated Authors: Florian Kolbl / Roland Giraud / Louis Regnacq / Thomas Couppey (c) ETIS - University Cergy-Pontoise - CNRS
- nrv.nmod.myelinated.get_MRG_parameters(diameter)[source]
Compute the MRG parameters
Original parameters are listed and used if the input diameter is in the list, parameters are interpolated if the diameter is not in the original list.
- nrv.nmod.myelinated.diameter
diameter of the unmylinated axon to implement, in um
- Type:
float
- Returns:
g (float)
axonD (float)
nodeD (float)
paraD1 (float)
paraD2 (float)
deltax (float)
paralength2 (float)
nl (float)
- nrv.nmod.myelinated.get_length_from_nodes(diameter, nodes)[source]
Function to compute the length of a myelinated axon to get the correct number of Nodes of Ranvier For Myelinated models only (not compatible with A delta thin myelinated models)
- nrv.nmod.myelinated.diameter
diameter of the axon in um
- Type:
float
- nrv.nmod.myelinated.nodes
number of nodes in the axon
- Type:
int
- Returns:
length – lenth of the axon with the correct number of nodes in um
- Return type:
float
- class nrv.nmod.myelinated.myelinated(y=0, z=0, d=10, L=10000, model='MRG', dt=0.001, node_shift=0, Nseg_per_sec=0, freq=100, freq_min=0, mesh_shape='plateau_sigmoid', alpha_max=0.3, d_lambda=0.1, rec='nodes', v_init=None, T=None, ID=0, threshold=-40, **kwargs)[source]
Bases:
axon
Myelineated axon class. Automatic refinition of all neuron sections and properties. User-friendly object including model definition Inherit from axon class. see axon for further detail.
get the markov model at the end of simulation. For internal use only.
- get_ionic_conductance()[source]
get the ionic channels conductance at the end of simulation. For internal use only.
- get_ionic_current()[source]
get the ionic channels currents at the end of simulation. For internal use only.
- get_membrane_conductance()[source]
get the total membrane conductance at the end of simulation. For internal use only.
- get_membrane_current()[source]
get the membrane current at the end of simulation. For internal use only.
- get_membrane_voltage()[source]
get the membrane voltage at the end of simulation. For internal use only.
- get_particles_values()[source]
get the particules values at the end of simulation. For internal use only.
- insert_I_Clamp(position, t_start, duration, amplitude)[source]
Insert a IC clamp stimulation at the midd point of the nearest node to the specified position
- Parameters:
position (float) – relative position over the axon
t_start (float) – starting time (ms)
duration – duration of the pulse(ms)
amplitude – amplitude of the pulse (nA)
- insert_I_Clamp_node(index, t_start, duration, amplitude)[source]
Insert a IC clamp stimulation on a Ranvier node at its midd point position
- Parameters:
index (int) – node number of the node to stimulate
t_start (float) – starting time (ms)
duration (float) – duration of the pulse(ms)
amplitude (float) – amplitude of the pulse (nA)
- insert_V_Clamp(position, stimulus)[source]
Insert a V clamp stimulation at the midd point of the nearest node to the specified position
- Parameters:
position (float) – relative position over the axon
stimulus (stimulus object) – stimulus for the clamp, see Stimulus.py for more information
- insert_V_Clamp_node(index, stimulus)[source]
Insert a V clamp stimulation
- Parameters:
index (int) – node number of the node to stimulate
stimulus (stimulus object) – stimulus for the clamp, see Stimulus.py for more information
- save(save=False, fname='axon.json', extracel_context=False, intracel_context=False, rec_context=False, blacklist=[])[source]
Return axon as dictionary and eventually save it as json file
- Parameters:
save (bool) – if True, save in json files
fname (str) – Path and Name of the saving file, by default “axon.json”
- Returns:
ax_dic – dictionary containing all information
- Return type:
dict
Change typical particle-Na sodium in Hodgking-Huxley formalism to Markov-channel population model.
- Parameters:
list_of_nodes (list, array, np.array) – list of Nodes of Ranier to modify, if empty, all nodes sodium channels are changed
Note
based on: Yi, G., and Grill, W. M. (2020). Kilohertz waveforms optimized to produce closed-state Na+ channel inactivation eliminate onset response in nerve conduction block. PLoS computational biology, 16(6), e1007766.
!!! TO USE WITH CAUTION !!!
Prepare the markov model recording. For internal use only.
- set_conductance_recorders()[source]
Prepare the ionic channels conductance recording. For internal use only.
- set_ionic_current_recorders()[source]
Prepare the ionic channels current recording. For internal use only.
- set_membrane_current_recorders()[source]
Prepare the membrane current recording. For internal use only.
nrv.nmod.nerve module
NRV-Nerves Authors: Florian Kolbl / Roland Giraud / Louis Regnacq (c) ETIS - University Cergy-Pontoise - CNRS
- class nrv.nmod.nerve.nerve(Length=10000, Diameter=100, Outer_D=5, ID=0, **kwargs)[source]
Bases:
NRV_simulable
- A nerve in NRV is defined as:
a list of fascicles
a list of materials
a kind of extracellular context (analytical or FEM based)
a nerve can be instrumented by adding couples of electrodes+stimulus
- add_fascicle(fascicle, ID=None, y=None, z=None, **kwargs)[source]
Add a fascicle to the list of fascicles
- Parameters:
fascicle (object) – fascicle to add to the nerve struture
- attach_extracellular_recorder(rec: recorder)[source]
attach an extracellular recorder to the axon
- Parameters:
rec (recorder object) – see Recording.recorder help for more details
- attach_extracellular_stimulation(stimulation: FEM_stimulation)[source]
attach a extracellular context of simulation for an axon.
- Parameters:
stimulation (stimulation object, see Extracellular.stimulation help for more details) –
- change_stimulus_from_elecrode(ID_elec, stimulus)[source]
Change the stimulus of the ID_elec electrods
Parameters:
- ID_elecint
ID of the electrode which should be changed
- stimulusstimulus
New stimulus to set
- clear_context(extracel_context=True, intracel_context=True, rec_context=True)[source]
Clear all stimulation and recording mecanism
- define_circular_contour(D, y_c=None, z_c=None, N_vertices=100)[source]
Define a circular countour to the fascicle
- Parameters:
D (float) – diameter of the circular fascicle contour, in um
y_c (float) – y coordinate of the circular contour center, in um
z_c (float) – z coordinate of the circular contour center, in um
N_vertices (int) – Number of vertice in the compute the contour
- define_length(L)[source]
set the length over the x axis of the fascicle
- Parameters:
L (float) – length of the fascicle in um
- fit_circular_contour(y_c=None, z_c=None, Delta=20, N_vertices=100)[source]
Define a circular countour to the fascicle
- Parameters:
y_c (float) – y coordinate of the circular contour center, in um
z_c (float) – z coordinate of the circular contour center, in um
Delta (float) – distance between farest axon and contour, in um
N_vertices (int) – Number of vertice in the compute the contour
- get_axons_parameters(unmyelinated_only=False, myelinated_only=False)[source]
get parameters of axons in the nerve
- Parameters:
unmyelinated_only (bool) – modification will only
myelinated_only (bool) – modification will only
- get_circular_contour()[source]
Returns the properties of the fascicle contour considered as a circle (y and z center and diameter)
- Returns:
D (float) – diameter of the contour, in um. Set to 0 if not applicable
y (float) – y position of the contour center, in um
z (float) – z position of the contour center, in um
- insert_I_Clamp(position, t_start, duration, amplitude, ax_list=None)[source]
Insert a IC clamp stimulation
- Parameters:
position (float) – relative position over the fascicle. Note that all thin myelinated and myelinated will be stimulated in the nearest node of Ranvier around the clamp specified position
t_start (float) – starting time, in ms
duration (float) – duration of the pulse, in ms
amplitude (float) – amplitude of the pulse (nA)
ax_list (list, array, np.array) – list of axons to insert the clamp on, if None, all axons are stimulated
- load(data, extracel_context=False, intracel_context=False, rec_context=False, blacklist=[])[source]
Load a fascicle configuration from a json file
- Parameters:
fname (str) – path to the json file describing a fascicle
extracel_context (bool) – if True, load the extracellular context as well
intracel_context (bool) – if True, load the intracellular context as well
rec_context (bool) – if True, load the recording context as well
blacklist (list[str]) – key to exclude from loading
- plot(fig, axes, contour_color='k', myel_color='r', unmyel_color='b', num=False)[source]
plot the nerve in the Y-Z plane (transverse section)
- Parameters:
fig (matplotlib.figure) – figure to display the fascicle
axes (matplotlib.axes) – axes of the figure to display the fascicle
contour_color (str) – matplotlib color string applied to the contour. Black by default
myel_color (str) – matplotlib color string applied to the myelinated axons. Red by default
unmyel_color (str) – matplotlib color string applied to the myelinated axons. Blue by default
num (bool) – if True, the index of each axon is displayed on top of the circle
- save(fname='nerve.json', extracel_context=False, intracel_context=False, rec_context=False, fascicles_context=True, save=True, _fasc_save=False, blacklist=[])[source]
Save a fascicle in a json file
- Parameters:
fname (str) – name of the file to save the fascicle
extracel_context (bool) – if True, add the extracellular context to the saving
intracel_context (bool) – if True, add the intracellular context to the saving
rec_context (bool) – if True, add the recording context to the saving
fascicles_context (bool) – if True, add the fascicles are fully saved
blacklist (list[str]) – key to exclude from saving
save (bool) – if false only return the dictionary
- Returns:
key_dict – Pyhton dictionary containing all the fascicle information
- Return type:
dict
- set_axons_parameters(unmyelinated_only=False, myelinated_only=False, **kwargs)[source]
set parameters of axons in the fascicle
- Parameters:
unmyelinated_only (bool) – if true modification only done for unmyelinated axons parameters, by default False
myelinated_only (bool) – if true modification only done for myelinated axons parameters, by default False
kwargs – parameters to modify (see myelinated and unmyelinated)
- simulate(**kwargs)[source]
Simulate the nerve with the proposed extracellular context. Top level method for large scale neural simulation.
Warning
calling this method can result in long processing time, even with large computational ressources. Keep aware of what is really implemented, ensure configuration and simulation protocol is correctly designed.
nrv.nmod.thin_myelinated module
nrv.nmod.unmyelinated module
NRV-unmyelinated Authors: Florian Kolbl / Roland Giraud / Louis Regnacq / Thomas Couppey (c) ETIS - University Cergy-Pontoise - CNRS
- class nrv.nmod.unmyelinated.unmyelinated(y=0, z=0, d=1, L=1000, model='Rattay_Aberham', dt=0.001, Nrec=0, Nsec=1, Nseg_per_sec=0, freq=100, freq_min=0, mesh_shape='plateau_sigmoid', alpha_max=0.3, d_lambda=0.1, v_init=None, T=None, ID=0, threshold=-40, **kwarks)[source]
Bases:
axon
Unmyelineated axon class. Automatic refinition of all neuron sections and properties. User-friendly object including model definition Inherit from axon class. see axon for further detail.
- get_ionic_conductance()[source]
get the membrane conductance at the end of simulation. For internal use only. NB: [S/cm^{2}] (see Neuron unit)
- get_ionic_current()[source]
get the ionic currents at the end of simulation. For internal use only.
- get_membrane_conductance()[source]
get the membrane voltage at the end of simulation. For internal use only. NB: [S/cm^{2}] (see Neuron unit)
- get_membrane_current()[source]
get the membrane current at the end of simulation. For internal use only.
- get_membrane_voltage()[source]
get the membrane voltage at the end of simulation. For internal use only.
- get_particles_values()[source]
get the particules values at the end of simulation. For internal use only.
- insert_I_Clamp(position, t_start, duration, amplitude)[source]
Insert a I clamp stimulation
- Parameters:
position (float) – relative position over the axon
t_start (float) – starting time, in ms
duration (float) – duration of the pulse, in ms
amplitude (float) – amplitude of the pulse (nA)
- insert_V_Clamp(position, stimulus)[source]
Insert a V clamp stimulation
- Parameters:
position (float) – relative position over the axon
stimulus (stimulus object) – stimulus for the clamp, see Stimulus.py for more information
- save(save=False, fname='axon.json', extracel_context=False, intracel_context=False, rec_context=False, blacklist=[])[source]
Return axon as dictionary and eventually save it as json file
- Parameters:
save (bool) – if True, save in json files
fname (str) – Path and Name of the saving file, by default “axon.json”
- Returns:
ax_dic – dictionary containing all information
- Return type:
dict
- set_conductance_recorders()[source]
Prepare the membrane conductance recording. For internal use only.
- set_membrane_current_recorders()[source]
Prepare the membrane current recording. For internal use only.
Module contents
NeuRon Virtualizer, large scale modeling of Peripheral Nervous System with random stimulation waveforms