bycycle.features.compute_features¶
- bycycle.features.compute_features(sig, fs, f_range, center_extrema='peak', burst_method='cycles', burst_kwargs=None, threshold_kwargs=None, find_extrema_kwargs=None, return_samples=True)[source]¶
Compute shape and burst features for each cycle.
- Parameters:
- sig1d array
Time series.
- fsfloat
Sampling rate, in Hz.
- f_rangetuple of (float, float)
Frequency range for narrowband signal of interest (Hz).
- center_extrema{‘peak’, ‘trough’}
The center extrema in the cycle.
‘peak’ : cycles are defined trough-to-trough
‘trough’ : cycles are defined peak-to-peak
- burst_method{‘cycles’, ‘amp’}
Method for detecting bursts.
‘cycles’: detect bursts based on the consistency of consecutive periods & amplitudes
‘amp’: detect bursts using an amplitude threshold
- burst_kwargsdict, optional, default: None
Additional keyword arguments defined in
compute_burst_fraction()
for dual amplitude threshold burst detection (i.e. when burst_method=’amp’).- threshold_kwargsdict, optional, default: None
Feature thresholds for cycles to be considered bursts, matching keyword arguments for:
detect_bursts_cycles()
for consistency burst detection (i.e. when burst_method=’cycles’)detect_bursts_amp()
for amplitude threshold burst detection (i.e. when burst_method=’amp’).
- find_extrema_kwargsdict, optional, default: None
Keyword arguments for function to find peaks an troughs (
find_extrema()
) to change filter parameters or boundary. By default, the filter length is set to three cycles of the low cutoff frequency (f_range[0]
).- return_samplesbool, optional, default: True
Returns samples indices of cyclepoints used for determining features if True.
- Returns:
- df_featurespandas.DataFrame
A dataframe containing shape and burst features for each cycle. Columns:
period
: period of the cycletime_decay
: time between peak and next troughtime_rise
: time between peak and previous troughtime_peak
: time between rise and decay zero-crossestime_trough
: duration of previous trough estimated by zero-crossingsvolt_decay
: voltage change between peak and next troughvolt_rise
: voltage change between peak and previous troughvolt_amp
: average of rise and decay voltagevolt_peak
: voltage at the peakvolt_trough
: voltage at the last troughtime_rdsym
: fraction of cycle in the rise periodtime_ptsym
: fraction of cycle in the peak periodband_amp
: average analytic amplitude of the oscillation
When consistency burst detection is used (i.e. burst_method=’cycles’):
amp_fraction
: normalized amplitudeamp_consistency
: difference in the rise and decay voltage within a cycleperiod_consistency
: difference between a cycle’s period and the period of the adjacent cyclesmonotonicity
: fraction of monotonic voltage changes in rise and decay phases (positive going in rise and negative going in decay)
When dual threshold burst detection is used (i.e. burst_method=’amp’):
burst_fraction
: fraction of a cycle that is bursting
When cyclepoints are returned (i.e. default, return_samples=True)
sample_peak
: sample at which the peak occurssample_zerox_decay
: sample of the decaying zero-crossingsample_zerox_rise
: sample of the rising zero-crossingsample_last_trough
: sample of the last troughsample_next_trough
: sample of the next trough
Examples
Compute shape and burst features:
>>> from neurodsp.sim import sim_bursty_oscillation >>> fs = 500 >>> sig = sim_bursty_oscillation(10, fs, freq=10) >>> df_features = compute_features(sig, fs, f_range=(8, 12))