osl_dynamics.data.task#

Functions to handle task data.

Module Contents#

Functions#

epoch(data, time_index, pre, post[, pad])

Transform (time, channel) data to (time, channel, epoch) data.

epoch_mean(data, time_index, pre, post[, pad])

Get the mean over epochs of a (time, channels) dataset.

osl_dynamics.data.task.epoch(data, time_index, pre, post, pad=False)[source]#

Transform (time, channel) data to (time, channel, epoch) data.

Given a series of triggers given by time_index, spit a continuous dataset into epochs. time_index should be a sequence of integers representing the triggers of the epochs. pre and post specify the window around each trigger event.

Parameters:
  • data (np.ndarray) – A (time, channels) dataset to be epoched.

  • time_index (np.ndarray) – The integer indices of the start of each epoch.

  • pre (int) – The integer number of samples to include before the trigger.

  • post (int) – The integer number of samples to include after the trigger.

  • pad (bool, optional) – Pad with NaNs so that initial epochs will always been included.

Returns:

epoched – A (time, channels, epochs) dataset.

Return type:

np.ndarray

osl_dynamics.data.task.epoch_mean(data, time_index, pre, post, pad=False)[source]#

Get the mean over epochs of a (time, channels) dataset.

Calls epoch_mean, and takes a mean over epochs, returning data with dimensions (time, channels) in which the time is the length of the epoch window.

Parameters:
  • data (np.ndarray) – A (time, channels) dataset to be epoched.

  • time_index (np.ndarray) – The integer indices of the start of each epoch.

  • pre (int) – The integer number of samples to include before the trigger.

  • post (int) – The integer number of samples to include after the trigger.

  • pad (bool, optional) – Pad with NaNs so that initial epochs will always been included.

Returns:

epoch_mean – (time, channels) data meaned over epochs.

Return type:

np.ndarray