-
Notifications
You must be signed in to change notification settings - Fork 6
/
voltageHistogramAnalysis.m
123 lines (119 loc) · 3.93 KB
/
voltageHistogramAnalysis.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
function areas = voltageHistogramAnalysis( userdata, varargin )
% VOLTAGEHISTOGRAMANALYSIS Performs voltage histogram analysis
%
% Usage:
% areas = voltageHistogramAnalysis( userdata, varargin )
% Where:
% userdata - see importcarto_mem
% areas - he chamber areas within each of the voltage thresholds
%
% VOLTAGEHISTOGRAMANALYSIS accepts the following parameter-value pairs
% 'method' {'map'}|'egm'
% 'type' {'bip'}|'uni'
% 'threshold' n x 2 matrix of threshold values, default:
% [ 0.01 0.11; 0.11 0.21; 0.21 0.30; 0.30 0.40; 0.40 0.50 ]
% 'plot' {false} | true
% 'colors' {colorBrewer colors r, y, g, b, p}|
%
% VOLTAGEHISTOGRAMANALYSIS displays a histogram of voltages coloured according
% to voltages, threshold. If 'method' is set to 'egm' then the bipolar
% voltage is first interpolated from the bipolar electrogram data (stored
% in userdata.electric). If 'type' is set to 'uni' then unipolar voltages
% are used.
%
% Author: Steven Williams (2020) (Copyright)
% SPDX-License-Identifier: Apache-2.0
%
% Modifications -
%
% Info on Code Testing:
% ---------------------------------------------------------------
% test code
% ---------------------------------------------------------------
%
% ---------------------------------------------------------------
% code
% ---------------------------------------------------------------
nStandardArgs = 1; % UPDATE VALUE
method = 'map';
type = 'bip';
threshold = [ 0.01 0.11; 0.11 0.21; 0.21 0.30; 0.30 0.40; 0.40 0.50 ];
colors = [colorBrewer('r'); colorBrewer('y'); colorBrewer('g'); colorBrewer('b'); colorBrewer('p')];
plot = false;
if nargin > nStandardArgs
for i = 1:2:nargin-nStandardArgs
switch varargin{i}
case 'method'
method = varargin{i+1};
case 'type'
type = varargin{i+1};
case 'threshold'
threshold = varargin{i+1};
case 'plot'
plot = varargin{i+1};
case 'colors'
colors = varargin{i+1};
end
end
end
% TODO: check format of input values for each parameter are correct
% TODO: separate histogram analysis code so that it can be re-used for
% other purposes e.g. local activation time or conduction velocity
for i = 1:size(threshold, 1)
[areas(i) voltages, ~, tr2{i}] = getLowVoltageArea(userdata ...
, 'threshold', threshold(i,:) ...
, 'method', method ...
, 'type', type ...
);
end
if plot
% plot the histogram
hold on;
% plot bars for each of the thresholds specified
for i = 1:size(threshold, 1)
y1 = 0;
y2 = areas(i);
x1 = threshold(i,1);
x2 = threshold(i,2);
patch([x1 x1 x2 x2],[y1 y2 y2 y1], colors(i,:) ...
, 'edgecolor', 'none' ...
);
end
% calculate the number of other bars we need
meanWidth = mean(range(threshold,2));
remainingVoltages = voltages(voltages>threshold(end));
nbins = floor(range(remainingVoltages) / meanWidth);
for i = 1:nbins
vstart = threshold(end)+(i-1)*meanWidth;
vend = threshold(end)+i*meanWidth;
area = getLowVoltageArea(userdata ...
, 'threshold', [vstart vend] ...
, 'method', method ...
, 'type', type ...
);
y1 = 0;
y2 = area;
x1 = vstart;
x2 = vend;
patch([x1 x1 x2 x2],[y1 y2 y2 y1], [.5 .5 .5] ...
, 'edgecolor', 'none' ...
);
end
xlabel('Voltage (mV)');
ylabel('Area (cm^2)');
set(gcf, 'color', 'w')
set(gca, 'fontsize', 14);
% plot the surface
figure
drawMap(userdata, 'type', 'none', 'orientation', 'pa');
hold on
for i = 1:size(threshold, 1)
if ~isempty(tr2{i})
trisurf(tr2{i} ...
, 'facecolor', colors(i,:) ...
, 'edgecolor', 'none' ...
, 'SpecularStrength', 0 ...
);
end
end
end