Problem
Closed-loop transcranial stimulation can be treated as a sequential control problem: infer a circuit state from neural activity, choose stimulation parameters, and observe how the simulated dynamics change. Studying that loop requires software that can connect neural-circuit simulation, signal generation, stimulation modelling and learning algorithms without presenting simulation as clinical evidence.
System
NeuroStimEnv provides that integration layer. NEURON simulates morphologically and biophysically detailed neural circuits; LFPy derives extracellular and EEG-like measurements; SimNIBS supplies stimulation-field parameters; and learning agents use processed neural activity as observations and stimulation settings as actions.
The repository includes simpler local models for development and a detailed human cortical layer 2/3 microcircuit for large-scale experiments. Configuration is managed as reproducible experiment data, and MPI execution supports parallel rollouts on HPC systems.
Technical contribution
The framework turns a multi-tool computational-neuroscience workflow into an environment for reinforcement learning and bandit experiments. It exposes the main scientific choices—circuit model, temporal resolution, observation window, EEG processing, stimulation type, montage, action set and reward formulation—rather than hiding them behind a fixed benchmark.
Computational scale
The public preprint reports a depression case study with approximately 1,000 neurons, a 0.025 ms simulation timestep and an HPC run using 624 CPU processes. These numbers describe computational experiments, not participant counts or clinical validation.
Results / demonstration
The released experiments demonstrate that the complete loop can be executed: simulated stimulation affects a neural microcircuit, LFPy-derived signals are processed into observations, and a learning algorithm selects among stimulation settings. The work is a simulation study and a research-software contribution; it does not claim clinical treatment efficacy.
Open-source resources
- Public code, environment configurations and examples are available in the NeuroStimEnv repository (opens in a new tab).
- The repository documents local toy circuits and the HPC-oriented depression microcircuit.
- Setup examples cover NEURON model compilation, MPI execution and SimNIBS preprocessing.
Paper
The public preprint is “Simulating closed-loop transcranial brain stimulation for reinforcement learning-based treatment discovery” (opens in a new tab). It is explicitly presented as a simulation and evaluation study.

