Nilearn first level model error and crash


I’m trying to fit the First Level Model with nilearn, but I get the following warning: UserWarning: Matrix is singular at working precision, regularizing…After that python crashes and restarts the kernel.
I use 24 motion parameters+csf+white_matter from fmriprep confounds file. Do you know what might be the issue? Also, my events file is pretty big: 478 entries.


Hi, do yo have more columns (regressors) than rows (time points) in your design matrix?

so i don’t create the design matrix explicitly, i use glm =, events=events, confounds=confounds_clean)
but it should have more time points than regressors (I have only 33 in confounds_clean)

Could you call ‘make_design_matrix’ with the corresponding arguments ? This should create the design matrix you need. If it has too many columns, indeed the fit may simply go wrong.

The shape of my design matrix is 50 columns by 415 rows.

are some of these columns very correlated? what are the largest and smallest eigenvalues of X^T X, where X is your design matrix?

Thanks a lot! I removed derivatives and power from the confounds dataframe and the warning disappeared. However, fitting GLM was still crashing. So I tried to run it on another computer and it worked.