forked from yeatmanlab/speech_contrasts_public
-
Notifications
You must be signed in to change notification settings - Fork 1
/
start.m
200 lines (144 loc) · 6.67 KB
/
start.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
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
% This is the start screen for the categorization experiment. It should
% give...
% choice of user ID
% choice of results file location
% choice of stimulus location
% choice of stimulus continuum (ba-da, sa-sha)
% choice of experiment type (categorization or discrimination)
% choice of # of reps
function start()
close all
blue1 = [97, 132, 216] ./ 255;
blue2 = [83, 58, 113] ./ 255;
green1 = [80, 197, 183] ./ 255;
green2 = [156, 236, 91] ./ 255;
yellow = [240, 244, 101] ./ 255;
hndl.StartupWindow = figure('name', 'Experiment_Setup', ...
'numbertitle','off','menubar','none',...
'color', green1, ...
'units','normalized','position',[0 0 1 1]);
% Big text on screen
uicontrol('style','text','units','normalized','position',[.35 .79 .35 .2], ...
'backgroundcolor', green1,'string', 'Speech Contrasts', 'fontsize', 50,...
'FontWeight','bold')
%% Listener code
% Listener code box label
uicontrol('style', 'text', 'units','normalized','position',[.02 .65 .25 .16],...
'backgroundcolor',green1,'string','Listener Code:', 'fontsize', 34, 'FontWeight','bold')
% Listener code entry box
hndl.ListenerEntry = uicontrol('style','edit','units','normalized','position', ...
[.25 .73 .18 .1], 'backgroundcolor', [.97 .97 .97], 'string', 'nnn',...
'fontsize',34, 'FontWeight','bold');
%% Experiment choices
% Which contrast? Ba-da, or sa-sha
uicontrol('style', 'text', 'units','normalized','position',[.05 .5 .25 .16],...
'backgroundcolor',green1,'string','Contrast:', 'fontsize', 34, 'FontWeight','bold')
hndl.test_cueEntry = uicontrol('style','popupmenu', ...
'units','normalized','Position',[.25 .51 .18 .15],...
'string', ...
{'Ba_Da';...
'Sa_Sha'},...
'FontSize',34);
% Categorization versus discrimination
uicontrol('style', 'text', 'units','normalized','position',[.075 .35 .25 .16],...
'backgroundcolor',green1,'string','Task:', 'fontsize', 34, 'FontWeight','bold')
hndl.test_type = uicontrol('style','popupmenu', ...
'units','normalized','Position',[.25 .36 .18 .15],...
'string', ...
{'categorization';...
'discrimination'},...
'FontSize',30);
% Number of presentations
uicontrol('style', 'text', 'units','normalized','position',[.03 .25 .22 .16],...
'backgroundcolor',green1,'string','# of presentations per stimulus:', 'fontsize', 28, 'FontWeight','bold')
hndl.reps = uicontrol('style','edit','units','normalized','position', ...
[.25 .31 .18 .1], 'backgroundcolor', [.97 .97 .97], 'string', '10',...
'fontsize',34, 'FontWeight','bold');
% Random A B order or not
%uicontrol('style', 'text', 'units','normalized','position',[.03 .1 .22 .16],...
% 'backgroundcolor',green1,'string','Random A-B:', 'fontsize', 28, 'FontWeight','bold')
hndl.randAB = uicontrol('Style','checkbox','Value', 0, 'units', 'normalized',...
'position', [.05 .2 .2 .1], 'backgroundcolor', green1, ...
'String','Random A-B','fontsize', 24);
hndl.A_first = uicontrol('Style','checkbox','Value', 0, 'units', 'normalized',...
'position', [.2 .2 .2 .1], 'backgroundcolor', green1, ...
'String','A first','fontsize', 24);
hndl.B_first = uicontrol('Style','checkbox','Value', 0, 'units', 'normalized',...
'position', [.3 .2 .2 .1], 'backgroundcolor', green1, ...
'String','B first','fontsize', 24);
hndl.single_interval = uicontrol('Style','checkbox','Value', 0, 'units', 'normalized',...
'position', [.4 .2 .2 .1], 'backgroundcolor', green1, ...
'String','Single Interval','fontsize', 24);
%% File system parameters
basedir = fileparts(which('start'));
uicontrol('style', 'text', 'units','normalized','position',[.45 .67 .15 .16],...
'backgroundcolor',green1,'string','Stimulus path:', 'fontsize', 34, 'FontWeight','bold')
hndl.StimPath = uicontrol('style','edit','units','normalized','position', ...
[.6 .73 .35 .1], 'backgroundcolor', [.97 .97 .97], 'string', ...
fullfile(basedir,'Stimuli'),...
'fontsize',14, 'FontWeight','bold');
uicontrol('style', 'text', 'units','normalized','position',[.45 .53 .15 .16],...
'backgroundcolor',green1,'string','Results path:', 'fontsize', 34, 'FontWeight','bold')
hndl.ResultsPath = uicontrol('style','edit','units','normalized','position', ...
[.6 .58 .35 .1], 'backgroundcolor', [.97 .97 .97], 'string', ...
fullfile(basedir,'Results'),...
'fontsize',14, 'FontWeight','bold');
%% Practice buttons
uicontrol('style','frame', 'units','normalized','position',[.53 .4 .4 .12],...
'backgroundcolor', blue1);
hndl.practice = uicontrol('style','checkbox',...
'value', 0, ...
'units','normalized',...
'position', [.66 .41 .2 .1],...
'string','Practice',...
'backgroundcolor',blue1,...
'fontsize',36, 'FontWeight','bold');
%% Start button
hndl.StartExp = uicontrol('style','pushbutton',...
'units','normalized',...
'position', [.4 .05 .2 .14],...
'string','Start',...
'backgroundcolor',yellow,...
'callback', @SuperStart, 'fontsize',44);
set(findobj('name','Experiment_Setup'), 'UserData', hndl);
end
%% Start the experiment
function SuperStart(varargin)
hndl = get(findobj('name','Experiment_Setup'),'UserData');
% Get the values from user input to set up parameters
SubjectCode = get(hndl.ListenerEntry, 'string');
% ba-da or sa-sha?
list_of_test_cues = get(hndl.test_cueEntry,'string');
test_cue = list_of_test_cues{get(hndl.test_cueEntry, 'value')};
% type of test
list_of_tasks = get(hndl.test_type, 'string');
task = list_of_tasks{get(hndl.test_type, 'value')};
% Get number of reps
reps = str2num(get(hndl.reps,'string'));
% Get the location of the stimulus directory
stim_path = get(hndl.StimPath, 'string');
results_path = get(hndl.ResultsPath, 'string');
% Get stimulus presentation rules
rand_ab = get(hndl.randAB, 'value');
a_first = get(hndl.A_first, 'value');
b_first = get(hndl.B_first, 'value');
single_interval = get(hndl.single_interval, 'value');
% Is this practice?
is_practice = get(hndl.practice, 'value');
minimize(hndl.StartupWindow);
% Throw an error if the user has selected conflicting settings for the
% categorization task.
if sum([rand_ab a_first b_first]) > 1
error('Can only selet one: Random A-B, A first, or B first.')
end
% Is it practice?
if is_practice && strcmp(task, 'categorization')
Categorization_Practice(SubjectCode, test_cue, stim_path, results_path, single_interval)
elseif is_practice && strcmp(task, 'discrimination')
Discrimination_Practice(SubjectCode, test_cue, stim_path, results_path)
elseif ~is_practice && strcmp(task, 'categorization')
Categorization(SubjectCode,test_cue,task,reps,stim_path,results_path,rand_ab,a_first,b_first,single_interval)
elseif ~is_practice && strcmp(task, 'discrimination')
Discrimination(SubjectCode, test_cue, task, reps, stim_path, results_path)
end
end