simulator module

This module contains everything needed to run a NeuroDevSim simulation.

The simulator will print output depending on the verbose level set during Admin_agent instantiation, this verbose level is also used by all processes. Each additional level prints more information:

  • verbose=0 : no output is printed except for error messages (red color).

  • verbose=1 : simulation start and end messages and start of each cycle messages are printed (blue color).

  • verbose=2 : warning messages are printed (magenta color), default setting.

  • verbose=3 : methods called by manage_front start info is printed (black color).

  • verbose=4 : Admin_agent methods start info is printed (black color).

  • verbose=5 : processes methods start info is printed (black color).

  • verbose=6 : for all above methods also interim info and end messages are printed.

  • verbose=7 : low level non-public methods messages are printed.

Some Front methods have a printing parameter which allows additional control over printing.

Admin_agent class

Admin_agent is the conductor of NeuroDevSim. Every NeuroDevSim simulation starts by instantiating an Admin_agent and calling its add_neurons method to set up the actual simulation. Its simulation_loop method runs the simulation. Finish cleanly by calling the destruction method.

Should be instantiated only once for each simulation. Can be instantiated repeatedly in the beginning of a for loop provided each instantiation is removed by destruction at the end of the loop.

class simulator.Admin_agent(num_procs, db_name, sim_volume, neuron_types, seed=None, verbose=2, num_admins=1, debug=False, max_neurons=1000, max_fronts=20000, max_active=2000, max_arcs=40, max_substrate=1000, max_synapse=1000, grid_step=20.0, grid_extra=10, dict_size=20, plot=False, time_lapse=False, azim=- 60.0, elev=30.0, box=False, no_axis=False, axis_ticks=True, scale_axis=False, soma_black=True, color_scheme=0, radius_scale=1.0, sphere_scale=1.0, color_data=None)

Bases: object

Main class implementing the conductor that controls NeuroDevSim simulations.

Only the attributes listed below can be read. Some can be changed as indicated, otherwise DO NOT change these attributes.

constellation

Constellation : the simulation constellation, needed in interactive mode.

cycle

integer : simulation cycle.

importable_db

boolean : make the database suitable for import_simulation method. Can be changed, default False.

seed

integer : seed value used, either set by user or by Admin_agent.

total_fronts

integer : total number of fronts made during the simulation, updated at end of each cycle.

verbose

integer : verbose level as defined above. Can be changed but this affects Admin_agent only, processes verbose level is not changed.

Parameters
  • num_procs (integer >= 0: number of extra processes to start for parallel simulation. A 0 value activates an interactive session with no parallel computing.) –

  • db_name (string : name of the sqlite database that stores simulation results. Can be empty for an interactive session.) –

  • sim_volume (list of 2 lists or list of 3 floats: coordinates specifying simulation volume in µm as: [[left, front, bottom], [right, back, top]]; if only all positive [right, back, top] is provided it is assumed to be [[0.,0.,0.], [right, back, top]]) –

  • neuron_types (list of strings: list with names of all Front subclasses that can be used.) –

  • optional1 (general) –

  • debug (boolean : perform extra error checking that will slow down simulation, default False.) –

  • num_admins (integer 1-3 : run extra admin core if plot==False, default 1.) –

  • seed (integer > 0: seed for random number generator, default: None) –

  • verbose (integer 0-7 : increasing amounts of information printed to console, see documentation above for details, 0: no output, default 2.) –

  • optional2 (preset array sizes) –

  • max_fronts (integer > 0: maximum number of fronts for each Front subclass, default 20000.) –

  • max_active (integer > 0 : maximum number of growing fronts each cycle, default 2000.) –

  • max_arcs (integer > 0 : maximum number of arcs stored, default 40 per process.) –

  • max_substrate (integer > 0 : maximum number of Substrate, default 1000.) –

  • max_synapse (integer > 0 : maximum number of Synapse, default 1000.) –

  • grid_step (float > 1.0 : distance between grid points, default 20 µm.) –

  • grid_extra (integer > 0 : size of blocks for grid entries, default 10.) –

  • dict_size (integer > 0 : size of blocks for local grid storage, default 20) –

  • optional3 (plotting in notebooks) –

  • plot (boolean : if True an interactive 3D plot is generated, default False.) –

  • time_lapse (boolean : plots a time lapse sequence after simulation, overrides plot and no_axis=True, default False.) –

  • axis_ticks (boolean : show axis ticks, default True.) –

  • azim (float : azimuth in degrees of camera, default -60.) –

  • box (box format [[left, front, bottom], [right, back, top]] to plot, allows to zoom in, default full sim_volume.) –

  • color_scheme (integer 0-3 : controls how colors change: 0: every neuron has a different color; 1: neurons of same type have same color, different types have different colors; 2: different branches in a neuron have different colors, based on branch_name; 3: color set by front attribute, default 0.) –

  • color_data (list : [front attribute name, min value, max value], data necessary for color_scheme 3, default None.) –

  • elev (float : elevation in degrees of camera, default 30.) –

  • no_axis (boolean : suppress drawing of axes, default False.) –

  • radius_scale (float : change thickness of cylindrical fronts, default 1. normal size.) –

  • scale_axis (boolean or list of 3 floats : list as [1.0,1.0,1.0] decrease one or more values to change relative scaling of axes, value for largest axis should be close to 1.0; default False.) –

  • soma_black (boolean : all somata are black for increased contrast, default True.) –

  • sphere_scale (float : change size of spherical fronts, default 1. normal size.) –

add_neurons(front_class, neuron_name, number, location, radius, axon=False, migrating=False, grid=False, origins=[], print_color=False)

Add new neuron somata or axons to the simulation.

The only way to create new neurons. This method can be called repeatedly to generate different neuron types and/or neurons of the same type at different simulation cycles. By default random placement is performed, either grid or origins can be used to specify more specific placement of multiple neurons.

By default spherical somata are created, but instead cylindrical axon fronts can be made (axon optional parameter. Either will become the root of a neuron tree. By default the first front has is_growing()=True, unless the migrating optional parameter is used.

Parameters
  • front_class (string : name of the Front subclass to use.) –

  • neuron_name (string of maximum 34 characters : name of the neuron. Names are automatically numbered as neuron_name_0, neuron_name_1, etc.) –

  • number (integer > 0 : number of neurons to create.) –

  • location (list or list of 2 lists: location of neuron somata specified as bounding coordinates. To add a single neuron [x, y, z] can be specified, to add multiple neurons this should be a box as [[left, front, bottom], [right, back, top]]. Each neuron soma is placed randomly within this box unless grid or origins is specified. Soma centers are minimally separated by the diameter.) –

  • radius (float > 0.0 : soma radius in µm.) –

  • Optional

  • axon (boolean or list : initialize axon instead of soma; list [dx,dy,dz] specifies an offset to apply to orig to generate end of cylindrical axon, default False: spherical somata are made.) –

  • grid (boolean or list : place somata on a grid specified as [nx, ny, nz] or as [nx, ny, nz, jitter] where integers nx, ny, nz are the number of positions on the grid along each dimension (there can be more grid positions than number of neurons, but not less) and optional float jitter is the standard deviation in µm of random (normal distribution) jitter applied to each grid position, default False.) –

  • migrating (boolean : set soma.is_migrating()=True and soma.is_growing=False, default False) –

  • origins ([Point,] : list of Point to be used to place the somata.) –

  • print_color (boolean : print neuron colors for interactive plot, default False.) –

Returns

nds_list of fronts as stored

Return type

[Front,]

add_substrate(substrate, index=- 1, database=True)

Add substrate to the simulation.

Parameters
  • substrate (a Substrate or list of Substrate.) –

  • Optional

  • internal_use_only

Returns

nds_list of substrate as stored

Return type

[Substrate,]

import_simulation(stored_db_name, copy_db=True)

Import a previous neurodevsim simulation. This can be used either for interactive model debugging or to continue the simulation, in the latter case the num_procs should be identical. The database should be from a simulation that ran to finish and completed its admin.destruction method.

This assumes that the same values for the sim_volume and neuron_types Admin_agent attributes have been defined as for the stored simulation. Any optional changes to Admin_agent array size attributes should also be applied.

This method should be the first method called after initalization of Admin_agent. New, additional neuron types are allowed but they should be at the end of the previous neuron_types list.

The method tries to recreate the original data structures as much as possible. Hidden data structures should contain identical information but the order may be different. Additional, user-defined Front attributes that were stored using attrib_to_db are restored.

Parameters
  • stored_db_name (string : name of the sqlite database that stores previous simulation results. This should be a different name than the db_name used for Admin_agent initialization.) –

  • Optional

  • copy_db (boolean : the content of stored_db_name is copied to db_name, default True.) –

plot_item(item, color='r', symbol=None, line=False)

Plot a structure in an interactive notebook plotting context. Item can be a Point, Front or Substrate or a list of these. :param item: :type item: Point, Front or Substrate` or list : item(s) to be plotted. :param Optional: :param color: :type color: char or string : valid color name to use, default red :param line: :type line: boolean : how to plot a list of ``Point, as individual points (False) or as a line (True), default False :param symbol: :type symbol: char or None : symbol to use for Point or Substrate instead of default one, default None

Returns

matplotlib object

Return type

plot object

flash_front(front)

Flashes a plotted front by changing its color a few times. :param front: :type front: Front : front to flash.

simulation_loop(num_cycles)

Runs the simulation for a number of cycles.

Parameters

num_cycles (integer > 0.) –

attrib_to_db(front_class, attribute, sql_type, neuron_name='', object=<class 'simulator.Front'>, last_only=False)

Store (new) attribute(s) in the simulation database. This can be used to either store changes to predefined attributes like synaptic weight or neuron firing rate, or to store user defined additional attributes. A new database table with the name of attribute will be created.

By default attrib_to_db starts storing specified Front attribute(s) for all active fronts belonging to front_class after this method was run and continues till end of the simulation. Alternatively, active fronts stored can be limited to those of a specific neuron using optional neuron_name.

Another mode of output occurs when optional last_only=True. Now specified attribute(s) for all fronts belonging to front_class (including inactive ones) are stored only after last cycle of the simulation during admin.destruction() call.

To store (only predefined) Neuron (firing_rate,…) or Synapse (at present only weight changes) attributes the object optional parameter should be used.

This method can only be called after at least one neuron of *front_class* is instantiated: add_neurons must have been called. Only ctypes attributes or ID or Point (for Fronts only) can be stored, not other classes can be stored.

Parameters
  • front_class (string : name of the Front subclass to store.) –

  • attribute (string or [string] : name(s) of the attribute(s) to store. Can be a single attribute or a list of attributes from same front_class. Recognized predefined attributes are: CV_ISI, firing_rate and weight.) –

  • sql_type (string or [string] : defines for each attribute the data type to be used in the database, choice of "id", "int", "point", "real", "text".) –

  • Optional

  • last_only (boolean : output for all fronts but only at time of admin.destruction(), default False: store for active fronts every cycle from now on.) –

  • neuron_name (string : output only attributes from fronts belonging to neuron with neuron_name (wildcard), default: “” (all neurons).) –

  • object (Front, Neuron or Synapse : output attribute from one of these objects, default Front.) –

sim_memory()

Print memory use in Mb.

sim_statistics(verbose=3)

Print runtime statistics for a simulation and returns runtime.

Print processor specific waiting times and load balancing statistics.

Parameters
  • Parameters (Optional) –

  • verbose (integer 0-3 : print increasing amount of data, for verbose > 2 processor specific data is included.) –

grid_statistics(bin_width=1)

Print a histogram about grid use by fronts.

Parameters

bin_width (integer : width of bins to use, default 1.) –

Returns

grid data

Return type

list containing number of fronts for each grid point

destruction(update_db=True, exit=True)

Shut down NeuroDevSim: end all processes and admin.

By default it also quits the program, any following statements are ignored.

Parameters
  • Optional

  • exit (boolean : exit program after shutting down, default: True) –

  • update_db (boolean : update database with final values. As this updates all front data this may take a few seconds. Affects many tables, default: True) –

Model definition classes

Point class

A Point encodes a 3D coordinate or vector in µm. It is used in Front to specify the origin and end coordinates of cylinders. Point can be instantiated anytime.

As a vector it can be used to compute directions for growth:

# direction, target and front.end are all Points
direction = target - front.end
# compute the distance to target
distance = direction.length()
# make direction a unit vector
u_dir = direction.norm()

Simple arithmetic using Point is possible, the following operations are supported and produce a new Point:

  • Point + Point : sums all attributes one by one

  • Point + list (list should be size 3 vector)

  • Point + numpy.array (numpy.array should be size 3 vector)

  • Point - Point : subtracts all attributes one by one

  • Point - list (list should be size 3 vector)

  • Point - numpy.array (numpy.array should be size 3 vector)

  • Point * integer : multiplies all attributes with integer

  • Point * float : multiplies all attributes with float

  • Point / integer : divides all attributes by integer

  • Point / float : divides all attributes by float

The order is important: integer * Point is not supported and will result in a ‘TypeError: invalid type promotion’ error. Simple comparisons are also possible, the following operations are supported and produce a boolean:

  • Point == Point

  • Point != Point

class simulator.Point

Bases: _ctypes.Structure

Class implementing 3D coordinates and vectors.

x

float : width position in µm.

y

float : depth position in µm.

z

float : height position in µm.

nds_class()

Return class name.

Returns

Class name “Point”

Return type

string

length()

Compute length of a vector.

Returns

length of vector

Return type

float

norm()

Normalize vector to unit vector.

Returns

vector

Return type

Point

dot(other)

Perform vector dot operation between two vectors.

Parameters

other (Point.) –

Returns

dot product of vectors

Return type

float

cross(other)

Perform vector cross operation between two 1D vectors.

Parameters

other (Point.) –

Returns

cross product of vectors

Return type

Point

nparray()

Turn vector into numpy.array.

Returns

vector

Return type

numpy.array

abs()

Make all attributes of Point positive.

Returns

vector

Return type

Point

wiggle(constellation, scale, min_size=0.5)

Randomly change position of a point so it is still inside the simulation volume.

Parameters
  • constellation (Constellation object.) –

  • scale (float : maximum amount of change applied (summed over all coordinates), should be larger than min_size.) –

  • Optional

  • min_size (float : miminum amount of change applied (summed over all coordinates), default 0.5 µm.) –

Returns

vector

Return type

Point

out_volume(constellation)

Returns whether the Point is outside the simulation volume (including its borders).

If inside volume returns 0., otherwise it returns first coordinate outside the volume.

Parameters

constellation (Constellation object.) –

Returns

is outside simulation volume

Return type

float

toPol_point()

Convert Point to a Pol_point.

Returns

polar point

Return type

Pol_point

is_cylinder()

Compatibility with other Structures.

Returns

always False

Return type

boolean

Front class

Front implements the agents that mimic growth and migration in NeuroDevSim. However, the class cannot be used directly. Instead a NeuroDevSim model creates a subclass of Front that defines a manage_front method. Front cannot be instantiated by the user, instead they are created by Admin_agent.add_neurons, Front.add_child or Front.add_branch methods.

Only a subset of Front attributes can be read directly as listed below, the other ones can be obtained with attribute methods.

Front methods are labeled and ordered in this documentation as:

  • growth methods that control front growth.

  • attribute methods that give access to additional attributes.

  • tree methods that give access to the neuronal tree structure.

  • behavior methods that report the current behavior of the front.

  • search methods to return other objects around the front.

  • point methods to return points close to the front.

  • size methods that return size related information.

class simulator.Front

Bases: _ctypes.Structure

Main class implementing growing/migrating agents.

This class is not meant to be instantiated, instead subclass it with a model specific extend_front method.

Only the attributes listed below can be read. NEVER change these attributes.

birth

integer : cycle when front was created.

death

integer : cycle when front was retracted, default: -1 (not retracted).

end

Point : specifying end coordinate of cylinder.

order

integer : centripetal order of branching, soma has order 0.

orig

Point : origin coordinate of cylinder or center of sphere.

num_children

integer : number of children in the tree structure.

path_length

float : distance in µm to soma center along the tree structure.

radius

float : radius in µm of the cylinder or sphere.

swc_type

integer : SWC_type as specified in Cannon et al. (optional).

nds_class()

Return class name.

Returns

Class name of Front subclass

Return type

string

manage_front(constellation)

Main front method.

Must be replaced by a method in the subclass, not doing so generates an error. This method is called each cycle for active fronts so that different growth, migration, etc. methods can be used.

Parameters

constellation (Constellation object.) –

add_child(constellation, coordinate, radius=0.0, branch_name='', swc_type=0, cylinder=True)

Main growth method. Instantiate a new Front of the same subclass as self that becomes a child of self.

By default a cylindrical front with orig equal to self.end (if self is also cylindrical, otherwise point on spherical surface) and end equal to coordinate is created. If cylinder==False a spherical front with orig equal to coordinate is created. Collision and inside simulation volume checks are performed, if these fail a CollisionError, InsideParentError, VolumeError or GridCompetitionError exception is thrown.

Parameters
  • constellation (Constellation object.) –

  • coordinate (Point : end (cylinder, default) or orig (sphere) coordinate of new child front.) –

  • Optional

  • branch_name (string of maximum 20 characters : optional branch_name, default: None.) –

  • cylinder (boolean : make cylindrical (True) or spherical child (False), default True.) –

  • radius (float : radius in µm of the cylinder or sphere, default same radius as self.) –

  • swc_type (integer : SWC_type as specified in Cannon et al., default same as self or 3 (dendrite) if self is a soma.) –

Returns

the new child or an exception

Return type

Front subclass or CollisionError, GridCompetitionError, InsideParentError, NotSelfError, ValueError or VolumeError

add_branch(constellation, coord_list, radius=0.0, branch_name='', swc_type=0, enable_all=False)

Additional growth method. Similar to add_child but multiple cylindrical Front are made as an unbranched branch with as a root a child of self.

Collision and inside simulation volume checks are performed, if these fail on the first point a CollisionError, InsideParentError, VolumeError or GridCompetitionError exception is thrown. For collision errors on later points no error is thrown, instead add_branch tries to solve GridCompetitionErrors by retrying or returns with less fronts made than points provided.

Parameters
  • constellation (Constellation object.) –

  • coord_list ([Point,] : end of consecutive child fronts.) –

  • Optional

  • branch_name (string of maximum 20 characters : optional branch_name, default: None.) –

  • enable_all (boolean : all new Front made are enabled, otherwise only the terminal child is enabled and the rest are disabled, default: False.) –

  • radius (float : radius in µm of the cylinder or sphere, default same radius as self.) –

  • swc_type (integer : SWC_type as specified in Cannon et al., default same as self or 3 (dendrite) if self is a soma.) –

Returns

the new fronts as nds_list or an exception

Return type

[Front subclass,] or CollisionError, GridCompetitionError, InsideParentError, NotSelfError, ValueError or VolumeError

migrate_soma(constellation, coordinate, filipod=False, trailing_axon=False)

Growth method. Migrate self, a soma, to a new position.

By default migration to coordinate and no children allowed. Alternative is to migrate along a filipod with filipod==True, replacing the single child filipod (swc_type 12) front (coordinate ignored). If trailing_axon==True an axon front is made to connect with single axon child (swc type 2). Maximum number of children allowed is two (a filipod and an axon). Collision and inside simulation volume checks are performed, if these fail a CollisionError, InsideParentError or VolumeError exception is thrown. Additional possible errors: BadChildError, NotSomaError.

Parameters
  • constellation (Constellation object.) –

  • coordinate (Point : position to which soma migrates. Ignored if filipod==True.) –

  • Optional

  • filipod (boolean : replace filipod child by migrating to a position where filipod.end falls on surface of soma, default False.) –

  • trailing_axon (boolean : make a new axon front to connect with existing axon child, default False.) –

Returns

the new position or an exception

Return type

Point or BadChildError, NotSelfError, NotSomaError, CollisionError, GridCompetitionError, VolumeError

retract(constellation)

Growth method. Retract self: the front is removed from the simulation.

This can be called only if the front has no children, otherwise a TypeError is raised. The irreversible retraction is done at the end of the current cycle. Next cycle will have self.has_child_retracted()==True.

Parameters

constellation (Constellation object.) –

retract_branch(constellation, child)

Growth method. Retract child and all its (grand)children: the fronts are removed from the simulation.

This can be called on any child of self and is robust to any status of the child and its (grand)children. The irreversible retraction is done at the end of the current cycle. Next cycle will have self.has_child_retracted()==True.

Parameters
  • constellation (Constellation object.) –

  • child (Front : the root of the branch to be retracted.) –

get_id()

Attribute method that returns the ID of self.

Returns

self’s unique ID

Return type

ID

get_dataid(constellation)

Attribute method that returns the DataID of self.

Returns

self’s data id

Return type

DataID

get_neuron(constellation)

Attribute method that returns the neuron self belongs to.

Parameters

constellation (Constellation object.) –

Returns

self’s neuron

Return type

Neuron

get_neuron_type(constellation, index=True)

Attribute method that returns the front subclass of the neuron.

The method can return either an index into the neuron_types list that was used for Admin_agent initialization, with value 1 for the first entry, or the name of the Front subclass.

Parameters
  • constellation (Constellation object.) –

  • Optional

  • index (boolean : return index starting with 1 into neuron_types, default: True.) –

Returns

self’s neuron type

Return type

integer or string

get_neuron_name(constellation)

Attribute method that returns the name of the neuron self belongs to.

Parameters

constellation (Constellation object.) –

Returns

self’s neuron name

Return type

string

get_branch_name()

Attribute method that returns the optional branch name of self.

Returns

self’s branch name

Return type

string

set_branch_name(name)

Attribute method that sets the optional branch name of self.

Cannot be applied to soma, which is always called “soma”.

Parameters

name (string : new branch name) –

get_parent(constellation, returnID=False, printing=False)

Tree method that returns the parent of self.

This method by default returns Front or None, but can also return an ID.

Parameters
  • constellation (Constellation object.) –

  • Optional

  • printing (boolean : also print soma, output depends on returnID, default: False) –

  • returnID (boolean : return ID, default: False.) –

Returns

self’s parent, depending on returnID parameter

Return type

Front or ID or None

is_parent(front)

Tree method that confirms whether self is the parent of front.

Parameters

front (Front object.) –

Returns

is self the parent of front?

Return type

boolean

is_ancestor(constellation, front)

Tree method that confirms whether self is a (distant) parent of front, e.g. grandparent, grand-grandparent, etc.

Parameters
  • constellation (Constellation object.) –

  • front (Front object.) –

Returns

is self an ancestor of front?

Return type

boolean

is_child(front)

Tree method that confirms whether self is a child of front.

Parameters

front (Front object.) –

Returns

is self a child of front?

Return type

boolean

get_children(constellation, returnID=False, swc_type=0, printing=False)

Tree method that returns a list of all children of self.

This method by default returns a list of Front, but can also return a list of ID. The children returned can be selected by swc_type.

Parameters
  • constellation (Constellation object.) –

  • Optional

  • printing (boolean : also print list of children, output depends on returnID, default: False) –

  • returnID (boolean : return list of ID, default: False.) –

  • swc_type (integer : only return children with specified swc_type, default: return all children.) –

Returns

Depending on returnID parameter nds_list of Front or nds_list of ID

Return type

list

get_soma(constellation, returnID=False, printing=False)

Tree method that returns the soma of the neuron self belongs to.

This method by default returns Front, but can also return an ID.

Parameters
  • constellation (Constellation object.) –

  • Optional

  • printing (boolean : also print soma, output depends on returnID, default: False) –

  • returnID (boolean : return ID, default: False.) –

Returns

self’s soma, depending on returnID parameter

Return type

Front or ID

get_neuron_fronts(constellation, returnID=False)

Tree method that returns a list of all fronts of the entire neuron self belongs to.

This method by default returns a list of Front, but can also return a list of ID.

Parameters
  • constellation (Constellation object.) –

  • Optional

  • returnID (boolean : return list of ID, default: False.) –

Returns

Depending on returnID parameter nds_list of [Front,] or [ID,]

Return type

list.

get_terminals(constellation, returnID=False)

Returns a list of all terminal fronts for self.

This method by default returns a list of Front, but can also return a list of ID.

Parameters
  • constellation (Constellation object.) –

  • Optional

  • returnID (boolean : return list of ID, default: False.) –

Returns

Depending on returnID parameter nds_list of [Front,] or [ID,]

Return type

list.

get_neighbors(constellation, distance, branch_stop=False, returnID=False)

Tree method that returns a list of fronts that are close to self on the neuron tree.

Return all fronts that are within a given path_length distance of self, in both somatopetal and somatofugal directions, or (option) till next branch point. This method by default returns a list of Front, but can also return a list of ID.

Parameters
  • constellation (Constellation object.) –

  • distance (float : maximum distance (inclusive) that returned fronts can be.) –

  • Optional

  • branch_stop (boolean : stop at first branch point encountered, default: False.) –

  • returnID (boolean : return list of ID, default: False.) –

Returns

Depending on returnID parameter nds_list of [Front,] or [ID,]

Return type

list.

count_descendants(constellation)

Returns number of descendants, the total number of all children, grandchildren, grand-grandchildren, etc.

Parameters

constellation (Constellation object.) –

Returns

Count of descendant fronts

Return type

integer.

enable(constellation, growing=False, migrating=False)

Behavior method: make a front active: it calls manage_front each cycle, starting next cycle.

It is safe to call this method on other fronts than self without locking. If the front is already active a Warning will be printed if verbose >= 2 and nothing will change.

Parameters
  • constellation (Constellation object.) –

  • Optional

  • growing (boolean : flag enabled front as growing, default False: not growing.) –

  • migrating (boolean : flag enabled front as migrating, default False: not migrating.) –

disable(constellation, till_cycle=0, till_cycle_g=0, till_cycle_m=0)

Behavior method: make a front inactive: it no longer calls manage_front, starting next cycle.

Also clears is_growing() and is_migrating(). It is safe to call this method on other fronts than self without locking. If the till_cycle parameter is used this will make the front active again on till_cycle. In addition the front can be set to growing with till_cycle_g or to migrating with till_cycle_m. Only one of the till_cycle options may be used. If the front should be made both growing and migrating, use *till_cycle_g and call self.set_migrating() when manage_front is called again.

Parameters
  • constellation (Constellation object.) –

  • Optional

  • till_cycle (integer : transiently disable, at till_cycle will be active again, default 0: permanent disable.) –

  • till_cycle_g (integer : transiently disable, at till_cycle will be growing and active, default 0: permanent disable.) –

  • till_cycle_m (integer : transiently disable, at till_cycle will be migrating and active, default 0: permanent disable.) –

enable_parent(constellation, growing=False, migrating=False)

Behavior method: make the parent of a front active: it calls manage_front each cycle, starting next cycle.

If the parent is already active nothing will change.

Parameters
  • constellation (Constellation object.) –

  • Optional

  • growing (boolean : flag enabled front as growing, default False: not growing.) –

  • migrating (boolean : flag enabled front as migrating, default False: not migrating.) –

is_cylinder()

Behavior method: is self a cylinder (True) or a sphere (False)?.

Returns

is *self* a cylinder?

Return type

boolean

is_active()

Behavior method: is self active (calling manage_front)?.

Returns

is self active?

Return type

boolean

is_growing()

Behavior method: is self growing?.

Returns

is self growing?

Return type

boolean

set_growing()

Behavior method: signal self is growing. Makes front active.

Only set if self.is_migrating() == False

clear_growing()

Behavior method: signal self stopped growing.

is_migrating()

Behavior method: is self migrating now?.

Returns

is self migrating now?

Return type

boolean

set_migrating()

Behavior method: signal self is migrating. Makes front active.

Clears self.is_growing()

clear_migrating()

Behavior method: signal self stopped migrating.

has_moved()

Behavior method: has migrating self moved in last call to manage_front?.

At start of manage_front call this reflects whether it moved during the previous cycle. Upon return from manage_front it is set to what happened on current cycle.

Returns

has migrating self moved?

Return type

boolean

has_migrated()

Behavior method: has self ever migrated?.

Returns

has self ever migrated?

Return type

boolean

is_retracted()

Behavior method: has self been retracted (deleted after birth)?.

Returns

has self been retracted?

Return type

boolean

has_child_retracted()

Behavior method: has a child of self been retracted in the past?.

This flag is reset to False when self grows a new child.

Returns

has a child of self been retracted?

Return type

boolean

is_arc()

Behavior method: is self part of an arc made by the arc_around method?

Returns

is self part of an arc?

Return type

boolean

is_status1()

Behavior method: is self status1 set?.

Returns

is self status1 set?

Return type

boolean

set_status1()

Behavior method: set self status1 to True.

clear_status1()

Behavior method: set self status1 to False.

is_status2()

Behavior method: is self status2 set?.

Returns

is self status2 set?

Return type

boolean

set_status2()

Behavior method: set self status2 to True.

clear_status2()

Behavior method: set self status2 to False.

is_status3()

Behavior method: is self status3 set?.

Returns

is self status3 set?

Return type

boolean

set_status3()

Behavior method: set self status3 to True.

clear_status3()

Behavior method: set self status3 to False.

has_synapse()

Has self a synaptic connection defined?. Always False for Front.

Returns

False

Return type

boolean

get_fronts(constellation, what='other', name='', type=0, max_cycle=- 1, max_distance=100.0, swc_types=[], sort=True, returnID=False)

Search method: returns all fronts with a specific property within Euclidian max_distance (default 100 µm).

This method by default returns a distance sorted list of Front, but can also return a list of ID. The what controls overall behavior of the method, this can be further refined by changing max_distance or specifying a subset of swc_types to return.

Speed of method depends on max_distance: for max_distance <= Admin_agent.grid_step a different method is used that is less sensitive to number of neurons in the simulation. Otherwise this method’s computation time scales with the number of neurons in the simulation.

Parameters
  • constellation (Constellation object.) –

  • Optional

  • what (string: string options:) –

    • ‘self’: get fronts belonging to same neuron as self, excluding all up to second order ancestors and descendents.

    • ’self+’: get all fronts within max_distance belonging to self.

    • ’name’: get fronts belonging to neurons with name (wildcard), not including same neuron as self.

    • ’other’: get fronts that do not belong to self (default).

    • ’type’: get fronts belonging to this type of neuron, not including same neuron as self.

  • max_cycle (integer : ignore fronts born at this cycle or later, default -1: use all fronts.) –

  • name (string : used for the what=='name' and what=='type' options.) –

  • max_distance (float : maximum Euclidian distance, inclusive, default: 100 µm.) –

  • swc_types (list : only include fronts with these swc_types.) –

  • sort (boolean : sort the list by increasing distance, default: True.) –

  • returnID (boolean : return list of ID, default: False.) –

Returns

Depending on returnID parameter nds_list of tuples (Front, distance) or (ID, distance)

Return type

nds_list of tuples

get_substrates(constellation, name, max_distance=100, sort=True, returnID=False)

Search method: returns all substrate with a specific name within Euclidian max_distance (default 100 µm).

This method by default returns a distance sorted list of Substrate, but can also return a list of ID. max_distance can be changed as an optional parameter.

Parameters
  • constellation (Constellation object.) –

  • name (string : name of the Substrate (wildcard).) –

  • Optional

  • max_distance (float : maximum Euclidian distance, inclusive, default: 100 µm.) –

  • sort (boolean : sort the list by increasing distance, default: True.) –

  • returnID (boolean : return list of ID, default: False.) –

Returns

Depending on returnID parameter nds_list of tuples (substrate, distance) or (ID, distance)

Return type

nds_list of tuples

point_valid(constellation, point, cylinder=True, new_radius=None)

Search method: checks whether given point is a valid location for a new front: inside the simulation volume and not causing any collision.

Depending on the cylinder (default True) optional parameter this method either checks for collisions with a cylinder with as origin self.end and as end point or, if False, for an isolated sphere with point as its origin. It assumes the same radius as self unless a new_radius is specified.

Parameters
  • constellation (Constellation object.) –

  • point (Point : location to be validated.) –

  • Optional

  • cylinder (boolean : check for cylinder ending at point (True) or isolated sphere around point (False), default True.) –

  • new_radius (float : use this value as radius of cylinder or sphere, default None (use self.radius instead).) –

Returns

An exception if point is not valid

Return type

CollisionError, InsideParentError or VolumeError

wiggle_front(constellation, max_scale, min_scale=0.5)

Point method: returns a random point based on current front position.

Called when Front is colliding. Returns a random point scaled by max_scale * radius added to the proper position. The point is guaranteed to be inside the simulation volume.

This method can be subclassed to refine the generation of random points.

Parameters
  • constellation (Constellation object.) –

  • max_scale (float : scales the maximum amount of wiggling by radius.) –

  • Optional

  • min_scale (float : sets a minimum to the amount of wiggling, default: 1/2 radius vector length.) –

Returns

random position

Return type

Point

solve_collision(constellation, point, error, new_radius=None, half_arc=True)

Point method: try to resolve a collision.

Can be called after add_child exempts with a CollisionError or point_valid(constellation,point) returns False for a cylindrical self. If successful, returns a list of points in the same general growth direction that does not collide, otherwise returns [].

Parameters
  • constellation (Constellation object.) –

  • point (Point : the point that caused the collision.) –

  • error (Exception : the CollisionError that we are trying to solve) –

  • Optional

  • new_radius (float : use this value as radius for collision checking, default None.) –

  • half_arc (boolean : if arc made it is 180 deg, else 90 deg arc, default True.) –

Returns

new positions as nds_list

Return type

[Point,] or []

in_volume(constellation)

Search method: returns whether the self is inside the simulation volume (including its borders).

For cylinder self.orig and self.end is tested, for sphere self.orig.

Parameters

constellation (Constellation object.) –

Returns

is inside simulation volume

Return type

boolean

unit_heading_sample(mean=0.0, width=52.0, max_angle=180)

Point method: return a random unit vector in a cone centered around the direction of front.

For cylindrical front a zero angle vectors points in the same direction as the front. For spherical fronts the direction is random. Vector is drawn from a normal distribution defined by mean ± width in degrees. The default values are for cat motor neurons.

Parameters
  • mean (float > 0.: mean of the normal distribution for angle in degrees, default: 0.) –

  • width (float > 0.: standard deviation of the normal distribution for angle, default: 55.) –

  • max_angle (float > 0.: maximum angle relative to heading, cuts of the distribution,) – max value is 180 degrees, default: 180 degrees.

Returns

unit length vector

Return type

Point

unit_branching_sample(number, mean=45.0, width=33.0, sep_mean=73.0, sep_width=32.0)

Point method: generates a list with number random unit vectors.

If the front is a cylinder the vectors will have a mean ± width angle relative to the heading (zero angle) of self. The vectors always have a minimal pairwise separation that is larger than a sample of sep_mean ± sep_width. The default values are for cat motor neurons.

Parameters
  • number (integer in range 2-20 : number of vectors to return.) –

  • mean (float > 0. : mean of the normal distribution for angle in degrees relative to heading of self, default: 45.) –

  • width (float > 0. : standard deviation of the normal distribution for angle, default: 44.) –

  • sep_mean (float > 0.: mean of the normal distribution for separation angle in degrees, default: 73.) –

  • sep_width (float > 0.: standard deviation of the normal distribution for separation angle, default: 32.) –

Returns

nds_list of unit length vectors

Return type

[Point,]

get_migration_history(constellation)

Point method: available after import_simulation only. If front migrated, returns a two lists: list of front origin coordinates and list of corresponding cycles.

If no data available, empty lists are returned.

Returns

Coordinate nds_list and cycle list

Return type

[Point,] , [integer, ]

alternate_locations(point, distance, number, random=False)

Point method: generates a list with number alternate Point around point.

The alternate points are located on a ring with distance as radius around point, orthogonal to the axis self.end - point (cylinder) or self.orig - point (sphere). Order is clockwise unless optional parameter random is True.

Warning: this method does not test whether returned points are inside the simulation volume.

Parameters
  • point (Point : center of ring of Point.) –

  • distance (float > 0.: radius of ring of Point.) –

  • number (integer > 0: number of Point generated. Actual number may be smaller if some of the points would be too close to self.) –

  • Optional

  • random (boolean : randomize position of points and order of the list returned, default: False.) –

Returns

positions around point as nds_list

Return type

[Point,]

arc_around(constellation, target, arc=90.0, arc_size=None, offset=0.0, new_radius=None)

Point method: returns a list of Point forming an arc around target Front.

To grow around a much larger spherical front an arc needs to be made, this will tend to consists of several short fronts. This method produces a list of positions that can be used to generate these fronts with the add_branch method.

The method checks obstructing structures close to target to find the optimal orientation of the arc. The number of points returned is determined by two parameters: the arc will be computed for any size in the range 1 - 180 degrees, for that given arc the number of points will be decided by whichever is smallest: the length of self, which can be overridden by the length parameter arc_size, and the resolution needed to have fronts not intersect with the target. The arc distance from target center is given by 1.5 * self.radius + target.radius + offset.

Parameters
  • constellation (Constellation object.) –

  • target (Front : spherical front to go around.) –

  • Optional

  • arc (float >=1. and <= 180. : maximal arc size to be produced.) –

  • arc_size (float > 0. : minimum cumulative length of lines connecting the points returned, default 10 µm.) –

  • new_radius (float : use this value as radius of cylinder or sphere, default None (use self.radius instead).) –

  • offset (float >= 0. : distance by which the point is offset from target membrane in addition to self.radius, default 0.0 µm.) –

Returns

nds_list of points or empty list

Return type

[Point,] or GridCompetitionError

arc_continue(constellation, collision=False)

Point method: returns a list of Point continuing an arc ending at self.end.

Returns empty list if no previous arc is found. The method performs NO collision detection. The number of points returned is either the same as before or the remainder of the arc.

If collission=True it will extend the previous arc if no points on it remain.

Parameters
  • constellation (Constellation object.) –

  • Optional

  • collision (boolean : called by solve_collision method, default False.) –

Returns

nds_list of points or empty list

Return type

[Point,]

go_around(constellation, point, target, offset=0.0, new_radius=None)

Point method: returns a list of Point going around a cylindrical target Front without making an arc.

Parameters
  • constellation (Constellation object.) –

  • point (Point : the point that caused the collision, used to compute desired growth direction.) –

  • target (Front : front to go around.) –

  • Optional

  • new_radius (float : use this value as radius of cylinder or sphere, default None (use self.radius instead).) –

  • offset (float >= 0. : distance by which the point is offset from target membrane in addition to self.radius, default 0.0 µm.) –

Returns

nds_list of points or empty list

Return type

[Point,] or GridCompetitionError

surface_point_to(point, mid=True, offset=0.0, pos=None)

Point method: returns Point on the membrane surface of self in the direction of point.

If optional parameter mid is True this point is halfway along the length of the cylinder, else it is a random location. This can be overruled with pos to specify a specific position along the length: between 0.0 (self.orig) and 1.0 (self.end), pos=0.5 corresponds to mid=True. For a sphere it is always the closest point on the surface. Optional parameter offset gets added to the radius of self and results in a point at distance offset from its membrane surface.

Parameters
  • point (Point : gives direction relative to self.) –

  • Optional

  • mid (boolean : point is in the center of the cylinder, else it is a) – random location. For a sphere it is always the closest point on the surface. Default: True.

  • offset (float >= 0. : distance by which the point is offset from the membrane) – along the line connecting to point, default 0.0 µm.

  • pos (float 0.0 - 1.0 : overrule mid setting with relative position, default None.) –

Returns

location on or close to membrane surface of *self*

Return type

Point

sphere_interpol(point1, point2, scale=0.5)

Point method: returns a point on or close to the membrane surface of spherical self on the arc connecting point1 and point2.

Optional parameter scale changes location of Point: from point1 for scale=0 to point2 for scale=1. If the points are not on the surface it is assumed that they have the same distance to self.orig.

Parameters
  • point1 (Point : (close to) surface point.) –

  • point2 (Point : (close to) surface point.) –

  • Optional

  • scale (float : in range 0 - 1.0, default 0.5 (mid-point).) –

Returns

location on or close to membrane surface of *self*

Return type

Point

sphere_intersect(front, offset=0.0)

Point method: return closest point along the heading of front that intersects the membrane surface of spherical self.

Parameters
  • front (Front : must be a cylinder.) –

  • Optional

  • offset (float >= 0. : distance by which the point is offset from the membrane) – along the line connecting to front, default 0.0 µm.

Returns

closest intersection point

Return type

Point or None

sphere_T_points(point1, point2)

For sphere with center and two points on or close to its surface, generate two more points on circle perpendicular to arc made by point1 and point2, resulting in a T with the vertical defined by point1 and point2.

Parameters
  • point1 (Point : (close to) surface point.) –

  • point2 (Point : (close to) surface point.) –

Returns

nds_list of pair of points at same distance from point2

Return type

[Point,Point]

mid(scale=0.5)

Point method: returns center point on the axis of the cylinder.

Optional parameter scale changes location of Point: from self.orig for scale=0 to self.end for scale=1. For spheres the origin is returned.

Parameters
  • Optional

  • scale (float : in range 0 - 1.0, default 0.5 (mid-point).) –

Returns

location on axis of cylindrical *self*

Return type

Point

length()

Size method: returns length of self.

Length of cylinder or diameter of sphere.

Returns

length of *self* in µm

Return type

float

front_distance(other, point=False)

Size method: returns shortest distance between self and a Front, Point or Substrate.

The distance is computed for the coordinates of the stuctures, not for their extent in space as defined by a radius.

Parameters
  • other (Front, Point or Substrate.) –

  • Optional

  • point (boolean : return also closest point on other, default=False) –

Returns

  • distance in µm (float)

  • if point=True; distance,point (float, Point)

taper(fraction, minimum=0.3)

Size method: returns a tapered radius.

Returns self.radius scaled by fraction, with value larger or equal to optional parameter minimum.

Parameters
  • fraction (float : relative scaling of radius.) –

  • Optional

  • mimimum (float : mimimal radius, default 0.3 µm.) –

Returns

new radius in µm

Return type

float

simulator.average_fronts(front_list)

Compute average position over all fronts in front_list.

Parameters

front_list (list: either list of fronts or list returned by get_fronts) –

Returns

average position

Return type

Point

simulator.swc_name(swc)

Returns string for swc type

Parameters

swc (integer : swc type value) –

Returns

swc name

Return type

string

SynFront subclass

SynFront is a subclass of Front that enables synaptic connections between fronts. Both pre- and postsynaptic neurons have to use the SynFront subclass.

class simulator.SynFront

Bases: simulator.Front

Front class that implements synaptic connections.

Current implementation allows only one synaptic connection per front, the front is either pre- or postsynaptic. Neurons based on SynFront have a firing_rate (default: 1) and a CV_ISI (default 0.) defined that can be accessed with methods.

This class is not meant to be instantiated, instead subclass it with a model specific manage_front method.

Only the attributes listed below can be read in addition to Front attributes. NEVER change these attributes.

syn_input

float : current synaptic input, always 0. for presynaptic front, updated for active postsynaptic front.

nds_class()

Return class name.

Returns

Class name of SynFront subclass

Return type

string

add_synapse(constellation, other_front, weight, presynaptic=True)

Make a synaptic connection with another front.

Parameters
  • constellation (Constellation object.) –

  • other_front (SynFront : postsynaptic (default) or presynaptic front that is also part of this synapse.) –

  • weight (float : synaptic weight. Positive for excitation, negative for inhibition.) –

  • Optional

  • presynaptic (boolean : self is the presynaptic front, default True.) –

remove_synapse(constellation)

Removes the synaptic connection with another front.

Parameters

constellation (Constellation object.) –

has_synapse()

Has self a synaptic connection defined?.

Returns

has self has a synaptic connection defined?

Return type

boolean

get_synapse(constellation)

Returns Synapse if defined.

Parameters

constellation (Constellation object.) –

Returns

Synapse or None

Return type

Synapse

get_branch_synapses(constellation)

Returns a list containing all Synapse present on self and all its descendants.

Parameters

constellation (Constellation object.) –

Returns

List of Synapses

Return type

[Synapse,]

is_presynaptic()

Is self a presynaptic?. Returns False if no synapse defined.

Returns

is self presynaptic?

Return type

boolean

is_postsynaptic()

Is self a postsynaptic?. Returns False if no synapse defined.

Returns

is self postsynaptic?

Return type

boolean

Neuron class

Neuron contains information about all fronts belonging to the same neuron.

class simulator.Neuron

Bases: _ctypes.Structure

Class for storing neuron level data.

Only the attributes listed below can be read. NEVER change these attributes directly, use methods instead for those that can be changed.

WARNING: firing_rate and CV_ISI updates are not stored in the database, use the attrib_to_db method to store these.

soma_ID

ID : ID of the soma or root of the axon tree.

firing_rate

float >= 0. : firing rate of the neuron, used for synaptic connections, default: 1.

CV_ISI

float >= 0. : Coefficient of Variation of the firing InterSpike Interval distribution, used for synaptic connections, default: 0.

num_fronts

integer : number of fronts belonging to the neuron at end of previous cycle.

num_retracted

integer : number of retracted fronts that belonged to the neuron at end of previous cycle.

num_synapses

integer : number of synapses belonging to the neuron at end of previous cycle.

nds_class()

Return class name.

Returns

Class name “Neuron

Return type

string

get_id()

Returns the ID of self.

Returns

self’s unique ID

Return type

ID.

get_dataid(constellation)

Attribute method that returns the DataID of self.

Returns

self’s data id

Return type

DataID

get_name()

Returns the name of the neuron.

Returns

self’s neuron name

Return type

string

get_base_name()

Return name of the neuron without its _number_ at the end.

Returns

self’s name without number

Return type

string

set_firing_rate(constellation, rate)

Change the neuron firing rate: this will affect the entire neuron.

Parameters
  • constellation (Constellation object.) –

  • rate (float >= 0. : new firing rate.) –

set_CV_ISI(constellation, CV_ISI)

Change the neuron firing rate CV: this will affect the entire neuron.

A CV_ISI larger than zero makes the postsynaptic syn_input a stochastic variable.

Parameters
  • constellation (Constellation object.) –

  • CV_ISI (float >= 0. : new firing rate CV.) –

get_neuron_fronts(constellation, returnID=False)

Returns a list of all fronts of the entire neuron.

This method by default returns a list of Front, but can also return a list of ID.

Parameters
  • constellation (Constellation object.) –

  • Optional

  • returnID (boolean : return list of ID, default: False.) –

Returns

Depending on returnID parameter nds_list of [Front,] or of [ID,]

Return type

list.

get_neuron_soma(constellation, returnID=False)

Returns the soma of a neuron.

This method by default returns a Front, but can also return an ID.

Parameters
  • constellation (Constellation object.) –

  • Optional

  • returnID (boolean : return ID, default: False.) –

Returns

Depending on returnID parameter

Return type

Front or ID.

Substrate class

Substrate are chemical cues in the environment identified by a name. In the simplest case this can just be an unknown amount of cue at specific location(s). In more complex cases a diffusion coefficient is defined and stochastic concentrations can be computed with the diff_gradient_to function for either release from a fixed amount or production at a constant rate.

Initialization: Substrate can be instantiated either in the main loop or in any Front method:

# instantiate a substrate without diffusion
orig = Point(10.,10.,10.)
n_mol = 1
sub = Substrate(name, orig, birth, n_mol)
# instantiate a substrate with diffusion from an initial amount
n_mol = int(1e10)
sub = Substrate(name, orig, birth, n_mol, diff_c=10.)
# instantiate a substrate produce at constant rate with diffusion
sub = Substrate(name, orig, birth, 0, rate=10000, diff_c=10.)

Initialization parameters:

  • name (string: name of substrate, multiple substrate can have the same name.)

  • orig (Point: unique location of substrate.)

  • birth (integer: cycle when substrate was/is created, available as constellation.cycle in ``Front`` methods.)

  • n_mol (integer: number of molecules, value is important only when diff_c is defined.)

Optional parameters:

  • rate (float: production rate of substrate, value is important only when diff_c is defined: if larger than zero production rate based diffusion is computed.)

  • diff_c (float: diffusion coefficient of substrate.)

class simulator.Substrate(name, orig, birth, n_mol, rate=0.0, diff_c=0.0)

Bases: _ctypes.Structure

Class implementing substrate.

name

string : name of the substrate.

orig

Point : 3D coordinate with location.

birth

integer : cycle when it was created.

n_mol

integer : number of molecules when it was created.

rate

float : production rate in molecules/cycle (optional).

diff_c

float : 3D diffusion coefficient in µm^2/cycle (optional).

nds_class()

Return class name.

Returns

Class name “Substrate”

Return type

string

get_id()

Returns the ID of self.

Returns

self’s unique ID

Return type

ID.

get_name()

Returns the name of the substrate.

Returns

self’s name

Return type

string.

is_cylinder()

Always False.

Returns

False

Return type

boolean.

simulator.diff_gradient_to(point, substrates, cycle, size=1, what='largest')

Computes a stochastic number of substrate molecules at point and a unit direction vector towards the substrate from point.

Stochasticity can be controlled by changing the size of the sampling volume. Diffusion equation used depends on property of substrate: if rate > 0.0: constant rate based, n_mol value ignored; else: instantaneous point source using n_mol as initial amount.

Parameters
  • point (Point : location at which the concentration is computed.) –

  • substrates (list of Substrate: list of substrate or list returned by get_substrates method.) –

  • cycle (integer : current simulation cycle or -1 to compute concentration at very long time after release (only for rate-based).) –

  • Optional

  • size (integer > 0 : size of cubic sampling box in µm, larger values reduce stochasticity of result, default 1.) –

  • what (string : either 'largest': computes concentration and direction to the nearest point in the list of substrate or 'average': computes summed concentration and mean of all directions, default 'largest'.) –

Returns

number of molecules at *point* and direction to substrate

Return type

integer, Point

Synapse class

Defines attributes for synaptic connections, read-only. Use the SynFront methods to create and access synapses.

class simulator.Synapse

Bases: _ctypes.Structure

Class implementing synaptic connections.

Synaptic strength is computed as presynaptic_neuron.firing_rate * synaptic.weight and is stochastic if presynaptic_neuron.CV_ISI > 0.. Only the attributes listed below can be read. NEVER change these attributes.

WARNING: weight updates are not stored in the database, use the attrib_to_db method to store.

pre_syn

ID : id of the presynaptic front.

post_syn

ID : id of the postsynaptic front.

weight

float : synaptic weight. Positive for excitation, negative for inhibition.

nds_class()

Return class name.

Returns

Class name “Synapse”

Return type

string

set_weight(constellation, weight)

Change the synaptic weight for existing synapse.

Parameters
  • constellation (Constellation object.) –

  • weight (float : new synaptic weight. Positive for excitation, negative for inhibition.) –

Utility classes

Constellation class

class simulator.Constellation(proc, master_constell)

Bases: object

Class that provides other classes access to NeuroDevSim shared memory. Passed to many Front methods and provides some unique methods.

Most of this class is for internal use only. A few attributes listed below can be read. NEVER change these attributes except for only_first_collision which can be changed.

cycle

integer : current simulation cycle.

only_first_collision

boolean : stop checking for collision after first one is found, otherwise continue till all collisions have been detected, this can be changed by the user but will only affect the constellation of a single processor, default: True.

sim_volume

list of 2 lists : the simulation volume as specified during Admin_agent instantiation.

verbose

integer : the verbosity level as specified during Admin_agent instantiation.

front_by_id(id)

Returns Front with given ID.

Parameters

id (ID.) –

Returns

front

Return type

Front or None

neuron_by_id(id)

Returns Neuron with given ID.

Parameters

id (ID.) –

Returns

neuron

Return type

Neuron or None

neuron_type_index(front_class)

Returns index of a front_class, this index is in range 1 - len(neuron_types).

Method will cause a TypeError if front_class does not exist.

Parameters

front_class (string : one of the front_class defined in the neuron_types list for Admin_agent.) –

Returns

type_index

Return type

integer

neurons_by_name(name, type_index=None)

Returns all neurons with given name (wildcard).

Parameters
  • name (string : all neurons that start with name will be returned.) –

  • Optional

  • type_index (integer : index returned by neuron_type_index, only search for neurons of this front_class (faster), default: None.) –

Returns

nds_list of neurons

Return type

[Neuron] or []

neurons_by_front_class(front_class)

Returns all neurons with given front_class.

Parameters

front_class (string : one of the front_class defined in the neuron_types list for Admin_agent.) –

Returns

nds_list of neurons

Return type

[Neuron] or []

neurons_by_type(type_index)

Returns all neurons with given type_index (for front_class).

Parameters

type_index (integer : index returned by neuron_type_index.) –

Returns

nds_list of neurons

Return type

[Neuron] or []

substrate_by_id(id)

Returns Substrate with given ID.

Parameters

id (ID.) –

Returns

substrate

Return type

Substrate or None

id_to_data(id)

Returns the DataID for a given ID.

Parameters

id (ID.) –

Returns

data id

Return type

DataID

data_to_id(data)

Returns the ID for a given DataID.

Parameters

id (data) –

Returns

id

Return type

ID

lock(item, time_out=0.25)

Locks memory access to Front or Substrate objects.

This prevents simultaneous writing by several different processes to the same memory address, resulting in unpredictable outcomes. Should be used before changing any attribute that does not belong to self.

If the object is already locked by another process this call will wait till it the other lock is either released or the time_out period in seconds has passed. Every successful lock call should be followed by an unlock call within the same method context. Do this as soon as possible to allow other processes to access the object when needed.

Parameters
  • item (ID, Front or Substrate.) –

  • Optional

  • time_out (float : time in seconds that lock waits for another process to unlock the item.) –

unlock(item)

Unlocks memory access to Front or Substrate object after a previous lock call.

Should be called from inside the same method that called lock and as soon as possible. Not calling unlock may result in NeuroDevSim hanging or crashing.

Parameters

item (ID, Front or Substrate.) –

add_substrate(substrate)

Add substrate to the simulation.

This method can be called by any Front method. Biological realism requires that fronts add substrate at nearby locations only, but this is not enforced.

Parameters

substrate (Substrate or list of Substrate) –

ID class

class simulator.ID

Bases: _ctypes.Structure

Class that defines the ID used to uniquely identify Front, Neuron and Substrate instantiations.

This class has no public attributes or methods and the private ones may change in future NeuroDevSim implementations.

DataID class

class simulator.DataID

Bases: _ctypes.Structure

Class that describes Front and Neuron using the identifiers used in the sqlite database that stores the simulation results.

This class can be used to print information about Front or Neuron that can be matched with the database entry.

The attributes are read-only, changing them will have no effect.

neuron_id

integer : neuron_id used in sqlite database.

front_id

integer : front_id used in sqlite database, 0 if data is about a Neuron.

nds_list class

class simulator.nds_list(iterable=(), /)

Bases: list

Class implementing a list that prints NeuroDevSim objects inside the list nicely. Otherwise acts as a standard list.

Utility methods

simulator.nds_version(raw=False)

returns version of NeuroDevSim as a string (default) or a number which equals 100 times the version number.

Parameters
  • Optional

  • raw (boolean : return a number instead of a string, default: False.) –

Returns

version

Return type

string or float

simulator.unit_sample_on_sphere()

Returns a random point on a unit sphere around the zero point.

Returns

random unit-length vector

Return type

Point

simulator.unit_sample_on_circle(axis=2)

Returns a random point on a circle around the zero point.

Default is a horizontal circle but another plane can be selected with the axis parameter.

Parameters
  • Optional

  • axis (integer : select plane: 0 is yz plane, 1 is xz plane, 2 is zy plane.) –

Returns

random unit-length vector in a plane

Return type

Point

simulator.unit_sample_on_cone(angle1, angle2=None)

Returns a random point in a vertical cone within two angles relative to vertical: range angle1-angle2, where angle2 >= angle1.

If only angle1 is given it applies a 0-angle1 range.

Parameters
  • angle1 (float : angle in degrees) –

  • Optional

  • angle2 (float : angle in degrees) –

Returns

unit-length vector within two angles

Return type

Point

simulator.angle_two_dirs(dir1, dir2, degree=True)

Returns small angle in degrees between two directions relative to [0.0, 0.0, 0.0]

Parameters
  • dir1 (Point) –

  • dir2 (Point) –

  • Optional

  • degree (return angle in degrees (True) or radians (False), default True.) –

Returns

angle in degrees or radians

Return type

float

simulator.dist3D_cyl_to_cyl(orig, end, front, points=False)

Mathematical method to compute minimal distance between two cylinders. Can return the closest points on each cylinder.

c++ from http://geomalgorithms.com/

Parameters
  • orig (Point : origin of first cylinder.) –

  • end (Point : end of first cylinder.) –

  • front (Front : second cylinder) –

  • Optional

  • points (boolean : return also closest points, default: False.) –

Returns

Depending on points parameter distance or distance and two points

Return type

float or float,Point,Point.

simulator.dist3D_point_to_cyl(point, orig, end, points=False)

Mathematical method to compute minimal distance a point and a cylinder. Can return the closest point on the cylinder.

c++ from http://geomalgorithms.com

Parameters
  • point (Point) –

  • orig (Point : origin of cylinder.) –

  • end (Point : end of cylinder.) –

  • Optional

  • points (boolean : return also closest point, default: False.) –

Returns

Depending on points parameter distance or distance and a points

Return type

float or float,Point.

Errors

class simulator.ActiveChildError

Filipod in migrate_soma call is active.

class simulator.BadChildError(explanation)

Too many children or children with wrong swc_type in migrate_soma call.

explanation

string : bug description

class simulator.BugError(method, explanation)

Bug occurred during the simulation. NeuroDevSim contains a lot of code that checks for inconsistent behavior.

method

string : name of method where bug occurred

explanation

string : bug description

class simulator.CollisionError(only_first, collider, distance)

New front collides with existing one.

Value stored depends on local constellation.only_first_collision: either a single Front (True) of a list of Front (False) is stored in collider

only_first

boolean : copy of constellation.only_first_collision.

collider

Front or [Front,]: colliding front(s).

distance

float or [float,]: distance(s) to colliding front(s).

class simulator.GridCompetitionError(gid)

Process tries to lock an already locked grid point.

This error occurs during collision detection and indicates a great likelihood of future collision. Different from CollisionError the colliding front is unknown.

gid

integer : grid index that is not available

class simulator.InsideParentError

Coordinate is inside the prospective parent front.

class simulator.LockError(type_string, id, proc, lproc)

Front or Substrate locking failed.

type

string : type of lock

id

ID : identifier of front or substrate

proc

integer : number of process that tries to lock

lproc

integer : number of process that has the lock

class simulator.NotSelfError(method)

A method call was attempted for a front different than self. This method only allow calls from self to preserve model integrity.

method

string : name of offending method

class simulator.NotSomaError

Only somata can migrate.

class simulator.OverflowError(array, attribute)

Overflow of a shared array occurred.

array

string : name of overflowing array

attribute

string : name of Admin_agent attribute to increase

class simulator.SynapseError(explanation)

Problem adding or removing synapse.

explanation

string : specific problem.

class simulator.TypeError(message)

A method parameter has an inappropriate type.

message

string : name of the parameter.

class simulator.ValueError(value, range)

A method parameter has an inappropriate value.

value

string : name of the parameter.

range

string : description of allowed range.

class simulator.VolumeError(coord)

Point is outside the simulation volume.

coord

float : first coordinate outside of simulation volume