Recording Protocol (Panel)

class myogestic.gui.protocols.record.RecordProtocol(self, parent: PySide6.QtCore.QObject | None = None)[source]

Bases: QObject

Protocol for recording EMG and kinematics data.

This protocol allows the user to record EMG and kinematics data for a specified duration. The user can select the task to be recorded and provide a label for the recording.

The protocol includes the following features:
  • Recording EMG data from the biosignal device.

  • Recording kinematics data from the virtual hand interface.

  • Setting the recording duration in seconds.

  • Selecting the task to be recorded.

  • Providing a label for the recording.

  • Saving the recorded data to a file.

Parameters:

parent (MyoGestic, optional) – The parent object that manages the protocol, by default None.

main_window

The main window object that manages the protocol.

Type:

MyoGestic

current_task

The current task selected for recording.

Type:

str

kinematics_sampling_frequency

The sampling frequency for kinematics data.

Type:

int

recording_time

The duration of the recording in seconds.

Type:

int

emg_buffer

A list of tuples containing the timestamp and EMG data samples.

Type:

list[(int, np.ndarray)]

kinematics_buffer

A list of tuples containing the timestamp and kinematics data samples.

Type:

list[(int, np.ndarray)]

has_finished_emg

A flag indicating whether the EMG recording has finished.

Type:

bool

has_finished_kinematics

A flag indicating whether the kinematics recording has finished.

Type:

bool

start_time

The start time of the recording.

Type:

float

recording_dir_path

The directory path for saving the recordings.

Type:

str

emg_recording_time

The total number of EMG samples to be recorded.

Type:

int

Initialize self. See help(type(self)) for accurate signature.

emg_update(data)[source]

Updates the EMG (electromyography) data buffer with new data and checks if the recording is complete.

Parameters:

data (np.ndarray) – The new EMG data to be added to the buffer.

Return type:

None

Notes

This method performs the following steps:

  1. Extracts the EMG signal from the provided data using the extract_emg_data method of the device_widget.

  2. Appends the current timestamp and the extracted EMG signal to the emg_buffer.

  3. Calculates the total number of current samples in the buffer.

  4. Updates the EMG progress bar with the current number of samples.

  5. Checks if the number of current samples has reached or exceeded the required recording time.

    • If the recording is complete, it logs a message indicating the completion time.

    • Sets the has_finished_emg flag to True.

    • Disconnects the emg_update method from the ready_read_signal of the device_widget.

    • Calls the finished_recording method to handle post-recording actions.

finished_recording()[source]

Handles the post-recording actions after the EMG and kinematics recordings are complete.

Return type:

None

kinematics_update(data)[source]

Updates the kinematics data buffer with new data and checks if the recording is complete.

Parameters:

data (np.ndarray) – The new kinematics data to be added to the buffer.

Return type:

None

Notes

This method performs the following steps:

  1. Checks if the kinematics recording is enabled using the use_kinematics_check_box.

  2. Appends the current timestamp and the kinematics data to the kinematics_buffer.

  3. Calculates the total number of current samples in the buffer.

  4. Updates the kinematics progress bar with the current number of samples.

  5. Checks if the number of current samples has reached or exceeded the required recording time.

    • If the recording is complete, it logs a message indicating the completion time.

    • Sets the has_finished_kinematics flag to True.

    • Disconnects the kinematics_update method from the input_message_signal of the virtual_hand_interface.

    • Calls the finished_recording method to handle post-recording actions.