Electrophysiology simulations of a cardiac atrial cell (Maleckar model) with acidosis modulation (pH variation) affecting ionic currents and action potential dynamics. The project is designed to study transient and steady-state behavior of state variables, currents, conductances, and AP metrics under healthy and acidotic conditions.
- Maleckar atrial cell model simulation in MATLAB
- pH profile: fixed or linearly decreasing over time (ischemia phase 1A)
- Automatic plots of 30 state variables and ionic species
- Extraction and visualization of currents (
i_Na,i_CaL,i_NaCa...), apparent conductances, and Nernst potentials - Metrics computation:
Vrest,Vpp,dV/dt_max,APD90,APD50,TRI,DI - Restitution curves (APD–DI) across different BCLs
- AP shape video over time (
plot_video.mp4)
Animated visualization of the action potential (AP) morphology as extracellular pH decreases from ≈7.2 to ≈6.2 (ischemia phase 1A). Each trace corresponds to the last beat of successive minutes during the protocol. Notice the progressive reduction of upstroke velocity (dV/dt_max) and peak-to-peak amplitude (Vpp), the shortening of AP duration (APD), increased triangulation (TRI), and a gradual shift in the resting potential. Important: after 10 minutes, Delayed After Depolarizations (DADs) start to appear!
Schematic of the main processes modulated by extracellular acidosis during ischemia 1A: reduced sodium current (i_Na) and L-type calcium current (i_CaL), altered Na–Ca exchanger (i_NaCa), and consequent shifts in Nernst potentials and buffering. Together, these changes reduce upstroke velocity and peak amplitude, shorten AP duration, and increase triangulation.
Overview panel of all 30 state variables tracked by the model across the simulation, covering ionic concentrations, gating variables, SR handling, and buffering dynamics.
- MATLAB R2019b or newer (R2021a+ recommended)
- Platform: macOS (tested;
VideoWriterwithMPEG-4works) - No extra toolboxes required
driver.m: main simulation and plotting scriptmaleckar_main.m: orchestrates numerical integration andsettings(returnsStateControl,TiControl,Ns,pH,extra_var)maleckarnorm.m: Maleckar model dynamics + pH modulation, currents, and extra variables
- Open MATLAB and set the project folder as the current directory.
- Run:
driver - The script will generate plots of state variables, ionic species, currents/conductances, and metrics. If enabled, a video (
plot_video.mp4) is also saved.
Headless run from macOS terminal (if MATLAB is on PATH):
matlab -batch "driver"Main options are defined at the top of driver.m. Default example:
settings.BCL = 800;stimulation period [ms]settings.TSim = 900000;simulation duration [ms] (15 min)settings.NumStim = floor(settings.TSim / settings.BCL);number of stimulisettings.storeLast = settings.NumStim;store the last beat of each stimulation seriessettings.pH_status = 1;1 = decreasing pH; 0 = fixed pHsettings.saving_status = 0;control intermediate saving
Additional model options (typically in maleckar_main.m):
settings.StimOffset[ms]: stimulus onsetsettings.Dur_stim[ms]: stimulus durationsettings.Amp_stim[pA/pF]: stimulus amplitudesettings.Ca_o,settings.K_o,settings.Na_o[mM]: extracellular reference concentrations
pH modulations applied in maleckarnorm.m:
f_pH_Na = 0.5*pH - 2.6→ scalesi_Naandg_Na_maxf_pH_CaL = 0.5*pH - 2.6→ scalesi_Ca_Landg_Ca_L_maxf_pH_NaCa = 0.9*pH - 5.48→ scalesi_NaCa
With settings.pH_status = 1, pH decreases linearly from 7.2 to ~6.2 across the simulated horizon (depending on NumStim). With settings.pH_status = 0, pH remains fixed.
- pH vs time (min)
- Jacobian sparsity and conditioning (if
calculate_eigenvalues_jacobianis available) - Subplots of the 30 state variables over the entire simulation
- Intracellular species comparison:
Na_i,K_i,Ca_i - Single-variable trace (default
V), selectable from a list - Currents:
i_Na,i_Ca_L,i_NaCa(extensible) - Apparent conductances: e.g.,
g_Na = i_Na/(V-E_Na),g_CaL = i_CaL/(V-E_Ca) - AP video over time:
plot_video.mp4 - Metrics over time:
Vrest,Vpp,dV/dt_max,APD90,APD50,TRI, and restitution curve (APD–DI)
Vrest: resting membrane potentialVmax: AP peakVpp: peak-to-peak amplitudedV/dt_max: maximum upstroke velocityAPD50,APD90: AP duration at 50% and 90% repolarizationTRI: triangulation,TRI = APD90 - APD50CI: coupling interval,CI = BCLDI: diastolic interval,DI = CI - APD90
- BCL variation and restitution curve: blocks in
driver.msweep BCL and plot APD90 vs DI. - AP comparison between start (pH ≈ 7.2) and end (pH ≈ 6.2) of the simulation.
- Percentage change of metrics vs acidosis progression.
- Reduce
settings.TSimfor quick tests (e.g., 60000 ms = 1 min) - For numerical stability, check stimulus parameters (
Amp_stim,Dur_stim,StimOffset) - On macOS,
VideoWriter('MPEG-4')relies on system codecs (available by default)
- Error on
calculate_eigenvalues_jacobian: ensure the function exists in your MATLAB path; otherwise comment out the related lines indriver.m. - Slow execution: decrease
TSim, increaseBCL, or disable non-essential plotting sections. - Video not generated: check write permissions and
MPEG-4support on MATLAB/macOS. - Units mismatch: units are indicated in plot titles/axes; refer to
names_sv/units_svindriver.m.
- Cell model: Maleckar et al. (atrial cell; MATLAB implementation derived from CellML conversion)
- CellML → MATLAB conversion: COR (Dr Alan Garny)
- Adaptations: pH modulation on
i_Na,i_CaL,i_NaCaand extra variables
Licensed under the MIT License. See LICENSE for details.


