-
Notifications
You must be signed in to change notification settings - Fork 0
/
getDemographics.m
120 lines (94 loc) · 3.6 KB
/
getDemographics.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
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
function [out] = getDemographics(constants)
%--------------------------------------------------------%
% Onscreen script to record race/ethnic/sex demographics %
% for Matlab %
% Updated 09/21/2015 %
%--------------------------------------------------------%
%{
Purpose:
A Matlab script which will generate a set of dialog boxes that ask
participants an assortment of questions regarding demographics (in
compliance with NIH requirements).
Requirements:
An installation of Matlab
Outputs:
A text file 'Demographics.txt'
Notes:
Forthcoming
%%% TO DO %%%
- Forthcoming
%}
% Set the width and height of the dialog box
boxSize = [ 250, 100 ];
% Create a cellstring array to store the answers
output = [ {'Sex'} {'Ethnicity'} {'Race'} ];
out = output;
% Display an initial message regarding the NIH
headerNIH = sprintf('The National Institute of Health requests basic demographic information (sex, ethnicity, and race) for clinical or behavioral studies, to the extent that this information is provided by research participants.\n\nYou are under no obligation to provide this information. If you would rather not answer these questions, you will still receive full compensation for your participation in this study and the data you provide will still be useful for our research.');
waitfor( msgbox(headerNIH,'Demographics') ); % Must close message to continue
%%% Sex at birth %%%
% Define the initial prompt
stringPrompt = [ {sprintf('1) Sex at birth:')} {''} ];
% Define the choices that can be selected
Choices = [ {'Female'} {'Male'} {'Other'} ];
% Create a list dialog box and determine the selection
sel = listdlg('PromptString',stringPrompt,...
'SelectionMode','single',... % So people can only pick one option
'ListString',Choices,...
'ListSize',boxSize,...
'CancelString','Rather not say');
% Save output
if ( isempty(sel) )
output{1} = 'Sex, Rather not say';
out{1} = {'Rather not say'};
else
output{1} = [ 'Sex, ' Choices{sel} ];
out{1} = Choices{sel};
end
%%% Ethnicity %%%
% Define the initial prompt
stringPrompt = [ {sprintf('2) Ethnicity:')} {''} ];
% Define the choices that can be selected
Choices = [ {'Hispanic or Latino'} {'Not Hispanic or Latino'} ];
% Create a list dialog box and determine the selection
sel = listdlg('PromptString',stringPrompt,...
'SelectionMode','single',...
'ListString',Choices,...
'ListSize',boxSize,...
'CancelString','Rather not say');
% Save output
if ( isempty(sel) )
output{2} = 'Ethnicity, Rather not say';
out{2} = 'rather not say';
else
output{2} = [ 'Ethnicity, ' Choices{sel} ];
out{2} = Choices{sel};
end
%%% Race %%%
% Define the initial prompt
stringPrompt = [ {sprintf('3) Race:')} {''} ];
% Define the choices that can be selected
Choices = [ {'American Indian/Alaska Native'} {'Asian'} {'Native Hawaiian or Other Pacific Islander'} {'Black or African American'} {'White'} ];
% Create a list dialog box and determine the selection
sel = listdlg('PromptString',stringPrompt,...
'SelectionMode','single',...
'ListString',Choices,...
'ListSize',boxSize,...
'CancelString','Rather not say');
% Save output
if ( isempty(sel) )
output{3} = 'Race, Rather not say';
out{3} = 'rather not say';
else
output{3} = [ 'Race, ' Choices{sel} ];
out{3} = Choices{sel};
end
% Record output to a text file
fid = fopen([constants.subDir, '\demographics.txt'], 'wt' );
for i = 1:3
fprintf( fid, sprintf( [ output{i} '\n' ] ) );
end
fclose(fid);
% Cleans up workspace
% clear boxSize output headerNIH stringPrompt Choices sel output i ans fid
end