[422372]: / functions / sigprocfunc / ploterp.m

Download this file

163 lines (144 with data), 4.6 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
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
% PLOTERP - plot a selected multichannel data epoch on a common timebase
%
% Usage: >> ploterp(data,frames,epoch,[limits],'title',[plotchans]);
%
% Inputs:
% data = EEG/ERP data epoch (chans,frames)
% frames = frames per epoch {default: data length}
% epoch = epoch to plot {default: 1}
% [limits] = [xmin xmax ymin ymax] (x's in ms)
% {def|0 or both y's 0 -> data limits}
% 'title' = plot title {default|0 -> none}
% plotchans = data channels to plot {default|0 -> all}
%
% Author: Scott Makeig, SCCN/INC/UCSD, La Jolla, 6-11-98
%
% See also: TIMTOPO
% Copyright (C) 6-11-98 from PLOTDATA Scott Makeig, SCCN/INC/UCSD,
% scott@sccn.ucsd.edu
%
% This file is part of EEGLAB, see http://www.eeglab.org
% for the documentation and details.
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are met:
%
% 1. Redistributions of source code must retain the above copyright notice,
% this list of conditions and the following disclaimer.
%
% 2. Redistributions in binary form must reproduce the above copyright notice,
% this list of conditions and the following disclaimer in the documentation
% and/or other materials provided with the distribution.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
% THE POSSIBILITY OF SUCH DAMAGE.
% 01-25-02 reformated help & license, added links -ad
function plot_handl = ploterp(data,frames,epoch,limits,titl,plotchans)
LABELFONT = 16;
TICKFONT = 14;
TITLEFONT = 16;
if nargin < 1
help ploterp
return
end
[chans,framestot] = size(data);
icadefs;
if nargin < 6
plotchans = 0;
end
if plotchans==0
plotchans = 1:chans;
end
if nargin < 5,
titl = ''; % DEFAULT TITLE
end
if nargin < 4,
limits = 0;
end
if nargin < 3
epoch = 0;
end
if epoch == 0
epoch = 1;
end
if nargin<2
frames = 0;
end
if frames == 0
frames = size(data,2);
end
if floor(framestot/frames)*frames ~= framestot
fprintf('ploterp(): frames argument does not divide data length.\n');
return
end
if epoch*frames > framestot
fprintf('ploterp(): data does not contain %d epochs of %d frames.\n',epoch,frames);
return
end
%
%%%%%%%%%%%%%%%%%%%%%%% Read and adjust limits %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
if limits==0, % == 0 or [0 0 0 0]
xmin=0;
xmax=frames-1;
ymin=min(min(data));
ymax=max(max(data));
else
if length(limits)~=4,
fprintf( ...
'ploterp: limits should be 0 or an array [xmin xmax ymin ymax].\n');
return
end
xmin = limits(1);
xmax = limits(2);
ymin = limits(3);
ymax = limits(4);
end
if xmax == 0 && xmin == 0,
x = (0:1:frames-1);
xmin = 0;
xmax = frames-1;
else
dx = (xmax-xmin)/(frames-1);
x=xmin*ones(1,frames)+dx*(0:frames-1); % compute x-values
end
if xmax<=xmin,
fprintf('ploterp() - xmax must be > xmin.\n')
return
end
if ymax == 0 && ymin == 0,
ymax=max(max(data));
ymin=min(min(data));
end
if ymax<=ymin,
fprintf('ploterp() - ymax must be > ymin.\n')
return
end
sampint = (xmax-xmin)/(frames-1); % sampling interval = 1000/srate;
x = xmin:sampint:xmax; % make vector of x-values
%
%%%%%%%%%%%%%%%%%%%%%%% Plot the data %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
cla % clear the current figure axes
set(gca,'YColor',BACKCOLOR); % set the background color
set(gca,'Color',BACKCOLOR);
set(gca,'GridLineStyle',':')
set(gca,'Xgrid','off')
set(gca,'Ygrid','on')
set(gca,'Color',BACKCOLOR,'FontSize',TICKFONT,'FontWeight','bold');
plot_handl=plot(x,data(plotchans,(epoch-1)*frames+1:epoch*frames)); % plot the data
title(titl,'fontsize',TITLEFONT,'FontWeight','bold');
l= xlabel('Time (ms)');
set(l,'FontSize',LABELFONT,'FontWeight','bold');
l=ylabel('Potential (uV)');
set(l,'FontSize',LABELFONT,'FontWeight','bold');
axis([xmin xmax ymin ymax]);