-
Notifications
You must be signed in to change notification settings - Fork 0
/
ctf_channel_plot.m
152 lines (131 loc) · 4.65 KB
/
ctf_channel_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
function [Handles] = ctf_channel_plot(ctf,surf,CHAN,Handles)
% ctf_channel_plot - plot ctf.sensor data
%
% [Handles] = ctf_channel_plot(ctf [,surf][,CHAN][,H])
%
% ctf - a struct returned by ctf_read
% surf - a surface tesselation struct, surf.vertices and surf.faces;
% the default is to create a convex hull of the sensor locations
% CHAN - see ctf_channel_select for options (default, CHAN = 'meg')
%
% Handles - handles struct, eg:
% H.Hf - figure handle to plot into (default, H.Hf = figure;)
% H.Hs - sensor handles
% H.Hp - patch handles
% H.Hl - light handles
%
% All inputs, except ctf, are optional. An empty input [] will be replaced
% with the default.
%
% <>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
% < >
% < 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:26 $
% 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: 05/2004, Darren.Weber_at_radiology.ucsf.edu
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if ~exist('ctf','var'), error('no ctf input'); end
if isempty(ctf), error('no ctf input'); end
% check the figure handle for initialization
if ~exist('Handles','var'),
Handles.Hf = figure;
colordef(Handles.Hf,'white')
end
if isempty(Handles),
Handles.Hf = figure;
colordef(Handles.Hf,'white')
end
if ~isfield(Handles,'Hf'),
Handles.Hf = figure;
colordef(Handles.Hf,'white')
end
if isempty(Handles.Hf),
Handles.Hf = figure;
colordef(Handles.Hf,'white')
end
% check other fields of the Handles
if ~isfield(Handles,'Hp'), Handles.Hp = {}; end
if ~isfield(Handles,'Hs'), Handles.Hs = {}; end
if ~isfield(Handles,'Hl'), Handles.Hl = []; end
usesurf = 1; % assume input surf
if ~exist('surf','var'), usesurf = 0; end
if isempty(surf), usesurf = 0; end
if ~exist('CHAN','var'), CHAN = 'meg'; end
if CHAN,
% Get the channel indices to plot
[CHAN,type] = ctf_channel_select(ctf,CHAN);
sensors.vertices = zeros(length(CHAN),3);
for i = 1:length(CHAN),
sensors.vertices(i,:) = ctf.sensor.info(CHAN(i)).location(:,1)';
end
end
ver = '$Revision: 1.1 $ $Date: 2009-01-30 03:49:26 $';
fprintf('\nCTF_CHANNEL_PLOT [v %s]\n',ver(11:15));
figure(Handles.Hf); hold on
set(Handles.Hf,'Renderer','OpenGL')
if CHAN,
% plot the sensor cloud
Handles.Hs{end+1} = scatter3(sensors.vertices(:,1),...
sensors.vertices(:,2),...
sensors.vertices(:,3),...
50,'bo','filled');
end
if ~usesurf,
% nothing provided, assume we want
% to create a convex hull of the sensors
surf.vertices = sensors.vertices;
surf.faces = convhulln(surf.vertices);
end
Nvert = length(surf.vertices);
% assume surface is a skin color
skinRGB = [1, 0.85, 0.75];
vertexColors = ones(Nvert,1) * skinRGB;
% plot the surface patch (eg, sensors or scalp)
Handles.Hp{end+1} = patch('faces',surf.faces,'vertices',surf.vertices,...
'facecolor','interp',...
'FaceVertexCData', vertexColors,...
'edgecolor', 'none',...
'facealpha',0.5);
% view parameters
view([40,20])
daspect([1 1 1])
axis equal
axis tight
grid on
lighting phong
material dull
% only add a light if it doesn't exist already
if ~isfield(Handles,'Hl'),
Handles.Hl = camlight;
elseif isempty(Handles.Hl),
Handles.Hl = camlight;
end
% The CTF MEG Head Coordinate System is
% +X anterior, +Y left, +Z superior
xlabel('x (cm)')
ylabel('y (cm)')
zlabel('z (cm)')
rotate3d on
return