fooof.utils.subsample_spectra

fooof.utils.subsample_spectra(spectra, selection, return_inds=False)[source]

Subsample a group of power spectra.

Parameters
spectra2d array

A group of power spectra to subsample from.

selectionint or float

The number of spectra to subsample. If int, is the number to select, if float, is a proportion based on input size.

return_indsbool, optional, default: False

Whether to return the list of indices that were selected.

Returns
subsample2d array

A subsampled selection of power spectra.

indslist of int

A list of which indices where subsampled. Only returned if return_inds is True.

Examples

Using a group of simulated spectra, subsample a specific number:

>>> from fooof.sim import gen_group_power_spectra
>>> freqs, powers = gen_group_power_spectra(10, [1, 50], [1, 1], [10, 0.5, 1.0])
>>> subsample = subsample_spectra(powers, 5)

Using a group of simulated spectra, subsample a proportion:

>>> from fooof.sim import gen_group_power_spectra
>>> freqs, powers = gen_group_power_spectra(10, [1, 50], [1, 1], [10, 0.5, 1.0])
>>> subsample = subsample_spectra(powers, 0.25)

Examples using fooof.utils.subsample_spectra

Developmental Data Demo

Developmental Data Demo