-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStart_Analysis.m
More file actions
138 lines (105 loc) · 4.68 KB
/
Copy pathStart_Analysis.m
File metadata and controls
138 lines (105 loc) · 4.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
% start script and follow prompts in command window
clear
clc
addpath(genpath('Code'));
addpath(genpath('Data'));
% spm_path = '/scratch/monikag/Toolboxes/spm8'; % insert your path to the SPM toolbox here. Only needed for searchlight analysis
%% set parameters for EEG time-resolved and time-generalization analysis
steps = 10; % downsample EEG data to 10 ms for speed. Set steps=1 for full 1 ms temporal resolution.
permutations = 5; % 5 permutations for speed. This gives a close approximation to the result with full 100 permutations (used in paper).
%% set parameters for ROI analysis
subs = 25;
nROIs = 9;
BG = 3;
ROIs = nan(subs,nROIs*BG);
sbj = 25; % example subject for EEG analyses
%% Durations
% Durations time-resolved analyses (example subject):
% 5 permutations downsampled to 10 ms resolution takes ~37 seconds (fast parameters).
% 100 permutations with 1 ms resulution takes ~2 hours (original parameters).
% Durations time-generalization (example subject):
% 5 permutations downsampled to 10 ms resolution takes ~4 minutes (fast parameters).
% 100 permutations downsampled to 10 ms takes ~85 minutes (original parameters).
% Duration ROI analysis (all subjects):
% ~ 2 minutes
%% prompt user input
disp('This is a quick demo of the analyses for a representative single subject for speed (EEG) or the entire dataset (ROI).')
disp('Please bear in mind that single subject data is noisier than the group averaged result.')
disp('The result can vary slightly from time to time due to random assignment of trials to bins for training and testing set.')
task = input(' \n Would you like to see results for location (1) or category classification (2)?');
if task~=1 & task~=2
error('Please press 1 for location or 2 for category.')
end
analysis=input('Which analysis would you like to run?\n Press \n 1 for ROI \n 2 for timecourse \n 3 for time-generalization \n');
%% run selected analysis
if task ==1 % location analyses
if analysis==1 % ROI
% run ROI analysis
for isub = 1:subs
result = Location_ROI(isub);
result = result';
ROIs(isub,:) = result(:); clear result
end
% test for significance above chance and plot
alpha = 0.05;
for itest = 1:size(ROIs,2)
[p_rois(itest), h(itest)] = signrank(ROIs(:,itest));
end
[mask, crit_p, adj_ci_cvrg, adj_p] = fdr_bh(p_rois,alpha,'pdep');
plot_ROI(ROIs,task,mask);
elseif analysis==2 % timecourse
Location_Time_Resolved(steps,permutations,sbj);
plot_timecourse(sbj,task);
elseif analysis==3 % time-generalization
Location_Time_Generalization(steps,permutations,sbj);
plot_time_generalization(sbj,task);
else
error('Please press 1=ROI,2=timecourse or 3=time-generalization.')
end
else % category analyses
if analysis==1 % ROI
% run ROI analysis
for isub = 1:subs
result = Category_ROI(isub);
result = result';
ROIs(isub,:) = result(:); clear result
end
% test for significance above chance and plot
alpha = 0.05;
for itest = 1:size(ROIs,2)
[p_rois(itest), h(itest)] = signrank(ROIs(:,itest));
end
[mask, crit_p, adj_ci_cvrg, adj_p] = fdr_bh(p_rois,alpha,'pdep');
plot_ROI(ROIs,task,mask);
elseif analysis==2 % timecourse
Category_Time_Resolved(steps,permutations,sbj);
plot_timecourse(sbj,task);
elseif analysis==3 % time-generalization
Category_Time_Generalization(steps,permutations,sbj);
plot_time_generalization(sbj,task);
else
error('Please press 1=ROI,2=timecourse or 3=time-generalization.')
end
end
%% Optional: Searchlight analysis (~16 hours, 2 GB memory)
% You also have the option to run the searchlight classification analysis
% of object location across categories. This analysis takes ~16 hours per
% background condition.
% to run this analysis uncomment the following 3 lines:
% addpath(genpath(spm_path));
% iBG = 1; % 1= no, 2= low, 3= high clutter
% subject = 1;
% Location_Searchlight(subject,iBG);
%
% to plot the result uncomment and run this line:
%
% plot_searchlight(1,iBG);
%% Optional: DNN analysis (~40 minutes with 5 permutations)
% You also have the option to run the DNN classification analysis
% of object location across categories. This analysis takes ~10 minutes per layer with 5 permutations.
% to run this analysis uncomment the following lines:
% permutations = 5;
% for ilayer = 1:4 % 1=V1,2=V2,3=V4,4=IT
% Location_DNN(permutations,ilayer);
% end
% plot_DNN;