I would like to know how does 3dDeconvolve -gltsym compute the t statistics for simple contrasts.
I thought I should be able to get the same results manually.

For a simple study having two conditions, A and B, I’d like to compute the t-stat for +A -B.
I used the following formula:
C = [zeros for baseline regressors, 1, -1]
X is design matrix from X.test.xmat.1D
dof (degrees of freedom) can be found using 3dinfo -verb stats.test_REML+orig
beta_A and beta_B can be found in stats.test_REML+orig
t = (beta_A - beta_B) / sem
sem = sqrt(mse * C * (X’ * X)^-1 * C’)
mse = sum(errts^2, axis=-1) / dof where errts is from errts.test_REML+orig

However, the result was not equal to the t value in stats.test_REML+orig

Could anyone help and tell me what I’m missing here? Is this discrepancy due to the fact that I calculate the stats with 3dREMLfit?

Replying years later in case anyone else is interested… I had the same question, wanting to understand precisely how t-statistics are computed when using 3dREMLfit. To manually replicate a t-statistic you’ll need to construct or estimate the correlation matrix R as described in the (handwritten…) 3dREMLfit notes. This matrix is neither saved in output nor explicitly stored in memory by the solver given its size.

As a test example to understand construction, given sigma, coef, a, and lambda from stats.REML and stats.REMLvar results datasets, a design matrix X, and a vector or matrix C (tested here as a vector, for a single contrast, for a single run, with no censored TRs) which extracts the contrast of interest, I am able to replicate t-statistics with reasonable precision with a Matlab function explicitly forming R:

function T = REML_tStat(a, lam, std, coef, X, C)
dim = size(X,1);
r = zeros(dim,1);
r(1) = 1; r(2) = lam;
for i = 3:dim
r(i) = lama.^(i-2);
end
R = toeplitz(r);
T = coef/sqrt(std^2C*inv(X’*inv(R)*X)*C’);
end

I’m not aware of a convenient/straightforward way to generate whole volumes with AFNI functions but do not believe that would be a worthwhile endeavor anyway.

If there are any glaring errors here I would appreciate those being pointed out by AFNI experts.

Thanks for nicely addressing this question that apparently got lost in the shuffle.

Indeed, REML has more considerations that ‘just’ running 3dDeconvolve. I just wanted to note for any future readers that the cited, handcrafted notes and further discussion about REML in the case of censoring (which might also be of interest to people) are contained within this section of the documentation: https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/statistics/remlfit.html

As to this comment:

I’m not aware of a convenient/straightforward way to generate whole volumes with AFNI functions but do not believe that would be a worthwhile endeavor anyway.

… isn’t 3dREMLfit the convenient and straightforward way to generate those whole volumes?

… isn’t 3dREMLfit the convenient and
straightforward way to generate those whole
volumes?

Yes I had meant whole volumes of manually replicated statistics to compare with AFNI’s output. Unnecessary and laborious. Some scalar-level checks suffice for peace of mind.
Thanks!

Okeydoke. And happy to have those validated—it may have been laborious, but it was certainly useful.

thanks,
pt

The
National Institute of Mental Health (NIMH) is part of the National Institutes of
Health (NIH), a component of the U.S. Department of Health and Human
Services.