Skip to content

Commit

Permalink
Merge pull request #286 from toni-neurosc/bursts_fix_pr
Browse files Browse the repository at this point in the history
Bursts feature performance improvement
  • Loading branch information
timonmerk authored Jan 28, 2024
2 parents 189be9b + 11cb64d commit 906f50d
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions py_neuromodulation/nm_bursts.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,25 +167,18 @@ def get_burst_amplitude_length(
bursts = np.zeros((beta_averp_norm.shape[0] + 1), dtype=bool)
bursts[1:] = beta_averp_norm >= burst_thr
deriv = np.diff(bursts)
isburst = False
burst_length = []
burst_amplitude = []
burst_start = 0

for index, burst_state in enumerate(deriv):
if burst_state == True:
if isburst == True:
burst_length.append(index - burst_start)
burst_amplitude.append(beta_averp_norm[burst_start:index])
burst_time_points = np.where(deriv==True)[0]

isburst = False
else:
burst_start = index
isburst = True
for i in range(burst_time_points.size//2):
burst_length.append(burst_time_points[2 * i + 1] - burst_time_points[2 * i])
burst_amplitude.append(beta_averp_norm[burst_time_points[2 * i] : burst_time_points[2 * i + 1]])

# the last burst length (in case isburst == True) is omitted,
# since the true burst length cannot be estimated

burst_length = np.array(burst_length) / sfreq

return burst_amplitude, burst_length

0 comments on commit 906f50d

Please sign in to comment.