-
Notifications
You must be signed in to change notification settings - Fork 4
/
ResponseCheck.m
33 lines (30 loc) · 896 Bytes
/
ResponseCheck.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
classdef ResponseCheck < StudyEvent
% StudyEvent subclass for logging responses
properties
validkeys = []; % vector of possible responses
name = 'responsecheck';
keyisdown = 0;
lastkey = NaN;
end
methods
function s = ResponseCheck(varargin)
if nargin==0
return
end
sout = varargs2structfields(varargin,s);
for fn = fieldnames(sout)'
s.(fn{1}) = sout.(fn{1});
end
end
function call(self)
self.ncalls = self.ncalls + 1;
[respk,resptime] = self.checkkeys;
[validresp,x,inds] = intersect(self.validkeys,respk);
self.response = validresp;
self.responsetime = resptime(inds);
end
end
methods (Abstract)
[respk,resptime] = checkkeys(self);
end
end