This thread is to document timing considerations in the MEG, primarily delays for various stimuli and devices. It will likely be a work in progress for a while.
Audio
Delays: 6.2 ms from the computer, 5.0 ms from the speakers & ear tubes
In PsychToolbox (Matlab), there appears to be a 6.2 ms delay between the requested presentation time of a sound, and the actual playback start time reported by PTB. This would depend on the details of the task code and should be verified, but gives an idea on what to expect for delays inside the computer (Matlab, Windows, audio drivers).
Once the sound is output, there is a further 5 ms delay for the sound to reach the ears. This was measured by recording the original sound in a MEG analog channel (which is the recommended approach to measure onset times for all sounds), and using a microphone to record the sound at the tip of the ear tubes, also in an analog channel. While the latter is noisy, averaging trials and using cross-correlation gives a clear result: a difference of 12 samples at 2400 Hz = 5 ms. Note that the signals are flipped with respect to each other in this speaker/microphone setup.
Video
Delays: 8.33 ms (at 120 Hz frame rate) after pixel mode event marker
The PROPixx projector has a “pixel mode” which sends the color values from the top left pixel to a digital input channel in the MEG. These codes are sent exactly 1 frame (8.33 ms @ 120 Hz) before appearing on the projector screen. For visual stimuli, it is recommended to encode information in this top left pixel to record their onsets, e.g. the simplest is to add a 1-pixel wide white box to the visual stim(s) of interest, and black at every other time. This replaces the use of a photodiode, but we have to account for the constant 1 frame delay.
Digital channels and triggers
Delays: about 4 samples (1.7 ms at 2400 Hz) earlier than all analog channels, practically always safely ignored
All analog channels (MEG, EEG, ADC) are filtered in the hardware to prevent aliasing, when going from the initial high sampling rate to the one selected for the recording (we typically use 2400 Hz). This causes a group delay of about 4 samples. While this delay is complicated and varies for different frequencies, it is small and practically never of concern. Digital channels are not filtered but instead apply a “bit-wise or” operation when down-sampling, such that all signals are kept even if they are only present for a fraction of a sample.
Similarly, triggers defined in the acquisition software configuration by a threshold on an analog channel, e.g. audio recorded on an ADC channel, are detected early in the processing, before down-sampling occurs, and are thus also ahead of the analog signals by about 4 samples. This is easily seen by comparing the trigger time with the moment the signal (recorded in an analog channel) actually crosses the defined threshold for the trigger.