Skip to content

Commit 7509350

Browse files
committed
fix: fix spikes_during_stim_detection and improve test_printouts
1 parent b610ef4 commit 7509350

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

ephyspy/features/utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,18 +240,21 @@ def where_stimulus(data: Union[EphysSweep, EphysSweepSet]) -> Union[bool, ndarra
240240

241241

242242
def where_spike_during_stimulus(
243-
ft: SweepFeature, recompute: bool = False
243+
ft: SweepFeature, recompute: bool = False, spike_ft: str = "peak"
244244
) -> ndarray[bool]:
245245
"""Checks where spikes occur during stimulus.
246246
247247
Args:
248248
ft (SweepFeature): Spike feature to check.
249249
recompute (bool, optional): If True, recompute spikes. Defaults to False.
250+
spike_ft (str, optional): Which spike feature to consider when inferring,
251+
whether a spike is inside of the stimulus window, i.e. "peak",
252+
"threshold", "trough", etc.. Defaults to "peak".
250253
251254
Returns:
252255
ndarray: Boolean array with length of sweep.t; True where spikes occur
253256
during stimulus."""
254-
t_thresh = ft.lookup_spike_feature("threshold_t", recompute=recompute)
257+
t_thresh = ft.lookup_spike_feature(f"{spike_ft}_t", recompute=recompute)
255258
stim_onset = ft.lookup_sweep_feature("stim_onset", recompute=recompute)
256259
stim_end = ft.lookup_sweep_feature("stim_end", recompute=recompute)
257260
during_stim = where_between(t_thresh, stim_onset, stim_end)

tests/test_features.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,12 @@ def test_no_new_features():
148148
ground_truth_features.keys(),
149149
ids=ground_truth_features.keys(),
150150
)
151-
def test_compare_against_ground_truth(ft_name):
151+
def test_against_ground_truth(ft_name):
152152
est = computed_features[ft_name]
153153
true = ground_truth_features[ft_name]
154154
assert (
155155
np.allclose(est, true) or np.isnan(est) and np.isnan(true)
156-
), f"Feature {ft_name} has changed vs. latest ground truth."
156+
), f"{ft_name} has changed vs. ground truth: {est:.2} vs. {true:.2}."
157157

158158

159159
test_sweepset.clear_features()

0 commit comments

Comments
 (0)