identify and calculate the peak to peak amplitude of both an m-wave and h-reflex in a 600 data point by 21 trial matrix emg signal by finding the peaks over two time periods in matlab

To identify and calculate the peak to peak amplitude of both an m-wave and h-reflex in a 600 data point by 21 trial matrix emg signal by finding the peaks over two time periods in MATLAB, we can follow these steps:

  1. Define the two time periods of interest to search for peaks in the EMG signal. For example, we can define one time period as the time just before the stimulus (to capture the M-wave) and another time period as the time after the stimulus (to capture the H-reflex).
  2. Loop through each trial of the EMG signal matrix and extract the two time periods of interest.
  3. Apply a bandpass filter to the EMG signal within each time period to remove any noise and isolate the relevant frequency range.
  4. Use the findpeaks function in MATLAB to detect the peaks in each time period.
  5. Calculate the peak-to-peak amplitude by subtracting the minimum value from the maximum value for each of the identified peaks.

Here's some example MATLAB code that implements these steps:

main.m
% Define the time periods of interest for peak detection
pre_stim_time = 200:300; % 100 ms before stimulus
post_stim_time = 350:450; % 100 ms after stimulus

% Initialize array to hold peak-to-peak amplitudes for each trial
peak_to_peak_amp = zeros(21, 2); % 21 trials, 2 time periods

% Loop through each trial
for i = 1:21
    
    % Extract the two time periods of interest for this trial
    pre_stim_emg = emg_data(pre_stim_time, i);
    post_stim_emg = emg_data(post_stim_time, i);
    
    % Apply bandpass filter to isolate relevant frequency range (e.g. 20-200 Hz)
    pre_stim_filt = bandpass(pre_stim_emg, [20 200], 1000);
    post_stim_filt = bandpass(post_stim_emg, [20 200], 1000);
    
    % Detect peaks in each time period
    [pre_pk_val, pre_pk_loc] = findpeaks(pre_stim_filt);
    [post_pk_val, post_pk_loc] = findpeaks(post_stim_filt);
    
    % Calculate peak-to-peak amplitude for each time period
    peak_to_peak_amp(i, 1) = max(pre_pk_val) - min(pre_stim_filt);
    peak_to_peak_amp(i, 2) = max(post_pk_val) - min(post_stim_filt);
end
1062 chars
27 lines

This code assumes that the EMG data is stored in a matrix called emg_data with size 600 x 21, where each column represents a single trial. It also assumes that the sampling rate of the EMG data is 1000 Hz.

Note that the bandpass filter parameters (20-200 Hz) are just an example and may need to be adjusted depending on the specific EMG signal being analyzed. You may also need to experiment with other peak detection algorithms or parameters depending on the characteristics of your data.

related categories

gistlibby LogSnag