hnn_core.Network

class hnn_core.Network(params, add_drives_from_params=False, legacy_mode=True)[source]

The Network class.

Parameters
paramsdict

The parameters to use for constructing the network.

add_drives_from_paramsbool

If True, add drives as defined in the params-dict. NB this is mainly for backward-compatibility with HNN GUI, and will be deprecated in a future release. Default: False

legacy_modebool

Set to True by default to enable matching HNN GUI output when drives are added suitably. Will be deprecated in a future release.

Attributes
cell_typesdict

Dictionary containing names of real cell types in the network (e.g. ‘L2_basket’) as keys and corresponding Cell instances as values. The Cell instance associated with a given key is used as a template for the other cells of its type in the population.

gid_rangesdict

A dictionary of unique identifiers of each real and artificial cell in the network. Every cell type is represented by a key read from cell_types, followed by keys read from external_drives. The value of each key is a range of ints, one for each cell in given category. Examples: ‘L2_basket’: range(0, 270), ‘evdist1’: range(272, 542), etc

pos_dictdict

Dictionary containing the coordinate positions of all cells. Keys are ‘L2_pyramidal’, ‘L5_pyramidal’, ‘L2_basket’, ‘L5_basket’, or any external drive name

cell_responseCellResponse

An instance of the CellResponse object.

external_drivesdict (keys: drive names) of dict (keys: parameters)

The external driving inputs to the network. Drives are added by defining their spike-time dynamics, and their connectivity to the real cells of the network. Event times are instantiated before simulation, and are stored under the 'events'-key (list of list; first index for trials, second for event time lists for each drive cell).

external_biasesdict of dict (bias parameters for each cell type)

The parameters of bias inputs to cell somata, e.g., tonic current clamp

connectivitylist of dict

List of dictionaries specifying each cell-cell and drive-cell connection

rec_arraysdict

Stores electrode position information and voltages recorded by them for extracellular potential measurements. Multiple electrode arrays may be defined as unique keys. The values of the dictionary are instances of hnn_core.extracellular.ExtracellularArray.

thresholdfloat

Firing threshold of all cells.

delayfloat

Synaptic delay in ms.

Notes
—-
`net = jones_2009_model(params)` is the reccomended path for creating a
network. Instantiating the network as `net = Network(params)` will
produce a network with no cell-to-cell connections. As such,
connectivity information contained in `params` will be ignored.

Methods

add_bursty_drive(name, *[, tstart, …])

Add a bursty (rhythmic) external drive to all cells of the network

add_connection(src_gids, target_gids, loc, …)

Appends connections to connectivity list

add_electrode_array(name, electrode_pos, *)

Specify coordinates of electrode array for extracellular recording.

add_evoked_drive(name, *, mu, sigma, …[, …])

Add an ‘evoked’ external drive to the network

add_poisson_drive(name, *[, tstart, tstop, …])

Add a Poisson-distributed external drive to the network

add_tonic_bias(*[, cell_type, amplitude, …])

Attach parameters of tonic biasing input for a given cell type.

clear_connectivity()

Remove all connections defined in Network.connectivity

clear_drives()

Remove all drives defined in Network.connectivity

copy()

Return a copy of the Network instance

gid_to_type(gid)

Reverse lookup of gid to type.

plot_cells([ax, show])

Plot the cells using Network.pos_dict.

set_cell_positions(*[, inplane_distance, …])

Set relative positions of cells arranged in a square grid

__repr__()[source]

Return repr(self).

add_bursty_drive(name, *, tstart=0, tstart_std=0, tstop=None, location, burst_rate, burst_std=0, numspikes=2, spike_isi=10, n_drive_cells=1, cell_specific=False, weights_ampa=None, weights_nmda=None, synaptic_delays=0.1, space_constant=100.0, probability=1.0, event_seed=2, conn_seed=3)[source]

Add a bursty (rhythmic) external drive to all cells of the network

Parameters
namestr

Unique name for the drive

tstartfloat

Start time of the burst trains (default: 0)

tstart_stdfloat

If greater than 0, randomize start time with standard deviation tstart_std (unit: ms). Effectively jitters start time across multiple trials.

tstopfloat

End time of burst trains (defaults to None: tstop is set to the end of the simulation)

locationstr

Target location of synapses (‘distal’ or ‘proximal’)

burst_ratefloat

The mean rate at which cyclic bursts occur (unit: Hz)

burst_stdfloat

The standard deviation of the burst occurrence on each cycle (unit: ms). Default: 0 ms

numspikesint

The number of spikes in a burst. This is the spikes/burst parameter in the GUI. Default: 2 (doublet)

spike_isifloat

Time between spike events within a cycle (ISI). Default: 10 ms

n_drive_cellsint | ‘n_cells’

The number of drive cells that contribute an independently sampled burst at each cycle. If n_drive_cells=’n_cells’ and cell_specific=True, a drive cell gets assigned to each available simulated cell in the network with 1-to-1 connectivity. Otherwise (default: 1), drive cells are assigned with all-to-all connectivity and provide synchronous input to cells in the network.

cell_specificbool

Whether each artifical drive cell has 1-to-1 (True) or all-to-all (False, default) connection parameters. Note that 1-to-1 connectivity requires that n_drive_cells=’n_cells’, where ‘n_cells’ denotes the number of all available cells that this drive can target in the network.

weights_ampadict or None

Synaptic weights (in uS) of AMPA receptors on each targeted cell type (dict keys). Cell types omitted from the dict are set to zero.

weights_nmdadict or None

Synaptic weights (in uS) of NMDA receptors on each targeted cell type (dict keys). Cell types omitted from the dict are set to zero.

synaptic_delaysdict or float

Synaptic delay (in ms) at the column origin, dispersed laterally as a function of the space_constant. If float, applies to all target cell types. Use dict to create delay->cell mapping.

space_constantfloat

Describes lateral dispersion (from the column origin) of synaptic weights and delays within the simulated column. The constant is measured in the units of inplane_distance of Network. For example, for space_constant=3, the weights and delays are modulated by the factor exp(-(x / (3 * inplane_distance)) ** 2), where x is the physical distance (in um) between the connected cells in the xy plane.

probabilitydict or float (default: 1.0)

Probability of connection between any src-target pair. Use dict to create probability->cell mapping. If float, applies to all target cell types.

event_seedint

Optional initial seed for random number generator (default: 2). Used to generate event times for drive cells.

conn_seedint

Optional initial seed for random number generator (default: 3). Used to randomly remove connections when probablity < 1.0.

add_connection(src_gids, target_gids, loc, receptor, weight, delay, lamtha, allow_autapses=True, probability=1.0, conn_seed=3)[source]

Appends connections to connectivity list

Parameters
src_gidsstr | int | range | list of int

Identifier for source cells. Passing str arguments (‘evdist1’, ‘L2_pyramidal’, ‘L2_basket’, ‘L5_pyramidal’, ‘L5_basket’, etc.) is equivalent to passing a list of gids for the relevant cell type. source - target connections are made in an all-to-all pattern.

target_gidsstr | int | range | list of int

Identifer for targets of source cells. Passing str arguments (‘L2_pyramidal’, ‘L2_basket’, ‘L5_pyramidal’, ‘L5_basket’) is equivalent to passing a list of gids for the relevant cell type. source - target connections are made in an all-to-all pattern.

locstr

Location of synapse on target cell. Must be ‘proximal’, ‘distal’, or ‘soma’. Note that inhibitory synapses (receptor=’gabaa’ or ‘gabab’) of L2 pyramidal neurons are only valid loc=’soma’.

receptorstr

Synaptic receptor of connection. Must be one of: ‘ampa’, ‘nmda’, ‘gabaa’, or ‘gabab’.

weightfloat

Synaptic weight on target cell.

delayfloat

Synaptic delay in ms.

lamthafloat

Space constant.

allow_autapsesbool

If True, allow connecting neuron to itself.

probabilityfloat

Probability of connection between any src-target pair. Defaults to 1.0 producing an all-to-all pattern.

conn_seedint

Optional initial seed for random number generator (default: 2). Used to randomly remove connections when probablity < 1.0.

Notes

Connections are stored in: net.connectivity[idx][‘gid_pairs’] : dict

dict indexed by src gids with the format: {src_gid: [target_gids, …], …} where each src_gid indexes a list of all its targets.

add_electrode_array(name, electrode_pos, *, conductivity=0.3, method='psa', min_distance=0.5)[source]

Specify coordinates of electrode array for extracellular recording.

Parameters
namestr

Unique name of the array.

electrode_postuple | list of tuple

Coordinates specifying the position for extracellular electrodes in the form of (x, y, z) (in um).

conductivityfloat

Extracellular conductivity, in S/m, of the assumed infinite, homogeneous volume conductor that the cell and electrode are in.

methodstr

Approximation to use. 'psa' (point source approximation) treats each segment junction as a point extracellular current source. 'lsa' (line source approximation) treats each segment as a line source of current, which extends from the previous to the next segment center point: |---x---|, where x is the current segment flanked by |.

min_distancefloat (default: 0.5; unit: um)

To avoid numerical errors in calculating potentials, apply a minimum distance limit between the electrode contacts and the active neuronal membrane elements that act as sources of current. The default value of 0.5 um corresponds to 1 um diameter dendrites.

add_evoked_drive(name, *, mu, sigma, numspikes, location, n_drive_cells='n_cells', cell_specific=True, weights_ampa=None, weights_nmda=None, space_constant=3.0, synaptic_delays=0.1, probability=1.0, event_seed=2, conn_seed=3)[source]

Add an ‘evoked’ external drive to the network

Parameters
namestr

Unique name for the drive

mufloat

Mean of Gaussian event time distribution

sigmafloat

Standard deviation of event time distribution

numspikesint

Number of spikes at each target cell

locationstr

Target location of synapses (‘distal’ or ‘proximal’)

n_drive_cellsint | ‘n_cells’

The number of drive cells that each contribute an independently sampled synaptic spike to the network according to the Gaussian time distribution (mu, sigma). If n_drive_cells=’n_cells’ (default) and cell_specific=True, a drive cell gets assigned to each available simulated cell in the network with 1-to-1 connectivity. Otherwise, drive cells are assigned with all-to-all connectivity. If you wish to synchronize the timing of this evoked drive across the network in a given trial with one spike, set n_drive_cells=1 and cell_specific=False.

cell_specificbool

Whether each artifical drive cell has 1-to-1 (True, default) or all-to-all (False) connection parameters. Note that 1-to-1 connectivity requires that n_drive_cells=’n_cells’, where ‘n_cells’ denotes the number of all available cells that this drive can target in the network.

weights_ampadict or None

Synaptic weights (in uS) of AMPA receptors on each targeted cell type (dict keys). Cell types omitted from the dict are set to zero.

weights_nmdadict or None

Synaptic weights (in uS) of NMDA receptors on each targeted cell type (dict keys). Cell types omitted from the dict are set to zero.

synaptic_delaysdict or float

Synaptic delay (in ms) at the column origin, dispersed laterally as a function of the space_constant. If float, applies to all target cell types. Use dict to create delay->cell mapping.

space_constantfloat

Describes lateral dispersion (from the column origin) of synaptic weights and delays within the simulated column. The constant is measured in the units of inplane_distance of Network. For example, for space_constant=3, the weights are modulated by the factor exp(-(x / (3 * inplane_distance)) ** 2), where x is the physical distance (in um) between the connected cells in the xy plane (delays are modulated by the inverse of this factor).

probabilitydict or float (default: 1.0)

Probability of connection between any src-target pair. Use dict to create probability->cell mapping. If float, applies to all target cell types

event_seedint

Optional initial seed for random number generator (default: 2). Used to generate event times for drive cells. Not fixed across trials (see Notes)

conn_seedint

Optional initial seed for random number generator (default: 3). Used to randomly remove connections when probablity < 1.0. Fixed across trials (see Notes)

Notes

Random seeding behavior across trials is different for event_seed and conn_seed (n_trials > 1 in simulate_dipole(…, n_trials) event_seed

Across trials, the random seed is incremented leading such that the exact spike times are different

conn_seed

The random seed does not change across trials. This means for probability < 1.0, the random subset of gids targeted is the same.

add_poisson_drive(name, *, tstart=0, tstop=None, rate_constant, location, n_drive_cells='n_cells', cell_specific=True, weights_ampa=None, weights_nmda=None, space_constant=100.0, synaptic_delays=0.1, probability=1.0, event_seed=2, conn_seed=3)[source]

Add a Poisson-distributed external drive to the network

Parameters
namestr

Unique name for the drive

tstartfloat

Start time of Poisson-distributed spike train (default: 0)

tstopfloat

End time of the spike train (defaults to None: tstop is set to the end of the simulation)

rate_constantfloat or dict of floats

Rate constant (lambda > 0) of the renewal-process generating the samples. If a float is provided, the same rate constant is applied to each target cell type. Cell type-specific values may be provided as a dictionary, in which a key must be present for each cell type with non-zero AMPA or NMDA weights.

locationstr

Target location of synapses (‘distal’ or ‘proximal’)

n_drive_cellsint | ‘n_cells’

The number of drive cells that each contribute an independently sampled synaptic spike to the network according to a Poisson process. If n_drive_cells=’n_cells’ (default) and cell_specific=True, a drive cell gets assigned to each available simulated cell in the network with 1-to-1 connectivity. Otherwise, drive cells are assigned with all-to-all connectivity. If you wish to synchronize the timing of Poisson drive across the network in a given trial, set n_drive_cells=1 and cell_specific=False.

cell_specificbool

Whether each artifical drive cell has 1-to-1 (True, default) or all-to-all (False) connection parameters. Note that 1-to-1 connectivity requires that n_drive_cells=’n_cells’, where ‘n_cells’ denotes the number of all available cells that this drive can target in the network.

weights_ampadict or None

Synaptic weights (in uS) of AMPA receptors on each targeted cell type (dict keys). Cell types omitted from the dict are set to zero.

weights_nmdadict or None

Synaptic weights (in uS) of NMDA receptors on each targeted cell type (dict keys). Cell types omitted from the dict are set to zero.

synaptic_delaysdict or float

Synaptic delay (in ms) at the column origin, dispersed laterally as a function of the space_constant. If float, applies to all target cell types. Use dict to create delay->cell mapping.

space_constantfloat

Describes lateral dispersion (from the column origin) of synaptic weights and delays within the simulated column. The constant is measured in the units of inplane_distance of Network. For example, for space_constant=3, the weights and delays are modulated by the factor exp(-(x / (3 * inplane_distance)) ** 2), where x is the physical distance (in um) between the connected cells in the xy plane.

probabilitydict or float (default: 1.0)

Probability of connection between any src-target pair. Use dict to create probability->cell mapping. If float, applies to all target cell types.

event_seedint

Optional initial seed for random number generator (default: 2). Used to generate event times for drive cells.

conn_seedint

Optional initial seed for random number generator (default: 3). Used to randomly remove connections when probablity < 1.0.

add_tonic_bias(*, cell_type=None, amplitude=None, t0=None, tstop=None)[source]

Attach parameters of tonic biasing input for a given cell type.

Parameters
cell_typestr

The cell type whose cells will get the tonic input. Valid inputs are those in net.cell_types.

amplitudefloat

The amplitude of the input.

t0float

The start time of tonic input (in ms). Default: 0 (beginning of simulation).

tstopfloat

The end time of tonic input (in ms). Default: end of simulation.

clear_connectivity()[source]

Remove all connections defined in Network.connectivity

clear_drives()[source]

Remove all drives defined in Network.connectivity

copy()[source]

Return a copy of the Network instance

The returned copy retains the intrinsic connectivity between cells, as well as those of any external drives or biases added to the network. The parameters of drive dynamics are also retained, but the instantiated events of the drives are cleared. This allows iterating over the values defining drive dynamics, without the need to re-define connectivity. Extracellular recording arrays are retained in the network, but cleared of existing data.

Returns
net_copyinstance of Network

A copy of the instance with previous simulation results and events of external drives removed.

gid_to_type(gid)[source]

Reverse lookup of gid to type.

plot_cells(ax=None, show=True)[source]

Plot the cells using Network.pos_dict.

Parameters
axinstance of matplotlib Axes3D | None

An axis object from matplotlib. If None, a new figure is created.

showbool

If True, show the figure.

Returns
figinstance of matplotlib Figure

The matplotlib figure handle.

set_cell_positions(*, inplane_distance=None, layer_separation=None)[source]

Set relative positions of cells arranged in a square grid

Note that it is possible to change only a subset of the parameters (the default value of each is None, which implies no change).

Parameters
inplane_distancefloat

The in plane-distance (in um) between pyramidal cell somas in the square grid. Note that this parameter does not affect the amplitude of the dipole moment.

layer_separationfloat

The separation of pyramidal cell soma layers 2/3 and 5. Note that this parameter does not affect the amplitude of the dipole moment.

Examples using hnn_core.Network