bemobil_mne.preproc.process_rigid_body#

bemobil_mne.preproc.process_rigid_body(raw, rb_names=None, lowpass_orient=8.0, lowpass_pos=8.0, lowpass_deriv=24.0, compute_velocity=True, compute_acceleration=True, sfreq_target=None)[source]#

Process rigid body motion capture streams.

For each rigid body found in raw:

  1. Optionally low-pass filter the orientation (and position) signals.

  2. Convert quaternions to Euler angles (ZYX convention = yaw-pitch-roll) if quaternion channels are present. The source quaternion channels are dropped and replaced by Euler angle channels.

  3. Compute the first derivative (velocity) via finite differences, with an optional low-pass filter applied after differentiation.

  4. Compute the second derivative (acceleration) in the same way.

Derivative channels are appended to the returned raw object with the naming scheme <rb>_<type>_vel_<axis> and <rb>_<type>_acc_<axis>, where type is eul or pos so that orientation and position derivatives always have distinct names (e.g. head_eul_vel_x, head_pos_vel_x).

Parameters:
rawmne.io.BaseRaw

Source recording. Motion channels should be of type "misc" (which is the default when XDFLoader imports non-EEG streams).

rb_nameslist of str | None

Rigid body identifiers to process. If None, all identifiers found by find_rigid_bodies() are processed.

lowpass_orientfloat | None

Low-pass cutoff (Hz) applied to orientation channels. None skips this filter.

lowpass_posfloat | None

Low-pass cutoff (Hz) applied to position channels. None skips.

lowpass_derivfloat | None

Low-pass cutoff (Hz) applied to velocity and acceleration channels after differentiation. None skips.

compute_velocitybool

Whether to compute and append velocity channels.

compute_accelerationbool

Whether to compute and append acceleration channels.

sfreq_targetfloat | None

If not None, resample motion channels to this rate before differentiation. Useful to match the EEG sample rate.

Returns:
raw_outmne.io.Raw

Copy of raw with quaternion channels replaced by Euler channels and velocity / acceleration channels appended.

rb_infodict

Per-rigid-body processing summary: {rb_name: {"mode": "quat"|"euler", "channels": list[str]}}.