pycrostates.preprocessing.resample#

pycrostates.preprocessing.resample(inst, picks=None, tmin=None, tmax=None, reject_by_annotation=True, n_resamples=None, n_samples=None, coverage=None, replace=True, random_state=None, verbose=None)[source]#

Resample a recording into epochs of random samples.

Resample Raw. Epochs or ChData into n_resamples each containing n_samples random samples of the original recording.

Parameters:
instRaw | Epochs | ChData

Instance to resample.

picksstr | array_like | slice | None

Channels to include. Slices and lists of integers will be interpreted as channel indices. In lists, channel type strings (e.g., ['meg', 'eeg']) will pick channels of those types, channel name strings (e.g., ['MEG0111', 'MEG2623'] will pick the given channels. Can also be the string values 'all' to pick all channels, or 'data' to pick data channels. None (default) will pick all channels. Note that channels in info['bads'] will be included if their names or indices are explicitly provided.

tminfloat

Start time of the raw data to use in seconds (must be >= 0).

tmaxfloat | None

End time of the raw data to use in seconds (cannot exceed data duration). If None (default), the current end of the data is used.

reject_by_annotationbool

Whether to omit bad segments from the data before fitting. If True (default), annotated segments whose description begins with 'bad' are omitted. If False, no rejection based on annotations is performed.

Has no effect if inst is not a mne.io.Raw object.

n_resamplesint

Number of resamples to draw. Each epoch can be used to fit a separate clustering solution. See notes for additional information.

n_samplesint

Length of each epoch (in samples). See notes for additional information.

coveragefloat

Strictly positive ratio between resampling data size and size of the original recording. See notes for additional information.

replacebool

Whether or not to allow resampling with replacement.

random_stateNone | int | instance of RandomState

A seed for the NumPy random number generator (RNG). If None (default), the seed will be obtained from the operating system (see RandomState for details), meaning it will most likely produce different output every time this function or method is run. To achieve reproducible results, pass a value here to explicitly initialize the RNG with a defined state.

verboseint | str | bool | None

Sets the verbosity level. The verbosity increases gradually between "CRITICAL", "ERROR", "WARNING", "INFO" and "DEBUG". If None is provided, the verbosity is set to "WARNING". If a bool is provided, the verbosity is set to "WARNING" for False and to "INFO" for True.

Returns:
resampleslist of ChData

List of resamples.

Notes

Only two of n_resamples, n_samples and coverage parameters must be defined, the non-defined one will be determine at runtime by the 2 other parameters.

Examples using pycrostates.preprocessing.resample#

Subject level analysis with resampling

Subject level analysis with resampling

Group level analysis from individual GFP peaks

Group level analysis from individual GFP peaks

Global Field Power peaks

Global Field Power peaks

Resampling

Resampling