identify and 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

To calculate the peak-to-peak amplitude of both the M-wave and H-reflex in a 21 data point by 600 trial matrix EMG signal in MATLAB, follow these steps:

  1. First, preprocess the EMG signal by filtering out any noise or artifacts that might be present. You can use bandpass filters to isolate the frequencies of interest.

  2. Next, segment the EMG signal into individual trials of 21 data points each. You can do this by looping through the 600 trials and extracting the appropriate segment from each trial.

  3. Compute the peak-to-peak amplitude of each trial for both the M-wave and H-reflex. To do this, find the maximum and minimum voltage values within the segment and subtract them from each other. This will give you the peak-to-peak amplitude for that trial.

  4. Store the peak-to-peak amplitude values in separate arrays for the M-wave and H-reflex.

  5. Finally, plot the peak-to-peak amplitude values for each trial using a scatter plot or line plot. You can also calculate summary statistics such as the mean, median, and standard deviation of the peak-to-peak amplitudes for each condition.

Here's some sample MATLAB code to get you started:

main.m
% Load the EMG data
load emg_data.mat % Replace with your own data file

% Preprocess the EMG signal
fs = 1000; % Sampling rate in Hz
fc_high = 20; % High-pass cutoff frequency in Hz
fc_low = 500; % Low-pass cutoff frequency in Hz

[b,a] = butter(4, [fc_high,fc_low]/(fs/2), 'bandpass'); % Design a bandpass filter
emg_filtered = filtfilt(b,a,emg_data); % Apply the filter to the EMG data

% Segment the EMG signal into individual trials
n_trials = 600;
trial_len = 21;
emg_trials = zeros(trial_len, n_trials);

for i = 1:n_trials
    start_idx = (i-1)*trial_len + 1;
    end_idx = start_idx + trial_len - 1;
    emg_trials(:,i) = emg_filtered(start_idx:end_idx);
end

% Compute peak-to-peak amplitude values for the M-wave and H-reflex
m_wave_ppa = zeros(n_trials, 1);
h_reflex_ppa = zeros(n_trials, 1);

for i = 1:n_trials
    trial = emg_trials(:,i);
    [~,max_idx] = max(trial);
    [~,min_idx] = min(trial);
    
    m_wave_ppa(i) = trial(max_idx) - trial(1);
    h_reflex_ppa(i) = trial(max_idx) - trial(min_idx);
end

% Plot the peak-to-peak amplitude values
figure;
subplot(2,1,1);
plot(m_wave_ppa,'o');
title('M-Wave Peak-to-Peak Amplitudes');
ylabel('Amplitude (uV)');
xlabel('Trial Number');
ylim([0 max(m_wave_ppa)]);
subplot(2,1,2);
plot(h_reflex_ppa,'o');
title('H-Reflex Peak-to-Peak Amplitudes');
ylabel('Amplitude (uV)');
xlabel('Trial Number');
ylim([0 max(h_reflex_ppa)]);
1393 chars
50 lines

related categories

gistlibby LogSnag