Dear DCM experts,
I am trying to automate DCM calculations and running into a number of problems. Does anyone have code for doing this, or have any advice for what might be going on here?
Here is a code snippet of how I'm doing it:
% Load pre-configured DCM
load(fullfile(dataPath,dcmFile));
% Remove priors
DCM.M = rmfield(DCM.M,{'pE','pC'});
try
DCM.M = rmfield(DCM.M,{'gE','gC'});
catch
disp('Error removing prior, does not exist');
end
% fileType is an identified for the combined ERP mat files
files = dir([dataPath fileType '*.mat']);
for k = 1:length(files)
dcmFileNew = strcat(dataPath,'DCM_', files(k).name);
disp(['Running subject ' fileName ']);
% get data file
DCM.xY.Dfile = fullfile(dataPath,files(k).name);
% Load data
DCM = spm_dcm_erp_data(DCM);
% Force location of head model
DCM.M.dipfit.vol = 'C:\Users\Mark\Documents\MATLAB\spm12\canonical\single_subj_T1_EEG_BEM.mat';
% Invert the DCM and save
DCM.options.Nmax = 128;
DCM.M.Nmax = 128;
DCMout = spm_dcm_erp(DCM);
save(dcmFileNew,'DCMout');
end
So, basically what this is doing is loading a pre-configured DCM, overwriting the data and inverting. The data I am using are from a 32 channel array, with an oddball paradigm, and the data are two trial waveforms for the standard and deviant trials averaged over multiple - artifact-free - events. The data are combined into one mat object for each subject.
The issues which I am finding is that it is sometimes going back to the SPM input window to ask for the head model, even though I have already defined the head model and it's saved into the DCM file. Also, you will notice that I had to hard code the location of the head model, even though it is already specified in the DCM which is loaded upfront.
The second problem I am running into, with may have to do with the head model as well, is that running the same model (i.e. same ERP data, and starting with the same DCM and the same saved head model), I get very different performance on two systems (Linux vs. PC, both are on SPM12). The Linux version seems to be behaving fine and converges, while the PC version is not (it is clear from the system identification window that the algorithm is way off, the hidden states look nothing like I would expect - on the PC version, on Linux they look fine).
Any advice here would be MOST appreciated. Thanks!
Mark Wagshul
|