Vertex-wise Mediation Analyses -Error message
antoniettapepe opened this issue · 1 comments
Hi,
I was trying to replicate step by step the work flow example for vertex wise mediation analyses on my own data, but while running the fourth step (mediation analysis), I run into this error message:
_Traceback (most recent call last):
File "/homes_unix/pepe/anaconda2/envs/newer_plot_surfaces/bin/tfce_mediation", line 137, in
args.func(args)
File "/homes_unix/pepe/anaconda2/envs/newer_plot_surfaces/lib/python2.7/site-packages/tfce_mediation/tmanalysis/STEP_1_vertex_tfce_multiple_regression.py", line 245, in run
y_lh = resid_covars(x_covars,data_lh)
File "tfce_mediation/cynumstats.pyx", line 55, in tfce_mediation.cynumstats.resid_covars
File "tfce_mediation/cynumstats.pyx", line 29, in tfce_mediation.cynumstats.cy_lin_lstsqr_mat
File "/homes_unix/pepe/.local/lib/python2.7/site-packages/numpy/linalg/linalg.py", line 528, in inv
ainv = _umath_linalg.inv(a, signature=signature, extobj=extobj)
File "/homes_unix/pepe/.local/lib/python2.7/site-packages/numpy/linalg/linalg.py", line 89, in raise_linalgerror_singular
raise LinAlgError("Singular matrix")
numpy.linalg.linalg.LinAlgError: Singular matrix
I am wondering if this has something to do with the way I defined my predictors or covariates (one column for variable, and one row for subject, no header, no subject IDs). In attempt to debug this problem, at line 236 of the STEP_1_vertex_tfce_multiple_regression.py, I printed the size of some variables:
x_covars.shape = (452, 7)
data_lh.shape = (149955, 452)
n = 452
opts.input = ['predictor_lang_spat_memo_std_dm.csv', 'covariates_age_sex_hand_ne_std_dm.csv']
pred_x.shape=(452, 3)
covars.shape= (452, 6)
Do them make any sense to you? I am also curious about the size 149955 in data_lh.shape, which does not seam to be equal to the number of vertices in the ?h.all.area.03B.mgh
Any ideas on this error message on this will be really appreciated
Antonietta
Hi Antonietta,
The "Singular matrix" error occurs when at least one of the regressor is the linear product of the other. Do you mind sharing your covariate and predictor files (email is fine)?
Regarding the shape of the data. 149955 vertices have non-zero values from the 164K surface (i.e., the same size of the Freesurfer ?h.cortex mask).
Cheers,
Tris