calculate the peak to peak amplitude of both an m-wave and h-reflex in a 21 data point by 600 trial matrix emg signal in matlab in matlab

Assuming that you have already filtered the EMG signal and identified the M-wave and H-reflex peaks, you can use the following code to calculate their peak-to-peak amplitude:

main.m
% Let's say that the EMG signal is stored in a variable called emg_data
% and the M-wave and H-reflex peaks are stored in variables called m_peaks
% and h_peaks, respectively.

num_trials = 600;
num_data_points = 21;

% Reshape the emg_data into a 3D matrix of size num_data_points x num_trials x channels
emg_data = reshape(emg_data, num_data_points, num_trials, []);

% Initialize variables to store the peak-to-peak amplitudes
m_ppa = zeros(num_trials, size(emg_data, 3));
h_ppa = zeros(num_trials, size(emg_data, 3));

for i = 1:num_trials
    for j = 1:size(emg_data, 3)
        % Extract the data for the current trial and channel
        trial_data = emg_data(:, i, j);
        
        % Calculate the peak-to-peak amplitude of the M-wave and H-reflex
        m_ppa(i, j) = max(trial_data(m_peaks(i, j):h_peaks(i, j))) - ...
                       min(trial_data(m_peaks(i, j):h_peaks(i, j)));
        h_ppa(i, j) = max(trial_data(h_peaks(i, j):end)) - ...
                       min(trial_data(h_peaks(i, j):end));
    end
end
1036 chars
27 lines

Note that this code assumes that the M-wave and H-reflex peaks for each trial and channel have already been identified and stored in the m_peaks and h_peaks variables, respectively. Also, the emg_data variable should be a 3D matrix of size num_data_points x num_trials x num_channels.

related categories

gistlibby LogSnag