Skip to content
6 changes: 3 additions & 3 deletions cleo/ephys/lfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ def connect_to_neuron_group(self, neuron_group: NeuronGroup, **kwparams):
self._init_wslfp_calc(neuron_group, **kwparams)

buf_len_ampa, buf_len_gaba = self._get_buf_lens_for_wslfp(
self._wslfps[neuron_group]
self._wslfps[neuron_group], **kwparams
)
self._t_ampa_bufs[neuron_group] = deque(maxlen=buf_len_ampa)
self._I_ampa_bufs[neuron_group] = deque(maxlen=buf_len_ampa)
Expand All @@ -633,8 +633,8 @@ def _get_buf_lens_for_wslfp(self, wslfp_calc, **kwparams):
try:
sample_period = self.probe.sim.io_processor.sample_period
except AttributeError: # probably means sim doesn't have io_processor
raise Exception(
"RSWLFPSignalFromPSCs needs to know the sampling period."
raise RuntimeError(
"RWSLFPSignalFromPSCs needs to know the sampling period."
" Either set the simulator's IO processor before injecting"
f" {self.probe.name} or "
f" specify it on injection: .inject({self.probe.name}"
Expand Down
20 changes: 12 additions & 8 deletions cleo/ephys/spiking.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ def connect_to_neuron_group(self, neuron_group: NeuronGroup, **kwparams):
# spike sorters don't sort by multi-channel recall; we only do this
# for computational efficiency, to not get super distant neurons

# needed even if no neurons are recorded
if not self._prev_t:
self._prev_t = self.probe.sim.network.t
if self._mu_eap is None:
self._mu_eap = np.zeros((0, self.n_channels))

n2keep = np.sum(where_to_keep)
if n2keep == 0:
warnings.warn(
Expand All @@ -271,14 +277,8 @@ def connect_to_neuron_group(self, neuron_group: NeuronGroup, **kwparams):
assert len(self.i_ng_by_i_probe) == i_probe_start
self.i_ng_by_i_probe.extend(list(zip([neuron_group] * n2keep, i2keep)))

if not self._prev_t:
self._prev_t = self.probe.sim.network.t

# store neuron-channel mean and stdev of EAPs to use in subclasses
if self._mu_eap is None:
self._mu_eap = snr[where_to_keep]
else:
self._mu_eap = np.concatenate((self._mu_eap, snr[where_to_keep]), axis=0)
self._mu_eap = np.concatenate((self._mu_eap, snr[where_to_keep]), axis=0)

return snr[where_to_keep].max(axis=1), new_i_probe

Expand Down Expand Up @@ -642,7 +642,11 @@ def sorted_units_snr(self) -> Float[np.ndarray, "{self.n_sorted}"]:
return self._mu_eap[self._i_probe_by_i_sorted]

def connect_to_neuron_group(self, neuron_group, **kwparams):
snr, i_probe = super().connect_to_neuron_group(neuron_group, **kwparams)
connect_result = super().connect_to_neuron_group(neuron_group, **kwparams)
if connect_result is None:
# No neurons with high-enough multi-channel recall to record
return
snr, i_probe = connect_result
n_recorded_ng = len(snr)
# filter by SNR (measured on peak channel)
above_cutoff = snr >= self.snr_cutoff
Expand Down
10 changes: 10 additions & 0 deletions cleo/opto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
enphr3_3s,
gtacr2_4s,
vfchrimson_4s,
reachr_4s,
chrimsonr_4s,
cschrimson_4s,
breaches_4s,
chrmine_4s,
cheta_4s,
chronos_4s,
cheriff_4s,
nphr_3s,
jaws_3s,
)
from cleo.opto.opsins import (
BansalFourStateOpsin,
Expand Down
Loading
Loading