Interactive single Izhikevich neuron NeuroML example#

To run this interactive Jupyter Notebook, please click on the rocket icon 🚀 in the top panel. For more information, please see how to use this documentation. Please uncomment the line below if you use the Google Colab (it does not include these packages by default).

#%pip install pyneuroml neuromllite NEURON
from neuroml import NeuroMLDocument
import neuroml.writers as writers
from neuroml.utils import component_factory
from neuroml.utils import validate_neuroml2
from pyneuroml import pynml
from pyneuroml.lems import LEMSSimulation
import numpy as np

Declaring the NeuroML model#

Create a NeuroML document#

nml_doc = component_factory(NeuroMLDocument, id="IzhSingleNeuron")
nml_doc.info()
Please see the NeuroML standard schema documentation at https://docs.neuroml.org/Userdocs/NeuroMLv2.html for more information.

Valid members for NeuroMLDocument are:
* sine_generators (class: SineGenerator, Optional)
* sine_generator_dls (class: SineGeneratorDL, Optional)
* ramp_generators (class: RampGenerator, Optional)
* ramp_generator_dls (class: RampGeneratorDL, Optional)
* compound_inputs (class: CompoundInput, Optional)
* compound_input_dls (class: CompoundInputDL, Optional)
* includes (class: IncludeType, Optional)
* voltage_clamps (class: VoltageClamp, Optional)
* extracellular_properties (class: ExtracellularProperties, Optional)
* voltage_clamp_triples (class: VoltageClampTriple, Optional)
* intracellular_properties (class: IntracellularProperties, Optional)
* spike_arrays (class: SpikeArray, Optional)
* morphology (class: Morphology, Optional)
* timed_synaptic_inputs (class: TimedSynapticInput, Optional)
* ion_channel (class: IonChannel, Optional)
* spike_generators (class: SpikeGenerator, Optional)
* ion_channel_hhs (class: IonChannelHH, Optional)
* spike_generator_randoms (class: SpikeGeneratorRandom, Optional)
* ion_channel_v_shifts (class: IonChannelVShift, Optional)
* spike_generator_poissons (class: SpikeGeneratorPoisson, Optional)
* ion_channel_kses (class: IonChannelKS, Optional)
* spike_generator_ref_poissons (class: SpikeGeneratorRefPoisson, Optional)
* decaying_pool_concentration_models (class: DecayingPoolConcentrationModel, Optional)
* poisson_firing_synapses (class: PoissonFiringSynapse, Optional)
* fixed_factor_concentration_models (class: FixedFactorConcentrationModel, Optional)
* transient_poisson_firing_synapses (class: TransientPoissonFiringSynapse, Optional)
* alpha_current_synapses (class: AlphaCurrentSynapse, Optional)
* IF_curr_alpha (class: IF_curr_alpha, Optional)
* alpha_synapses (class: AlphaSynapse, Optional)
* IF_curr_exp (class: IF_curr_exp, Optional)
* exp_one_synapses (class: ExpOneSynapse, Optional)
* IF_cond_alpha (class: IF_cond_alpha, Optional)
* exp_two_synapses (class: ExpTwoSynapse, Optional)
* IF_cond_exp (class: IF_cond_exp, Optional)
* id (class: NmlId, Required)
* exp_three_synapses (class: ExpThreeSynapse, Optional)
* EIF_cond_exp_isfa_ista (class: EIF_cond_exp_isfa_ista, Optional)
* blocking_plastic_synapses (class: BlockingPlasticSynapse, Optional)
* EIF_cond_alpha_isfa_ista (class: EIF_cond_alpha_isfa_ista, Optional)
* double_synapses (class: DoubleSynapse, Optional)
* HH_cond_exp (class: HH_cond_exp, Optional)
* gap_junctions (class: GapJunction, Optional)
* exp_cond_synapses (class: ExpCondSynapse, Optional)
* silent_synapses (class: SilentSynapse, Optional)
* alpha_cond_synapses (class: AlphaCondSynapse, Optional)
* metaid (class: MetaId, Optional)
* linear_graded_synapses (class: LinearGradedSynapse, Optional)
* exp_curr_synapses (class: ExpCurrSynapse, Optional)
* properties (class: Property, Optional)
* graded_synapses (class: GradedSynapse, Optional)
* alpha_curr_synapses (class: AlphaCurrSynapse, Optional)
* biophysical_properties (class: BiophysicalProperties, Optional)
* SpikeSourcePoisson (class: SpikeSourcePoisson, Optional)
* cells (class: Cell, Optional)
* networks (class: Network, Optional)
* cell2_ca_poolses (class: Cell2CaPools, Optional)
* ComponentType (class: ComponentType, Optional)
* base_cells (class: BaseCell, Optional)
* iaf_tau_cells (class: IafTauCell, Optional)
* annotation (class: Annotation, Optional)
* iaf_tau_ref_cells (class: IafTauRefCell, Optional)
* notes (class: xs:string, Optional)
* iaf_cells (class: IafCell, Optional)
* iaf_ref_cells (class: IafRefCell, Optional)
* izhikevich_cells (class: IzhikevichCell, Optional)
* izhikevich2007_cells (class: Izhikevich2007Cell, Optional)
* ad_ex_ia_f_cells (class: AdExIaFCell, Optional)
* fitz_hugh_nagumo_cells (class: FitzHughNagumoCell, Optional)
* fitz_hugh_nagumo1969_cells (class: FitzHughNagumo1969Cell, Optional)
* pinsky_rinzel_ca3_cells (class: PinskyRinzelCA3Cell, Optional)
* pulse_generators (class: PulseGenerator, Optional)
* pulse_generator_dls (class: PulseGeneratorDL, Optional)
'Please see the NeuroML standard schema documentation at https://docs.neuroml.org/Userdocs/NeuroMLv2.html for more information.\n\nValid members for NeuroMLDocument are:\n* sine_generators (class: SineGenerator, Optional)\n* sine_generator_dls (class: SineGeneratorDL, Optional)\n* ramp_generators (class: RampGenerator, Optional)\n* ramp_generator_dls (class: RampGeneratorDL, Optional)\n* compound_inputs (class: CompoundInput, Optional)\n* compound_input_dls (class: CompoundInputDL, Optional)\n* includes (class: IncludeType, Optional)\n* voltage_clamps (class: VoltageClamp, Optional)\n* extracellular_properties (class: ExtracellularProperties, Optional)\n* voltage_clamp_triples (class: VoltageClampTriple, Optional)\n* intracellular_properties (class: IntracellularProperties, Optional)\n* spike_arrays (class: SpikeArray, Optional)\n* morphology (class: Morphology, Optional)\n* timed_synaptic_inputs (class: TimedSynapticInput, Optional)\n* ion_channel (class: IonChannel, Optional)\n* spike_generators (class: SpikeGenerator, Optional)\n* ion_channel_hhs (class: IonChannelHH, Optional)\n* spike_generator_randoms (class: SpikeGeneratorRandom, Optional)\n* ion_channel_v_shifts (class: IonChannelVShift, Optional)\n* spike_generator_poissons (class: SpikeGeneratorPoisson, Optional)\n* ion_channel_kses (class: IonChannelKS, Optional)\n* spike_generator_ref_poissons (class: SpikeGeneratorRefPoisson, Optional)\n* decaying_pool_concentration_models (class: DecayingPoolConcentrationModel, Optional)\n* poisson_firing_synapses (class: PoissonFiringSynapse, Optional)\n* fixed_factor_concentration_models (class: FixedFactorConcentrationModel, Optional)\n* transient_poisson_firing_synapses (class: TransientPoissonFiringSynapse, Optional)\n* alpha_current_synapses (class: AlphaCurrentSynapse, Optional)\n* IF_curr_alpha (class: IF_curr_alpha, Optional)\n* alpha_synapses (class: AlphaSynapse, Optional)\n* IF_curr_exp (class: IF_curr_exp, Optional)\n* exp_one_synapses (class: ExpOneSynapse, Optional)\n* IF_cond_alpha (class: IF_cond_alpha, Optional)\n* exp_two_synapses (class: ExpTwoSynapse, Optional)\n* IF_cond_exp (class: IF_cond_exp, Optional)\n* id (class: NmlId, Required)\n* exp_three_synapses (class: ExpThreeSynapse, Optional)\n* EIF_cond_exp_isfa_ista (class: EIF_cond_exp_isfa_ista, Optional)\n* blocking_plastic_synapses (class: BlockingPlasticSynapse, Optional)\n* EIF_cond_alpha_isfa_ista (class: EIF_cond_alpha_isfa_ista, Optional)\n* double_synapses (class: DoubleSynapse, Optional)\n* HH_cond_exp (class: HH_cond_exp, Optional)\n* gap_junctions (class: GapJunction, Optional)\n* exp_cond_synapses (class: ExpCondSynapse, Optional)\n* silent_synapses (class: SilentSynapse, Optional)\n* alpha_cond_synapses (class: AlphaCondSynapse, Optional)\n* metaid (class: MetaId, Optional)\n* linear_graded_synapses (class: LinearGradedSynapse, Optional)\n* exp_curr_synapses (class: ExpCurrSynapse, Optional)\n* properties (class: Property, Optional)\n* graded_synapses (class: GradedSynapse, Optional)\n* alpha_curr_synapses (class: AlphaCurrSynapse, Optional)\n* biophysical_properties (class: BiophysicalProperties, Optional)\n* SpikeSourcePoisson (class: SpikeSourcePoisson, Optional)\n* cells (class: Cell, Optional)\n* networks (class: Network, Optional)\n* cell2_ca_poolses (class: Cell2CaPools, Optional)\n* ComponentType (class: ComponentType, Optional)\n* base_cells (class: BaseCell, Optional)\n* iaf_tau_cells (class: IafTauCell, Optional)\n* annotation (class: Annotation, Optional)\n* iaf_tau_ref_cells (class: IafTauRefCell, Optional)\n* notes (class: xs:string, Optional)\n* iaf_cells (class: IafCell, Optional)\n* iaf_ref_cells (class: IafRefCell, Optional)\n* izhikevich_cells (class: IzhikevichCell, Optional)\n* izhikevich2007_cells (class: Izhikevich2007Cell, Optional)\n* ad_ex_ia_f_cells (class: AdExIaFCell, Optional)\n* fitz_hugh_nagumo_cells (class: FitzHughNagumoCell, Optional)\n* fitz_hugh_nagumo1969_cells (class: FitzHughNagumo1969Cell, Optional)\n* pinsky_rinzel_ca3_cells (class: PinskyRinzelCA3Cell, Optional)\n* pulse_generators (class: PulseGenerator, Optional)\n* pulse_generator_dls (class: PulseGeneratorDL, Optional)\n'
nml_doc.info(True)
Please see the NeuroML standard schema documentation at https://docs.neuroml.org/Userdocs/NeuroMLv2.html for more information.

Valid members for NeuroMLDocument are:
* sine_generators (class: SineGenerator, Optional)
* sine_generator_dls (class: SineGeneratorDL, Optional)
* ramp_generators (class: RampGenerator, Optional)
* ramp_generator_dls (class: RampGeneratorDL, Optional)
* compound_inputs (class: CompoundInput, Optional)
* compound_input_dls (class: CompoundInputDL, Optional)
* includes (class: IncludeType, Optional)
* voltage_clamps (class: VoltageClamp, Optional)
* extracellular_properties (class: ExtracellularProperties, Optional)
* voltage_clamp_triples (class: VoltageClampTriple, Optional)
* intracellular_properties (class: IntracellularProperties, Optional)
* spike_arrays (class: SpikeArray, Optional)
* morphology (class: Morphology, Optional)
* timed_synaptic_inputs (class: TimedSynapticInput, Optional)
* ion_channel (class: IonChannel, Optional)
* spike_generators (class: SpikeGenerator, Optional)
* ion_channel_hhs (class: IonChannelHH, Optional)
* spike_generator_randoms (class: SpikeGeneratorRandom, Optional)
* ion_channel_v_shifts (class: IonChannelVShift, Optional)
* spike_generator_poissons (class: SpikeGeneratorPoisson, Optional)
* ion_channel_kses (class: IonChannelKS, Optional)
* spike_generator_ref_poissons (class: SpikeGeneratorRefPoisson, Optional)
* decaying_pool_concentration_models (class: DecayingPoolConcentrationModel, Optional)
* poisson_firing_synapses (class: PoissonFiringSynapse, Optional)
* fixed_factor_concentration_models (class: FixedFactorConcentrationModel, Optional)
* transient_poisson_firing_synapses (class: TransientPoissonFiringSynapse, Optional)
* alpha_current_synapses (class: AlphaCurrentSynapse, Optional)
* IF_curr_alpha (class: IF_curr_alpha, Optional)
* alpha_synapses (class: AlphaSynapse, Optional)
* IF_curr_exp (class: IF_curr_exp, Optional)
* exp_one_synapses (class: ExpOneSynapse, Optional)
* IF_cond_alpha (class: IF_cond_alpha, Optional)
* exp_two_synapses (class: ExpTwoSynapse, Optional)
* IF_cond_exp (class: IF_cond_exp, Optional)
* id (class: NmlId, Required)
	* Contents ('ids'/<objects>): IzhSingleNeuron

* exp_three_synapses (class: ExpThreeSynapse, Optional)
* EIF_cond_exp_isfa_ista (class: EIF_cond_exp_isfa_ista, Optional)
* blocking_plastic_synapses (class: BlockingPlasticSynapse, Optional)
* EIF_cond_alpha_isfa_ista (class: EIF_cond_alpha_isfa_ista, Optional)
* double_synapses (class: DoubleSynapse, Optional)
* HH_cond_exp (class: HH_cond_exp, Optional)
* gap_junctions (class: GapJunction, Optional)
* exp_cond_synapses (class: ExpCondSynapse, Optional)
* silent_synapses (class: SilentSynapse, Optional)
* alpha_cond_synapses (class: AlphaCondSynapse, Optional)
* metaid (class: MetaId, Optional)
* linear_graded_synapses (class: LinearGradedSynapse, Optional)
* exp_curr_synapses (class: ExpCurrSynapse, Optional)
* properties (class: Property, Optional)
* graded_synapses (class: GradedSynapse, Optional)
* alpha_curr_synapses (class: AlphaCurrSynapse, Optional)
* biophysical_properties (class: BiophysicalProperties, Optional)
* SpikeSourcePoisson (class: SpikeSourcePoisson, Optional)
* cells (class: Cell, Optional)
* networks (class: Network, Optional)
* cell2_ca_poolses (class: Cell2CaPools, Optional)
* ComponentType (class: ComponentType, Optional)
* base_cells (class: BaseCell, Optional)
* iaf_tau_cells (class: IafTauCell, Optional)
* annotation (class: Annotation, Optional)
* iaf_tau_ref_cells (class: IafTauRefCell, Optional)
* notes (class: xs:string, Optional)
* iaf_cells (class: IafCell, Optional)
* iaf_ref_cells (class: IafRefCell, Optional)
* izhikevich_cells (class: IzhikevichCell, Optional)
* izhikevich2007_cells (class: Izhikevich2007Cell, Optional)
* ad_ex_ia_f_cells (class: AdExIaFCell, Optional)
* fitz_hugh_nagumo_cells (class: FitzHughNagumoCell, Optional)
* fitz_hugh_nagumo1969_cells (class: FitzHughNagumo1969Cell, Optional)
* pinsky_rinzel_ca3_cells (class: PinskyRinzelCA3Cell, Optional)
* pulse_generators (class: PulseGenerator, Optional)
* pulse_generator_dls (class: PulseGeneratorDL, Optional)
"Please see the NeuroML standard schema documentation at https://docs.neuroml.org/Userdocs/NeuroMLv2.html for more information.\n\nValid members for NeuroMLDocument are:\n* sine_generators (class: SineGenerator, Optional)\n* sine_generator_dls (class: SineGeneratorDL, Optional)\n* ramp_generators (class: RampGenerator, Optional)\n* ramp_generator_dls (class: RampGeneratorDL, Optional)\n* compound_inputs (class: CompoundInput, Optional)\n* compound_input_dls (class: CompoundInputDL, Optional)\n* includes (class: IncludeType, Optional)\n* voltage_clamps (class: VoltageClamp, Optional)\n* extracellular_properties (class: ExtracellularProperties, Optional)\n* voltage_clamp_triples (class: VoltageClampTriple, Optional)\n* intracellular_properties (class: IntracellularProperties, Optional)\n* spike_arrays (class: SpikeArray, Optional)\n* morphology (class: Morphology, Optional)\n* timed_synaptic_inputs (class: TimedSynapticInput, Optional)\n* ion_channel (class: IonChannel, Optional)\n* spike_generators (class: SpikeGenerator, Optional)\n* ion_channel_hhs (class: IonChannelHH, Optional)\n* spike_generator_randoms (class: SpikeGeneratorRandom, Optional)\n* ion_channel_v_shifts (class: IonChannelVShift, Optional)\n* spike_generator_poissons (class: SpikeGeneratorPoisson, Optional)\n* ion_channel_kses (class: IonChannelKS, Optional)\n* spike_generator_ref_poissons (class: SpikeGeneratorRefPoisson, Optional)\n* decaying_pool_concentration_models (class: DecayingPoolConcentrationModel, Optional)\n* poisson_firing_synapses (class: PoissonFiringSynapse, Optional)\n* fixed_factor_concentration_models (class: FixedFactorConcentrationModel, Optional)\n* transient_poisson_firing_synapses (class: TransientPoissonFiringSynapse, Optional)\n* alpha_current_synapses (class: AlphaCurrentSynapse, Optional)\n* IF_curr_alpha (class: IF_curr_alpha, Optional)\n* alpha_synapses (class: AlphaSynapse, Optional)\n* IF_curr_exp (class: IF_curr_exp, Optional)\n* exp_one_synapses (class: ExpOneSynapse, Optional)\n* IF_cond_alpha (class: IF_cond_alpha, Optional)\n* exp_two_synapses (class: ExpTwoSynapse, Optional)\n* IF_cond_exp (class: IF_cond_exp, Optional)\n* id (class: NmlId, Required)\n\t* Contents ('ids'/<objects>): IzhSingleNeuron\n\n* exp_three_synapses (class: ExpThreeSynapse, Optional)\n* EIF_cond_exp_isfa_ista (class: EIF_cond_exp_isfa_ista, Optional)\n* blocking_plastic_synapses (class: BlockingPlasticSynapse, Optional)\n* EIF_cond_alpha_isfa_ista (class: EIF_cond_alpha_isfa_ista, Optional)\n* double_synapses (class: DoubleSynapse, Optional)\n* HH_cond_exp (class: HH_cond_exp, Optional)\n* gap_junctions (class: GapJunction, Optional)\n* exp_cond_synapses (class: ExpCondSynapse, Optional)\n* silent_synapses (class: SilentSynapse, Optional)\n* alpha_cond_synapses (class: AlphaCondSynapse, Optional)\n* metaid (class: MetaId, Optional)\n* linear_graded_synapses (class: LinearGradedSynapse, Optional)\n* exp_curr_synapses (class: ExpCurrSynapse, Optional)\n* properties (class: Property, Optional)\n* graded_synapses (class: GradedSynapse, Optional)\n* alpha_curr_synapses (class: AlphaCurrSynapse, Optional)\n* biophysical_properties (class: BiophysicalProperties, Optional)\n* SpikeSourcePoisson (class: SpikeSourcePoisson, Optional)\n* cells (class: Cell, Optional)\n* networks (class: Network, Optional)\n* cell2_ca_poolses (class: Cell2CaPools, Optional)\n* ComponentType (class: ComponentType, Optional)\n* base_cells (class: BaseCell, Optional)\n* iaf_tau_cells (class: IafTauCell, Optional)\n* annotation (class: Annotation, Optional)\n* iaf_tau_ref_cells (class: IafTauRefCell, Optional)\n* notes (class: xs:string, Optional)\n* iaf_cells (class: IafCell, Optional)\n* iaf_ref_cells (class: IafRefCell, Optional)\n* izhikevich_cells (class: IzhikevichCell, Optional)\n* izhikevich2007_cells (class: Izhikevich2007Cell, Optional)\n* ad_ex_ia_f_cells (class: AdExIaFCell, Optional)\n* fitz_hugh_nagumo_cells (class: FitzHughNagumoCell, Optional)\n* fitz_hugh_nagumo1969_cells (class: FitzHughNagumo1969Cell, Optional)\n* pinsky_rinzel_ca3_cells (class: PinskyRinzelCA3Cell, Optional)\n* pulse_generators (class: PulseGenerator, Optional)\n* pulse_generator_dls (class: PulseGeneratorDL, Optional)\n"

Define the Izhikevich cell and add it to the model#

izh0 = nml_doc.add(
    "Izhikevich2007Cell",
    id="izh2007RS0", v0="-60mV", C="100pF", k="0.7nS_per_mV", vr="-60mV",
    vt="-40mV", vpeak="35mV", a="0.03per_ms", b="-2nS", c="-50.0mV", d="100pA")
izh0.info(True)
nml_doc.info(show_contents=True)
Izhikevich2007Cell -- Cell based on the modified Izhikevich model in Izhikevich 2007, Dynamical systems in neuroscience, MIT Press

Please see the NeuroML standard schema documentation at https://docs.neuroml.org/Userdocs/NeuroMLv2.html for more information.

Valid members for Izhikevich2007Cell are:
* notes (class: xs:string, Optional)
* vpeak (class: Nml2Quantity_voltage, Required)
	* Contents ('ids'/<objects>): 35mV

* a (class: Nml2Quantity_pertime, Required)
	* Contents ('ids'/<objects>): 0.03per_ms

* C (class: Nml2Quantity_capacitance, Required)
	* Contents ('ids'/<objects>): 100pF

* b (class: Nml2Quantity_conductance, Required)
	* Contents ('ids'/<objects>): -2nS

* metaid (class: MetaId, Optional)
* c (class: Nml2Quantity_voltage, Required)
	* Contents ('ids'/<objects>): -50.0mV

* properties (class: Property, Optional)
* d (class: Nml2Quantity_current, Required)
	* Contents ('ids'/<objects>): 100pA

* v0 (class: Nml2Quantity_voltage, Required)
	* Contents ('ids'/<objects>): -60mV

* k (class: Nml2Quantity_conductancePerVoltage, Required)
	* Contents ('ids'/<objects>): 0.7nS_per_mV

* id (class: NmlId, Required)
	* Contents ('ids'/<objects>): izh2007RS0

* vr (class: Nml2Quantity_voltage, Required)
	* Contents ('ids'/<objects>): -60mV

* neuro_lex_id (class: NeuroLexId, Optional)
* annotation (class: Annotation, Optional)
* vt (class: Nml2Quantity_voltage, Required)
	* Contents ('ids'/<objects>): -40mV


Please see the NeuroML standard schema documentation at https://docs.neuroml.org/Userdocs/NeuroMLv2.html for more information.

Valid members for NeuroMLDocument are:
* sine_generators (class: SineGenerator, Optional)
* sine_generator_dls (class: SineGeneratorDL, Optional)
* ramp_generators (class: RampGenerator, Optional)
* ramp_generator_dls (class: RampGeneratorDL, Optional)
* compound_inputs (class: CompoundInput, Optional)
* compound_input_dls (class: CompoundInputDL, Optional)
* includes (class: IncludeType, Optional)
* voltage_clamps (class: VoltageClamp, Optional)
* extracellular_properties (class: ExtracellularProperties, Optional)
* voltage_clamp_triples (class: VoltageClampTriple, Optional)
* intracellular_properties (class: IntracellularProperties, Optional)
* spike_arrays (class: SpikeArray, Optional)
* morphology (class: Morphology, Optional)
* timed_synaptic_inputs (class: TimedSynapticInput, Optional)
* ion_channel (class: IonChannel, Optional)
* spike_generators (class: SpikeGenerator, Optional)
* ion_channel_hhs (class: IonChannelHH, Optional)
* spike_generator_randoms (class: SpikeGeneratorRandom, Optional)
* ion_channel_v_shifts (class: IonChannelVShift, Optional)
* spike_generator_poissons (class: SpikeGeneratorPoisson, Optional)
* ion_channel_kses (class: IonChannelKS, Optional)
* spike_generator_ref_poissons (class: SpikeGeneratorRefPoisson, Optional)
* decaying_pool_concentration_models (class: DecayingPoolConcentrationModel, Optional)
* poisson_firing_synapses (class: PoissonFiringSynapse, Optional)
* fixed_factor_concentration_models (class: FixedFactorConcentrationModel, Optional)
* transient_poisson_firing_synapses (class: TransientPoissonFiringSynapse, Optional)
* alpha_current_synapses (class: AlphaCurrentSynapse, Optional)
* IF_curr_alpha (class: IF_curr_alpha, Optional)
* alpha_synapses (class: AlphaSynapse, Optional)
* IF_curr_exp (class: IF_curr_exp, Optional)
* exp_one_synapses (class: ExpOneSynapse, Optional)
* IF_cond_alpha (class: IF_cond_alpha, Optional)
* exp_two_synapses (class: ExpTwoSynapse, Optional)
* IF_cond_exp (class: IF_cond_exp, Optional)
* id (class: NmlId, Required)
	* Contents ('ids'/<objects>): IzhSingleNeuron

* exp_three_synapses (class: ExpThreeSynapse, Optional)
* EIF_cond_exp_isfa_ista (class: EIF_cond_exp_isfa_ista, Optional)
* blocking_plastic_synapses (class: BlockingPlasticSynapse, Optional)
* EIF_cond_alpha_isfa_ista (class: EIF_cond_alpha_isfa_ista, Optional)
* double_synapses (class: DoubleSynapse, Optional)
* HH_cond_exp (class: HH_cond_exp, Optional)
* gap_junctions (class: GapJunction, Optional)
* exp_cond_synapses (class: ExpCondSynapse, Optional)
* silent_synapses (class: SilentSynapse, Optional)
* alpha_cond_synapses (class: AlphaCondSynapse, Optional)
* metaid (class: MetaId, Optional)
* linear_graded_synapses (class: LinearGradedSynapse, Optional)
* exp_curr_synapses (class: ExpCurrSynapse, Optional)
* properties (class: Property, Optional)
* graded_synapses (class: GradedSynapse, Optional)
* alpha_curr_synapses (class: AlphaCurrSynapse, Optional)
* biophysical_properties (class: BiophysicalProperties, Optional)
* SpikeSourcePoisson (class: SpikeSourcePoisson, Optional)
* cells (class: Cell, Optional)
* networks (class: Network, Optional)
* cell2_ca_poolses (class: Cell2CaPools, Optional)
* ComponentType (class: ComponentType, Optional)
* base_cells (class: BaseCell, Optional)
* iaf_tau_cells (class: IafTauCell, Optional)
* annotation (class: Annotation, Optional)
* iaf_tau_ref_cells (class: IafTauRefCell, Optional)
* notes (class: xs:string, Optional)
* iaf_cells (class: IafCell, Optional)
* iaf_ref_cells (class: IafRefCell, Optional)
* izhikevich_cells (class: IzhikevichCell, Optional)
* izhikevich2007_cells (class: Izhikevich2007Cell, Optional)
	* Contents ('ids'/<objects>): ['izh2007RS0']

* ad_ex_ia_f_cells (class: AdExIaFCell, Optional)
* fitz_hugh_nagumo_cells (class: FitzHughNagumoCell, Optional)
* fitz_hugh_nagumo1969_cells (class: FitzHughNagumo1969Cell, Optional)
* pinsky_rinzel_ca3_cells (class: PinskyRinzelCA3Cell, Optional)
* pulse_generators (class: PulseGenerator, Optional)
* pulse_generator_dls (class: PulseGeneratorDL, Optional)
"Please see the NeuroML standard schema documentation at https://docs.neuroml.org/Userdocs/NeuroMLv2.html for more information.\n\nValid members for NeuroMLDocument are:\n* sine_generators (class: SineGenerator, Optional)\n* sine_generator_dls (class: SineGeneratorDL, Optional)\n* ramp_generators (class: RampGenerator, Optional)\n* ramp_generator_dls (class: RampGeneratorDL, Optional)\n* compound_inputs (class: CompoundInput, Optional)\n* compound_input_dls (class: CompoundInputDL, Optional)\n* includes (class: IncludeType, Optional)\n* voltage_clamps (class: VoltageClamp, Optional)\n* extracellular_properties (class: ExtracellularProperties, Optional)\n* voltage_clamp_triples (class: VoltageClampTriple, Optional)\n* intracellular_properties (class: IntracellularProperties, Optional)\n* spike_arrays (class: SpikeArray, Optional)\n* morphology (class: Morphology, Optional)\n* timed_synaptic_inputs (class: TimedSynapticInput, Optional)\n* ion_channel (class: IonChannel, Optional)\n* spike_generators (class: SpikeGenerator, Optional)\n* ion_channel_hhs (class: IonChannelHH, Optional)\n* spike_generator_randoms (class: SpikeGeneratorRandom, Optional)\n* ion_channel_v_shifts (class: IonChannelVShift, Optional)\n* spike_generator_poissons (class: SpikeGeneratorPoisson, Optional)\n* ion_channel_kses (class: IonChannelKS, Optional)\n* spike_generator_ref_poissons (class: SpikeGeneratorRefPoisson, Optional)\n* decaying_pool_concentration_models (class: DecayingPoolConcentrationModel, Optional)\n* poisson_firing_synapses (class: PoissonFiringSynapse, Optional)\n* fixed_factor_concentration_models (class: FixedFactorConcentrationModel, Optional)\n* transient_poisson_firing_synapses (class: TransientPoissonFiringSynapse, Optional)\n* alpha_current_synapses (class: AlphaCurrentSynapse, Optional)\n* IF_curr_alpha (class: IF_curr_alpha, Optional)\n* alpha_synapses (class: AlphaSynapse, Optional)\n* IF_curr_exp (class: IF_curr_exp, Optional)\n* exp_one_synapses (class: ExpOneSynapse, Optional)\n* IF_cond_alpha (class: IF_cond_alpha, Optional)\n* exp_two_synapses (class: ExpTwoSynapse, Optional)\n* IF_cond_exp (class: IF_cond_exp, Optional)\n* id (class: NmlId, Required)\n\t* Contents ('ids'/<objects>): IzhSingleNeuron\n\n* exp_three_synapses (class: ExpThreeSynapse, Optional)\n* EIF_cond_exp_isfa_ista (class: EIF_cond_exp_isfa_ista, Optional)\n* blocking_plastic_synapses (class: BlockingPlasticSynapse, Optional)\n* EIF_cond_alpha_isfa_ista (class: EIF_cond_alpha_isfa_ista, Optional)\n* double_synapses (class: DoubleSynapse, Optional)\n* HH_cond_exp (class: HH_cond_exp, Optional)\n* gap_junctions (class: GapJunction, Optional)\n* exp_cond_synapses (class: ExpCondSynapse, Optional)\n* silent_synapses (class: SilentSynapse, Optional)\n* alpha_cond_synapses (class: AlphaCondSynapse, Optional)\n* metaid (class: MetaId, Optional)\n* linear_graded_synapses (class: LinearGradedSynapse, Optional)\n* exp_curr_synapses (class: ExpCurrSynapse, Optional)\n* properties (class: Property, Optional)\n* graded_synapses (class: GradedSynapse, Optional)\n* alpha_curr_synapses (class: AlphaCurrSynapse, Optional)\n* biophysical_properties (class: BiophysicalProperties, Optional)\n* SpikeSourcePoisson (class: SpikeSourcePoisson, Optional)\n* cells (class: Cell, Optional)\n* networks (class: Network, Optional)\n* cell2_ca_poolses (class: Cell2CaPools, Optional)\n* ComponentType (class: ComponentType, Optional)\n* base_cells (class: BaseCell, Optional)\n* iaf_tau_cells (class: IafTauCell, Optional)\n* annotation (class: Annotation, Optional)\n* iaf_tau_ref_cells (class: IafTauRefCell, Optional)\n* notes (class: xs:string, Optional)\n* iaf_cells (class: IafCell, Optional)\n* iaf_ref_cells (class: IafRefCell, Optional)\n* izhikevich_cells (class: IzhikevichCell, Optional)\n* izhikevich2007_cells (class: Izhikevich2007Cell, Optional)\n\t* Contents ('ids'/<objects>): ['izh2007RS0']\n\n* ad_ex_ia_f_cells (class: AdExIaFCell, Optional)\n* fitz_hugh_nagumo_cells (class: FitzHughNagumoCell, Optional)\n* fitz_hugh_nagumo1969_cells (class: FitzHughNagumo1969Cell, Optional)\n* pinsky_rinzel_ca3_cells (class: PinskyRinzelCA3Cell, Optional)\n* pulse_generators (class: PulseGenerator, Optional)\n* pulse_generator_dls (class: PulseGeneratorDL, Optional)\n"

Create a network and add it to the model#

net = nml_doc.add("Network", id="IzNet", validate=False)

Create a population of defined cells and add it to the model#

size0 = 1
pop0 = net.add("Population", id="IzhPop0", component=izh0.id, size=size0)
net.info()
Network -- Network containing:  **population** s ( potentially of type  **populationList** , and so specifying a list of cell  **location** s );  **projection** s ( with lists of  **connection** s ) and/or  **explicitConnection** s; and  **inputList** s ( with lists of  **input** s ) and/or  **explicitInput** s. Note: often in NeuroML this will be of type  **networkWithTemperature**  if there are temperature dependent elements ( e. g. ion channels ).

Please see the NeuroML standard schema documentation at https://docs.neuroml.org/Userdocs/NeuroMLv2.html for more information.

Valid members for Network are:
* synaptic_connections (class: SynapticConnection, Optional)
* projections (class: Projection, Optional)
* electrical_projections (class: ElectricalProjection, Optional)
* continuous_projections (class: ContinuousProjection, Optional)
* explicit_inputs (class: ExplicitInput, Optional)
* input_lists (class: InputList, Optional)
* id (class: NmlId, Required)
* metaid (class: MetaId, Optional)
* properties (class: Property, Optional)
* annotation (class: Annotation, Optional)
* notes (class: xs:string, Optional)
* type (class: networkTypes, Optional)
* temperature (class: Nml2Quantity_temperature, Optional)
* neuro_lex_id (class: NeuroLexId, Optional)
* spaces (class: Space, Optional)
* regions (class: Region, Optional)
* extracellular_properties (class: ExtracellularPropertiesLocal, Optional)
* populations (class: Population, Required)
* cell_sets (class: CellSet, Optional)
'Network -- Network containing:  **population** s ( potentially of type  **populationList** , and so specifying a list of cell  **location** s );  **projection** s ( with lists of  **connection** s ) and/or  **explicitConnection** s; and  **inputList** s ( with lists of  **input** s ) and/or  **explicitInput** s. Note: often in NeuroML this will be of type  **networkWithTemperature**  if there are temperature dependent elements ( e. g. ion channels ).\n\nPlease see the NeuroML standard schema documentation at https://docs.neuroml.org/Userdocs/NeuroMLv2.html for more information.\n\nValid members for Network are:\n* synaptic_connections (class: SynapticConnection, Optional)\n* projections (class: Projection, Optional)\n* electrical_projections (class: ElectricalProjection, Optional)\n* continuous_projections (class: ContinuousProjection, Optional)\n* explicit_inputs (class: ExplicitInput, Optional)\n* input_lists (class: InputList, Optional)\n* id (class: NmlId, Required)\n* metaid (class: MetaId, Optional)\n* properties (class: Property, Optional)\n* annotation (class: Annotation, Optional)\n* notes (class: xs:string, Optional)\n* type (class: networkTypes, Optional)\n* temperature (class: Nml2Quantity_temperature, Optional)\n* neuro_lex_id (class: NeuroLexId, Optional)\n* spaces (class: Space, Optional)\n* regions (class: Region, Optional)\n* extracellular_properties (class: ExtracellularPropertiesLocal, Optional)\n* populations (class: Population, Required)\n* cell_sets (class: CellSet, Optional)\n'

Define an external stimulus and add it to the model#

pg = nml_doc.add(
    "PulseGenerator",
    id="pulseGen_%i" % 0, delay="0ms", duration="1000ms",
    amplitude="0.07 nA"
)
exp_input = net.add("ExplicitInput", target="%s[%i]" % (pop0.id, 0), input=pg.id)

Write the NeuroML model to a file#

nml_file = 'izhikevich2007_single_cell_network.nml'
writers.NeuroMLWriter.write(nml_doc, nml_file)
print("Written network file to: " + nml_file)
Written network file to: izhikevich2007_single_cell_network.nml

Validate the NeuroML model#

validate_neuroml2(nml_file)
Validating izhikevich2007_single_cell_network.nml against /home/asinha/.local/share/virtualenvs/neuroml-dev/lib/python3.10/site-packages/neuroml/nml/NeuroML_v2.3.xsd
It's valid!

Simulating the model#

Create a simulation instance of the model#

simulation_id = "example-single-izhikevich2007cell-sim"
simulation = LEMSSimulation(sim_id=simulation_id,
                            duration=1000, dt=0.1, simulation_seed=123)
simulation.assign_simulation_target(net.id)
simulation.include_neuroml2_file(nml_file)
pyNeuroML >>> INFO - Loading NeuroML2 file: /home/asinha/Documents/02_Code/00_mine/NeuroML/documentation/source/Userdocs/NML2_examples/izhikevich2007_single_cell_network.nml

Define the output file to store simulation outputs#

Here, we record the neuron’s membrane potential to the specified data file.

simulation.create_output_file(
    "output0", "%s.v.dat" % simulation_id
)
simulation.add_column_to_output_file("output0", 'IzhPop0[0]', 'IzhPop0[0]/v')

Save the simulation to a file#

lems_simulation_file = simulation.save_to_file()

Run the simulation using the jNeuroML simulator#

pynml.run_lems_with_jneuroml(
    lems_simulation_file, max_memory="2G", nogui=True, plot=False
)
pyNeuroML >>> INFO - Loading LEMS file: LEMS_example-single-izhikevich2007cell-sim.xml and running with jNeuroML
pyNeuroML >>> INFO - Executing: (java -Xmx2G  -Djava.awt.headless=true -jar  "/home/asinha/.local/share/virtualenvs/neuroml-dev/lib/python3.10/site-packages/pyneuroml/lib/jNeuroML-0.12.0-jar-with-dependencies.jar"  "LEMS_example-single-izhikevich2007cell-sim.xml"  -nogui -I '') in directory: .
pyNeuroML >>> INFO - Command completed. Output: 
  jNeuroML >>   jNeuroML v0.12.0
  jNeuroML >>  Loading: /home/asinha/Documents/02_Code/00_mine/NeuroML/documentation/source/Userdocs/NML2_examples/LEMS_example-single-izhikevich2007cell-sim.xml with jLEMS, NO GUI mode...
  jNeuroML >>  INFO Sep 15,2022 15:24  (INFO) Loading LEMS file from: /home/asinha/Documents/02_Code/00_mine/NeuroML/documentation/source/Userdocs/NML2_examples/LEMS_example-single-izhikevich2007cell-sim.xml
  jNeuroML >>  INFO Sep 15,2022 15:24  (INFO) Reading from: /home/asinha/Documents/02_Code/00_mine/NeuroML/documentation/source/Userdocs/NML2_examples/LEMS_example-single-izhikevich2007cell-sim.xml
  jNeuroML >>  INFO Sep 15,2022 15:24  (INFO) Finished 10000 steps in 0.081 seconds (sim duration: 1000.0ms; dt: 0.1ms)
  jNeuroML >>  INFO Sep 15,2022 15:24  (INFO) Written to the file /home/asinha/Documents/02_Code/00_mine/NeuroML/documentation/source/Userdocs/NML2_examples/./example-single-izhikevich2007cell-sim.v.dat 204829
  jNeuroML >>  INFO Sep 15,2022 15:24  (INFO) Finished reading, building, running and displaying LEMS model
  jNeuroML >>  
True

Plot the recorded data#

# Load the data from the file and plot the graph for the membrane potential
# using the pynml generate_plot utility function.
data_array = np.loadtxt("%s.v.dat" % simulation_id)
pynml.generate_plot(
    [data_array[:, 0]], [data_array[:, 1]],
    "Membrane potential", show_plot_already=True,
    xaxis="time (s)", yaxis="membrane potential (V)"
)
pyNeuroML >>> INFO - Generating plot: Membrane potential
/home/asinha/.local/share/virtualenvs/neuroml-dev/lib/python3.10/site-packages/pyneuroml/plot/Plot.py:186: UserWarning: marker is redundantly defined by the 'marker' keyword argument and the fmt string "o" (-> marker='o'). The keyword argument will take precedence.
  plt.plot(
../../_images/SingleNeuron_30_1.png
<AxesSubplot:xlabel='time (s)', ylabel='membrane potential (V)'>