Skip to content

Commit

Permalink
Sharpwaves performance fix
Browse files Browse the repository at this point in the history
  • Loading branch information
toni-neurosc committed Jan 26, 2024
1 parent cee19a4 commit 442044c
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions py_neuromodulation/nm_sharpwaves.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,21 +257,22 @@ def analyze_waveform(self) -> None:
distance=self.sw_settings["detect_troughs"]["distance_troughs_ms"],
)[0]

peak_idx = 0
for trough_idx in troughs:
try:
(
peak_idx_left,
peak_idx_right,
peak_left,
peak_right,
) = self._get_peaks_around(
trough_idx, peaks, self.data_process_sw
)
except NoValidTroughException:
# in this case there are no adjacent two peaks around this trough
# str(e) could print the exception error message
# print(str(e))

while peak_idx < peaks.size and peaks[peak_idx] < trough_idx:
peak_idx += 1

if peak_idx - 1 < 0:
continue
peak_idx_left = peaks[peak_idx - 1]

if peak_idx >= peaks.size:
continue
peak_idx_right = peaks[peak_idx]

peak_left = self.data_process_sw[peak_idx_left]
peak_right = self.data_process_sw[peak_idx_right]

trough = self.data_process_sw[trough_idx]
self.trough.append(trough)
Expand Down

0 comments on commit 442044c

Please sign in to comment.