dirconn.TimeSeries#

class dirconn.TimeSeries(data: ndarray, sfreq: float, channels: tuple[ChannelMeta, ...], segmentation: str, tmin: float = 0.0, valid: ndarray | None = None, predict: ndarray | None = None, history: tuple[dict[str, Any], ...] = ())#

Multichannel time series with explicit segmentation.

The data always have shape (n_trials, n_channels, n_times). Whether the data are one continuous record or a set of epochs is stored explicitly in segmentation and is never inferred from n_trials: a single epoch is still "epoched".

Parameters:
  • data (ndarray, shape (n_trials, n_channels, n_times)) – Real-valued, finite samples. Converted to float64 and exposed as a read-only view; a float64 input array is not copied.

  • sfreq (float) – Sampling frequency in Hz.

  • channels (tuple of ChannelMeta) – One entry per channel, with unique names.

  • segmentation ({"continuous", "epoched"}) – "continuous" requires n_trials == 1.

  • tmin (float) – Time of the first sample in seconds, relative to the epoch event (0 for continuous data).

  • valid (ndarray of bool, shape (n_trials, n_times), optional) – Which samples can be used at all, as a regressor or as a predicted value. Gaps and bad segments are False. The samples themselves must still be finite: put any number there (from_array() with nan="mask" puts 0). None (default) means every sample is valid.

  • predict (ndarray of bool, shape (n_trials, n_times), optional) –

    Which samples contribute an equation (a regression row) to a model fit, for example the samples inside beta bursts. None (default) means every sample.

    A VAR model of order p uses the row at time t only when predict[t] and valid[t - p .. t] are all True (see dirconn.methods.mvar.lagged_design()). Masks that are all True are stored as None. Estimators that cannot use the masks refuse masked data (MethodInfo.supports_mask).

  • history (tuple of dict) – Steps that produced these data from a recording, oldest first, for example lock(). Every estimator copies them into the provenance of its result (preprocessing["data_history"]). Must be JSON serialisable.

__init__(data: ndarray, sfreq: float, channels: tuple[ChannelMeta, ...], segmentation: str, tmin: float = 0.0, valid: ndarray | None = None, predict: ndarray | None = None, history: tuple[dict[str, Any], ...] = ()) → None#

Methods

__init__(data, sfreq, channels, segmentation)

control_locks(eligible, n, tmin, tmax, *, seed)

Draw n control epochs from eligible time points of a continuous record.

from_array(data, sfreq, *[, names, ...])

Build a time series from a numpy array.

from_mne(inst[, picks, nan, bad_annotations])

Build a time series from an MNE Raw or Epochs object.

lock(events, tmin, tmax)

Cut epochs around events of a continuous record.

mask_summary()

Return the number of samples, valid samples and samples to predict, for provenance.

pick(channels)

Return a series with only the selected channels, in the given order.

Attributes

duration

Duration of one trial in seconds.

has_mask

Whether the series has a valid or a predict mask.

history

n_channels

Number of channels.

n_times

Number of samples per trial.

n_trials

Number of trials (1 for continuous data).

names

Channel names in data order.

predict

tmin

valid

data

sfreq

channels

segmentation