Exemplo n.º 1
0
    def step_math(self, dt, J, spiked, cells, voltage):
        # 1. Determine voltage changes
        dV = (dt / self.tau_rc) * J

        spiketimes = np.array(
            [c.spiketime if not c.refractory else 0.0 for c in cells])
        dV += spiketimes * J / nrn_duration(self.tau_rc)

        # 2. Apply voltage changes
        for c, w in zip(cells, dV):
            if not c.refractory:
                c.spiketime = 0.0
            c.in_con.weight[0] = w
            c.in_con.event(neuron.h.t + nrn_duration(dt) / 2.0)

        # 3. Setup recording of spikes
        spikes = self._setup_spike_recorder(cells)

        # 4. Simulate for one time step
        neuron.run(neuron.h.t + nrn_duration(dt))

        # 5. Check for spikes and record voltages
        spiked[:] = [s.size() > 0 for s in spikes]
        spiked /= dt
        voltage[:] = [np.clip(c.neuron.M(), 0, 1) for c in cells]

        # 6. Record spike times
        for idx in np.where(spiked)[0]:
            cells[idx].spiketime = neuron.h.t - spikes[idx][0]
            cells[idx].neuron.refrac = nrn_duration(self.tau_ref +
                                                    dt) - cells[idx].spiketime
Exemplo n.º 2
0
 def __init__(self, tau_rc, tau_ref):
     self.neuron = neuron.h.IntFire1()
     self.neuron.tau = nrn_duration(tau_rc)
     self.neuron.refrac = nrn_duration(tau_ref)
     self.in_con = neuron.h.NetCon(None, self.neuron)
     self.out_con = neuron.h.NetCon(self.neuron, None)
     self.spiketime = 0.0
Exemplo n.º 3
0
    def step_math(self, dt, J, spiked, cells, voltage):
        # 1. Determine voltage changes
        dV = (dt / self.tau_rc) * J

        spiketimes = np.array(
            [c.spiketime if not c.refractory else 0.0 for c in cells])
        dV += spiketimes * J / nrn_duration(self.tau_rc)

        # 2. Apply voltage changes
        for c, w in zip(cells, dV):
            if not c.refractory:
                c.spiketime = 0.0
            c.in_con.weight[0] = w
            c.in_con.event(neuron.h.t + nrn_duration(dt) / 2.0)

        # 3. Setup recording of spikes
        spikes = self._setup_spike_recorder(cells)

        # 4. Simulate for one time step
        neuron.run(neuron.h.t + nrn_duration(dt))

        # 5. Check for spikes and record voltages
        spiked[:] = [s.size() > 0 for s in spikes]
        spiked /= dt
        voltage[:] = [np.clip(c.neuron.M(), 0, 1) for c in cells]

        # 6. Record spike times
        for idx in np.where(spiked)[0]:
            cells[idx].spiketime = neuron.h.t - spikes[idx][0]
            cells[idx].neuron.refrac = nrn_duration(
                self.tau_ref + dt) - cells[idx].spiketime
Exemplo n.º 4
0
 def __init__(self, tau_rc, tau_ref):
     self.neuron = neuron.h.IntFire1()
     self.neuron.tau = nrn_duration(tau_rc)
     self.neuron.refrac = nrn_duration(tau_ref)
     self.in_con = neuron.h.NetCon(None, self.neuron)
     self.out_con = neuron.h.NetCon(self.neuron, None)
     self.spiketime = 0.0
Exemplo n.º 5
0
    def create(self, sec, weight):
        syn = neuron.h.FixedCurrent(sec)
        syn.tau = nrn_duration(self.tau)

        in_con = neuron.h.NetCon(None, syn)
        in_con.weight[0] = weight

        return self.SynapticCon(syn=syn, in_con=in_con)
Exemplo n.º 6
0
    def create(self, sec, weight):
        syn = neuron.h.FixedCurrent(sec)
        syn.tau = nrn_duration(self.tau)

        in_con = neuron.h.NetCon(None, syn)
        in_con.weight[0] = weight

        return self.SynapticCon(syn=syn, in_con=in_con)
Exemplo n.º 7
0
    def step_math(self, dt, J, spiked, cells, voltage):
        for c in cells:
            c.spikes.resize(0)

        # 1. Simulate for one time step
        neuron.run(neuron.h.t + nrn_duration(dt))

        # 2. Check for spikes
        spiked[:] = [c.spikes.size() > 0 for c in cells]
        spiked /= dt
        voltage[:] = [c.neuron.soma.v for c in cells]
Exemplo n.º 8
0
    def step_math(self, dt, J, spiked, cells, voltage):
        for c in cells:
            c.spikes.resize(0)

        # 1. Simulate for one time step
        neuron.run(neuron.h.t + nrn_duration(dt))

        # 2. Check for spikes
        spiked[:] = [c.spikes.size() > 0 for c in cells]
        spiked /= dt
        voltage[:] = [c.neuron.soma.v for c in cells]
Exemplo n.º 9
0
    def create(self, sec, weight):
        syn = neuron.h.ExpSyn(sec)
        syn.tau = nrn_duration(self.tau)
        if weight >= 0.0:
            syn.e = self.e_exc
        else:
            syn.e = self.e_inh

        in_con = neuron.h.NetCon(None, syn)
        in_con.weight[0] = abs(weight)

        return self.SynapticCon(syn=syn, in_con=in_con)
Exemplo n.º 10
0
    def create(self, sec, weight):
        syn = neuron.h.ExpSyn(sec)
        syn.tau = nrn_duration(self.tau)
        if weight >= 0.0:
            syn.e = self.e_exc
        else:
            syn.e = self.e_inh

        in_con = neuron.h.NetCon(None, syn)
        in_con.weight[0] = abs(weight)

        return self.SynapticCon(syn=syn, in_con=in_con)