Running first level analysis with varying number of different trial_types per run

nistats
#1

Hi there,

I’m trying to calculate a simple first level analysis using nistats. However, for some of our subjects, not all runs have the same number of different trial_types (e.g. for run 1 there might be condition_1 and condition_2, while for run 2 there is condition_1, condition_2 and condition_3). While fitting the model works fine, computing the contrasts doesn’t:

ValueError: t contrasts should be length P=37, but this is length 38

I’m quite a newbie so I’d like to apologize if my two questions seem stupid:

  1. I was under the impression that nistats fits the model for all provides runs simultaneously - so wouldn’t be missing regressors for parts of the model problematic? Why does fitting even work?

  2. What is the recommended way of dealing with this?

Cheers,
Marc

#2

Hi Marc,
Indeed at the moment we do not support missing regressors in nistats glm. What should be returned in case of a missing regressor is actually unclear…
The best way to proceed is probably to fit glms separately for the different sessions, and then run the cross-session fixed effects analysis “manually”.
Does it make sense to you ?
B

1 Like
#3

Hi Bertrand,

thanks for your answer. Your suggestion sounds reasonable but I wonder if it would be possible to just concatenate the design matrices? Meaning to model each run/session separately and then create a large design matrix where all bold regressors “span” over all runs and regressors that are run-specific (e.g. drift-correction, confounds, motion outliers etc.) are set to 0 for all runs except those they were modeled for?

I’m a little bit unsure what this would mean in statistical terms. It feels like this would add a little bit of power because the model has more data to be fitted on, but there is probably a caveat to this approach I’m not seeing here.

Thanks,
Marc

#4

Note sure what you want to do, but indeed there is the possibility to handle all you data as if it were one single session by creating a large block-diagonal design matrix, in which each block is the design matrix for one sessions.
Note that in this case, even the confounds of the different blocks are handled cleanly.

The only caveat I can see is memory cost for the fit.

1 Like
#5

Hi Bertrand and Marc,

I’m so glad you’ve posted this, as I’m running into the same error! In my case, my runs have the same conditions but different confounds (I added regressors for high motion TRs above a certain FD threshold). As Marc mentioned, fitting the GLM seems to work, but I get a ValueError when making the contrasts.

I’m new to this too, and not quite sure how to run the cross-run fixed effects analysis and compute the resulting contrasts manually. Does anyone have an example of how to do this? Or thoughts on whether it would be worth it to take out the additional confounds just use FD as a continuous regressor?

Thanks so much!
Laura

#6

OK, there’s an ongoing PR on Nistats on this topic (https://github.com/nistats/nistats/pull/386) .
If you know how to do this, simply clone the corresponding branch and use it…

Best,
Bertrand