-
Notifications
You must be signed in to change notification settings - Fork 0
/
rd_checkTriggers.m
50 lines (42 loc) · 1.34 KB
/
rd_checkTriggers.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
function allTriggers = rd_checkTriggers(fileName, trigChans, verbose)
% function rd_checkTriggers(fileName, [trigChans], [verbose])
% INPUTS:
% fileName is the path to the sqd file
% trigChans (optional) is the trigger channels to plot. Default is 160:167.
% verbose (optional) [1 or 0] specify whether to print the trigger count
% for each channel
%
% OUTPUTS:
% f is a figure handle for the generated plot
%% deal with inputs
if nargin<2 || isempty(trigChans)
trigChans = 160:167; % all trigger channels
end
if nargin<3 || isempty(verbose)
verbose = 1;
end
%% plot triggers from each channel
figure;
hold all
allTriggers = [];
for iTrig = 1:numel(trigChans)
try
triggers = all_trigger(fileName, trigChans(iTrig));
trigTimes = triggers(:,1);
plot(trigTimes, ones(size(trigTimes))+iTrig-1, '.', 'MarkerSize', 30)
allTriggers = [allTriggers; triggers(:,1) ones(size(trigTimes))+iTrig-1];
if verbose
fprintf('Channel %d: %d triggers\n', trigChans(iTrig), numel(trigTimes))
end
catch err
if strcmp(err.identifier, 'MATLAB:badsubscript')
if verbose
fprintf('Channel %d: 0 triggers\n', trigChans(iTrig))
end
end
end
end
ylim([0 10])
xlabel('time')
ylabel('triggers')
allTriggers = sortrows(allTriggers, 1);