gPPI: Tutorial on first and second level analysis using MATLAB and SPM8

gPPI: Tutorial on first and second level analysis using MATLAB and SPM8
paly

This tutorial by Donald G. McLaren PhD provides an overview of gPPI analysis, including first and second level analysis using MATLAB, SPM8, and PPPI. It covers topics such as clustering and labeling peaks, plotting results, and peak extract nii. It also discusses MATLAB basics such as variable names, try statements, and working with 4D data and Nifti files.

About gPPI: Tutorial on first and second level analysis using MATLAB and SPM8

PowerPoint presentation about 'gPPI: Tutorial on first and second level analysis using MATLAB and SPM8'. This presentation describes the topic on This tutorial by Donald G. McLaren PhD provides an overview of gPPI analysis, including first and second level analysis using MATLAB, SPM8, and PPPI. It covers topics such as clustering and labeling peaks, plotting results, and peak extract nii. It also discusses MATLAB basics such as variable names, try statements, and working with 4D data and Nifti files.. The key topics included in this slideshow are gPPI, MATLAB, SPM8, first level analysis, second level analysis, PPPI, clustering, plotting, peak extract, Nifti files,. Download this presentation absolutely free.

Presentation Transcript


1. gPPI: The Tutorial Donald G. McLaren, PhD Department of Neurology, MGH/HMS GRECC, ENRM Veterans Hospital 04/12/2013

2. Financial Disclosures None.

3. Overview MATLAB SPM8 gPPI (first level analysis -- PPPI) gPPI (second level analysis SPM/GLM Flex) Clustering and labeling peaks (peak_nii) Plotting results (peak_extract_nii)

5. MATLAB Basics Column Major (rows then columns) * versus .* (. Can be used with many functions) (),[],{} Strings versus numbers versus arrays versus structures Variable Names are: a, a1, a3 not a(1) a(2) a{2} = versus == try statements for loops 4D data versus 2D processing SPM Nifti files

6. Launch MATLAB

7. Prepare To Use SPM8 Add SPM8 to the MATLAB path addpath(/Applications/MATLAB_SV74/toolbox/spm8) Add available scripts to the MATLAB path addpath /Applications/MATLAB_SV74/toolbox/spm8/toolbox/PPPI addpath /Applications/MATLAB_SV74/toolbox/spm8/toolbox/OrthoView spm fmri would launch spm now.

8. The SPM.mat SPM.xX .X -- The design matrix .name Labels for each column of the design matrix SPM.xY .P The input files .xY The headers of the input files, modified pinfo SPM.xBF Information about the HRF SPM.xCon Information about the contrasts SPM.Sess Information about event timings

9. Steps for gPPI 1. First Level SPM Model of Task Activity 2. Identify and create a seed region 3. Create a parameter file 4. Run PPPI, will do: - Create PPI regressors - Estimate PPI model - Create PPI contrasts for group analysis 5. Create a wrapper for multiple regions/subjects 6. Run the wrapper

10. Implementation MATLAB/SPM (for gPPI)

11. Class Dataset Testing gPPI Does running_gPPI_generic run properly? This will determine if gPPI is installed correctly and your Matlab search path is setup correctly.

12. Step 1: First-Level Model Hopefully you already have the first level task activity model completed as PPI is a secondary analysis of the data.

13. Step 2: The Seed Region VOI Button create_sphere_image create_sphere_image(SPMmatfile,spherecenter,{ VOIname},radius) create_sphere_image('/Users/mclaren/Download s/glm_ppi_analysis/attention/GLM/SPM.mat',[15 - 78 -9],{'VOI_V2c_15_-78_-9'},6)

14. Step 3: Creating the Parameter File This is a file that stores the parameters of PPI

15. parameter fields (required) subject -- A string with the subject number. directory -- Either a string with the path to the first-level SPM.mat directory, or if you are only estimating a PPI model, then path to the the first-level PPI directory. VOI -- Either a string with a filename and path OR a structure variable defining the seed region Region -- A string containing the basename of output file(s), if doing physiophysiological interaction, then two names separated by a space are needed. analysis -- Specifies psychophysiological interaction ('psy'); physiophysiological interaction('phys'); or psychophysiophysiological interactions ('psyphy). This is a string. method -- Specifies traditional SPM PPI ('trad') or generalized context- dependent PPI ('cond'). This is a string.

16. parameter fields (optional) contrast -- Contrast to adjust for. Adjustments remove the effect of the null space of the contrast. Set to 0 for no adjustment. Set to a number, if you know the contrast number. Set to a contrast name, if you know the name. The default is: 'Omnibus F-test for PPI Analyses. extract -- Specifies the method of ROI extraction, eigenvariate ('eig') or mean ('mean'). The default is: eig. equalroi -- Specifies the ROIs must be the same size in all subjects. This is a number. The default is1 (true) . Use 0 to lift the restriction. FLmask -- Specifies that the ROI should be restricted using the mask.img from the first- level statistics. This is a number. The default is 0. VOI2 -- Either a string with a filename and path OR a structure variable defining the second seed region for physiophysiological interactions. outdir This is the name of the output directory if you want to store the PPI analysis in a different location than the first-level SPM.mat file. maskdir location to store VOI file if input VOI was a mat-file.

17. parameter fields Weighted -- Default is not to weight tasks by number of trials (0); to change this, specify which tasks should be weighted by trials. If you want to weight trials, then specify a duration longer than your events. If you have a mixed block event related design, then you can average your events based on number of trials and the blocks won't be averaged if Weighted is set to be a number that is shorter than the block duration and longer than your events. This is a number. GroupDir This is the location you want to copy the con_ files to for easier group analyses. ConcatR Under development, but can be used to concat sessions to reduce collineaity between task and PPI regressors. preservevarcorr preserves the variance correction estimated from the first level model. This will save time and also means all regions will have the same correction applied. correct -- Set by the program to 1 if it has passed error checking.

18. parameter fields Tasks -- In the generalized context-dependent PPI, you need specify the tasks to include in the analyses, but put a 0 or 1 in front of them to specify if they must exist in all sessions. For the traditional approach the task must appear in all runs, thus no number is needed. For the traditional approach, the task order must match the order of the weights. For the conditional approach the task has to occur in at least 1 run, which is why you have the option. The default is that it does not have to occur in each run. This is a cell array. Weights -- For traditional PPI, you must specify weight vector for each task. This is a row vector. Estimate -- Specifies whether or not to estimate the PPI design. 1 means to estimate the design, 2 means to estimate the design from already created regressors (must be of the OUT structure), 0 means not to estimate. This is a number. Default is set to 1, so it will estimate.

19. parameter fields CompContrasts -- 0 not to estimate any contrasts; 1 to estimate contrasts; 2 to only use PPI txt file for 1st level (not recommended); 3 to only use PPI txt file for 1st level and estimate contrasts (not recommended); 2&3 are not recommended as they potentially do not include all tasks effects in the mode. Use them at your own risk. 3 cannot weight the contrasts based on the number of trials. Default is 0. This is a number. 1 is the most common setting. Contrasts -- A cell array of tasks to create contrasts to evaluate OR it is a structure variable. If left blank and CompContrasts=1, then it defines all possible T contrasts for task components and across runs. This is only feasible with less than four tasks.

20. Contrasts

21. Contrasts fields left -- A cell array with tasks on left side of equation or 'none'** right -- A cell array with tasks on right side of equation or 'none Weighted -- From Weighted above, default is 0. This is a number. STAT -- A string that is either: 'T' or 'F c -- A contrast vector from createVec. This will be generated automatically. name -- Name of the contrast, will be defined from left and right fields if left blank. If not left blank, then this is a string. Prefix -- Prefix to the task name (optional), can be used to select each run. This is a string. Contrail -- Suffix after task name (e.g. parametric modulators, different basis function). This is a string. MinEvents -- The minimum number of events needed to compute the contrast. This is required. This is a number. MinEventsPer -- The minimum number of events per task needed to compute the contrast. This is a number. Default is MinEvents/NumberOfTasks.

22. VOI Structure VOI -- Filename and path of the VOI file ('.nii', '.img') masks -- A cell array of statistic images ('.nii', '.img') to threshold to define subject specific ROI. Must be NxM array, where N is either 1 or the number of sessions and M is the number of statistical images to use to define subject specific ROI. thresh -- An NxM matrix of thresholds (e.g. use []) where N is either 1 or the number of sessions and M is the number of statistical images to threshold; thresholds should be the statistic value (e.g. 3) and not the significance (e.g. .05). These correspond to the images in the masks field up with the image names in the masks field. exact -- If set to 1, will find a cluster of size VOImin. The default is 0. This is a number. If set to 1, then peak_nii.m must be in the MATLAB path. VOImin -- The minimum VOI size required. This is a number.

23. Lets Open MATLAB: Create Parameter file

24. Step 4: Running PPPI PPPI(parameterfile) PPPI(parameterfile,structurefile) PPPI(parameterfile,structurefile,tsdata) PPPI(parameterfile,[],tsdata)

25. Step 5: Creating a Wrapper

26. Automation ppi_R01_v1(1,1,60) Preconfigured file with ROI list and subject list Can add regions or subjects at anytime Uses a master template of gPPI settings, which are study specific (matlab structure with ~15 fields) Output is con_ and spmT_ images for group level analyses Tutorial and manuals are available online

27. Lets automate the process

28. By creating a wrapper %Setup the PPPI Toolbox addpath(PPPIdirectory) %Replace PPPIdirectory with the location of the PPPI directory that was downloaded %Setup SPM8 addpath('spm8directory') %Replace spm8directory with the location of spm8 (can be found by typing which spm) %Select the subjects Subjects={'subject1' 'subject2'}; %Put your subjects in inside the {}. This is a cell array. %Set the VOI regionfile={'region1.nii'... 'region2.nii'}; %These are the VOIs files (.nii, .img, .mat) with full paths to use for PPI. This is a cell array. %Set the region names region={'region1'... 'region2'}; %These are the VOIs names. They must match the order of the VOIs in the regionfile variable. This is a cell array.

29. %Load PPI parameters that dont change between regions or subjects (e.g. a master parameter file) load('ppi_master_template.mat'); %Replace ppi_master_template.mat with the name of your master parameter file. If you have not made one yet, save this m-file and make your master parameter file now. %Set the location to save the region specific mat-files save(['directory' region{regionnumber} '.mat'],'P'); %Replace directory with the location you want to save the parameter structure that has the region and VOI information added to it. %Make a loop first subjects, then regions for ii=1:numel(subjects) For jj=1:numel(regions) %Set the subject directory Directory=['subjectdirectory']; %Replace subjectdirectory with the location of 1st level statistics. Can include variables (e.g. [/Data/ Subjects{i} /model/]) %Set the parameter file to be loaded for PPI analysis load(['directory' region{regionnumber} '.mat']); %must match the location where you saved the file above. %Set an identifier for this analysis save([Subjects{i} '_analysis_' region{regionnumber} '.mat'],'P'); PPPI([Subjects{i} '_analysis_' region{regionnumber} '.mat']); %Replace analysis with an identifier that you can use to identify what you did for this PPI analysis. end end

31. Class Dataset Is there any psychophysiological interactions with repetion or familiarity with the posterior cingulate cortex? Repetition Dataset Sphere centered at [0 -28 37]

32. GLM_Flex

33. Analysis Package Differences

34. Finding Clusters and Peaks [voxels XX XX regions mapparameters UID] =peak_nii(myimage.nii,mapparameters) UID - - This was added to allow the user to add a unique ID to the analysis. If this field is not specified, then the default will be a timestamp (e.g. _20111108T150137). To avoid the using a timestamp, set this field to . sign -- This can either be pos or neg. This specifies the direction of the contrast to test. If not specified, the program will default to pos. NOTE: F-contrasts can only be positive. thresh -- This specifies the voxel threshold for finding clusters. This is only optional because the program will default to a value of 0. The threshold has to be a number and can either be the T/F statistic, a p-value, or any other number. This should almost always be specified. type -- This specifies the statistic type, 'T', 'F', Z, or 'none'. cluster -- This specifies the minimum cluster size required to keep a cluster in the results. The default is 0. This is BAD!!!. df1 --The numerator degrees of freedom for T/F-test df2 --The denominator degrees of freedom for F-test. label-- This specifies which labeling scheme to use.

35. Results Table Cluster Size Peak T-statistic Peak X,Y,Z Region 256 4.5923 18,56,6 R. Superior Frontal Gyrus 3.1503 26,44,2 R. Middle Frontal Gyrus 145 3.4918 26,-32,40 R. Postcentral Gyrus 594 3.4741 40,-56,-20 R. Fusiform 3.4027 20,-84,-16 R. Cerebellum 2.9215 32,-68,-18 R. Fusiform 2.5887 16,-96,-6 R. Calcarine Sulcus 149 3.4199 18,-8,52 R. Supplemental Motor Area 3.0916 22,-16,62 R. Precentral Gyrus 211 3.3672 -2,-8,62 L. Supplemental Motor Area 113 3.341 -14,28,26 L. Anterior Cingulate 288 3.3201 30,14,26 R. Inferior Frontal Gyrus - Pars Triangularis 3.0813 34,22,22 R. Middle Frontal Gyrus 3.0031 18,20,18 R. Caudate 2.4654 20,30,16 R. Anterior Cingulate Cortex 109 3.2134 -22,-84,-12 L. Fusiform 60 3.1279 4,-20,14 R. Thalamus 184 3.0597 -32,-18,44 L. Precentral Gyrus 3.0011 -30,-20,60 L. Precentral Gyrus 2.9813 -18,-16,64 L. Paracentral Lobule 221 3.01 48,-76,10 R. Middle Temporal Gyrus 3.0074 40,-72,12 R. Middle Occipital Gyrus 2.6437 28,-68,22 R. Superior Occipital Gyrus 67 2.9583 30,-88,16 R. Middle Occipital Gyrus 61 2.9485 44,-30,-6 R. Superior Temporal Gyrus 139 2.8433 28,-48,40 R. Angular Gyrus

36. peak_extract_nii [resultsvoxels columnlistvoxels resultscluster columnlistcluster clusters mapparams subjparams UID] = peak_extract_nii(subjectparameters,mappara meters) [resultsvoxels columnlistvoxels resultscluster columnlistcluster clusters mapparams subjparams UID] = peak_extract_nii([],mapparameters)

37. Acknowledgements Harvard Aging Brain Project Dr. Reisa Sperling Dr. Alireza Atri Dr. Aaron Schultz Aishwarya Sreenivasan Andrew Ward Dr. Koene Van Dijk Dr. Willem Huijbers Dr. Dorene Rentz Dr. Trey Hedden Dr. Darren Gitelman Justin Vincent Dr. Bob Spunt Wisconsin Alzheimers Disease Research Center Imaging Core (Dr. Sterling Johnson, Dr. Michele Ries, Dr. Guofan Xu, Elisa Canu, Erik Kastman) Dr. Mark Sager Dr. Sanjay Asthana