function [ ] = dcm_suppression_movement_modelled_17M(SJs, sessions)



% first DCM script to test 17 models (first one full model) on how suppression in
% V5 takes place. 
% fully connected A-matrix
% B-matrix modelled only for active condition 


%% run script with the following command
% for i={'01','02','03','04','05','09','10','12','13','14','15','17','18','19','21','22','24'}; rk_efp_dcm_OOFFAA_emosep(i{1}); end;
% these are all subs without depress AND with bilateral AMY activation at
% 0.001 uncorrected


% % subject identifiers stub
SJs =   {'P1', 'P2', 'P4', 'P5', 'P8', ...
         'P10', 'P11', 'P13', 'P15', 'P16',...
         'P17', 'P18', 'P19', 'P20', 'P22', ...
         'P25', 'P26', 'P27', 'P28' 'P29'};

sessions = 1;


for sj = [1] %[1 2 4 5 8 10 11 13 15 16 17 18 19 20 22 25:29] % P2 & P8e sonradan bak!!! yapmadi
    
   clear SPM.mat SPM.swd data_path DCM.xY DCM.n DCM.v DCM.Y DCM.U DCM.a DCM.b DCM.c
   
%% Load new SPM.mat

load(strcat('/export/data/mridsk001_sqfs/imaging/StudyData/PACT/Ezgi_camera/CAMERA/Results/fMRI/ICA2/DCM/movement_modelled/P', num2str(sj),'/SPM.mat'));
SPM.swd=strcat('/export/data/mridsk001_sqfs/imaging/StudyData/PACT/Ezgi_camera/CAMERA/Results/fMRI/ICA2/DCM/movement_modelled/P', num2str(sj));

% save('SPM.mat',SPM);


data_path = fullfile(strcat('/export/data/mridsk001_sqfs/imaging/StudyData/PACT/Ezgi_camera/CAMERA/Results/fMRI/ICA2/DCM/movement_modelled/P', num2str(sj)));
cd(data_path);

%% Load regions of interest

try
    
    load(fullfile(data_path,strcat('VOI_PPC_1','.mat')),'xY');
    DCM.xY(1) = xY;
    load(fullfile(data_path,strcat('VOI_M1_1','.mat')),'xY');
    DCM.xY(2) = xY;
    load(fullfile(data_path,strcat('VOI_V5_1','.mat')),'xY');
    DCM.xY(3) = xY;
    load(fullfile(data_path,strcat('VOI_cerebellum_1','.mat')),'xY');
    DCM.xY(4) = xY;
    
catch
    display(['subject P', strcat(num2str(sj)), ' not all VOIs available\n'])
    return;                                                         %%% STOPS SCRIPT IF NOT ALL VOIS PRESENT !!!
end

DCM.n = length(DCM.xY);      % number of regions
DCM.v = length(DCM.xY(1).u); % number of time points

%% Time series

DCM.Y.dt  = SPM.xY.RT;
DCM.Y.X0  = DCM.xY(1).X0;
for i = 1:DCM.n
    DCM.Y.y(:,i)  = DCM.xY(i).u;
    DCM.Y.name{i} = DCM.xY(i).name;
end

DCM.Y.Q    = spm_Ce(ones(1,DCM.n)*DCM.v);

%% Experimental inputs

DCM.U.dt   =  SPM.Sess.U(1).dt;
DCM.U.name = [SPM.Sess.U.name];
DCM.U.u    = [SPM.Sess.U(1).u(33:end,1) ... %% hier nochmal nachschauen ob es mit der anderen Matrix uebereinstuimmt
              SPM.Sess.U(2).u(33:end,1)];




%% DCM parameters and options
% DCM.delays in the order of PPC, M1, V5, cerebellum [0.275; 0.65; 0.075; 1.20]
DCM.delays = [0.275; 0.65; 0.075; 1.20]; %repmat(SPM.xY.RT/2,DCM.n,1);   % hier nur anpassen, wenn slice timing angepasst werden sollte
DCM.TE     = 0.025;                          % anpassen

DCM.options.nonlinear  = 0;                 %%%%% das hier besonders in diesem skript !!!!! %%%%%%
DCM.options.two_state  = 0;                 % anpassen
DCM.options.stochastic = 0;                 % evtl noch stoch machen
DCM.options.nograph    = 0;                 % urspr 1

%% M_fi2007core_1a

% DCM.a = [0 1 1 1; 1 0 1 1; 1 1 0 1; 1 1 1 0]; %fully connected A-matrix
% DCM.b = zeros(3,3,4);
% DCM.c = [1 0 0 0; 0 0 0 0; 0 0 0 0];
% DCM.d = zeros(3,3,0);
% save(strcat('/media/cth/TOSHIBA EXT8/MRI_data/EFP/4_DCM/7_fairhallishai2007_rhem_bilinearmod/',subjects,'/DCM_fi2007_core_M_1a_sub',subjects,'.mat'),'DCM');

%% M_fi2007core alle definitionen
% full model (all parameters included)
for model = 1
     DCM.a = [1 1 1 1; 1 1 1 1; 1 1 1 1; 1 1 1 1]; 
        DCM.b = zeros(4,4,2);
        DCM.b(:,:,1) = [0 1 1 1; 1 0 1 1; 1 1 0 1; 1 1 1 0]; % active condition
        DCM.c = [1 1; 1 1; 1 1; 0 0];   
        
        save(strcat('/export/data/mridsk001_sqfs/imaging/StudyData/PACT/Ezgi_camera/CAMERA/Results/fMRI/ICA2/DCM/GLMs/movement_modelled_17M/P',num2str(sj),'/DCM_',num2str(model),'.mat'),'DCM');
        spm_dcm_estimate(strcat('/export/data/mridsk001_sqfs/imaging/StudyData/PACT/Ezgi_camera/CAMERA/Results/fMRI/ICA2/DCM/GLMs/movement_modelled_17M/P',num2str(sj),'/DCM_',num2str(model),'.mat'));
end

% first model space (direct input to M1 and V5)
for model = 2:9
    if model == 2
        %for active condition
        DCM.a = [1 1 1 1; 1 1 1 1; 1 1 1 1; 1 1 1 1]; %[0 1 1 1; 1 0 1 1; 1 1 0 1; 1 1 1 0];
        DCM.b = zeros(4,4,2);
        DCM.b(:,:,1) = [0 0 0 0; 0 0 0 0; 0 0 0 1; 0 1 0 0]; % active condition
        %         DCM.b(:,:,2) = [0 0 0 0; 0 0 0 0; 0 0 0 1; 0 1 0 0]; % passive condition
        DCM.c = [0 0; 1 1; 1 1; 0 0]; % direct input [0 0 0 0 0; 1 0 0 0 0; 1 0 0 0 0; 0 0 0 0 0];
        
    elseif model == 3
        %for active condition
        DCM.a = [1 1 1 1; 1 1 1 1; 1 1 1 1; 1 1 1 1]; %[0 1 1 1; 1 0 1 1; 1 1 0 1; 1 1 1 0];
        DCM.b = zeros(4,4,2);
        DCM.b(:,:,1) = [0 0 0 0; 0 0 0 0; 0 0 0 1; 1 1 0 0]; % active condition
        DCM.c = [0 0; 1 1; 1 1; 0 0]; % direct input [0 0 0 0 0; 1 0 0 0 0; 1 0 0 0 0; 0 0 0 0 0];
        
    elseif model == 4
        %for active condition
        DCM.a = [1 1 1 1; 1 1 1 1; 1 1 1 1; 1 1 1 1]; %[0 1 1 1; 1 0 1 1; 1 1 0 1; 1 1 1 0];
        DCM.b = zeros(4,4,2);
        DCM.b(:,:,1) = [0 0 0 0; 0 0 0 0; 1 0 0 1; 1 1 0 0]; % active condition
        DCM.c = [0 0; 1 1; 1 1; 0 0]; % direct input [0 0 0 0 0; 1 0 0 0 0; 1 0 0 0 0; 0 0 0 0 0];
        
    elseif model == 5
        %for active condition
        DCM.a = [1 1 1 1; 1 1 1 1; 1 1 1 1; 1 1 1 1]; %[0 1 1 1; 1 0 1 1; 1 1 0 1; 1 1 1 0];
        DCM.b = zeros(4,4,2);
        DCM.b(:,:,1) = [0 0 0 0; 0 0 0 1; 0 0 0 1; 1 1 0 0]; % active condition
        DCM.c = [0 0; 1 1; 1 1; 0 0]; % direct input [0 0 0 0 0; 1 0 0 0 0; 1 0 0 0 0; 0 0 0 0 0];
        
    elseif model == 6
        %for active condition
        DCM.a = [1 1 1 1; 1 1 1 1; 1 1 1 1; 1 1 1 1]; %[0 1 1 1; 1 0 1 1; 1 1 0 1; 1 1 1 0];
        DCM.b = zeros(4,4,2);
        DCM.b(:,:,1) = [0 0 0 0; 0 0 0 1; 1 0 0 1; 1 1 0 0]; % active condition
        DCM.c = [0 0; 1 1; 1 1; 0 0]; % direct input [0 0 0 0 0; 1 0 0 0 0; 1 0 0 0 0; 0 0 0 0 0];
        
        
    elseif model == 7
        %for active condition
        DCM.a = [1 1 1 1; 1 1 1 1; 1 1 1 1; 1 1 1 1]; %[0 1 1 1; 1 0 1 1; 1 1 0 1; 1 1 1 0];
        DCM.b = zeros(4,4,2);
        DCM.b(:,:,1) = [0 0 0 1; 0 0 0 0; 0 0 0 1; 1 1 0 0]; % active condition
        DCM.c = [0 0; 1 1; 1 1; 0 0]; % direct input [0 0 0 0 0; 1 0 0 0 0; 1 0 0 0 0; 0 0 0 0 0];
        
        
    elseif model == 8
        %for active condition
        DCM.a = [1 1 1 1; 1 1 1 1; 1 1 1 1; 1 1 1 1]; %[0 1 1 1; 1 0 1 1; 1 1 0 1; 1 1 1 0];
        DCM.b = zeros(4,4,2);
        DCM.b(:,:,1) = [0 0 0 1; 0 0 0 1; 0 0 0 1; 1 1 0 0]; % active condition
        DCM.c = [0 0; 1 1; 1 1; 0 0]; % direct input [0 0 0 0 0; 1 0 0 0 0; 1 0 0 0 0; 0 0 0 0 0];
        
        
    elseif model == 9
        %for active condition
        DCM.a = [1 1 1 1; 1 1 1 1; 1 1 1 1; 1 1 1 1]; %[0 1 1 1; 1 0 1 1; 1 1 0 1; 1 1 1 0];
        DCM.b = zeros(4,4,2);
        DCM.b(:,:,1) = [0 0 0 1; 0 0 0 1; 1 0 0 1; 1 1 0 0]; % active condition
        DCM.c = [0 0; 1 1; 1 1; 0 0]; % direct input [0 0 0 0 0; 1 0 0 0 0; 1 0 0 0 0; 0 0 0 0 0]; 
    end
    
     save(strcat('/export/data/mridsk001_sqfs/imaging/StudyData/PACT/Ezgi_camera/CAMERA/Results/fMRI/ICA2/DCM/GLMs/movement_modelled_17M/P',num2str(sj),'/DCM_',num2str(model),'.mat'),'DCM');
     spm_dcm_estimate(strcat('/export/data/mridsk001_sqfs/imaging/StudyData/PACT/Ezgi_camera/CAMERA/Results/fMRI/ICA2/DCM/GLMs/movement_modelled_17M/P',num2str(sj),'/DCM_',num2str(model),'.mat'));
end


% model space 2, direct input to PPC and V5
for model = 10:17
    
    if model == 10
        DCM.a = [1 1 1 1; 1 1 1 1; 1 1 1 1; 1 1 1 1]; %[0 1 1 1; 1 0 1 1; 1 1 0 1; 1 1 1 0];
        DCM.b = zeros(4,4,2);
        DCM.b(:,:,1) = [0 0 0 0; 1 0 0 0; 0 0 0 1; 0 1 0 0]; % active condition
        DCM.c = [1 1; 0 0; 1 1; 0 0];
        
    elseif model == 11
        DCM.a = [1 1 1 1; 1 1 1 1; 1 1 1 1; 1 1 1 1]; %[0 1 1 1; 1 0 1 1; 1 1 0 1; 1 1 1 0];
        DCM.b = zeros(4,4,2);
        DCM.b(:,:,1) = [0 0 0 0; 1 0 0 0; 0 0 0 1; 1 1 0 0]; % active condition
        DCM.c = [1 1; 0 0; 1 1; 0 0];
        
    elseif model == 12
        DCM.a = [1 1 1 1; 1 1 1 1; 1 1 1 1; 1 1 1 1]; %[0 1 1 1; 1 0 1 1; 1 1 0 1; 1 1 1 0];
        DCM.b = zeros(4,4,2);
        DCM.b(:,:,1) = [0 0 0 0; 1 0 0 0; 1 0 0 1; 1 1 0 0]; % active condition
        DCM.c = [1 1; 0 0; 1 1; 0 0];
        
    elseif model == 13
        DCM.a = [1 1 1 1; 1 1 1 1; 1 1 1 1; 1 1 1 1]; %[0 1 1 1; 1 0 1 1; 1 1 0 1; 1 1 1 0];
        DCM.b = zeros(4,4,2);
        DCM.b(:,:,1) = [0 0 0 0; 1 0 0 1; 0 0 0 1; 1 1 0 0]; % active condition
        DCM.c = [1 1; 0 0; 1 1; 0 0];
        
    elseif model == 14
        DCM.a = [1 1 1 1; 1 1 1 1; 1 1 1 1; 1 1 1 1]; %[0 1 1 1; 1 0 1 1; 1 1 0 1; 1 1 1 0];
        DCM.b = zeros(4,4,2);
        DCM.b(:,:,1) = [0 0 0 0; 1 0 0 1; 1 0 0 1; 1 1 0 0]; % active condition
        DCM.c = [1 1; 0 0; 1 1; 0 0];
        
    elseif model == 15
        DCM.a = [1 1 1 1; 1 1 1 1; 1 1 1 1; 1 1 1 1]; %[0 1 1 1; 1 0 1 1; 1 1 0 1; 1 1 1 0];
        DCM.b = zeros(4,4,2);
        DCM.b(:,:,1) = [0 0 0 1; 1 0 0 0; 0 0 0 1; 1 1 0 0]; % active condition
        DCM.c = [1 1; 0 0; 1 1; 0 0];
        
    elseif model == 16
        DCM.a = [1 1 1 1; 1 1 1 1; 1 1 1 1; 1 1 1 1]; %[0 1 1 1; 1 0 1 1; 1 1 0 1; 1 1 1 0];
        DCM.b = zeros(4,4,2);
        DCM.b(:,:,1) = [0 0 0 1; 1 0 0 1; 0 0 0 1; 1 1 0 0]; % active condition
        DCM.c = [1 1; 0 0; 1 1; 0 0];
        
    elseif model == 17
        DCM.a = [1 1 1 1; 1 1 1 1; 1 1 1 1; 1 1 1 1]; %[0 1 1 1; 1 0 1 1; 1 1 0 1; 1 1 1 0];
        DCM.b = zeros(4,4,2);
        DCM.b(:,:,1) = [0 0 0 1; 1 0 0 1; 1 0 0 1; 1 1 0 0]; % active condition
        DCM.c = [1 1; 0 0; 1 1; 0 0];
        
        
    end
    
       save(strcat('/export/data/mridsk001_sqfs/imaging/StudyData/PACT/Ezgi_camera/CAMERA/Results/fMRI/ICA2/DCM/GLMs/movement_modelled_17M/P',num2str(sj),'/DCM_',num2str(model),'.mat'),'DCM');
       spm_dcm_estimate(strcat('/export/data/mridsk001_sqfs/imaging/StudyData/PACT/Ezgi_camera/CAMERA/Results/fMRI/ICA2/DCM/GLMs/movement_modelled_17M/P',num2str(sj),'/DCM_',num2str(model),'.mat'));
    
end
        
% % DCM Estimation
% clear matlabbatch
% for sj = [1 2 4 5 8 10 11 13 15 16 17 18 19 20 22 25:29] % P8e sonradan bak!!! yapmadi
%  spm_dcm_estimate(strcat('/export/data/mridsk001_sqfs/imaging/StudyData/PACT/Ezgi_camera/CAMERA/Results/fMRI/ICA2/DCM/GLMs/movement_modelled/P',num2str(sj),'/DCM_ModelSpace1_1','.mat'));
%  spm_dcm_estimate(strcat('/export/data/mridsk001_sqfs/imaging/StudyData/PACT/Ezgi_camera/CAMERA/Results/fMRI/ICA2/DCM/GLMs/movement_modelled/P',num2str(sj),'/DCM_ModelSpace1_2','.mat'));
%  spm_dcm_estimate(strcat('/export/data/mridsk001_sqfs/imaging/StudyData/PACT/Ezgi_camera/CAMERA/Results/fMRI/ICA2/DCM/GLMs/movement_modelled/P',num2str(sj),'/DCM_ModelSpace1_3','.mat'));
%  spm_dcm_estimate(strcat('/export/data/mridsk001_sqfs/imaging/StudyData/PACT/Ezgi_camera/CAMERA/Results/fMRI/ICA2/DCM/GLMs/movement_modelled/P',num2str(sj),'/DCM_ModelSpace1_4','.mat'));
%  spm_dcm_estimate(strcat('/export/data/mridsk001_sqfs/imaging/StudyData/PACT/Ezgi_camera/CAMERA/Results/fMRI/ICA2/DCM/GLMs/movement_modelled/P',num2str(sj),'/DCM_ModelSpace1_5','.mat'));
%  spm_dcm_estimate(strcat('/export/data/mridsk001_sqfs/imaging/StudyData/PACT/Ezgi_camera/CAMERA/Results/fMRI/ICA2/DCM/GLMs/movement_modelled/P',num2str(sj),'/DCM_ModelSpace1_6','.mat'));
%  spm_dcm_estimate(strcat('/export/data/mridsk001_sqfs/imaging/StudyData/PACT/Ezgi_camera/CAMERA/Results/fMRI/ICA2/DCM/GLMs/movement_modelled/P',num2str(sj),'/DCM_ModelSpace1_7','.mat'));
%  spm_dcm_estimate(strcat('/export/data/mridsk001_sqfs/imaging/StudyData/PACT/Ezgi_camera/CAMERA/Results/fMRI/ICA2/DCM/GLMs/movement_modelled/P',num2str(sj),'/DCM_ModelSpace1_8','.mat'));
%  spm_dcm_estimate(strcat('/export/data/mridsk001_sqfs/imaging/StudyData/PACT/Ezgi_camera/CAMERA/Results/fMRI/ICA2/DCM/GLMs/movement_modelled/P',num2str(sj),'/DCM_ModelSpace2_1','.mat'));
%  spm_dcm_estimate(strcat('/export/data/mridsk001_sqfs/imaging/StudyData/PACT/Ezgi_camera/CAMERA/Results/fMRI/ICA2/DCM/GLMs/movement_modelled/P',num2str(sj),'/DCM_ModelSpace2_2','.mat'));
%  spm_dcm_estimate(strcat('/export/data/mridsk001_sqfs/imaging/StudyData/PACT/Ezgi_camera/CAMERA/Results/fMRI/ICA2/DCM/GLMs/movement_modelled/P',num2str(sj),'/DCM_ModelSpace2_3','.mat'));
%  spm_dcm_estimate(strcat('/export/data/mridsk001_sqfs/imaging/StudyData/PACT/Ezgi_camera/CAMERA/Results/fMRI/ICA2/DCM/GLMs/movement_modelled/P',num2str(sj),'/DCM_ModelSpace2_4','.mat'));
%  spm_dcm_estimate(strcat('/export/data/mridsk001_sqfs/imaging/StudyData/PACT/Ezgi_camera/CAMERA/Results/fMRI/ICA2/DCM/GLMs/movement_modelled/P',num2str(sj),'/DCM_ModelSpace2_5','.mat'));
%  spm_dcm_estimate(strcat('/export/data/mridsk001_sqfs/imaging/StudyData/PACT/Ezgi_camera/CAMERA/Results/fMRI/ICA2/DCM/GLMs/movement_modelled/P',num2str(sj),'/DCM_ModelSpace2_6','.mat'));
%  spm_dcm_estimate(strcat('/export/data/mridsk001_sqfs/imaging/StudyData/PACT/Ezgi_camera/CAMERA/Results/fMRI/ICA2/DCM/GLMs/movement_modelled/P',num2str(sj),'/DCM_ModelSpace2_7','.mat'));
%  spm_dcm_estimate(strcat('/export/data/mridsk001_sqfs/imaging/StudyData/PACT/Ezgi_camera/CAMERA/Results/fMRI/ICA2/DCM/GLMs/movement_modelled/P',num2str(sj),'/DCM_ModelSpace2_8','.mat'));  
% 
% 
% % cd ../../..;
% 
% 
% end

end



