bycycle.objs.Bycycle¶
- class bycycle.objs.Bycycle(center_extrema='peak', burst_method='cycles', burst_kwargs=None, thresholds=None, find_extrema_kwargs=None, return_samples=True)[source]¶
Compute bycycle features from a signal.
- Attributes:
- df_featurespandas.DataFrame
A dataframe containing shape and burst features for each cycle.
- sig1d array
Voltage 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.
- __init__(center_extrema='peak', burst_method='cycles', burst_kwargs=None, thresholds=None, find_extrema_kwargs=None, return_samples=True)[source]¶
Initialize object settings.
Methods
__init__
([center_extrema, burst_method, ...])Initialize object settings.
fit
(sig, fs, f_range)Run the bycycle algorithm on a signal.
load
(df_features, sig, fs, f_range)Load external results.
plot
([xlim, figsize, plot_only_results, interp])Plot burst detection results.
recompute_edges
([reduction])Recomputes features for cycles on the edge of bursts.
reduce_thresholds
(reduction)Adjust thresholds by a given amount.
- fit(sig, fs, f_range)[source]¶
Run the bycycle algorithm on a signal.
- Parameters:
- sig1d array
Time series.
- fsfloat
Sampling rate, in Hz.
- f_rangetuple of (float, float)
Frequency range for narrowband signal of interest (Hz).
- plot(xlim=None, figsize=(15, 3), plot_only_results=False, interp=True)[source]¶
Plot burst detection results.
- Parameters:
- xlimtuple of (float, float), optional, default: None
Start and stop times for plot.
- figsizetuple of (float, float), optional, default: (15, 3)
Size of each plot.
- plot_only_resultbool, optional, default: False
Plot only the signal and bursts, excluding burst parameter plots.
- interpbool, optional, default: True
If True, interpolates between given values. Otherwise, plots in a step-wise fashion.
- recompute_edges(reduction=None)[source]¶
Recomputes features for cycles on the edge of bursts.
- Parameters:
- reductionfloat, optional, default: None
Reduces all float thresholds by given amount.
- reduce_thresholds(reduction)¶
Adjust thresholds by a given amount.
- Parameters:
- reductionfloat, optional, default: None
Reduces all float thresholds by given amount.
- Returns:
- reduced_thresholdsdict
Copy of thresholds with reduction applied.