forked from Shlomit-Beker/Anticipatory-activity-in-ASD
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSCP.m
More file actions
55 lines (43 loc) · 1.59 KB
/
SCP.m
File metadata and controls
55 lines (43 loc) · 1.59 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
% datamatrix1 and datamatrix2 in this case are [subjects x time x electrodes] for each condition
% Shlomit Beker 2017 (following a version from the CNL)
function ST = SCP(datamatrix,newChansInds, figurenum, time,a,sigVals)
datamatrix1 = datamatrix{1};
datamatrix2 = datamatrix{2};
% Initial parameters
alpha_level = 0.05;
numconsectime = 2; %number of consecutive time points required
numconsecchan = 2; %number of consecutive channels required
No_of_Electrodes = 64; %number of electrodes
% Run through all the t-tests
for q = 1:length(datamatrix1(1,:,1)) %this loops through each time point
for r = 1:length(datamatrix1(1,1,:)) % this loops through each electrode
[H(q,r) P(q,r) C D(q,r)]=ttest2(datamatrix1(:,q,r),datamatrix2(:,q,r));
t_val(q,r) = D(q,r).tstat;
end
end
% Threshold t-stat values
[P_val T_val]=SCP_THRESHOLD(squeeze(P)',t_val',alpha_level,numconsectime,numconsecchan);
% Reorder the channels to an anatomical order
newT_val = T_val(newChansInds,:);
newsigVals = sigVals(newChansInds,:);
% Make the figure
sigImage = zeros(64,308);
sigImage(newsigVals) = newT_val(newsigVals);
figure;
imagesc(time,[1:No_of_Electrodes],sigImage);
% cmap = jet;
% cmap(end,:) = 1;
caxis([-5 5]);
colormap(bluewhitered(256)), colorbar
hold on;
imagesc(time,[1:No_of_Electrodes],squeeze(newT_val),'AlphaData',0.3);
colormap(bluewhitered(256)), colorbar
caxis([-5 5]);
colorbar;
ylabel('Electrode index')
xlabel('Time (ms)');
y1=get(gca,'ylim');
mini = min(abs(time));
hold on;
plot([mini mini],y1,'--k');
set(gca,'fontsize', 12);