NEST-Compatible Examples#

A Rosetta map of PyNEST examples ported to brainpy.state. Each entry keeps NEST’s model and parameter names, so a NEST user can find the familiar example on the left and the brainpy.state equivalent on the right. All scripts live in the examples/nest_like/ directory and run end to end through the Simulator (one compiled for_loop — no Python step loop).

Every port is backed by a live-NEST parity test where a sample-for-sample comparison is meaningful; see Validation status for the per-model parity evidence and tolerance bands, and the NEST-Compatible Models hub for the build-your-network guides.

Reading the map

Each line reads script.pyNEST upstreambrainpy.state model or feature — one-line summary. Where an upstream mechanism is NEST-specific (e.g. the Connection Set Algebra), the port re-expresses the connectivity it describes natively; those entries are marked.

First steps: single & two neurons#

The PyNEST “Part 1-2” first-contact examples — drive one or two neurons and record them.

one_neuron.py

NEST one_neuroniaf_psc_alpha + voltmeter. A single neuron driven by a constant I_e, observed by a reverse-connected voltmeter.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/one_neuron.py
one_neuron_with_noise.py

NEST one_neuron_with_noiseiaf_psc_alpha + 2-channel poisson_generator. Excitatory/inhibitory Poisson drive with signed per-channel weights.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/one_neuron_with_noise.py
twoneurons.py

NEST twoneurons → two iaf_psc_alpha + static_synapse. A driven presynaptic neuron connected to a postsynaptic neuron, each with its own voltmeter.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/twoneurons.py
testiaf.py

NEST testiafiaf_psc_alpha swept over dt ∈ {0.1, 0.5, 1.0} ms. Constant-current charge / spike / refractory / recovery (rebuild-per-trial).

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/testiaf.py
if_curve.py

NEST if_curveaeif_cond_exp + noise_generator. Population firing rate across an (I_mean, I_std) grid — the neuron’s transfer function.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/if_curve.py
vinit_example.py

NEST vinit_exampleiaf_cond_exp_sfa_rr. Passive relaxation toward E_L from several initial membrane voltages (rebuild-per-trial).

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/vinit_example.py
balancedneuron.py

NEST balancedneuroniaf_psc_alpha + 2-channel poisson_generator. Root-find the inhibitory rate that balances the neuron’s output rate (SciPy bisect, rebuild-per-trial).

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/balancedneuron.py
izhikevich.py

NEST izhikevichizhikevich neuron. The canonical Izhikevich (2003) firing regimes.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/izhikevich.py
hh_psc_alpha.py

NEST hh_psc_alphahh_psc_alpha + multimeter + spike_recorder. Hodgkin-Huxley F-I curve from a constant-current sweep.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/hh_psc_alpha.py
hh_phaseplane.py

NEST hh_phaseplanehh_psc_alpha (analysis). V-n phase-plane vector field, nullclines, and a limit cycle — a pedagogical analysis demo.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/hh_phaseplane.py

Neuron models#

Single-neuron ports exercising specific neuron families — adaptive exponential, generalized-LIF, multi-timescale, and multi-compartment models.

aeif_cond_beta_multisynapse.py

NEST aeif_cond_beta_multisynapse → same model. One spike fans out to four distinct beta-function conductance receptors via connect(receptor_type=k).

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/aeif_cond_beta_multisynapse.py
brette_gerstner_fig_2c.py

NEST brette_gerstner_fig_2caeif_cond_alpha. AdEx spike-frequency adaptation (Brette & Gerstner 2005, Fig 2C).

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/brette_gerstner_fig_2c.py
brette_gerstner_fig_3d.py

NEST brette_gerstner_fig_3daeif_cond_exp. AdEx post-inhibitory rebound burst (Fig 3D).

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/brette_gerstner_fig_3d.py
gif_cond_exp_multisynapse.py

NEST gif_cond_exp_multisynapse → same model. Generalized-IAF neuron with two exponential-conductance receptors.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/gif_cond_exp_multisynapse.py
glif_cond_neuron.py

NEST glif_cond_neuronglif_cond. Conductance-based Allen-Institute GLIF at its five mechanism levels (RKF45 conductance synapses).

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/glif_cond_neuron.py
glif_psc_neuron.py

NEST glif_psc_neuronglif_psc. Current-based GLIF at five mechanism levels, advanced with exact propagator matrices.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/glif_psc_neuron.py
glif_psc_double_alpha_neuron.py

NEST glif_psc_double_alpha_neuronglif_psc_double_alpha. Double-alpha post-synaptic currents across three receptor ports.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/glif_psc_double_alpha_neuron.py
mat_psc_exp.py

NEST mat_psc_expmat2_psc_exp / amat2_psc_exp. Multi-timescale adaptive-threshold neurons whose membrane never resets.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/mat_psc_exp.py
mc_neuron.py

NEST mc_neuroniaf_cond_alpha_mc. Three-compartment neuron with nine receptors selecting compartment and channel.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/mc_neuron.py
two_comps.py

NEST compartmental two_compscm_default. Two-compartment models with active vs passive dendrites and attached AMPA/GABA/NMDA receptors.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/two_comps.py
receptors_and_current.py

NEST compartmental receptors_and_currentcm_default. A soma + two dendrites with a different receptor per compartment plus a current injection.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/receptors_and_current.py
wang_decision_making.py

NEST wang_decision_makingiaf_bw_2001. Wang (2002) spiking decision-making network with AMPA/GABA/recurrent-NMDA receptors.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/wang_decision_making.py

Balanced & Brunel networks#

Random balanced networks — the Brunel family and related E/I benchmarks.

brunel_alpha.py

NEST brunel_alpha_nestiaf_psc_alpha + poisson_generator + spike_recorder. Brunel (2000) balanced random network with alpha synapses.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/brunel_alpha.py
brunel_delta.py

NEST brunel_delta_nestiaf_psc_delta. Brunel network with delta synapses (instantaneous voltage jumps; weights in mV).

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/brunel_delta.py
brunel_exp_multisynapse.py

NEST brunel_exp_multisynapse_nestiaf_psc_exp_multisynapse. Brunel network with per-connection uniformly-drawn receptor ports.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/brunel_exp_multisynapse.py
brunel_alpha_evolution_strategies.py

NEST brunel_alpha_evolution_strategiesiaf_psc_alpha (Brunel alpha). Natural-evolution-strategies tuning of eta and g to target statistics.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/brunel_alpha_evolution_strategies.py
brunel_siegert.py

NEST brunel_siegert_nestsiegert_neuron + diffusion_connection. Mean-field (Siegert) rates for the Brunel network via pseudo-time relaxation.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/brunel_siegert.py
brette_et_al_2007.py

NEST brette_et_al_2007/{coba,cuba}iaf_cond_exp / iaf_psc_exp. The Vogels-Abbott COBA + CUBA FACETS review benchmarks.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/brette_et_al_2007.py
ei_clustered_network.py

NEST EI_clustered_networkiaf_psc_exp. Clustered random balanced network with potentiated in-cluster / depressed out-cluster weights.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/ei_clustered_network.py
sensitivity_to_perturbation.py

NEST sensitivity_to_perturbationiaf_psc_delta (Brunel-style). Two trials differing by one spike show chaotic decorrelation.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/sensitivity_to_perturbation.py
artificial_synchrony.py

NEST artificial_synchrony (grid branch) → iaf_psc_alpha. Grid-induced artificial synchrony measured by the Golomb-Rinzel statistic.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/artificial_synchrony.py

Devices: generators, recorders & detectors#

The device family — stimulation generators, recorders/multimeters, and correlation detectors (see Devices).

multimeter_file.py

NEST multimeter_filemultimeter (in-memory). Recording several analog variables; read back with res.trace(mm, name).

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/multimeter_file.py
recording_demo.py

NEST recording_demopoisson_generator + iaf_psc_exp + recorders. A tour of the recording API.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/recording_demo.py
repeated_stimulation.py

NEST repeated_stimulationpoisson_generator gated to a [start, stop] window, repeated across trials.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/repeated_stimulation.py
BrodyHopfield.py

NEST BrodyHopfieldiaf_psc_alpha + ac_generator + noise_generator. Spike synchronization to a weak subthreshold oscillation.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/BrodyHopfield.py
sinusoidal_poisson_generator.py

NEST sinusoidal_poisson_generator → same device. An inhomogeneous Poisson train with a sinusoidally-modulated instantaneous rate.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/sinusoidal_poisson_generator.py
sinusoidal_gamma_generator.py

NEST sinusoidal_gamma_generator → same device. A sinusoidally-modulated gamma-process drive (regularity controlled by the shape parameter).

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/sinusoidal_gamma_generator.py
pulsepacket.py

NEST pulsepacketpulsepacket_generator. Gaussian-profile synchronous spike volleys and their effect on a target neuron.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/pulsepacket.py
precise_spiking.py

NEST precise_spikingiaf_psc_exp vs iaf_psc_exp_ps. Grid vs precise (off-grid) spike timing across resolutions.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/precise_spiking.py
correlospinmatrix_detector_two_neuron.py

NEST correlospinmatrix_detector_two_neuronginzburg_neuron + mcculloch_pitts_neuron + correlospinmatrix_detector. Binary auto-/cross-covariances.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/correlospinmatrix_detector_two_neuron.py
cross_check_mip_corrdet.py

NEST cross_check_mip_corrdetmip_generator + correlation_detector. A cross-correlogram cross-checked against a hand-written reference.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/cross_check_mip_corrdet.py
CampbellSiegert.py

NEST CampbellSiegertiaf_psc_alpha (analytic cross-check). Campbell’s theorem + Siegert’s approximation vs a simulated population.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/CampbellSiegert.py

Plasticity: STP, STDP & dendritic rules#

Short-term plasticity, spike-timing-dependent plasticity, and dendritic prediction-error learning (see STDP parity: where state lives and how spikes pair).

evaluate_tsodyks2_synapse.py

NEST evaluate_tsodyks2_synapsetsodyks2_synapse. Depressing and facilitating short-term-plasticity envelopes read off a linear post neuron.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/evaluate_tsodyks2_synapse.py
evaluate_quantal_stp_synapse.py

NEST evaluate_quantal_stp_synapsequantal_stp_synapse. The stochastic (multi-release-site) Tsodyks-Markram variant converging to the deterministic envelope.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/evaluate_quantal_stp_synapse.py
iaf_tum_2000_short_term_depression.py

NEST iaf_tum_2000_short_term_depressioniaf_tum_2000. Presynaptic short-term depression (Tsodyks et al. 1998, Fig 1A).

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/iaf_tum_2000_short_term_depression.py
iaf_tum_2000_short_term_facilitation.py

NEST iaf_tum_2000_short_term_facilitationiaf_tum_2000. Presynaptic short-term facilitation (Fig 1B).

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/iaf_tum_2000_short_term_facilitation.py
clopath_synapse_spike_pairing.py

NEST clopath_synapse_spike_pairingaeif_psc_delta_clopath + clopath_synapse. Voltage-based STDP weight change vs pairing frequency.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/clopath_synapse_spike_pairing.py
clopath_synapse_small_network.py

NEST clopath_synapse_small_networkaeif_psc_delta_clopath + clopath_synapse. Clopath rule establishing directional structure (made deterministic).

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/clopath_synapse_small_network.py
urbanczik_synapse_example.py

NEST urbanczik_synapse_examplepp_cond_exp_mc_urbanczik + urbanczik_synapse. Dendritic prediction-error plasticity (Urbanczik & Senn 2014).

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/urbanczik_synapse_example.py

Gap junctions#

Electrical coupling via the one-step-lagged difference-current scheme.

gap_junctions_two_neurons.py

NEST gap_junctions_two_neuronshh_psc_alpha_gap + gap_junction. Two cells synchronizing through a single symmetric electrical coupling.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/gap_junctions_two_neurons.py
gap_junctions_inhibitory_network.py

NEST gap_junctions_inhibitory_networkhh_psc_alpha_gap. An inhibitory network whose synchrony rises with the gap-junction weight (Hahne et al. 2015).

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/gap_junctions_inhibitory_network.py

Astrocytes & tripartite networks#

Neuron-astrocyte (tripartite) models using tripartite_connect and sic_connection.

astrocyte_single.py

NEST astrocyte_singleastrocyte_lr_1994 (+ readout neuron). A single Poisson-driven astrocyte’s IP3/calcium dynamics.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/astrocyte_single.py
astrocyte_interaction.py

NEST astrocyte_interactionaeif_cond_alpha_astro + astrocyte_lr_1994 + sic_connection. The two-neuron + one-astrocyte tripartite loop.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/astrocyte_interaction.py
astrocyte_small_network.py

NEST astrocyte_small_network → tripartite pairwise_bernoulli + third_factor_bernoulli_with_pool. A small neuron-astrocyte network.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/astrocyte_small_network.py
astrocyte_brunel_bernoulli.py

NEST astrocyte_brunel_bernoulli → Brunel + astrocytes, Bernoulli primary wiring with a random astrocyte pool.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/astrocyte_brunel_bernoulli.py
astrocyte_brunel_fixed_indegree.py

NEST astrocyte_brunel_fixed_indegree → Brunel + astrocytes, fixed-indegree primary wiring (shares the Bernoulli assembly).

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/astrocyte_brunel_fixed_indegree.py

Rate models & mean-field#

Rate-based neurons and mesoscopic population-rate models.

lin_rate_ipn_network.py

NEST lin_rate_ipn_networklin_rate_ipn. Linear rate-neuron network with delayed excitation and instantaneous inhibition.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/lin_rate_ipn_network.py
rate_neuron_dm.py

NEST rate_neuron_dmlin_rate_ipn. A two-unit rectified winner-take-all rate decision circuit.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/rate_neuron_dm.py
gif_pop_psc_exp.py

NEST gif_pop_psc_expgif_pop_psc_exp vs microscopic gif_psc_exp. Mesoscopic population-rate model against its spiking realization.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/gif_pop_psc_exp.py
gif_population.py

NEST gif_populationgif_psc_exp. An adaptation-driven oscillating GIF population under Poisson drive.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/gif_population.py

Spatially-structured networks#

Distance-dependent connectivity from the brainpy.state.spatial family (see Spatially-structured networks).

spatial_grid_iaf.py

NEST spatial/grid_iafspatial.grid + iaf_psc_alpha. A 4x3 grid layer; coordinates read back with get_position.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/spatial_grid_iaf.py
spatial_gaussex.py

NEST spatial/gaussex → distance-dependent pairwise-Bernoulli with a Gaussian kernel between two grid populations.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/spatial_gaussex.py
spatial_3d_gauss.py

NEST spatial/test_3d_gaussspatial.free 3D layer + Gaussian kernel clipped to a cubic mask.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/spatial_3d_gauss.py
spatial_gabor.py

NEST-like anisotropic kernel → gabor distance distribution + rotated elliptical mask (per-axis distance.x / distance.y).

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/spatial_gabor.py
spatial_csa.py

NEST csa_spatial_example → native distance-dependent pairwise-Bernoulli. The Connection Set Algebra expression re-expressed without libneurosim.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/spatial_csa.py
csa_example.py

NEST csa_example → native pairwise_bernoulli equivalent. The CSA / conngen mechanism is intentionally not ported; the connectivity it describes is shown natively.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/csa_example.py

Connectivity & introspection#

Building, retrieving, and inspecting connections (see Connectivity).

synapsecollection.py

NEST synapsecollectionSimulator.get_connections. Connecting under several rules/synapse models and reading/setting .source / .target / .weight.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/synapsecollection.py
plot_weight_matrices.py

NEST plot_weight_matrices → connection introspection. Extract every realized weight and assemble the EE/EI/IE/II matrices for visualization.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/plot_weight_matrices.py

Applications: learning & large networks#

Larger, application-flavored networks — reinforcement learning and constraint solving. These are the “large networks” entries featured on the NEST-Compatible Models hub.

pong.py

NEST pong/pong → pure-Python game logic. The Pong playing field, ball, and paddles used by the spiking learners.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/pong.py
pong_networks.py

NEST pong/networksiaf_psc_exp learners. Reward-modulated STDP (R-STDP) and dopaminergic spiking networks that learn the input→output map.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/pong_networks.py
pong_run.py

NEST pong/run_simulations → harness. Trains the two spiking learners against each other turn by turn with Simulator.cont.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/pong_run.py
sudoku.py

NEST sudoku/sudoku_solver → harness. Relaxes a Sudoku puzzle with a spiking winner-take-all network, reading out per-cell winners each chunk.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/sudoku.py
sudoku_net.py

NEST sudoku/sudoku_netiaf_psc_exp WTA network. Inhibitory connectivity encoding the row/column/box/cell Sudoku constraints.

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/sudoku_net.py
sudoku_puzzles.py

NEST sudoku/helpers_sudoku → pure-Python puzzle bank + solution validator (NumPy only).

https://github.com/chaobrain/brainpy.state/blob/main/examples/nest_like/sudoku_puzzles.py

See Also#