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

Check/fix physical units of input spike train #727

Closed
clinssen opened this issue Feb 11, 2022 · 3 comments · Fixed by #882
Closed

Check/fix physical units of input spike train #727

clinssen opened this issue Feb 11, 2022 · 3 comments · Fixed by #882

Comments

@clinssen
Copy link
Contributor

clinssen commented Feb 11, 2022

The unit $[\delta(x)]$ of the Dirac delta "function" $\delta(x)$ follows
from its definition:

$f(y) = \int dx \delta(x-y) f(x)$

Here, f(.) is some arbitrary continuous function. As the f(.) on the lhs
has the same unit as the f(.) on the rhs, the unit of

$dx \delta(x)$

must be equal to 1. Hence, the unit $[\delta(x)]$ of the delta function
must be identical to the inverse $1/[x]$ of the unit $[x]$ of its argument
x, i.e.

$[\delta(x)] = 1/[x]$

This is a very generic property of the delta function. For the special
case where x is a measure of time with unit s, $\delta(x)$ must
consequently have units 1/s.

In the neuroscience context, we often use

$\xi(t) = \sum_k \delta(t-t_k)$

to represent sequences of spikes at times t_k (spike train), because
then we can easily construct other signals that are derived from spikes
by a convolution integral

$g(t)$
$= \int du \xi(u) h(t-u)$
$= \sum_k \int du \delta(u-t_k) h(t-u)$
$= \sum_k h(t-t_k)$

such as the number of spikes in a certain time interval, the synaptic
input current, the membrane potential, etc. If the kernel $h(t)$ on the
rhs has the same unit as $g(t)$, the delta function needs to have units of
1/s. Same reasoning as above.

Reference: https://en.wikipedia.org/wiki/Dirac_delta_function

With credits to @tomtetzlaff for pointing this out!

@clinssen
Copy link
Contributor Author

clinssen commented Mar 8, 2023

See also #368. The discussion there seems to have focused on whether kernels (called shapes at the time) or the spike input ports should have a unit type. My proposal (and if I understand it right also @tfardet's in that thread) is for neither to have a unit type.

The input port with the unit now looks like:

input:
  spikes_exc nS <- excitatory spike

So an input port without the unit, for example:

input:
  spikes_exc <- excitatory spike

would be interpreted as a train of delta pulses: spikes_exc = $\sum_i \delta(t - t_i)$ which would have units 1/s (see the discussion above, provided by @tomtetzlaff). The NESTML kernels are also dimensionless, and so a convolution between a kernel and an input port would be dimensionless. So the unit would then be introduced outside of the convolution, e.g.

old:

inline I_syn_exc pA = convolve(g_exc, spikes_exc) * ( V_m - E_exc )

new: 1

inline I_syn_exc pA = nS * convolve(g_exc, spikes_exc) * ( V_m - E_exc )

new: 2

parameters:
  cond_per_spike nS = 1 nS
inline I_syn_exc pA = cond_per_spike * convolve(g_exc, spikes_exc) * ( V_m - E_exc )

@tfardet
Copy link

tfardet commented Mar 8, 2023

I support spikes having no units
For kernels, I don't really mind whether they have units or not.

@pnbabu
Copy link
Contributor

pnbabu commented Mar 10, 2023

After the discussion with Abigail and others at the lab meeting, we decided to remove units from the spiking input ports. So the resulting definition of a spiking port would be:

input:
  spikes_exc <- excitatory spike

and to use spikes_exc in the equations, we could have a parameter to multiply the right unit.

parameters:
  cond_per_spike nS = 1 nS
equations:
  inline I_syn_exc pA = cond_per_spike * convolve(g_exc, spikes_exc) * ( V_m - E_exc )

To avoid memory usage for the variable cond_per_spike in the resulting target platform, as per @clinssen's suggestion, we could introduce a new keyword, say const, and substitute the parameter's value directly in the equation during the code generation process.

parameters:
  const cond_per_spike nS = 1 nS
equations:
  inline I_syn_exc pA = cond_per_spike * convolve(g_exc, spikes_exc) * ( V_m - E_exc )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants