Skip to content

Commit 7f27871

Browse files
authored
Merge pull request #2 from cll008/master
Set effective_srate to 0 for empty streams when JitterRemoval is off
2 parents 772a592 + a1433e8 commit 7f27871

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

load_xdf.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@
356356
if temp(id).srate > 0
357357
temp(id).sampling_interval = 1/temp(id).srate;
358358
else
359+
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);
359360
temp(id).sampling_interval = 0;
360361
end
361362
% fread parsing format for data values
@@ -571,7 +572,14 @@
571572
else
572573
% calculate effective sampling rate
573574
for k=1:length(temp)
574-
temp(k).effective_srate = (length(temp(k).time_stamps) - 1) / (temp(k).time_stamps(end) - temp(k).time_stamps(1)); end
575+
if ~isempty(temp(k).time_stamps)
576+
temp(k).effective_srate = (length(temp(k).time_stamps) - 1) / (temp(k).time_stamps(end) - temp(k).time_stamps(1));
577+
else
578+
temp(k).effective_srate = 0;
579+
end
580+
% transfer the information into the output structs
581+
streams{k}.info.effective_srate = temp(k).effective_srate;
582+
end
575583
end
576584

577585
% copy the information into the output

0 commit comments

Comments
 (0)