Help with 3ddeconvolve for linear models


This is my first attempt at fMRI analysis.
Some background -
I have 2 phases, 1 where images are presented singular, and 2 where they are paired. I want to describe phase 2’s data using phase 1, via the following equation.
[center]ss = b1 * s1 + b2 * s2 + b3 * s1 * s2[/center]

S1 and S2 are the response of the 2 images from phase 1, SS is the response of the pair in phase 2.
I have 3 1D files, S1 and S2 which have been ordered based on their presentation in phase 2.

I want to obtain b1, b2 and b3.

All my inputs are 1D files, as I am extracting values from a specific ROI.

please let me know if the given approach and the code is appropriate.


AAR_ROI_Analysis_MR: Performs multiple regression analysis on ROI time series

set subj = $1
echo $subj

set proj_path = /media/sanjana/home2/AARv4_MRI
set temp_path = /media/sanjana/home2/templates
set reg_path=$proj_path/data/regressors/activation

#set cond_names = (PP PN PU)
#@ no_Of_cond = $#cond_names

Looping through subjects

cd $proj_path/data/individual/AAR"$subj"/activation/trialWise/

Converting row vectors into coloumn vectors

1dtranspose -overwrite p2_trialWise_AAR"$subj".1D p2_trialWise_Transpose_AAR"$subj".1D
1dtranspose -overwrite S1_trialWise_AAR"$subj".1D S1_trialWise_Transpose_AAR"$subj".1D
1dtranspose -overwrite S2_trialWise_AAR"$subj".1D S2_trialWise_Transpose_AAR"$subj".1D

Providing 1D timeseries and its resolution (TR)

setenv AFNI_1D_TIME_TR 2.5

-input $proj_path/data/individual/AAR"$subj"/activation/trialWise/p2_trialWise_Transpose_AAR"$subj".1D
-polort A
-jobs 4
-num_stimts 3
-stim_file 1 $proj_path/data/individual/AAR"$subj"/activation/trialWise/S1_trialWise_Transpose_AAR"$subj".1D -stim_label 1 S1
-stim_file 2 $proj_path/data/individual/AAR"$subj"/activation/trialWise/S2_trialWise_Transpose_AAR"$subj".1D -stim_label 2 S2
-stim_file 3 $proj_path/data/individual/AAR"$subj"/activation/trialWise/S1xS2_trialWise_Transpose_AAR"$subj".1D -stim_label 2 S1xS2
-cbucket ./" AAR"$subj"_trialWise_TS_MR_SS"
-x1D ./“AAR”$subj"_TR_MNI_2mm_SI_censor_MR_trialWise_p1.x1D"
-xjpeg ./“AAR”$subj"_TR_MNI_2mm_SI_censor_MR_trialWise_p1.png"
-num_glt 1
-gltsym “SYM: S1 +S2 +S1xS2” -glt_label 1 AAR_interaction
-bucket ./“AAR”$subj"_TR_MNI_2mm_SI_censor_MR_SS_p2.txt"

If anything needs clarification, please let me know.
Thanks in advance


That looks okay, depending on how s1*s2 was constructed.

Since the phase of the S1 and S2 events differs from that of S1xS2 (is that the p2 file?), presumably the S1.1D and S2.1D files are zero where S1xS2.1D is non-zero, and vice versa. So if those were multiplied, the result would be all zero. Is that the case? I just want to be sure the regressors are temporally offset, so that the phases are distinct.

To be sure, multiple phases exist within a single run, is that right? Or is it supposed to be one phase per run?

And are you sure you do not want other regressors of no interest, such as for motion?

There is mention of ‘censor’ in the X-matrix. Has there been a regression already applied? What processing leads up to this?

  • rick

Hello Rick,

Thank you for your response. S1xS2 is the product of S1 and S2 responses from phase 1, that goes in the 3rd term in the RHS. So this term is zero when S1 and/or S2 is zero.

The phases are distinct, run one after the other. The design is such that - phase 1 - 4 runs then phase 2 - 4 runs.

I have already run 3ddeconvolve prior to this step, where I have included the motion parameters.

Does this change things in my code?

Maybe I am not quite following what the input is. Is this just the regression of phase 2, the last 4 runs? And in phase 2, you want the model b1S1 + b2S2 + b3S1S2? Or is that model supposed to span all 8 runs? That aspect is not quite clear.

In general, it is more appropriate to run a single complete regression than to project nuisance before a secondary one.
But ignoring that, I just want to clarify what the input to the regression is (4 runs (and which) or 8).


  • rick

In phase 2, I want the model b1S1 + b2S2 + b3S1S2. The last 4 runs only. The input I’ll be giving here is the phase 2 data.

“In general, it is more appropriate to run a single complete regression than to project nuisance before a secondary one.” Could you please elaborate on this?


Hi Sanjana,

Sure, modeling that in just the last 4 runs makes sense. I had initially gathered that all runs were in a single model.

Regarding running an initial regression before running a secondary regression on the residuals, there are 2 distinct issues with it.

  1. Assuming the betas in the first regression are not important (such as for motion in this case), a secondary regression is okay if the regressors in the secondary step are first orthogonalized with respect to the initial regressors. So in this case, the S1,S2,S1xS2 regressors should have motion, etc. projected out as well (as for the input). If this is not done, any motion components in the regressors are orthogonal to the input, and so the fit to regressors of interest will be distorted as the regression tries to minimize the least squares of the residuals (which will subsequently contain that motion). My guess as to the impact of this is that it would drive those betas closer to zero (as a collection) as the amount of motion in the regressors increases.

But in any case, this is not appropriate. So rather than pondering the effect, it would be better to avoid the problem. Either use a complete regression step or project motion (anything else? censoring?) from those regressors. Having -polort in both means you do not need to project out the polort from the regressors.

  1. A different problem arises if you actually care about the betas from the first regression (such as if you were to first model S1 and S2, and then model S1xS2 in the residuals, which I understand you are not doing). In this case, the S1 and S2 betas would likely be unfairly larger. The amount of S1xS2 in them will inflate the betas by the amount of S1xS2 in the original input. It would be identical to projecting S1xS2 out of S1 and S2 (which some groups do by habit).

Anyway, the most accurate way to go is to simply put this all in a single model.

  • rick

Hello Rick,

I understand the point you had made about the motion parameters. I had run a 3ddeconvolve on phase 1 and phase 2 data individually, and had regressed out the motion parameters. Would these issues in the first point arise despite this step?

Yes, the issue in the first point would arise because of the separate motion regression.
It would be more correct to orthogonalize the regressors of interest with respect to motion and polort, whatever is in the initial regression.

But really, what is the benefit of running 2 regression steps (projecting nuisance before computing betas)?

  • rick