PyRates—A Python framework for rate-based neural simulations

Autoři: Richard Gast aff001;  Daniel Rose aff003;  Christoph Salomon aff001;  Harald E. Möller aff002;  Nikolaus Weiskopf aff003;  Thomas R. Knösche aff001
Působiště autorů: MEG and Cortical Networks Group, Max Planck Institute for Human Cognitive and Brain Sciences, Leipzig, Saxony, Germany aff001;  Nuclear Magnetic Resonance Group, Max Planck Institute for Human Cognitive and Brain Sciences, Leipzig, Saxony, Germany aff002;  Neurophysics Department, Max Planck Institute for Human Cognitive and Brain Sciences, Leipzig, Saxony, Germany aff003;  Institute for Biomedical Engineering and Informatics, TU Ilmenau, Ilmenau, Thuringia, Germany aff004
Vyšlo v časopise: PLoS ONE 14(12)
Kategorie: Research Article


In neuroscience, computational modeling has become an important source of insight into brain states and dynamics. A basic requirement for computational modeling studies is the availability of efficient software for setting up models and performing numerical simulations. While many such tools exist for different families of neural models, there is a lack of tools allowing for both a generic model definition and efficiently parallelized simulations. In this work, we present PyRates, a Python framework that provides the means to build a large variety of rate-based neural models. PyRates provides intuitive access to and modification of all mathematical operators in a graph, thus allowing for a highly generic model definition. For computational efficiency and parallelization, the model is translated into a compute graph. Using the example of two different neural models belonging to the family of rate-based population models, we explain the mathematical formalism, software structure and user interfaces of PyRates. We show via numerical simulations that the behavior of the PyRates model implementations is consistent with the literature. Finally, we demonstrate the computational capacities and scalability of PyRates via a number of benchmark simulations of neural networks differing in size and connectivity.

Klíčová slova:

Data visualization – Electroencephalography – Membrane potential – Network analysis – Neural networks – Neurons – Simulation and modeling – Synapses


1. Goense J, Merkle H, Logothetis N. High-Resolution fMRI Reveals Laminar Differences in Neurovascular Coupling between Positive and Negative BOLD Responses. Neuron. 2012;76(3):629–639. doi: 10.1016/j.neuron.2012.09.019 23141073

2. Huber L, Uludağ K, Möller HE. Non-BOLD contrast for laminar fMRI in humans: CBF, CBV, and CMRO2. NeuroImage. 2017. doi: 10.1016/j.neuroimage.2017.07.041 28736310

3. Niedermeyer E, Silva FHLd. Electroencephalography: Basic Principles, Clinical Applications, and Related Fields. Lippincott Williams & Wilkins; 2005.

4. Baillet S, Mosher J C, Leahy R M. Electromagnetic brain mapping. IEEE Signal Processing Magazine. 2001;18(6):14–30. doi: 10.1109/79.962275

5. Markram H, Toledo-Rodriguez M, Wang Y, Gupta A, Silberberg G, Wu C. Interneurons of the neocortical inhibitory system. Nature Reviews Neuroscience. 2004;5:793. doi: 10.1038/nrn1519 15378039

6. Attal Y, Schwartz D. Assessment of Subcortical Source Localization Using Deep Brain Activity Imaging Model with Minimum Norm Operators: A MEG Study. PLOS ONE. 2013;8(3):e59856. doi: 10.1371/journal.pone.0059856 23527277

7. Logothetis NK, Wandell BA. Interpreting the BOLD Signal. Annual Review of Physiology. 2004;66(1):735–769. doi: 10.1146/annurev.physiol.66.082602.092845 14977420

8. Deco G, Jirsa VK, Robinson PA, Breakspear M, Friston K. The Dynamic Brain: From Spiking Neurons to Neural Masses and Cortical Fields. PLOS Computational Biology. 2008;4(8):e1000092. doi: 10.1371/journal.pcbi.1000092 18769680

9. Friston KJ, Dolan RJ. Computational and dynamic models in neuroimaging. NeuroImage. 2010;52(3):752–765. doi: 10.1016/j.neuroimage.2009.12.068 20036335

10. Breakspear M. Dynamic models of large-scale brain activity. Nat Neurosci. 2017;20(3):340–352. doi: 10.1038/nn.4497 28230845

11. Sanz-Leon P, Knock SA, Spiegler A, Jirsa VK. Mathematical framework for large-scale brain network modeling in The Virtual Brain. NeuroImage. 2015;111:385–430. doi: 10.1016/j.neuroimage.2015.01.002 25592995

12. Friston KJ, Harrison L, Penny W. Dynamic causal modelling. NeuroImage. 2003;19(4):1273–1302. doi: 10.1016/s1053-8119(03)00202-7 12948688

13. Bekolay T, Bergstra J, Hunsberger E, DeWolf T, Stewart TC, Rasmussen D, et al. Nengo: a Python tool for building large-scale functional brain models. Frontiers in Neuroinformatics. 2014;7. doi: 10.3389/fninf.2013.00048 24431999

14. Gewaltig MO, Diesmann M. NEST (NEural Simulation Tool). Scholarpedia. 2007;2(4):1430. doi: 10.4249/scholarpedia.1430

15. Vitay J, Dinkelbach HU, Hamker FH. ANNarchy: a code generation approach to neural simulations on parallel hardware. Frontiers in Neuroinformatics. 2015;9. doi: 10.3389/fninf.2015.00019 26283957

16. Goodman DFM, Brette R. The Brian simulator. Frontiers in Neuroscience. 2009;3. doi: 10.3389/neuro.01.026.2009 20011141

17. Hines ML, Carnevale NT. The NEURON Simulation Environment. Neural Computation. 1997;9(6):1179–1209. doi: 10.1162/neco.1997.9.6.1179 9248061

18. Migliore M, Cannia C, Lytton WW, Markram H, Hines ML. Parallel network simulations with NEURON. Journal of Computational Neuroscience. 2006;21(2):119. doi: 10.1007/s10827-006-7949-5 16732488

19. Pecevski D, Natschläger T, Schuch K. PCSIM: a parallel simulation environment for neural circuits fully integrated with Python. Frontiers in Neuroinformatics. 2009;3. doi: 10.3389/neuro.11.011.2009 19543450

20. Gratiy SL, Billeh YN, Dai K, Mitelut C, Feng D, Gouwens NW, et al. BioNet: A Python interface to NEURON for modeling large-scale networks. PLOS ONE. 2018;13(8):e0201630. doi: 10.1371/journal.pone.0201630 30071069

21. Dura-Bernal S, Suter BA, Gleeson P, Cantarelli M, Quintana A, Rodriguez F, et al. NetPyNE, a tool for data-driven multiscale modeling of brain circuits. eLife. 2019;8:e44494. doi: 10.7554/eLife.44494 31025934

22. Jensen O, Goel P, Kopell N, Pohja M, Hari R, Ermentrout B. On the human sensorimotor-cortex beta rhythm: Sources and modeling. NeuroImage. 2005;26(2):347–355. doi: 10.1016/j.neuroimage.2005.02.008 15907295

23. Sherman MA, Lee S, Law R, Haegens S, Thorn CA, Hämäläinen MS, et al. Neural mechanisms of transient neocortical beta rhythms: Converging evidence from humans, computational modeling, monkeys, and mice. Proceedings of the National Academy of Sciences of the USA. 2016;113(33):E4885–E4894. doi: 10.1073/pnas.1604135113 27469163

24. Neymotin SA, Daniels DS, Caldwell B, Peled N, McDougal RA, Carnevale NT, et al. Human Neocortical Neurosolver; 2018.

25. Hagen E, Naess S, Ness TV, Einevoll GT. Multimodal Modeling of Neural Network Activity: Computing LFP, ECoG, EEG, and MEG Signals With LFPy 2.0. Frontiers in Neuroinformatics. 2018;12. doi: 10.3389/fninf.2018.00092

26. Coombes S. Large-scale neural dynamics: simple and complex. NeuroImage. 2010;52(3):731–739. doi: 10.1016/j.neuroimage.2010.01.045 20096791

28. Freeman WJ. Models of the dynamics of neural populations. Electroencephalography and clinical neurophysiology. 1978;34:9–18.

27. da Silva FHL, Hoeks A, Smits H, Zetterberg LH. Model of brain rhythmic activity. Biological cybernetics. 1974;15(1):27–37.

29. Jansen BH, Rit VG. Electroencephalogram and visual evoked potential generation in a mathematical model of coupled cortical columns. Biol Cybern. 1995;73(4):357–366. doi: 10.1007/bf00199471 7578475

30. David O, Friston KJ. A neural mass model for MEG/EEG:: coupling and neuronal dynamics. NeuroImage. 2003;20(3):1743–1755. doi: 10.1016/j.neuroimage.2003.07.015 14642484

31. Babajani A, Soltanian-Zadeh H. Integrated MEG/EEG and fMRI model based on neural masses. IEEE Transactions on Biomedical Engineering. 2006;53(9):1794–1801. doi: 10.1109/TBME.2006.873748 16941835

32. Cona F, Zavaglia M, Massimini M, Rosanova M, Ursino M. A neural mass model of interconnected regions simulates rhythm propagation observed via TMS-EEG. NeuroImage. 2011;57(3):1045–1058. doi: 10.1016/j.neuroimage.2011.05.007 21600291

33. Moran RJ, Kiebel SJ, Stephan KE, Reilly RB, Daunizeau J, Friston KJ. A neural mass model of spectral responses in electrophysiology. NeuroImage. 2007;37(3):706–720. doi: 10.1016/j.neuroimage.2007.05.032 17632015

34. Wang P, Knösche TR. A Realistic Neural Mass Model of the Cortex with Laminar-Specific Connections and Synaptic Plasticity—Evaluation with Auditory Habituation. PLOS ONE. 2013;8(10):e77876. doi: 10.1371/journal.pone.0077876 24205009

35. David O, Kiebel SJ, Harrison LM, Mattout J, Kilner JM, Friston KJ. Dynamic causal modeling of evoked responses in EEG and MEG. NeuroImage. 2006;30(4):1255–1272. doi: 10.1016/j.neuroimage.2005.10.045 16473023

36. Sotero RC, Trujillo-Barreto NJ, Iturria-Medina Y, Carbonell F, Jimenez JC. Realistically Coupled Neural Mass Models Can Generate EEG Rhythms. Neural Computation. 2007;19(2):478–512. doi: 10.1162/neco.2007.19.2.478 17206872

37. Bojak I, Oostendorp TF, Reid AT, Kötter R. Connecting Mean Field Models of Neural Activity to EEG and fMRI Data. Brain Topography. 2010;23(2):139–149. doi: 10.1007/s10548-010-0140-3 20364434

38. Spiegler A, Knösche TR, Schwab K, Haueisen J, Atay FM. Modeling Brain Resonance Phenomena Using a Neural Mass Model. PLOS Computational Biology. 2011;7(12):e1002298. doi: 10.1371/journal.pcbi.1002298 22215992

39. Onslow ACE, Jones MW, Bogacz R. A Canonical Circuit for Generating Phase-Amplitude Coupling. PLOS ONE. 2014;9(8):e102591. doi: 10.1371/journal.pone.0102591 25136855

40. Kunze T, Hunold A, Haueisen J, Jirsa V, Spiegler A. Transcranial direct current stimulation changes resting state functional connectivity: A large-scale brain network modeling study. NeuroImage. 2016;140:174–187. doi: 10.1016/j.neuroimage.2016.02.015 26883068

41. Jansen BH, Zouridakis G, Brandt ME. A neurophysiologically-based mathematical model of flash visual evoked potentials. Biological Cybernetics. 1993;68(3):275–283. doi: 10.1007/bf00224863 8452897

42. Spiegler A, Kiebel SJ, Atay FM, Knösche TR. Bifurcation analysis of neural mass models: Impact of extrinsic inputs and dendritic time constants. NeuroImage. 2010;52(3):1041–1058. doi: 10.1016/j.neuroimage.2009.12.081 20045068

43. Montbrió E, Pazó D, Roxin A. Macroscopic Description for Networks of Spiking Neurons. Physical Review X. 2015;5(2):021028.

44. Coombes S, Byrne A. Next Generation Neural Mass Models. In: Corinto F, Torcini A, editors. Nonlinear Dynamics in Computational Neuroscience. PoliTO Springer Series. Cham: Springer International Publishing; 2019. p. 1–16. Available from:

45. Oliphant TE. A guide to NumPy. USA: Trelgol Publishing; 2006.

46. Ben-Kiki O, Evans C, döt Net I. YAML Ain’t Markup Language (YAML™) Version 1.2; 2009. Available from:

47. Hagberg AA, Schult DA, Swart PJ. Exploring Network Structure, Dynamics, and Function using NetworkX. In: Varoquaux G, Vaught T, Millman J, editors. Proceedings of the 7th Python in Science Conference. Pasadena, CA USA; 2008. p. 11–15.

48. Abadi M, Agarwal A, Barham P, Brevdo E, Chen Z, Citro C, et al. TensorFlow: Large-Scale Machine Learning on Heterogeneous Systems; 2015. Available from:

49. McKinney W. Data Structures for Statistical Computing in Python. In: van der Walt S, Millman J, editors. Proceedings of the 9th Python in Science Conference; 2010. p. 51–56.

50. Gansner ER, North SC. An open graph visualization system and its applications to software engineering. Software—Practice and Experience. 2000;30(11):1203–1233. doi: 10.1002/1097-024X(200009)30:11%3C1203::AID-SPE338%3E3.0.CO;2-N

51. Gramfort A, Luessi M, Larson E, Engemann DA, Strohmeier D, Brodbeck C, et al. MEG and EEG data analysis with MNE-Python. Front Neurosci. 2013;7. doi: 10.3389/fnins.2013.00267 24431986

52. Gramfort A, Luessi M, Larson E, Engemann DA, Strohmeier D, Brodbeck C, et al. MNE software for processing MEG and EEG data. NeuroImage. 2014;86:446–460. doi: 10.1016/j.neuroimage.2013.10.027 24161808

53. Ratas I, Pyragas K. Macroscopic self-oscillations and aging transition in a network of synaptically coupled quadratic integrate-and-fire neurons. Physical Review E. 2016;94(3):032215. doi: 10.1103/PhysRevE.94.032215 27739712

54. Ritter P, Schirner M, McIntosh AR, Jirsa VK. The Virtual Brain Integrates Computational Modeling and Multimodal Neuroimaging. Brain Connectivity. 2013;3(2):121–145. doi: 10.1089/brain.2012.0120 23442172

55. Website: © Allen Institute for Brain Science. DiPDE Simulator [Internet]. Available from:; 2015.

56. Kamps Md, Baier V. Multiple Interacting Instantiations of Neuronal Dynamics (MIIND): a Library for Rapid Prototyping of Models in Cognitive Neuroscience. In: 2007 International Joint Conference on Neural Networks; 2007. p. 2829–2834.

57. Bäck T, Schwefel HP. An Overview of Evolutionary Algorithms for Parameter Optimization. Evolutionary Computation. 1993;1(1):1–23. doi: 10.1162/evco.1993.1.1.1

58. Shannon P, Markiel A, Ozier O, Baliga NS, Wang JT, Ramage D, et al. Cytoscape: a software environment for integrated models of biomolecular interaction networks. Genome Res. 2003;13(11):2498–2504. doi: 10.1101/gr.1239303 14597658

59. Waskom M. seaborn: statistical data visualization, URL:; 2012.

Článek vyšel v časopise


2019 Číslo 12
Nejčtenější tento týden