sccn / labstreaminglayer

LabStreamingLayer super repository comprising submodules for LSL and associated apps.
Other
522 stars 157 forks source link

Single PC clock offset meaning vs. latency and jitter #108

Closed sunshineinsandiego closed 1 year ago

sunshineinsandiego commented 1 year ago

Hi - My setup has a Cognionics headset and a heart rate monitor connected to the same PC via bluetooth, with both peripherals sending data to an LSL stream that is being recorded by the LabRecorder App on the same PC. Because this is a single PC setup, I am having trouble understanding the clock offset measurements that I'm seeing in my xdf file and how they relate to latency and jitter.

My code to analyze this xdf file is in python so I make use of the pyxdf library.

import pyxdf

# read raw data
in_file = 'baseline.xdf'

data, header = pyxdf.load_xdf(in_file)

# disaggregate streams
for stream in data:
    [stream_name] = stream['info']['name']
    [stream_type] = stream['info']['type']
    if (stream_type == 'ECG'):
        ecg_stream = stream
    elif (stream_type == 'EEG'):
        eeg_stream = stream

When I examine ecg_stream, I see a series of timestamps and clock offsets:

>>> eeg_stream['footer']['info']
{'first_timestamp': ['1386534.7123869'],
             'last_timestamp': ['1387116.712358'],
             'sample_count': ['291008'],
             'clock_offsets': [defaultdict(list,
                          {'offset': [defaultdict(list,
                                        {'time': ['1386540.36854905'],
                                         'value': ['-2.094986848533154e-05']}),
                            defaultdict(list,
                                        {'time': ['1386545.3686529'],
                                         'value': ['-1.600000541657209e-05']}),
                            defaultdict(list,
                                        {'time': ['1386550.3687949'],
                                         'value': ['-2.410006709396839e-05']}),
 ...
                            defaultdict(list,
                                        {'time': ['1386575.37059335'],
                                         'value': ['-2.505001612007618e-05']}),
...

I can also see a time_series of what I assume is the time at which each sample is received:

>>> eeg_stream['time_series']
array([[ 7.6612516e+04, -1.0331230e+03, -1.2857312e+05, ...,
         1.1788505e+06,  9.0000000e+00,  0.0000000e+00],
       [ 7.6611164e+04, -1.0314032e+03, -1.2857277e+05, ...,
         1.1788505e+06,  1.0000000e+01,  0.0000000e+00],...

After reading the FAQs and the Time Synchronization page, I still have the following questions.

Thanks!

cboulay commented 1 year ago

Keep it in the other issue. https://github.com/xdf-modules/pyxdf/issues/92