neurodsp.spectral.compute_relative_power

neurodsp.spectral.compute_relative_power(freqs, powers, band, method='sum', norm_range=None)[source]

Compute relative power for a given frequency band.

Parameters
freqs1d array

Frequency values.

powers1d array

Power spectrum power values.

bandlist of [float, float]

Band definition.

method{‘sum’, ‘mean’, ‘median’}, optional

Method to use to compute power across the band.

norm_rangelist of [float, float], optional

Frequency range to use to compute total power. If not provided, the whole spectrum is used.

Returns
rel_powerfloat

Computed relative power.

Examples

Compute relative alpha power in a simulated signal:

>>> from neurodsp.sim import sim_combined
>>> from neurodsp.spectral import compute_spectrum
>>> sig = sim_combined(10, 500, {'sim_powerlaw': {}, 'sim_oscillation': {'freq': 10}})
>>> freqs, powers = compute_spectrum(sig, fs=500)
>>> abs_power = compute_relative_power(freqs, powers, [8, 12])