sccn/lsl_archived

load_xdf fails if there are no Clock Synchronization Chunks in the stream

sahin-ozsoy opened this issue · 4 comments

Hi,
I have realized that, the Labrecorder may never record a Clock synchronization chunk into the xdf file, if the time_correction() function timeouts all the time during the acquisition:

image

then, when you try to import the data using load_xdf(), the default HandleClockSynchronization setting is true. And the following code block runs:

try
clock_times = temp(k).clock_times;
clock_values = temp(k).clock_values;
catch
disp(['No clock offsets were available for stream "' streams{k}.info.name '"']);
continue;
end

Here, the temp(k).clock_times and temp(k).clock_values fields are empty but existing fields. Therefore, try block runs with success. But since clock_times and clock_values arrays are empty, robust_fit function fails with a message "matrix must be positive definite".

Understand, But I still think that load_xdf should not fail if there are no clock synchronizations in the xdf file. I believe the try cathc block:

try
clock_times = temp(k).clock_times;
clock_values = temp(k).clock_values;
catch
disp(['No clock offsets were available for stream "' streams{k}.info.name '"']);
continue;
end

is trying to do that. But it will never get into the catch block, because in line 33:
temp(id).clock_times = [];
temp(id).clock_values = [];

Moreover, think of a lsl scenario and there is only one stream with a fixed sampling rate. there is no need for clock synch, therefore there is no need to include clock synch chunks in the xdf file.

OK. Just wanted to point out that load_xdf will never give the warning message (No clock offsets were available for stream). It will instead say "matrix must be positive definite", which will direct the user in the wrong direction, and leave him/her puzzled as to where the issue is.