specparam.utils.trim_spectrum

specparam.utils.trim_spectrum(freqs, power_spectra, f_range)[source]

Extract a frequency range from power spectra.

Parameters:
freqs1d array

Frequency values for the power spectrum.

power_spectra1d or 2d array

Power spectral density values.

f_range: list of [float, float]

Frequency range to restrict to, as [lowest_freq, highest_freq].

Returns:
freqs_ext1d array

Extracted frequency values for the power spectrum.

power_spectra_ext1d or 2d array

Extracted power spectral density values.

Notes

This function extracts frequency ranges >= f_low and <= f_high. It does not round to below or above f_low and f_high, respectively.

Examples

Using a simulated spectrum, extract a frequency range:

>>> from specparam.sim import sim_power_spectrum
>>> freqs, powers = sim_power_spectrum([1, 50], [1, 1], [10, 0.5, 1.0])
>>> freqs, powers = trim_spectrum(freqs, powers, [3, 30])

Examples using specparam.utils.trim_spectrum

Dealing with Line Noise

Dealing with Line Noise

Developmental Data Demo

Developmental Data Demo

Band-by-Band

Band-by-Band

Band Ratio Measures

Band Ratio Measures

Conflating Periodic & Aperiodic Changes

Conflating Periodic & Aperiodic Changes