-
Notifications
You must be signed in to change notification settings - Fork 14
/
rastplotstat.m
50 lines (43 loc) · 1.72 KB
/
rastplotstat.m
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
function [h, p, sign] = rastplotstat(rasters,fsigma,twind_one,twin_two,plotwind)
%raster averaging, stat test on two regions and plot
convrasters_one=NaN(size(rasters,1),diff(twind_one)+1); %kernel's linear space is 6 sigma
for rast=1:size(rasters,1)
convrasters_one(rast,:)=fullgauss_filtconv(rasters(rast,twind_one(1):twind_one(2)),fsigma,0);
end
% convrasters_one=convrasters_one(:,3*fsigma+1:end-3*fsigma);
convrasters_one=nanmean(convrasters_one).*1000;
convrasters_two=NaN(size(rasters,1),diff(twin_two)+1);
for rast=1:size(rasters,1)
convrasters_two(rast,:)=fullgauss_filtconv(rasters(rast,twin_two(1):twin_two(2)),fsigma,0);
end
% convrasters_two=convrasters_two(:,3*fsigma+1:end-3*fsigma);
convrasters_two=nanmean(convrasters_two).*1000;
[sign, ~, p] = statcond({convrasters_one convrasters_two}, 'method', 'perm', 'naccu', 20000);
h=p<0.01;
% [p, h] = signrank(convrasters_one, convrasters_two)
% [p, pvals]
% sign=mean(convrasters_one-convrasters_two);
%% full raster
% convrasters_all=NaN(size(rasters,1),size(rasters,2)-2*(3*fsigma)+1);
% for rast=1:size(rasters,1)
% convrasters_all(rast,:)=fullgauss_filtconv(rasters(rast,3*fsigma:size(rasters,2)-3*fsigma),fsigma,0);
% end
% convrasters_all=convrasters_all(:,3*fsigma+1:end-3*fsigma);
% convrasters_all=nanmean(convrasters_all).*1000;
% figure
% plot(convrasters_all)
%% plots
if plotwind
figure;
plot([1:length(convrasters_one)],convrasters_one,'b');
hold on;
plot([length(convrasters_one)+2:(length(convrasters_one)+1+length(convrasters_two))],convrasters_two,'r');
hold off;
ylim=get(gca,'ylim');
set(gca,'ylim',[0 ylim(2)+1]);
if h
text(5,3,['sign = ' num2str(sign)])
end
legend('pre','post','location','SouthEast');
end
end