-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcorrcoef_filt_meanHIST.m
59 lines (59 loc) · 2.29 KB
/
corrcoef_filt_meanHIST.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
51
52
53
54
55
56
57
58
59
format long
oo=1; c_signal_name = cell(1,1);
c_signal_name{1} = 'Lozeron130919';
c_signal_name{2} = 'Lozeron08092016';
c_signal_name{3} = 'Milani08092106';
c_signal_name{4} = 'Milani150916';
signal_name = c_signal_name{oo};
[st_Header, m_SignalsMat] = edfread([signal_name,'.edf']); % a=rand(1,10000); b=filtfilt(SOS, G, a); figure;plot(b)
str_corrcoef = struct;
v_delay = 0:60;
for kk = 1:6%%%%%%%%%%%%%%%%%%%%%%
mean_AB_cc = zeros(1,length(v_delay));
mean_BA_cc = zeros(1,length(v_delay));
time_mean_cc = zeros(1,length(v_delay));
k_1 = kk; %signal EEG
k_2 = 8; %signal EMG
Fs = st_Header.samples(k_1);
t = 0:1/Fs:1-1/Fs; %Time
load('G.mat'), load('SOS.mat')
x_raw = m_SignalsMat(k_1,:);
x = filtfilt(SOS, G, x_raw);
y_raw = m_SignalsMat(k_2,:);
y = filtfilt(SOS, G, y_raw);
load([signal_name,'.mat']);
lab = st_Header.label(kk);
c_cc_AB = cell(1,1); c_cc_BA = cell(1,1); equal_cc = cell(1,1);
cc_hist = cell(1,1);
for kkk = 1:length(v_delay)%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
cc_AB_CM = zeros(1, length(v_TimeStartEvts));
cc_BA_CM = zeros(1, length(v_TimeStartEvts));
for k = 1:length(v_TimeStartEvts)
t1 = (v_TimeStartEvts(k)*Fs)+(Fs*0.5);%-(Fs*2);
t2 = t1+Fs*1.5;
t3 = (v_TimeStartEvts(k)*Fs)-(Fs*2)+(v_delay(kkk)*25);
t4 = t3+Fs*1.5;
R = corrcoef(x(t1:t2),y(t3:t4)); %Corrcoef
cc_AB_CM(k) = abs(R(3));
cc_BA_CM(k) = abs(R(2));
end
c_cc_AB{kkk} = cc_AB_CM;
c_cc_BA{kkk} = cc_AB_CM;
equal_cc{kkk} = cc_AB_CM==cc_BA_CM;
h1 = histogram(cc_AB_CM,20);
cc_hist{kkk} = h1;
time_mean_cc(kkk) = v_delay(kkk)*25/256;
mean_AB_cc(kkk) = mean(cc_AB_CM);
mean_BA_cc(kkk) = mean(cc_BA_CM);
end
str_corrcoef(kk).name = lab{1};
str_corrcoef(kk).cc_AB = c_cc_AB;
str_corrcoef(kk).cc_BA = c_cc_BA;
str_corrcoef(kk).equals_cc = equal_cc;
str_corrcoef(kk).AB_hists = cc_hist;
str_corrcoef(kk).mean_AB_cc = mean_AB_cc;
str_corrcoef(kk).mean_BA_cc = mean_BA_cc;
str_corrcoef(kk).time_means = time_mean_cc;
str_corrcoef(kk).static = 'EEG_contraction';
end
save(['./seminario5_corrcoef/hists_1v2/',signal_name,'_cc_signal',num2str(k_2),'_1-',num2str(kk),'.mat'], 'str_corrcoef')