-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_events_ch.m
78 lines (60 loc) · 1.83 KB
/
plot_events_ch.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
function plot_events_ch(events_ch,index,vshift,range,info,hdlfig,titlestr,linestyle,linewidth,color)
%function [range]=plot_events_ch(events_ch,index,vshift,info,hdlfig,titlestr,linestyle,linewidth,color)
% plot events for each individual channel
%
% index: index of channels to display if missing channels
% vshift: verticla shift between channels (control scaling)
%
% see also plot_trials
%
% Corentin Massot
% Cognition and Sensorimotor Integration Lab, Neeraj J. Gandhi
% University of Pittsburgh
% created 11/07/2016 last modified 06/21/2017
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%figure
if ~isempty(hdlfig)
subplot(hdlfig);
else
figure;
end
%range
maxtime=range(1);maxtime=range(2);
minval=range(3);maxval=range(4);
%plot
nchannels=size(events_ch,1);
%color
if isempty(color)
colorlist=get_colorlist;
else
colorlist(1:nchannels,:)=color;
end
%vshift
if isempty(vshift)
vshift=maxval/4;
end
%index
if isempty(index),index=[1:nchannels];end;
%adjust timing
events_ch(:,1)=events_ch(:,1)+info.aligntime;
if nchannels~=1
for ch=1:nchannels
chi=index(ch);
if events_ch(chi,1)~=0
hl=line([events_ch(chi,1) events_ch(chi,1)] ,[vshift*chi+events_ch(chi,2)-vshift/2 vshift*chi+events_ch(chi,2)+vshift/2]);
set(hl,'Color',colorlist(chi,:),'LineStyle',linestyle,'Linewidth',linewidth);
end
end
else
if events_ch(1,1)~=0
hl=line([events_ch(1,1) events_ch(1,1)] ,[minval maxval]);
set(hl,'Color',colorlist(1,:),'LineStyle',linestyle,'Linewidth',linewidth);
end
end
if ~strcmp(titlestr,'n')
if ~isempty(titlestr)
title(titlestr);
else
title({info.datafile ; [info.align ' t' num2str(info.targ) ' #trials:' num2str(info.ntrials)]});
end
end