-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunReader.m
More file actions
128 lines (112 loc) · 4.07 KB
/
runReader.m
File metadata and controls
128 lines (112 loc) · 4.07 KB
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
configReader();
% create the control window and execute the phase selection loop
contFig=controller();
info=guidata(contFig);
while (ishandle(contFig))
set(contFig,'visible','on');
uiwait(contFig); % CPU hog on ver 7.4
if ( ~ishandle(contFig) )
break;
end;
set(contFig,'visible','off');
info=guidata(contFig);
subject=info.subject;
phaseToRun=lower(info.phaseToRun);
fprintf('Start phase : %s\n',phaseToRun);
switch phaseToRun;
%---------------------------------------------------------------------------
case 'capfitting';
sendEvent('subject',info.subject);
sendEvent('startPhase.cmd',phaseToRun);
% wait until capFitting is done
buffer_waitData(buffhost,buffport,[],'exitSet',{{phaseToRun} {'end'}},'verb',verb);
%---------------------------------------------------------------------------
case 'eegviewer';
sendEvent('subject',info.subject);
sendEvent('startPhase.cmd',phaseToRun);
% wait until capFitting is done
buffer_waitData(buffhost,buffport,[],'exitSet',{{phaseToRun} {'end'}},'verb',verb);
%---------------------------------------------------------------------------
case 'practice';
sendEvent('subject',info.subject);
sendEvent(phaseToRun,'start');
% Override sequence number and block number
onSequence = nSequence;
nSequence=5;
onBlock = nBlock;
nBlock=1;
try
readerCalibrateStimulus();
catch
le=lasterror;
fprintf('ERROR Caught:\n %s\n%s\n',le.identifier,le.message);
end
sendEvent(phaseToRun,'end');
% Reset to original sequence number and block number
nSequence = onSequence;
nBlock = onBlock;
%---------------------------------------------------------------------------
case {'calibrate','calibration'};
sendEvent('subject',info.subject);
sendEvent('startPhase.cmd',phaseToRun)
sendEvent(phaseToRun,'start');
try
readerCalibrateStimulus();
catch
le=lasterror;
fprintf('ERROR Caught:\n %s\n%s\n',le.identifier,le.message);
sendEvent('stimulus.training','end');
end
sendEvent(phaseToRun,'end');
%---------------------------------------------------------------------------
case {'train','classifier'};
sendEvent('subject',info.subject);
sendEvent('startPhase.cmd',phaseToRun);
% wait until training is done
buffer_waitData(buffhost,buffport,[],'exitSet',{{phaseToRun} {'end'}},'verb',verb);
%---------------------------------------------------------------------------
case {'epochfeedback'};
sendEvent('subject',info.subject);
%sleepSec(.1);
sendEvent(phaseToRun,'start');
%try
sendEvent('startPhase.cmd','epochfeedback');
readerEpochFeedbackStimulus();
%catch
% le=lasterror;fprintf('ERROR Caught:\n %s\n%s\n',le.identifier,le.message);
%end
sendEvent('stimulus.test','end');
sendEvent(phaseToRun,'end');
%---------------------------------------------------------------------------
case {'readerfeedback'};
sendEvent('subject',info.subject);
%sleepSec(.1);
sendEvent(phaseToRun,'start');
% try
sendEvent('startPhase.cmd','readerfeedback');
readerNeuroFeedbackStimulus();
%catch
% le=lasterror;
% fprintf('ERROR Caught:\n %s\n%s\n',le.identifier,le.message);
% end
sendEvent('stimulus.test','end');
sendEvent(phaseToRun,'end');
%---------------------------------------------------------------------------
end
info.phasesCompleted={info.phasesCompleted{:} info.phaseToRun};
if ( ~ishandle(contFig) )
oinfo=info; % store old info
contFig=controller(); % make new figure
info=guidata(contFig); % get new info
% re-place old info
info.phasesCompleted=oinfo.phasesCompleted;
info.phaseToRun=oinfo.phaseToRun;
info.subject=oinfo.subject;
set(info.subjectName,'String',info.subject);
guidata(contFig,info);
end;
end
uiwait(msgbox({'Thank you for participating in our experiment.'},'Thanks','modal'),10);
pause(1);
% shut down signal proc
sendEvent('startPhase.cmd','exit');