nemos.convolve.tensor_convolve#
- nemos.convolve.tensor_convolve(array, eval_basis)[source]#
Apply a convolution on the given array with the evaluation basis and reshapes the result.
This function first flattens the input array across dimensions other than the first one, then performs a vectorized convolution with the evaluation basis. The result is reshaped back to the original array’s shape (except for the first dimension, which is adjusted based on the convolution).
- Parameters:
array (NDArray) – The input array to convolve. It is expected to be at least 1D. The first axis is expeted to be the sample axis, i.e. the shape of array is
(num_samples, ...)
.eval_basis (NDArray) – The evaluation basis array for convolution. It should be 2D, where the first dimension represents the window size for convolution. Shape
(window_size, n_basis_funcs)
.
- Returns:
The convolved array, reshaped to maintain the original dimensions except for the first one, which is adjusted based on the window size of
eval_basis
.
Notes
The convolution implemented here is in mode
"valid"
. This implies that the time axis shrinksnum_samples - window_size + 1
, where num_samples is the first size of the first axis ofarray
andwindow_size
is the size of the first axis ineval_basis
.