Ob jective
BEng Biomedical Engineering Computer Programming
Coursework 3 – Take-Home Assignment
To gain practical experience of computer programming and design using MATLAB.
Introduction
The volume of the heart’s left ventricle (LV) over the cardiac cycle can provide useful information to cardiologists about the health of the heart. LV volumes can be estimated from imaging data by automated image processing techniques. A sample volume curve derived from magnetic resonance imaging (MRI) is shown in the figure below.
The cardiac cycle can be divided into two stages. In systole the muscle contracts and the heart pumps blood around the body. Systole consists of the isovolumetric contraction phase and the ejection phase. In diastole the heart muscle relaxes and allows the chambers to fill with blood. Diastole consists of the rapid inflow phase, the diastasis phase and the atrial systole phase. End- systole and end-diastole represent the ends of the systole and diastole stages. The figure above indicates these two points, at which the volume curve values represent the end-systolic volume (ESV) and end-diastolic volume (EDV) respectively.
The EDV and ESV are two important parameters that can be derived from LV volume curves. A number of others are summarised below:
1. Peak ejection rate (PER): The magnitude of the slope of the volume curve during the ejection phase of the cardiac cycle.
1
- Peak filling rate (PFR): The magnitude of the slope of the volume curve during the rapid inflow phase of the cardiac cycle.
- Atrial contribution (AC): The difference between the EDV and the volume in the diastasis phase of the cardiac cycle.
Instructions
Volume curves have been produced from MRI scans of a number of volunteers. You are provided with data for two of these volunteers. For each volunteer there are two files: one containing an array of LV volume values (in ml) and another containing an array of times (in ms) at which these volumes were estimated. For example, for volunteer 1088154 the files are called ‘1088154 volume.txt’ and ‘1088154 trigger time.txt’.
You are required to write code to perform the following operations:
- Ask the user of the program to enter the volunteer number. Read in this number.
- Read in the time and volume files for this volunteer. If either file does not exist report an error and stop the program.
(Hint: Look at the MATLAB documentation for the exist function.) - Compute and display to the command window the EDV, ESV, PER, PFR and AC for this volunteer. The units for EDV and ESV should be ml, and for PER, PFR and AC they should be ml/s.
- Produce a plot showing the volume curve over time for this volunteer. The plot should also indicate the EDV and ESV.
- Ask the user if they want to enter another volunteer number. If they enter ‘y’ or ‘Y’, repeat from 1, otherwise exit.
For example, for volunteer 1088154 the command window output should be similar to this:
Volunteer: 1088154 EDV = 106.03 ml ESV = 46.40 ml PER = 311.18 ml/s PFR = 274.37 ml/s AC = 14.28 ml/s
The plot should look similar to that shown below.
Computer Programming Page 2 of 4 Coursework 3 – Take-Home Assignment
To help you in making the calculations, the following techniques can be used when computing the values of the parameters:
- EDV : This is just the volume at the first time point.
- ESV : This is the minimum volume over the whole of the cardiac cycle.
- PER: This can be computed by finding the minimum of the 1st derivative of the volume curve between the first time point and end-systole, and then dividing this by the mean time difference between measurements. Then take the absolute value of the result.
- PFR: This can be computed by finding the first local maximum of the 1st derivative of the volume curve, and dividing this by the mean time difference between measurements. Then take the absolute value of the result.
- AC : This is the difference between the EDV and the volume at the last local minimum of the 1st derivative of the volume curve.
Note that you should write your program in such a way that it will work for any input file with the same format as those provided. Your code will be tested using files from different volunteers.
General advice
Before starting any coding, you should produce a structured design for your program, using struc- ture charts and/or pseudocode. You should then apply an incremental development approach to develop your code.
The following MATLAB commands, which we have not covered in class, may be useful to you: gradient, findpeaks and diff. Please see the documentation for more details.
Reporting Requirements
You should submit MATLAB files that meet as many of the requirements as possible. Try to use variable/function naming, comments and indentation to make your program as easy to understand as possible.
You should also submit a short written report detailing the design of your program. This report should contain structure charts and/or pseudocode for your program design, together with a short explanation of why you chose to design the program in this way. To help you in producing this
Computer Programming Page 3 of 4 Coursework 3 – Take-Home Assignment
report, a sample model report will be made available to you through the KEATS system. The report should not need to be longer than 3 pages of A4, and can be shorter.
Submission will be via the KEATS system. The submission point will only allow you to upload a single file so if you have multiple files you should combine all files into a single zip file. Name your file cw3-YEAR-SURNAME-FIRSTNAME.zip, replacing YEAR, SURNAME and FIRSTNAME with your personal details (e.g. cw3-2018-KING-ANDREW.zip).
The hand-in date is 28 Nov 2018, 5 pm. Late submissions (within 24 hours of this deadline) will be accepted but will be capped at the module pass mark (i.e. 40%).
If your program does not meet all requirements then please submit what you have written by the deadline.
Assessment
Your coursework will be marked on a number of factors:
- Does the program work? Does it meet all requirements? (60%)
- Program design, i.e. structure charts and/or pseudocode (20%)
- Appropriate use of MATLAB language features, e.g. control structures, functions, etc. (10%)
- Use of comments, indentation and variable/function names to make code easy to understand (10%)
The overall mark for this coursework will make up 15% of your total mark for this module.
This is an individual assignment. You are not permitted to work together with any other student. Note that general discussions about design decisions and/or coding strategies are permitted, and such discussions can be a useful learning experience for you. But you should not, under any circumstances, share details of designs or code.
If you have any questions about this coursework please contact Andy King (andrew.king@kcl.ac.uk).
Computer Programming Page 4 of 4 Coursework 3 – Take-Home Assignment