-
Notifications
You must be signed in to change notification settings - Fork 3
/
pop_MEF3.m
48 lines (40 loc) · 1.27 KB
/
pop_MEF3.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
% pop_MEF3 - import MEF file to EEGLAB structure.
%
% Usage:
% EEG = pop_MEF3; % pop up menu to select file
% EEG = pop_MEF3(folder); % import folder
%
% Input:
% folder - foldername for the MEF data
%
% Output:
% EEG - EEGLAB structure
function [EEG, com] = pop_MEF3(fileName)
com = '';
if nargin < 1
% pop up window
% -------------
fileName = uigetdir('*', 'Select a MEF3 folder');
if isempty(fileName), return; end
end
[metadata, signaldata] = readMef3(fileName);
EEG = eeg_emptyset;
EEG.data = signaldata;
EEG.nbchan = size(EEG.data,1);
EEG.pnts = size(EEG.data,2);
if isfield(metadata, 'time_series_channels')
for iChan = 1:length(metadata.time_series_channels)
if isfield(metadata.time_series_channels(iChan), 'name')
EEG.chanlocs(iChan).labels = metadata.time_series_channels(iChan).name;
end
end
end
if isfield(metadata, 'time_series_metadata')
sections = fieldnames(metadata.time_series_metadata);
for iSection = 1:length(sections)
if isfield(metadata.time_series_metadata.(sections{iSection}), 'sampling_frequency')
EEG.srate = metadata.time_series_metadata.(sections{iSection}).sampling_frequency;
end
end
end
com = sprintf('EEG = pop_MEF3(''%s'');', fileName);