Dear Raphael
If you are using the latest of release of SPM (out last month), there is a simpler scripting interface for specifying fMRI DCMs, via the function spm_dcm_specify. Here's the example script included in the help text of that function:
s = struct();
s.name = 'test';
s.u = [1 1]';
s.delays = [1.2 1.2];
s.TE = 0.05;
s.nonlinear = true;
s.two_state = true;
s.stochastic = true;
s.centre = true;
s.induced = 0;
s.a = a;
s.b = b;
s.c = c;
s.d = d;
DCM = spm_dcm_specify(SPM,xY,s);
Most of these settings recapitulate those in the SPM GUI and can be run in a loop over subjects. There are two settings you should be mindful of:
s.u(i,j) sets whether to include regressor j of condition i from the design matrix in the DCM. If you don't have parametric regressors, then j will always equal one.
xY is a cell array of strings containing the filenames of the VOIs to include.
If for any reason you can't upgrade to the latest DCM, e.g. you're half way through an analysis, feel free to share a broken DCM (zipped, as I can't receive .mat files), and I'll take a look at what's wrong.
Best
Peter
-----Original Message-----
From: SPM (Statistical Parametric Mapping) <[log in to unmask]> On Behalf Of Raphael Underwood
Sent: 25 January 2019 18:12
To: [log in to unmask]
Subject: [SPM] DCM specification script help
Dear DCM experts,
I have inherited a script that allows you to specify a model for multiple participants, using a template model specified by hand in SPM.
The data is taken from a facial emotion task involving neutral, fearful, angry, and happy faces.
My template model has 3 out of 4 inputs included (Neutral, fear, anger, but not happy), and 2 of those inputs are hypothesised to have modulatory input (fear and anger).
The script runs successfully for all my participants, but when I try to estimate a model created by this script, I get this error:
Error using inlineeval (line 14)
Error in inline expression ==> spm_int(P,M,U) Inner matrix dimensions must agree.
I've determined that when I open the DCM.U variable, my template model has 3 inputs (Neutral, Fear, Anger) as expected, but the models created by the script show all 4 (Neutral, Fear, Anger, Happy). I'm assuming this is the source of the error, and that my script is not creating the U variable properly.
I've copied the section of my script which gets the inputs below, in the hopes that someone can point out what might need editing.
I've noticed that the code for 'main condition' and 'parametric modulator' are identical, which might be part of the problem? Any help appreciated!
Raphael
% inputs
%==================================================================
% get 'causes' or inputs U
%------------------------------------------------------------------
Sess = SPM.Sess(xY(1).Sess);
U.dt = Sess.U(1).dt;
u = length(Sess.U);
U.name = {};
U.u = [];
for i = 1:u
for j = 1:length(Sess.U(i).name)
switch j
case 1 % main condition
U.u = [U.u Sess.U(i).u(33:end,j)];
U.name{end + 1} = Sess.U(i).name{j};
case 2 % parametric modulator: probability
U.u = [U.u Sess.U(i).u(33:end,j)];
U.name{end + 1} = Sess.U(i).name{j};
end
end
nc = size(U.u,2);
end
|