Esempio n. 1
0
    def run(self, morphodata):
        """run """

        # Set Biophysics
        neuron = self.biophysics(morphodata)
        neuron.run_regularly('Mgblock = 1./(1.+ exp(-0.062*vu2)/3.57)',
                             dt=br2.defaultclock.dt)
        # Record in every section
        #        monitor = self.v_record(neuron)
        monitor = br2.StateMonitor(neuron,
                                   'v',
                                   record=True,
                                   dt=20 * defaultclock.dt)

        morph_data = morphodata

        axo = len(morph_data['axon'])
        bsl = list(morph_data['basal'])
        apc = list(morph_data['apical'])
        #        dc = distal_compartments_Branco_eff
        #        pc = proximal_compartments_Branco
        dc = distal_compartments_Acker_eff
        pc = proximal_compartments_Acker

        #        nrComp = 10 #len(bsl)

        #####################################################
        # Input Neuron
        #####################################################
        Theta_low = morph_data['thetalow'] * br2.mV

        V_rest = 0. * br2.mV
        V_thresh = 0.5 * br2.mV

        NrInGroups = 4
        Nr_clust_dist = NrInGroups  #5     # Nr of clustered ensembles distally
        Nr_clust_prox = 0  #5    # Nr of clustered ensembles proximally
        Nr_scattered = 0  #5    # Nr of scattered ensembles
        Ens_size = 20  # Ensemble size
        GrpSize = Ens_size * NrInGroups
        NrEnsembles = (Nr_clust_dist + Nr_clust_prox + Nr_scattered)
        NrGroups = int(NrEnsembles / NrInGroups)
        NrIn = NrEnsembles * Ens_size  # nr of input neurons
        init_weight = .2  # initial weight

        signal_rate = 30. * br2.Hz  # activation rate of synapses
        t_stim = 50 * br2.ms  # stimulation length
        buffertime = 50 * br2.ms  # resting time between stimulations

        reps = 1  # nr of activations of each ensemble

        # Equations input neuron
        eqs_in = ''' 
        dv/dt = (V_rest-v)/ms: volt
        v2 = rand()<rate_v*dt :1 (constant over dt)
        rate_v :Hz
        ds_trace/dt = -s_trace/taux :1
        '''

        #####################################################
        # Create neurons
        #####################################################
        N_input = br2.NeuronGroup(NrIn,
                                  eqs_in,
                                  threshold='v+v2*2*V_thresh>V_thresh',
                                  reset='v=V_rest;s_trace+=x_reset*(taux/ms)',
                                  method='linear')  #

        Syn_1 = br2.Synapses(N_input,
                             neuron,
                             model=eq_1_nonPlast,
                             on_pre=eq_2_nonPlast,
                             method='heun')

        # distally clustered ensembles
        c_ndx = np.floor(np.random.rand(Nr_clust_dist) * len(dc))
        for cc in range(Nr_clust_dist):
            Syn_1.connect(i=range(cc * Ens_size, (cc + 1) * Ens_size),
                          j=neuron[dc[int(c_ndx[cc])]:dc[int(c_ndx[cc])] + 1])

        # proximally clustered ensembles
        c_ndx2 = np.floor(np.random.rand(Nr_clust_prox) * len(pc))
        for cc in range(Nr_clust_prox):
            Syn_1.connect(
                i=range(cc * Ens_size + Nr_clust_dist * Ens_size,
                        (cc + 1) * Ens_size + Nr_clust_dist * Ens_size),
                j=neuron[pc[int(c_ndx2[cc])]:pc[int(c_ndx2[cc])] + 1])

        # distributed ensembles
        rand_post_comp = np.floor(
            np.random.rand(Ens_size * Nr_scattered) * (len(bsl) - axo - 1) +
            axo + 1)
        for pp in range(Ens_size * (Nr_clust_dist + Nr_clust_prox), NrIn):
            Syn_1.connect(
                i=pp,
                j=neuron[int(rand_post_comp[pp - Ens_size *
                                            (Nr_clust_dist + Nr_clust_prox)]):
                         int(rand_post_comp[pp - Ens_size *
                                            (Nr_clust_dist + Nr_clust_prox)] +
                             1)])

        # Initialize the model
        neuron.v = EL
        neuron.I = 0. * br2.nA
        #        neuron.I[0] = 0.2*nA
        set_init_syn(Syn_1, init_weight)
        set_init_nrn(neuron, Theta_low)
        N_input.v = V_rest

        #####################################################
        # Run
        #####################################################
        print('Simulating ...')
        for tt in range(reps * NrGroups):
            print(tt)
            N_input.rate_v[np.mod(tt, NrGroups) *
                           GrpSize:np.mod(tt, NrGroups) * GrpSize +
                           GrpSize] = signal_rate
            br2.run(t_stim)
            N_input.rate_v = np.zeros(NrIn)
            br2.run(buffertime)
        print('Simulation Finished!')

        #store data in sec[1]
        for sec in self.sections.values():
            kk = sec[2]
            sec[1] = monitor.v[kk:kk + len(sec[0].x)]


#            sec[1] = monitor.gKL[kk:kk+len(sec[0].x)]

        plt.figure()
        plt.plot(monitor.t / br2.ms, monitor.v[0] / br2.mV)
        return monitor, neuron
                             on_pre=eq_2_plastAMPA,
                             method='heun')
            #
            #
            Syn_4 = Synapses(neuron2,
                             neuron,
                             model=eq_1_plastAMPA,
                             on_pre=eq_2_plastAMPA,
                             method='heun')
            #
            for rr in range(NrSyn):
                Syn_1.connect(
                    i=0,
                    j=neuron2[compv1[int(syn_loc1[rr]
                                         )]:compv1[int(syn_loc1[rr])] + 1])
            set_init_syn(Syn_1, init_weight)
            #
            #
            for rr in range(NrSyn):
                Syn_4.connect(
                    i=0,
                    j=neuron[compv2[int(syn_loc2[rr]
                                        )]:compv2[int(syn_loc2[rr])] + 1])
            set_init_syn(Syn_4, init_weight)
            #
            print('Synapses created...')
            #

            #####################################################
            # Monitors
            #####################################################
Esempio n. 3
0
for ggg in range(len(dendList)):
    if dendList[ggg] < nrD:
        Syn_1.connect(
            i=ggg * nrIn + np.arange(nrIn),
            j=neuron[compartments[dendList[ggg]]:compartments[dendList[ggg]] +
                     1])
    else:
        print('ERROR, wrong synaptic organisation')

#####################################################
# Initial Values
#####################################################
N_input.v = V_rest
set_init_nrn(neuron, Theta_low)
set_init_syn(Syn_1, init_weight)

print('Synapses created...')

#####################################################
# Monitors
#####################################################
M_post_soma = StateMonitor(neuron.main, ['v'], record=True)
M_post_dend = StateMonitor(neuron, ['v'], record=compartments)

######################################################
## Simulation
######################################################
print('Start ' + morph[12:-4])
t_init = 0
times_mtx = zeros(len(dendList) + 1)