From d78487b0b507de60ec7055a062294138b15790d6 Mon Sep 17 00:00:00 2001 From: cll008 Date: Wed, 14 Aug 2019 10:12:39 -0700 Subject: [PATCH 1/3] Set effective_srate to 0 for empty streams when JitterRemoval is off --- load_xdf.m | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/load_xdf.m b/load_xdf.m index 6573dab..0ac2340 100644 --- a/load_xdf.m +++ b/load_xdf.m @@ -566,7 +566,12 @@ else % calculate effective sampling rate for k=1:length(temp) - temp(k).effective_srate = (length(temp(k).time_stamps) - 1) / (temp(k).time_stamps(end) - temp(k).time_stamps(1)); end + if ~isempty(temp(k).time_stamps) + temp(k).effective_srate = (length(temp(k).time_stamps) - 1) / (temp(k).time_stamps(end) - temp(k).time_stamps(1)); + else + temp(k).effective_srate = 0; + end + end end % copy the information into the output From 74c2466ca56ac5adb4025c431422c55fc97823ee Mon Sep 17 00:00:00 2001 From: cll008 Date: Wed, 14 Aug 2019 14:10:02 -0700 Subject: [PATCH 2/3] Add warning when nominal_srate <= 0 copied from @jfrey-xx --- load_xdf.m | 1 + 1 file changed, 1 insertion(+) diff --git a/load_xdf.m b/load_xdf.m index 0ac2340..37e9efe 100644 --- a/load_xdf.m +++ b/load_xdf.m @@ -351,6 +351,7 @@ if temp(id).srate > 0 temp(id).sampling_interval = 1/temp(id).srate; else + warning('Nominal sampling rate of stream %s is 0. Calculated effective sampling rate might not be meaningful, relying on this rate is not recommended.', header.info.name); temp(id).sampling_interval = 0; end % fread parsing format for data values From a1433e8027cc1090b7cad4d1c36b6928af0ed6cd Mon Sep 17 00:00:00 2001 From: cll008 Date: Mon, 26 Aug 2019 15:39:58 -0700 Subject: [PATCH 3/3] Transfer effective_srate to streams.info when JitterRemoval is off --- load_xdf.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/load_xdf.m b/load_xdf.m index 37e9efe..389e595 100644 --- a/load_xdf.m +++ b/load_xdf.m @@ -572,6 +572,8 @@ else temp(k).effective_srate = 0; end + % transfer the information into the output structs + streams{k}.info.effective_srate = temp(k).effective_srate; end end