I have three .niis from the same session, two of these contain condition A, and the third contains condition B. I want to produce subject level t/z maps for A > B and B > A. Following the tutorial here, I was able to make design matrices individually for the three runs and can fit the GLM. However, I am now running into troubles defining the contrasts for a few reasons: 1) the design matrices are different sizes between the condition A and B runs since they are different lengths, 2) I don’t see how I can define a contrast vector, since the conditions I am interested in may be the first conditions of the given runs. That is, I can’t think of a way to make one-hot encoded vectors unique to my contrasts, unless I make them 2D which I’m not sure Nilearn would accept.
Does anyone have any advice about how to proceed in this case?
Thanks,
Steven
Not sure I understand properly. Do you means that A and B are observed in different runs and that you want to combine them a posteriori to get a contrast ?
IIUC this is something unusual, and that should be avoided, because it conflates a run effect with a condition effect. I don’t see a good solution to your case, sorry.
Bertrand
Just to get more specific, in the picture below, I want to contrast the conditions “arith_Large” in runs 1 and 2 with “Word_Rhyme” in run 3. Is this design matrix invalid? The GLM was fit on the three runs concatenated with a concatenated design matrix as seen below. The individual runs were zero padded in times when they were not active. Would a contrast matrix for arith_Large vs Word_Rhyme have 0.5 where arith_Large is active (since it happens in two columns) and -1 when word_rhyme is active (and 0s everywhere else)?
It seems like in this thread you note the possibility of making a diagonal design matrix, or alternatively a fixed effect model, as in the tutorial here.
If I do the diagonal design matrix, did I set it up correctly in the picture above? Since the first two blocks are the same size and have the same regressor names can I just vertically stack them?
If I do the fixed effect model, should the effect I use for a given session be for A > Baseline or B > Baseline, or can I use just the effect of A/B?
I think that technically, your solution with a block design matrix solves your problem (I can only acknowledge your creativity ). In a perfect world, where scanners are reliable and brain signals are well-behaved, there is no big problem with this approach.
You should simply be aware that there may be some drifts across runs (due to tiredness or any type of instability), so that part of the difference you see between contrasts may be attributable to a run effect. It’s your responsbility to interpret these values with caution.
I would not stack vertically the first two blocks, to better fit signals variations, whether wanted (task effects) or not (drifts, motion).
Best,
Bertrand
Got it, thanks! Initial testing looks okay. This is reading > face match contrast and looks to be about what I expect (more reading on the left. more faces on the right).
@Steven Hi Steven, I’m very new to Nilearn and python in general but I am trying to create a block design matrix just like yours, do you mind sharing with me how you did it?
I actually now do most of my first-level modeling in Fitlins, since it is developed against fMRIPrep derivatives (and I mainly use fMRIPrep for preprocessing). If you would want help on this, feel free to reach out or start a new thread!
Hello! I am a novice in NiLearn trying to model a contrast between two difference conditions (a number and a lexical task - two runs each) from each subject. I am thinking it might be best to create a diagonal design matrix (like the one shown above) for my first level analysis. I am not sure how to code that in Python. Any tips would be greatly appreciated! Thank you!