alexandrebarachant / muse-lsl

Python script to stream EEG data from the muse 2016 headset
BSD 3-Clause "New" or "Revised" License
616 stars 182 forks source link

Expose time_func to stream() and allow option to use pylsl timestamps #197

Closed DominiqueMakowski closed 4 months ago

DominiqueMakowski commented 1 year ago

Adds the --lsltime argument to stream() to use pylsllocal_clock() for timestamps instead of Python's time.time() (still the default).

cboulay commented 1 year ago

@alexandrebarachant , I'm sure Dominique didn't want to change the way things work so they opted to keep time.time() as the default, but the default way is incorrect and IMO shouldn't even be an option.

Using LSL's clock is really the only correct option. The only use-case for manually providing a timestamp is when the client knows that the push time (i.e., the moment that push_sample or push_chunk is called) is delayed relative to the sample acquisition time and that delay is known. In this case, the provided timestamp should be the lsl clock with the known delay subtracted: pylsl.local_clock() - known_delay_in_seconds.

If the delay is not constant and is not known precisely, but the device provides its own timestamps and one can access the device clock with low latency, then precise timestamps are still possible. In this case, a transformation between device clock and LSL clock could be calculated (and continuously updated if drift is expected) and applied to the device timestamps for each sample.

lukeinator42 commented 11 months ago

@alexandrebarachant what is the status of getting this pull request merged? It isn't currently possible to use muse-lsl with Lab Recorder and a separate Marker stream as muse-lsl isn't using LSL's clock.

aureateAnatidae commented 5 months ago

@jdpigeon Hey, sorry to bother you, glad to see a maintainer still around, but is this PR being considered? If Dr Makowski isn't around, I could try to polish merge conflicts too, since it seems pretty important.

jdpigeon commented 4 months ago

Huge thanks for this! It's been released now in version 2.3.1 on pypi. It's not enabled by default, but I hear you that it might make sense to do that.

Right now, you can enable it with muselsl stream -lslt