bycycle-tools / bycycle

Cycle-by-cycle analysis of neural oscillations.

Home Page:https://bycycle-tools.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bycycle test with perfect sinusoidal but failed

LeilaNS opened this issue · comments

Hello,
I would like to use your plot_3_bycycle_resting_state in your tutorials. To test the performance of your program, I use a perfect sinusoidal with 10.1 Hz as input.

Fs=500
x=np.arange(0,5,1/Fs)
y=(0.5e-10)*np.sin(2*np.pi*f2*x)
f_range=[7,14]
I use the same parameters as 
burst_kwargs = {'amplitude_fraction_threshold': .2,
                'amplitude_consistency_threshold': .5,
                'period_consistency_threshold': .5,
                'monotonicity_threshold': .8,
                'N_cycles_min': 3}
df = compute_features(y,Fs, f_range,   burst_detection_kwargs=burst_kwargs)
plot_burst_detect_params(y, Fs, df, burst_kwargs,  figsize=(16, 3), plot_only_result=True)
 

Only part of sinusoidal is detected as bursts. I do understand the 3 first period not consider as busrt but not other parts. Could you please help me?
Figure_2

amplitude_fraction_threshold is a relative threshold parameter, i.e. it will discard the bottom 20th percentile of amplitudes, regardless of the absolute value of the amplitude values. In your case, all the amplitudes are extremely similar, so it boils down to some floating point numerical changes in amplitude.

If you set that parameter to zero, all cycles free of filter edge artefacts (arising at the beginning and end of the signal) are considered.

from bycycle.features import compute_features
from bycycle.burst import plot_burst_detect_params
import numpy as np

Fs = 500
x = np.arange(0, 5, 1/Fs)
f2 = 10.1
y = (0.5e-10) * np.sin(2*np.pi*f2*x)
f_range = [7, 14]

burst_kwargs = {'amplitude_fraction_threshold': 0,
                'amplitude_consistency_threshold': .5,
                'period_consistency_threshold': .5,
                'monotonicity_threshold': .8,
                'N_cycles_min': 3}

df = compute_features(y, Fs, f_range,   burst_detection_kwargs=burst_kwargs)
plot_burst_detect_params(y, Fs, df, burst_kwargs,  figsize=(10, 3),
    plot_only_result=True)

Screenshot from 2020-03-30 16-54-51