pactools.raw_to_mask

pactools.raw_to_mask(raw, ixs, events=None, tmin=None, tmax=None)[source]

A function to transform MNE data into pactools input signals. It select the one channel on which you to estimate PAC, or two channels for cross-channel PAC. It also returns a mask generator, that mask the data outside a given window around an event. The mask generator returns a number of masks equal to the number of events times the number of windows (i.e. the number of pairs (tmin, tmax)).

Warning: events is stored in indices, tmin and tmax are stored in seconds.

Parameters
rawan instance of Raw, containing data of shape (n_channels, n_times)

The data used to calculate PAC

ixsint or couple of int

The indices for the low/high frequency channels. If only one is given, the same channel is used for both low_sig and high_sig.

eventsarray, shape (n_events, 3) | array, shape (n_events,) | None

MNE events array. To be supplied if data is 2D and output should be split by events. In this case, tmin and tmax must be provided. If ndim == 1, it is assumed to be event indices, and all events will be grouped together. Otherwise, events will be grouped along the third dimension.

tminfloat | list of floats, shape (n_windows, ) | None

If events is not provided, it is the start time to use in raw. If events is provided, it is the time (in seconds) to include before each event index. If a list of floats is given, then PAC is calculated for each pair of tmin and tmax. Defaults to min(raw.times).

tmaxfloat | list of floats, shape (n_windows, ) | None

If events is not provided, it is the stop time to use in raw. If events is provided, it is the time (in seconds) to include after each event index. If a list of floats is given, then PAC is calculated for each pair of tmin and tmax. Defaults to max(raw.times).

Returns
low_sigarray, shape (1, n_points)

Input data for the phase signal

high_sigarray or None, shape (1, n_points)

Input data for the amplitude signal. If None, we use low_sig for both signals.

maskMaskIterator instance

Object that behaves like a list of mask, without storing them all. The PAC will only be evaluated where the mask is False.

Examples

>>> from pactools import raw_to_mask
>>> low_sig, high_sig, mask = raw_to_mask(raw, ixs, events, tmin, tmax)
>>> n_masks = len(mask)
>>> for one_mask in mask:
...     pass