-
Notifications
You must be signed in to change notification settings - Fork 6
/
getElectrogramDuration.m
67 lines (60 loc) · 2.42 KB
/
getElectrogramDuration.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
function egmDuration = getElectrogramDuration( userdata )
% GETELECTROGRAMDURATION Returns the electrogram durations
%
% Usage:
% egmDuration = getElectrogramDuration( userdata )
% Where:
% userdata - see importcarto_mem
% egmDuration - the duration of activation for each electrogram
%
% GETELECTROGRAMDURATION Calculates electrogram durations for each bipolar
% electrogram in userdata. The method is as follows. First, we iterate
% through all the bipolar mapping points in userdata.electric. For each
% mapping point we get the electrogram within the window of interest. We
% apply the non-linear energy operator to this electrogram. We identify the
% earliest and latest activation of the energy operator. We calculate the
% difference and assign that to egmDuration. We also remove any values that
% are not within +/- 2 standard deviations of the mean. This is an
% arbritary cut off but some filtering is necessary to avoid identifying
% noise as continuous activation, for example.
%
% Author: Steven Williams (2020) (Copyright)
% SPDX-License-Identifier: Apache-2.0
%
% Modifications -
%
% Info on Code Testing:
% ---------------------------------------------------------------
% egmDuration = getElectrogramDuration(userdata)
% ---------------------------------------------------------------
%
% ---------------------------------------------------------------
% code
% ---------------------------------------------------------------
iPoint = getMappingPointsWithinWoI(userdata);
egmDuration = [];
for i = 1:numel(userdata.electric.names)
if iPoint(i)
woi = getWindowOfInterest(userdata, 'iegm', i);
reference = getReferenceAnnotation(userdata, 'iegm', i);
electrogram = getEgmsAtPoints(userdata, 'iegm', i, 'egmtype', 'bip', 'reference', 'off');
e = electrogram{1}(reference+woi(1):reference+woi(2));
[~,~,act] = nleo(e', 'adaptive', false, 'threshold', 5E-3);
A = find(act);
if ~isempty(A)
egmDuration(i,1) = A(end) - A(1);
else
warning(['OPENEP/EGMDURATION: No activation identified for point ' num2str(i)]);
egmDuration(i,1) = NaN;
end
end
end
% remove any values that do not fall wthin ±2 standard deviations of the
% mean
m = nanmean(egmDuration);
s = nanstd(egmDuration);
toRemove = false(size(egmDuration));
toRemove(egmDuration<m-2*s) = 1;
toRemove(egmDuration>m+2*s) = 1;
egmDuration(toRemove) = NaN;
end