sccn / lsl_archived

Multi-modal time-synched data transmission over local network
242 stars 134 forks source link

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

Closed sahin-ozsoy closed 6 years ago

sahin-ozsoy commented 6 years ago

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".

dmedine commented 6 years ago

Yes. That is true. However, if your clock sync is timing out all the time, you can't synchronize your data anyway so there would be no need to run 'HandleClockSynchronization', true.

One feature that would be nice in xdf would be the ability to set 'HandleClockSynchronization' and 'HandleJitterRemoval' on a stream by stream basis. In that sense, this is an xdf issue, not an LSL issue.

Also, if time_correction() is timing out /every/ time, you either have the timeout set to some very (too) small value in your config file, or your network is super buggy and you aren't pushing the data in a timely fashion either.

On 8/7/2018 2:09 PM, sahin-ozsoy wrote:

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 https://user-images.githubusercontent.com/23072504/43774844-8a994af4-9a18-11e8-85d5-6f4a4774fc3c.png

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".

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sccn/labstreaminglayer/issues/329, or mute the thread https://github.com/notifications/unsubscribe-auth/ADch7uwD03Tz_sRNGPabHqG7KWtPPv_yks5uOYNigaJpZM4VyCU0.

sahin-ozsoy commented 6 years ago

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.

dmedine commented 6 years ago

Yes. I agree that this can be improved, but at the very least load_xdf should shout a very loud warning whenever this happens. It is a strong indication that the data is seriously messed up.

Again, this is an issue with xdf not LSL. I am going to close this issue. If you'd like to continue this conversation, I propose moving it to the xdf repository.

On 8/7/2018 4:35 PM, sahin-ozsoy wrote:

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.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sccn/labstreaminglayer/issues/329#issuecomment-411078874, or mute the thread https://github.com/notifications/unsubscribe-auth/ADch7qGZVldKSbL4wO7IYbZ4zrT4GhOwks5uOaW-gaJpZM4VyCU0.

sahin-ozsoy commented 6 years ago

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.