-
Notifications
You must be signed in to change notification settings - Fork 1
/
ElectrodeLocation.m
69 lines (57 loc) · 2.64 KB
/
ElectrodeLocation.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
classdef ElectrodeLocation < PointSet
%ElectrodeLocation Electrode Location in 3D Space
% See also PointSet
properties
DefinitionIdentifier %Identifier connecting the location to the Electrode Definiton
end
methods
function obj = ElectrodeLocation()
obj.DefinitionIdentifier=zeros(1,0,'uint32');
end
function electrodeNames= GetElectrodeNames(obj,eDef)
%GetElectrodeNames - returns the names of the electrodes based
%on provided electrode Definition
% eDef - ElectrodeDefiniton object
% see also ElectrodeDefinition
if(~isObjectTypeOf(eDef,'ElectrodeDefinition'))
error("Input is expected to be of type ElectrodeDefinition");
end
electrodeNames=cell(size(obj.DefinitionIdentifier,1),1);
idx=1;
order=unique(obj.DefinitionIdentifier,'stable');
for i=1:length(order)
for ii=1:eDef.Definition(order(i)).NElectrodes
electrodeNames{idx}=[eDef.Definition(order(i)).Name num2str(ii)];
idx=idx+1;
end
end
end
function RemoveWithIdentifier(obj, identifier)
% RemoveWithIdentifier - Remove Locations based on the
% Identifier
obj.Location(obj.DefinitionIdentifier == identifier,:)=[];
obj.DefinitionIdentifier(obj.DefinitionIdentifier == identifier)=[];
obj.Label(obj.DefinitionIdentifier == identifier)=[];
obj.DeleteAnnotations(find(obj.DefinitionIdentifier == identifier));
end
function elLocs=GetWithIdentifier(obj,identifier)
% GetWithIdentifier - Return all locations for a specific
% Electrode Definition Identifier
elLocs=obj.Location(obj.DefinitionIdentifier==identifier,:);
end
function AddWithIdentifier(obj,identifier,location)
% AddWithIdentifier - Adds in new locations with a specific
% identifier - Identifier to connect an electrode location to a
% specific electrode definition
% location - all locations corresponding to the identifier as
% (n x3 ) vector
dim=size(location);
if(dim(1)== 3 && dim(2)~= 3)
location=location';
end
obj.DefinitionIdentifier(end+1:end+dim(1))=identifier*ones(dim(1),1);
obj.Location(end+1:end+dim(1),:)=location;
obj.Label(end+1:end+dim(1))={''};
end
end
end