Simulation module¶
Module to interact easily with the NEST simulator. It allows to :
- build a NEST network from
Network
orSpatialNetwork
objects, - monitor the activity of the network (taking neural groups into account)
- plot the activity while separating the behaviours of predefined neural groups
Content¶
-
nngt.simulation.
make_nest_network
(network, use_weights=True)[source]¶ Create a new subnetwork which will be filled with neurons and connector objects to reproduce the topology from the initial network.
Parameters: - network (
nngt.Network
ornngt.SpatialNetwork
) – the network we want to reproduce in NEST. - use_weights (bool, optional (default: True)) – Whether to use the network weights or default ones (value: 10.).
Returns: - subnet (tuple (node in NEST)) – GID of the new NEST subnetwork
- gids (tuple (nodes in NEST)) – GIDs of the neurons in subnet
- network (
-
nngt.simulation.
get_nest_network
(nest_subnet, id_converter=None)[source]¶ Get the adjacency matrix describing a NEST subnetwork.
Parameters: - nest_subnet (tuple) – Subnetwork node in NEST.
- id_converter (dict, optional (default: None)) – A dictionary which maps NEST gids to the desired neurons ids.
Returns: mat_adj (
lil_matrix
) – Adjacency matrix of the network.
-
nngt.simulation.
set_noise
(gids, mean, std)[source]¶ Submit neurons to a current white noise. @todo: check how NEST handles the \(\sqrt{t}\) in the standard dev.
Parameters: - gids (tuple) – NEST gids of the target neurons.
- mean (float) – Mean current value.
- std (float) – Standard deviation of the current
Returns: noise (tuple) – The NEST gid of the noise_generator.
-
nngt.simulation.
set_poisson_input
(gids, rate)[source]¶ Submit neurons to a Poissonian rate of spikes.
Parameters: - gids (tuple) – NEST gids of the target neurons.
- rate (float) – Rate of the spike train.
Returns: poisson_input (tuple) – The NEST gid of the poisson_generator.
-
nngt.simulation.
monitor_nodes
(gids, nest_recorder=['spike_detector'], params=[{}], network=None)[source]¶ Monitoring the activity of nodes in the network.
Parameters: - gids (tuple of ints or list of tuples) – GIDs of the neurons in the NEST subnetwork; either one list per recorder if they should monitor different neurons or a unique list which will be monitored by all devices.
- nest_recorder (list of strings, optional (default: [“spike_detector”])) – List of devices to monitor the network.
- params (list of dict, optional (default: [{}])) – List of dictionaries containing the parameters for each recorder (see NEST documentation for details).
- network (
Network
or subclass, optional (default: “”)) – Network which population will be used to differentiate inhibitory and excitatory spikes.
Returns: recorders (tuple) – Tuple of the recorders’ gids
-
nngt.simulation.
plot_activity
(gid_recorder, record, network=None, gids=None, show=True, limits=None, hist=True)[source]¶ Plot the monitored activity.
Parameters: - gid_recorder (tuple or list) – The gids of the recording devices.
- record (tuple or list) – List of the monitored variables for each device.
- network (
Network
or subclass, optional (default: None)) – Network which activity will be monitored. - gids (tuple, optional (default: None)) – NEST gids of the neurons which should be monitored.
- show (bool, optional (default: True)) – Whether to show the plot right away or to wait for the next plt.show().
- hist (bool, optional (default: True)) – Whether to display the histogram when plotting spikes rasters.
- limits (tuple, optional (default: None)) – Time limits of the plot (if not specified, times of first and last spike for raster plots).
Returns: fignums (list) – List of the figure numbers.
-
nngt.simulation.
activity_types
(network, spike_detector, limits, phase_coeff=(0.5, 10.0), mbis=0.5, mfb=0.2, mflb=0.05, simplify=False, fignums=[], show=False)[source]¶ Analyze the spiking pattern of a neural network. @todo: think about inserting t= and t=simtime at the beginning and at the end of ``times’‘.
Parameters: - network (
Network
) – Neural network that was analyzed - spike_detector (NEST node(s), (tuple or list of tuples)) – The recording device that monitored the network’s spikes
- limits (tuple of floats) – Time limits of the simulation regrion which should be studied (in ms).
- phase_coeff (tuple of floats, optional (default: (0.2, 5.))) –
A phase is considered bursting’ when the interspike between all spikes
that compose it is smaller than ``phase_coeff[0]*avg_rate` (where
avg_rate
is the average firing rate), quiescent’ when it is greater that ``phase_coeff[1]*avg_rate`, `mixed’ otherwise. - mbis (float, optional (default: 0.5)) – Maximum interspike interval allowed for two spikes to be considered in the same burst (in ms).
- mfb (float, optional (default: 0.2)) – Minimal fraction of the neurons that should participate for a burst to be validated (i.e. if the interspike is smaller that the limit BUT the number of participating neurons is too small, the phase will be considered as localized).
- mflb (float, optional (default: 0.05)) – Minimal fraction of the neurons that should participate for a local burst to be validated (i.e. if the interspike is smaller that the limit BUT the number of participating neurons is too small, the phase will be considered as mixed).
- simplify (bool, optional (default: False)) –
If
True
, mixed phases that are contiguous to a burst are incorporated to it. - return_steps (bool, optional (default: False)) –
If
True
, a second dictionary, phases_steps will also be returned. @todo: not implemented yet - fignums (list, optional (default: [])) – Indices of figures on which the periods can be drawn.
- show (bool, optional (default: False)) – Whether the figures should be displayed.
Returns: - phases (dict) –
Dictionary containing the time intervals (in ms) for all four phases
(bursting’, `quiescent’, `mixed’, and `localized) as lists.
E.g:
phases["bursting"]
could give[[123.5,334.2],[857.1,1000.6]]
. - phases_steps (dict, optional (not implemented yet)) – Dictionary containing the timesteps in NEST.
- network (