RectifiedLNP

class spikeometric.models.RectifiedLNP(lambda_0: float, theta: float, T: int, tau: float, dt: float, r: float, b: float, rng=None)[source]

Bases: spikeometric.models.base_model.BaseModel

The Rectified LNP model from section S.6 of the paper “Systematic errors in connectivity inferred from activity in strongly coupled recurrent circuits”.

It is a Linear-Nonlinear-Poisson model which passes the input to each neuron through a rectified linear nonlinearity to give an expected firing rate and then samples from a Poisson distribution with that rate.

More formally, the model is defined by the three equations:

  1. \[g_i(t+1) = r \: \sum_{\tau = 0}^{T-1} \sum_{j\in \mathcal{N}(i)} (W_0)_{j, i} X_j(t-\tau)c(\tau) + b_i + \mathcal{E}_i(t+1)\]
  2. \[\mu_i(t+1) = \lambda_0 \Delta t [g_i(t+1)) - \theta]_+\]
  3. \[X_i(t+1) \sim \text{Pois}(\mu_i(t+1))\]

The first equation is implemented by the input() method and gives the input to neuron \(i\) at time \(t+1\) as a sum of a recurrent synaptic input, a uniform background input \(b_i\) and an external input \(\mathcal{E}_i(t+1)\). The synaptic input is obtained by convolving the spike history of neighbouring neurons with a coupling filter \(c\), weighted by the synaptic weights \(W_0\). The strength of the recurrence is controlled by the parameter \(r\).

The second equation is implemented by the non_linearity() method and gives the expected firing rate of neuron \(i\) at time \(t+1\) by rectifying the thresholded input and scaling it by the parameter \(\lambda_0\) and the time step \(\Delta t\).

The third equation is implemented by the emit_spikes() method and samples the spikes from a Poisson distribution with rate \(\mu_i(t+1)\).

Parameters
  • lambda_0 (float) – The scaling of the response \(\lambda_0\)

  • theta (float) – The threshold \(\theta\) of the rectified linear nonlinearity

  • T (int) – The coupling window \(T\) in time steps

  • tau (float) – The time constant \(\tau\) in the exponential filter in milliseconds

  • dt (float) – The time step \(\Delta t\)

  • r (float) – The scaling of the recurrent connections \(r\)

  • b (float) – The strength of the uniform background input \(b\)

  • rng (torch.Generator, optional) – The random number generator to use for sampling the spikes, by default None

input(edge_index: torch.Tensor, W: torch.Tensor, state: torch.Tensor, t=- 1) torch.Tensor[source]

The input to the network at time t+1.

\[g_i(t+1) = r \: \sum_{\tau = 0}^{T-1} \sum_{j\in \mathcal{N}(i)} (W_0)_{j, i} X_j(t-\tau)c(\tau) + b_i + \mathcal{E}_i(t+1)\]
Parameters
  • edge_index (torch.Tensor[int]) – The edge index of the network.

  • W (torch.Tensor[float]) – The weights of the network.

  • state (torch.Tensor[int]) – The state of the network at time t.

  • t (int) – The time step of the simulation.

Returns

The input to the network at time t+1.

Return type

torch.Tensor

non_linearity(input: torch.Tensor) torch.Tensor[source]

Computes the response to the input through a rectified linear nonlinearity:

\[\mu_i(t+1) = \lambda_0\Delta t [g_i(t+1)) - \theta]_+\]
Parameters

input (torch.Tensor) – The input to the network at time \(t+1\)

Returns

The response to the input at time \(t+1\)

Return type

torch.Tensor

emit_spikes(rates: torch.Tensor) torch.Tensor[source]

Samples the spikes from a Poisson distribution with rate \(\mu_i(t+1)\).

\[X_i(t+1) \sim \text{Pois}(\mu_i(t+1))\]
Parameters

rates (torch.Tensor[float]) – The expected spike count of the network at time t+1.

Returns

The state of the network at time t+1.

Return type

torch.Tensor

connectivity_filter(W0: torch.Tensor, edge_index: torch.Tensor) torch.Tensor[source]

The connectivity filter of the network is a tensor that contains the synaptic weights between two neurons \(i\) and \(j\) at time step \(t\) after a spike event. This is computed by filtering the initial synaptic weights \(W_0\) with the exponetial coupling kernel \(c\):

\[W_{i,j}(t) = (W_0)_{i,j} \: c(t) = (W_0)_{i,j} e^{- \Delta t \frac{t}{\tau}}\]

Spikes that are emited more than \(T\) time steps ago have no effect on the input.

Parameters
  • W0 (torch.Tensor[float]) – The initial synaptic weights of the network.

  • edge_index (torch.Tensor[int]) – The edge index of the network.

Returns

  • W (torch.Tensor[float]) – The connectivity filter of the network.

  • edge_index (torch.Tensor[int]) – The edge index of the network