Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions eeg_load_xdf.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,8 @@
% chanlocs...
chanlocs = struct();
try
if ~iscell(stream.info.desc.channels.channel)
warning('Channel structure not a cell array (likely a g.tek writer compatibility issue; Using hack to import channel info)');
end
for c=1:length(stream.info.desc.channels.channel)
if iscell(stream.info.desc.channels.channel)
chn = stream.info.desc.channels.channel{c};
else
chn = stream.info.desc.channels.channel(c);
end
chn = stream.info.desc.channels.channel{c};
if isfield(chn,'label')
chanlocs(c).labels = chn.label; end
if isfield(chn,'type') && strcmpi(chn.type, 'EEG')
Expand Down Expand Up @@ -130,7 +123,7 @@
% events...
event = [];
for s=1:length(streams)
if (strcmp(streams{s}.info.type,'Markers') || strcmp(streams{s}.info.type,'Events')) && ~ismember(streams{s}.info.name,args.exclude_markerstreams)
if (strcmp(streams{s}.info.type,'Markers') || strcmp(streams{s}.info.type,'Events') ) && ~ismember(streams{s}.info.name,args.exclude_markerstreams)
try
s_events = struct('type', '', 'latency', [], 'duration', num2cell(ones(1, length(streams{s}.time_stamps))));
for e=1:length(streams{s}.time_stamps)
Expand All @@ -146,6 +139,32 @@
disp(['Could not interpret event stream named "' streams{s}.info.name '": ' err.message]);
end
end
% Import non-marker stream as event
% All non-zero elements are considered as events
if strcmp(streams{s}.info.name,args.stream_as_event)
try
%
onset_Indices=find(streams{s}.time_series);
disp(['Interpreting all non zero entries as events.']);
s_events = struct('type', '', 'latency', [], 'duration', num2cell(ones(1, length(onset_Indices))));
event_index=1;
for e=onset_Indices
if iscell(streams{s}.time_series)
s_events(event_index).type = streams{s}.time_series{e};
else
s_events(event_index).type = num2str(streams{s}.time_series(e));
end
[~, s_events(event_index).latency] = min(abs(stream.time_stamps - streams{s}.time_stamps(e)));
event_index=event_index+1;
end
event = [event, s_events]; %#ok<AGROW>


catch err
disp(['Problems reading AFEx data "' streams{s}.info.name '": ' err.message]);

end
end
end
raw.event = event;

Expand Down
7 changes: 6 additions & 1 deletion pop_loadxdf.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,14 @@

% popup window parameters
% -----------------------
uigeom = { [1 0.5] [1 0.5] [1 0.5] 0.13};
uigeom = { [1 0.5] [1 0.5] [1 0.5] [1 0.5] 0.13};
uilist = { { 'style' 'text' 'string' 'Stream name to import:' } ...
{ 'style' 'edit' 'string' '' } ...
{ 'style' 'text' 'string' 'Stream type to import:' } ...
{ 'style' 'edit' 'string' 'EEG' } ...
{ 'style' 'text' 'string' 'Exclude marker streams(s):' } ...
{ 'style' 'edit' 'string' '{}' } ...
{ 'style' 'text' 'string' 'Stream name to import as event:' } ...
{ 'style' 'edit' 'string' '{}' } {}};

result = inputgui(uigeom, uilist, 'pophelp(''pop_loadxdf'')', 'Load an XDF file');
Expand All @@ -93,6 +95,9 @@
options = [options ', ''streamtype'', ''' result{2} '''']; end
if ~isempty(result{3}),
options = [options ', ''exclude_markerstreams'', ' result{3} '']; end
if ~isempty(result{4}),
options = [options ', ''stream_as_event'', ''' result{4} '''']; end

else
options = vararg2str(varargin);
end;
Expand Down