Skip to content

Commit

Permalink
eeg_load_xdf: Markers/Events latencies now come from a search of the …
Browse files Browse the repository at this point in the history
…eeg stream latencies, instead of assuming any sampling rate.
  • Loading branch information
cboulay committed May 2, 2018
1 parent 76db08a commit 13f50ef
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions Matlab/eeg_load_xdf.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,27 +108,19 @@

% events...
event = [];
if isfinite(stream.info.effective_srate) && stream.info.effective_srate>0
srate = stream.info.effective_srate;
else
srate = raw.srate;
end
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)
try
if iscell(streams{s}.time_series)
for e=1:length(streams{s}.time_stamps)
event(end+1).type = streams{s}.time_series{e};
event(end).latency = 1+srate*(streams{s}.time_stamps(e)-stream.time_stamps(1));
event(end).duration = 1;
end
else
for e=1:length(streams{s}.time_stamps)
event(end+1).type = num2str(streams{s}.time_series(e));
event(end).latency = 1+srate*(streams{s}.time_stamps(e)-stream.time_stamps(1));
event(end).duration = 1;
s_events = struct('type', '', 'latency', [], 'duration', num2cell(ones(1, length(streams{s}.time_stamps))));
for e=1:length(streams{s}.time_stamps)
if iscell(streams{s}.time_series)
s_events(e).type = streams{s}.time_series{e};
else
s_events(e).type = num2str(streams{s}.time_series(e));
end
[~, s_events(e).latency] = min(abs(stream.time_stamps - streams{s}.time_stamps(e)));
end
event = [event, s_events];
catch err
disp(['Could not interpret event stream named "' streams{s}.info.name '": ' err.message]);
end
Expand All @@ -142,9 +134,6 @@
raw.etc.info = rmfield(stream.info,'desc');





function res = hlp_varargin2struct(args, varargin)
% Convert a list of name-value pairs into a struct with values assigned to names.
% struct = hlp_varargin2struct(Varargin, Defaults)
Expand Down

0 comments on commit 13f50ef

Please sign in to comment.