create script to determine the points of cancellation on h-reflex and m-wave in matlab

To determine the points of cancellation on h-reflex and m-wave in MATLAB, you can follow these steps:

  1. Define the stimulation parameters, such as pulse duration, amplitude, and frequency.
main.m
pulseDuration = 0.2 % in milliseconds
pulseAmplitude = 20 % in milliamperes
pulseFrequency = 1 % in hertz
106 chars
4 lines
  1. Use the daq.createSession function to create a session object for data acquisition.
main.m
s = daq.createSession('ni');
29 chars
2 lines
  1. Add an analog output channel to generate the stimulation pulse.
main.m
addAnalogOutputChannel(s,'Dev1',0,'Voltage');
46 chars
2 lines
  1. Add an analog input channel to record the muscle response.
main.m
addAnalogInputChannel(s,'Dev1',0,'Voltage');
45 chars
2 lines
  1. Set the data acquisition parameters, such as sampling rate and duration of acquisition.
main.m
s.Rate = 1000 % in samples per second
s.DurationInSeconds = 2 % in seconds
75 chars
3 lines
  1. Generate the stimulation pulse and record the muscle response.
main.m
for i = 1:10 % repeat stimulation and recording 10 times
    outputData = repmat(pulseAmplitude,round(pulseDuration*s.Rate/1000),1)*(-1)^i; % generate pulse with alternating polarity
    queueOutputData(s,outputData); % queue output data
    inputData = startForeground(s); % start acquisition and wait for it to finish
    [maxValue,maxIndex] = max(inputData); % find the maximum value and index of the muscle response
    [minValue,minIndex] = min(inputData); % find the minimum value and index of the muscle response
    hReflex(i) = minValue; % store the amplitude of the h-reflex
    mWave(i) = maxValue; % store the amplitude of the m-wave
    hCancel(i) = maxIndex/s.Rate*1000-pulseDuration/2; % calculate the time of cancellation of the h-reflex
    mCancel(i) = minIndex/s.Rate*1000-pulseDuration/2; % calculate the time of cancellation of the m-wave
end
864 chars
12 lines
  1. Plot the results.
main.m
figure;
subplot(2,2,1);
plot(1:10,hReflex);
title('h-reflex amplitude');
subplot(2,2,2);
plot(1:10,mWave);
title('m-wave amplitude');
subplot(2,2,3);
plot(1:10,hCancel);
title('h-reflex cancellation');
subplot(2,2,4);
plot(1:10,mCancel);
title('m-wave cancellation');
268 chars
14 lines

This script generates a stimulation pulse with the specified parameters and alternates its polarity in each iteration of the loop. It records the muscle response using an analog input channel and finds the maximum and minimum values and indices of the response. It stores the amplitudes of the h-reflex and m-wave and calculates the times of cancellation for each of them. Finally, it plots the results for all iterations.

related categories

gistlibby LogSnag