%================================================% % GPPI_WRAPPER % % This script allows you to run Donald McLaren's gPPI toolbox to build % and estimate psychophysiological interaction (PPI) models for multiple % subjects and for multiple seed volumes-of-interest (VOI). Note that % before using this, you must first create image files corresponding to % your seed regions. In addition, note that there are TWO sections which % require your input. In the first section, you will define the majority % of the variables necessary for performing the analysis. In the second % section (near the bottom of the script), you will need to specify the % contrasts that you would like to estimate. % % You can download the toolbox and find further information at: % http://www.brainmap.wisc.edu/PPI % % November 7, 2011 -- Created by Bob Spunt % Edited by Christian Stoppel, Dec. 19, 2013 % Edited by Alexander Genauck, Dec. 08, 2014 %================================================% clear all; % USER INPUT: Paths, file-finding patterns, and analysis parameters %---------------------------------------------------------------------% % -----------Paths----------- gPPIpath = 'C:\Program Files\spm8\toolbox\PPPI'; % path for gPPI toolbox studypath = 'F:\AG_Diplomarbeit\Preprocessed_on_Windows_Machine_swuaf_VBM8'; % path for study directory sub_paths = {'CT'; 'PG'; 'AD'}; % if using subfolders in the study path for groups like CT, PG, AD level1path = 'results_abs_loss'; % path of level analysis (relative to subject folder) maskpath = 'F:\AG_Diplomarbeit\Preprocessed_on_Windows_Machine_swuaf_VBM8\batch_templates\SS_gPPI\VOIs'; % path for folder containing ROIs % -----------Patterns for finding files and folders ----------- subjectpattern = 'BGG_*'; % pattern for finding subject folders (use wildcards) subTAG = 'all'; % do which subjects? 'all' to do all, position indices to do subset, e.g., [1 3 7] maskpattern = '*nii'; % pattern for finding image files in ROI directory (z.B. ".img" oder ".nii") % -----------General PPI analysis parameters----------- spmversion = 8; % version of spm (5 or 8) estimateTAG = 1; % estimate the level 1 models? (1 = yes, 0 = no) ppi_folder_affix = 'cond'; % string to affix to name of your PPI analysis folder % -----------Defining the conditions (psychological effects)----------- method = 'cond'; % 'trad' for traditional method, 'cond' for generalized (condition-specific) method % conditions = {'task on' 'gain' 'loss' 'euclidean distance'}; % conditions % to compute PPIs for (must match names used in level 1 analysis) weiter % unten anlegen weights = [ ]; % weights to apply to conditions in traditional PPI (ignore if doing condition-spec) % -----------Definining the seed timecourse (physiological effect)----------- fcontrast = {'Omnibus F-test for PPI Analyses'};% 23; % F contrast to adjust for (corresponds to number of the ess image in level 1 folder) extract='eig'; % extract timecourse as first eigenvariate ('eig') or mean eigenvariate ('mean') masks={'mask.img'}; % name of images to use to constrain definition of the seed region threshold = [.0]; % values to threshold the images above at (number of values must match number of masks) VOImin = 1; % minimum number of voxels to accept a seed region as valid %-----------Contrasts----------- convec = []; % vector of weights for computing PPI contrast (trad PPI only) % IMPORTANT! If you are doing generalized PPI, specify your contrasts below %---------------------------------------------------------------------% addpath(gPPIpath) for ii = 3:3 %length(sub_paths) %looping through experimental groups % Find subjects %---------------------------------------------------------------------% cur_studypath = [studypath filesep sub_paths{ii}]; cd(cur_studypath); fprintf('\nSUBJECT LIST:\n'); d=dir(subjectpattern); for i=1:length(d) subnam{i}=d(i).name; subdir{i} = [cur_studypath filesep subnam{i} filesep level1path]; fprintf('\tAdding %s to subject list\n',subnam{i}) end % Diese Zeilen müssen nicht beachtet werden: subnam2 = {'K_FR02_t1';'K_FR06_t1';'K_BN02_t1';'K_FR04_t1';'K_FR08_t1';'K_FR09_t1';'K_FR10_t1';'K_BN01_t1';'K_BN12_t1';'K_FR13_t1';'K_FR14_t1';'K_BN14_t1';'K_BN18_t1';'K_FR15_t1';'K_BN10_t1';'K_BN16_t1';'K_FR02_t2';'K_FR06_t2';'K_BN02_t2';'K_FR04_t2';'K_FR08_t2';'K_FR09_t2';'K_FR10_t2';'K_BN01_t2';'K_BN12_t2';'K_FR13_t2';'K_FR14_t2';'K_BN14_t2';'K_BN18_t2';'K_FR15_t2';'K_BN10_t2';'K_BN16_t2';'P_FR19_t1';'P_FR05_t1';'P_BN07_t1';'P_FR24_t1';'P_BN14_t1';'P_BN12_t1';'P_BN03_t1';'P_FR11_t1';'P_FR34_t1';'P_BN10_t1';'P_FR21_t1';'P_FR36_t1';'P_BN15_t1';'P_FR18_t1';'P_FR09_t1';'P_FR37_t1';'P_FR19_t2';'P_FR05_t2';'P_BN07_t2';'P_FR24_t2';'P_BN14_t2';'P_BN12_t2';'P_BN03_t2';'P_FR11_t2';'P_FR34_t2';'P_BN10_t2';'P_FR21_t2';'P_FR36_t2';'P_BN15_t2';'P_FR18_t2';'P_FR09_t2';'P_FR37_t2';}; indices = []; for k=1:size(subnam2,1) for l=1:size(subnam,2) if strcmp(subnam2{k},subnam{l})==1 indices=[indices,l]; end end end % subTAG = sort(indices); nsubs = length(subnam); if strcmp(subTAG,'all') dosubs = 1:nsubs; else dosubs = subTAG; end % Find mask files %---------------------------------------------------------------------% cd(maskpath) fprintf('\n\nMASK LIST:\n'); d=dir(maskpattern); for i=1:length(d) voiNAMES{i}=d(i).name; voi_anal_names{i} = voiNAMES{i}(1:end-4); fprintf('\tAdding %s to mask list\n',voiNAMES{i}) end nmasks = length(voiNAMES); domasks = 1:nmasks; %---------------------------------------------------------------------% %---------------------------------------------------------------------% % Begin looping through regions and subjects %---------------------------------------------------------------------% for v=[1]%domasks % v: Anzahl der Seed ROIs für die das PPI-Skript durchgeführt werden soll for i= 3 %dosubs % v: Anzahl der Subjects für die das PPI-Skript durchgeführt werden soll try %%% load conditions condi = spm_select('List',subdir{i},'^SPM.mat'); load(fullfile(subdir{i},condi)) %%% load condition file! conditions = SPM.Sess.U.name(1); % in LA only one "task" the rest are PM modulators %conditions = [SPM.Sess.U.name]; %%% so werden alle Conditions in ein cell geschrieben, auch wenn zuvor in einer Zelle zwei regressoren drinne waren %%%Now add specific Parameters to P structure! cd(gPPIpath) load('parameters.mat') P.subject=subnam{i}; P.VOI.VOI = [maskpath filesep voiNAMES{v}]; P.VOI.masks = masks; P.FLmask = 0; % if 1, then the VOI is masked in each subject with the mask image of ss analysis P.equalroi = 0; % if 1 then ROIs across subjects must all have same size P.VOI.thresh = threshold; P.VOI.min = VOImin; P.VOImin = VOImin; % % % Set a cluster size and find the cluster of that size inside your mask: % P.VOI.VOI % VOI region file (e.g. DMPFC) % P.VOI.exact=1; % tells the program to find a cluster of specified size % P.VOImin % tells the program the cluster size % P.VOI.thresh % threshold for the data -- in actual units (e.g. T-value), same length as masks field % P.VOI.masks % Used to identify the data (e.g. spmT_ images); cell array. % % % Find all voxels above a threshold inside the VOI. % P.VOI.VOI % VOI region file % P.VOI.thresh % threshold for the masks. % P.VOImin % tells the program the cluster size % P.VOI.masks % Used to identify the data (e.g. spmT_ images) % -- Can only use 1 image at a time. Either list one image in a cell array, or list N images where N is the number of sessions. P.Region = [voi_anal_names{v} '_' ppi_folder_affix]; P.SPMver = spmversion; P.directory=subdir{i}; P.method = method; P.Estimate = estimateTAG; P.contrast = fcontrast; P.extract = extract; if strcmp(method,'trad') P.Tasks = conditions; P.Weights = weights; P.Contrasts(1).name = 'PPI'; P.Contrasts(1).left = convec; P.Contrasts(1).right = []; else P.Tasks = ['0' conditions]; end if strcmp(method,'cond') % USER INPUT: Specify your contrasts of interest (Cond PPI only) %--------------------------------------------------------------% P.Contrasts(1).name = 'gain'; P.Contrasts(1).left = {'Task_onxgain^1'}; %left is always bigger than right P.Contrasts(1).right = {''}; P.Contrasts(1).STAT = 'T'; P.Contrasts(1).MinEvents = 5; P.Contrasts(2).name = 'loss'; P.Contrasts(2).left = {'Task_onxloss^1'}; %left is always bigger than right P.Contrasts(2).right = {''}; P.Contrasts(2).STAT = 'T'; P.Contrasts(2).MinEvents = 5; % P.Contrasts(2).name = 'Forms_Baseline'; % P.Contrasts(2).left = {'MatchForms'}; % P.Contrasts(2).right = {''}; % P.Contrasts(2).STAT = 'T'; % P.Contrasts(3).name = 'Faces_vs_Shapes'; % P.Contrasts(3).left = {'MatchFaces'}; % P.Contrasts(3).right = {'MatchForms'}; % P.Contrasts(3).STAT = 'T'; % P.Contrasts(4).name = 'Shapes_vs_Faces'; % P.Contrasts(4).left = {'MatchForms'}; % P.Contrasts(4).right = {'MatchFaces'}; % P.Contrasts(4).STAT = 'T'; %--------------------------------------------------------------% end cd(subdir{i}) spm_jobman('initcfg') PPPI(P) catch MExc disp(['Failed: ' subnam{i}]) end save('gPPI_parameters.mat', 'P'); end end end