Skip to content

Commit 0aa2515

Browse files
committed
Moving away from using term 'tutorial'
1 parent 8fb6440 commit 0aa2515

35 files changed

+207
-169
lines changed

README.md

Lines changed: 106 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,107 @@
1-
# Fitting ion channel models with Myokit & PINTS
2-
3-
This repository contains examples showing how to fit Myokit models to data using the PINTS optimisation & inference framework.
4-
5-
A part on fitting AP models is planned, but for now the repository contains:
6-
7-
- a [detailed tutorial](ion-currents-tutorial/README.md) showing how to fit kinetic parameters of ion current models.
8-
9-
## General recommendations
10-
11-
**Start with a synthetic data study:**
12-
Before going to the lab, work out what data you expect to get, simulate this data and add noise, prepare your analysis code, and test that it can recover the parameters you used to generate the data.
13-
14-
**Fit to time-series data:**
15-
Whenever possible, fit to time-series data, not to "summary statistics" or "biomarkers" such as time constants, IV-, or (in)activation curves.
16-
Contacting experimenters, digging in archives, or even repeating experiments is a better use of time than trying to fit to data not suitable for fitting to.
17-
18-
**Define expected ranges for the parameters:**
19-
Define boundaries on the parameters (or on e.g. rates derived from the parameters).
20-
These can speed up your search, but are also used to prevent numerical problems and solver failures when certain parameters and functions of parameters get too large or small.
21-
22-
**Verify the reliability of your results:** by running repeated fits.
23-
Restart your fit several (50?) times from different positions sampled from within the feasible ranges of the parameters.
24-
If only a handful of fits find the same "best result", it's likely this isn't the true optimum.
25-
26-
**Check your solver tolerances**: if using an adaptive step-size solver, make sure you use strict tolerances.
27-
If you're not sure, plot the error measure along a line between two nearby points: if it's nice and smooth the optimiser will love it.
28-
29-
**Search in a log-transformed parameter space**: This can often make the problem much easier for whatever optimisation algorithm you're using.
30-
31-
**Use the CMA-ES optimiser**: It performs much better on these problems than anything else we've tested.
32-
33-
## More information
34-
35-
### Software
36-
37-
- **Probabilistic Inference on Noisy Time Series (PINTS)**.
38-
Michael Clerx, Martin Robinson, Ben Lambert, Chon Lok Lei, Sanmitra Ghosh, Gary R. Mirams, David J. Gavaghan.
39-
2019, Journal of Open Research Software.
40-
[doi:10.5334/jors.252](https://doi.org/10.5334/jors.252)
41-
| [examples](https://github.com/pints-team/pints/blob/master/examples/README.md)
42-
| [documentation](https://pints.readthedocs.io/)
43-
| [installation](https://github.com/pints-team/pints/)
44-
| [code](https://github.com/pints-team/pints/)
45-
46-
- **Myokit: A simple interface to cardiac cellular electrophysiology**.
47-
Michael Clerx, Pieter Collins, Enno de Lange, Paul G.A. Volders.
48-
2016, Progress in Biophysics and Molecular Biology.
49-
[doi:10.1016/j.pbiomolbio.2015.12.008](https://doi.org/10.1016/j.pbiomolbio.2015.12.008)
50-
| [examples](http://myokit.org/examples/)
51-
| [documentation](https://myokit.readthedocs.io)
52-
| [installation](http://myokit.org/install)
53-
| [website](http://myokit.org)
54-
| [code](https://github.com/MichaelClerx/myokit/)
55-
56-
### Papers
57-
58-
- **Calibration of ionic and cellular cardiac electrophysiology models**.
59-
Dominic G. Whittaker, Michael Clerx, Chon Lok Lei, David J. Christini, Gary R. Mirams.
60-
2020, WIREs Systems Biology and Medicine.
61-
[doi:10.1002/wsbm.1482](https://doi.org/10.1002/wsbm.1482)
62-
| [code](https://github.com/CardiacModelling/WIRES)
63-
64-
- **Four ways to fit an ion channel model**.
65-
Michael Clerx, Kylie A. Beattie, David J. Gavaghan, Gary R. Mirams.
66-
2019, Biophysical Journal.
67-
[doi:10.1016/j.bpj.2019.08.001](https://doi.org/10.1016/j.bpj.2019.08.001)
68-
| [code](https://github.com/CardiacModelling/FourWaysOfFitting)
69-
70-
- **Rapid characterisation of hERG channel kinetics I: using an automated high-throughput system**.
71-
Chon Lok Lei, Michael Clerx, David J. Gavaghan, Liudmila Polonchuk, Gary R. Mirams, Ken Wang.
72-
2019, Biophysical Journal.
73-
[doi:j.bpj.2019.07.029](https://doi.org/10.1016/j.bpj.2019.07.029)
74-
| [code](https://github.com/CardiacModelling/hERGRapidCharacterisation)
75-
76-
- **Rapid characterisation of hERG channel kinetics II: temperature dependence**.
77-
Chon Lok Lei, Michael Clerx, Kylie A. Beattie, Dario Melgari, Jules C. Hancox, David J. Gavaghan, Liudmila Polonchuk, Ken Wang, Gary R. Mirams.
78-
2019, Biophysical Journal.
79-
[doi:j.bpj.2019.07.030](https://doi.org/10.1016/j.bpj.2019.07.030)
80-
| [code](https://github.com/CardiacModelling/hERGRapidCharacterisation)
81-
82-
- **Sinusoidal voltage protocols for rapid characterisation of ion channel kinetics**
83-
Kylie A. Beattie, Adam P. Hill, Rémi Bardenet, Yi Cui, Jamie I. Vandenberg, David J. Gavaghan, Teun P. de Boer, Gary R. Mirams
84-
2018, The Journal of Physiology.
85-
[doi:10.1113/JP275733](https://doi.org/10.1113/JP275733)
86-
| [code](https://github.com/mirams/sine-wave)
87-
88-
### Advanced topics
89-
90-
- **Accounting for variability in ion current recordings using a mathematical model of artefacts in voltage-clamp experiments**
91-
Chon Lok Lei, Michael Clerx, Dominic G. Whittaker, David J. Gavaghan, Teun P. de Boer, Gary R. Mirams
92-
[doi:10.1098/rsta.2019.0348](https://doi.org/10.1098/rsta.2019.0348)
93-
| [code](https://github.com/CardiacModelling/VoltageClampModel)
94-
95-
- **Considering discrepancy when calibrating a mechanistic electrophysiology model**
96-
Chon Lok Lei, Sanmitra Ghosh, Dominic G. Whittaker, Yasser Aboelkassem, Kylie A. Beattie, Chris D. Cantwell, Tammo Delhaas, Charles Houston, Gustavo Montes Novaes, Alexander V. Panfilov, Pras Pathmanathan, Marina Riabiz, Rodrigo Weber dos Santos, John Walmsley, Keith Worden, Gary R. Mirams, Richard D. Wilkinson
97-
2020, Phil. Trans. R. Soc. A.
98-
[doi:10.1098/rsta.2019.0349](http://doi.org/10.1098/rsta.2019.0349)
99-
| [code](https://github.com/CardiacModelling/fickleheart-method-tutorials)
1+
[↩ back to index](../README.md)
2+
# Estimating parameters of ion current models from whole-cell voltage-clamp data
3+
4+
In these notebooks, we look at the problem of estimating the parameters of an ion current model from whole-cell voltage-clamp data.
5+
6+
As we go along, we'll create some classes and utility functions that may be useful in general.
7+
These are all stored in [library.py](./library.py).
8+
9+
The follow topics are covered:
10+
11+
## [Introduction](introduction.ipynb) - [nbviewer](https://nbviewer.jupyter.org/github/CardiacModelling/fitting-notebooks/blob/main/ion-currents/introduction.ipynb)
12+
13+
This notebook provides some background on the model we'll use in all examples.
14+
It also introduces a first voltage-protocol (a simplified variant of the "staircase protocol").
15+
16+
## [Basic simulations](basic-simulations.ipynb) - [nbviewer](https://nbviewer.jupyter.org/github/CardiacModelling/fitting-notebooks/blob/main/ion-currents/basic-fitting.ipynb)
17+
18+
This notebook shows how Myokit can be used to simulate patch-clamp experiments.
19+
It shows you how to create a simulation from a model and protocol stored on disk, and discusses how to change model parameters.
20+
Finally, it shows how steady-states can be calculated and set as initial conditions.
21+
22+
## [Basic fitting](basic-fitting.ipynb)
23+
24+
In this notebook we link Myokit to PINTS.
25+
Noise models are discussed and synthetic data is generated, after which an error measure is defined and minimised.
26+
Inspecting the results, we show how tight solver tolerances are needed for fitting, and how the finite size of our experimental time series can cause a slight bias in the results.
27+
28+
## Fitting to different voltage protocols
29+
30+
The next four notebooks discuss different voltage protocols, and the simulation methods appropriate to each one.
31+
32+
- [Combining step protocols with sine waves or ramps](more-protocols-1-steps-and-ramps.ipynb) - [nbviewer](https://nbviewer.jupyter.org/github/CardiacModelling/fitting-notebooks/blob/main/ion-currents/more-protocols-1-steps-and-ramps.ipynb)
33+
- [Simulating an AP protocol with "data clamp"](more-protocols-2-data-clamp.ipynb)
34+
- [Analytical solvers for simple step protocols](more-protocols-3-analytic-solvers.ipynb)
35+
- [Fitting to multiple simple step protocols](more-protocols-4-multiple-protocols.ipynb)
36+
37+
## [Setting boundaries on model parameters](boundaries.ipynb)
38+
39+
In this notebook we show how some parameters can cause numerical issues during simulation, and how we can catch and report these errors.
40+
We then inspect the model equations and use previous estimates of our parameters (or quantities related to the parameters) to define some very wide boundaries, or "prior estimates".
41+
Finally, we show how we can use this kind of reasoning to define univariate boundaries (one on each parameter), and multivariate boundaries (which restrict the maximum rate coefficients seen during a simulation).
42+
43+
## [Selecting starting points for an optimisation](starting-points.ipynb)
44+
45+
Continuing from the previous chapters, this notebook shows how we can sample from within the (univariate and multivariate) boundaries to select starting points for an optisiation.
46+
At the end of this notebook we briefly discuss a "repeated-fits" strategy which allows you to test the reliability of results obtained on real data, where the "true" parameters are not known.
47+
48+
## [Searching in a transformed space](transformations.ipynb)
49+
50+
This notebook shows how you can create wrappers around models and boundaries to run optimisations on a transformed parameter space.
51+
52+
## [Running big fitting experiments](big-fitting.ipynb)
53+
54+
This notebook focusses on the practical side of fitting.
55+
It introduces methods to store simulation results to disk, load and analyse them, and shows a way to "reserve" filenames when multiple processes are running at once.
56+
It ends with a brief note on multiprocessing.
57+
58+
## [Validating modelling results](validation.ipynb)
59+
60+
- Repeated runs (see previous notebook) validates fitting
61+
- Training, validation, and test sets validates modelling?
62+
63+
## Dealing with real data
64+
65+
Blah blah blah
66+
67+
These are sequential, not independent notebooks
68+
69+
- [Introduction, and additive noise](real-data-1-noise.ipynb)
70+
- [Capacitance and series resistance](real-data-2-capacitance-and-resistance.ipynb)
71+
72+
- One
73+
- Four strategies
74+
- Noise model
75+
- Stochastic noise
76+
- Periodic noise
77+
- Two
78+
- Pipette capacitance
79+
- Membrane capacitance
80+
81+
Sources:
82+
- [x] Thermal, shot, mains, etc.
83+
- [x] Stray capacitance
84+
- [ ] Membrane capacitance
85+
- [ ] Series resistance
86+
- [ ] Leak
87+
- [ ] Endogeneous currents
88+
- [ ] Gating currents? (~100x smaller than ionic currents)
89+
90+
Things to be uncertain about
91+
- [ ] Concentrations
92+
- [ ] Reversal potential (Nernst/GHK graph?)
93+
- [ ] Temperature
94+
- [ ] Model discrepancy
95+
96+
Methods
97+
- [x] Low-pass filter
98+
- [x] Modelling noise
99+
- [x] Stray cap correction
100+
- [ ] Cm correction
101+
- [ ] Artefact filtering
102+
- [ ] Rs correction
103+
- [ ] Subtraction protocol
104+
- [ ] Leak correction
105+
- [ ] Leak ramp
106+
- [ ] Reversal potential ramp
100107

ion-currents-tutorial/README.md renamed to ion-currents/README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,57 @@
11
[↩ back to index](../README.md)
22
# Estimating parameters of ion current models from whole-cell voltage-clamp data
33

4-
In this tutorial, we look at the problem of estimating the parameters of an ion current model from whole-cell voltage-clamp data.
4+
In these notebooks, we look at the problem of estimating the parameters of an ion current model from whole-cell voltage-clamp data.
55

66
As we go along, we'll create some classes and utility functions that may be useful in general.
77
These are all stored in [library.py](./library.py).
88

99
The follow topics are covered:
1010

11-
## [Introduction](introduction.ipynb)
11+
## [Introduction](introduction.ipynb) - [nbviewer](https://nbviewer.jupyter.org/github/CardiacModelling/fitting-notebooks/blob/main/ion-currents/introduction.ipynb)
1212

13-
This tutorial provides some background on the model we'll use throughout the tutorial.
13+
This notebook provides some background on the model we'll use in all examples.
1414
It also introduces a first voltage-protocol (a simplified variant of the "staircase protocol").
1515

16-
## [Basic simulations](basic-simulations.ipynb)
16+
## [Basic simulations](basic-simulations.ipynb) - [nbviewer](https://nbviewer.jupyter.org/github/CardiacModelling/fitting-notebooks/blob/main/ion-currents/basic-fitting.ipynb)
1717

18-
This tutorial shows how Myokit can be used to simulate patch-clamp experiments.
18+
This notebook shows how Myokit can be used to simulate patch-clamp experiments.
1919
It shows you how to create a simulation from a model and protocol stored on disk, and discusses how to change model parameters.
2020
Finally, it shows how steady-states can be calculated and set as initial conditions.
2121

2222
## [Basic fitting](basic-fitting.ipynb)
2323

24-
In this tutorial we link Myokit to PINTS.
24+
In this notebook we link Myokit to PINTS.
2525
Noise models are discussed and synthetic data is generated, after which an error measure is defined and minimised.
2626
Inspecting the results, we show how tight solver tolerances are needed for fitting, and how the finite size of our experimental time series can cause a slight bias in the results.
2727

2828
## Fitting to different voltage protocols
2929

3030
The next four notebooks discuss different voltage protocols, and the simulation methods appropriate to each one.
3131

32-
- [Combining step protocols with sine waves or ramps](more-protocols-1-steps-and-ramps.ipynb)
32+
- [Combining step protocols with sine waves or ramps](more-protocols-1-steps-and-ramps.ipynb) - [nbviewer](https://nbviewer.jupyter.org/github/CardiacModelling/fitting-notebooks/blob/main/ion-currents/more-protocols-1-steps-and-ramps.ipynb)
3333
- [Simulating an AP protocol with "data clamp"](more-protocols-2-data-clamp.ipynb)
3434
- [Analytical solvers for simple step protocols](more-protocols-3-analytic-solvers.ipynb)
3535
- [Fitting to multiple simple step protocols](more-protocols-4-multiple-protocols.ipynb)
3636

3737
## [Setting boundaries on model parameters](boundaries.ipynb)
3838

39-
In this tutorial we show how some parameters can cause numerical issues during simulation, and how we can catch and report these errors.
39+
In this notebook we show how some parameters can cause numerical issues during simulation, and how we can catch and report these errors.
4040
We then inspect the model equations and use previous estimates of our parameters (or quantities related to the parameters) to define some very wide boundaries, or "prior estimates".
4141
Finally, we show how we can use this kind of reasoning to define univariate boundaries (one on each parameter), and multivariate boundaries (which restrict the maximum rate coefficients seen during a simulation).
4242

4343
## [Selecting starting points for an optimisation](starting-points.ipynb)
4444

45-
Continuing from the previous tutorial, this tutorial shows how we can sample from within the (univariate and multivariate) boundaries to select starting points for an optisiation.
46-
At the end of this tutorial we briefly discuss a "repeated-fits" strategy which allows you to test the reliability of results obtained on real data, where the "true" parameters are not known.
45+
Continuing from the previous chapters, this notebook shows how we can sample from within the (univariate and multivariate) boundaries to select starting points for an optisiation.
46+
At the end of this notebook we briefly discuss a "repeated-fits" strategy which allows you to test the reliability of results obtained on real data, where the "true" parameters are not known.
4747

4848
## [Searching in a transformed space](transformations.ipynb)
4949

50-
This tutorial shows how you can create wrappers around models and boundaries to run optimisations on a transformed parameter space.
50+
This notebook shows how you can create wrappers around models and boundaries to run optimisations on a transformed parameter space.
5151

5252
## [Running big fitting experiments](big-fitting.ipynb)
5353

54-
This tutorial focusses on the practical side of fitting.
54+
This notebook focusses on the practical side of fitting.
5555
It introduces methods to store simulation results to disk, load and analyse them, and shows a way to "reserve" filenames when multiple processes are running at once.
5656
It ends with a brief note on multiprocessing.
5757

ion-currents-tutorial/basic-fitting.ipynb renamed to ion-currents/basic-fitting.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"source": [
77
"# First steps: a synthetic data study\n",
88
"\n",
9-
"In this part of the tutorial, we'll take a [myokit.Simulation](https://myokit.readthedocs.io/api_simulations/Simulation.html) and wrap it in a [pints.ForwardModel](https://pints.readthedocs.io/en/latest/core_classes_and_methods.html#forward-model).\n",
9+
"In this notebook, we'll take a [myokit.Simulation](https://myokit.readthedocs.io/api_simulations/Simulation.html) and wrap it in a [pints.ForwardModel](https://pints.readthedocs.io/en/latest/core_classes_and_methods.html#forward-model).\n",
1010
"We'll then use this ForwardModel to generate some data, add synthetic noise, and set up a [pints.SingleOutputProblem](https://pints.readthedocs.io/en/latest/core_classes_and_methods.html#pints.SingleOutputProblem).\n",
1111
"Finally, we'll define an [ErrorMeasure](https://pints.readthedocs.io/en/latest/error_measures.html#pints.ErrorMeasure) on this problem and use an [Optimiser](https://pints.readthedocs.io/en/latest/optimisers/index.html) to find that parameters that minimise it.\n",
1212
"\n",
@@ -141,7 +141,7 @@
141141
"cell_type": "markdown",
142142
"metadata": {},
143143
"source": [
144-
"Real voltage-clamp experiments are affected by various noise and error sources (see the \"real data\" part of the tutorial for details).\n",
144+
"Real voltage-clamp experiments are affected by various noise and error sources (see the \"Dealing with real data\" notebooks for details).\n",
145145
"In this example, we'll keep it simple and only add some Gaussian (i.e. normally distributed) noise:"
146146
]
147147
},
@@ -907,14 +907,14 @@
907907
"source": [
908908
"## Summary\n",
909909
"\n",
910-
"In this part of the tutorial we have\n",
910+
"In this notebook we have\n",
911911
"\n",
912912
"- Set up a PINTS problem and defined an error measure\n",
913913
"- Used an optimisation to find the parameters that minimise this error\n",
914914
"- Seen the benefits of using a fine tolerance when running simulations\n",
915915
"- Seen bias in our estimate of the parameters, caused by our finite sampling of noisy data\n",
916916
"\n",
917-
"In the next tutorial we'll look at some more simulation methods, selecting the appropriate types for different models and protocols."
917+
"In the next notebook we'll look at some more simulation methods, selecting the appropriate types for different models and protocols."
918918
]
919919
}
920920
],
@@ -934,7 +934,7 @@
934934
"name": "python",
935935
"nbconvert_exporter": "python",
936936
"pygments_lexer": "ipython3",
937-
"version": "3.7.7"
937+
"version": "3.9.5"
938938
}
939939
},
940940
"nbformat": 4,

0 commit comments

Comments
 (0)