Physical Activity and Heart Rates

Jennifer Jordan, Virginia Commonwealth University, Biomedical Engineering

jhjordan [at] vcu.edu

Author Profile

Summary

This problem is an assessment of several computational methods being pulled together to solve a complex problem for biomedical engineering students. Students need to use mock clinical data to compute whether study participants met specific target heart rate zones during prescribed exercise.

Students should be able to demonstrate the following outcomes successfully to solve the problem: Selection statements (for loop, while loop, and/or switch cases), data importing, logical operators, data output, and functions.


Learning Goals

Students should be able to demonstrate the following outcomes successfully to solve the problem: Selection statements (for loop, while loop, and/or switch cases), data importing, logical operators, data output, and functions.
This assignment requires critical thinking, program development, and computational methods including data analysis.

The following learning targets should be demonstrated successfully through this assessment:

  • I can demonstrate ability to identify, formulate, and solve engineering problems.
  • I can write MATLAB scripts, add meaningful and concise comments to them.
  • I can use a range of built-in MATLAB functions to read data from external text or data files.
  • I can write and run a MATLAB mlx-file that contains a function which can take arguments and return output. 
  • I create flexible code that does not hard code values unless necessary.
  • I include checks for errors or warnings in my own functions.
  • I can write MATLAB conditional statements using if-else and switch statements.
  • I can write MATLAB iteration statements using 'for' loops.
  • I can incrementally develop a MATLAB function or program.

 

 

Context for Use

This is a midterm assessment for sophomore biomedical engineering students given as a take-home problem to allow students more than a single lecture to complete.

Alternatively, this could be a classroom group activity where students work together to develop algorithms and then independently code in MATLAB.

Description and Teaching Materials

According to the CDC Guidelines, your target heart rate should be between 64-76% of your maximum heart rate for moderate-intensity physical activity or between 77-93% of your maximum heart rate for vigorous-intensity physical activity. One can estimate maximum age-related heart rate by subtracting their age from 220. For example, a 50-year old person would have a maximum age-related heart rate of 220-50 = 170 beats per minute (bpm).

Instructions are included in attached file. Briefly,
Your task with this question is to write a MATLAB script to retrieve and display the heart rate zones for a list of study patients participating in an exercise-based study. In addition to displaying the heart rate zones, your program should also display whether or not target metrics were met during their exercise time at the clinical study facility. Your code should work for any files that are of the same format (imagine I give you two more files with x patients and one with y patients).

Your script should make use of two text files of simulated study data:

  • study_patients.txt: This file contains a row of data for each unique patient. The column data is as follows: the patient ID, their age, and the type of exercise prescription they are targeting (either moderate-intensity=MI or vigorous-intensity=VI).
  • study_results.txt: This file contains a row of data for each exercise visit. Each row contains two numbers: the patient ID and the average heart rate during the exercise in BPM. There may be multiple tests for each patient or none at all. No date is provided for the tests but they are included in the file in chronologic order.

Your completed program should:

  • Read in the patient and result data from the two text files.
  • Utilize at least one user-defined function to either calculate the heart rate zone and/or category for the exercise visit result ("Within Target Zone", "Too Low", or "Too High"). Be sure to include "type functionname.mlx" in your main program to print the file to your output.
  • For a patient with results, your code should independently determine their heart rate range for prescribed physical activity intensity (moderate or vigorous) and whether the measured heart rate from the file was "Within Target Zone", "Too Low", or "Too High" (remember that normal range will depend upon the age of the patient). This means that you do not hard code per patient but rather your code would select the text to display based on some selection statement test.
  • Your code should create a summary list for each patient of their ID, target intensity (moderate or vigorous), target heart rate range for that intensity given their age, and the number of times each category (Within Zone, Too Low, Too High) were identified. For this, you may use disp orfprintf statements or you can put all of the data into a table to print to the output.
  • Your program should identify if a patient has no test results and display a text warning statement that this information is missing.
  • Finally, at the end of your program, your code should include description of your algorithm and code design choices- this may be in "text" in your .mlx script.

Students should submit a fully executed MLX program exported as a PDF which will include their problem statement, algorithm/pseudocode, coding solution, discussion (as specified above) and as outputs: the summary list/table and function script (using the 'type' command).


Physical Activity and Heart Rates - Instructions/Specifications (Acrobat (PDF) 157kB Sep13 21) 
study_patients.txt data file (Text File 89bytes Sep13 21) 
study_results.txt data file (Text File 171bytes Sep13 21) 

Teaching Notes and Tips

As this is a complex problem, students may have difficulty in one area and be unable to solve meeting full specifications. In such cases, encourage students to use data import tool if needed or to hard code values rather than having flexible counters. Students should also be encouraged to create an algorithm or diagram of code flow to assist and incrementally develop with test stubs.

If given as a take home assessment, students should be able to complete within a few days to a week given debugging difficulties and scheduling. If using this as an in-class group activity, students will need 30-60 min to diagram their code and develop their algorithm/pseudocode before independently coding the program. The independent coding time should take 2-3 hours.

Prior instruction required:

  • This assessment is used midway through a sophomore-level computational methods course with a mixture of students with (~20%) and without (~80%) MATLAB experience prior to the course.
  • Topics to be covered prior to assessment:
    • General MATLAB programming and how to well-commented write programs
    • Selection statements
    • Iteration statements
    • User-defined functions
    • Incremental programming
    • Debugging and errors
    • Data importing
    • Problem solving strategies including algorithm development, structure charts and/or flow charts, pseudocode

Assessment

Students must meet the criteria/specifications given in the attached rubric.

Physical Activity and Heart Rates - Rubric.pdf (Acrobat (PDF) 598kB Nov8 21)

References and Resources

CDC Heart Rate Guidelines: https://www.cdc.gov/physicalactivity/basics/measuring/heartrate.htm