^{*}

The author has declared that no competing interests exist.

Conceived and designed the experiments: RC. Performed the experiments: RC. Analyzed the data: RC. Contributed reagents/materials/analysis tools: RC. Wrote the paper: RC. Designed and wrote the software used in analysis: RC.

The PyDSTool software environment is designed to develop, simulate, and analyze dynamical systems models, particularly for biological applications. Unlike the engineering application focus and graphical specification environments of most general purpose simulation tools, PyDSTool provides a programmatic environment well suited to exploratory data- and hypothesis-driven biological modeling problems. In this work, we show how the environment facilitates the application of hybrid dynamical modeling to the reverse engineering of complex biophysical dynamics; in this case, of an excitable membrane. The example demonstrates how the software provides novel tools that support the inference and validation of mechanistic hypotheses and the inclusion of data constraints in both quantitative and qualitative ways. The biophysical application is broadly relevant to models in the biosciences. The open source and platform-independent PyDSTool package is freely available under the BSD license from

There are now many simulation and visualization software packages available for individual application domains across the biosciences, and several general purpose packages for analyzing dynamical systems. However, less attention has been paid to the tools needed to develop models for complex phenomena through inference and reverse engineering of natural systems

Model development in the biosciences requires tools such as simulation, visualization, data analysis, diagnostics and validation, sensitivity analysis, and parameter optimization

At a more technical level, PyDSTool provides a range of general purpose simulation and analysis tools with similar functionality to existing packages. A detailed feature comparison is provided on the website

PyDSTool exhibits superior performance in numerical integration over other high-level environments because it automatically generates low-level C code from user model descriptions. The low-level code is linked dynamically with C or Fortran solvers and reloaded as a dynamic linked library for transparent user access within Python. Comparable high-level programmatic environments such as Matlab or Python-based packages such as SciPy, Brian

This article describes an example of how the PyDSTool environment supports flexible and extensible workflows to be built over a class hierarchy designed for development and analysis of dynamical models in scientific applications, as well as for inter-operability between packages and algorithms. Example workflows suited to this environment include: (1) model creation specified by code that later adaptively modifies the model structure or parameters (e.g., when interfaced with optimization algorithms); (2) adaptive batches of simulations and analyses that post-process simulation results to determine which simulations to perform next; and (3) exploration of model properties and live prototyping of model development code. Further examples are discussed throughout the text.

To illustrate some of the unique benefits of PyDSTool to the modeler, we will discuss an example that combines elements of the workflows (1) and (3) above using reduction techniques and hybrid dynamical systems (see

In contrast to dimension reduction methods that aim to increase simulation efficiency (e.g., see

A simple example of reducing an ODE in this way is the replacement of a smooth sigmoidal function having a steep slope with a piecewise-constant or piecewise-linear step function in contexts that are not sensitive to the details of the smooth slope (see

Multiple time scale systems such as the Van der Pol oscillator or chemical reaction systems with explicit small parameters are classic examples of systems that can be reduced to hybrid systems

We demonstrate hybrid model reduction in a scenario involving the space-clamped Hodgkin-Huxley (HH) formalism for neural action potentials (AP)

The PyDSTool package is a library-based environment written primarily in Python, utilizing the numpy

PyDSTool is unique in providing a variety of high-level data types (‘classes’) and library functions that closely mimic mathematical counterparts in dynamical systems theory and provide intuitive functionality. For example, domains and numeric intervals are represented by the Interval class, for which membership, intersection, endpoint testing, etc., are simple operations. Similarly, numerical arrays are extended to become Pointsets, incorporating several features: named fields instead of indices for accessing variables, an associated independent variable that may parameterize the data, and metadata labels that can be indexed and cross-referenced. Pointsets are further abstracted to Trajectories (parameterized, smooth curves), which further add a transparent layer of domain checking and interpolation that allows numerically computed data to be treated as continuous, when appropriate. Among others, such classes provide intuitive abstractions that allow users to more efficiently express their mathematical ideas in new algorithms, or to naturally specify complex meta-model constraints.

At the lowest level, PyDSTool supports simulations of ordinary differential equations (ODEs), differential-algebraic equations (DAEs), and discrete mappings

Bundled toolboxes provide special functionality such as phase plane analysis, model reduction, optimization, data analysis, and templates and interfaces for application-specific modeling and third-party software. For instance, users who install the PySCeS

We take a practical approach to implementing hybrid systems (sometimes known as composite models in other fields) in PyDSTool that is most applicable to biophysical models, where smooth dynamics are primary and are punctuated by finite numbers of discrete events. This differs from the majority of existing simulation platforms, which typically focus on physical models for engineering applications with many parallel discrete event processes mixed with smooth dynamics. Hybrid models in PyDSTool can be built from sub-models that mix discrete mappings, ODEs, DAEs, preset trajectories, or any other embedded code that can produce a Trajectory object.

There are many formalisms for hybrid systems, but the 6-tuple of Simić et al. is adequate for our purposes

PyDSTool uses three essential code elements to define a hybrid model: (1) a hierarchy of component sub-models, (2) a mixture of zero-crossing events and global self-consistency conditions, and (3) transition rules between the sub-models that are applied on occurrence of an associated event or condition failure. During simulation of a sub-model, a terminal event may occur that stops the trajectory generation (see the Tutorial in Supplemental

A user may define a hybrid model with only one sub-model, such that a terminal event or maximum elapsed time defined for that sub-model's regime will be associated with a transition back to the same sub-model, typically after a discrete change to the state is applied. An example of this is using a simple threshold-crossing event to signal an action potential (AP) in an integrate-and-fire neuron model

An MI wraps a hybrid or non-hybrid model, providing users an option to add pre- and post-simulation code to validate input and output, or otherwise filter or transform the data flow. The control structure also permits failure recovery in the model to be added.

In this sub-section, we introduce a broad conceptual framework for the established analytical approach of piecewise-reduced models, and focus on the validation of the analysis by implementing the result as a hybrid systems reduction within PyDSTool.

Modularity of systems (more accurately, ‘near decomposability’) can be described as the occurrence of clusters of state variables that are highly inter-coupled but sparsely or weakly coupled to external variables

This example assumes a model with hub-like connectivity, exhibiting multiple scale dynamics, and a periodic behavior (period

In its focus on supporting the exploration and understanding of emergent dynamics across scales, PyDSTool permits embedding of data playback, simplified model components, or even analytical tools as surrogates inside MI objects, thereby creating a hybrid model of heterogeneous component types. For instance, an embedded optimization tool could interface with regular model components to infer a low-dimensional characterization (e.g. a functional curve fit or a reduced-order model) of the dynamics of some part of a larger process

The scaffolding idea has not been exploited in computational software previously, but is conceptually related to using code stubs and testing with surrogate data in software engineering, and to the mathematical ‘buffering’ principle for tackling complex models of biochemical systems

We present a hybrid system implementation of the reduced Hodgkin-Huxley (HH) action potential (AP) derived from a ‘dominant scale’ analysis

There are four state variables in the HH model:

Dominant scale analysis of a periodic orbit indicated four reduced regimes that capture the essential dynamics of qualitatively distinct parts of the AP cycle relative to

Taken together as a hybrid model, the piecewise-local reductions form a formal hypothesis about the key mechanistic relationships between variables during an AP. The inferred mechanistic description is formalized as a sequence of domain and transition rules called a ‘template’ (e.g., see Table 1 of

The graph compares the period of regular AP firing in the original Hodgkin-Huxley model (‘x’ markers) and the hybrid reduction (‘o’ markers) as a function of applied current

Voltage traces versus time summarize the qualitative fit of four smooth biophysical models of APs (solid lines) with their hybrid counterparts (dashed lines). The four sub-model regimes of the AP are indicated with Roman numerals, with onsets indicated by solid square or circular markers.

The software and its source code are publicly available, anonymously and for free, under the BSD license:

This work reinforces the idea that a reduction should take place in the

The design of PyDSTool facilitates qualitative and multi-objective optimization techniques, which are increasingly recognized as important aspects of biological modeling

Tutorial for Hybrid Model Implementation in PyDSTool.

(PDF)

Syntax-highlighted code for the demonstration script IF_squarespike_model.py.

(PDF)

Syntax-highlighted code for the demonstration script HH_DSSRTtest.py.

(PDF)

Complete source code for the PyDSTool package (version 0.88.120504). Includes API documentation and help files linking to web pages. This file is identical to the current public release on Sourceforge.net.

(ZIP)

I thank S. Nolen and the anonymous reviewers for their constructive comments.