-
Notifications
You must be signed in to change notification settings - Fork 1
/
WaitForTTL.m
84 lines (52 loc) · 2.72 KB
/
WaitForTTL.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
function [ TriggerTime ] = WaitForTTL( DataStruct )
if strcmp(DataStruct.OperationMode,'Acquisition')
if ~isfield(DataStruct,'StartTime') % It means wait for 1st TTL @ Begining of stimulation
disp('----------------------------------')
disp(' Waiting for trigger "t" ')
disp(' OR ')
disp(' Press "s" to emulate trigger ')
disp(' Press "Escape" to abort ')
disp('----------------------------------')
disp(' ')
else % All other cases
disp('Waiting for TTL')
end
% Just to be sure the user is not pushing a button before
WaitSecs(0.2); % secondes
% Waiting for TTL signal
while 1
[ keyIsDown , TriggerTime, keyCode ] = KbCheck;
if keyIsDown
switch DataStruct.Environement
case 'MRI'
if keyCode(DataStruct.Parameters.Keybinds.TTL_t_ASCII) || keyCode(DataStruct.Parameters.Keybinds.emulTTL_s_ASCII)
break
elseif keyCode(DataStruct.Parameters.Keybinds.Stop_Escape_ASCII)
% Eyelink mode 'On' ?
if strcmp(DataStruct.EyelinkMode,'On')
Eyelink.STOP % Stop wrapper
end
sca
stack = dbstack;
error('WaitingForTTL:Abort','\n ESCAPE key : %s aborted \n',stack.file)
end
case 'Training'
if keyCode(DataStruct.Parameters.Keybinds.Right_Blue_b_ASCII) || keyCode(DataStruct.Parameters.Keybinds.TTL_t_ASCII) || keyCode(DataStruct.Parameters.Keybinds.emulTTL_s_ASCII)
break
elseif keyCode(DataStruct.Parameters.Keybinds.Stop_Escape_ASCII)
% Eyelink mode 'On' ?
if strcmp(DataStruct.EyelinkMode,'On')
Eyelink.STOP % Stop wrapper
end
sca
stack = dbstack;
error('WitingForTTL:Abort','\n ESCAPE key : %s aborted \n',stack.file)
end
end
end
end
else % in DebugMod
disp('Waiting for TTL : DebugMode')
TriggerTime = GetSecs;
end
end