Add additional column (accuracy) to design matrix

I am fitting a first-level GLM in nilearn, and am unsure how to go about adding accuracy as an additional regressor (I want to control for accuracy). For example, in my events file I have a column that indicates whether or not participants got a trial correct (1, 0).

Example of the column in my events file I have for accuracy (correct).

My current design matrix where I want an additional column that indicates correct vs incorrect

Is there an easy way to add this column? Should it simply be a 1 and 0 for one scan/TR at the onset of the trial or should it cover the full duration of the trial?

Thank you so much any help is much appreciated!

Hi @marlietandoc,

It is hard to provide you exact code without seeing how you got your current matrix. You can look at this tutorial for creating design matrices (Examples of design matrices - Nilearn). But since you already have them in your events files, it should just be a matter of loading your tsvs as a Pandas dataframe and dropping columns you aren’t interested, and then merging that dataframe with the corresponding dataframe from the confounds you want to use.

That might depend on the nature of the task and what kind of questions you are trying to answer. It is hard to say one way or the other without knowing more specifics. I would guess that more often than not, you would want the 1/0 to cover all the TRs for the given trial.


I may need to think a bit more about this one but my hunch (am under caffeinated so this could be complete :poop:) would then to actually split your conditions into several regressors (2 regressors per condition, one for correct answers and one for incorrect answers).