Simulation

Functions for performing SPICE-based electrical simulation of a neuron given its synapses and skeleton using a simple linear passive model.

Try the interactive simulation tutorial for a tour of basic simulation options.

Note

The simulation module depends on additional packages. Install them from conda-forge:

conda install -c conda-forge ngspice umap-learn scikit-learn matplotlib

NeuronModel

NeuronModel(bodyid[, Ra, Rm, Cm, client])

Neuron model constructor.

NeuronModel.simulate([max_per_region])

Simulate passive model based on neuron inputs and outputs.

NeuronModel.estimate_intra_neuron_delay([...])

Simulate delay between random parts of a neuron.

TimingResult

TimingResult(bodyid, delay_matrix, ...[, ...])

Timing result constructor.

TimingResult.compute_region_delay_matrix()

Generate delay and amplitude matrix based on primary brain regions.

TimingResult.plot_response_from_region(...)

Show neuron response to brain regions based on inputs from a given region.

TimingResult.plot_neuron_domains([path])

Show how the different simulation points cluster in the neuron and their corresponding ROI.

TimingResult.estimate_neuron_domains(...[, plot])

Estimate the domains based on timing estimates.

class neuprint.simulation.NeuronModel(bodyid, Ra=1.2, Rm=0.8, Cm=0.01, *, client=None)[source]

Neuron model constructor.

Create model of a neuron which can be simulated. in different ways.

Parameters
  • bodyid (int) – Segment id for neuron.

  • Ra (float) – axon resistance Examples: 0.4 (Ra_LOW), 1.2 (Ra_MED), 4.0 (Ra_HIGH)

  • Rm (float) – membrane resistance Examples: 0.2 (Rm_LOW), 0.8 (Rm_MED), 3.11 (Rm_HIGH)

  • Cm (float) – membrane capacitance (should not very too much between neurons)

estimate_intra_neuron_delay(num_points=100)[source]

Simulate delay between random parts of a neuron.

This function produces a delay matrix for a set of points determined by pre or post-synaptic sites. The result is a square distance matrix which can be clustered to determine isopotential regions. The points where current are injected do not represent real neural mechanisms and in practice random points could be chosen for simulation. Synapse location are chosen for convenience and to ensure proper weighting on ‘important’ parts of the neuron.

Parameters

num_points (int) – number of points to simulate.

Returns

TimingResult (contains input/output delay matrix)

simulate(max_per_region=10)[source]

Simulate passive model based on neuron inputs and outputs.

Parameters

max_per_region (int) – maxinum number of inputs per primary ROI to sample (0 means all)

Returns

TimingResult (contains input/output delay matrix)

class neuprint.simulation.TimingResult(bodyid, delay_matrix, amplitude_matrix, neuron_io, neuron_conn_info, symmetric=False)[source]

Timing result constructor.

Provides methods for parsing timing results.

Parameters
  • bodyid (int) – Segment id for neuron

  • delay_matrix (dataframe) – nxm matric of source to sink (if source set == sink set, the data can be used to cluster the provided io into different domains.

  • neuron_io (dataframe) – synapse information: location, ispre, brain region

compute_region_delay_matrix()[source]

Generate delay and amplitude matrix based on primary brain regions.

Averages the delay and amplitude between the sources and sinks of the timing results.

Returns

(dataframe, dataframe) for the delay and amplitude from brain region to brain region.

estimate_neuron_domains(num_components, plot=False)[source]

Estimate the domains based on timing estimates.

Note: only works for symmetric sink and source simulation.

Parameters
  • num_components (int) – number of cluster domains

  • plot (bool) – If True, create and return a plot that shows cluster results with predicted labels (can compare with roi labels from plot_neuron_domains). If plot is a string, it is interpreted as a filepath, to which the plot is also written to disk as a PNG.

Returns

(dataframe, dataframe, plot) input and output connection summary split by domain, synapse-level neuron_io indicating component partition. If a plot was requested, then the generated plot is returned as the third tuple element, otherwise that element is None.

plot_neuron_domains(path=None)[source]

Show how the different simulation points cluster in the neuron and their corresponding ROI.

Plots the distance matrix in 2D using delay as the distance.

Parameters

path (str) – save plot to file as png

plot_response_from_region(brain_region, path=None)[source]

Show neuron response to brain regions based on inputs from a given region.

Parameters
  • brain_region (str) – Source brain region.

  • path (str) – Optionally save plot to designated file