From 55b4e77f8c1e38af8fe1408917834fc338b9d338 Mon Sep 17 00:00:00 2001 From: Chadwick Boulay Date: Mon, 29 Feb 2016 20:36:50 -0500 Subject: [PATCH 1/2] Copied files over from eeglab plugin download and modified to suit new structure. --- Matlab/eeg_load_xdf.m | 12 +++++++++--- Matlab/eegplugin_xdfimport.m | 2 +- Matlab/xdf/load_xdf.m | 7 ++++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Matlab/eeg_load_xdf.m b/Matlab/eeg_load_xdf.m index 1139b75..f344bd5 100644 --- a/Matlab/eeg_load_xdf.m +++ b/Matlab/eeg_load_xdf.m @@ -69,7 +69,7 @@ if args.effective_rate && isfinite(stream.info.effective_srate) && stream.info.effective_srate>0 raw.srate = stream.info.effective_srate; else - raw.srate = str2num(stream.info.nominal_srate); + raw.srate = str2num(stream.info.nominal_srate); %#ok end raw.xmin = 0; raw.xmax = (raw.pnts-1)/raw.srate; @@ -108,19 +108,24 @@ % 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+raw.srate*(streams{s}.time_stamps(e)-stream.time_stamps(1)); + 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+raw.srate*(streams{s}.time_stamps(e)-stream.time_stamps(1)); + event(end).latency = 1+srate*(streams{s}.time_stamps(e)-stream.time_stamps(1)); event(end).duration = 1; end end @@ -131,6 +136,7 @@ end raw.event = event; + % etc... raw.etc.desc = stream.info.desc; raw.etc.info = rmfield(stream.info,'desc'); diff --git a/Matlab/eegplugin_xdfimport.m b/Matlab/eegplugin_xdfimport.m index 0747926..39a68bc 100644 --- a/Matlab/eegplugin_xdfimport.m +++ b/Matlab/eegplugin_xdfimport.m @@ -45,7 +45,7 @@ function vers = eegplugin_xdfimport(fig, trystrs, catchstrs) - vers = 'xdfimport1.11b'; + vers = 'xdfimport1.12'; if nargin < 3 error('eegplugin_xdfimport requires 3 arguments'); diff --git a/Matlab/xdf/load_xdf.m b/Matlab/xdf/load_xdf.m index 5153b08..857a95b 100644 --- a/Matlab/xdf/load_xdf.m +++ b/Matlab/xdf/load_xdf.m @@ -145,8 +145,8 @@ % Contains portions of xml2struct Copyright (c) 2010, Wouter Falkena, % ASTI, TUDelft, 21-08-2010 % -% version 1.11 -LIBVERSION = '1.11'; +% version 1.12 +LIBVERSION = '1.12'; % check inputs opts = cell2struct(varargin(2:2:end),varargin(1:2:end),2); @@ -227,6 +227,7 @@ end end + % ====================== % === parse the file === % ====================== @@ -502,7 +503,7 @@ segments(r).t_begin = temp(k).time_stamps(range(1)); segments(r).t_end = temp(k).time_stamps(range(2)); segments(r).duration = segments(r).t_end - segments(r).t_begin; - segments(r).effective_srate = (segments(r).num_samples-1)/ segments(r).duration; + segments(r).effective_srate = segments(r).num_samples / segments(r).duration; end % calculate the weighted mean sampling rate over all segments From f4b6915dda604620d2e71fcfa8b956a9c8539310 Mon Sep 17 00:00:00 2001 From: Chadwick Boulay Date: Mon, 29 Feb 2016 22:07:03 -0500 Subject: [PATCH 2/2] Re-added effective_srate fix from 1.11 that was missing in 1.12 --- Matlab/xdf/load_xdf.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Matlab/xdf/load_xdf.m b/Matlab/xdf/load_xdf.m index 857a95b..162c532 100644 --- a/Matlab/xdf/load_xdf.m +++ b/Matlab/xdf/load_xdf.m @@ -503,7 +503,7 @@ segments(r).t_begin = temp(k).time_stamps(range(1)); segments(r).t_end = temp(k).time_stamps(range(2)); segments(r).duration = segments(r).t_end - segments(r).t_begin; - segments(r).effective_srate = segments(r).num_samples / segments(r).duration; + segments(r).effective_srate = (segments(r).num_samples-1)/ segments(r).duration; end % calculate the weighted mean sampling rate over all segments