Abstract Trees¶
Basic tree¶
-
class
STree
(root=None)[source]¶ A simple tree for use with a simple Node (neat.SNode).
Generic implementation of a tree structure as a linked list extended with some convenience functions
- Parameters
root (neat.SNode, optional) – The root of the tree, default is
None
which creates an empty tree- Variables
root (neat.SNode) – The root of the tree
|
Returns the node with given index, if no such node is in the tree, None is returned. |
|
Return the number of nodes in the tree. |
|
Iterate over the nodes in the subtree of the given node. |
|
Generate a string of the subtree of the given node. |
|
Fill the |
Check if the indices of the tree are number in the same order as they appear in the iterator |
|
|
Build a list of all the nodes in the tree |
Build a list of all the nodes in the tree |
|
|
Build a list of all the nodes in the subtree of the provided node |
|
Get all leaf nodes in the tree. |
Get all leaf nodes in the tree. |
|
|
Check if input node is a leaf of the tree |
|
Check if input node is root of the tree. |
|
Create a node with the given index and add it to the tree under a specific parent node. |
|
Add a node to the tree under a specific parent node |
|
Remove a node and its subtree from the tree by deleting the reference to it in its parent. |
|
Remove a node as well as its subtree from the tree |
|
Remove a single node from the tree. |
|
Insert a node in the tree as a child of a specified parent. |
|
Resets the indices in the order they appear in a depth-first iteration |
|
Get the subtree of the specified node. |
|
compute the depth of the node (number of edges between node and root) |
|
Compute the degree (number of leafs in its subtree) of a node. |
|
Compute the order (number of bifurcations from the root) of a node. |
|
Return the path from a given node to the root |
|
Inclusive path from |
|
Inclusive path from |
|
Returns the nodes in the subtree that contains the given reference nodes and has the given subtree root as root. |
|
Find the leafs that are in the subtree of the nearest bifurcation node up from the input node. |
|
Find the nearest bifurcation node up (towards root) from the input node. |
Find the nearest bifurcation node down (towards leafs) from the input node. |
|
|
Get the bifurcation nodes in bewteen the provided input nodes |
|
Find the nearest neighbours of |
|
Fill the |
-
class
SNode
(index)[source]¶ Simple Node for use with a simple Tree (neat.STree)
- Parameters
index (int) – index of the node
- Variables
index (int) – index of the node
parent_node (neat.SNode or
None
) – parent of node,None
means node is rootchild_nodes (list of neat.SNode) – child nodes of
self
, empty list means node is leafcontent (dict) – arbitrary items can be stored at the node
Compartment Tree¶
-
class
CompartmentTree
(root=None)[source]¶ Abstract tree that implements physiological parameters for reduced compartmental models. Also implements the matrix algebra to fit physiological parameters to impedance matrices
|
Add an ion channel current to the tree |
Set the choice for the state variables of the ion channel around which to linearize. |
|
|
Set the equilibrium potential at all nodes on the compartment tree |
|
Get the equilibrium potentials at each node. |
Fit the leak reversal potential to obtain the stored equilibirum potentials as resting membrane potential |
|
Get list of fake locations in the same order as original list of locations to which the compartment tree was fitted. |
|
|
Constructs the impedance matrix of the model for each frequency provided in freqs. |
|
Constructs the conductance matrix of the model |
|
Constructs the matrix of conductance and capacitance terms of the model for each frequency provided in |
|
Calculates the eigenvalues and eigenvectors of the passive system |
|
Fit the models’ membrane and coupling conductances to a given steady state impedance matrix. |
Fit the conductances of multiple channels from the given impedance matrices, or store the feature matrix and target vector for later use (see action). |
|
Fit the conductances of a single channel from the given impedance matrices, or store the feature matrix and target vector for later use (see action). |
|
|
Fit the capacitances to the eigenmode expansion |
Delete all stored feature matrices and and target vectors. |
|
Run a linear least squares fit for the conductances concentration mechanisms. |
|
Computes a fake geometry so that the neuron model is a reduced compurtmental model |
|
|
Generate a dendrogram of the NET |
-
class
CompartmentNode
(index, loc_ind=None, ca=1.0, g_c=0.0, g_l=0.01, e_eq=- 75.0)[source]¶ Implements a node for CompartmentTree
- Variables
ca (float) – capacitance of the compartment (uF)
g_l (float) – leak conductance at the compartment (uS)
g_c (float) – Coupling conductance of compartment with parent compartment (uS). Ignore if node is the root
e_eq (float) – equilibrium potential at the compartment
currents (dict {str: [g_bar, e_rev]}) – dictionary with as keys the channel names and as elements lists of length two with contain the maximal conductance (uS) and the channels’ reversal potential in (mV)
concmechs (dict {str: neat.channels.concmechs.ConcMech}) – dictionary with as keys the ion names and as values the concentration mechanisms governing the concentration of each ion channel
expansion_points (dict {str: np.ndarray}) – dictionary with as keys the channel names and as elements the state variables of the ion channel around which to compute the linearizations
Neural Evaluation Tree¶
-
class
NET
(root=None)[source]¶ Abstract tree class that implements the Neural Evaluation Tree (Wybo et al., 2019), representing the spatial voltage as a number of voltage components present at different spatial scales.
|
Get the indices of the locations a subtree integrates |
|
Get the node for which |
Set the new location indices in a tree |
|
|
Construct a reduced tree where only the locations index by ``loc_inds’’ are retained |
|
Compute the total impedance associated with a node. |
|
compute I_Z between any pair of locations in |
compute the Iz matrix for all locations present in the tree |
|
Compute the impedance matrix approximation associated with the NET |
|
Compute the impedance matrix approximation associated with the NET |
|
|
Returns a compartmentalization for the NET tree where each pair of compartments is separated by an Iz of at least |
|
Generate a dendrogram of the NET |
-
class
NETNode
(index, loc_inds, newloc_inds=[], z_kernel=None)[source]¶ Node associated with neat.NET.
- Variables
loc_inds (list of int) – The inidices of locations which the node integrates
newloc_inds (list of int) – The locations for which the node is the most local component to integrate them
z_kernel (neat.Kernel) – The impedance kernel with which the node integrates inputs
z_bar (float) – The steady state impedance associated with the impedance kernel
-
class
Kernel
(kernel)[source]¶ Implements a kernel as a superposition of exponentials:
\[k(t) = \sum_n c_n e^{ - a_n t}\]Kernels can be added and subtracted, as this class overloads the __add__ and __subtract__ functions.
They can be evaluated as a function of time by calling the object with a time array.
They can be evaluated in the Fourrier domain with Kernel.ft
- Parameters
kernel (dict, float, neat.Kernel, tuple or list) – If dict, has the form {‘a’: np.array, ‘c’: np.array}. If float, sets c single exponential prefactor and assumes a is 1 kHz. If neat.Kernel, copies the object. If tuple or list, sets ‘a’ as first element and ‘c’ as last element.
- Variables
a (np.array of float or complex) – The exponential coefficients (kHz)
c (np.array of float or complex) – The exponential prefactors
The total surface under the kernel |
|
|
Evaluates the kernel in the time domain |
|
Evaluates the kernel in the Fourrier domain |
Simulate reduced compartmental models¶
-
class
NeuronCompartmentTree
(t_calibrate=0.0, dt=0.025, v_init=- 75.0)[source]¶ Subclass of NeuronSimTree where sections are defined so that they are effectively single compartments. Should be created from a neat.CompartmentTree using neat.createReducedCompartmentModel()
-
createReducedNeuronModel
(ctree, fake_c_m=1.0, fake_r_a=9.999999999999999e-05, method=2)[source]¶ Creates a neat.NeuronCompartmentTree to simulate reduced compartmentment models from a neat.CompartmentTree.
- Parameters
ctree (neat.CompartmentTree) – The tree containing the parameters of the reduced compartmental model to be simulated
- Returns
- Return type
neat.NeuronCompartmentTree
Notes
The function ctree.getEquivalentLocs() can be used to obtain ‘fake’ locations corresponding to each compartment, which in turn can be used to insert hoc point process at the compartments using the same functions definitions as for as for a morphological neat.NeuronSimTree
Morphological Trees¶
Morphology Tree¶
-
class
MorphTree
(file_n=None, types=[1, 3, 4])[source]¶ Subclass of simple tree that implements neuronal morphologies. Reads in trees from ‘.swc’ files (http://neuromorpho.org/).
Neural morphologies are assumed to follow the three-point soma conventions. Internally however, the soma is represented as a sphere. Hence nodes with indices 2 and 3 do not represent anything and are skipped in iterations and getters.
Can also store a simplified version of the original tree, where only nodes are retained that should hold computational parameters - the root, the bifurcation nodes and the leafs at least, although the user can also specify additional nodes. One tree is set as primary by changing the treetype attribute (select ‘original’ for the original morphology and ‘computational’ for the computational morphology). Lookup operations will often use the primary tree. Using nodes from the other tree for lookup operations is unsafe and should be avoided, it is better to set the proper tree to primary first.
For computational efficiency, it is possible to store sets of locations on the morphology, under user-specified names. These sets are stored as lists of neat.MorphLoc, and associated arrays are stored that contain the corresponding node indices of the locations, their x-coordinates, their distances to the soma and their distances to the nearest bifurcation in the ‘up’-direction
- Parameters
file_n (str (optional)) – the file name of the morphology file. Assumed to follow the ‘.swc’ format. Default is
None
, which initialized an empty treetypes (list of int (optional)) – The list of node types to be included. As per the ‘.swc’ convention,
1
is soma,2
is axon,3
is basal dendrite and4
apical dendrite. Default is[1,3,4]
.
- Variables
root (neat.MorphNode instance) – The root of the tree.
locs (dict {str: list of neat.MorphLoc}) – Stored sets of locations, key is the user-specified the name of the set of locations. Initialized as empty dict.
nids (dict {str: np.array of int}) – Node indices of locations Initialized as empty dict.
xs (dict {str: np.array of float}) – x-coordinates of locations Initialized as empty dict.
d2s (dict {str: np.array of float}) – distances to soma of locations Initialized as empty dict.
d2b (dict {str: np.array of float}) – distances to nearest bifurcation in ‘up’ direction of locations. Initialized as empty dict.
Read a morphology from an SWC file
|
Non-specific for a “tree data structure” Read and load a morphology from an SWC file and parse it into an neat.MorphTree object. |
|
Determine the soma type used in the SWC file. |
|
Returns the node with given index, if no such node is in the tree, None is returned. |
|
Overloaded iterator from parent class that avoids iterating over the nodes with index 2 and 3 |
Get specific nodes or sets of nodes from the tree.
Returns the root of the original or the computational tree, depending on which treetype is active. |
|
|
Overloads the parent function to allow skipping nodes with certain indices and to return the nodes associated with the corresponding treetype. |
Overloads the parent function to allow skipping nodes with certain indices and to return the nodes associated with the corresponding treetype. |
|
|
Overloads the getLeafs of the parent class to return the leafs in the current treetype. |
Overloads the getLeafs of the parent class to return the leafs in the current treetype. |
|
Return the nodes associated with the basal subtree |
|
Return the nodes associated with the apical subtree |
|
Return the nodes associated with the apical subtree |
|
|
Converts a node argument to a list of nodes. |
Relating to the computational tree.
|
Set the active tree |
|
Non-specific for a “tree data structure” Read and load a morphology from an SWC file and parse it into an neat.MorphTree object. |
|
Sets the nodes that contain computational parameters. |
|
Return |
Removes the computational tree |
Storing locations, interacting with stored locations and distributing locations
|
Converts locations argument to list of neat.MorphLoc. |
|
Store locations under a specified name |
|
Add location to set of locations of given name |
Remove all set of locs stored in the tree |
|
|
Remove a set of locations of a given name |
|
Tests if the name is in use. |
|
Returns a set of locations of a specified name |
|
Returns an array of node indices of locations of a specified name |
|
Returns an array of x-values of locations of a specified name |
|
Returns a list of the indices of locations in the list of a given name that are on a the input node, ordered for increasing x |
|
Returns a list of the indices of locations in the list of a given name that are on one of the nodes specified in the node list. |
|
Returns a list of the indices of locations in the list of a given name that are on the given path. |
|
For each location in the input location list, find the index of the closest location in a set of locations stored under a given name. |
|
Search nearest neighbours to loc in locarg. |
|
Find the indices in the desire location list that are ‘leafs’, i.e. locations for which no other location exist that is farther from the root. |
|
Compute the distance of each location in a given set to the soma |
|
Compute the distance of each location to the nearest bifurcation in the ‘up’ direction (towards root) |
|
Distributes locs on a given set of nodes at specified distances from the soma. |
|
Distributes locations as uniform as possible, i.e. for a given distance between locations dx, locations are distributed equidistantly on each given node in the computational tree and their amount is computed so that the distance in between them is as close to dx as possible. |
|
Returns a list of input locations randomly distributed on the tree |
|
Extends input loc_arg with the intermediate bifurcations. |
|
Gets the unique locations in the provided locs |
|
Find the length of the direct path between loc1 and loc2 |
Plotting on a 1D axis.
|
Create a set of locs suitable for serving as the x-axis for 1D plotting. |
|
Set the color code for the nodes for 1D plotting |
|
Get the corresponding location on the x-axis of the input locations |
|
Plot an array where each element corresponds to the matching location on the x-axis with a depth-first ordering on a 1D plot |
|
Plot an array where each element corresponds to the matching location in the x-axis location list. |
|
Color the x-axis of a plot according to the morphology. |
Plotting the morphology in 2D.
|
Plot the morphology projected on the x,y-plane |
Show the morphology either in 3d or projected on the x,y-plane. |
Creating new trees from the existing tree.
|
Creates a new tree where the locs of a given ‘name’ are now the nodes. |
|
Creates a new compartment tree where the provided set of locations correspond to the nodes. |
|
Fill the |
-
class
MorphNode
(index, p3d=None)[source]¶ Node associated with neat.MorphTree. Stores the geometrical information associated with a point on the tree morphology
- Variables
xyz (numpy.array of floats) – The xyz-coordinates associated with the node (um)
R (float) – The radius of the node (um)
swc_type (int) – The type of node, according to the .swc file format convention:
1
is dendrites,2
is axon,3
is basal dendrite and4
is apical dendrite.L (float) – The length of the node (um)
|
Set the 3d parameters of the node |
Get the child_nodes of this node. |
-
class
MorphLoc
(loc, reftree, set_as_comploc=False)[source]¶ Stores a location on the morphology. The location is initialized starting from a node and x-value on the real morphology. The location is also be stored in the coordinates of the computational morphology. To toggle between coordinates, the class stores a reference to the morphology tree on which the location is defined, and returns either the original coordinate or the coordinate on the computational tree, depending on which tree is active.
Initialized based on either a tuple or a dict where one entry specifies the node index and the other entry the x-coordinate specifying the location between parent node (x=0) or the node indicated by the index (x=1), or on a neat.MorphLoc.
- Parameters
loc (tuple or dict or neat.MorphLoc) – if tuple: (node index, x-value) if dict: {‘node’: node index, ‘x’: x-value}
reftree (neat.MorphTree) –
set_as_comploc (bool) – if True, assumes the paremeters provided in loc are coordinates on the computational tree. Doing this while no computational tree has been initialized in reftree will result in an error. Defaults to False
- Raises
ValueError – If x-coordinate of location is not in
[0,1]
Physiology Tree¶
-
class
PhysTree
(file_n=None, types=[1, 3, 4])[source]¶ Adds physiological parameters to neat.MorphTree and convenience functions to set them across the morphology. Initialized in the same way as neat.MorphTree
- Variables
channel_storage (dict {str: neat.IonChannel}) – Stores the user defined ion channels present in the tree
|
Makes the membrane act as a passive membrane (for the nodes in |
|
Set the equilibrium potentials throughout the tree |
|
Set specifice membrane capacitance, axial resistance and (optionally) static point-like shunt conductances in the tree. |
|
Set the parameters of the leak current. |
|
Adds a channel to the morphology. |
|
Returns list of strings of all channel names in the tree |
|
Fits the leak current to fix equilibrium potential and membrane time- scale. |
|
Return |
-
class
PhysNode
(index, p3d=None, c_m=1.0, r_a=9.999999999999999e-05, g_shunt=0.0, e_eq=- 75.0)[source]¶ Node associated with neat.PhysTree. Stores the physiological parameters of the cylindrical segment connecting this node with its parent node
- Variables
currents (dict {str: [float,float]}) – dict with as keys the channel names and as values lists of length two containing as first entry the channels’ conductance density (uS/cm^2) and as second element the channels reversal (mV) (i.e.: {name: [g_max (uS/cm^2), e_rev (mV)]}) For the leak conductance, the corresponding key is ‘L’
concmechs (dict) – dict containing concentration mechanisms present in the segment
c_m (float) – The sement’s specific membrane capacitance (uF/cm^2)
r_a (float) – The segment’s axial resistance (MOhm*cm)
g_shunt (float) – Point-like shunt conductance located at x=1 (uS)
e_eq (float) – Segment’s equilibrium potential
Separation of Variables Tree¶
-
class
SOVTree
(file_n=None, types=[1, 3, 4])[source]¶ Class that computes the separation of variables time scales and spatial mode functions for a given morphology and electrical parameter set. Employs the algorithm by (Major, 1994). This three defines a special neat.SomaSOVNode on as a derived class from neat.SOVNode as some functions required for SOV calculation are different and thus overwritten.
The SOV calculation proceeds on the computational tree (see docstring of neat.MorphNode). Thus it makes no sense to look for sov quantities in the original tree.
|
Calculate the timescales and spatial functions of the separation of variables approach, using the algorithm by (Major, 1993). |
|
Gives the overal importance of the SOV modes for a certain set of locations |
|
Returns the most importand eigenmodes (those whose importance is above the threshold defined by eps) |
|
Compute the impedance matrix for a set of locations |
|
Construct a Neural Evaluation Tree (NET) for this cell |
|
Construct linear terms for net so that transfer impedance to soma is exactly matched |
Greens Tree¶
-
class
GreensTree
(file_n=None, types=[1, 3, 4])[source]¶ Class that computes the Green’s function in the Fourrier domain of a given neuronal morphology (Koch, 1985). This three defines a special neat.SomaGreensNode as a derived class from neat.GreensNode as some functions required for Green’s function calculation are different and thus overwritten.
The calculation proceeds on the computational tree (see docstring of neat.MorphNode). Thus it makes no sense to look for Green’s function related quantities in the original tree.
- Variables
freqs (np.array of complex) – Frequencies at which impedances are evaluated
[Hz]
Remove expansion points from all nodes in the tree |
|
|
Set the boundary impedances for each node in the tree |
|
Computes the transfer impedance between two locations for all frequencies in self.freqs. |
|
Computes the impedance matrix of a given set of locations for each frequency stored in self.freqs. |
-
class
GreensNode
(index, p3d)[source]¶ Node that stores quantities and defines functions to implement the impedance matrix calculation based on Koch’s algorithm (Koch & Poggio, 1985).
- Variables
expansion_points (dict {str: np.ndarray}) – Stores ion channel expansion points for this segment.
|
Set the choice for the state variables of the ion channel around which to linearize. |
Simulate NEURON models¶
-
class
NeuronSimTree
(file_n=None, types=[1, 3, 4], factor_lambda=1.0, t_calibrate=0.0, dt=0.025, v_init=- 75.0)[source]¶ Tree class to define NEURON (Carnevale & Hines, 2004) based on neat.PhysTree.
- Variables
sections (dict of hoc sections) – Storage for hoc sections. Keys are node indices.
shunts (list of hoc mechanisms) – Storage container for shunts
syns (list of hoc mechanisms) – Storage container for synapses
iclamps (list of hoc mechanisms) – Storage container for current clamps
vclamps (lis of hoc mechanisms) – Storage container for voltage clamps
vecstims (list of hoc mechanisms) – Storage container for vecstim objects
netcons (list of hoc mechanisms) – Storage container for netcon objects
vecs (list of hoc vectors) – Storage container for hoc spike vectors
dt (float) – timestep of the simulator
[ms]
t_calibrate (float) – Time for the model to equilibrate``[ms]``. Not counted as part of the simulation.
factor_lambda (int or float) – If int, the number of segments per section. If float, multiplies the number of segments given by the standard lambda rule (Carnevale, 2004) to give the number of compartments simulated (default value 1. gives the number given by the lambda rule)
v_init (float) – The initial voltage at which the model is initialized
[mV]
NeuronSimTree can be extended easily with custom point process mechanisms. (A) –
make sure that you store the point process in an existing appropriate (Just) –
container or in a custom storage container, since if all references (storage) –
the hocobject disappear, the object itself will be deleted as well. (to) –
code-block: (.) –
python: class CustomSimTree(NeuronSimTree): def addCustomPointProcessMech(self, loc, **kwargs):
loc = MorphLoc(loc, self)
# create the point process pp = h.custom_point_process(self.sections[loc[‘node’]](loc[‘x’])) pp.arg1 = kwargs[‘arg1’] pp.arg2 = kwargs[‘arg2’] …
self.storage_container_for_point_process.append(pp)
you define a custom storage container, make sure that you overwrite the (If) –
and deleteModel() functions to make sure it is created and (`__init__()`) –
properly. (deleted) –
|
Initialize hoc-objects to simulate the neuron model implemented by this tree. |
Delete all stored hoc-objects |
|
|
Adds a static conductance at a given location |
|
Adds a double exponential input current at a given location |
|
Adds a single-exponential conductance-based synapse |
|
Adds a double-exponential conductance-based synapse |
|
Adds a single-exponential conductance-based synapse with an AMPA and an NMDA component |
Adds a double-exponential conductance-based synapse with an AMPA and an NMDA component |
|
|
Injects a DC current step at a given lcoation |
|
Injects a sinusoidal current at a given lcoation |
|
Injects a Ornstein-Uhlenbeck current at a given lcoation |
|
Injects a Ornstein-Uhlenbeck conductance at a given location |
|
|
|
Adds a voltage clamp at a given location |
|
Each hoc point process that receive spikes through should by appended to the synapse stack (stored under the list self.syns). |
|
Run the NEURON simulation. |
|
Compute the equilibrium potentials in the middle ( |
Other Classes¶
Fitting reduced models¶
-
class
CompartmentFitter
(phys_tree, e_hs=array([- 75.0, - 55.0, - 35.0, - 15.0]), freqs=array([0.0]), name='dont save', path='')[source]¶ Helper class to streamline fitting reduced compartmental models
- Variables
tree (neat.PhysTree()) – The full tree based on which reductions are made
e_hs (np.array of float) – The holding potentials for which quasi active expansions are computed
freqs (np.array of float or complex (default is
np.array([0.])
)) – The frequencies at which impedance matrices are evaluatedname (str (default 'dont save')) – name of files in which intermediate trees required for the fit are stored. Details about what is in the actual pickle files are appended as a suffix to name. Default is to not store intermediate files.
path (str (default '')) – specify a path under which the intermediate files are saved (only if name is specified). Default is empty string, which means that intermediate files are stored in the working directory.
To implement the default methodology.
|
Store an initial neat.CompartmentTree, providing a tree structure scaffold for the fit for a given set of locations. |
|
Runs the full fit for a set of locations (the location are automatically extended with the bifurcation locs) |
To check the faithfullness of the passive reduction, the following functions implement vizualisation of impedance kernels.
|
Checks the impedance kernels of the passive model. |
|
Returns the impedance kernels as a double nested list of “neat.Kernel”. |
|
Plots the impedance kernels. |
Individual fit functions.
|
Create a FitTreeGF copy of the old tree, but only with the channels in |
Create a SOVTree copy of the old tree |
|
Fit leak only. |
|
Fit the steady state passive model, consisting only of leak and coupling conductances, but ensure that the coupling conductances takes the passive opening of all channels into account |
|
|
Evaluate the impedance matrix for the model restricted to a single ion channel type. |
|
Fit the active ion channel parameters |
|
Fit the capacitances of the model to the largest SOV time scale |
|
Set equilibrium potentials, measured from neuron simulation. |
|
Get equilibrium potentials. |
|
Fits the leak potentials of the reduced model to yield the same equilibrium potentials as the full model |
|
Computes the rescaled conductances when synapses are moved to compartment locations, assuming a given average conductance for each synapse. |
Defining ion channels¶
-
class
IonChannel
[source]¶ Base ion channel class that implements linearization and code generation for NEURON (.mod-files) and C++.
Userdefined ion channels should inherit from this class and implement the define() function, where the specific attributes of the ion channel are set.
The ion channel current is of the form
\[i_{chan} = \overline{g} \, p_o(x_1, ... , x_n) \, (e - v)\]where \(p_o\) is the open probability defined as a function of a number of state variables. State variables evolve according to
\[\dot{x}_i = f_i(x_i, v, c_1, ..., c_k)\]with \(c_1, ..., c_n\) the (optional) set of concentrations the ion channel depends on. There are two canonical ways to define \(f_i\), either based on reaction rates \(\alpha\) and \(\beta\):
\[\dot{x}_i = \alpha_i(v) \, (1 - x_i) - \beta_i(v) \, x_i,\]or based on an asymptotic value \(x_i^{\infty}\) and time-scale \(\tau_i\)
\[\dot{x}_i = \frac{x_i^{\infty}(v) - x_i}{\tau_i(v)}.\]IonChannel accepts handles either description. For the former description, dicts self.alpha and self.beta must be defined with as keys the names of every state variable in the open probability. Similarly, for the latter description, dicts self.tauinf and self.varinf must be defined with as keys the name of every state variable.
The user must define the attributes p_open, and either alpha and beta or tauinf and varinf in the define() function. The other attributes ion, conc, q10, temp, and e are optional.
- Parameters
p_open (str) – The open probability of the ion channel.
alpha (dict {str: str}) – dictionary of the rate function for each state variables. Keys must correspond to the name of every state variable in p_open, values must be formulas written as strings with v and possible ion as variabels
beta (dict {str: str}) – dictionary of the rate function for each state variables. Keys must correspond to the name of every state variable in p_open, values must be formulas written as strings with v and possible ion as variabels
tauinf (dict {str: str}) – state variable time scale and asymptotic activation level. Keys must correspond to the name of every state variable in p_open, values must be formulas written as strings with v and possible ion as variabels
varinf (dict {str: str}) – state variable time scale and asymptotic activation level. Keys must correspond to the name of every state variable in p_open, values must be formulas written as strings with v and possible ion as variabels
ion (str ('na', 'ca', 'k' or ''), optional) – The ion to which the ion channel is permeable
conc (set of str (containing 'na', 'ca', 'k') or dict of {str: float}) – The concentrations the ion channel activation depends on. Can be a set of ions or a dict with the ions as keys and default values as float.
q10 (str, optional) – Temperature dependence of the state variable rate functions. May be a float or a string convertible to a sympy expression containing the temp parameter (temperature in
[deg C]
). This factor divides the time-scales :math:` au_i(v)` of the ion channel. If not given, default is 1.temp (float, optional) – The temperature at which the ion channel is evaluated. Can be modified after initializiation by calling IonChannel.setDefaultParams(temp=new_temperature). If not given, the evaluates self.q10 at the default temperature of 36 degC.
e (float, optional) – Reversal of the ion channel in
[mV]
. functions that need it allow the default value to be overwritten with a keyword argument. If nothing is provided, will take a default reversal for self.ion (which is -85 mV for ‘K’, 50 mV for ‘Na’ and 50 mV for ‘Ca’). If no ion is provided, errors will occur if functions that need e are called without specifying the value as a keyword argument.
Examples
>>> class Na_Ta(IonChannel): >>> def define(self): >>> # from (Colbert and Pan, 2002), Used in (Hay, 2011) >>> self.ion = 'na' >>> # concentrations the ion channel depends on >>> self.conc = {} >>> # define channel open probability >>> self.p_open = 'h * m ** 3' >>> # define activation functions >>> self.alpha, self.beta = {}, {} >>> self.alpha['m'] = '0.182 * (v + 38.) / (1. - exp(-(v + 38.) / 6.))' # 1/ms >>> self.beta['m'] = '-0.124 * (v + 38.) / (1. - exp( (v + 38.) / 6.))' # 1/ms >>> self.alpha['h'] = '-0.015 * (v + 66.) / (1. - exp( (v + 66.) / 6.))' # 1/ms >>> self.beta['h'] = '0.015 * (v + 66.) / (1. - exp(-(v + 66.) / 6.))' # 1/ms >>> # temperature factor for reaction rates >>> self.q10 = '2.3^((temp - 23.)/10.)'
|
**kwargs |
|
Compute the open probability of the ion channel |
|
Compute: (i) the derivatives of the open probability to the state variables (ii) The derivatives of state functions to the voltage (iii) The derivatives of state functions to the state variables |
|
Compute the derivatives of the state functions to the concentrations |
Compute the asymptotic values for the state variables at a given activation level |
|
Compute the time-scales for the state variables at a given activation level |
|
|
Combute the contributions of the state variables to the linearized channel current |
|
Combute the contributions of the state variables to the linearized channel current |
|
Combute the linearized channel current contribution (without concentributions from the concentration - see computeLinConc()) |
|
Combute the linearized channel current contribution from the concentrations |
Neural evaluation tree simulator¶
Compute Fourrier transforms¶
-
class
FourrierTools
(tarr, fmax=7, base=10, num=200)[source]¶ Performs an accurate Fourrier transform on functions evaluated at a given array of temporal grid points
- Parameters
tarr (np.array of floats,) – the time points (ms) at which the function is evaluated, have to be regularly spaced
fmax (float, optional (default
7.
)) – the maximum value to which the logarithm is evaluated to get the maximum evaluation frequencybase (float, optional (defaul
10
)) – the base of the logarithm used to generated the logspacenum (int, even, optional (default
200
)) – Number of points. the eventual number of points in frequency space is (2+1/2)*num
- Variables
s (np.array of complex) – The frequencies at which input arrays in the Fourrier domain are supposed to be evaluated
t (np.array of real) – The time array at which input arrays in the time domain are supposed to be evaluated
ind_0s (int) – Index of the zero frequency component in self.s
Evaluate the Fourrier transform of arr |
|
|
Evaluate the Fourrier transform of arr |
|
Evaluate the inverse Fourrier transform of arr |