-
Notifications
You must be signed in to change notification settings - Fork 0
/
anova_f.m
56 lines (51 loc) · 1.77 KB
/
anova_f.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
function [donneesoxy, condition, sujet, F, h_matrix] = anova_f(avg,nbabies,nt,nch);
%construction de la matrice de données
donneesoxy=zeros(nbabies,3,nt,nch);
for bb=1:nbabies
for cond = 'NCD'
for t=1:nt
for ch=1:nch
if cond == 'N'
donneesoxy(bb,1,t,ch)=avg(bb).(cond)(t,ch,1);
elseif cond == 'C'
donneesoxy(bb,2,t,ch)=avg(bb).(cond)(t,ch,1);
elseif cond == 'D'
donneesoxy(bb,3,t,ch)=avg(bb).(cond)(t,ch,1);
end
end
end
end
end
%on remplit les vecteurs condition et sujet qui indiqueront la condition et le sujet dans le tableau de
%données
condition=repmat(['N','C','D']',nbabies,1);
sujet=reshape(repmat([1:nbabies],3,1),[],1);
%on remplace les valeurs manquantes par la moyenne (echantillon-condition-canal)
%pour pouvoir obtenir plus tard le F de Fisher.
for ch=1:nch
for cond=1:3
for t=1:nt
ech=donneesoxy(:,cond,t,ch);
nan=isnan(ech);
ech(nan)=nanmean(ech);
donneesoxy(:,cond,t,ch)=ech;
end
end
end
clear('ech')
%on remplit la variable vd qui contiendra les concentrations en hb (vecteur
%colonne avec les conditions l'une après l'autre). Refait à chaque échantillon-canal.
%seuil=3.34; %définition libre, en fonction de la distribution du F ou pas.
F=cell(nch,nt);
for ch=1:nch
for t=1:nt
vd=reshape(donneesoxy(:,:,t,ch)',[],1);
[p, table]=anovan(vd,{sujet condition},'random',1,'sstype',3,'model',3,'display','off');
F(ch,t)=table(3,6);
p_values (ch,t) = p(2);
end
end
F = cell2mat(F); %Matrice des valeurs de F par canal et par échantillon temporel
h_matrix = zeros(ch,t);
sig=find(p_values <= 0.05);
h_matrix(sig)=1;