Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update poisson_glm_model.py #20

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions spikeometric/models/poisson_glm_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ class PoissonGLM(BaseModel):

More specifically, we have the following equations:

#. .. math:: 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)
#. .. math:: g_i(t+1) = r \: \sum_{t' = 0}^{T-1} \sum_{j\in \mathcal{N}(i)} (W_0)_{j, i} X_j(t-t')c(t') + b_i + \mathcal{E}_i(t+1)
#. .. math:: \mu_i(t+1) = \frac{\Delta t}{\alpha}\: e^{\beta g_i(t+1)}
#. .. math:: X_i(t+1) \sim \text{Pois}(\mu_i(t+1))

The first equation is implemented in the :meth:`input` method and gives the input to neuron :math:`i` at time :math:`t+1`
as a convolution of the spike history of the neighboring neurons with a coupling filter :math:`c`, weighted by the
as a convolution of the spike history of the neighboring neurons with a coupling filter :math:`c(t) = e^{- \Delta t \frac{t}{\tau}}`, weighted by the
connectivity matrix :math:`W_0`, and scaled by the recurrent scaling factor :math:`r`. There is also a uniform background
input :math:`b_i` and an external stimulus :math:`\mathcal{E}_i(t+1)`.

Expand All @@ -37,7 +37,7 @@ class PoissonGLM(BaseModel):
T : int
The number of time steps to consider back in time.
tau : float
The time constant of the exponential filter.
The time constant of the exponential coupling filter.
dt : float
The time step of the simulation in milliseconds.
r : float
Expand Down Expand Up @@ -156,4 +156,4 @@ def connectivity_filter(self, W0: torch.Tensor, edge_index: torch.Tensor) -> tor
The edge index of the network.
"""
t = torch.arange(1, self.T+1, dtype=torch.float32, device=W0.device).repeat(W0.shape[0], 1)
return torch.einsum("i, ij -> ij", W0, torch.exp((t -self.T)*self.dt/self.tau)), edge_index
return torch.einsum("i, ij -> ij", W0, torch.exp((t -self.T)*self.dt/self.tau)), edge_index