-
Notifications
You must be signed in to change notification settings - Fork 0
/
analysis_HR.asv
268 lines (234 loc) · 12.6 KB
/
analysis_HR.asv
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
function analysis_HR(dfl_c,dfw_c, treatlabels, varargin)
% Flags for varargin:
% Cave, confusing nomenclature:
% mean_CPT_HR_mean_pre[*CPT*]_post[*treatment*] --> "average heart rate before CPT, after treatment"
% 'singlecurves': Will create a plot of all CPT rating curves
% 'averagecurves': Will create a plot of averaged CPT rating curves
% Show all HR variables: dfw_c.Properties.VariableNames(startsWith(dfw_c.Properties.VariableNames,'CPT_HR','IgnoreCase',true))'
treatcolors={[0,0,0],[0.6,0.6,0.6],[0,0.3,0.7],[0.7,0,0.3]};
dfw_c.maxtimers =(dfw_c.maxtime_pre>179) & (dfw_c.maxtime_post>179);
dfw_c.CPT_HR_max_change_from_BL_pre= dfw_c.CPT_HR_max_pre-dfw_c.CPT_HR_mean_pre_pre;
dfw_c.CPT_HR_max_change_from_BL_post= dfw_c.CPT_HR_max_post-dfw_c.CPT_HR_mean_pre_post;
dfw_c.CPT_HR_mean_change_from_BL_pre=dfw_c.CPT_HR_mean_pre-dfw_c.CPT_HR_mean_pre_pre;
dfw_c.CPT_HR_mean_change_from_BL_post=dfw_c.CPT_HR_mean_post-dfw_c.CPT_HR_mean_pre_post;
dfw_c.valid_HR = ~isnan(dfw_c.CPT_HR_mean_diff);
dfw_c.valid_HR_complete_CPT = dfw_c.maxtimers & ~isnan(dfw_c.CPT_HR_mean_diff);
demovars={'study','treat',...
'valid_HR'};
grpstats(dfw_c(:,demovars),{'study','treat'},{'sum'})
% LIMIT ANALYSIS TO valid HR recordings
dfw_c=dfw_c(dfw_c.valid_HR,:);
CPT_vars={'treat',...
'maxtimers',...
'healthy',...
'CPT_HR_mean_pre_pre','CPT_HR_mean_pre_post',...
'CPT_HR_mean_pre','CPT_HR_mean_post',...
'CPT_HR_max_pre','CPT_HR_max_post',...
'CPT_HR_max_perc_BL_pre','CPT_HR_max_perc_BL_post',...
'CPT_HR_max_change_from_BL_pre','CPT_HR_max_change_from_BL_post'};
% GENERAL MEANS: ("HEALTHY" is used as a dummy, as all included participants have that tag)
grpstats(dfw_c(:,CPT_vars(3:end)),'healthy',{'mean','std'})
% QUALITY CHECK 1: ARE EARLY-ABORTERS, MAXTIMERS FUNDAMENTALLY DIFFERENT?
grpstats(dfw_c(:,CPT_vars([2,4:end])),'maxtimers',{'mean','std'})
% GROUP MEANS: TREATMENT EFFECTS (ignoring sub study!!!)
grpstats(dfw_c(:,CPT_vars([1,4:end])),'treat',{'mean','std'})
% Test pre-CPT baseline differences between before and after treatment
[H,P,CI,STATS] =ttest(dfw_c.CPT_HR_mean_pre_pre,...
dfw_c.CPT_HR_mean_pre_post)
%% GLM analysis HR
dfw_c.z_CPT_HR_mean_pre_pre=nanzscore(dfw_c.CPT_HR_mean_pre_pre);
dfw_c.z_CPT_HR_mean_pre_post=nanzscore(dfw_c.CPT_HR_mean_pre_post);
dfw_c.z_CPT_HR_mean_pre=nanzscore(dfw_c.CPT_HR_mean_pre);
dfw_c.z_CPT_HR_mean_post=nanzscore(dfw_c.CPT_HR_mean_post);
dfw_c.z_CPT_HR_mean_perc_BL_pre=nanzscore(dfw_c.CPT_HR_mean_perc_BL_pre);
dfw_c.z_CPT_HR_mean_perc_BL_post=nanzscore(dfw_c.CPT_HR_mean_perc_BL_post);
dfw_c.z_CPT_HR_max_change_from_BL_pre =nanzscore(dfw_c.CPT_HR_max_change_from_BL_pre);
dfw_c.z_CPT_HR_max_change_from_BL_post =nanzscore(dfw_c.CPT_HR_max_change_from_BL_post);
dfw_c.z_CPT_HR_max_pre=nanzscore(dfw_c.CPT_HR_max_pre);
dfw_c.z_CPT_HR_max_post=nanzscore(dfw_c.CPT_HR_max_post);
dfw_c.z_maxtime_pre=nanzscore(dfw_c.maxtime_pre);
dfw_c.z_maxtime_post=nanzscore(dfw_c.maxtime_post);
% dfw_c.z_lab_time_before_pre_treat_CPT=nanzscore(dfw_c.lab_time_before_pre_treat_CPT);
% dfw_c.z_TT_TU=nanzscore(dfw_c.TT_TU);
% GLM1: Sanity check: Are there baseline (pre-CPT, pre-treatment differences
% between treatment groups)
dfw_c.treat_reordered=reordercats(dfw_c.treat,{'0','1','2','3'});
lm_pre_CPT_pre_treat_no_treat_ref=fitlm(dfw_c,...
'CPT_HR_mean_pre_pre~study+treat_reordered',...
'RobustOpts','on')
anova_pre_CPT_pre_treat_no_treat_ref=anova(lm_pre_CPT_pre_treat_no_treat_ref)
partial_eta_sq=anova_pre_CPT_pre_treat_no_treat_ref.SumSq./(anova_pre_CPT_pre_treat_no_treat_ref.SumSq+anova_pre_CPT_pre_treat_no_treat_ref.SumSq('Error'));
model_diagnostics(lm_pre_CPT_pre_treat_no_treat_ref)
% GLM2: Did treatment group (post-treatment!) affect baseline, pre-CPT HR?
lm_pre_CPT_post_treat=fitlm(dfw_c,...
'CPT_HR_mean_pre_post~study+CPT_HR_mean_pre_pre+treat_reordered',...
'RobustOpts','on')
anova_pre_CPT_post_treat_no_treat_ref=anova(lm_pre_CPT_post_treat)
partial_eta_sq=anova_pre_CPT_post_treat_no_treat_ref.SumSq./(anova_pre_CPT_post_treat_no_treat_ref.SumSq+anova_pre_CPT_post_treat_no_treat_ref.SumSq('Error'));
model_diagnostics(lm_pre_CPT_post_treat)
% GLM3a (MAIN): Did treatment group affect post-treatment HR-peak response to CPT?
lm_results_per_protocol=lm_main(dfw_c,'CPT_HR_max_change_from_BL_post~study+CPT_HR_max_change_from_BL_pre');
z_lm_results_per_protocol=lm_main(dfw_c,'z_CPT_HR_max_change_from_BL_post~study+z_CPT_HR_max_change_from_BL_pre');
% ALTERNATIVE ANALYSIS: We could
% GLM3b (MAIN 2): Did treatment group affect post-treatment HR-mean response to CPT?
% lm_results_per_protocol_mean=lm_main(dfw_c,'CPT_HR_mean_change_from_BL_post~study+CPT_HR_mean_change_from_BL_pre');
% z_lm_results_per_protocol_mean=lm_main(dfw_c,'z_CPT_mean_change_from_BL_post~study+z_CPT_mean_change_from_BL_pre');
%
%
% % GLM4 (Follow-up): Did early termination of CPT explain treatment group affect post-treatment HR-peak response to CPT?
% lm_results_per_protocol_maxtimers=lm_main(dfw_c,'CPT_HR_max_change_from_BL_post~study+CPT_HR_max_change_from_BL_pre+maxtimers');
% z_lm_results_per_protocol_maxtimers=lm_main(dfw_c,'z_CPT_HR_max_change_from_BL_post~study+z_CPT_HR_max_change_from_BL_pre+maxtimers');
%% SUPPLEMENT 2a v A: plot FULL, raw HR curves
if any(strcmp(varargin,'singlecurves'))
h_means=cpt_timeplot2(dfl_c.prepost,dfl_c.treat,dfl_c.CPT_HR,80);
hs = findall(gcf,'Type','axes');
xticklabels(hs(5:8),[])
yticklabels(hs([1,2]),[])
title(hs(8),treatlabels(1));
title(hs(7),treatlabels(2));
title(hs(6),treatlabels(3));
title(hs(5),treatlabels(4));
ylabel(hs(4),'Heart rate (bpm)');
ylabel(hs(8),'Heart rate (bpm)');
xlabel(hs(1),'Time (s)');
xlabel(hs(2),'Time (s)');
xlabel(hs(3),'Time (s)');
xlabel(hs(4),'Time (s)');
text(hs(4),-0.6, 0.5, 'post','Units','normalized','FontWeight','bold','FontSize',11)
text(hs(8),-0.6, 0.5, 'pre','Units','normalized','FontWeight','bold','FontSize',11)
hgexport(gcf, '../paper_placebo_taste/figure2Sa_HR.svg', hgexport('factorystyle'), 'Format', 'svg');
hgexport(gcf, '../paper_placebo_taste/figure2Sa_HR.png', hgexport('factorystyle'), 'Format', 'png');
crop('../paper_placebo_taste/figure2Sa_HR.png');
% % SUPPLEMENT 2a v B: plot FULL, HR curves in % of baseline
% h_means=cpt_timeplot2(dfl_c.prepost,dfl_c.treat,dfl_c.CPT_HR_perc_BL,80);
% hs = findall(gcf,'Type','axes');
% xticklabels(hs(5:8),[])
% yticklabels(hs([1,2]),[])
%
% title(hs(8),treatlabels(1));
% title(hs(7),treatlabels(2));
% title(hs(6),treatlabels(3));
% title(hs(5),treatlabels(4));
%
% ylabel(hs(4),'Heart rate (%baseline)');
% ylabel(hs(8),'Heart rate (%baseline)');
% xlabel(hs(1),'Time (s)');
% xlabel(hs(2),'Time (s)');
% xlabel(hs(3),'Time (s)');
% xlabel(hs(4),'Time (s)');
%
% text(hs(4),-0.6, 0.5, 'post','Units','normalized','FontWeight','bold','FontSize',11)
% text(hs(8),-0.6, 0.5, 'pre','Units','normalized','FontWeight','bold','FontSize',11)
%
% hgexport(gcf, '../paper_placebo_taste/figure2Sa_HRpercBL.svg', hgexport('factorystyle'), 'Format', 'svg');
% hgexport(gcf, '../paper_placebo_taste/figure2Sa_HRpercBL.png', hgexport('factorystyle'), 'Format', 'png');
% crop('../paper_placebo_taste/figure2Sa_HRpercBL.png');
end
%% SUPPLEMENT 2a v A: plot MEAN HR curves
if any(strcmp(varargin,'averagecurves'))
% h_means=cpt_timeplot_means(dfl_c.treat,dfl_c.prepost,dfl_c.CPT_HR,dfl_c.maxtime,[60,100],80);
% hs = findall(gcf,'Type','axes');
% title(hs(4),treatlabels(1));
% title(hs(3),treatlabels(2));
% title(hs(2),treatlabels(3));
% title(hs(1),treatlabels(4));
% yticklabels(hs([1,2]),[])
% ylabel(hs(4),'Mean heart rate (bpm) ± 95% CI');
% xlabel(hs(1),'Time (s)');
% xlabel(hs(2),'Time (s)');
% xlabel(hs(3),'Time (s)');
% xlabel(hs(4),'Time (s)');
% text(hs(4),0.85, 0.45, 'pre','Units','normalized','FontSize',11)
% text(hs(4),0.85, 0.15, 'post','Units','normalized','FontSize',11)
% text(hs(3),0.85, 0.45, 'pre','Units','normalized','FontSize',11)
% text(hs(3),0.85, 0.15, 'post','Units','normalized','FontSize',11)
% text(hs(2),0.85, 0.45, 'pre','Units','normalized','FontSize',11)
% text(hs(2),0.85, 0.15, 'post','Units','normalized','FontSize',11)
% text(hs(1),0.85, 0.45, 'pre','Units','normalized','FontSize',11)
% text(hs(1),0.85, 0.15, 'post','Units','normalized','FontSize',11)
% hgexport(gcf, '../paper_placebo_taste/figure2Sb_HR.svg', hgexport('factorystyle'), 'Format', 'svg');
% hgexport(gcf, '../paper_placebo_taste/figure2Sb_HR.png', hgexport('factorystyle'), 'Format', 'png');
% crop('../paper_placebo_taste/figure2Sb_HR.png');
%% SUPPLEMENT 2a v B: plot MEAN HR curves, in % baseline
%h_means=cpt_timeplot_means(dfl_c.treat,dfl_c.prepost,dfl_c.CPT_HR_perc_BL,dfl_c.maxtime,[80,120],80,'highlight_maxima','group_color',treatcolors);
h_means=cpt_timeplot_means_simple(dfl_c.treat,dfl_c.prepost,dfl_c.CPT_HR_perc_BL,dfl_c.maxtime,[80,120],100,'highlight_maxima','refline','group_color',treatcolors);
hs = findall(gcf,'Type','axes');
title(hs(4),treatlabels(1),'FontWeight', 'normal');
title(hs(3),treatlabels(2),'FontWeight', 'normal');
title(hs(2),treatlabels(3),'FontWeight', 'normal');
title(hs(1),treatlabels(4),'FontWeight', 'normal');
yticklabels(hs([1,2,3]),[])
ylabel(hs(4),'Mean heart rate (%baseline) ± 95% CI');
xlabel(hs(1),'Time (s)');
xlabel(hs(2),'Time (s)');
xlabel(hs(3),'Time (s)');
xlabel(hs(4),'Time (s)');
% text(hs(4),0.3, 0.85, 'pre','Units','normalized','FontSize',11)
% text(hs(4),0.05, 0.48, 'post','Units','normalized','FontSize',11)
% text(hs(3),0.1, 0.85, 'pre','Units','normalized','FontSize',11)
% text(hs(3),0.08, 0.55, 'post','Units','normalized','FontSize',11)
% text(hs(2),0.15, 0.6, 'pre','Units','normalized','FontSize',11)
% text(hs(2),0.02, 0.85, 'post','Units','normalized','FontSize',11)
% text(hs(1),0.3, 0.95, 'pre','Units','normalized','FontSize',11)
% text(hs(1),0.1, 0.62, 'post','Units','normalized','FontSize',11)
legend(hs(4),'Pre-treatment','mean_m_a_x ± 95% CI','Post-treatment','mean_m_a_x ± 95% CI','Location','southwest')
legend(hs(4),'boxoff');
hgexport(gcf, '../paper_placebo_taste/figure2Sb_HR_percBL.svg', hgexport('factorystyle'), 'Format', 'svg');
hgexport(gcf, '../paper_placebo_taste/figure2Sb_HR_percBL.png', hgexport('factorystyle'), 'Format', 'png');
crop('../paper_placebo_taste/figure2Sb_HR_percBL.png');
end
%% Figure 2a: plot HR pre versus post (HR_max)
figure
subplot(1,2,1)
[~,h_means]=groupplot2(dfl_c.treat,dfl_c.prepost,dfl_c.CPT_HR_max);
title('Max heart rate',...
'Units','Normalized',...
'Position',[0.5,1.02])
h=gca;
ylabel('Max heart rate (BPM) ± 95% CI')
xticklabels(treatlabels);
xtickangle(45)
pbaspect([1 2 1])
% Figure 2b: plot HR change: post-pre
subplot(1,2,2)
pbaspect([2 1 1])
unicodeminus = sprintf(strrep('\u2212', '\u', '\x'));
[~,h_means]=groupplot(dfw_c.treat,dfw_c.CPT_HR_max_diff); %dfw_c.CPT_HR_max_diff
title('Change in max heart rate',...
'Units','Normalized',...
'Position',[0.5,1.02])
ylabel('Max heart rate (BPM) ± 95% CI')
xticklabels(treatlabels);
xtickangle(45)
hline(0,'color',[0 0 0])
pbaspect([1 2 1])
annotation('arrow',...
[0.48 0.52],[.5 .5],...
'HeadStyle','plain',...
'Units','Normalized');
annotation('textbox',...
[0.48, 0.58, .04, .04],...
'String',['post ' unicodeminus ' pre'],...
'Units','Normalized',...
'FontWeight','bold',...
'HorizontalAlignment','center',...
'LineStyle','none');
hgexport(gcf, '../paper_placebo_taste/figure2.svg', hgexport('factorystyle'), 'Format', 'svg');
hgexport(gcf, '../paper_placebo_taste/figure2.png', hgexport('factorystyle'), 'Format', 'png');
crop('../paper_placebo_taste/figure2.png');
%% Figure HRmax short version
figure
treatcolors={[0,0,0],[0.6,0.6,0.6],[0,0.3,0.7],[0.7,0,0.3]};
maxtime_y_label='Change in CPT HR-response (bpm) ± 95% CI';
[~,h_means]=groupplot(dfw_c.treat,dfw_c.CPT_HR_max_diff,'group_color',treatcolors);
%title('Change in CPT hand retention time',...
% 'Units','Normalized',...
% 'Position',[0.5,1.02])
ylabel(maxtime_y_label)
xticklabels(treatlabels);
hline(0,'color',[0 0 0])
%set(gcf, 'Position', [0 0 960 540])
hgexport(gcf, '../paper_placebo_taste/figure_HR_MAX.svg', hgexport('factorystyle'), 'Format', 'svg');
hgexport(gcf, '../paper_placebo_taste/figure_HR_MAX.png', hgexport('factorystyle'), 'Format', 'png');
crop('../paper_placebo_taste/figure_HR_MAX.png');
end