Skip to content

Commit 16b22f6

Browse files
committed
complete last cycle
1 parent 8effec3 commit 16b22f6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

neurodsp/sim/periodic.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,14 +347,21 @@ def make_bursts(n_seconds, fs, is_oscillating, cycle):
347347
n_samples_cycle = len(cycle)
348348

349349
burst_sig = np.zeros([n_samples])
350-
for sig_ind, is_osc in zip(range(0, n_samples, n_samples_cycle), is_oscillating):
350+
351+
for ind, sig_ind in enumerate(range(0, n_samples, n_samples_cycle)):
352+
353+
is_osc = is_oscillating[ind]
351354

352355
# If set as an oscillating cycle, add cycle to signal
353356
# The sample check is to check there are enough samples left to add a full cycle
354357
# If there are not, this skipps the add, leaving zeros instead of adding part of a cycle
355-
if is_osc and sig_ind + n_samples_cycle < n_samples:
358+
if is_osc and sig_ind + n_samples_cycle + 1 < n_samples:
356359
burst_sig[sig_ind:sig_ind+n_samples_cycle] = cycle
357360

361+
# Complete the last cycle of a burst
362+
if is_osc and ind < len(is_oscillating) - 1 and not is_oscillating[ind+1]:
363+
burst_sig[sig_ind+n_samples_cycle] = cycle[0]
364+
358365
return burst_sig
359366

360367

0 commit comments

Comments
 (0)