Skip to content

Latest commit

 

History

History
62 lines (33 loc) · 2.85 KB

README.md

File metadata and controls

62 lines (33 loc) · 2.85 KB

EMG Data Processing

This Python script is designed to process Electromyography (EMG) data stored in CSV format. EMG data typically represents electrical signals generated by muscle activity and is commonly used in various fields such as biomechanics, sports science, and rehabilitation.

Prerequisites

Before running the script, ensure you have the following installed:

  • Python 3.x
  • Required Python packages: pandas, matplotlib, numpy, scipy

Usage

  1. Input Data: The input EMG data should be stored in a CSV file format. You can specify the file path in the input_file_path variable within the main() function.

  2. Output Data: Processed EMG data will be saved as CSV files in the 'output' directory. The file paths are specified by the output_file_path and rms_output_file_path variables in the main() function.

  3. Running the Script: Simply execute the script. The main() function orchestrates the entire data processing pipeline.

Functions

  1. read_emg_data(file_path): Reads EMG data from a CSV file and returns it as a pandas DataFrame.

  2. full_wave_rectification(emg_data): Performs full-wave rectification on the EMG data, converting negative values to positive.

  3. non_inverting_amplifier(emg_data, gain): Simulates a non-inverting amplifier by amplifying the EMG signals by a specified gain factor.

  4. butter_filter(cutoff_freq, sampling_freq, btype, order=2): Designs a Butterworth filter.

  5. butter_filter_signal(emg_data, cutoff_freq, sampling_freq, btype, order=2): Applies a Butterworth filter to the EMG signal.

  6. rms_smoothing(emg_data, window_size): Performs Root Mean Square (RMS) smoothing on the EMG data using a moving window.

  7. movag_smoothing(emg_data, window_size): Performs Moving Average (MOVAG) smoothing on the EMG data using a moving window.

  8. plot_emg_data(emg_data): Plots the EMG data.

  9. save_emg_data(emg_data, file_path): Saves the EMG data to a CSV file.

Data Processing Steps

  1. Full Wave Rectification: Converts EMG signals to their absolute values.

  2. Amplification: Increases the magnitude of EMG signals using a specified gain.

  3. High-pass and Low-pass Filtering (Optional): Butterworth filters can be applied to remove unwanted noise from the EMG signals.

  4. Smoothing: Two smoothing techniques are provided: Root Mean Square (RMS) and Moving Average (MOVAG).

  5. Plotting and Saving: Processed EMG data can be visualized using matplotlib and saved as CSV files for further analysis.

Note

  • Some filtering and smoothing functions are currently commented out in the main() function. Uncomment and adjust parameters as needed for your specific data processing requirements.

  • Make sure to customize the file paths and processing parameters according to your data and analysis needs.

Example

if __name__ == "__main__":
    main()