Extending the NEURON Simulator with MATLAB
Noah Safar1, Robert A. McDougal*2,3,4,5
1Department of Neuroscience, Example University, City, Country
2 Institute for Brain Research, Another University, City, Country
3 Center for Cognitive Science, Yet Another Institution, City, Country
1 Yale College, Yale University, New Haven, CT, USA
2 Department of Biostatistics, Yale School of Public Health, New Haven, CT, USA
3 Department of Biomedical Informatics and Data Science, Yale School of Medicine, New Haven, CT, USA
4 Program in Computational Biology and Biomedical Informatics, Yale University, New Haven, CT, USA
5 Wu Tsai Institute, Yale University, New Haven, CT, USA
*Email: robert.mcdougal@yale.edu
Introduction
NEURON [1] is the most commonly used simulation environment for models of neurons and neural networks in the ModelDB [2] repository of computational neuroscience models. While NEURON has supported interaction through both HOC and Python, it did not offer direct support for MATLAB, the second-most commonly used simulation environment in ModelDB. This disconnect has hindered workflows for researchers and labs who rely on work across both environments-it has long created an artificial divide where tools and models may be available for one but not the other. To bridge this gap, we developed a robust interface that connects NEURON and MATLAB, allowing researchers to define, analyze, and run NEURON models without leaving the MATLAB environment.
Methods
In the past, integrating a new language with NEURON meant writing substantial custom code in its C/C++ internals. NEURON 9 introduces a stable C API with over 100 functions providing access to NEURON's full suite of simulation, modeling, and analysis features while keeping internal details independent of user code. The API allows other languages, such as MATLAB, to call NEURON functions, and vice versa. Building on earlier work with VORtech, we used this API with MEX to create a comprehensive, cross-platform NEURON Toolbox for MATLAB that works across operating systems and processor architectures. A set of test models was developed to ensure usability and completeness. Detailed documentation for using the interface is in development.
Results
Our MATLAB interface closely follows the Python and HOC interfaces, with modifications to support interoperability with native MATLAB workflows. For example, NEURON Vector objects may be initialized from MATLAB arrays, used directly in calls to MATLAB's plot function, and return a 2-dimensional size() instead of the 1-dimensional size() returned in Python or HOC. Key NEURON-specific graph types (the PlotShape for 3D false-color images and RangeVarPlot for showing concentration or potential along a path) have plot() methods that render them inside of a MATLAB window or MLX MATLAB Live Code file.
Discussion
This integration opens new possibilities for hybrid modeling and analysis pipelines in computational neuroscience, bridging a long-standing gap between neuroscientific simulation and widely used analysis tools. By enabling NEURON within MATLAB, we lower the barrier for MATLAB-centric researchers to adopt model-driven workflows and foster tighter coupling between modeling and data analysis across platforms. The use of a standardized API provides a clean separation between NEURON and MATLAB's interface, allowing future interface development to proceed without requiring any knowledge of NEURON's internal functions or data structures. This approach sets a precedent for building robust, user-friendly language bindings to simulator platforms.
MATLAB is a registered trademark of MathWorks. Funding from MathWorks supported the initial development of the NEURON Toolbox by VORtech, who we also thank for their work. We thank Fernando Pereira for significant contributions to the API.
1. Hines, M., Carnevale, T., & McDougal, R. A. (2022). NEURON simulation environment. Encyclopedia of computational neuroscience, 2355-2361.
2. McDougal, R. A., Morse, T. M., Carnevale, T., Marenco, L., Wang, R., Migliore, M., ... & Hines, M. L. (2017). Twenty years of ModelDB and beyond: building essential modeling tools for the future of neuroscience. Journal of computational neuroscience, 42, 1-10. http://doi.org/10.1007/s10827-016-0623-7