Attachment 'showAAResults.m'
Download 1 % Command-line based SPM results display for AA results.
2 % showAAResults(aadir,subjectn,contrast,correction,threshold)
3 % Where
4 % aadir - directory where aap_parameters.mat may be found
5 % subjectn - I for subject in aap
6 % contrast - I for contrast in subject's SPM.mat
7 % correction - 'none','FWE','FDR'
8 % threshold - p/t value
9 % All arguments are optional. Try leaving one out (or make it [])
10 % and see what happens. In particular, leaving out subjectn or
11 % contrastn brings up reference lists of indices for these.
12 % 16/1/2011 J Carlin
13 % 18/2/2011 Updated for SPM8 compatibility
14
15 function showAAResults(aadir,subjectn,contrastn,correction,threshold)
16
17 % If you tell us no dir, assume we're already there
18 if ~exist('aadir','var') || isempty(aadir)
19 fprintf('No aadir defined - assume it''s pwd\n')
20 aadir = pwd;
21 end
22
23 load(fullfile(aadir,'aap_parameters.mat'))
24
25
26 % --- PARAMETER TO CHANGE --- %
27 %addpath /Users/johan/code/UtilityScripts/BatchPrintSPMs %Change to where this is saved
28
29 subjroot = aadir;
30 ana_dir = aap.directory_conventions.stats_singlesubj;
31
32 def = '';
33 if ~exist('correction','var') || isempty(correction)
34 correction = 'none';
35 def = 'default ';
36 end
37 fprintf('Using %scorrection: %s', def,correction);
38
39 def = '';
40 if ~exist('threshold','var') || isempty(threshold)
41 threshold = 0.001;
42 def = 'default ';
43 end
44 fprintf(', %sp<%.03f\n', def, threshold)
45
46 % TODO - second level analysis
47
48 % Get subject paths
49 for s = 1:length(aap.acq_details.subjects)
50 subjpaths{s} = aas_getsubjpath(aap,s);
51 end
52
53 % Test if we need to return a list.
54 simpletest = @(x) ~exist(x) || isempty(eval(x)) || strcmp(eval(x),'list');
55
56 % Return a list of subjects, with indices
57 if simpletest('subjectn')
58 subjlist = [num2str((1:length(subjpaths))','%03d') repmat(' ',length(subjpaths),1) char(subjpaths)];
59 fprintf('Must define a subject (by its index):\n')
60 display(subjlist)
61 return
62 end
63
64 % Get contrasts for this subject
65 spmpath = fullfile(subjpaths{subjectn},ana_dir,'SPM.mat');
66
67 if simpletest('contrastn')
68 load(spmpath);
69 contrastnames = {SPM.xCon.name};
70 contrastlist = [num2str((1:length(contrastnames))','%03d') repmat(' ',length(contrastnames),1) char(contrastnames)];
71 fprintf('Must define a contrast (by its index):\n')
72 display(contrastlist)
73 return
74 end
75
76 % Now using SPM8 batch functionality
77 matlabbatch{1}.spm.stats.results.spmmat = cellstr(spmpath);
78 matlabbatch{1}.spm.stats.results.conspec.titlestr = '';
79 matlabbatch{1}.spm.stats.results.conspec.contrasts = contrastn;
80 matlabbatch{1}.spm.stats.results.conspec.threshdesc = correction;
81 matlabbatch{1}.spm.stats.results.conspec.thresh = threshold;
82 matlabbatch{1}.spm.stats.results.conspec.extent = 0;
83 matlabbatch{1}.spm.stats.results.conspec.mask = struct('contrasts', {}, ...
84 'thresh', {}, 'mtype', {});
85 matlabbatch{1}.spm.stats.results.units = 1;
86 matlabbatch{1}.spm.stats.results.print = false;
87
88 spm('defaults','FMRI');
89 spm_jobman('serial',matlabbatch);
90 return
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.