Abstract Trees¶
Basic tree¶
- class STree(arg=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:
arg (neat.SNode or subclass, neat.STree or subclass, or
None) – When arg is a neat.SNode, it specifies the root of the tree. When arg is a neat.STree, it constructs a deep copy of the provided tree. Default isNone, which creates an empty tree.- Variables:
root (neat.SNode) – The root of the tree
nodes (list of neat.SNode) – The nodes in the tree
leafs (list of neat.SNode) – The leaf nodes in 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 |
|
Generate a representation string of the subtree of the given node. |
Generates an integer hash with that standard python hash function applied to the representation string |
|
Generates a hexadecimal hash based on the hashlib sha25 algorithm applied to the representation string |
|
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. |
|
Creates a node with the given index corresponding to the tree class. |
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 on the path from input node to root. |
|
Find the nearest bifurcation node towards root from the input node. |
Find the nearest bifurcation node towards leaf from the input node. |
|
Get the bifurcation nodes in bewteen the provided input nodes |
|
|
Find the nearest neighbours of |
Compartment Tree¶
- class CompartmentTree(arg=None)[source]¶
Abstract tree that implements physiological parameters for reduced compartmental models. Also implements the matrix algebra to fit physiological parameters to impedance matrices
- Variables:
channel_storage (dict {str: neat.IonChannel}) – Stores the user defined ion channels present in the tree
Creates a node with the given index corresponding to the tree class. |
|
find the nodes that correspond(s) to a (list of) location index (indices) |
|
Returns index array for the permutation of location indices to tree indices |
|
Return an index array that can be used to permute matrices that follow to tree order to the location list order |
|
Get list of fake locations in the same order as original list of locations to which the compartment tree was fitted. |
|
|
Add an ion channel current to the tree |
|
Add a concentration mechanism 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. |
|
Set the equilibrium concentrations at all nodes in the compartment tree |
|
Get the equilibrium concentrations of 'ion' at each node. |
Fit the leak reversal potential to obtain the stored equilibirum potentials as resting membrane potential |
|
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 compartmental model |
|
|
Generate a dendrogram of the NET |
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.
|
Creates a node with the given index corresponding to the tree class. |
|
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_idxs'' 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_idxs, newloc_idxs=[], z_kernel=None)[source]¶
Node associated with neat.NET.
- Variables:
loc_idxs (list of int) – The inidices of locations which the node integrates
newloc_idxs (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
k_bar (float) – The total surface area under the kernel
The total surface under the kernel |
|
|
Evaluates the kernel in the time domain |
|
Evaluates the kernel in the Fourrier domain |
Morphological Trees¶
Morphology Tree¶
- class MorphTree(arg=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 convention. 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.
The MorphTree can also store a simplified version of the original tree, where only nodes are retained that should hold computational parameters, i.e. the root, the bifurcation nodes and the leafs at least, although the user can also specify additional nodes. By default, the active tree is the original one, where nodes correspond to the underlying ‘.swc’ file. Trough the MorphTree.as_computational_tree context, the computational tree can be accessed.
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 in the direction of the soma.
- Parameters:
arg (str (optional), neat.MorphNode or subclass, or neat.MorphTree or subclass, or
None) –If str, represents the file path of the morphology file.
Assumed to follow the ‘.swc’ format. - If neat.MorphNode or derived class, initializes a the tree with the provided node as root. - If neat.MorphTree or derived class, initialized a copy of the provided tree. - 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,
1is soma,2is axon,3is basal dendrite and4apical 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 the direction of the soma 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. |
Note that in the ‘.swc’ format, nodes 2 and 3 contain extra information on the soma geometry. By default, these nodes are skipped in the neat.MorphTree iteration and getitem functions.
|
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 |
|
Fill the |
Resets the indices in the order they appear in a depth-first iteration |
Get specific nodes or sets of nodes from the tree.
|
Creates a node with the given index corresponding to the tree class. |
|
Overloads the parent function to allow skipping nodes with certain indices and to return the nodes associated with the corresponding active tree. |
Overloads the parent function to allow skipping nodes with certain indices and to return the nodes associated with the corresponding active tree. |
|
|
Overloads the get_leafs of the parent class to return the leaf nodes in the corresponding active tree. |
Overloads the get_leafs of the parent class to return the leaf nodes in the corresponding active tree. |
|
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 either the 'original' or 'computatianal' tree as the default one. |
Context manager that ensures the computational tree is active |
|
Context manager that ensures the original tree is active |
|
check whether the computational tree is active |
|
|
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 loc_arg. |
|
|
Find the indices in the location list specified stored under name 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 to the soma ('d2s'). |
|
Distributes locations as uniformly, 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 provided location in loc_arg 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:
1is dendrites,2is axon,3is basal dendrite and4is 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(arg=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
Functions for setting ion channels densities are applied to the original tree, which can cause the computational tree to be out of sync. To avoid this, the computational tree is always removed by these functions. It can be set afterwards with PhysTree.set_comp_tree()
- Variables:
channel_storage (dict {str: neat.IonChannel}) – Stores the user defined ion channels present in the tree
ions (set {str}) – The ions for which a concentration mechanism is present in the tree
|
Makes the membrane act as a passive membrane (for the nodes in |
|
Set the voltage expansion points throughout the tree. |
|
Set the concentration expansion points 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. |
|
Add a concentration mechanism to the tree |
|
Fits the leak current to fix equilibrium potential and membrane time- scale. |
Returns list of strings of all channel names in the tree |
Pertaining to the computational tree create, which for the neat.PhysTree also takes the physiological parameters into account.
NEAT implements the functionality to construct a neat.CompartmentTree whose parameters represent the 2nd order finite difference approximation to the cable equation.
- class PhysNode(index, p3d=None, c_m=1.0, r_a=9.999999999999999e-05, g_shunt=0.0, v_ep=-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(*args, **kwargs)[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.
|
Creates a node with the given index corresponding to the tree class. |
|
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(*args, **kwargs)[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]
|
Creates a node with the given index corresponding to the tree class. |
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. |
|
Compute linearized ion channel state variable responses in the frequency domain at loc2 to a delta current pulse input at loc1. |
Compute linearized ion channel state variable response matrix in the frequency domain at all locations in loc_arg to delta current pulse inputs at each of those loctions. |
- 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. |
Greens Tree Time¶
- class GreensTreeTime(*args, **kwargs)[source]¶
Computes the Greens function in the time domain
- Variables:
ft (neat.FourierTools) – Helper class instance to transform transfer impedance kernels back to the time domain through quadrature
|
Set the boundary impedances for each node in the tree. |
|
Computes the impulse response kernel between two locations for all time points in self.ft.t (the input times provided to set_impedance()). |
Computes the matrix of impulse response kernels at a given set of locations for all time-points defined in self.ft.t (the input times provided to set_impedance()). |
|
Compute linearized ion channel state variable responses in the time domain at loc2 to a delta current pulse input at loc1. |
|
Compute linearized ion channel state variable response matrix at all locations in loc_arg to delta current pulse inputs at each of those loctions. |
CacheTrees¶
Compute equilibrium potentials and concentrations¶
- class EquilibriumTree(*args, recompute_cache=None, save_cache=None, cache_name=None, cache_path=None, **kwargs)[source]¶
Subclass of neat.PhysTree that allows for the calculation of the equilibrium potential at each node.
Uses the NEURON simulator to evaluate the equibrium potentials. Can cache the results of the computation.
The equilibrium potential is stored under the v_ep attribute of each node.
|
Calculates equilibrium potentials and concentrations in the tree. |
|
Set equilibrium potentials and concentrations in the tree. |
Cacheing the Greens function and separation of variables expansion¶
- class CachedGreensTree(*args, recompute_cache=None, save_cache=None, cache_name=None, cache_path=None, **kwargs)[source]¶
Derived class of neat.GreensTree that caches the impedance calculation at each node.
Sets the impedances in the tree. |
- class CachedGreensTreeTime(*args, recompute_cache=None, save_cache=None, cache_name=None, cache_path=None, **kwargs)[source]¶
Derived class of neat.GreensTreeTime that caches the separation of variables calculation
Sets the impedances in the tree. |
- class CachedSOVTree(*args, recompute_cache=None, save_cache=None, cache_name=None, cache_path=None, **kwargs)[source]¶
Derived class of neat.GreensTreeTime that caches the impedance calculation at each node.
Fitting reduced models¶
- class CompartmentFitter(*args, fit_cfg=None, concmech_cfg=None, **kwargs)[source]¶
Tree class that streamlines fitting reduced compartmental models
- Variables:
tree (neat.PhysTree) – The full tree based on which reductions are made
fit_cfg (neat.FitParams) – The fit parameters
concmech_cfg (neat.MechParams) – The concentration mechanisms parameters
model_fits (dict of {str: dict}) – Data structure with already performed model fits, where keys are the provided names. Each entry is a dict of the form {‘ctree’: neat.CompartmentTree, ‘locs’: list of neat.MorphLoc}
cache_name (str (default '')) – name of files in which intermediate trees required for the fit are cached.
cache_path (str (default '')) – specify a path under which the intermediate files are cached. Default is empty string, which means that intermediate files are stored in the working directory.
save_cache (bool (default True)) – Save the intermediate results in a cache (using cache_path and cache_name).
recompute_cache (bool (default False)) – Forces recomputing the caches.
To implement the default methodology.
To get stored fit results and associated location lists
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.
|
Store an initial neat.CompartmentTree, providing a tree structure scaffold for the fit for a given set of locations. |
Create a CachedGreensTree copy of the original 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 |
|
Fit the active ion channel parameters |
|
Fits the concentration mechanisms parameters associate with the ion ion type. |
|
Fit the capacitances of the model to the largest SOV time scale |
|
Computes the rescaled conductances when synapses are moved to compartment locations, assuming a given average conductance for each synapse. |
|
Fits the leak potentials of the reduced model to yield the same equilibrium potentials as the full model |
neat.CompartmentFitter can also computed conductance rescale values for synapses at sites on the original morphology, when they are shifted to compartment locations on the reduced morphology. For this, the average conductances of each synapses need to be known.
|
Computes the rescaled conductances when synapses are moved to compartment locations, assuming a given average conductance for each synapse. |
Simulating full and reduced models¶
Simulate full models in NEURON¶
- class NeuronSimTree(arg=None, types=[1, 3, 4])[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]mechanisms. (A NeuronSimTree can be extended easily with custom point process)
appropriate (Just make sure that you store the point process in an existing)
references (storage container or in a custom storage container, since if all)
well. (to the hocobject disappear, the object itself will be deleted as)
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)
the (If you define a custom storage container, make sure that you overwrite)
and (__init__() and delete_model() functions to make sure it is created)
properly. (deleted)
Creates a node with the given index corresponding to the tree class. |
|
|
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 ( |
Simulate reduced compartmental models in NEURON¶
- class NeuronCompartmentTree(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
fake_c_m (float) – Fake value for the membrance capacitance density, rescales cylinder surface
fake_r_a (float) – Fake value for the axial resistance, rescales cylinder length
- Variables:
equivalent_locs (list of tuples) – ‘Fake’ locations corresponding to each compartment, which are used to insert hoc point process at the compartments using the same functions definitions as for as for a morphological neat.NeuronSimTree.
Notes
Note that this class inherits from neat.NeuronSimTree and not from
neat.CompartmentTree. This is because NEAT defines a fake morphology to implement the compartment model in NEURON, and also to reuse the functionality implemented by neat.NeuronSimTree. Any function that is not explicitly redefined from neat.NeuronSimTree can be called in the same way for this compartment model. - Locations to this class can be provided either as fake morphology locations – i.e. a tuple (node.index, x-location in [0,1]) – where the value of the x-location is ignored since the nodes here are single compartments, as in the neat.CompartmentTree, and not cylinders, as in neat.MorphTree or subclasses, or as location indices, where the index corresponds to the location in the original list of locations from which the neat.CompartmentTree was derived.
Creates a node with the given index corresponding to the tree class. |
|
|
Set the recording locations |
|
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 |
Simulate reduced compartmental models in NEST¶
Creates a node with the given index corresponding to the tree class. |
|
|
Initialize n nest instantiations of the current model. |
Neural evaluation tree simulator¶
- class NETSim¶
Miscellaneous¶
Defining ion channels¶
- class IonChannel(**kwargs)[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.set_default_params(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 compute_lin_conc()) |
|
Combute the linearized channel current contribution from the concentrations |
Compute Fourrier transforms¶
- class FourierQuadrature(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 |