Note
Go to the end to download the full example code.
PyNEST EI-clustered network: Run SimulationΒΆ
Run this example as a Jupyter notebook:
See our guide for more information and troubleshooting.
This is an example script for running the EI-clustered model with two stimulations and generating a raster plot.
import matplotlib.pyplot as plt
import network
from helper import raster_plot
from network_params import net_dict
from sim_params import sim_dict
from stimulus_params import stim_dict
if __name__ == "__main__":
# Creates object which creates the EI clustered network in NEST
ei_network = network.ClusteredNetwork(sim_dict, net_dict, stim_dict)
# Runs the simulation and returns the spiketimes
# get simulation initializes the network in NEST
# and runs the simulation
# it returns a dict with the average rates,
# the spiketimes and the used parameters
result = ei_network.get_simulation()
ax = raster_plot(
result["spiketimes"],
tlim=(0, sim_dict["simtime"]),
colorgroups=[
("k", 0, net_dict["N_E"]),
("darkred", net_dict["N_E"], net_dict["N_E"] + net_dict["N_I"]),
],
)
plt.savefig("clustered_ei_raster.png")
print(f"Firing rate of excitatory neurons: {result['e_rate']:6.2f} spikes/s")
print(f"Firing rate of inhibitory neurons: {result['i_rate']:6.2f} spikes/s")