mne.epochs.equalize_epoch_counts#

mne.epochs.equalize_epoch_counts(epochs_list, method='mintime', *, rng=None, random_state=None)[source]#

Equalize the number of trials in multiple Epochs or EpochsTFR instances.

Parameters:
epochs_listlist of Epochs

The Epochs instances to equalize trial counts for.

method'truncate' | 'mintime' | 'random'

If 'truncate', events will be truncated from the end of each event list. If 'mintime', timing differences between each event list will be minimized. If 'random', events will be randomly selected from each event list.

New in v1.8.

rngNone | int | instance of Generator | RandomState

The random number generator (RNG). If None (default), a new numpy.random.Generator seeded from entropy is used. Pass an int or a numpy.random.Generator for reproducible results, or a legacy RandomState to control the random-number stream or for interoperability with third-party code such as scikit-learn that does not accept generators. An integer seed uses numpy.random.default_rng() and therefore produces a different stream than the same integer passed to a legacy random_state or seed parameter. Used only if method='random'.

New in v1.13.

random_stateNone | int | instance of RandomState

Supported for compatibility. New code should use rng. If None, NumPy’s global RandomState is used. Used only if method='random'.

Notes

The method 'mintime' tries to make the remaining epochs occurring as close as possible in time. This method is motivated by the possibility that if there happened to be some time-varying (like on the scale of minutes) noise characteristics during a recording, they could be compensated for (to some extent) in the equalization process. This method thus seeks to reduce any of those effects by minimizing the differences in the times of the events in the two sets of epochs. For example, if one had event times [1, 2, 3, 4, 120, 121] and the other one had [3.5, 4.5, 120.5, 121.5], it would remove events at times [1, 2] in the first epochs and not [120, 121].

Examples

>>> equalize_epoch_counts([epochs1, epochs2])

Examples using mne.epochs.equalize_epoch_counts#

Permutation t-test on source data with spatio-temporal clustering

Permutation t-test on source data with spatio-temporal clustering