bycycle-tools / bycycle

Cycle-by-cycle analysis of neural oscillations.
https://bycycle-tools.github.io/
Apache License 2.0
82 stars 21 forks source link

[ENH] Optimize find_extrema runtime #103

Closed ryanhammonds closed 3 years ago

ryanhammonds commented 3 years ago

This optimizes the code in find_extrema from O(2^N) to O(N) (i.e. exponential to linear increase in runtime with increasing signal size). A signal with 1mil samples took 4.7s to run vs 0.9s after these changes. Before, a signal with 10's of millions of samples would take several minutes to run trough find_extrema before I became impatient and killed the process.