brain_pipe.preprocessing.brain.trigger.default_drift_correction

default_drift_correction(brain_data, brain_trigger_indices, brain_fs, stimulus_trigger_indices, stimulus_fs)

Correct the drift between the brain response data and the stimulus.

When the brain response data and the stimulus data are not recorded on the same system (i.e. using the same clock), clock drift may cause the brain response data to be misaligned with the stimulus. This function tries to correct for this by interpolating the brain response data to the same length as the stimulus.

Parameters:
  • brain_data (np.ndarray) – The brain response data. The data is expected to be a 2D array of shape (n_channels, n_samples).

  • brain_trigger_indices (np.ndarray) – The indices of the brain response data where the triggers are located. The data is expected to be a 1D array of integers.

  • brain_fs (int) – The sampling frequency of the brain response data.

  • stimulus_trigger_indices (np.ndarray) – The indices of the stimulus data where the triggers are located. The data is expected to be a 1D array of integers.

  • stimulus_fs (int) – The sampling frequency of the stimulus data.

Returns:

The brain response data with the same length as the stimulus data.

Return type:

np.ndarray