pyntbci.utilities.event_matrix

pyntbci.utilities.event_matrix(stimulus: ndarray[Any, dtype[_ScalarType_co]], event: str, onset_event: bool = False) tuple[ndarray[Any, dtype[_ScalarType_co]], tuple[str]][source]

Make an event matrix. The event matrix describes the onset of events in a stimulus sequence, given a particular event definition.

Parameters:
  • stimulus (NDArray) – The stimulus used for stimulation of shape (n_stims, n_samples). Note, this can be any continuous time-series per stimulus, it is not limited to binary sequences.

  • event (str) –

    The event type to perform the transformation of codes to events with:

    ”id” | “identity”: the events are continuous, the stimulus itself. “dur” | “duration”: each run-length of the same value is an event (e.g., 1, 11, 111, etc.). “re” | “rise” | “risingedge”: each transition of a lower to a higher value is an event (e.g., 01). “fe” | “fall” | “fallingedge”: each transition of a higher to a lower value is an event (i.e., 10). “refe” | “risefall” | “risingedgefallingedge” | “contrast”: one event for rising edges and one event for falling edges (i.e., 01 and 10).

  • onset_event (bool (default: False)) – Whether to model the onset of stimulation. This “onset” event is added as last event.

Returns:

  • events (NDArray) – An event matrix of zeros and ones denoting the onsets of events of shape (n_stims, n_events, n_samples).

  • labels (tuple) – A tuple of event labels of shape (n_events).