-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalibShocks.m
More file actions
70 lines (56 loc) · 1.47 KB
/
calibShocks.m
File metadata and controls
70 lines (56 loc) · 1.47 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
function calibShocks( options )
markerStart = 250;
markerStop = 252;
dummymode = 0;
for i=1:length(options)
switch options{i}
case 'dummymodeLpt'
dummymode = 1;
end
end
%% init LPT port
if dummymode
[ status, LPT ] = initlpt('dummy');
else
[ status, LPT ] = initlpt();
end
if status ~= 0; return; end
%% PTB functions
ListenChar(-1); %makes it so characters typed don?t show up in the command window
KbName('UnifyKeyNames'); %used for cross-platform compatibility of keynaming
spaceKey = KbName('Space');
qKey = KbName('q');
% get the index for the main keyboard in the lab
% KbPointer = GetKeyboardIndices('Dell Dell Wired Multimedia Keyboard');
KbQueueCreate(); %creates cue using defaults
KbQueueStart(); %starts the cue
WaitSecs(.5);
KbQueueCheck();
KbQueueFlush();
% marker to segment biopac
LPT.sendMarker(markerStart);
fprintf('Press space to apply stimulus.\n');
fprintf('Press q to exit.\n');
shocking = 1;
while shocking
KbStrokeWait();
[ keyIsDown, ~, keyCode ] = KbQueueCheck();
keyCode = find(keyCode, 1);
if keyIsDown
if keyCode == spaceKey
LPT.sendShock();
fprintf('Stimulus\n');
WaitSecs(.1);
elseif keyCode == qKey
shocking = 0;
fprintf('Bye\n');
WaitSecs(.5);
end
end
KbQueueFlush();
end
KbQueueStop();
% marker to segment biopac
LPT.sendMarker(markerStop);
cleanup('LPT', LPT);
end