% DCM PEB % Please replace filenames etc. by your own. %-------------------------------------------------------------------------- spm('defaults','EEG'); % Data and analysis directories %-------------------------------------------------------------------------- clear; close all; clc; ID = {'h17024', 'h17025', 'h17026', 'h17027', 'h17028', 'h17029', 'h17030', 'h17031', 'h17032', 'h17033', 'h17034', 'h17035', 'h17036', 'h17037', 'h17038', 'h17040', 'h17041', 'h17042', 'h17043', 'h17044', 'h17045', 'h17099',... 'p17024', 'p17027', 'p17043', 'p17044', 'p17059', 'p17060', 'p17061', 'p17062', 'p17063', 'p17064', 'p17071', 'p17072', 'p17073', 'p17075', 'p17076', 'p17078', 'p17085', 'p17086', 'p17087', 'p17089', 'p17090',... 'p17026', 'p17028', 'p17029', 'p17030', 'p17031', 'p17035', 'p17036', 'p17037', 'p17038', 'p17045', 'p17048', 'p17049', 'p17051', 'p17055', 'p17056', 'p17057', 'p17058', 'p17066', 'p17068', 'p17074', 'p17091'}; diff_patient = [zeros(1,22) -1*ones(1,21) ones(1,21)]'; main_patient = [-1*ones(1,22) ones(1,21) ones(1,21)]'; O_diff_patient = [zeros(1,22) ones(1,21) -1*ones(1,21)]'; main_effect_group1 = [ones(1,22) -1*ones(1,21) zeros(1,21)]'; main_effect_group2 = [zeros(1,22) ones(1,21) -1*ones(1,21)]'; main_group1 = [ones(1,21) -1*ones(1,21)]'; main_group2 = [-1*ones(1,21) ones(1,21)]'; load ('/Volumes/MDHS-Research/5120/Psychology/CNCP/Ilvana/RESULTS/VolatilityMonash/DCM/VolMelb.mat'); mkdir STABLE_RLE_CNTRGROUP Pdata = '/Volumes/MDHS-Research/5120/Psychology/CNCP/Ilvana/RESULTS/VolatilityMonash/DCM'; Panalysis = '/Volumes/MDHS-Research/5120/Psychology/CNCP/Ilvana/RESULTS/VolatilityMonash/DCM/STABLE_RLE_CNTRGROUP'; % analysis directory in Pbase for i = 1:length(ID) currname = cell2mat(ID(i)); %-------------------------------------------------------------------------- % Collate DCMs into a GCM file GCM{i} = ['/Volumes/MDHS-Research/5120/Psychology/CNCP/Ilvana/RESULTS/VolatilityMonash/DCM/STABLE_' currname '_results_fullMODEL_Allmodulation.mat']; end GCM = GCM'; cd(Panalysis); %specify PEB model settings M = struct(); M.alpha = 1; M.beta = 16; M.hE = 0; M.hC = 1/16; M.Q = 'all'; % Specify design matrix for N subjects. It should start with a constant column %M.X = [ones(numel(ID),1) main_patient O_diff_patient Age-mean(Age)]; %constant; main effect of patient; difference between patients; age covariate of no interest M.X = [ones(numel(ID),1) Total_RLE-mean(Total_RLE) Age-mean(Age) main_effect_group1 main_effect_group2]; %CAPE-mean(CAPE) Hallucinations-mean(Hallucinations) Delusions-mean(Delusions) %main_group1 main_group2 AgeC-mean(AgeC) % Choose field field = {'B'}; % Estimate model [PEB,GCM_updated] = spm_dcm_peb(GCM,M,field); save('PEB.mat','PEB'); save('GCM_updated.mat','GCM_updated'); %BMA = spm_dcm_peb_bmc(PEB(1)); [BMC2,PEB2] = spm_dcm_bmc_peb(GCM,M,field); GCM = spm_dcm_peb(GCM); %Write results save('GCM.mat','GCM'); % Compare and search over nested PEB models. BMA = spm_dcm_peb_bmc(PEB(1)); save('BMA.mat','BMA'); % Review results spm_dcm_peb_review(BMA,GCM)