-
Notifications
You must be signed in to change notification settings - Fork 6
/
drawMap.m
173 lines (159 loc) · 5.21 KB
/
drawMap.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
function hSurf = drawMap(userdata, varargin)
% DRAWMAP plots an OpenEP map
% Usage:
% hSurf = drawMap(userdata)
% hSurf = drawMap(userdata, varargin);
%
% Where:
% hSurf - is a handle to the surface
% userdata - is a Carto data structure
%
% DRAWMAP accepts the following parameter-value pairs
% 'data' {[]} | [d]
% - Where d is a vector of data values and size(d) equals numel(userdata.surface.triRep.X)
% 'type' {'act'} | 'bip' | 'force' | 'uni' | 'none' | 'cv'
% - Specifies type of map - activation, bipolar or unipolar voltage
% 'coloraxis' {[]} | [a b]
% - Where a and b are real numbers. See help colorShell
% 'noLight' {false} | true
% - If set to true no additional light will be drawn. Useful if
% overlaying maps.
% 'usrColorMap' {[]}|cMap
% - If set, this colormap will be used instead of the defaults
% colorbarlocation 'north' | 'south' | 'east' | 'west' | 'northoutside' |
% 'southoutside' | 'eastoutside' | {'westoutside'}
% 'orientation' {'AP'} | 'PA'
% - Specifies the view as AP or PA. LAO, RAO, LL, RL yet to be
% defined
% 'colorfillthreshold' {10} | c
% - Where c is a scalar value; defaulting to 10mm
%
% DRAWMAP is a wrapper function for colorShell.m which allows OpenEP data
% to be plotted.
%
% Author: Steven Williams (2016) (Copyright)
% SPDX-License-Identifier: Apache-2.0
%
% Modifications -
%
% Info on Code Testing:
% ---------------------
% hSurf = drawMap(userdata, 'type', 'act')
% set(hSurf, 'facealpha', .5);
% hSphere = plot3dsphere(userdata.electric.egmSurfX, 'r', 3, 16, 'stepthrough', true)
% ---------------------
% ---------------------------------------------------------------
% code
% ---------------------------------------------------------------
% Parse the input variables
p = inputParser;
p.addRequired('userdata');
p.addParameter('data', [], @isnumeric);
p.addParameter('type', 'act', @ischar);
p.addParameter('coloraxis', [], @isnumeric);
p.addParameter('noLight', false, @isbool);
p.addParameter('usrColorMap', [], @isnumeric);
p.addParameter('colorbarlocation', 'westoutside', @(x)ischar(x) && (strcmpi(x, 'north') ...
|| strcmpi(x, 'south') || strcmpi(x, 'east') || strcmpi(x, 'west') ...
|| strcmpi(x, 'northoutside') || strcmpi(x, 'southoutside') ...
|| strcmpi(x, 'eastoutside') || strcmpi(x, 'westoutside') ...
));
p.addParameter('orientation', 'ap', @ischar);
p.addParameter('colorfillthreshold', 10, @isnumeric);
p.parse(userdata, varargin{:});
inputs = p.Results;
userdata = inputs.userdata;
DATAMANUAL = inputs.data;
type = inputs.type;
coloraxis = inputs.coloraxis;
noLight = inputs.noLight;
usrColorMap = inputs.usrColorMap;
colorbarlocation = inputs.colorbarlocation;
orientation = inputs.orientation;
DISTANCETHRESH = inputs.colorfillthreshold;
if ~any(strcmpi(type, {'act', 'bip', 'force', 'uni', 'none', 'cv'}))
error('DRAWMAP: Invalid parameter-value pair; type must be one of act, bip, force, uni, none')
end
% Draw the surface
hSurf = trisurf(userdata.surface.triRep, 'edgecolor', 'none');
axis equal vis3d
set(hSurf, 'facecolor', [.5 .5 .5]);
% Draw the free boundary, i.e. valve
drawFreeBoundary(userdata.surface.triRep, [0 0 0]);
% Set up variables for colorShell
switch type
case 'act'
DATATYPE = 'activation';
if ~isempty(DATAMANUAL)
DATA = DATAMANUAL;
else
DATA = userdata.surface.act_bip(:,1);
end
case 'bip'
DATATYPE = 'voltage';
if ~isempty(DATAMANUAL)
DATA = DATAMANUAL;
else
DATA = userdata.surface.act_bip(:,2);
end
case 'force'
DATATYPE = 'force';
if ~isempty(DATAMANUAL)
DATA = DATAMANUAL;
else
DATA = userdata.surface.uni_imp_frc(:,3);
end
case 'uni'
DATATYPE = 'voltage';
if ~isempty(DATAMANUAL)
DATA = DATAMANUAL;
else
DATA = userdata.surface.uni_imp_frc(:,1);
end
case 'cv'
DATATYPE = 'cv';
if ~isempty(DATAMANUAL)
DATA = DATAMANUAL;
else
DATA = getConductionVelocity(userdata);
end
end
if ~strcmpi(type, 'none')
if isempty(coloraxis)
t_min = min(DATA);
t_max = max(DATA);
else
t_min = coloraxis(1);
t_max = coloraxis(2);
end
% Call colorShell
if ~all(isnan(DATA))
colorShell(hSurf, userdata.electric.egmSurfX, DATA, DISTANCETHRESH ...
, 'showcolorbar', 'show' ...
, 'coloraxis', [t_min t_max] ...
, 'datatype', DATATYPE ...
, 'interpolation', 'off' ...
, 'colorbarlocation', 'north' ...
, 'usrColorMap', usrColorMap ...
, 'colorbarlocation', colorbarlocation ...
);
else
disp('no data to color the shell with')
end
end
% Adjust the light/material
material dull
if ~noLight
cameraLight;
end
% Adjust the viewpoint
switch lower(orientation)
case 'ap'
set(gca, 'cameraposition', get(gca, 'cameratarget') + [0 0 700])
case 'pa'
set(gca, 'cameraposition', get(gca, 'cameratarget') - [0 0 700])
end
set(gca, 'cameraupvector', [0 1 0]);
% Adjust the appearances
set(gcf, 'color', 'white');
axis off;