Computational simulation of the heart Edmund Altman 2010/2011

Similar documents
6.3.4 Action potential

The Physics of the Heart. Sima Setayeshgar

APPM 2360 Project 3 Mathematical Investigation of Cardiac Dynamics

A note on discontinuous rate functions for the gate variables in mathematical models of cardiac cells

Lecture Notes 8C120 Inleiding Meten en Modelleren. Cellular electrophysiology: modeling and simulation. Nico Kuijpers

2013 NSF-CMACS Workshop on Atrial Fibrillation

Introduction to Physiology V - Coupling and Propagation

The Physics of the Heart. Sima Setayeshgar

Topics in Neurophysics

Simulating Cardiac Electromechanics using Abaqus UEL

Electrophysiology of the neuron

Parameters for Minimal Model of Cardiac Cell from Two Different Methods: Voltage-Clamp and MSE Method

The Department of Electrical Engineering. nkrol Mentors: Dr. Mohammad Imtiaz, Dr. Jing Wang & Dr. In Soo Ahn

STUDENT PAPER. Santiago Santana University of Illinois, Urbana-Champaign Blue Waters Education Program 736 S. Lombard Oak Park IL, 60304

Math 345 Intro to Math Biology Lecture 20: Mathematical model of Neuron conduction

Mathematical Foundations of Neuroscience - Lecture 3. Electrophysiology of neurons - continued

Biomedical Instrumentation

Lecture 10 : Neuronal Dynamics. Eileen Nugent

CSD-TR R. Samade, B. Kogan

Nonlinear Observer Design and Synchronization Analysis for Classical Models of Neural Oscillators

Bo Deng University of Nebraska-Lincoln UNL Math Biology Seminar

ACTION POTENTIAL. Dr. Ayisha Qureshi Professor MBBS, MPhil

Membrane Potentials, Action Potentials, and Synaptic Transmission. Membrane Potential

Simulation of Cardiac Action Potentials Background Information

PCMI Project: Resetting Reentrant Excitation Oscillations in Different Geometries

me239 mechanics of the cell - syllabus me239 mechanics of the cell me239 mechanics of the cell - grading me239 mechanics of the cell - overview

Neurons, Synapses, and Signaling

Electrophysiological Modeling of Membranes and Cells

Peripheral Nerve II. Amelyn Ramos Rafael, MD. Anatomical considerations

Modeling Action Potentials in Cell Processes

Neurophysiology. Danil Hammoudi.MD

From neuronal oscillations to complexity

Scroll Waves in Anisotropic Excitable Media with Application to the Heart. Sima Setayeshgar Department of Physics Indiana University

Scroll Waves in Anisotropic Excitable Media with Application to the Heart. Sima Setayeshgar Department of Physics Indiana University

Final Project Descriptions Introduction to Mathematical Biology Professor: Paul J. Atzberger. Project I: Predator-Prey Equations

Automatic Validation and Optimisation of Biological Models

9 Generation of Action Potential Hodgkin-Huxley Model

MEMBRANE POTENTIALS AND ACTION POTENTIALS:

ROLE OF BIDOMAIN MODEL OF CARDIAC TISSUE IN THE DYNAMICS OF PHASE SINGULARITIES

Converting energy into nerve impulses, resting potentials and action potentials Sensory receptors

FRTF01 L8 Electrophysiology

Quantitative Electrophysiology

Transport of ions across plasma membranes

Particles with opposite charges (positives and negatives) attract each other, while particles with the same charge repel each other.

Quantitative Electrophysiology

Learning Cycle Linear Hybrid Automata for Excitable Cells

All-or-None Principle and Weakness of Hodgkin-Huxley Mathematical Model

9.01 Introduction to Neuroscience Fall 2007

BME 5742 Biosystems Modeling and Control

Reproducing Cardiac Restitution Properties Using the Fenton Karma Membrane Model

Biological membranes and bioelectric phenomena

Overview Organization: Central Nervous System (CNS) Peripheral Nervous System (PNS) innervate Divisions: a. Afferent

Neurons and Nervous Systems

SUMMARY OF THE EVENTS WHICH TRIGGER AN ELECTRICAL IMPUSLE IN NERVE CELLS (see figures on the following page)

An Approach for Applying Data Assimilation Techniques for Studying Cardiac Arrhythmias

Physiology Unit 2. MEMBRANE POTENTIALS and SYNAPSES

Signal processing in nervous system - Hodgkin-Huxley model

3.3 Simulating action potentials

Nervous Lecture Test Questions Set 2

Modelling biological oscillations

PHYSIOLOGY CHAPTER 9 MUSCLE TISSUE Fall 2016

The Membrane Potential

General Physics. Nerve Conduction. Newton s laws of Motion Work, Energy and Power. Fluids. Direct Current (DC)

Physiology Coloring Book: Panels 29, 32, 33,

The Membrane Potential

On Parameter Estimation for Neuron Models

Νευροφυσιολογία και Αισθήσεις

... Cardiac Gap Junctions Physiology, Regulation, Pathophysiology and Pharmacology

Fundamentals of the Nervous System and Nervous Tissue

Boundary-induced reentry in homogeneous excitable tissue

Channels can be activated by ligand-binding (chemical), voltage change, or mechanical changes such as stretch.

لجنة الطب البشري رؤية تنير دروب تميزكم

Simulating Hodgkin-Huxley-like Excitation using Comsol Multiphysics

Membrane Potentials and Bioelectricity

Nervous System Organization

Naseem Demeri. Mohammad Alfarra. Mohammad Khatatbeh

Questions: Properties of excitable tissues Transport across cell membrane Resting potential Action potential Excitability change at excitation

Single-Compartment Neural Models

Introduction Principles of Signaling and Organization p. 3 Signaling in Simple Neuronal Circuits p. 4 Organization of the Retina p.

Dendrites - receives information from other neuron cells - input receivers.

Instructor (Brad Osgood)

3 Action Potentials - Brutal Approximations

Lecture 11 : Simple Neuron Models. Dr Eileen Nugent

Chapter 2 Basic Cardiac Electrophysiology: Excitable Membranes

Nerve Signal Conduction. Resting Potential Action Potential Conduction of Action Potentials

me239 mechanics of the cell me239 mechanics of the cell - final projects 4 6 mechanotransduction downloadable layout file from coursework

Membrane Physiology. Dr. Hiwa Shafiq Oct-18 1

Neural Modeling and Computational Neuroscience. Claudio Gallicchio

80% of all excitatory synapses - at the dendritic spines.

Deconstructing Actual Neurons

Kirchhoff s Rules. Survey available this week. $ closed loop. Quiz on a simple DC circuit. Quiz on a simple DC circuit

NEURONS, SENSE ORGANS, AND NERVOUS SYSTEMS CHAPTER 34

Physiology Unit 2. MEMBRANE POTENTIALS and SYNAPSES

Microsystems for Neuroscience and Medicine. Lecture 9

Discrete and Indiscrete Models of Biological Networks

Basic mechanisms of arrhythmogenesis and antiarrhythmia

Multiple Mechanisms of Spiral Wave Breakup in a Model of Cardiac Electrical Activity

The Intersection of Chemistry and Biology: An Interview with Professor W. E. Moerner

Electrical Signaling. Lecture Outline. Using Ions as Messengers. Potentials in Electrical Signaling

7.013 Spring 2005 Problem Set 4

Transcription:

Computational simulation of the heart Edmund Altman 2010/2011 The candidate confirms that the work submitted is their own and the appropriate credit has been given where reference has been made to the work of others. I understand that failure to attribute material which is obtained from another source may be considered as plagiarism. (Signature of student)

Abstract In an ideal world there would be a complete computational simulation of the human body. There would be no need for medical testing as drugs could be trialled using the computational model instead of being tested on animals or humans. Although this ideal situation is a long way from reality, there are a lot of people working on creating models of particular parts or systems of the human body. One of the areas that has a lot of research put into it is simulations of the heart. In this project I will examine the biology behind how the heart works, examine existing heart models and attempt to recreate some of existing heart models.

Acknowledgements I would like to sincerely thank Matthew Hubbard for his help and guidance in writing of this project and with my code. I would also like to thank David Duke for his input and comments on my mid-project report.

Contents 1 Introduction 3 1.1 Project Aim....................................... 3 1.2 Objectives........................................ 3 1.3 Minimum requirements................................. 3 1.4 Deliverables....................................... 4 1.5 Schedule......................................... 4 1.5.1 Proposed plan................................. 4 1.5.2 Final plan.................................... 4 2 Background reading 6 2.1 Anatomy of the heart................................. 6 2.2 Origins of heart modelling............................... 7 2.3 Current heart models.................................. 7 2.3.1 Cell models................................... 8 2.3.2 Tissue models.................................. 8 2.3.3 Anatomical models............................... 9 3 Implementation 10 3.1 Single Cell........................................ 10 3.2 One dimensional model................................ 10 3.3 Two dimensional model................................ 12 4 Evaluation 22 4.1 Further work...................................... 23 A Appendix A - Personal reflection 27 B Appendix B - Code 28 B.1 fitzhugh.m....................................... 28 B.2 fitzplot.m........................................ 29 1

B.3 fhn1d.m......................................... 30 B.4 fhn2d.m......................................... 32 2

Chapter 1 Introduction 1.1 Project Aim An ideal goal for biomedical research would be to produce a computational model of the entire human body, which modelled all of its different systems, organs and structures. If this idealistic model was accurate then it could mean the end of long, expensive medical trials which may cause harm to the participants. Unfortunately this goal is a very long way away, but research groups around the world have been working towards making computational models of smaller parts of the body such as the heart. The field of cardiac modelling has been around for around 60 years and in this project I intend to investigate other people s work in this field, and reproduce some of these models myself. Using these computational models I hope to study the heart dysfunctions such as types of Arrhythmia, and go on to produce these models on much larger domains to see if their behaviour changes. 1.2 Objectives The key objectives of this report are as follows: Investigate current cardiac models Gain an understanding of the biochemistry behind basic heart function Produce my own results from existing cardiac models 1.3 Minimum requirements The minimum requirements that I specified for this project are as follows: Simulate at least one single cell model 3

Simulate diffusion across cells in 2D Reproduce a spiral wave pattern 1.4 Deliverables The final project report Results from my reproductions of existing cardiac models, for a single cell and in one or two dimensions Any code written to produce these results 1.5 Schedule 1.5.1 Proposed plan I constructed a Gantt chart in order to plan out a schedule for when I will complete each section of work. Figure 1.1: Project Schedule 1.5.2 Final plan Due to certain problems that are mentioned in appendix A, my schedule ended up as this. 4

Figure 1.2: Project Schedule 5

Chapter 2 Background reading 2.1 Anatomy of the heart The heart is an integral part of the circulatory system that pumps blood around the body, providing muscles, other organs and the brain with oxygenated blood. The heart is a muscular organ that rhythmically contracts and relaxes to act as a pump for the circulatory system. The walls of the heart are made up of involuntary cardiac muscle, which is mainly constructed of myocytes [1]. These are the base cells of muscles that contract and relax on a cellular level to contract and relax the muscle as a whole. This is accomplished by the movement of ions across the cell membrane through ion channels. The movement of these ions causes a change in voltage of the cell membrane which creates an action potential. Ion channels are gates in the cell membrane present in all biological cells. They control the movement of ions in and out of the cell which controls all of the cells functions. The main ions that move across the cell membrane are Sodium (Na + ), Potassium (K + ) and Calcium (Ca ++ ) [2]. These ion channels are integral to cell function that many pharmaceuticals specifically focus on altering certain ion channels to give their desired effect. Current drugs that affect ion channels are local anaesthetics which selectively inhibit sodium channels, and anti-epileptic drugs focus on inhibiting sodium and calcium channels [3]. The combined effects of the movement of these ions changes the voltage of the cell membrane which directly affects whether a myocyte will contract [4]. Incorrect movement of ions can lead to heart dysfunction such as Ventricular fibrillation, which is a life-threatening condition where the hearts rhythm becomes disordered and the heart fails to pump blood correctly. When a myocyte enters an excited state through changes to it s action potential from ion channels it contracts by 20% in the direction of the muscle fibres [5]. Cardiac cells are not self-excitatory, they require an external stimulus to function at all. This external stimulus is provided in the sino-atrial node of the heart which functions as a pacemaker [6]. 6

2.2 Origins of heart modelling Cardiac modelling started in the 1950 s when Alan Hodgkin and Andrew Huxley published the Hodgkin-Huxley model that described the ionic mechanisms of giant squid axons [7]. Many cephalopods such as the squid have evolved especially large axons which it uses to control its muscles. An axon is the part of a neuron that transmits information to other cells, and it works using ion channels, similar to cardiac muscles. The axons in squids are of comparable length to those found in other animals, but have a far greater diameter. For example most axons in humans are between 2µm and 20µm in diameter, but the Squid giant axon is between 250µm and 750µm. For normal fibers, the thicker the axon, the higher the conduction rate as shown in figure 2.1. This thicker axon allows the Squid to make very rapid movements, possibly to escape potential predators [8]. Figure 2.1: Diameter of animal axons against conduction rate The additional advantage of the giant axon is that it was physically big enough for Hodgkin and Huxley to attach electrodes to the axon and measure the action potential across the cell membrane. This allowed them to gather detailed findings about the ion channels of cells. 2.3 Current heart models In this section I will discuss different cardiac models and their applications. 7

2.3.1 Cell models Cardiac cell models attempt to model each individual cell as a separate entity with their own interactions. Ideally these will model all the processes of the cardiac cell, mainly their action potential, but ideally including all ion channels. Simplified models In some cases we may not want to have a completely realistic model of cells, a simplified model would be sufficient and would make any computations far more efficient. The first model that I studied was the Fitzhugh Nagumo model which is a simplified twovariable model, based on the Hodgkin-Huxley model for Giant Squid Axons. It was constructed in 1961 by Richard Fitzhugh and J. Nagumo. V t = 2 V + (a V )(V 1)V v x2 (2.1) v = ɛ(βv αv δ) t (2.2) This model reduces the complexity of the ion channels and instead represents the cells functions through a voltage variable (2.1) and a recovery variable(2.2) [9]. The simplicity of the Fitzhugh-Nagumo model was the main reason for choosing this model to implement myself first. Complex models On the other end of the spectrum we have complex cell models which aim to not simplify at all, instead representing every ion channel and process within the cardiac cells. These models are far more computationally expensive but give a deeper understanding of cell dynamics. The Luo-Rudy model is an exceptionally complex model that models all of the ion channels plus many intercellular interactions. Figure 2.2 shows all of the separate ion channels and extra cell processes that it models. 2.3.2 Tissue models The behaviour of the individual cells working together over a large area of tissue has additional effects to the hearts behaviour. There are two models for cardiac tissue: Monodomain model The monodomain model is a simpler representation which ignores extracellular space and only represents the cells and their individual behaviours through ion channels. 8

Figure 2.2: Diagram of ion channels represented in the Luo-Rudy model [10] Bidomain model The bidomain model also considers the extracellular space which changes from the contraction and relaxation of the cells over an area. This has effects on diffusion of ions as cells are pushed closer together during contraction, and apart during relaxation. 2.3.3 Anatomical models Anatomical models consider cardiac modelling as a three-dimensional problem and attempt to fit cell models and tissue models onto a three-dimensional mesh. This includes modelling the orientation of muscles fibres, and ideally the position of the sinoatrial node. [9] 9

Chapter 3 Implementation This section contains the work I made towards studying existing heart models. I wrote all the code myself as to get a better understanding of the problem. I decided to write the code in matlab for easier prototyping and testing, and so I could focus more on the models and quickly get graphical results of them 3.1 Single Cell I constructed the Fitzhugh-Nagumo model (2.1)(2.2) for a single cell in Matlab. I used the forward Euler method to calculate the value of each variable at the following timestep, and used Dirichlet boundary conditions, where both boundaries were set to 0. In figure 3.1 a small stimulus is provided at 100 timesteps, which causes the voltage variable in red to spike and then rapidly fall. While the voltage variable is hitting its minimum point, the recovery variable peaks at 0.18, then the two variable converge back to zero. This process of spiking and then converging to zero represents a myocyte (cardiac cell) contracting and then relaxing. In figure 3.2 I experimented with introducing stimuli at different times. Here I introduced a stimulus at 300 timesteps and another at 500 timesteps before the system had converged back to zero. The gap between stimuli was sufficiently large in this case that although the second spike is slightly different in shape, the system still reacted in a similar way. In figure 3.3 I introduced a stimulus at 100 and then shortly after at 180 timesteps. This was too soon after the last stimulus and the system failed to react properly, and it did not produce a second spike from the second stimulus. 3.2 One dimensional model I then implemented the Fithugh-Nagumo model in 1 dimension with a computational mesh of 100 cells, and introduced a small stimulus at the centre cell in figure 3.4. I used dirichlet 10

Figure 3.1: Fitzhugh-Nagumo with a single stimulus at 100 timesteps Figure 3.2: Fitzhugh-Nagumo with two stimuli at 300 timesteps and 500 timesteps 11

Figure 3.3: Fitzhugh-Nagumo with two stimuli at 100 timesteps and 180 timesteps boundary conditions for simplicity, and I used central differences to discretise the diffusion term. The central stimulus affected the adjacent cells causing a ripple effect in both directions which continued with the same magnitude until it reached the boundary. The voltage for each cell behaves in the same way as the single cell demonstration as after spiking from stimulus, the voltage negative then slowly converges back to zero. This demonstrates the way that a cardiac cell being stimulated stimulates adjacent cells and propagates a wave outwards from the point of stimulus. 3.3 Two dimensional model Now that I have constructed my model in 1 dimension, I can take the model further and make it into a two dimensional model. The ripple effect that I observed in my one dimensional model doesn t apply in the same way though. As discussed in the background reading section, the Sino-Atrial node generates a stimulus in the heart that makes the heart beat. This impulse from the Sino-Atrial node causes a spiral wave effect on the heart tissue which I will attempt to recreate. For a spiral wave to form I had to change several aspects of my model. Dirichlet boundary conditions will make it impossible to create the spiral wave, so I had to implement homogeneous Neumann boundary conditions to prevent the boundaries of the domain affecting the spiral wave 12

Figure 3.4: Fitzhugh-Nagumo implemented in 1 dimension at 50 timesteps 13

Figure 3.5: Fitzhugh-Nagumo implemented in 1 dimension at 300 timesteps 14

negatively. One way to induce this spiral wave is to set the grid up so that the left half of the domain has the u, the voltage variable, set to 1. And in the lower half the of the domain v, the recovery variable should be set to 0.5. This setup is shown in figure 3.6. Figure 3.6: 2D model - initial setup This should be only left for a short amount of time, and then have both these sections wiped to zero. This will leave a single wave, as shown in figure 3.7. This wave propagates forward and through diffusion and the chain-reaction effect of the Fitzhugh-Nagumo model a spiral wave is created. This effect is shown in figures 3.8 to 3.12. I have changed the visualisation to be displayed from the top down, so that is easier to observe the spiral wave form. 15

Figure 3.7: 2D model - initial wave 16

Figure 3.8: 2D model - Spiral wave 1 17

Figure 3.9: 2D model - Spiral wave 2 18

Figure 3.10: 2D model - Spiral wave 3 19

Figure 3.11: 2D model - Spiral wave 4 20

Figure 3.12: 2D model - Spiral wave 5 21

Chapter 4 Evaluation The goal of this project was to study heart simulation models to better understand them, and to possibly apply this knowledge to investigating heart dysfunction. I believe that I ve accomplished the first part of my aims, but I have fallen short on coming close to achieving the second part. I recreated the Fitzhugh-Nagumo model and gauged it s accuracy based on other recreations of the model that I have found. The best recreation of the Fitzhugh-Nagumo model that I found on Flavio Fenton, and Elizabeth cherry s website, thevirtualheart.org [11]. Figure 4.1 shows the results that they produced, and if you look back to my own recreation of Fitzhugh-Nagumo as a single cell model in figure 3.1 you can see the similarities. Figure 4.1: Fitzhugh-Nagumo model - Thevirtualheart.org Attempting to replicate these results I discovered some of the limitations of the model. Larger values of dt caused instability in the model and produced useless results. This was due to the way that the forward Euler method works, in that there is a maximum value of dt that 22

the model will take, and any more than that will cause instability and bad results. Once I had created the model in 1 dimension, I just expanded on the code on top of the model to first apply it across 100 cells in 1 dimension (figures 3.6 to 3.7). With a bit of special setup, I was able to recreate the spiral waves that I had deemed to be my final minimum requirement. The 2 dimensional model remains true to the original model, and the single cell behaviour is clearly visible if seen from an angle, such as in figure 4.2. Figure 4.2: 2 Dimensional Fitzhugh-Nagumo from an angle Changing the variables of the model can produce different spiral wave results. For example, increasing the diffusion rate by a factor of three results in a much thicker spiral wave, as shown in figure 4.3. 4.1 Further work If I had the chance to do this project again and have the time to take the work further than the minimum requirements there are several areas that I would have liked to study. I m personally interested in computer graphics, and I would ve liked to get a simulation of a very large domain, or one of very fine detail. This could produce some interesting results, 23

Figure 4.3: 2 Dimensional Fitzhugh-Nagumo with triple diffusion 24

but would involve a lot of extra work as realistically I would have to stop using matlab. I used matlab to start with because it s perfect for quickly trying ideas out and then visualising them with matlab s built in tools, but I would have to write the software in C for it s greater efficiency and speed. Another possible idea would be to write it up for GPGPU computing, perhaps using the CUDA (Compute Unified Device Architecture) by Nvidia, or another GPU computing framework. The massively parallel design of graphics processors would be perfect for a problem such as this and once the software is written could produce very fast simulations of high detail. I also would ve liked to have been able to move on from the Fitzhugh-Nagumo model and attempt to implement some of the more complex models. These complex models which represent more of the actual functions of myocytes rather than approximating them allow for much more experimentation. Implementing a model such as Fenton-Karma or even Luo-Rudy would have given me a deeper insight into heart function. But this would have meant that Ihad to spend more time on the computation side of the project as a more complex model would require far more efficient code to get results within a reasonable time frame. Implementing more complex models would also open up another area of study that I am interested in. When I was researching ion channels, I discovered that certain drugs work to specifically target individual ion channels which I think is very interesting. I would have liked to replicate the effects of a certain drug by suppressing a certain ion channel and viewing the results. And finally, I would have liked to take the model from 2 dimensional, to 3 dimensional. But as with more complex models, this would have required me to rewrite most of my code to make it efficient enough to get results in a timely manner. 25

Bibliography [1] R. Clayton, O. Bernus, E. Cherry, H. Dierckx, F. Fenton, L. Mirabella, A. Panfilov, F. Sachse, G. Seemann, and H. Zhang, Models of cardiac tissue electrophysiology: Progress, challenges and open questions, Progress in Biophysics and Molecular Biology, vol. 104, no. 1-3, pp. 22 48, 2011. Cardiac Physiome project: Mathematical and Modelling Foundations. [2] B. Hille, Ionic channels in excitable membranes, Biophysical Journal, 1977. [3] D. J. Camerino DC, Tricarico D, Ion channel pharmacology, Neurotherapeutics, pp. 184 198, April 2007. [4] C. E. Dangerfield, D. Kay, and K. Burrage, Stochastic models and simulation of ion channel dynamics, Procedia Computer Science, vol. 1, no. 1, pp. 1581 1590, 2010. [5] M. Nash, Electromechanical model of excitable tissue to study reentrant cardiac arrhythmias, Progress in Biophysics and Molecular Biology, vol. 85, pp. 501 522, July 2004. [6] M. Boyett and H. Dobrzynski, The sinoatrial node is still setting the pace 100 years after its discovery, Circ Res, vol. 100, no. 11, pp. 1543 1545, 2007. [7] D. Noble, From the hodgkin-huxley axon to the virtual heart, Oct. 2006. [8] Robert.C.Eaton, Neural Mechanisms of Startle Behaviour. Springer, 1997. [9] R. H. Clayton and A. V. Panfilov, A guide to modelling cardiac electrical activity in anatomically detailed ventricles, Progress in Biophysics and Molecular Biology, vol. 96, pp. 19 43, Jan. 2008. [10] Y. Rudy, Single Cell Phenomena, 2009. [11] F. F. Elizabeth Cherry, Fitzhugh-Nagumo (FHN) model, 2009. 26

Appendix A Appendix A - Personal reflection I asked my supervisor, Matthew Hubbard on how I should approach this segment and he said Think of it as general advice to a second year who might be starting a similar type of project next year. With that in mind, I think that this project shows the importance of a proper work ethic and time management. Over the past 16 weeks I have struggled to find motivation to work on this project. I haven t shown what I believe to be my full academic potential by a long way, due to my own personal issues with time management and having any form of a work ethic. I m certain that sixteen weeks of a couple of contact hours per week helped a lot of people have the time to focus and work on their project without lectures or other educational deadlines to meet. But I think I found this made it easy to distance myself from the university and my work, and I found myself slowly slipping behind on work after the first month or so and failed to ever catch up to the point that I should have been. And from this a cycle of procrastination and guilt over said procrastination followed, and without seeking help at an early stage it s possible to fall very far behind and be a week from the deadline with nothing but your mid-project report to your name. That said, I completed my minimum requirements, but there is so much more I would ve like to add, and I ve mentioned them in the further work section of the evaluation. In some respects I really enjoyed this particular area of study, but the above issues stopped me from getting close to anything like my plans that I had for taking the project past my minimum requirements and I m really disappointed with myself for letting this happen. I would ve also liked to do a proper write-up of my work and be able to come to a proper conclusion over what I ve accomplished. 27

Appendix B Appendix B - Code B.1 fitzhugh.m f u n c t i o n [ du, dv ] = fitzhugh (u, v ) %FITZHUGH a = 0. 1 ; b = 0. 5 ; gam = 1 ; e p s i = 0. 0 1 ; d e l t a = 0 ; du = ( a u ) ( u 1) u v ; dv = e p s i ( b u gam v d e l t a ) ; end 28

B.2 fitzplot.m f u n c t i o n [ t, u, v ] = f i t z P l o t ( t0, u0, v0, t f i n a l ) % f i t z P l o t ( 0, 1, 0. 1, 2 5 0 ) % timestep dt = 0. 0 1 ; %s e t up m a t r i c e s t = z e r o s ( t f i n a l /dt, 1 ) ; u = z e r o s ( t f i n a l /dt, 1 ) ; v = z e r o s ( t f i n a l /dt, 1 ) ; %i n i t i a l vars t ( 1 ) = t0 ; u ( 1 ) = u0 ; v ( 1 ) = v0 ; f o r i = 1 : t f i n a l / dt ct = i dt ; [ du, dv ] = fitzhugh ( u ( i ), v ( i ) ) ; u ( i +1) = u ( i ) + dt du ; v ( i +1) = v ( i ) + dt dv ; t ( i +1) = t ( i ) + dt ; i f ( ct > 100) && ( ct < 105) u ( i +1) = u ( i +1) + 0. 0 0 0 0 1 ; end i f ( ct > 125) && ( ct < 130) u ( i +1) = u ( i +1) + 0. 0 0 0 0 1 ; end end c l o s e a l l ; pu = p l o t ( t, u ) ; s e t ( pu, Color, red ) hold on ; pv = p l o t ( t, v ) ; 29

B.3 fhn1d.m f u n c t i o n [ u, v ] = fhn1d ( save, c e l l s, d i f f R a t e, stime, sduration, t F i n a l ) %fhn1d ( 0, 1 0 0, 0. 0 0 1, 0. 0 5, 0. 2, 6 ) %stime = Time o f s p i k e % This i s as a f r a c t i o n o f t F i n a l %sduration = Duration o f s p i k e s P o s i t i o n = c e l l s / 2 ; %S i z e o f problem : x l = 0 ; xr = 1 ; dx = ( xl xr )/ c e l l s ; %timestep dt = 0. 0 1 ; %s e t up m a t r i c e s u = z e r o s ( t F i n a l /dt, c e l l s +2); v = z e r o s ( t F i n a l /dt, c e l l s +2); %Boundary c o n d i t i o n s u ( 1 : t F i n a l /dt, 1 ) = 0 ; u ( 1 : t F i n a l /dt, c e l l s +2) = 1 ; %Set up animation c l o s e a l l s e t ( gca, nextplot, r e p l a c e c h i l d r e n ) a x i s ( [ 0 c e l l s +2 0.3 1. 1 ] ) x l a b e l ( C e l l s ) ; y l a b e l ( Voltage ) ; d2u = 0 ; %Loop through time f o r i = 1 : t F i n a l / dt %c t = Current time ct = i dt ; s e t ( gcf, Position, [ 2 4 0, 2 0 0, 6 0 0, 6 0 0 ] ) s e t ( gca, PlotBoxAspectRatio, [ 1, 1, 1 ] ) 30

%Loop through space f o r j = 2 : c e l l s +1 %2nd D i f f e r e n t i a l d2u = d i f f R a t e ( u ( i, j +1) 2 u ( i, j ) + u ( i, j 1))/( dx ˆ 2 ) ; %Fitzhugh algorithm [ du, dv ] = fitzhugh ( u ( i, j ), v ( i, j ) ) ; du = 100 du + d2u ; dv = 100 dv ; %Update v a l u e s u ( i +1, j ) = u ( i, j ) + dt du ; v ( i +1, j ) = v ( i, j ) + dt dv ; end p l o t ( u ( i, : ) ) ; F( i ) = getframe ; f r a m e f i l e = [ frame i n t 2 s t r ( i 1)] i f ( ct >= stime t F i n a l ) && ( ct <= stime t F i n a l + sduration ) u ( 1 : t F i n a l /dt, s P o s i t i o n ) = u ( 1 : t F i n a l /dt, s P o s i t i o n ) + 0. 1 ; s p i k e = 1 end end i f save == 1 end p r i n t ( djpeg, f r a m e f i l e ) i f save == 0 disp ( Playing the movie... ) movie (F) end 31

B.4 fhn2d.m f u n c t i o n [ u, v ] = fhn2d ( save, c e l l s, d i f f R a t e, stime, sduration, t F i n a l ) %fhn2d ( 0, 1 0 0, 0. 0 0 0 0 1, 0. 0 5, 2 0, 1 0 0 0 ) %stime = Time o f s p i k e % This i s as a f r a c t i o n o f t F i n a l %sduration = Duration o f s p i k e %S i z e o f problem : x l = 0 ; xr = 1 ; dx = ( xl xr )/ c e l l s ; %timestep dt = 0. 5 ; %s e t up m a t r i c e s u = z e r o s ( c e l l s +2, c e l l s +2); v = z e r o s ( c e l l s +2, c e l l s +2); u D i f f = z e r o s ( c e l l s +2, c e l l s +2); v D i f f = z e r o s ( c e l l s +2, c e l l s +2); %Set up animation c l o s e a l l a x i s ( [ 0 c e l l s +1 0 c e l l s +1 0.3 1. 1 ] ) s e t ( gca, nextplot, r e p l a c e c h i l d r e n ) x l a b e l ( C e l l s x ) ; y l a b e l ( C e l l s y ) ; z l a b e l ( Voltage ) ; sa = s i z e ( u ) ; %Loop through time f o r t = 1 : t F i n a l / dt %c t = Current time ct = t dt ; %s e t ( gcf, Position, [ 2 4 0, 2 0 0, 6 0 0, 6 0 0 ] ) s e t ( gca, PlotBoxAspectRatio, [ 1, 1, 1 ] ) %%% Neumann boundary c o n d i t i o n s 32

%Top boundary f o r i = 2 : c e l l s +1 u ( i, 1 ) = u ( i, 3 ) ; end %bottom boundary f o r i = 2 : c e l l s +1 u ( i, c e l l s +2) = u ( i, c e l l s ) ; end %l e f t boundary f o r i = 2 : c e l l s +1 u ( 1, i ) = u ( 3, i ) ; end %r i g h t boundary f o r i = 2 : c e l l s +1 u ( c e l l s +2, i ) = u ( c e l l s, i ) ; end %Loop through space ( x ) f o r i = 2 : c e l l s +1 %Loop through space ( y ) f o r j = 2 : c e l l s +1 %2nd D i f f e r e n t i a l d2u = d i f f R a t e ( ( u ( i, j +1) 2 u ( i, j ) + u ( i, j 1))/( dx ˆ2) + ( u ( i +1, j ) 2 u ( %Fitzhugh algorithm [ du, dv ] = fitzhugh ( u ( i, j ), v ( i, j ) ) ; du = du + d2u ; %C a l c u l a t e d i f f e r e n c e s u D i f f ( i, j ) = dt du ; v D i f f ( i, j ) = dt dv ; %Update c u r r e n t value u ( i, j ) = u ( i, j ) + u D i f f ( i, j ) ; v ( i, j ) = v ( i, j ) + v D i f f ( i, j ) ; end end mesh ( u ) ; view ( [ 9 0 9 0 ] ) %Induce Stimulus f o r s p i r a l wave 33

i f ct < 35 u ( 2 : ( ( c e l l s + 1 ) / 2 ), 2 : ( c e l l s +1)) = 1 ; v ( 2 : ( c e l l s +1),(( c e l l s +1)/2):( c e l l s +1)) = 0. 5 ; end % Wipe 3/4 o f mesh to s t a r t s p i r a l wave i f ct >= 35 && ct < 50 u ( ( 2 : c e l l s +1),(( c e l l s +1)/2):( c e l l s +1)) = 0 ; v ( ( 2 : c e l l s +1),(( c e l l s +1)/2):( c e l l s +1)) = 0 ; u ( 2 : ( ( c e l l s + 1 ) / 2 ), 2 : ( c e l l s +1)) = 0 ; v ( 2 : ( ( c e l l s + 1 ) / 2 ), 2 : ( c e l l s +1)) = 0 ; end end 34