build_network.py

The script used to build the network for the simulation run in run_network.py

class L5NeuronSimulation.FullSimulation.build_network.SimulationBuilder(params_file, seed=123)[source]

Class used to build our BMTK simulation.

params

contains parameters for the network

Type

dict

seed

base random seed for the simulation

Type

int

syn

contains synaptic templates

Type

dict

n_dend_exc

number of excitatory input cells on the basal dendrites

Type

int

n_apic_exc

number of excitatory input cells on the apical dendrites

Type

int

n_dend_inh

number of inhibitory (SOM+) input cells on the basal dendrites more than 50 um from the soma.

Type

int

n_apic_inh

number of inhibitory (SOM+) input cells on the apical dendrites

Type

int

n_prox_dend_inh

number of inhibitory (PV+) input cells on the basal dendrites less than 50 um from the soma

Type

int

n_soma_inh

number of inhibitory (PV+) input cells on the soma

Type

int

clust_per_group

number of clusters per functional group

Type

int

net

the BMTK network for the biophysical cell

Type

NetworkBuilder

exc_stim

the BMTK network for excitatory inputs

Type

NetworkBuilder

prox_inh_stim

the BMTK network for perisomatic inhibition

Type

NetworkBuilder

dist_inh_stim

the BMTK network for dendritic inhibition

Type

NetworkBuilder

dend_groups

all excitatory functional groups on the basal dendrites

Type

list

apic_groups

all excitatory functional groups on the apical dendrites

Type

list

build()[source]

builds the network

save_groups()[source]

saves the functional groups to a csv

_set_prefixed_directory(base_dir_name: str)[source]

sets up the correct biophy_components structure based on the cell prefix in params for the given directory base

_build_exc()[source]

creates excitatory input nodes and edges

_build_exc_nodes(segs : pandas.DataFrame, base_name : str, n_cells : int, start=0 : int)[source]

builds excitatory nodes

_build_exc_edges(group_list: list)[source]

builds excitatory edges

_save_nets()[source]

builds and saves the BMTK NetworkBuilders

_build_inh()[source]

creates inhibitory input nodes and edges

_make_rasters()[source]

creates the inhibitory and excitatory input rasters

_gen_exc_spikes(fname: str)[source]

generates and saves the excitatory spike rasters

_gen_inh_spikes(n_cells: int, mean_fr: float, std_fr: float, key: str, fname: str)[source]

creates inhibitory spike rasters, using a noise trace based on averaging excitation and shifting it

_modify_jsons()[source]

modifies the various json files however is needed after they are built

_modify_sim_config()[source]

modifies the simulation_config.json however is needed

_update_cellvar_record_locs(sim_config: dict)[source]

modifies the location of cellvar recordings in the given JSON simulation_config

Static Methods
--------------
_get_directory_prefix(directory: str)[source]

reads the prefix.txt fil in directory and returns the contents

_connector_func(sources: list, targets: list, cells: list)[source]

sets the number of synapses from the given cells

_set_location(source: dict, target: dict, cells: list, start_id: int)[source]

sets the location of the given edge

_norm_connect(source: dict, target: dict, m: float, s: float, low: int, high: int)[source]

used to normally distribute connection counts

_gen_group_spikes(writer: SonataWriter, group: FunctionalGroup, seconds: float, start_time: float, dist: func)[source]

creates and saves a functional group’s spike raster

_norm_rvs(mean: float, std: float)[source]

generates a random float from a normal distribution with a near zero minimum

_build_exc()[source]

Builds the excitatory input cells and their synapses.

_build_exc_edges(group_list)[source]

Creates the connections between each cell in the list of groups and the biophysical cell.

Parameters

group_list (list) – list of functional groups

_build_exc_nodes(segs, base_name, n_cells, start=0)[source]

Creates the functional groups and adds the virtual cells to the BMTK NetworkBuilder

Parameters
  • segs (pandas.DataFrame) – all the segments available for the functional groups

  • base_name (str) – the string that is appended to to make the group names. groups get 0 - n_groups appended to their names.

  • n_cells (int) – total number of input cells that should be added.

  • start (int, optional) – starting id to be associated with the functional groups, by default 0 this is used later to associate cells in functional groups with the correct locations and synapses.

Returns

  • int – what the start parameter should be for the next call to _build_exc_nodes

  • list – list of functional groups that were created

_build_inh()[source]

Creates inhibitory input nodes and their connections onto the biophysical cell

_connector_func(target, cells)[source]

Used to set the number of synapses from each excitatory input cell in a functional group. Use with “all_to_one” iterator.

Parameters
  • sources (list) – presynaptic nodes (represented as dicts)

  • target (dict) – postsynaptic node

  • cells (list) – list of Cells in the FunctionalGroup

Returns

list of synapses for each pairing

Return type

list

_gen_exc_spikes(fname)[source]

Generates the excitatory input raster for all of the functional groups

Parameters

fname (str) – name of the file to save the rasters in (.h5)

_gen_group_spikes(group, seconds, start_time, dist)[source]

Generates and writes to a h5 file the given functional group’s spike trains

Parameters
  • writer (SonataWriter) – how the spike trains are saved

  • group (FunctionalGroup) – the functional group that the spike trains are being made for

  • seconds (float) – length of the spike trains in seconds

  • start_time (float) – what time (ms) the spike trains should start at

  • dist (func) – function for random distribution used for an individual cell’s firing rate

_gen_inh_spikes(n_cells, mean_fr, std_fr, rhythmic_dict, key, fname)[source]

Generates a spike raster with each train having the noise trace from averaging excitation. Distributes firing rates normally.

Parameters
  • n_cells (int) – number of spike trains

  • mean_fr (float) – mean firing rate

  • std_fr (float) – standard deviation of the firing rate

  • rhythmic_dict (dict) – dictionary with keys f - frequency, mod - depth of modulation

  • key (str) – name of the second group in the h5 file

  • fname (str) – name of file to save the raster to

_get_directory_prefix()[source]

Returns the contents of the prefix.txt file in the given directory.

Parameters

directory (str) – directory to look in

Returns

contents of prefix.txt

Return type

str

_make_rasters()[source]

Generates excitatory and inhibitory input rasters

_modify_jsons()[source]

modifies the various json files however is needed after they are built

_modify_sim_config()[source]

modifies the simulation_config.json however is needed

_norm_connect(target, m, s, low, high)[source]

Returns a random number of synapses based on the given distribution.

Parameters
  • source (dict) – source node

  • target (dict) – target node

  • m (float) – mean number of connections

  • s (float) – standard deviation of number of connections

  • low (int) – minimum number of connections

  • high (int) – maximum number of connections

Returns

number of connections

Return type

int

_norm_rvs(std)[source]

Generates a random float from a normal distribution with a near zero minimum

Parameters
  • mean (float) – mean of the distribution

  • std (float) – standard deviation of the distribution

Returns

random float

Return type

float

_save_nets()[source]

builds and saves the BMTK NetworkBuilders

_set_location(target, cells, start_id)[source]

Sets the location of the given synapse.

Parameters
  • source (dict) – source node information

  • target (dict) – target node information

  • cells (list) – Cells in the functional group

  • start_id (int) – start_id for the functional groups the cells come from

Returns

  • int – BMTK section id

  • float – distance along the section

_set_prefixed_directory(base_dir_name)[source]

Fixes the biophy_components directory. There should be only one directory named <base_dir_name> and it should be the one with the prefix.txt file in it that has the same prefix as params.

Parameters

base_dir_name (str) – base name of the set of directories to be fixed

_update_cellvar_record_locs(sim_config)[source]

modifies the location of cellvar recordings in the given JSON simulation_config

Parameters

sim_config (dict) – simulation_config to modify

build()[source]

Builds the nodes and edges for the network.

save_groups()[source]

saves the apic and dend groups into a csv. one row for each node containgin the id of the functional group it is in.