"""
Simple test of injecting noisy current into a cell

"""
import sys
from pyNN.utility import get_script_args, normalized_filename

simulator_name = get_script_args(1)[0]
exec("from pyNN.%s import *" % simulator_name)

setup()

filename = normalized_filename("Results", "NoisyCurrentInput", "pkl", simulator_name)

cells = Population(4, IF_curr_exp(v_thresh=-55.0, tau_refrac=5.0))

mean=0.55
stdev=0.1
start=50.0
stop=450.0

steady = DCSource(amplitude=mean, start=start, stop=stop)
cells[0].inject(steady)

noise1 = NoisyCurrentSource(mean=mean, stdev=stdev, start=start, stop=stop, dt=1.0)
cells[1].inject(noise1)
#record('i', noise0, filename)

noise2 = NoisyCurrentSource(mean=mean, stdev=stdev, start=start, stop=stop, dt=5)
cells[2].inject(noise2)
Example #2
0
Andrew Davison, UNIC, CNRS
March 2010

$Id: $
"""

import os
import socket
from math import *

from pyNN.utility import get_script_args, Timer, ProgressBar
usage = """Usage: python VAbenchmarks.py <simulator> <benchmark>
           <simulator> is either neuron, nest, brian or pcsim
           <benchmark> is either CUBA or COBA."""
simulator_name, benchmark = get_script_args(2, usage)
exec("from pyNN.%s import *" % simulator_name)
from pyNN.random import NumpyRNG, RandomDistribution

timer = Timer()

# === Define parameters ========================================================

threads  = 1
rngseed  = 98765
parallel_safe = True

n        = 4000  # number of cells
r_ei     = 4.0   # number of excitatory cells:number of inhibitory cells
pconn    = 0.02  # connection probability
stim_dur = 50.   # (ms) duration of random stimulation
Example #3
0
"""
Conversion of the Brunel network implemented in nest-1.0.13/examples/brunel.sli
to use PyNN.

Brunel N (2000) Dynamics of sparsely connected networks of excitatory and inhibitory spiking neurons. J Comput Neurosci 8:183-208

Andrew Davison, UNIC, CNRS
May 2006

"""

from pyNN.utility import get_script_args, Timer, ProgressBar

simulator_name = get_script_args(1)[0]
exec("from pyNN.%s import *" % simulator_name)

from pyNN.random import NumpyRNG, RandomDistribution

timer = Timer()

# === Define parameters ========================================================

downscale = 50  # scale number of neurons down by this factor
# scale synaptic weights up by this factor to
# obtain similar dynamics independent of size
order = 50000  # determines size of network:
# 4*order excitatory neurons
# 1*order inhibitory neurons
Nrec = 50  # number of neurons to record from, per population
epsilon = 0.1  # connectivity: proportion of neurons each neuron projects to
Example #4
0
File: read.py Project: markovg/PyNN
            connector,
            receptor_type=receptor_type,
            synapse_type=synapse_dynamics,
            label=nineml_projection.name)
        self.projections[
            prj_obj.
            label] = prj_obj  # need to add assembly label to make the name unique

    def describe(self):
        description = "Network model generated from a 9ML description, consisting of:\n  "
        description += "\n  ".join(a.describe()
                                   for a in self.assemblies.values()) + "\n"
        description += "\n  ".join(prj.describe()
                                   for prj in self.projections.values())
        return description


if __name__ == "__main__":
    # For testing purposes: read in the network and print its description
    # if using the nineml or neuroml backend, re-export the network as XML (this doesn't work, but it should).
    import sys, os
    from pyNN.utility import get_script_args
    nineml_file, simulator_name = get_script_args(
        2, "Please specify the 9ML file and the simulator backend.")
    exec("import pyNN.%s as sim" % simulator_name)

    sim.setup(filename="%s_export.xml" % os.path.splitext(nineml_file)[0])
    network = Network(sim, nineml_file)
    print network.describe()
    sim.end()
from pyNN.utility import get_script_args, Timer
import numpy as np
import matplotlib.pyplot as plt
from connector_functions import load_positions, load_lgn_spikes, return_lgn_starting_coordinates
import pyNN.space as space
from connector_functions import create_cortical_to_cortical_connection
from connector_functions import normalize_connection_list
from connector_functions import create_cortical_to_cortical_connection_corr
from connector_functions import create_thalamocortical_connection
from analysis_functions import calculate_tuning, visualize_conductances, visualize_conductances_and_voltage
from analysis_functions import conductance_analysis
from plot_functions import plot_spiketrains

#############################

simulator = get_script_args(1)[0]
exec("import pyNN.%s as simulator" % simulator)
#import pyNN.nest as simulator
#import pyNN.neuron as simulator

timer = Timer()

#############################
##  Parameters
#############################

# ============== Network and simulation parameters =================

contrast = 0.50  # Contrast used (possible range available in ./data)

Nside_lgn = 30  # N_lgn x N_lgn is the size of the LGN
Example #6
0
"""
Simple network with a Poisson spike source projecting to populations of of IF_cond_exp neurons
"""

import time
import numpy as np

import numpy.random as rnd
from pyNN.utility import get_script_args
simulator_name = get_script_args(1)[0]
exec("from pyNN.%s import *" % simulator_name)
if (len(get_script_args(1)) > 1):
    sim_cnt = get_script_args(1)[1]
else:
    sim_cnt = 0
print "DEBUG sim_cnt:", sim_cnt

# # # # # # # # # # # # # # # # # # # # #
#     Simulation parameters             #
# # # # # # # # # # # # # # # # # # # # #
import simulation_parameters
network_params = simulation_parameters.parameter_storage()  # network_params class containing the simulation parameters
params = network_params.load_params()                       # params stores cell numbers, etc as a dictionary

# # # # # # # # # # # # 
#     S E T U P       #
# # # # # # # # # # # #
setup()# timestep=0.1, min_delay=0.1, max_delay=1.0)
rng = NumpyRNG(seed = params['seed'], parallel_safe=True) #if True, slower but does not depend on number of nodes

v_init_distr = RandomDistribution('normal', 
from pyNN.utility import get_script_args, Timer
import numpy as np
import matplotlib.pyplot as plt
from connector_functions import load_positions, load_lgn_spikes, return_lgn_starting_coordinates
import pyNN.space as space
from connector_functions import create_cortical_to_cortical_connection
from connector_functions import normalize_connection_list
from connector_functions import create_cortical_to_cortical_connection_corr
from connector_functions import create_thalamocortical_connection
from analysis_functions import calculate_tuning, visualize_conductances, visualize_conductances_and_voltage
from analysis_functions import conductance_analysis
from plot_functions import plot_spiketrains

#############################

simulator = get_script_args(1)[0]
exec("import pyNN.%s as simulator" % simulator)
#import pyNN.nest as simulator
#import pyNN.neuron as simulator

timer = Timer()

#############################
##  Parameters
#############################

# ============== Network and simulation parameters =================

contrast = 0.50  # Contrast used (possible range available in ./data)

Nside_lgn = 30  # N_lgn x N_lgn is the size of the LGN
 def test_get_script_args(self):
     utility.get_script_args(0)
Example #9
0
Andrew Davison, UNIC, CNRS
August 2006

$Id:VAbenchmarks.py 5 2007-04-16 15:01:24Z davison $
"""

import os
import socket
from math import *

from pyNN.utility import get_script_args, Timer
usage = """Usage: python VAbenchmarks.py <simulator> <benchmark>
           <simulator> is either neuron, nest, brian or pcsim
           <benchmark> is either CUBA or COBA."""
simulator_name, benchmark = get_script_args(2, usage)
exec("from pyNN.%s import *" % simulator_name)
from pyNN.random import NumpyRNG, RandomDistribution

timer = Timer()

# === Define parameters ========================================================

threads = 1
rngseed = 98765
parallel_safe = True

n = 4000  # number of cells
r_ei = 4.0  # number of excitatory cells:number of inhibitory cells
pconn = 0.02  # connection probability
stim_dur = 50.  # (ms) duration of random stimulation
Example #10
0
"""
Very simple STDP test

Andrew Davison, UNIC, CNRS
January 2008

$Id: simple_STDP.py 607 2009-05-19 15:04:35Z apdavison $
"""

import numpy
from pyNN.utility import get_script_args
sim_name = get_script_args(1)[0]   
exec("from pyNN.%s import *" % sim_name)

setup(timestep=0.001, min_delay=0.1, max_delay=1.0, debug=True, quit_on_end=False)

p1 = Population(1, SpikeSourceArray, {'spike_times': numpy.arange(1, 50, 1.0)})
p2 = Population(1, IF_curr_exp)

stdp_model = STDPMechanism(timing_dependence=SpikePairRule(tau_plus=20.0, tau_minus=20.0),
                           weight_dependence=AdditiveWeightDependence(w_min=0, w_max=0.8,
                                                                      A_plus=0.01, A_minus=0.012))

connection_method = AllToAllConnector(weights=0.48, delays=0.2)
prj = Projection(p1, p2, method=connection_method,
                 synapse_dynamics=SynapseDynamics(slow=stdp_model))


p1.record()
p2.record()
p2.record_v()
Example #11
0
        synapse_dynamics = self._build_synapse_dynamics(nineml_projection)
        
        prj_obj = self.sim.Projection(
                    populations[nineml_projection.source.name],
                    populations[nineml_projection.target.name],
                    connector,
                    target=target,
                    synapse_dynamics=synapse_dynamics,
                    label=nineml_projection.name)
        self.projections[prj_obj.label] = prj_obj # need to add assembly label to make the name unique

    def describe(self):
        description = "Network model generated from a 9ML description, consisting of:\n  "
        description += "\n  ".join(a.describe() for a in self.assemblies.values()) + "\n"
        description += "\n  ".join(prj.describe() for prj in self.projections.values())
        return description


if __name__ == "__main__":
    # For testing purposes: read in the network and print its description
    # if using the nineml or neuroml backend, re-export the network as XML (this doesn't work, but it should).
    import sys, os
    from pyNN.utility import get_script_args
    nineml_file, simulator_name = get_script_args(2, "Please specify the 9ML file and the simulator backend.")  
    exec("import pyNN.%s as sim" % simulator_name)
    
    sim.setup(filename="%s_export.xml" % os.path.splitext(nineml_file)[0])
    network = Network(sim, nineml_file)
    print(network.describe())
    sim.end()
Example #12
0
"""
Very simple STDP test

Andrew Davison, UNIC, CNRS
January 2008

"""

import numpy
from pyNN.utility import get_script_args

sim_name = get_script_args(1)[0]
exec("from pyNN.%s import *" % sim_name)

setup(timestep=0.001, min_delay=0.1, max_delay=1.0)

p1 = Population(1, SpikeSourceArray(spike_times=numpy.arange(1, 50, 1.0)))
p2 = Population(1, IF_curr_exp())

stdp_model = STDPMechanism(timing_dependence=SpikePairRule(tau_plus=20.0,
                                                           tau_minus=20.0,
                                                           A_plus=0.01,
                                                           A_minus=0.012),
                           weight_dependence=AdditiveWeightDependence(
                               w_min=0, w_max=0.8),
                           weight=0.48,
                           delay=0.2)

connection_method = AllToAllConnector()
prj = Projection(p1, p2, connection_method, synapse_type=stdp_model)
Example #13
0
"""
Network of integrate-and-fire neurons with distance-dependent connectivity and STDP.
"""

from pyNN.utility import get_script_args
usage = """Usage: python stdp_network.py <simulator>"""
simulator_name, = get_script_args(1, usage)
exec("import pyNN.%s as sim" % simulator_name)
from pyNN import space

n_exc = 80
n_inh = 20
n_stim = 20
cell_parameters = {
    'tau_m' : 20.0,    'tau_syn_E': 2.0,    'tau_syn_I': 5.0,
    'v_rest': -65.0,   'v_reset'  : -70.0,  'v_thresh':  -50.0,
    'cm':     1.0,     'tau_refrac': 2.0,   'e_rev_E':   0.0,
    'e_rev_I': -70.0,
}
grid_parameters = {
    'aspect_ratio': 1, 'dx': 50.0, 'dy': 50.0, 'fill_order': 'random'
}
stimulation_parameters = {
    'rate': 100.0,
    'duration': 50.0
}

connectivity_parameters = {
    'gaussian': {'d_expression': 'exp(-d**2/1e4)'},
    'global': {'p_connect': 0.1},
    'input': {'n': 10},
Example #14
0
 def test_get_script_args(self):
     utility.get_script_args(0)