You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I believe that the detection of burst on- and offsets fails if the boolean burst vector starts and/or ends with bursts.
Here's an illustration:
importnumpyasnpdeffind_starts_ends_A(bursting): # current implementationstarts=np.array([])
ends=np.array([])
forii, indexinenumerate(np.where(np.diff(bursting) !=0)[0]):
if (ii%2) ==0:
starts=np.append(starts, index)
else:
ends=np.append(ends, index)
returnstarts, endsdeffind_starts_ends_B(bursting): # suggested alternative implementation# Find the indices of changes.change=np.diff(bursting)
idcs, =change.nonzero()
idcs+=1# Get indices following the change.ifbursting[0]:
# If the first sample fulfills the condition, prepend a zero.idcs=np.r_[0, idcs]
ifbursting[-1]:
# If the last sample fulfills the condition, append an index# corresponding to the length of signalidcs=np.r_[idcs, bursting.size]
starts=idcs[0::2]
ends=idcs[1::2]
returnstarts, endsbursts=np.array([True, True, False, False, True, True, True, False, True])
startsA, endsA=find_starts_ends_A(bursts)
startsB, endsB=find_starts_ends_B(bursts)
print(f"starts A: {startsA}, ends A: {endsA}")
print(f"starts B: {startsB}, ends B: {endsB}")
Hi @JanCBrammer, thanks for reporting the bug! I tested your solution and it looks great. Feel free to open a PR if you have time. Otherwise, I can implement the change soon.
I believe that the detection of burst on- and offsets fails if the boolean burst vector starts and/or ends with bursts.
Here's an illustration:
Happy to make a PR. Thanks for the amazing package btw.
The text was updated successfully, but these errors were encountered: