Using 2ndlevel design_matrix for confounds and regressors of interest


I hope this isn’t too simple a question - I am using nistats.second_level_model.SecondLevelModel, and want to model both confounds across participants (e.g. age, sex…) and group regressors of interest (e.g. look for regions whose betas correlate with some trait-score (e.g. mindfulness)).

Looking into the .fit() documentation (

I see that there is both a confounds argument and a design matrix argument. However, under the description of the arguments, the docs state of the confound argument: “If design_matrix is provided then this argument is ignored.”

Does this mean that we can only model confound regressors, and no group regressors of interest, or have I missed some other chunk of nistats that would simplify this greatly? What is the difference between the two arguments?


1 Like

Might be related to my post.

I hope I understand correctly, but you should prepare the design matrix “manually”, by designing the regressors as you wish (nuisance and regressors of interest).
Would this work for you ?

Note that the arguments are called “confound regressors”, but this does not mean that they are of no interest: you may want to make inference on them. Maybe the naming conventions used here are misleading.


@JohannesWiesner your post was very instructive - thank you very much!

@bthirion I will be able to create this design matrix manually without a problem (well, one small problem below), thanks for the note on the naming!

A new problem - some of the demographic data is missing! a small portion of the subjects did not complete the demographic survey, or the data was lost (this is an older dataset) - can nistats.second_level_model.SecondLevelModel handle missing data? for example, is regressing out age using 1 and -1, and 0 be used to indicate a missing value? for age, can 0 also be used? Thanks in advance for this guidance