pyntbci.utilities.encoding_matrix
- pyntbci.utilities.encoding_matrix(stimulus: array, length: int | list[int] | tuple[int, ...] | ndarray[Any, dtype[_ScalarType_co]], stride: int = 1, amplitude: ndarray[Any, dtype[_ScalarType_co]] | None = None, tmin: float = 0) ndarray[Any, dtype[_ScalarType_co]] [source]
Make a Toeplitz-like encoding matrix. Used to phase-shift the stimulus (forward / encoding model), per event to learn a (or several) temporal filter(s). Also called a “structure matrix” or “design matrix”.
- Parameters:
stimulus (NDArray) – Stimulus matrix of shape (n_classes, n_events, n_samples).
length (int | list[int] | tuple[int] | NDArray) – The length in samples of the temporal filter, i.e., the number of phase-shifted stimulus per event. If an array is provided, it denotes the length per event. If one value is provided, it is assumed all event responses are of the same length.
stride (int (default: 1)) – The step size in samples over the length of the temporal filter.
amplitude (NDArray (default: None)) – Amplitude information to embed in the encoding matrix of shape (n_classes, n_samples). If None, it is ignored.
tmin (float (default: 0)) – The start of stimulation in samples. Can be used if there was a delay in the marker.
- Returns:
ematrix – Encoding matrix of shape (n_classes, n_events * length / stride, n_samples).
- Return type:
NDArray