 # Grand-averaging regressed ERPs against different predictors

• MNE-Python version: 0.21.2
• operating system: macOS 11.1

I am working on regressed ERPs. As far as I can understand, the functions `linear_regression_raw` (for raw data) and `linear_regression` (for epoched data) calculate regressed ERPs against a given set of regressors and store coefficients (betas, t’s and p’s) for each predictor in a complex, dictionary-like object. For example, the dictionary `lm` has the predictor `s_freq` as key and a series of `Evoked` objects as values:

``````lm = {'s_freq': lm(beta=<Evoked | '' (average, N=1), [-0.1, 0.8] sec, 32 ch, ~144 kB>, stderr=<Evoked | '' (average, N=1), [-0.1, 0.8] sec, 32 ch, ~144 kB>, t_val=<Evoked | '' (average, N=1), [-0.1, 0.8] sec, 32 ch, ~144 kB>, p_val=<Evoked | '' (average, N=1), [-0.1, 0.8] sec, 32 ch, ~144 kB>, mlog10_p_val=<Evoked | '' (average, N=1), [-0.1, 0.8] sec, 32 ch, ~144 kB>)}
``````

I am trying to understand what is the best way to store the data for each regressor, coefficient participant, channel, and time, so to calculate grand averages for each regressor and coefficient. What I have trouble with is the inner structure of the `lm` object above (i.e., the structure within a given key of the dictionary). Would anyone be able to help?

Thanks!

As a follow-up – I think what I am really looking for is how to extract the values for each coefficient of each predictor. In the `lm` object above, for example, the key `s_freq` maps to a complex value that is a `mne.stats.regression.lm` object.

``````type(lm['s_freq'])
Out: mne.stats.regression.lm
``````

This object can be further broken down into different parts (which are the coefficients). The beta coefficients may be for example extracted as follows, which is an `EvokedArray` object.

``````lm['s_freq'].beta
type(lm['s_freq'].beta)
Out: mne.evoked.EvokedArray
``````

Am I understanding this well? If so, how could I extra with `EvokedArray` object of each coefficient for each predictor so that I can stored them in separate dictionaries?

Thanks!

did you have a look at the examples in

https://mne.tools/dev/generated/mne.stats.linear_regression.html#mne.stats.linear_regression

?

you can click on variables to know what their type is and on the source button to read the source code if it’s not clear

HTH
Alex

1 Like

Yes, I think I got it now. Thanks!