Git Product home page Git Product logo

docker_opencor_run_model's Introduction

Docker for OpenCOR

This repository holds the files required to build a Docker image that runs a simulation of a CellML model using OpenCOR with Python.

Build Command

You will need to get a copy of the OpenCOR binary from here. Save this in the directory where the 'Dockerfile' file exists.

docker build --rm -t hsorby/opencor-python .

Run Command

docker run hsorby/opencor-python <int> <float>

where <int> is the stimulation mode as an integer number (1:stellate; 2:vagal) and <float> is the stimulation level (0-1) as a decimal number.

Output

The output is a JSON string with the membrane potential 'v' at each time step and the heart rate in beats per minute, as per the sample shown below.

{
    "heart_rate": 73,
    "membrane": {
        "v": [-47.78, -47.82, -47.85, ...]
    }
}

Implementation notes

We are using the Fabbri et al (2017) sinoatrial cell model: https://models.physiomeproject.org/e/568

The model includes autonomic modulation via inclusion of the effects of ACh on If, ICaL, SR calcium uptake, and IK,ACh; and the effect of isoprenaline on If, ICaL, INaK, maximal Ca uptake, and IKs. We are varying the concentration of ACh according to the stimulation level, while isoprenaline is encoded to be "on" or "off" only (we use the "on" version in this exemplar). The range of ACh we're allowing is beyond what has been presented in the paper.

Example output

Plotted example data when using this container to simulate various levels of stellate stimulation:

stellate-stimulation.png

Plotted example data when using this container to simulate various levels of vagus stimulation:

vagus-stimulation.png

docker_opencor_run_model's People

Contributors

hsorby avatar nickerso avatar

Watchers

 avatar  avatar  avatar

docker_opencor_run_model's Issues

Update to use the official OpenCOR+Python snapshot

Python support has recently been officially added to OpenCOR. So, rather than referencing and using https://github.com/dbrnz/opencor/releases/download/snapshot-2019-06-11/OpenCOR-2019-06-11-Linux.tar.gz, we should now be using https://github.com/opencor/opencor/releases/download/snapshot-2019-12-20/OpenCOR-2019-12-20-Linux.tar.gz. We should also update the run_model.py script to use our updated Python module and wrappers.

Ping @hsorby and @nickerso.

application does not return non-zero code upon failure

Application run does return non-zero code upon failure.

Steps to reproduce

Running w/o arguments displays help and exit code 1

$ docker run hsorby/opencor-python
...
$ echo $?
1

Running w/ arguments runs through and returns exit code 0

$ docker run hsorby/opencor-python 1000.0
... [json result in stdout] ...
$ echo $?
0

Running w/ an invalid input runs though, reports error message in the std::err BUT still returns exit code 0

$ docker run hsorby/opencor-python 5
Traceback (most recent call last):
  File "run_model.py", line 39, in <module>
    main(period)
  File "run_model.py", line 21, in main
    s.run()
RuntimeError: std::runtime_error: at t = 7.89335, mxstep steps taken before reaching tout
$ echo $?
0

In this case, the expected behavior would be to get a non-zero. This way, the client can detect that something went wrong and e.g. show the user the std::err

Some insight

In order to understand better this, I built myself the image and tagged as opencor-python:dev, run the container and executed the command in the entrypoint.sh.

$ docker run -it --entrypoint /bin/bash opencor-python:dev

I noticed that i can reproduce the same in the executable

root@f801628872b5:/home/opencor# ./OpenCOR-2019-05-23-Linux/bin/OpenCOR -c PythonRunScript::script run_model.py 5
Traceback (most recent call last):
  File "run_model.py", line 39, in <module>
    main(period)
  File "run_model.py", line 21, in main
    s.run()
RuntimeError: std::runtime_error: at t = 7.89335, mxstep steps taken before reaching tout
root@f801628872b5:/home/opencor# echo $?
0

See that python interpreter, would return 1 if there is an exception raised:

root@f801628872b5:/home/opencor# OpenCOR-2019-05-23-Linux/python/bin/python -c "raise Exception"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
Exception
root@f801628872b5:/home/opencor# echo $?
1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.