[Mne_analysis] mne.stats.linear_regression

Emma Chen emma.chen.w at nyu.edu
Fri Dec 2 05:03:03 EST 2016
Search archives:

Hi Mne users,

Is there a way to use mne.stats.linear_regression on epoch data or stc
data  with *binary/categorical* predictors?

In the MEG data I'm analyzing, the  regressor I would like to use is a
categorical variable with 4 different categories of objects indicating
which type of object participants saw in each trial.

I've tried to create the design_matrix with a column of intercept + 4
column of dummy variables for each category. But it didn't work. Following
is the error messages I got:


LinAlgError                               Traceback (most recent call last)
<ipython-input-49-728b72ea06ce> in <module>()
----> 1 res=mne.stats.linear_regression(epochs_ALL, design_matrix, names)
in linear_regression(inst, design_matrix, names)
     85     logger.info(msg + ', (%s targets, %s regressors)' %
     86                 (np.product(data.shape[1:]), len(names)))
---> 87     lm_params = _fit_lm(data, design_matrix, names)
     88     lm = namedtuple('lm', 'beta stderr t_val p_val mlog10_p_val')
     89     lm_fits = {}

in _fit_lm(data, design_matrix, names)
    125     df = n_rows - n_predictors
    126     sqrt_noise_var = np.sqrt(resid_sum_squares /
--> 127     design_invcov = linalg.inv(np.dot(design_matrix.T,
    128     unscaled_stderrs = np.sqrt(np.diag(design_invcov))
    129     tiny = np.finfo(np.float64).tiny

in inv(a, overwrite_a, check_finite)
    685         inv_a, info = getri(lu, piv, lwork=lwork, overwrite_lu=1)
    686     if info > 0:
--> 687         raise LinAlgError("singular matrix")
    688     if info < 0:
    689         raise ValueError('illegal value in %d-th argument of
internal '

LinAlgError: singular matrix

Thanks in advance!


Emma(Wei) Chen, Ph.D.
Objects and Knowledge Laboratory
New York University Abu Dhabi
PO Box 129188
Abu Dhabi, United Arab Emirates
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20161202/196a5904/attachment.html 

More information about the Mne_analysis mailing list