File: run_bionet.py

package info (click to toggle)
bmtk 0.0%2Bgit20210109.8572664%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 74,876 kB
  • sloc: python: 24,853; javascript: 1,998; makefile: 34; sh: 16
file content (33 lines) | stat: -rw-r--r-- 1,036 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""Simulates an example network of 450 cell receiving two kinds of exernal input as defined in the configuration file"""
import sys
import matplotlib.pyplot as plt
import h5py
import numpy as np

from bmtk.simulator import bionet
from bmtk.analyzer.compartment import plot_traces


def show_cell_var(conf, var_name):
    plot_traces(config_file=conf, report_name=var_name)


def run(config_file):
    conf = bionet.Config.from_json(config_file, validate=True)
    conf.build_env()

    graph = bionet.BioNetwork.from_config(conf)
    sim = bionet.BioSimulator.from_config(conf, network=graph)
    sim.run()

    show_cell_var(config_file, 'membrane_potential')


if __name__ == '__main__':
    if __file__ != sys.argv[-1]:
        run(sys.argv[-1])
    else:
        # Make sure to run only one at a time
        run('config_iclamp.json')  # Current clamp stimulation
        # run('config_xstim.json')  # Extracellular electrode stimulation
        # run('config_spikes_input.json')  # Synaptic stimulation with external virtual cells