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
The spindles_detect function can be very slow when multiple channels are present and/or the sampling rate is high. Most of the overhead comes from the yasa.moving_transform and yasa.stft_power function, which are used to calculate the moving correlation / RMS and sigma relative power, respectively
There are several steps we could do to speed up the function:
Apply the stft_power function to all channels at once, instead of each channel separately
We should also only calculate the STFT power if the relative power threshold is enabled. Otherwise, STFT should only be calculated for each detected spindle event.
Update: implementing the above solutions 1 and 2 does not make a noticeable difference in computation time. The two parameters that really impact the computation time (apart from number of channels and number of samples) are:
The sampling frequency
The step size in yasa.moving_transform: increasing to 200 ms or 300 ms (instead of 100 ms) significantly reduces computation time, at the cost of a lower temporal resolution.
The spindles_detect function can be very slow when multiple channels are present and/or the sampling rate is high. Most of the overhead comes from the yasa.moving_transform and yasa.stft_power function, which are used to calculate the moving correlation / RMS and sigma relative power, respectively
There are several steps we could do to speed up the function:
yasa/yasa/detection.py
Lines 732 to 738 in b1890be
We should also only calculate the STFT power if the relative power threshold is enabled. Otherwise, STFT should only be calculated for each detected spindle event.
yasa/yasa/detection.py
Line 746 in b1890be
yasa/yasa/others.py
Line 219 in b1890be
yasa/yasa/detection.py
Lines 750 to 763 in b1890be
Let me know if you have any other ideas to speed up the function!
Raphael
The text was updated successfully, but these errors were encountered: