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

v0.16 #54

Merged
merged 85 commits into from
Sep 18, 2024
Merged
Changes from 1 commit
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
ea3150e
Update t_ms and interval_ms
arnavt2955 Jan 19, 2024
8892069
updates t in other files
arnavt2955 Jan 19, 2024
d4a7274
updated t
arnavt2955 Jan 19, 2024
05978e0
changed more _ms
arnavt2955 Feb 2, 2024
d5c5f03
Merge remote-tracking branch 'origin' into UsingBrianUnits
arnavt2955 Feb 2, 2024
9f4add0
added import
arnavt2955 Feb 2, 2024
ee04625
addes imports
arnavt2955 Feb 2, 2024
c77a52a
fixed base.py and made changes to lfp - still failing 10 cases
arnavt2955 Mar 15, 2024
288a286
Created jupyteer notebook for calculating ratios
arnavt2955 Apr 18, 2024
efff6b6
added ratio into opsin library and added 2p action spectra into spect…
arnavt2955 Apr 18, 2024
aa0609a
progress on all_optical fig
kjohnsen May 8, 2024
756bbf1
improve action spectrum extrapolation
kjohnsen May 27, 2024
521ac34
start Newman 15 with alternate opsins
kjohnsen May 27, 2024
23bf74b
Merge remote-tracking branch 'origin' into validation2
kjohnsen May 27, 2024
18ac155
update Overview doc
kjohnsen May 27, 2024
e85ed03
finish newman15 validation w/ alternate opsins
kjohnsen May 31, 2024
a66da8d
Update paper plot style
kjohnsen May 31, 2024
b6607b5
style_plots_for_paper docstring
kjohnsen Jun 6, 2024
e7897c5
Merge branch 'master' of https://github.com/Sensory-Information-Proce…
kjohnsen Jun 6, 2024
9e3bd1a
change Jupyter to Python for linguist
kjohnsen Jun 21, 2024
7e4dd0f
change OGB-1 name
kjohnsen Jun 21, 2024
8e121f0
add warning to scope when sensor not injected
kjohnsen Jun 21, 2024
f34b0b7
add showcase to docs
kjohnsen Jun 21, 2024
5d14096
implement LIOP reset in _base_reset
kjohnsen Jun 21, 2024
1f67236
add showcase doc to index
kjohnsen Jun 21, 2024
7173b74
add _base_reset to sim.reset
kjohnsen Jun 21, 2024
4b32fb8
fresh run through of all-optical-fig notebook
kjohnsen Jun 21, 2024
689a0f8
add README to notebooks, env info to all_optical_fig.ipynb
kjohnsen Jun 21, 2024
18e470d
bump to v0.15.0
kjohnsen Jun 21, 2024
cda9382
remove images [skip ci]
kjohnsen Jun 21, 2024
1e2eaa0
untrack images
kjohnsen Jun 21, 2024
023eb4e
more organizing notebook images
kjohnsen Jun 21, 2024
c7a79f7
Merge branch 'UsingBrianUnits' of https://github.com/Sensory-Informat…
kjohnsen Jun 21, 2024
37ed3a1
move Sridharan fig2
kjohnsen Jun 21, 2024
523e70e
use Brian units everywhere
kjohnsen Jun 24, 2024
5d904ae
reorganize ioproc tests
kjohnsen Jun 24, 2024
ded4fde
add firing_rate_estimate and pi_ctrl methods, revise PI_Ctrl notebook
kjohnsen Jun 24, 2024
6d33767
ax ioproc folder
kjohnsen Jun 24, 2024
5c74e9f
ax ProcessingBlock
kjohnsen Jun 24, 2024
1928c01
upgrade nptyping, make sim.remove() private
kjohnsen Jun 25, 2024
06c2d0f
fix more unit problems
kjohnsen Jun 25, 2024
be690c3
get overview working
kjohnsen Jun 27, 2024
0933ffc
get tutorials working
kjohnsen Jun 27, 2024
df3b507
use explicit units on Light
kjohnsen Jul 16, 2024
04fc0a8
add units to SimpleOpsin gain
kjohnsen Jul 16, 2024
b552d23
extend font stack
kjohnsen Jul 16, 2024
ddd7f60
fix spike count problem
kjohnsen Jul 18, 2024
7dc7375
scope to_neo
kjohnsen Jul 20, 2024
bdf27b6
2p light to_neo
kjohnsen Jul 21, 2024
b1c7582
fix spiking test fail
kjohnsen Jul 21, 2024
0b8b763
Use utilities.rng
kjohnsen Jul 21, 2024
1db73f1
units on Light.values and other small tweaks
kjohnsen Aug 14, 2024
84f9452
add version note to newman15 notebooks
kjohnsen Aug 14, 2024
30db678
add version note to opto val notebook
kjohnsen Aug 14, 2024
bd9a9fb
fix electrodes tutorial
kjohnsen Aug 14, 2024
9b8a546
fix opto tutorial
kjohnsen Aug 14, 2024
09723e3
fix multi_opto notebook, add range to plot_spectra
kjohnsen Aug 14, 2024
93d07ce
fix on_off_ctrl notebook
kjohnsen Aug 15, 2024
2c09a76
update PI ctrl notebook
kjohnsen Aug 16, 2024
b65a154
fix all_optical tutorial
kjohnsen Aug 16, 2024
79de3bd
fix video viz tutorial
kjohnsen Aug 16, 2024
8f58745
fix Neo tutorial
kjohnsen Aug 16, 2024
26a933d
fix advanced LFP notebook
kjohnsen Aug 16, 2024
e0d81f9
rename firing_rate_estimate to exp_firing_rate_estimate
kjohnsen Sep 4, 2024
49a559a
fix global set_seed
kjohnsen Sep 12, 2024
2ad5ad1
progress on lqr tutorial, before cutting adaptive control
kjohnsen Sep 12, 2024
0336931
revamp ldsCtrlEst tutorial
kjohnsen Sep 12, 2024
bf66e87
support numpy >= 2.0
kjohnsen Sep 12, 2024
f615489
remove bug workaround (closes Remove bug workaround in tutorials #16)
kjohnsen Sep 12, 2024
41176c5
fix light.to_neo
kjohnsen Sep 13, 2024
6dd8dcb
replace nptyping with jaxtyping
kjohnsen Sep 16, 2024
ee25e92
remove imported members from ioproc docs
kjohnsen Sep 16, 2024
63b50ca
mark lfp tests as slow
kjohnsen Sep 16, 2024
f7f9db2
polish tutorial notebooks
kjohnsen Sep 17, 2024
4cb34d0
tweak docstrings
kjohnsen Sep 17, 2024
88836ac
add LatencyIOProcessor to base cleo import
kjohnsen Sep 17, 2024
4b34135
clean up imports
kjohnsen Sep 17, 2024
84ee159
Merge branch 'master' into v0.16
kjohnsen Sep 17, 2024
2852b72
fix lqr notebook, fresh rerun of all
kjohnsen Sep 17, 2024
646eaa6
polish video tutorial, exit if no ffmpeg
kjohnsen Sep 18, 2024
3566ac4
skip execution of video write cell
kjohnsen Sep 18, 2024
ede7deb
tweak overview docs, increase test cell timeout
kjohnsen Sep 18, 2024
fc73d86
simplify 4-state opsin model
kjohnsen Sep 18, 2024
44b6f83
eliminate warnings
kjohnsen Sep 18, 2024
23f1cbf
rerun opto tutorial, increase timestep
kjohnsen Sep 18, 2024
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
Prev Previous commit
Next Next commit
fix spike count problem
kjohnsen committed Jul 18, 2024

Verified

This commit was signed with the committer’s verified signature.
oliviertassinari Olivier Tassinari
commit ddd7f6044a59718c1579c1e0f9aea5df35c138ba
15 changes: 9 additions & 6 deletions cleo/ephys/spiking.py
Original file line number Diff line number Diff line change
@@ -12,11 +12,11 @@
from attrs import define, field, fields
from bidict import bidict
from brian2 import NeuronGroup, Quantity, SpikeMonitor, mm, ms
from nptyping import NDArray, Shape, UInt, Float
from nptyping import Float, NDArray, Shape, UInt

from cleo.base import NeoExportable
from cleo.ephys.probes import Signal
from cleo.utilities import unit_safe_cat
from cleo.utilities import rng, unit_safe_cat


@define(eq=False)
@@ -232,7 +232,7 @@ def _noisily_detect_spikes_per_channel(
self, i_probe, t
) -> Tuple[NDArray, NDArray, NDArray]:
probs_for_spikes = self._dtct_prob_array[i_probe]
detected_spikes = np.random.random(probs_for_spikes.shape) < probs_for_spikes
detected_spikes = rng.random(probs_for_spikes.shape) < probs_for_spikes
y = np.sum(detected_spikes, axis=0)
# ⬇ nonzero gives row, column indices of each nonzero element
i_spike_detected, i_c_detected = detected_spikes.nonzero()
@@ -294,15 +294,18 @@ def get_state(
# inherit docstring
i_probe, t = self._get_new_spikes()
i_probe, t = self._noisily_detect_spikes(i_probe, t)
y = np.zeros(len(self.i_probe_by_i_ng), dtype=bool)
y[i_probe] = 1
y = np.bincount(i_probe.astype(int))
# include 0s for upper indices not seen:
y = np.concatenate([y, np.zeros(len(self.i_probe_by_i_ng) - len(y))])
t_samp = self.probe.sim.network.t / ms
self._update_saved_vars(t, i_probe, t_samp)
return (i_probe, t, y)

def _noisily_detect_spikes(self, i_probe, t) -> Tuple[NDArray, NDArray]:
# dtct_prob_array: n_nrns x n_channels
probs_for_spikes = self._dtct_prob_array[i_probe]
detected_spikes = np.random.random(probs_for_spikes.shape) < probs_for_spikes
# now n_spks x n_channels
detected_spikes = rng.random(probs_for_spikes.shape) < probs_for_spikes
i_spike_detected = detected_spikes.nonzero()
i_probe_out = i_probe[i_spike_detected]
t_out = t[i_spike_detected]
14 changes: 11 additions & 3 deletions tests/ephys/test_spiking.py
Original file line number Diff line number Diff line change
@@ -45,23 +45,26 @@ def test_MUS_multiple_contacts():

# remember i here is channel, no longer neuron
i, t, y = mus.get_state()
assert len(i) == 0
assert len(t) == 0
assert len(i) == len(t) == y.sum() == 0

sim.run(1 * ms) # 1 ms
i, t, y = mus.get_state()
assert len(i) == len(t) == y.sum()
assert (0 in i) and (0.9 * ms in t)

sim.run(1 * ms) # 2 ms
i, t, y = mus.get_state()
assert len(i) == len(t) == y.sum()
assert len(i) == 0 and len(t) == 0

sim.run(1 * ms) # 3 ms
i, t, y = mus.get_state()
assert len(i) == len(t) == y.sum()
assert (0 in i) and (2.1 * ms in t)

sim.run(1 * ms) # 4 ms
i, t, y = mus.get_state()
assert len(i) == len(t) == y.sum()
# should pick up 2 spikes on first and 1 or 2 on second channel
assert 1 in i and len(i) >= 3
assert 3.5 * ms in t
@@ -70,6 +73,7 @@ def test_MUS_multiple_contacts():
sim.run(2 * ms)
# sim.get_state() nested dict is what will be passed to IO processor
i, t, y = sim.get_state()["Probe"]["mus"]
assert len(i) == len(t) == y.sum()
assert (0 in i) and (1 in i) and len(i) >= 7
assert all(t_i in (t / ms).round(2) for t_i in [4.1, 4.9, 5.1, 5.3, 5.5])

@@ -104,7 +108,7 @@ def test_MUS_multiple_groups():
assert 20 < np.sum(mus.i == 0) < 60
# second channel would have caught all spikes from sgg1 and sgg2
assert np.sum(mus.i == 1) == 60
assert len(mus.t) == len(mus.t_samp)
assert len(mus.t) == len(mus.t_samp) == y.sum()
assert np.all(mus.t_samp == 10 * ms)


@@ -142,18 +146,22 @@ def test_SortedSpiking():
sim.run(3 * ms) # 3 ms
i, t, y = sim.get_state()["Probe"]["ss"]
assert all(i == [2, 2])
assert len(i) == len(t) == y.sum()

sim.run(1 * ms) # 4 ms
i, t, y = ss.get_state()
assert all(i == [2, 3])
assert len(i) == len(t) == y.sum()

sim.run(1 * ms) # 5 ms
i, t, y = ss.get_state()
assert all(i == [3, 5])
assert len(i) == len(t) == y.sum()

sim.run(1 * ms) # 6 ms
i, t, y = ss.get_state()
assert all(i == [2, 3, 5])
assert len(i) == len(t) == y.sum()

for i in (0, 1, 4):
assert i not in ss.i