-
Notifications
You must be signed in to change notification settings - Fork 16
/
mff_importsensorlayout.m
151 lines (143 loc) · 5.06 KB
/
mff_importsensorlayout.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
% mff_importsensorlayout - import information from MFF 'sensorLayout.xml' file
%
% Usage:
% layout = mff_importsensorlayout(mffFile);
%
% Inputs:
% mffFile - filename/foldername for the MFF file
%
% Output:
% layout - Matlab structure containing informations contained in the MFF file.
% This file is part of mffmatlabio.
%
% mffmatlabio is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% mffmatlabio is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with mffmatlabio. If not, see <https://www.gnu.org/licenses/>.
function [layout, rVal] = mff_importsensorlayout(mffFile)
layout = [];
rVal = true;
mff_path;
% Create an MFFFactory object.
mfffactorydelegate = javaObject('com.egi.services.mff.api.LocalMFFFactoryDelegate');
mfffactory = javaObject('com.egi.services.mff.api.MFFFactory', mfffactorydelegate);
% Create Signal object and read in event track file.
sLayoutURI = fullfile(mffFile, 'sensorLayout.xml');
sensorLayoutType = javaObject('com.egi.services.mff.api.MFFResourceType', javaMethod('valueOf', 'com.egi.services.mff.api.MFFResourceType$MFFResourceTypes', 'kMFF_RT_SensorLayout'));
sLayout = mfffactory.openResourceAtURI(sLayoutURI, sensorLayoutType);
%
% layout = [];
% if ~isempty(sLayout)
%
% % Load the Sensor Layout resource.
% if sLayout.loadResource()
% layout.name = char(sLayout.getName());
%
% % Get information about this layout.
% fprintf('Layout Name: ', char(sLayout.getName()));
%
% if ~isempty(sLayout.getOriginalLayout)
% fprintf('Original Layout Name: %s\n', char(sLayout.getOriginalLayout()));
% layout.originallayout = char(sLayout.getOriginalLayout());
% end
%
% sensors = sLayout.getSensors();
% neighbors = sLayout.getNeighbors();
% threads = sLayout.getThreads();%Not CPU threads.
% tilingSets = sLayout.getTilingSets();
%
% % Accessing the sensors.
% if ~isempty(sensors)
%
% for iSensor = 1:sensors.size
% sensor = sensors.get(iSensor-1);
%
% layout.sensor(iSensor).name = char(sensor.getName());
% layout.sensor(iSensor).number = sensor.getNumber();
% layout.sensor(iSensor).X = sensor.getX();
% layout.sensor(iSensor).Y = sensor.getY();
% layout.sensor(iSensor).Z = sensor.getZ();
% layout.sensor(iSensor).type = sensor.getType();
% end
% end
%
% % Sensor Layout threads are the visible connections between sensors on the net.
% if ~isempty(threads)
%
% for iThread = 1:threads.size
% thread = threads.get(iThread-1);
% layout.thread(iThread).first = thread.getFirst();
% layout.thread(iThread).second = thread.getSecond();
% end
%
% end
%
% % Tiling Sets.
% if ~isempty(tilingSets)
%
% for iTilingSet = 1:tilingSets.size
% tilingSet = tilingSets.get(iTilingSet-1);
% fprintf('Tiling Set:----------\n');
% for iSet = 1:tilingSet.size
% layout.tilingSet(iSet).value = tilingSet.get(iSet-1);
% end
% end
%
% end
%
% fprintf('\n');
%
% % Neighbors.
% if ~isempty(neighbors)
%
% for iNeighbor = 1:neighbors.size
% neighbor = neighbors.get(iNeighbor-1);
% layout.neighbors(iNeighbor).channelnumber = neighbor.getChannelNumber();
% channelNumbers = neighbor.getNeighbors();
% for iChan = 1:channelNumbers.size
% layout.neighbors(iNeighbor).value(iChan) = channelNumbers.get(iChan-1);
% end
%
% end
%
% end
%
% else
%
% fprintf('Error: Could not load the Sensor Layout\n');
% rVal = false;
%
% end
%
% else
%
% fprintf('Error: The Sensor Layout resource does not exist\n');
% rVal = false;
% end
% return
variables = ...
{ ...
'Name' 'char' {};
'OriginalLayout' 'char' {} ;
'Sensors' 'array' { 'Name' 'char' {}; 'Number' 'real' {}; 'X' 'real' {}; 'Y' 'real' {}; 'Z' 'real' {}; 'Type' 'real' {}; 'Identifier' 'real' {} };
'Threads' 'array' { 'First' 'real' {}; 'Second' 'real' {} };
'TilingSets' 'array' { '' 'array' {} };
'Neighbors' 'array' { 'ChannelNumber' 'real' {}; 'Neighbors' 'array' {} } };
layout = [];
if ~isempty(sLayout)
try
if sLayout.loadResource()
layout = mff_getobj(sLayout, variables);
end
catch
disp('Failed to load Layout ressource');
end
end