bycycle.utils.limit_df

bycycle.utils.limit_df(df, fs, start=None, stop=None, reset_indices=True)[source]

Restrict dataframe to be within time limits.

Parameters:
dfpandas.DataFrame

Dataframe output of compute_features().

fsfloat

Sampling rate, in Hz.

startfloat, optional

The lower time limit, in seconds, to restrict the df.

stopfloat, optional

The upper time limit, in seconds, to restrict the df.

reset_indicesbool, optional, default: True

Samples start at zero when True.

Returns:
dfpandas.DataFrame

A limited dataframe of cycle features.

Notes

Cycles, or rows in the df, are included if any segment of the cycle falls after the stop time or before the end time.

Examples

Limit a samples dataframe to the first second of a simulated signal:

>>> from neurodsp.sim import sim_bursty_oscillation
>>> from bycycle.features import compute_features
>>> fs = 500
>>> sig = sim_bursty_oscillation(10, fs, freq=10)
>>> df_features = compute_features(sig, fs, f_range=(8, 12))
>>> df_features = limit_df(df_features, fs, start=0, stop=1)