Exemple #1
0
    def test_CopyModel(self):
        """CopyModel"""

        cynest.ResetKernel()
        cynest.CopyModel("sample_neuron", 'new_neuron', {'V_m': 10.0})
        vm = cynest.GetDefaults('new_neuron')['V_m']
        self.assertEqual(vm, 10.0)

        n = cynest.Create('new_neuron', 10)
        vm = cynest.GetStatus([n[0]])[0]['V_m']
        self.assertEqual(vm, 10.0)

        cynest.CopyModel('static_synapse', 'new_synapse', {'weight': 10.})
        cynest.Connect([n[0]], [n[1]], model='new_synapse')
        w = cynest.GetDefaults('new_synapse')['weight']
        self.assertEqual(w, 10.0)

        try:
            cynest.CopyModel(
                "sample_neuron",
                'new_neuron')  # shouldn't be possible a second time
            self.fail('an error should have risen!')  # should not be reached
        except:
            info = sys.exc_info()[1]
            if not "NewModelNameExists" in info.__str__():
                self.fail('could not pass error message to cynest!')
    def test_GetDefaults(self):
        """GetDefaults"""

        model = "sample_neuron"

        cynest.ResetKernel()
        d = cynest.GetDefaults(model)
    def test_SetDefaults(self):
        """SetDefaults"""

        m = "sample_neuron"

        cynest.ResetKernel()
        cynest.SetDefaults(m, {'V_m': -1.})
        self.assertEqual(cynest.GetDefaults(m)['V_m'], -1.)

        try:
            cynest.SetDefaults(m, {'DUMMY': 0})
        except:
            info = sys.exc_info()[1]
            if not "DictError" in info.__str__():
                self.fail('wrong error message')
                             model="inhibitory")

endbuild = time.time()

print("Simulating.")

nest.Simulate(simtime)

endsimulate = time.time()

events_ex = nest.GetStatus(espikes, "n_events")[0]
rate_ex = events_ex / simtime * 1000.0 / N_rec
events_in = nest.GetStatus(ispikes, "n_events")[0]
rate_in = events_in / simtime * 1000.0 / N_rec

num_synapses = nest.GetDefaults("excitatory")["num_connections"]+\
nest.GetDefaults("inhibitory")["num_connections"]

build_time = endbuild - startbuild
sim_time = endsimulate - endbuild

print("Brunel network simulation (Python)")
print("Number of neurons :", N_neurons)
print("Number of synapses:", num_synapses)
print("       Exitatory  :", int(CE * N_neurons) + N_neurons)
print("       Inhibitory :", int(CI * N_neurons))
print("Excitatory rate   : %.2f Hz" % rate_ex)
print("Inhibitory rate   : %.2f Hz" % rate_in)
print("Building time     : %.2f s" % build_time)
print("Simulation time   : %.2f s" % sim_time)
Exemple #5
0
#  Copyright (C) 2009-2010 The NEST Initiative
'''
This file illustrates recording from a iaf_cond_alpha neuron 
using a multimeter.

See multimeter_file.py for an example of how to record to file.
'''

import cynest as nest
import numpy as np
import pylab as pl

nest.ResetKernel()

# display recordables for illustration
print 'iaf_cond_alpha recordables: ', nest.GetDefaults(
    'iaf_cond_alpha')['recordables']

# create neuron and multimeter
n = nest.Create('iaf_cond_alpha', params={'tau_syn_ex': 1.0, 'V_reset': -70.0})

m = nest.Create('multimeter',
                params={
                    'withtime': True,
                    'interval': 0.1,
                    'record_from': ['V_m', 'g_ex', 'g_in']
                })

# Create spike generators and connect
gex = nest.Create('spike_generator',
                  params={'spike_times': np.array([10.0, 20.0, 50.0])})
gin = nest.Create('spike_generator',