-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgetAnatomicalStructures.m
95 lines (85 loc) · 2.65 KB
/
getAnatomicalStructures.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
function [FF, l, a, tr] = getAnatomicalStructures( userdata, varargin )
% GETANATOMICALSTRUCTURES Returns the free boundaries (anatomical
% structures) described in userdata
%
% Usage:
% [FF, l, a, tr] = getAnatomicalStructures( userdata, varargin )
% Where:
% userdata - see importcarto_mem
% FF - see TriRep/freeBoundary, cell array
% l - array of lengths (perimeters) of each anatomical structure
% a - an array of areas of each anatomical structure
% tr - cell array of triangulations of each anatomical structure
%
% GETANATOMICALSTRUCTURES accepts the following parameter-value pairs
% 'plot' {false}|true
%
% GETANATOMICALSTRUCTURES identifies all the anatomical structures of a
% given data set. Anatomical structures are boundary regions that have been
% added to an anatomical model in the clinical mapping system. For example,
% with respect of left atrial ablation, anatomical structures may represent
% the pulmonary vein ostia, mitral valve annulus or left atrial appendage
% ostium.
%
% Author: Steven Williams (2020) (Copyright)
% SPDX-License-Identifier: Apache-2.0
%
% Modifications -
%
% See also FREEBOUNDARYPOINTS
%
% Info on Code Testing:
% ---------------------------------------------------------------
% test code
% ---------------------------------------------------------------
%
% ---------------------------------------------------------------
% code
% ---------------------------------------------------------------
% parse input
nStandardArgs = 1; % UPDATE VALUE
plot = false;
if nargin > nStandardArgs
for i = 1:2:nargin-nStandardArgs
switch varargin{i}
case 'plot'
plot = varargin{i+1};
end
end
end
% get a trirep
trMesh = getMesh(userdata);
% get all the free boundaries
[ FF, l ] = freeBoundaries( trMesh );
for i = 1:numel(FF)
% get the points of this boundary
[coords] = freeBoundaryPoints(FF{i}, trMesh);
% find the centre of the points
centre = nanmean(coords, 1);
% create a triRep of the boundary
X = [centre; coords];
numpts = size(X, 1);
A = ones(numpts-1,1);
B = [2:numpts]';
C = [[3:numpts]' ; 2];
TRI = [A B C];
tr{i} = TriRep(TRI, X(:,1), X(:,2), X(:,3));
% output values
a(i) = sum(triarea(tr{i}));
disp(['Perimeter is: ' num2str(l(i)) ' | Area is: ' num2str(a(i))]);
end
% plot
if plot
drawFreeBoundaries(FF, trMesh);
hold on
hS = trisurf(userdata.surface.triRep);
set(hS ...
, 'facecolor', [.5 .5 .5] ...
, 'edgecolor', 'none' ...
, 'facealpha', .2 ...
);
set(gcf, 'color', 'w' ...
);
axis off;
end
end