-
Notifications
You must be signed in to change notification settings - Fork 0
/
AM4100_stimulate.m
51 lines (50 loc) · 1.88 KB
/
AM4100_stimulate.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
function AM4100_stimulate(am4100, logger, client, options)
%AM4100_STIMULATE Stimulate using the AM4100, while recording this event.
arguments
am4100
logger
client
options.DelayAfterRunCommand (1,1) double {mustBeGreaterThanOrEqual(options.DelayAfterRunCommand, 0)} = 0.025;
options.DelayAfterNameCommand (1,1) double {mustBeGreaterThanOrEqual(options.DelayAfterNameCommand, 0)} = 0.025;
options.DelayAfterRecCommand (1,1) double {mustBeGreaterThanOrEqual(options.DelayAfterRecCommand, 0)} = 0.1;
options.Tag {mustBeTextScalar} = 'STIM';
options.StartRecording (1,1) logical = true;
options.RawDataRoot {mustBeTextScalar} = "";
end
if options.StartRecording
if ~isempty(am4100.UserData.timer)
am4100.UserData.timer.StartDelay = am4100.UserData.recording_duration;
end
if ~isempty(client)
SAGA_record(client, logger, ...
'DelayAfterRunCommand', options.DelayAfterRunCommand, ...
'DelayAfterNameCommand', options.DelayAfterNameCommand, ...
'DelayAfterRecCommand', options.DelayAfterRecCommand, ...
'Tag', options.Tag, ...
'Block', client.UserData.block, ...
'Intan', am4100.UserData.intan, ...
'Timer', am4100.UserData.timer, ...
'RawDataRoot', options.RawDataRoot);
end
if ~isempty(logger)
logger.info('Begin Stimulation');
end
else
if ~isempty(am4100.UserData.intan)
intan.startRunning(am4100.UserData.intan);
end
end
if am4100.UserData.enable
[rplStr,inputStr]=AM4100_sendCommand(am4100,'1001 s t one'); % set the trigger to free run
if ~isempty(logger)
logger.info(sprintf('sent = %s', inputStr));
logger.info(sprintf('reply = %s', rplStr));
end
end
if ~isempty(am4100.UserData.timer)
start(am4100.UserData.timer);
end
if ~isempty(client)
client.UserData.recording = true;
end
end