From 71d2426f75a8884a7b262cf367db0abec2b5fb69 Mon Sep 17 00:00:00 2001 From: Kyle Johnsen Date: Wed, 13 Mar 2024 16:25:21 -0400 Subject: [PATCH] clarify tau units in spikes_to_biexp --- pyproject.toml | 2 +- wslfp/spk2curr.py | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e45d61f..86f61b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "wslfp" -version = "0.1.1" +version = "0.1.2" description = "Weighted Sum Local Field Potentials - Implementation of the proxy method for point neurons from Mazzoni, Lindén et al., 2015" authors = [ "Kyle Johnsen ", diff --git a/wslfp/spk2curr.py b/wslfp/spk2curr.py index 7d798c6..6c33e74 100644 --- a/wslfp/spk2curr.py +++ b/wslfp/spk2curr.py @@ -21,8 +21,8 @@ def spikes_to_biexp_currents( t_spk_ms: np.ndarray, i_spk: np.ndarray, J: Union[np.ndarray, sparse.sparray], - tau1: float, - tau2: float, + tau1_ms: float, + tau2_ms: float, syn_delay_ms: float = 1, normalize: bool = False, threshold: float = 0.001, @@ -67,15 +67,15 @@ def spikes_to_biexp_currents( assert t_spk_conv.shape == (T, n_spk) assert np.all(np.diff(t_spk_ms) >= 0), "assuming t_spk_ms is sorted" - assert tau1 > tau2, "tau1 must be greater than tau2" + assert tau1_ms > tau2_ms, "tau1 must be greater than tau2" # Define a function for the difference between the biexp_kernel and the threshold def biexp(t): - return biexp_kernel(t, tau1, tau2, normalize=True) - threshold + return biexp_kernel(t, tau1_ms, tau2_ms, normalize=True) - threshold # Use fsolve to find the time when the biexp_kernel drops to the threshold - t_end = fsolve(biexp, 6 * tau1)[0] - assert t_end > tau1 + t_end = fsolve(biexp, 6 * tau1_ms)[0] + assert t_end > tau1_ms I_syn = np.zeros((T, n_targets)) @@ -89,7 +89,9 @@ def biexp(t): continue window_sizes[t] = spk_right - spk_left - I_syn_t = biexp_kernel(t_spk_conv[t, spk_left:spk_right], tau1, tau2, normalize) + I_syn_t = biexp_kernel( + t_spk_conv[t, spk_left:spk_right], tau1_ms, tau2_ms, normalize + ) J_t = J[i_spk[spk_left:spk_right], :] # numpy doesn't handle multiplication with sparse matrices