Hi Gina,
this depends a bit on the way you structured the data (in SPM.xY). Let's
say you have 10 subjects and HRF, time and dispersion derivatives from
each, so 3 dependent observations per subject. Assuming your data are
arranged in the way that the first 10 images are all HRFs per subject,
followed by 10 time derivatives (TD) and then 10 dispersion derivatives
(DD), you can proceed as follows (also assuming the same sorting of
subjects for HRF, TD and DD):
n=10; %no. subjects
c=3; %no. conditions per subject
xVi.I = [ones(n*c,1), kron([1:c]',ones(n,1)),...
kron(ones(c,1),[1:n]'), ones(n*c,1)];
xVi.var = sparse([0 1 0 0]);
xVi.dep = sparse([0 0 1 0]);
xVi = spm_non_sphericity(xVi);
If you sorted your data the other way round, i.e. the first three images
are the HRF, TD and DD of the 1st subject followed by the same
arrangement for the other 9 subjects you can write:
xVi.I = [ones(n*c,1), kron(ones(n,1),[1:c]'),...
kron([1:n]',ones(c,1)), ones(n*c,1)];
xVi.var = sparse([0 1 0 0]);
xVi.dep = sparse([0 0 1 0]);
xVi = spm_non_sphericity(xVi);
You can inspect the variance components in xVi.Vi by typing:
for i=1:6, imagesc(xVi.Vi{i}); pause; end
You will see, that you are right in the sense that xVi.Vi entails 30x30
matrices but there 6 of them (not only one). Note that with the
specifications above we model unequal variances between the conditions
as well as dependent observations within subject. The first three
matrices in xVi.Vi model the three different variances (all entries fall
on the main diagonal). The other three model the dependencies between
observations where the entries indicate which observations may be
related to each other (hence, the symmetrical entries along the
off-diagonals).
This SHOULD work, but please check the variance components and if these
fit to the arrangement of your data! In other words: no warranty.....
Hope this helps,
Thilo
On Tue, 2014-01-14 at 19:26 +0000, gj wrote:
> Hi,
>
> I apologize for the following very naive and big-no-no/way-too-general question...but time crunch is getting painful... I'd like to
> understand how covariance/hyperparameter/nonsphericity calculations are PRACTICALLY handled in SPM (i.e. structures, code) so I can properly set up SPM.xVi.Vi and SPM.xVi.I in a Matlab script for a 2nd level analysis with 3 basis functions (and hence I should have 6 hyperparameters if I only have a single contrast in my 2nd level design, but I'm failing to set this up properly....and as far as I understand, I need to make sure that xVi.Vi is an nxn matrix, such that n=#observations, so if I take a single contrast from 1st level with 3 basis functions and 10 subjects, this would be a 30x30 matrix?)....
>
> Any pointers/guidelines/thoughts and your patience greatly appreciated!!
|