Skip to content

Commit 01bdbf4

Browse files
committed
Added note to record type selection GUI that talks about need for data aggregation.
1 parent 9c9ed12 commit 01bdbf4

File tree

2 files changed

+114
-5
lines changed

2 files changed

+114
-5
lines changed

utilities/select_record_types.m

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,32 @@ function select_record_types(record_types)
2121
set(fig, 'units', 'pixels')
2222
window_px_sizes = get(fig, 'position');
2323
window_width = checkbox_width*2 + inset*4;
24-
window_height = 150;
24+
window_height = 250;
2525
set(fig, 'position', [window_px_sizes(1), window_px_sizes(2), window_width, window_height]);
2626

2727
y_pos = window_height;
2828

2929
% Create record selection note
3030
text_height = 18;
31-
y_pos = y_pos - text_height*2;
31+
y_pos = y_pos - text_height*7;
3232
url = 'https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifier';
33-
msg_str = sprintf(['<html>For an explination of record types, see <a href="' url '">Apple''s documentation</a>.']);
33+
msg_str = sprintf(['<html>For an explination of record types, see <a href="' url '">Apple''s documentation</a>.',...
34+
' Note that because of the way that watchOS/iOS measures and stores many of these record',...
35+
' types, it does not make much sense to plot their individual data points. For example,'...
36+
' the ''DistanceWalkingRunning'' record type records movement over relatively short and varying',...
37+
' time periods. To resolve this issue, support for some type of data aggregation (such as summing',...
38+
' all of the data points over one day) is planned for some time in the future.']);
39+
3440
jLabel = javaObjectEDT('javax.swing.JLabel', msg_str);
35-
[hjLabel,~] = javacomponent(jLabel, [inset, y_pos, window_width-30, text_height], gcf);
41+
[hjLabel,~] = javacomponent(jLabel, [inset, y_pos, window_width-30, text_height*6], gcf);
3642
hjLabel.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.HAND_CURSOR));
3743
set(hjLabel, 'MouseClickedCallback', @(h,e)web(url, '-browser'))
3844

3945
% uicontrol('Style', 'Text', 'Units', 'Pixels',...
4046
% 'Position', [inset, y_pos, window_width-30, text_height], 'FontSize', font_size, 'HorizontalAlignment', 'Left',...
4147
% 'String', message_str);
4248

43-
y_pos = y_pos - text_height;
49+
y_pos = y_pos - text_height*2;
4450

4551
uicontrol('Style', 'Text', 'Units', 'Pixels',...
4652
'Position', [inset, y_pos, window_width-30, text_height], 'FontSize', font_size, 'HorizontalAlignment', 'Left',...

utilities/select_record_types.m~

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
function select_record_types(record_types)
2+
3+
if ispc % Use smaller font on Windows
4+
font_size = 9;
5+
else
6+
font_size = 13;
7+
end
8+
9+
record_type_names = table2cell(record_types(:, 1));
10+
record_type_names = strrep(record_type_names, 'HKQuantityTypeIdentifier', '');
11+
record_units = table2cell(record_types(:, 2));
12+
13+
% half_record_count = ceil(size(record_types, 1)/2);
14+
inset = 15;
15+
checkbox_width = 250;
16+
17+
% Create figure
18+
fig = figure('units', 'normalized', 'position', [.3, .4, .4, .4], 'menu', 'none',...
19+
'NumberTitle', 'off', 'Name', 'Select Record Types');
20+
assignin('base', 'user_input_figure', fig); % Used by uiwait() in main script
21+
set(fig, 'units', 'pixels')
22+
window_px_sizes = get(fig, 'position');
23+
window_width = checkbox_width*2 + inset*4;
24+
window_height = 250;
25+
set(fig, 'position', [window_px_sizes(1), window_px_sizes(2), window_width, window_height]);
26+
27+
y_pos = window_height;
28+
29+
% Create record selection note
30+
text_height = 18;
31+
y_pos = y_pos - text_height*6;
32+
url = 'https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifier';
33+
msg_str = sprintf(['<html>For an explination of record types, see <a href="' url '">Apple''s documentation</a>.',...
34+
' Note that because of the way that watchOS/iOS measures and stores many of these record',...
35+
' types, it does not make much sense to plot their individual data points. For example,'...
36+
' the ''DistanceWalkingRunning'' record type records movement over relatively short and varying',...
37+
' time periods. To resolve this issue, support for some type of data aggregation (such as summing',...
38+
' all of the data points over one day) is planned for some time in the future (ticket number).']);
39+
40+
jLabel = javaObjectEDT('javax.swing.JLabel', msg_str);
41+
[hjLabel,~] = javacomponent(jLabel, [inset, y_pos, window_width-30, text_height*5], gcf);
42+
hjLabel.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.HAND_CURSOR));
43+
set(hjLabel, 'MouseClickedCallback', @(h,e)web(url, '-browser'))
44+
45+
% uicontrol('Style', 'Text', 'Units', 'Pixels',...
46+
% 'Position', [inset, y_pos, window_width-30, text_height], 'FontSize', font_size, 'HorizontalAlignment', 'Left',...
47+
% 'String', message_str);
48+
49+
y_pos = y_pos - text_height*2;
50+
51+
uicontrol('Style', 'Text', 'Units', 'Pixels',...
52+
'Position', [inset, y_pos, window_width-30, text_height], 'FontSize', font_size, 'HorizontalAlignment', 'Left',...
53+
'fontweight', 'bold', 'String', 'Record type to be plotted:');
54+
55+
y_pos = y_pos - text_height - 5;
56+
57+
% Create record checkboxes
58+
% for ind = 1:half_record_count
59+
% record_type_check_boxes(ind) = uicontrol('Style', 'Checkbox', 'Units', 'Pixels',...
60+
% 'Position', [inset, y_pos - 25*(ind-1), checkbox_width, 18],...
61+
% 'FontSize', font_size, 'String', [char(record_type_names(ind)) ' (' char(record_units(ind)) ')']);
62+
% end
63+
% for ind = half_record_count+1:size(record_types, 1)
64+
% record_type_check_boxes(ind) = uicontrol('Style', 'Checkbox', 'Units', 'Pixels',...
65+
% 'Position', [(inset*3)+checkbox_width, y_pos - 25*(ind-half_record_count-1), checkbox_width, 18],...
66+
% 'FontSize', font_size, 'String', [char(record_type_names(ind)) ' (' char(record_units(ind)) ')']);
67+
% end
68+
69+
record_strs = cellfun(@concat_record_type_strs, record_type_names, record_units, 'UniformOutput', false);
70+
71+
record_type_selector = uicontrol('Style', 'PopupMenu', 'Units', 'Pixels',...
72+
'Position', [inset, y_pos, checkbox_width, 18],...
73+
'FontSize', font_size, 'String', record_strs);
74+
75+
y_pos = y_pos - 55;
76+
77+
button_height = 26;
78+
uicontrol('Style', 'PushButton', 'Units', 'Pixels', 'Position', [(window_width-100)/2, y_pos, 100, button_height],...
79+
'FontSize', font_size, 'String', 'Proceed', 'Callback', @handle_proceed_button);
80+
81+
function str = concat_record_type_strs(type, unit)
82+
str = [char(type) ' (' char(unit) ')'];
83+
end
84+
85+
86+
function handle_proceed_button(~, ~)
87+
88+
% Pass user input to main script
89+
% selected_record_types = false(size(record_types, 1), 1);
90+
% for record_type_ind = 1:size(record_types, 1)
91+
% if record_type_check_boxes(record_type_ind).Value
92+
% selected_record_types(record_type_ind) = true;
93+
% end
94+
% end
95+
% assignin('base', 'selected_record_types', selected_record_types);
96+
assignin('base', 'selected_record_types', record_type_selector.Value);
97+
assignin('base', 'record_type', char(record_type_names(record_type_selector.Value)));
98+
99+
% Close user input window and resume main script
100+
close gcf;
101+
end
102+
103+
end

0 commit comments

Comments
 (0)