Hi!
A few years ago, during my PhD, we noticed with colleagues that the audio onset recorded by the MISC channel of our MEG device showed a consistent delay of ~200 ms with the trigger that was sent by Psychtoolbox. As we wanted to assume that the trial onset marks the audio onset, I developed a small Python package called find_delay.
I realized that I never really mentioned it anywhere, so as my PhD is coming to an end, I am writing this message here for posterity. The package basically performs a cross-correlation between two arrays to find where the best match is between the two; on top of that, it offers a range of options allowing to adapt it to different kinds of data, and to plot the results to have a visual confirmation that the delay found is indeed the right one.
We found multiple use cases for it:
- To find the delay between the trigger and the audio onset from the MISC channel, as mentioned earlier
- To synchronize EOG data with eye-tracking data
- To find where multiple excerpts start in a large file
I plan on adding a few updates to it later this year, notably to return a list of top candidates instead of just the best result (which would allow to find multiple occurrences of an excerpt, and to choose between candidates if the audio is very noisy), along with other options than the amplitude envelope alone to find a match (maybe using a pitch or intensity estimation).
In the lab, the package is now part of our MEG processing pipeline, so maybe other users reading this may be interested!
Here are the links to the package:
Documentation: https://find-delay.readthedocs.io/en/latest/
Repository: https://github.com/RomainPastureau/find_delay
PyPI page: https://pypi.org/project/find-delay/