-
Notifications
You must be signed in to change notification settings - Fork 1
/
create_table.m~
75 lines (54 loc) · 1.7 KB
/
create_table.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
% Organize data in a table format
%% vehicle
Rats=fieldnames(VEH);
StudyDays=fieldnames(VEH.(Rats{1}));
TrialNames={'Presleep','Post1','Post2','Post3','Post4','Post5-1','Post5-2','Post5-3','Post5-4'};
veh=[];
Treatment={'VEH','RGS14'};
for i=1:length(Rats)
for j=1:length(StudyDays)
Trials=VEH.(Rats{i}).(StudyDays{j});
Rat=(Rats{i});
StudyDay=StudyDays{j};
for k=1:length(Trials)
t=table(Treatment(1),{Rat},{StudyDay},{TrialNames{k}},Trials(k));
veh=[veh;t];
end
end
end
veh.Properties.VariableNames=[ {'Treatment'} {'Rat'} {'StudyDay'} {'Trial'} {'Ripples'}];
%% rgs14
Rats=fieldnames(RGS);
StudyDays=fieldnames(RGS.(Rats{1}));
TrialNames={'Presleep','Post1','Post2','Post3','Post4','Post5-1','Post5-2','Post5-3','Post5-4'};
rgs=[];
Treatment={'VEH','RGS14'};
for i=1:length(Rats)
for j=1:length(StudyDays)
Trials=RGS.(Rats{i}).(StudyDays{j});
Rat=(Rats{i});
StudyDay=StudyDays{j};
for k=1:length(Trials)
t=table(Treatment(2),{Rat},{StudyDay},{TrialNames{k}},Trials(k));
rgs=[rgs;t];
end
end
end
rgs.Properties.VariableNames=[ {'Treatment'} {'Rat'} {'StudyDay'} {'Trial'} {'Ripples'}];
%%
T=[veh;rgs];
%% Compute/add features
%% Amplitude
ripple_amp=cellfun(@(x) max(abs(hilbert(x.'))) ,T.Ripples,'UniformOutput',false);
T=[T ripple_amp];
T.Properties.VariableNames(6)={'Amplitude'};
%%
%% Mean Freq
[ripple_meanfreq]=cellfun(@(x) (compute_meanfreq(x)) ,T.Ripples,'UniformOutput',false);
%%
for j=1:length(T.Ripples)
compute_meanfreq(T.Ripples{j});
end
%%
T=[T ripple_meanfreq];
T.Properties.VariableNames(6)={'Mean frequency'};