Skip to content

Commit 53f44af

Browse files
ENH - added initial support for mega_neurone EEG format, see http://bugzilla.fieldtriptoolbox.org/show_bug.cgi?id=3126. The actual reading of header, data and events still needs to be added, but it contains the placeholders.
1 parent ae7a47b commit 53f44af

20 files changed

+1209
-14
lines changed
Binary file not shown.

external/neurone/Version History.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
NeurOne to EEGLAB data import plugin
2+
Mega Electronics
3+
4+
Version 1.0.3.4 (2016-06-17)
5+
- Bug fix in readneuroneevents.m: wrong file ID "fileIdEvents" fixed.
6+
- New feature: Support for events.bin revisions up to 6.
7+
8+
Version 1.0.3.3 (2015-05-28)
9+
- New feature: Support for events.bin revisions up to 4.
10+
11+
Version 1.0.3.2 (2013-04-04)
12+
- New feature: A warning is displayed instead of an error when an unknown filetype revision is found.
13+
14+
Version 1.0.3.1 (2012-06-18)
15+
- New feature: The reader is now able to read measurements with events.bin revision up to 2.
16+
17+
Version 1.0.3.0 (2012-01-13)
18+
- First release
19+
20+
Version 1.0.2.0 (2011-12-22)
21+
- Modifications in 'readneuronedata.m'. When all channels are to be read, the function
22+
will read the binary data without a loop to shorten the processing time.
23+
- The numerical data is stored as double-precision floating point (double) by default.
24+
25+
Version 1.0.1.2 (2011-12-21)
26+
- Fixed an error which occurred when the numerical data was divided into
27+
multiple binary files.
28+
- Added a progress indicator in the readneuronedata function.
29+
30+
Version 1.0.1.1 (2011-12-11)
31+
- Improved event readability. See help readneuroneevents for the new event structure.
32+
- readneuronedata.m re-created so that one channel will be read at a time.
33+
- Updated all m-file headers.
34+
- Fixed some other minor errors.
35+
36+
Version 1.0.1.0 (2011-11-28)
37+
- First version of the plugin.

external/neurone/eegplugin_neurone.m

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
% eegplugin_neurone() - EEGLAB plugin to import data from a NeurOne device.
2+
%
3+
% Usage:
4+
% >> eegplugin_neurone(fig,try_strings,catch_strings)
5+
%
6+
% Inputs:
7+
% fig - [integer] handle to EEGLAB figure
8+
% try_strings - [struct] "try" strings for menu callbacks.
9+
% catch_strings - [struct] "catch" strings for menu callbacks.
10+
%
11+
% NeurOne data import plugin consists of the following files:
12+
% pop_readneurone.m
13+
% guireadneurone.m
14+
% guireadneurone.fig
15+
% readneurone.m
16+
% readneuronedata.m
17+
% readneuroneevents.m
18+
% neurone_logo.png
19+
% mega_gradient_edit.png
20+
%
21+
% This plugin was created according to the instructions provided by the
22+
% creators of EEGLAB. These instructions can be found e.g. from the website:
23+
% http://sccn.ucsd.edu/wiki/A07:_Contributing_to_EEGLAB
24+
%
25+
% Current version: 1.0.3.4 (2016-06-17)
26+
% Author: Mega Electronics
27+
28+
function vers = eegplugin_neurone(fig,try_strings,catch_strings)
29+
30+
vers='NeurOne data import 1.0.3.4';
31+
32+
% Check the number of input arguments
33+
if nargin < 3
34+
error('Not enough input arguments.');
35+
end
36+
37+
% Add plugin folder to path
38+
if ~exist('pop_readneurone.m')
39+
path=which('eegplugin_neurone.m');
40+
[path filename]=fileparts(path);
41+
path=[path filesep];
42+
addpath([path version] );
43+
end
44+
45+
% Find the 'Import data' -menu
46+
importmenu=findobj(fig,'tag','import data');
47+
48+
% Construct command
49+
cmd = [try_strings.no_check '[EEG LASTCOM]=pop_readneurone;' catch_strings.new_and_hist];
50+
51+
% Create the menu for NeurOne import
52+
uimenu(importmenu,'label','From a NeurOne file (.ses)',...
53+
'Callback',cmd,'separator','on');
54+

external/neurone/guireadneurone.fig

34.5 KB
Binary file not shown.

external/neurone/guireadneurone.m

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
function varargout = guireadneurone(varargin)
2+
% GUIREADNEURONE Application M-file for guireadneurone.fig
3+
% FIG = GUIREADNEURONE launch guireadneurone GUI.
4+
% GUIREADNEURONE('callback_name', ...) invoke the named callback.
5+
%
6+
% ========================================================================
7+
% NOTE:
8+
% This file is part of the NeurOne data import plugin for EEGLAB.
9+
% ========================================================================
10+
%
11+
% Current version: 1.0.3.4 (2016-06-17)
12+
% Author: Mega Electronics
13+
14+
% If no input arguments are used, the GUI is launched
15+
if nargin == 0
16+
17+
neuroneimportfig = openfig(mfilename,'new');
18+
19+
% Initialize a structure of handles to pass to callbacks.
20+
handles = guihandles(neuroneimportfig);
21+
22+
% Load logos
23+
bgcolor=[0.656 0.758 1.0];
24+
megaLogo=imread('mega_gradient_edit.png','BackgroundColor',bgcolor);
25+
axes(handles.mega_logo);
26+
image(megaLogo)
27+
axis off
28+
axis image
29+
30+
neuroneLogo=imread('neurone_logo.png','BackgroundColor',bgcolor);
31+
axes(handles.neurone_logo);
32+
image(neuroneLogo)
33+
axis off
34+
axis image
35+
36+
% Declare variables
37+
handles.chans='';
38+
handles.sessionPhaseNumber=1;
39+
handles.loadStatus=0;
40+
41+
% Store the structure
42+
guidata(neuroneimportfig, handles)
43+
44+
% Wait for callbacks. 'Ok' or 'Cancel' to continue.
45+
uiwait(neuroneimportfig);
46+
47+
if nargout > 0
48+
varargout{1} = neuroneimportfig;
49+
end
50+
51+
elseif ischar(varargin{1})
52+
53+
try
54+
if (nargout)
55+
[varargout{1:nargout}] = feval(varargin{:});
56+
else
57+
feval(varargin{:});
58+
end
59+
catch
60+
disp(lasterr);
61+
end
62+
63+
end
64+
65+
66+
% --- Executes on button press in cancel_button.
67+
function varargout = cancel_button_Callback(hObject, eventdata, handles)
68+
% hObject handle to cancel_button (see GCBO)
69+
% eventdata reserved - to be defined in a future version of MATLAB
70+
% handles structure with handles and user data (see GUIDATA)
71+
72+
handles.loadStatus=0;
73+
guidata(hObject,handles);
74+
uiresume(handles.guireadneurone_fig)
75+
76+
77+
function varargout = channel_area_Callback(hObject, eventdata, handles)
78+
% hObject handle to channel_area (see GCBO)
79+
% eventdata reserved - to be defined in a future version of MATLAB
80+
% handles structure with handles and user data (see GUIDATA)
81+
82+
% Hints: get(hObject,'String') returns contents of channel_area as text
83+
% str2double(get(hObject,'String')) returns contents of channel_area as a double
84+
85+
handles.chans=get(hObject,'string');
86+
guidata(hObject,handles);
87+
88+
89+
% --- Executes during object creation, after setting all properties.
90+
function varargout = channel_area_CreateFcn(hObject, eventdata, handles)
91+
% hObject handle to channel_area (see GCBO)
92+
% eventdata reserved - to be defined in a future version of MATLAB
93+
% handles empty - handles not created until after all CreateFcns called
94+
95+
% Hint: edit controls usually have a white background on Windows.
96+
% See ISPC and COMPUTER.
97+
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
98+
set(hObject,'BackgroundColor','white');
99+
end
100+
101+
function varargout = session_area_Callback(hObject, eventdata, handles)
102+
% hObject handle to channel_area (see GCBO)
103+
% eventdata reserved - to be defined in a future version of MATLAB
104+
% handles structure with handles and user data (see GUIDATA)
105+
106+
% Hints: get(h,'String') returns contents of channel_area as text
107+
% str2double(get(hObject,'String')) returns contents of channel_area as a double
108+
109+
handles.sessionPhaseNumber=str2num(get(hObject,'String'));
110+
guidata(hObject,handles);
111+
112+
113+
% --- Executes during object creation, after setting all properties.
114+
function varargout = session_area_CreateFcn(hObject, eventdata, handles)
115+
% hObject handle to channel_area (see GCBO)
116+
% eventdata reserved - to be defined in a future version of MATLAB
117+
% handles empty - handles not created until after all CreateFcns called
118+
119+
% Hint: edit controls usually have a white background on Windows.
120+
% See ISPC and COMPUTER.
121+
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
122+
set(hObject,'BackgroundColor','white');
123+
end
124+
125+
126+
% --- Executes on button press in help_button.
127+
function varargout = help_button_Callback(hObject, eventdata, handles)
128+
% hObject handle to help_button (see GCBO)
129+
% eventdata reserved - to be defined in a future version of MATLAB
130+
% handles structure with handles and user data (see GUIDATA)
131+
132+
pophelp('pop_readneurone.m');
133+
134+
135+
% --- Executes on button press in ok_button.
136+
function varargout = ok_button_Callback(hObject, eventdata, handles)
137+
% hObject handle to ok_button (see GCBO)
138+
% eventdata reserved - to be defined in a future version of MATLAB
139+
% handles structure with handles and user data (see GUIDATA)
140+
141+
handles.loadStatus=1;
142+
guidata(hObject,handles);
143+
uiresume(handles.guireadneurone_fig);
63.6 KB
Loading
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
function xmlStruct = module_read_neurone_xml(xmlfile)
2+
%MODULE_READ_NEURONE_XML Read NeurOne XML-files into structures.
3+
%
4+
% Input : A NeurOne XML file (e.g. Session.xml, Protocol.xml,
5+
% Triggers.xml)
6+
% Output : A structure with the information from the XML-file.
7+
% Example: Session = read_neurone_xml('/data/Session.xml');
8+
% Protocol = read_neurone_xml('/data/Protocol.xml');
9+
% Triggers = read_neurone_xml('/data/Triggers.xml');
10+
%
11+
% Dependencies: none
12+
%
13+
% Module_read_neurone_xml is part of NeurOne Tools for Matlab.
14+
%
15+
% The NeurOne Tools for Matlab consists of the functions:
16+
% module_read_neurone.m, module_read_neurone_data.m,
17+
% module_read_neurone_events.m, module_read_neurone_xml.m
18+
%
19+
% ========================================================================
20+
% COPYRIGHT NOTICE
21+
% ========================================================================
22+
% Copyright 2009, 2010 Andreas Henelius ([email protected])
23+
% Finnish Institute of Occupational Health (http://www.ttl.fi/)
24+
% ========================================================================
25+
% This file is part of NeurOne Tools for Matlab.
26+
%
27+
% NeurOne Tools for Matlab is free software: you can redistribute it
28+
% and/or modify it under the terms of the GNU General Public License as
29+
% published by the Free Software Foundation, either version 3 of the
30+
% License, or (at your option) any later version.
31+
%
32+
% NeurOne Tools for Matlab is distributed in the hope that it will be
33+
% useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
34+
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35+
% GNU General Public License for more details.
36+
%
37+
% You should have received a copy of the GNU General Public License
38+
% along with NeurOne Tools for Matlab.
39+
% If not, see <http://www.gnu.org/licenses/>.
40+
% =======================================================================
41+
42+
%% Read XML-data using the builtin xmlread-function and get all child nodes
43+
% of the root XML-element.
44+
xml = xmlread(xmlfile);
45+
children = xml.getChildNodes;
46+
47+
%% Begin walking through the XML-tree
48+
% We initialise the walk with the children of the xml root element, set level
49+
% at zero and give an empty structure to be filled with data from the xml.
50+
xmlStruct = walkNodes(children, 0, {});
51+
52+
% Recursive function for walking through xml document.
53+
function xmlStruct = walkNodes(node, level, xmlStruct)
54+
if level < 3
55+
if (node.hasChildNodes)
56+
moreChildren = node.getChildNodes;
57+
for i=0:moreChildren.getLength-1
58+
% 'still has child nodes, going on'
59+
nextNode = moreChildren.item(i);
60+
nodeName = char(nextNode.getNodeName);
61+
% Skip "empty" nodes (#text)
62+
if ~strcmpi(nodeName,'#text')
63+
if nextNode.hasChildNodes
64+
% Read node data
65+
nodeData = node2struct(nextNode);
66+
if ~isempty(fieldnames(nodeData))
67+
% If we are at recursion depth 1, use the
68+
% nodeNames for main field names of the
69+
% structure to be returned. Append data to the
70+
% xml-structure and create subfields if the
71+
% field already exists.
72+
if level==1
73+
if ~isfield(xmlStruct, nodeName)
74+
xmlStruct(1).(nodeName) = nodeData;
75+
else
76+
xmlStruct.(nodeName)(end+1) = nodeData;
77+
end
78+
end
79+
end
80+
end
81+
end
82+
% Some childnodes left, recurse to access them.
83+
xmlStruct = walkNodes(moreChildren.item(i), level + 1, xmlStruct);
84+
end
85+
else
86+
% 'no more child nodes'
87+
end
88+
end
89+
end
90+
91+
92+
%% Helper function to return data from a node
93+
function nodeData = node2struct(mainNode)
94+
nodeData = struct();
95+
childNodes = mainNode.getChildNodes;
96+
for n=0:childNodes.getLength-1
97+
childNode = childNodes.item(n) ;
98+
nodeName = char(childNode.getNodeName);
99+
% Skip "empty" nodes (#text)
100+
if ~strcmpi(nodeName,'#text') && isempty(strfind(nodeName,':'))
101+
% If the node has children (i.e. the element has a value),
102+
% return possible data, otherwise return empty string
103+
% if the element has no value.
104+
if childNode.hasChildNodes
105+
nodeData.(nodeName) = char(childNode.getFirstChild.getNodeValue);
106+
else
107+
nodeData.(nodeName) = '';
108+
end
109+
end
110+
end
111+
end
112+
end % end of read_neurone_xml.m

external/neurone/neurone_logo.png

50.3 KB
Loading

0 commit comments

Comments
 (0)