-
Notifications
You must be signed in to change notification settings - Fork 16
/
mff_importepochs.m
67 lines (60 loc) · 2.55 KB
/
mff_importepochs.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
% mff_importepochs - import information from MFF 'epochs.xml' file
%
% Usage:
% epochs = mff_importepochs(mffFile, version);
%
% Inputs:
% mffFile - filename/foldername for the MFF file
% vesion - file version (optional - default is 3)
%
% Output:
% epochs - 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 continuous = mff_importepochs(mffFile, version)
mff_path;
if nargin < 2
version = 3;
end
if version == 0
divider = 1000;
else
divider = 1;
end
% Create a factory.
mfffactorydelegate = javaObject('com.egi.services.mff.api.LocalMFFFactoryDelegate');
%% create Segment to load time
epochsRType = javaObject('com.egi.services.mff.api.MFFResourceType', javaMethod('valueOf', 'com.egi.services.mff.api.MFFResourceType$MFFResourceTypes', 'kMFF_RT_Epochs'));
catURI = [ mffFile filesep 'epochs.xml' ];
if ~exist(catURI)
catURI = [ mffFile filesep 'epoch.xml' ];
end
epochResource = mfffactorydelegate.openResourceAtURI(catURI, epochsRType);
continuous = [];
if ~isempty(epochResource) && epochResource.loadResource()
epochs = epochResource.getEpochs();
fprintf('Importing epoch.xml ressource: %d data segments\n', epochs.size);
for iEpoch = 1:epochs.size
singleEpoch = epochs.get(iEpoch-1);
continuous(iEpoch).begintime = singleEpoch.getBeginTime()/divider;
continuous(iEpoch).endtime = singleEpoch.getEndTime()/divider;
continuous(iEpoch).firstblock = singleEpoch.getFirstBlock();
continuous(iEpoch).lastblock = singleEpoch.getLastBlock();
% fprintf('Continuous portion Begin Time: %d\n', singleEpoch.getBeginTime());
% fprintf('Continuous portion End Time: %d\n', singleEpoch.getEndTime());
% fprintf('Continuous portion Signal Block This Epoch: %d\n', singleEpoch.getFirstBlock());
% fprintf('Continuous portion Signal Block This Epoch: %d\n', singleEpoch.getLastBlock());
end
end