def __init__(self, n: int=60, weight: float=500., stepcycle: float=1000., step: float=10.):
		self.num_afferents = n
		self.cur_time = 0.
		self.fiber = Create('spike_generator', self.num_afferents)
		self.spiketimes = [[] for i in range(n)]
		self.base_freq = 40.
		self.max_freq = 200.
		self.startpoint = .3
		self.endpoint = .5
		self.maxpoint = .45
		self.spikes_per_step = 3
		self.step = step
		self.total_steps = int(stepcycle / step)
		self.generate_spiketimes(stepcycle, step)
		spike_weights = [[weight for _ in self.spiketimes[i]] for i in range(self.num_afferents)]
		for i in range(len(self.fiber)):
			SetStatus([self.fiber[i],], {'spike_times': sorted(self.spiketimes[i]), 'spike_weights': spike_weights[i]})

		self.neurons = Create(
			model='hh_cond_exp_traub',
	        n=n,
	        params={
            't_ref': 2.,
            'V_m': -70.0,
            'E_L': -70.0,
            'g_L': 50.0,
            'tau_syn_ex': .2,
            'tau_syn_in': 1.})

		self.connect(self.neurons)
def test_freq():
	from nest import SetKernelStatus, Simulate, ResetKernel, raster_plot
	ResetKernel()
	SetKernelStatus({
	    'total_num_virtual_procs': 2,
	    'print_time': True,
	    'resolution': 0.1})

	paf = ProkhazkaAfferentFiber()
	sd = Create('spike_detector', params={'withgid': True, 'withtime': True})
	mm = Create('')
	print(sd)
	Connect(paf.neurons, sd)
	Simulate(1000.)
	raster_plot.from_device(sd, hist=True)
	raster_plot.show()
Example #3
0
    def __init__(self):
        # ia_aff = AfferentFiber(muscle=Muscle.EXTENS, afferent=Afferent.IA)
        try:
            type(ia_aff)
        except NameError:
            ia_aff = create(60)
            Connect(pre=add_multimeter('afferent'), post=ia_aff)

        period = round(1000. / Params.RATE.value, 1)

        ees = Create(
            model='spike_generator',
            params={
                'spike_times':
                [10. + i * period for i in range(Params.NUM_SPIKES.value)],
                'spike_weights':
                [300. for i in range(Params.NUM_SPIKES.value)]
            })

        Connect(pre=ees,
                post=ia_aff,
                syn_spec={
                    'model': 'static_synapse',
                    'weight': 1.,
                    'delay': .1
                },
                conn_spec={
                    'rule': 'fixed_outdegree',
                    'outdegree': 60,
                    'multapses': False,
                    'autapses': False
                })

        moto = create(n=169)
        Connect(pre=add_multimeter('moto'), post=moto)
        ia_int = create(n=196)
        Connect(pre=add_multimeter('ia_int'), post=ia_int)
        rc = create(196)
        Connect(add_multimeter('rc'), post=rc)
        level2 = Level2()

        for i in range(Params.NUM_SUBLEVELS.value):
            connect(pre=level2.sublayers[i].general_left,
                    post=moto,
                    weight=15.,
                    degree=100)

        # connect(ia_aff.neuron_ids, level2.sublayers[0].general_right, 20., 20, 3.)
        # connect(ia_aff.neuron_ids, moto, 7., 196)
        # connect(ia_aff.neuron_ids, ia_int, 3., 196)

        connect(ia_aff, level2.sublayers[0].general_right, 30., 20, 3.)
        connect(ia_aff, moto, 7., 196)
        connect(ia_aff, ia_int, 3., 196)
        connect(moto, rc, 7., 100)
        connect(rc, moto, -7., 100)
        connect(ia_int, moto, -7., 100)
 def __init__(self):
     self.ees = Create(model='spike_generator',
                       params={
                           'spike_times': [
                               10. + i * round(1000. / Params.RATE.value, 1)
                               for i in range(Params.NUM_SPIKES.value)
                           ],
                           'spike_weights':
                           [500. for _ in range(Params.NUM_SPIKES.value)]
                       })
Example #5
0
def create(n: int):
    return Create(
        model='hh_cond_exp_traub',
        n=n,
        params={
            't_ref': 2.,
            'V_m': -70.0,
            'E_L': -70.0,
            'g_L': 50.0,
            'tau_syn_ex': .2,
            'tau_syn_in': 1.})
Example #6
0
def add_multimeter(name):
    return Create(model='multimeter',
                  n=1,
                  params={
                      'label': os.path.join(raw_data_path, name),
                      'record_from': ['V_m'],
                      'withgid': True,
                      'withtime': True,
                      'interval': 0.1,
                      'to_file': True,
                      'to_memory': True
                  })
Example #7
0
def add_spike_detector(name):
    """
	Args:
		name: neurons group name
    Returns:
		list: list of spikedetector GID
    """
    return Create(model='spike_detector',
                  n=1,
                  params={
                      'label': os.path.join(raw_data_path, name),
                      'withgid': True,
                      'to_file': True,
                      'to_memory': True
                  })
Example #8
0
    def __init__(self, n: int=60, weight: float=500., end_time: float=1000., stepcycle: float=1000., step: float=20.):

        self.n = n
        self.weight = weight
        self.stepcycle = stepcycle
        self.step = step
        self.end_time = end_time
        self.spikes_per_step = 2
        self.cur_time = .1

        self.generators = [Create('spike_generator', 1) for _ in range(self.n)]
        self.spike_times = [[] for _ in range(self.n)]

        while self.cur_time < self.end_time:
            for i in range(self.calculate_activated_fibers()):
                spike_times = sorted(self.generate_spike_times(i))
                spike_weights = [weight for _ in spike_times]
                self.spike_times[i].extend(spike_times)
            self.cur_time += step
    def create(self, neuron_number):
        """
		Args:
			neuron_number (int): number of neurons
		Returns:
			list: list of neurons ID
		"""
        return Create(
            model='hh_cond_exp_traub',
            n=neuron_number,
            params={
                't_ref': self.rand(1.9, 2.1)
                if self.multitest else 2.0,  # [ms] refractory period
                'V_m': -70.0,  # [mV] starting value of membrane potential
                'E_L': self.rand(-70.5, -69.5)
                if self.multitest else -70.0,  # [mV] leak reversal potential
                'g_L': 75.0,  # [nS] leak conductance
                'tau_syn_ex': 0.2,  # [ms]
                'tau_syn_in': 3.0  # [ms]
            })
Example #10
0
    def __init__(self,
                 inversion: bool = False,
                 time: float = 2000,
                 period: float = 1000.,
                 stand_coef: float = 0.7,
                 rate: float = 60):
        spike_times = []
        standing_time = period * stand_coef
        walking_time = period * (1 - stand_coef)
        if inversion:
            i = 0
            periods = [standing_time, walking_time]
        else:
            i = 1
            periods = [walking_time, standing_time]
        timepoint = 0.1
        while timepoint < time:
            if i:
                timepoint += periods[i]
                i = (i + 1) % 2
            else:
                spikes_at_period = int(periods[i] / 1000 * rate)
                time_between_spikes = round(periods[i] / spikes_at_period, 1)
                spike_times.extend([
                    timepoint + time_between_spikes * i
                    for i in range(spikes_at_period)
                ])
                timepoint += periods[i]
                i = (i + 1) % 2

        self.id = Create(model='spike_generator',
                         n=1,
                         params={
                             'spike_times': spike_times,
                             'spike_weights': [500. for _ in spike_times]
                         })