I have MATLAB homework that I need help with today

I have MATLAB homework that I need help with today


BIOE 3071 Batch Processing ECG Data in MATLAB: Recovery Rate Workflow In this lab we will create a script that loads all of the data files, calculates the heart rate for each subject and performs a curve fit (using a function you have created), and then plots the curve fit parameters for all the files. In order to facilitate debugging it is recommended that you test each section as it is completed. Section 1: Load Files, Define Filter Download the zip file containing the heart rate recovery data from CANVAS (Exercise_mat_Files.zip). These are the results of the first BIOPAC ECG exercise. Unzip the file into a directory. Define a variable ‘readPath’ that contains the path of the .mat files. Using a ‘for’ loop load all of the BIOPAC data into a structure array ‘BIOPAC_Data’. Store the file name and path in the structure. Define the sample rate to be 1000 Hz, store this in the variable ‘sampleRate’ Define an iir bandpass digital filter ‘filterObj’ with a low-frequency half power frequency of 0.1 Hz and a high-frequency half power frequency of 50 Hz. This action is performed outside of the loop to save computation time since we will use the same filter for all the samples. You do not need to plot the filter frequency response. Section 2: Create the framework for the iterative analysis Implement a ‘for’ loop that iterates through the length of the data structure BIOPAC_Data. During each iteration of the for loop:  Define the following fields in the data structure o The vector of voltages ‘V’ (the first column of the BIOPAC data) o The heart rate computed by the BIOPAC software ‘HR_BIOPAC’ (the 2nd column of the BIOPAC data) o The time vector ‘time’ (has a sample rate ‘sampleRate’ and a length equal to the voltage)  Plot the voltage against time and the heart rate against time in separate subplots  Add a 0.5 second pause using ‘pause(0.5)’ so that the plots will update when the loop is running When this section of code is executed, you should see a plot of a different subject’s ECG appear at 0.5 second intervals Function Definition The heart (pun intended) of the batch processing algorithm for heart rate detection will be a function called ‘HR_detect’ with three inputs:  The ECG voltage ‘V’  The sampling rate ‘sampleRate’  The digital filter object ‘filterObj’. The function will have three outputs:  The filtered voltage ‘VFilt’  The processed signal after rolling window integration ‘vInt’  The location (index) of the detected peaks ‘locs’. Paste the beat detection script that you previously developed into the function ‘HR_detect’. Delete everything that is not necessary for signal processing (e.g. the filter design and analysis, plotting sections, etc). Keep only the essential steps:  Apply the bandpass filter (that is stored in filterObj) using filtfilt  Take the derivative with the gradient function  Squaring the derivative  Define the convolution kernel (50 ms integration window)  Perform the rolling integration with convolution to find vInt  Perform peak detection on vInt with findpeaks o Minimum peak height is the mean of vInt o Minimum peak distance is 200 ms (remember to convert this to time steps) The function created by removing all lines that are not necessary for processing will be quite short: it can be accomplished in 12 lines or less. Make sure that the variable names of your inputs in the function definition (line 1) match what is used in the program. Likewise, make sure the output arguments (in line 1) match the variable names in the body of the code. Add a call to this function inside the ‘for’ loop (after the plots) in the analysis script. Save the outputs to fields in the BIOPAC_Data structure. Important Note: if your detection algorithm is detecting erroneous heartbeats (E.g. the heart rate intermittently spikes up to 250 BPM) you may need to adjust the minimum peak height and minimum peak distance in the ‘findpeaks’ function. Curve Fitting This component of the program will execute for each file (each field of the BIOPAC_Data structure). As such, it is positioned inside the loop after the beat detection is completed. First, extract the heart rate and store it in the BIOPAC_Data structure (using ‘locs’ from the previous step in this handout). Also extract and store the time at which each beat occurs. Based on the findings of Pierpont, Stolpman, and Gornick in ‘Heart rate recovery post-exercise as an index of parasympathetic activity’ (available on CANVAS) we will use a first-order decaying exponential function to analyze heart rate recovery after exercise. ??(?) = ??0 +??∆? (− ? ? ) Here HR is the time-dependent heart rate, HR0 is the resting heart rate, HR is the maximum heart rate minus the resting heart rate (HR0), t is time, and T is the decay constant. Fit this equation to the calculated heart rate and time of each beat. Plot the heart rate vs time and overlay the best fit line. Collect the values of T, HR0, and HR for all subjects into vectors for later analysis. Plotting and Analysis Create labeled box plots of the resting heart rate HR0, the maximum heart rate (HR0 + HR, and the time constant T. Add comments to your code discussing each plot. In your analysis please discuss 1) whether or not you think the values are appropriate and why; 2) what in the experimental or analysis procedures may have caused values that do not make physiological sense (such as a very fast resting heart rate) and 3) the changes you would make to the experiment or analysis to improve the quality of the data. Please consider both the physiological and technical aspects.
May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here