Myokit is a python-based software package designed to simplify the use of numerical models in the analysis of cardiac myocyte electrophysiology. It was created at Maastricht University, and developed further at the University of Oxford and the University of Nottingham. Myokit is released as open source software under a BSD 3-Clause License.

If you have any questions about using Myokit, please post them on the discussion forum. Problems with or suggestions for the software can be reported on the issues page. To contact Myokit's lead developer, use michael@myokit.org.

Last update: October 2nd, 2024.

What does it do?

Myokit provides a straightforward modelling language that allows you to write model equations without implementation details. Once a model has been defined, single or multi-cellular simulations can be run on your CPU or GPU.

Myokit can import models from CellML or SBML and export to C, matlab, python, CUDA, OpenCL and more. The separation of model code from engine allows you to run multiple types of analysis without having to rework your model. Conversely, scripted experiments set up using Myokit can be repeated for different models with little or no modifications.

A model editing GUI is provided as well as a growing number of tools for simulation, sensitivity analysis, parameter estimation and more. For a quick glance at some of the possibilities, see the examples page.

How does it work?

Behind the scenes, Myokit takes advantage of Python's distutils module to generate and compile simulation code on the fly. This means that, while the experiment is set up and post-processed in high-level Python, the actual simulation runs entirely in low-level C.

By building on the stiff-ode solver CVODES for single cell simulations and using OpenCL for multi-cell simulations, Myokit achieves the kind of performance usually associated with implementations in C or C++.

An example using the API

Myokit experiments are stored in an .mmt file containing

  1. A model definition (in myokit's model definition syntax). This contains all model equations, comments, units and the initial values of the state variables.
  2. A pacing protocol. This can be either a periodic stimulus for ordinary pacing, or a more complex protocol that mimicks patch-clamp experiments.
  3. A plot script (in plain python). In this part, you set up the simulation, run it and process the results.

In the example below, we're going to ignore the plot script and use only the model and protocol:

import myokit

# Load a model, protocol and plot script
m,p,x = myokit.load('example.mmt')

# Set 25% IK1 block
m.set_value('block.IK1', 0.25)

# Create a simulation
s = myokit.Simulation(m, p)

# Pre-pace for 99 beats
cl = 1000  # This should correspond to the cycle length of the protocol!
s.pre(99 * cl)

# Run the simulation for a single beat
d = s.run(1 * cl)

# Plot the results
import matplotlib.pyplot as plt
plt.figure()
plt.title('Membrane potential')
plt.plot(d['engine.time'], d['membrane.V'])
plt.show()

An example using the GUI

The myokit GUI provides a tiny IDE for myokit models. The example below shows a model being edited in the GUI.

Using the "explorer" view you can browse the results of a simulation