mne-connectivity icon indicating copy to clipboard operation
mne-connectivity copied to clipboard

Cannot predict from VAR model with lags > 1

Open tsbinns opened this issue 7 months ago • 0 comments

Describe the bug

Found while working on #330.

The predict() method of connectivity objects cannot be used when VAR coeffs have multiple lags. I haven't been able to investigate exactly why this is occurring or if this behaviour was ever supported, but I wanted to open this as a reminder to myself.

Steps to reproduce

import numpy as np

from mne_connectivity import vector_auto_regression

rng = np.random.RandomState(0)
n_epochs, n_signals, n_times = 2, 3, 64
data = rng.randn(n_epochs, n_signals, n_times)
times = np.arange(n_times)

conn = vector_auto_regression(data, model="dynamic", lags=2)
conn.predict(data)

Expected results

The predicted data is returned.

Actual results

File "\GitHub\mne-connectivity\mne_connectivity\base.py", line 282, in predict      
    predicted_data[jdx, :, lags:] += np.dot(
                                     ^^^^^^^
ValueError: shapes (3,2,2) and (3,62) not aligned: 2 (dim 2) != 3 (dim 0)

tsbinns avatar Sep 14 '25 18:09 tsbinns