-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathctf_plot.m
188 lines (152 loc) · 5.67 KB
/
ctf_plot.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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
function ctf_plot(ctf,CHAN,TIME,TRIALS,Xhair)
% ctf_plot - plot ctf.data
%
% ctf_plot(ctf,CHAN,TIME,TRIALS,Xhair)
%
% CHAN - see ctf_channel_select for options
% TIME - see ctf_read for options (given in msec)
% TRIALS - select 1 trial to plot (the default is trial = 1)
%
% Xhair - 1 to use the crosshair GUI features (default), 0 otherwise
%
% <>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
% < >
% < DISCLAIMER: >
% < >
% < THIS PROGRAM IS INTENDED FOR RESEARCH PURPOSES ONLY. >
% < THIS PROGRAM IS IN NO WAY INTENDED FOR CLINICAL OR >
% < OFFICIAL USE. >
% < >
% <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>
%
% $Revision: 1.1 $ $Date: 2009-01-30 03:49:27 $
% Copyright (C) 2004 Darren L. Weber
%
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 2
% of the License, or (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
% Modified: 02/2004, Darren.Weber_at_radiology.ucsf.edu
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if ~exist('CHAN','var'), CHAN = 'all'; end
if ~exist('TIME','var'), TIME = 'all'; end
if ~exist('TRIALS','var'), TRIALS = 1; end
if ~exist('Xhair','var'), Xhair = 1; end
if isempty(CHAN), CHAN = 'all'; end
if isempty(TIME), TIME = 'all'; end
if isempty(TRIALS), TRIALS = 1; end
if isempty(Xhair), Xhair = 1; end
% This function calls ctf_channel_select
[CHAN,type] = ctf_channel_select(ctf,CHAN);
switch num2str(TIME),
case 'all',
TIME = ctf.setup.time_msec;
TIME_index = 1:ctf.setup.number_samples;
otherwise
fprintf('...sorry, time restrictions not implemented correctly (03/2004)\n');
TIME = ctf.setup.time_msec;
TIME_index = 1:ctf.setup.number_samples;
% % assume the input is a range of times in sec
% % check the range
% if TIME(1) > ctf.setup.time_msec(1),
% fprintf('...setting TIME(1) = ctf.setup.time_msec(1)\n');
% TIME(1) = ctf.setup.time_msec(1);
% end
% if TIME(end) > ctf.setup.time_msec(end),
% fprintf('...setting TIME(end) = ctf.setup.time_msec(end)\n');
% TIME(end) = ctf.setup.time_msec(end);
% end
% % now find the nearest indices into the samples matrix
% TIME_index = interp1(ctf.setup.time_msec,1:ctf.setup.number_samples,TIME,'nearest');
% % now ensure that the TIME array is consistent with ctf.setup.time_sec
% TIME = ctf.setup.time_msec(TIME_index);
end
TIME = sort(TIME);
switch num2str(TRIALS),
case 'all',
TRIALS = 1:ctf.setup.number_trials;
otherwise
% assume the input is an array of trials
end
TRIALS = unique(sort(TRIALS));
% check the input data for more than 1 trial
trials = size(ctf.data,3);
if trials > 1,
fprintf('...plotting trial %d of %d trials in ctf.data\n',TRIALS,trials);
data = ctf.data(:,:,TRIALS);
else
data = ctf.data;
end
% now plot the data
switch type,
case 'all',
if isempty(ctf.sensor.index.meg_sens),
fprintf('...no meg sensors\n');
else
figure('Name','MEG sensors');
MEGCHAN = ctf_channel_select(ctf,'meg');
plot(ctf.setup.time_msec(TIME_index),data(TIME_index,MEGCHAN))
axis tight
if exist('crosshair') & Xhair,
crosshair;
end
end
if isempty(ctf.sensor.index.eeg_sens),
fprintf('...no eeg sensors\n');
else
figure('Name','EEG sensors');
EEGCHAN = ctf_channel_select(ctf,'eeg');
plot(ctf.setup.time_msec(TIME_index),data(TIME_index,EEGCHAN))
axis tight
end
case 'meg',
if isempty(CHAN),
fprintf('...no meg sensors\n');
else
figure('Name','MEG sensors');
plot(ctf.setup.time_msec(TIME_index),data(TIME_index,CHAN))
axis tight
end
case 'eeg',
if isempty(CHAN),
fprintf('...no eeg sensors\n');
else
figure('Name','EEG sensors');
plot(ctf.setup.time_msec(TIME_index),data(TIME_index,CHAN))
axis tight
end
case 'ref',
if isempty(CHAN),
fprintf('...no ref sensors\n');
else
figure('Name','MEG REF sensors');
plot(ctf.setup.time_msec(TIME_index),data(TIME_index,CHAN))
axis tight
end
case 'others',
if isempty(CHAN),
fprintf('...no other sensors\n');
else
figure('Name','Other sensors');
plot(ctf.setup.time_msec(TIME_index),data(TIME_index,CHAN))
axis tight
end
otherwise
figure;
plot(ctf.setup.time_msec(TIME_index),data(TIME_index,CHAN))
axis tight
end
if exist('crosshair') & Xhair,
crosshair;
end
return