Exemplo n.º 1
0
 def __init__(self,
              presynaptic_population,
              postsynaptic_population,
              connector,
              synapse_type,
              source=None,
              receptor_type=None,
              space=Space(),
              label=None):
     common.Projection.__init__(self, presynaptic_population,
                                postsynaptic_population, connector,
                                synapse_type, source, receptor_type, space,
                                label)
     self.connections = None
     self._n_connections = 0
     # create one Synapses object per pre-post population pair
     # there will be multiple such pairs if either `presynaptic_population`
     # or `postsynaptic_population` is an Assembly.
     if isinstance(self.pre, common.Assembly):
         presynaptic_populations = self.pre.populations
     else:
         presynaptic_populations = [self.pre]
     if isinstance(self.post, common.Assembly):
         postsynaptic_populations = self.post.populations
         assert self.post._homogeneous_synapses, "Inhomogeneous assemblies not yet supported"
     else:
         postsynaptic_populations = [self.post]
     self._brian_synapses = defaultdict(dict)
     for i, pre in enumerate(presynaptic_populations):
         for j, post in enumerate(postsynaptic_populations):
             # complete the synapse type equations according to the
             # post-synaptic response type
             psv = post.celltype.post_synaptic_variables[self.receptor_type]
             weight_units = post.celltype.conductance_based and uS or nA
             self.synapse_type._set_target_type(weight_units)
             equation_context = {
                 "syn_var": psv,
                 "weight_units": weight_units
             }
             pre_eqns = self.synapse_type.pre % equation_context
             if self.synapse_type.post:
                 post_eqns = self.synapse_type.post % equation_context
             else:
                 post_eqns = None
             model = self.synapse_type.eqs % equation_context
             # create the brian Synapses object.
             syn_obj = brian.Synapses(pre.brian_group,
                                      post.brian_group,
                                      model=model,
                                      pre=pre_eqns,
                                      post=post_eqns,
                                      code_namespace={"exp": numpy.exp})
             self._brian_synapses[i][j] = syn_obj
             simulator.state.network.add(syn_obj)
     # connect the populations
     connector.connect(self)
     # special-case: the Tsodyks-Markram short-term plasticity model takes
     #               a parameter value from the post-synaptic response model
     if isinstance(self.synapse_type, TsodyksMarkramSynapse):
         self._set_tau_syn_for_tsodyks_markram()
Exemplo n.º 2
0
def simulation_example(brian_clock, brian):

    import numpy

    print "Simulation function!"

    brian.defaultclock = brian_clock

    Number_of_input_neurons = 20

    spiketimes = []
    Input_layer = brian.SpikeGeneratorGroup(20, spiketimes)

    Output_layer = brian.NeuronGroup(Number_of_input_neurons,
                                     model='v:1',
                                     reset=0,
                                     threshold=10)

    S = brian.Synapses(Input_layer, Output_layer, model='w:1', pre='v+=w')

    S[:, :] = 'i==j'
    S.w = 100

    return Input_layer, Output_layer, [Input_layer, Output_layer], [S], []
Exemplo n.º 3
0
    def create_synapses(self, synapse_type):
        #
        # Creates the connections (Synapse object) among the neurons in the liquid
        #

        self.syn_type = synapse_type

        # synapse_type = 'exc'
        # EXCITATORY (PRE) TO ANYTHING (POST) => ie+=w*u*x (what defines if it is a Excitatory or Inhibitory connection
        # is the place where it is connected - ie or ii)
        # EE and IE connection types

        # synapse_type = 'inh'
        # INHIBITORY (PRE) TO ANYTHING (POST) => ii+=w*u*x (what defines if it is a Excitatory or Inhibitory connection
        # is the place where it is connected - ie or ii)
        # IE and II connection types

        # STP equation from:
        # http://www.briansimulator.org/docs/synapses.html
        # http://www.briansimulator.org/docs/examples-synapses_short_term_plasticity.html
        # In this part is selected the right synapse equation according to the type of the connection (see comments above)
        # The ONLY difference between the EXCITATORY AND THE INHIBITORY is where the weight is injected: ie or ii
        if self.syn_type == 'exc' and not self.nostp:
            model_eq = '''x : 1
                            u : 1
                            w : 1
                            tauf : 1
                            taud : 1
                            U : 1
                            '''
            pre_eq = '''u=U+(u-U)*numpy.exp(-(t-lastupdate)/tauf)
                          x=1+(x-1)*numpy.exp(-(t-lastupdate)/taud)
                          ie+=w*u*x
                          x*=(1-u)
                          u+=U*(1-u)'''

        elif self.syn_type == 'exc' and self.nostp:
            model_eq = '''w : 1'''
            pre_eq = '''ie+=w'''
            # pre_eq='''v+=w/c_m'''

        elif self.syn_type == 'inh' and not self.nostp:
            model_eq = '''x : 1
                            u : 1
                            w : 1
                            tauf : 1
                            taud : 1
                            U : 1
                            '''
            pre_eq = '''u=U+(u-U)*numpy.exp(-(t-lastupdate)/tauf)
                          x=1+(x-1)*numpy.exp(-(t-lastupdate)/taud)
                          ii+=w*u*x
                          x*=(1-u)
                          u+=U*(1-u)'''

        elif self.syn_type == 'inh' and self.nostp:
            model_eq = '''w : 1'''
            pre_eq = '''ii+=w'''
            # pre_eq='''v+=w/c_m'''

        self.syn_lsm = brian.Synapses(self.pop_lsm_a,
                                      self.pop_lsm_b,
                                      model=model_eq,
                                      pre=pre_eq,
                                      clock=self.sim_clock)

        # Sets the synapses according to the probability function (Maass 2002 - lsm_module.py)
        # NOT OPTMIZED!!!
        # Caution about creation of synapses:
        # 1) there is no deletion
        # 2) synapses are added, not replaced (e.g. S[1,2]=True;S[1,2]=True creates 2 synapses)

        self.w_syn = [
        ]  # list to store the Weights (w) in the same order as the creation of the synapses
        self.U_syn = [
        ]  # list to store the Use (U) in the same order as the creation of the synapses
        self.taud_syn = [
        ]  # list to store the Time constant for Depression (taud) in the same order as the creation of the synapses
        self.tauf_syn = [
        ]  # list to store the Time constant for Facilitation (tauf) in the same order as the creation of the synapses
        self.d_syn = [
        ]  # list to store the Delay (D) in the same order as the creation of the synapses

        # This part goes through all the connections (EE, EI, II and IE) but sets only the ones that start according to 'synapse_type'
        for i in xrange(len(self.output[self.syn_type])):

            ipre, ipos = self.output[self.syn_type][i][
                0]  # sets the position of the neurons
            self.syn_lsm[
                ipre,
                ipos] = True  # here is where the synapse is really created

            # It is extremely important to append this values at the same order the synapses (connections) are created otherwise they will not match the right synapse!!!!!!
            self.w_syn.append(
                self.output[self.syn_type][i][2]
                [0])  # sets the value of the Weight (w) for this connection
            self.U_syn.append(
                self.output[self.syn_type][i][2]
                [1])  # sets the value of the Use (U) for this connection
            self.taud_syn.append(
                self.output[self.syn_type][i][2][2]
            )  # sets the value of the Time constant for Depression (taud) for this connection
            self.tauf_syn.append(
                self.output[self.syn_type][i][2][3]
            )  # sets the value of the Time constant for Facilitation (tauf) for this connection
            self.d_syn.append(
                self.output[self.syn_type][i]
                [3])  # sets the value of the Delay (D) for this connection

        # The output[self.syn_type] is organized like this:
        #     (i,j), # PRE and POS synaptic neuron indexes (this is not the same thing as the position in the 3D Grid)
        #     pconnection, # probability of the connection (according to the Maass 2002 equation)
        #     (W_n, U_ds, D_ds, F_ds), # parameters according to Maass2002
        #     Delay_trans, # parameters according to Maass2002
        #     connection_type

        # What is the order of these vectors below in relation to the synapses connections????
        # THESE VECTORS SEEM TO FOLLOW THE SAME ORDER AS THE CREATION OF THE SYNAPSES
        # BUT I COULDN'T FIND ANY OFFICIAL INFORMATION ABOUT THAT
        # => NEED TO BE CHECKED BETTER IN THE BRIAN SIMULATOR SOURCE CODE!!!
        self.syn_lsm.taud = numpy.array(self.taud_syn) * brian.ms
        self.syn_lsm.tauf = numpy.array(self.tauf_syn) * brian.ms
        self.syn_lsm.U = numpy.array(self.U_syn)
        self.syn_lsm.w = numpy.array(self.w_syn) * brian.nA
        self.syn_lsm.delay = numpy.array(self.d_syn) * brian.ms

        self.syn_lsm.u = numpy.array(
            self.U_syn)  # Considering u<=U at the initialization

        self.syn_lsm.x = 1  # In Joshi thesis he uses u1=U and x1=1 (x1 is the R1 in his thesis)

        # from: http://www.scholarpedia.org/article/Short-term_synaptic_plasticity
        # In the model proposed by Tsodyks and Markram (Tsodyks 98), the STD effect is
        # modeled by a normalized variable x (0≤x≤1), denoting the fraction of resources
        # that remain available after neurotransmitter depletion. The STF effect is modeled
        # by a utilization parameter u, representing the fraction of available resources ready
        # for use (release probability). Following a spike, (i) u increases due to spike-induced
        # calcium influx to the presynaptic terminal, after which (ii) a fraction u of available
        # resources is consumed to produce the post-synaptic current. Between spikes, u decays
        # back to zero with time constant τf and x recovers to 1 with time constant τd.
        #
        # In general, an STD-dominated synapse favors information transfer for low firing rates,
        # since high-frequency spikes rapidly deactivate the synapse
        #
        # Since STP has a much longer time scale than that of single neuron dynamics (the latter is typically
        # in the time order of 10−20 milliseconds), a new feature STP can bring to the network dynamics is
        # prolongation of neural responses to a transient input.
        #
        # The interplay between the dynamics of u and x determines whether the joint effect of ux is dominated by
        # depression or facilitation. In the parameter regime of τd≫τf and large U, an initial spike incurs a large
        # drop in x that takes a long time to recover; therefore the synapse is STD-dominated (Fig.1B).
        # In the regime of τf≫τd and small U, the synaptic efficacy is increased gradually by spikes, and consequently
        # the synapse is STF-dominated (Fig.1C). This phenomenological model successfully reproduces the kinetic
        # dynamics of depressed and facilitated synapses observed in many cortical areas.

        return self.syn_lsm
Exemplo n.º 4
0
def fft_std(delta_u, run_num, new_connectivity, osc, rep):
    #bn.seed(int(time.time()))
    bn.reinit_default_clock()
    #bn.seed(1412958308+2)
    bn.defaultclock.dt = 0.5 * bn.ms

    #==============================================================================
    # Define constants for the model.
    #==============================================================================
    fft_file = './std_fft_p20_'
    rate_file = './std_rate_p20_'
    print delta_u
    print run_num
    print new_connectivity
    print rep

    if osc:
        T = 5.5 * bn.second
    else:
        T = 2.5 * bn.second
    n_tsteps = T / bn.defaultclock.dt
    fft_start = 0.5 * bn.second / bn.defaultclock.dt  # Time window for the FFT computation
    ro = 1.2 * bn.Hz

    SEE1 = 1.0
    SEE2 = 1.0
    qee1 = 1.00  # Fraction of NMDA receptors for e to e connections
    qee2 = 0.00
    qie1 = 1.00  # Fraction of NMDA receptors for e to i connections
    qie2 = 0.00

    uee1 = 0.2 - delta_u
    uee2 = 0.2 + delta_u
    uie1 = 0.2
    uie2 = 0.2
    trec1 = 1000.0 * bn.ms
    trec2 = 1000.0 * bn.ms

    k = 0.65
    #Jeo_const = 1.0#*bn.mV # Base strength of o (external) to e connections

    Ne = 3200  # number of excitatory neurons
    Ni = 800  # number of inhibitory neurons
    No = 20000  # number of external neurons
    N = Ne + Ni

    pcon = 0.2  # probability of connection

    Jee = 10.0 / (Ne * pcon)
    Jie = 10.0 / (Ne * pcon)
    Jii = k * 10.0 / (Ni * pcon)
    Jei = k * 10.0 / (Ni * pcon)
    Jeo = 1.0

    El = -60.0 * bn.mV  # leak reversal potential
    Vreset = -52.0 * bn.mV  # reversal potential
    Vthresh = -40.0 * bn.mV  # spiking threshold

    tref = 2.0 * bn.ms  # refractory period
    te = 20.0 * bn.ms  # membrane time constant of excitatory neurons
    ti = 10.0 * bn.ms  # membrane time constant of inhibitory neruons
    tee_ampa = 10.0 * bn.ms  # time const of ampa currents at excitatory neurons
    tee_nmda = 100.0 * bn.ms  # time const of nmda currents at excitatory neurons
    tie_ampa = 10.0 * bn.ms  # time const of ampa currents at inhibitory neurons
    tie_nmda = 100.0 * bn.ms  # time const of nmda currents at inhibitory neurons
    tii_gaba = 10.0 * bn.ms  # time const of GABA currents at inhibitory neurons
    tei_gaba = 10.0 * bn.ms  # time const of GABA currents at excitatory neurons
    teo_input = 100.0 * bn.ms

    #==============================================================================
    # Define model structure
    #==============================================================================

    model = '''
  dV/dt = (-(V-El)+J_ampa1*I_ampa1+J_nmda1*I_nmda1+J_ampa2*I_ampa2+J_nmda2*I_nmda2-J_gaba*I_gaba+J_input*I_input+eta)/tm : bn.volt
  dI_ampa1/dt = -I_ampa1/t_ampa : bn.volt
  dI_nmda1/dt = -I_nmda1/t_nmda : bn.volt
  dI_ampa2/dt = -I_ampa2/t_ampa : bn.volt
  dI_nmda2/dt = -I_nmda2/t_nmda : bn.volt
  dI_gaba/dt = -I_gaba/t_gaba : bn.volt
  dI_input/dt = (-I_input+mu)/t_input : bn.volt
  dx1/dt = (1-x1)/t1_rec : 1
  dx2/dt = (1-x2)/t2_rec : 1
  u1 : 1
  t1_rec : bn.second
  u2 : 1
  t2_rec : bn.second
  mu : bn.volt
  eta : bn.volt
  J_ampa1 : 1
  J_nmda1 : 1
  J_ampa2 : 1
  J_nmda2 : 1
  J_gaba : 1
  J_input : 1
  tm : bn.second
  t_ampa : bn.second
  t_nmda : bn.second
  t_gaba : bn.second
  t_input : bn.second
  '''

    P_reset = "V=-52*bn.mV;x1+=-u1*x1;x2+=-u2*x2"

    Se_model = '''
  we_ampa1 : bn.volt
  we_nmda1 : bn.volt
  we_ampa2 : bn.volt
  we_nmda2 : bn.volt
  '''

    Se_pre = ('I_ampa1 += x1_pre*we_ampa1', 'I_nmda1 += x1_pre*we_nmda1',
              'I_ampa2 += x2_pre*we_ampa2', 'I_nmda2 += x2_pre*we_nmda2')

    Si_model = '''
  wi_gaba : bn.volt
  '''

    Si_pre = 'I_gaba += wi_gaba'

    So_model = '''
  wo_input : bn.volt
  '''

    So_pre = 'I_input += wo_input'

    #==============================================================================
    # Define populations
    #==============================================================================

    P = bn.NeuronGroup(N,
                       model,
                       threshold=Vthresh,
                       reset=P_reset,
                       refractory=tref)

    Pe = P[0:Ne]
    Pe.tm = te
    Pe.t_ampa = tee_ampa
    Pe.t_nmda = tee_nmda
    Pe.t_gaba = tei_gaba
    Pe.t_input = teo_input
    Pe.I_ampa1 = 0 * bn.mV
    Pe.I_nmda1 = 0 * bn.mV
    Pe.I_ampa2 = 0 * bn.mV
    Pe.I_nmda2 = 0 * bn.mV
    Pe.I_gaba = 0 * bn.mV
    Pe.I_input = 0 * bn.mV
    Pe.V = (np.random.rand(Pe.V.size) * 12 - 52) * bn.mV

    Pe.x1 = 1.0
    Pe.x2 = 1.0
    Pe.u1 = uee1
    Pe.u2 = uee2
    Pe.t1_rec = trec1
    Pe.t2_rec = trec2

    Pi = P[Ne:(Ne + Ni)]
    Pi.tm = ti
    Pi.t_ampa = tie_ampa
    Pi.t_nmda = tie_nmda
    Pi.t_gaba = tii_gaba
    Pi.t_input = teo_input
    Pi.I_ampa1 = 0 * bn.mV
    Pi.I_nmda1 = 0 * bn.mV
    Pi.I_ampa2 = 0 * bn.mV
    Pi.I_nmda2 = 0 * bn.mV
    Pi.I_gaba = 0 * bn.mV
    Pi.I_input = 0 * bn.mV
    Pi.V = (np.random.rand(Pi.V.size) * 12 - 52) * bn.mV

    Pi.x1 = 1.0
    Pi.x2 = 1.0
    Pi.u1 = 0.0
    Pi.u2 = 0.0
    Pi.t1_rec = 1.0
    Pi.t2_rec = 1.0

    Pe.J_ampa1 = Jee * (1 - qee1)  #*SEE1
    Pe.J_nmda1 = Jee * qee1  #*SEE1
    Pe.J_ampa2 = Jee * (1 - qee2)  #*SEE2
    Pe.J_nmda2 = Jee * qee2  #*SEE2

    Pi.J_ampa1 = Jie * (1 - qie2)  #*SEE2
    Pi.J_nmda1 = Jie * qie2  #*SEE2
    Pi.J_ampa2 = Jie * (1 - qie1)  #*SEE1
    Pi.J_nmda2 = Jie * qie1  #*SEE1

    Pe.J_gaba = Jei
    Pi.J_gaba = Jii

    Pe.J_input = Jeo
    Pi.J_input = Jeo

    #==============================================================================
    # Define inputs
    #==============================================================================

    if osc:
        Pe.mu = 12.0 * bn.mV
        holder = np.zeros((n_tsteps, ))
        t_freq = np.linspace(0, 10, n_tsteps)

        fo = 0.2  # Smallest frequency in the signal
        fe = 10.0  # Largest frequency in the signal
        F = int(fe / 0.2)
        for m in range(1, F + 1):
            holder = holder + np.cos(2 * np.pi * m * fo * t_freq - m *
                                     (m - 1) * np.pi / F)
        holder = holder / np.max(holder)
        Pe.eta = bn.TimedArray(0.0 * bn.mV * holder)  #, dt=0.5*bn.ms)

        Background_eo = bn.PoissonInput(Pe,
                                        N=1000,
                                        rate=1.05 * bn.Hz,
                                        weight=0.2 * bn.mV,
                                        state='I_input')
        Background_io = bn.PoissonInput(Pi,
                                        N=1000,
                                        rate=1.0 * bn.Hz,
                                        weight=0.2 * bn.mV,
                                        state='I_input')

        Pi.mu = 0 * bn.mV
        Pi.eta = 0 * bn.mV  #, dt=0.5*bn.ms)

        Po = bn.PoissonGroup(No, rates=0 * bn.Hz)
    else:

        Background_eo = bn.PoissonInput(Pe,
                                        N=1000,
                                        rate=1.05 * bn.Hz,
                                        weight=0.2 * bn.mV,
                                        state='I_input')
        Background_io = bn.PoissonInput(Pi,
                                        N=1000,
                                        rate=1.0 * bn.Hz,
                                        weight=0.2 * bn.mV,
                                        state='I_input')
        holder_pe = np.zeros((n_tsteps, ))
        time_steps = np.linspace(0, T / bn.second, n_tsteps)
        holder_pe[time_steps < 0.5] = 0.0 * bn.mV
        holder_pe[time_steps >= 0.5] = 6.0 * bn.mV  #25
        holder_pe[time_steps > 1.5] = 0.0 * bn.mV  #25
        Pe.mu = bn.TimedArray(holder_pe)

        def firing_function(t, ro):
            if t > 0.5 * bn.second and t < 3.5 * bn.second:
                return 0.0 * bn.Hz
            else:
                return 0.0 * bn.Hz

        Pe.eta = 0 * bn.mV  #, dt=0.5*bn.ms)
        Pi.mu = 0.0 * bn.mV
        Pi.eta = 0 * bn.mV  #, dt=0.5*bn.ms)

        Po = bn.PoissonGroup(No, rates=lambda t: firing_function(t, ro))

    #==============================================================================
    # Define synapses
    #==============================================================================

    See1 = bn.Synapses(Pe, Pe, model=Se_model, pre=Se_pre)
    See2 = bn.Synapses(Pe, Pe, model=Se_model, pre=Se_pre)
    Sie1 = bn.Synapses(Pe, Pi, model=Se_model, pre=Se_pre)
    Sie2 = bn.Synapses(Pe, Pi, model=Se_model, pre=Se_pre)

    Sei = bn.Synapses(Pi, Pe, model=Si_model, pre=Si_pre)
    Sii = bn.Synapses(Pi, Pi, model=Si_model, pre=Si_pre)

    Seo = bn.Synapses(Po, Pe, model=So_model, pre=So_pre)

    #==============================================================================
    # Define random connections
    #==============================================================================

    if new_connectivity:
        See1.connect_random(Pe, Pe, sparseness=pcon / 2.0)
        See2.connect_random(Pe, Pe, sparseness=pcon / 2.0)
        Sie1.connect_random(Pe, Pi, sparseness=pcon / 2.0)
        Sie2.connect_random(Pe, Pi, sparseness=pcon / 2.0)
        Sii.connect_random(Pi, Pi, sparseness=pcon)
        Sei.connect_random(Pi, Pe, sparseness=pcon)
        Seo.connect_random(Po, Pe, sparseness=pcon)

        print 'Saving'
        See1.save_connectivity('./See1_connections_std_saver_p20_' +
                               str(run_num))
        See2.save_connectivity('./See2_connections_std_saver_p20_' +
                               str(run_num))
        Sie1.save_connectivity('./Sie1_connections_std_saver_p20_' +
                               str(run_num))
        Sie2.save_connectivity('./Sie2_connections_std_saver_p20_' +
                               str(run_num))
        Sii.save_connectivity('./Sii_connections_std_saver_p20_' +
                              str(run_num))
        Sei.save_connectivity('./Sei_connections_std_saver_p20_' +
                              str(run_num))
        Seo.save_connectivity('./Seo_connections_std_saver_p20_' +
                              str(run_num))
    else:
        print 'Loading'
        See1.load_connectivity('./See1_connections_std_saver_p20_' +
                               str(run_num))
        See2.load_connectivity('./See2_connections_std_saver_p20_' +
                               str(run_num))
        Sie1.load_connectivity('./Sie1_connections_std_saver_p20_' +
                               str(run_num))
        Sie2.load_connectivity('./Sie2_connections_std_saver_p20_' +
                               str(run_num))
        Sii.load_connectivity('./Sii_connections_std_saver_p20_' +
                              str(run_num))
        Sei.load_connectivity('./Sei_connections_std_saver_p20_' +
                              str(run_num))
        Seo.load_connectivity('./Seo_connections_std_saver_p20_' +
                              str(run_num))

    See1.we_ampa1 = SEE1 * 1.0 * bn.mV / tee_ampa
    See1.we_nmda1 = SEE1 * 1.0 * bn.mV / tee_nmda
    See1.we_ampa2 = 0.0 * bn.mV / tee_ampa
    See1.we_nmda2 = 0.0 * bn.mV / tee_nmda

    See2.we_ampa1 = 0.0 * bn.mV / tee_ampa
    See2.we_nmda1 = 0.0 * bn.mV / tee_nmda
    See2.we_ampa2 = SEE2 * 1.0 * bn.mV / tee_ampa
    See2.we_nmda2 = SEE2 * 1.0 * bn.mV / tee_nmda

    Sie1.we_ampa1 = 0.0 * bn.mV / tie_ampa
    Sie1.we_nmda1 = 0.0 * bn.mV / tie_nmda
    Sie1.we_ampa2 = SEE1 * 1.0 * bn.mV / tie_ampa
    Sie1.we_nmda2 = SEE1 * 1.0 * bn.mV / tie_nmda

    Sie2.we_ampa1 = SEE2 * 1.0 * bn.mV / tie_ampa
    Sie2.we_nmda1 = SEE2 * 1.0 * bn.mV / tie_nmda
    Sie2.we_ampa2 = 0.0 * bn.mV / tie_ampa
    Sie2.we_nmda2 = 0.0 * bn.mV / tie_nmda

    Sei.wi_gaba = 1.0 * bn.mV / tei_gaba
    Sii.wi_gaba = 1.0 * bn.mV / tii_gaba

    Seo.wo_input = 1.0 * bn.mV / teo_input

    #==============================================================================
    #  Define monitors
    #==============================================================================

    Pe_mon_V = bn.StateMonitor(Pe, 'V', timestep=10, record=True)
    Pe_mon_eta = bn.StateMonitor(Pe, 'eta', timestep=1, record=True)
    Pe_mon_ampa1 = bn.StateMonitor(Pe, 'I_ampa1', timestep=1, record=True)
    Pe_mon_nmda1 = bn.StateMonitor(Pe, 'I_nmda1', timestep=1, record=True)
    Pe_mon_ampa2 = bn.StateMonitor(Pe, 'I_ampa2', timestep=1, record=True)
    Pe_mon_nmda2 = bn.StateMonitor(Pe, 'I_nmda2', timestep=1, record=True)
    Pe_mon_gaba = bn.StateMonitor(Pe, 'I_gaba', timestep=1, record=True)
    Pe_mon_input = bn.StateMonitor(Pe, 'I_input', timestep=10, record=True)
    See1_mon_x = bn.StateMonitor(Pe, 'x1', timestep=10, record=True)
    See2_mon_x = bn.StateMonitor(Pe, 'x2', timestep=10, record=True)

    Pe_ratemon = bn.PopulationRateMonitor(Pe, bin=10.0 * bn.ms)
    Pi_ratemon = bn.PopulationRateMonitor(Pi, bin=10.0 * bn.ms)

    #==============================================================================
    # Run model
    #==============================================================================
    timer = 0 * bn.second
    t_start = time.time()
    bn.run(T, report='graphical')
    timer = timer + T
    print '-------------------------------------------------------'
    print 'Time is ' + str(timer) + ' seconds'
    t_end = time.time()
    print 'Time to compute last ' +str(T)+' seconds is: ' + \
          str(t_end - t_start) + ' seconds'
    print '-------------------------------------------------------\n'

    Pe_mon_ampa1_vals = Pe.J_ampa1[0] * np.mean(Pe_mon_ampa1.values.T, axis=1)
    Pe_mon_nmda1_vals = Pe.J_nmda1[0] * np.mean(Pe_mon_nmda1.values.T, axis=1)
    Pe_mon_ampa2_vals = Pe.J_ampa2[0] * np.mean(Pe_mon_ampa2.values.T, axis=1)
    Pe_mon_nmda2_vals = Pe.J_nmda2[0] * np.mean(Pe_mon_nmda2.values.T, axis=1)
    Pe_mon_ampa_vals = Pe_mon_ampa1_vals + Pe_mon_ampa2_vals
    Pe_mon_nmda_vals = Pe_mon_nmda1_vals + Pe_mon_nmda2_vals

    Pe_mon_gaba_vals = Pe.J_gaba[0] * np.mean(Pe_mon_gaba.values.T, axis=1)
    Pe_mon_input_vals = Pe.J_input[0] * np.mean(Pe_mon_input.values.T, axis=1)
    Pe_mon_V_vals = np.mean(Pe_mon_V.values.T, axis=1)

    Pe_mon_all_vals = Pe_mon_ampa_vals + Pe_mon_nmda_vals - Pe_mon_gaba_vals

    See1_mon_x_vals = np.mean(See1_mon_x.values.T, axis=1)
    See2_mon_x_vals = np.mean(See2_mon_x.values.T, axis=1)

    #==============================================================================
    # Save into a Matlab file
    #==============================================================================

    if osc:

        Pe_output = Pe.J_ampa1[0]*Pe_mon_ampa1.values+Pe.J_nmda1[0]*Pe_mon_nmda1.values + \
        Pe.J_ampa2[0]*Pe_mon_ampa2.values+Pe.J_nmda2[0]*Pe_mon_nmda2.values-Pe.J_gaba[0]*Pe_mon_gaba.values
        Pe_output = Pe_output[:, fft_start:, ]
        Pe_V = Pe_mon_V.values[:, fft_start:, ]
        Pe_glut = Pe.J_ampa1[0]*Pe_mon_ampa1.values+Pe.J_nmda1[0]*Pe_mon_nmda1.values + \
        Pe.J_ampa2[0]*Pe_mon_ampa2.values+Pe.J_nmda2[0]*Pe_mon_nmda2.values
        Pe_glut = Pe_glut[:, fft_start:, ]
        Pe_gaba = Pe.J_gaba[0] * Pe_mon_gaba.values
        Pe_gaba = Pe_gaba[:, fft_start:, ]

        Pe_input = Pe_mon_eta[:, fft_start:, ]
        T_step = bn.defaultclock.dt

        holder = {
            'Pe_output': Pe_output,
            'Pe_input': Pe_input,
            'Pe_V': Pe_V,
            'Pe_glut': Pe_glut,
            'Pe_gaba': Pe_gaba,
            'T_step': T_step
        }
        scipy.io.savemat(fft_file + 'delta_u' + str(delta_u) + '_' + str(rep),
                         mdict=holder)
    else:
        holder = {
            'Pe_rate': Pe_ratemon.rate,
            'Pe_time': Pe_ratemon.times,
            'uee1': uee1,
            'uee2': uee2,
            'uie1': uie1,
            'uie2': uie2
        }
        scipy.io.savemat(rate_file + 'delta_q_' + str(delta_u) + '_' +
                         str(run_num) + 'rep' + str(rep),
                         mdict=holder)
    bn.clear(erase=True, all=True)
Exemplo n.º 5
0
def excitatory_to_mso(mso_group,
                      ipsi_group=None,
                      contra_group=None,
                      strength=0,
                      num_e=6,
                      tau_e=.17e-3,
                      ipsi_delay=0,
                      contra_delay=0):
    """Connect excitatory neurons to MSO neurons.

    This establishes the excitatory connections to MSO neurons via
    biexponential synapses. num_i neurons from both the ipsi-lateral and
    contra-lateral group are connected to one MSO neuron. The neurons are
    picked randomly.

    Parameters
    ----------
    mso_group : brian.NeuronGroup
        The MSO neuron group
    ipsi_group : brian.NeuronGroup
        The ipsi-lateral neuron group. No group is connected if set to
        None. (default = None)
    contra_group : brian.NeuronGroup
        The contra-lateral neuron group. No group is connected if set to
        None. (default = None)
    strength : float
        The synaptic strength in Simens. (default=None)
    num_e : int
        The number of connections from the ipsi- and contra- lateral
        side to on neuron (default = 3)
    tau_e : int
        Time constant of the biexponential in seconds. (default = 0.17 ms)
    ipsi_delay : float
        Delay of all ipsi-lateral inputs in seconds (default = 0)
    contra_delay : float
        Delay of all contra-lateral inputs in seconds (default = 0)

    Returns
    -------
    A list containing the two brian synapse groups

    [ipsi_lateral, contra_lateral]
    """

    # All synaptic inputs are delayed by 1.5ms so that negative delays
    # are possible
    all_delay = 1.5e-3
    ipsi_delay += all_delay
    contra_delay += all_delay

    eqs = alpha_synapse(input='y', tau=tau_e * second, unit=1, output='gate')

    # Strength has to pe multiplied with e so that we gain correct
    # amplitudes!
    strength *= np.exp(1)

    # --> MSO (Excitatory)
    if ipsi_group:
        ipsi_synapse = br.Synapses(ipsi_group,
                                   mso_group, [eqs],
                                   pre='y += strength',
                                   freeze=True)
        mso_group.ex_syn_i = ipsi_synapse.gate

        # Randomly connect the Neurons
        s_list = range(len(ipsi_group))
        for i in range(len(mso_group)):
            for j in range(num_e):
                c = random.choice(s_list)
                ipsi_synapse[c, i] = True
        ipsi_synapse.delay[:] += ipsi_delay * second
    else:
        ipsi_synapse = None

    if contra_group:
        contra_synapse = br.Synapses(contra_group,
                                     mso_group, [eqs],
                                     pre='y += strength',
                                     freeze=True)
        mso_group.ex_syn_c = contra_synapse.gate

        # Randomly connect the Neurons
        s_list = range(len(contra_group))
        for i in range(len(mso_group)):
            for j in range(num_e):
                c = random.choice(s_list)
                contra_synapse[c, i] = True
        contra_synapse.delay[:] += contra_delay * second
    else:
        contra_synapse = None

    return [ipsi_synapse, contra_synapse]
Exemplo n.º 6
0
def inhibitory_to_mso(mso_group,
                      ipsi_group=None,
                      contra_group=None,
                      strength=0,
                      num_i=3,
                      tau_i1=0.14e-3,
                      tau_i2=1.6e-3,
                      ipsi_delay=0,
                      contra_delay=0):
    """Connect inhibitory neurons to MSO neurons.

    This establishes the inhibitory connections to MSO neurons via
    biexponential synapses. num_i neurons from both the ipsi-lateral and
    contra-lateral group are connected to one MSO neuron. The neurons are
    picked randomly.

    Parameters
    ----------
    mso_group : brian.NeuronGroup
        The MSO neuron group
    ipsi_group : brian.NeuronGroup
        The ipsi-lateral neuron group. No group is connected if set to
        None. (default = None)
    contra_group : brian.NeuronGroup
        The contra-lateral neuron group. No group is connected if set to
        None. (default = None)
    strength : float
        The synaptic strength in Simens. (default=None)
    num_i : int
        The number of connections from the ipsi- and contra- lateral
        side to on neuron (default = 3)
    tau_i1 : float
        First time constant of the biexponential in seconds
        (default = 0.14 ms)
    tau_i2 : float
        Second time constant in seconds of the biexpontential
        (default = 1.6 ms)
    ipsi_delay : float
        Delay of all ipsi-lateral inputs in seconds (default = 0)
    contra_delay : float
        Delay of all contra-lateral inputs in seconds (default = 0)

    Returns
    -------
    A list containing the two brian synapse groups

    [ipsi_lateral, contra_lateral]
    """

    # All synaptic inputs are delayed by 1.5ms so that negative delays
    # are possible
    all_delay = 1.5e-3
    ipsi_delay += all_delay
    contra_delay += all_delay

    eqs = biexp_synapse(input='y',
                        tau1=tau_i1 * second,
                        tau2=tau_i2 * second,
                        unit=1,
                        output='gate')

    if ipsi_group:
        ipsi_synapse = br.Synapses(ipsi_group,
                                   mso_group, [eqs],
                                   pre='y += strength',
                                   freeze=True)
        mso_group.in_syn_i = ipsi_synapse.gate

        # Randomly connect the Neurons
        s_list = range(len(ipsi_group))
        for i in range(len(mso_group)):
            for j in range(num_i):
                c = random.choice(s_list)
                ipsi_synapse[c, i] = True
        # Set the delay for all synapses
        ipsi_synapse.delay[:] += ipsi_delay * second
    else:
        ipsi_synapse = None

    if contra_group:
        contra_synapse = br.Synapses(contra_group,
                                     mso_group, [eqs],
                                     pre='y += strength',
                                     freeze=True)
        mso_group.in_syn_c = contra_synapse.gate

        # Randomly connect the Neurons
        s_list = range(len(contra_group))
        for i in range(len(mso_group)):
            for j in range(num_i):
                c = random.choice(s_list)
                contra_synapse[c, i] = True
        contra_synapse.delay[:] += contra_delay * second
    else:
        contra_synapse = None

    return [ipsi_synapse, contra_synapse]
Exemplo n.º 7
0
g = 2

liquid_neurons = br.NeuronGroup(N_liquid[0],
                                model=eqs_hidden_neurons,
                                refractory=2 * br.ms,
                                reset=reset)
liquid_inputs = liquid_neurons.subgroup(N_liquid[1])
liquid_hidden = liquid_neurons.subgroup(N_liquid[0] - N_liquid[1] -
                                        N_liquid[2])
liquid_output = liquid_neurons.subgroup(N_liquid[2])

spikes = []
hidden_neurons = []  # * len(N_hidden)
input_neurons = br.SpikeGeneratorGroup(N_in + 1, spikes)

Sin = br.Synapses(input_neurons, liquid_inputs, model='w:1', pre='ge+=w')
Sliq = br.Synapses(liquid_neurons, liquid_neurons, model='w:1', pre='ge+=w')

for i in range(len(N_hidden)):
    hidden_neurons.append(
        br.NeuronGroup(N_hidden[i],
                       model=eqs_hidden_neurons,
                       threshold=vt,
                       refractory=2 * br.ms,
                       reset=reset))

output_neurons = br.NeuronGroup(N_out,
                                model=eqs_hidden_neurons,
                                threshold=vt,
                                refractory=2 * br.ms,
                                reset=reset)
def fft_nostd(qee, run_num, new_connectivity, osc, rep):

    #bn.seed(int(time.time()))
    #  bn.seed(1412958308+2)
    bn.reinit_default_clock()
    bn.defaultclock.dt = 0.5 * bn.ms

    #==============================================================================
    # Define constants for the model.
    #==============================================================================
    fft_file = './nostd_fft_p20_'
    rate_file = './nostd_rate_p20_'

    if osc:
        T = 8.0 * bn.second
    else:
        T = 3.5 * bn.second
    n_tsteps = T / bn.defaultclock.dt
    fft_start = 3.0 * bn.second / bn.defaultclock.dt  # Time window for the FFT computation
    #run_num = 10
    ro = 1.2 * bn.Hz
    #==============================================================================
    #   Need to do all others besides 0.2 and 0.5
    #==============================================================================
    print qee
    print run_num
    print new_connectivity
    print rep
    qie = 0.3  # Fraction of NMDA receptors for e to i connections

    k = 0.65
    Jeo_const = 1.0  #*bn.mV # Base strength of o (external) to e connections

    Ne = 3200  # number of excitatory neurons
    Ni = 800  # number of inhibitory neurons
    No = 2000  # number of external neurons
    N = Ne + Ni

    pcon = 0.2  # probability of connection

    Jee = 5.0 / (Ne * pcon)
    Jie = 5.0 / (Ne * pcon)
    Jii = k * 5.0 / (Ni * pcon)
    Jei = k * 5.0 / (Ni * pcon)
    Jeo = 1.0

    El = -60.0 * bn.mV  # leak reversal potential
    Vreset = -52.0 * bn.mV  # reversal potential
    Vthresh = -40.0 * bn.mV  # spiking threshold

    tref = 2.0 * bn.ms  # refractory period
    te = 20.0 * bn.ms  # membrane time constant of excitatory neurons
    ti = 10.0 * bn.ms  # membrane time constant of inhibitory neruons
    tee_ampa = 10.0 * bn.ms  # time const of ampa currents at excitatory neurons
    tee_nmda = 100.0 * bn.ms  # time const of nmda currents at excitatory neurons
    tie_ampa = 10.0 * bn.ms  # time const of ampa currents at inhibitory neurons
    tie_nmda = 100.0 * bn.ms  # time const of nmda currents at inhibitory neurons
    tii_gaba = 10.0 * bn.ms  # time const of GABA currents at inhibitory neurons
    tei_gaba = 10.0 * bn.ms  # time const of GABA currents at excitatory neurons
    teo_input = 100.0 * bn.ms

    #==============================================================================
    # Define model structure
    #==============================================================================

    model = '''
  dV/dt = (-(V-El)+J_ampa*I_ampa+J_nmda*I_nmda-J_gaba*I_gaba+J_input*I_input+eta+eta_corr)/tm : bn.volt
  dI_ampa/dt = -I_ampa/t_ampa : bn.volt
  dI_nmda/dt = -I_nmda/t_nmda : bn.volt
  dI_gaba/dt = -I_gaba/t_gaba : bn.volt
  dI_input/dt = (-I_input+mu)/t_input : bn.volt
  J_ampa : 1
  J_nmda : 1
  J_gaba : 1
  J_input : 1
  mu : bn.volt
  eta : bn.volt
  eta_corr : bn.volt
  tm : bn.second
  t_ampa : bn.second
  t_nmda : bn.second
  t_gaba : bn.second
  t_input : bn.second
  '''

    P_reset = "V=-52*bn.mV"

    Se_model = '''
  we_ampa : bn.volt
  we_nmda : bn.volt
  '''

    Se_pre = ('I_ampa += we_ampa', 'I_nmda += we_nmda')

    Si_model = '''
  wi_gaba : bn.volt
  '''

    Si_pre = 'I_gaba += wi_gaba'

    So_model = '''
  wo_input : bn.volt
  '''

    So_pre = 'I_input += wo_input'

    #==============================================================================
    # Define populations
    #==============================================================================

    P = bn.NeuronGroup(N,
                       model,
                       threshold=Vthresh,
                       reset=P_reset,
                       refractory=tref)

    Pe = P[0:Ne]
    Pe.tm = te
    Pe.t_ampa = tee_ampa
    Pe.t_nmda = tee_nmda
    Pe.t_gaba = tei_gaba
    Pe.t_input = teo_input
    Pe.I_ampa = 0 * bn.mV
    Pe.I_nmda = 0 * bn.mV
    Pe.I_gaba = 0 * bn.mV
    Pe.I_input = 0 * bn.mV
    Pe.V = (np.random.rand(Pe.V.size) * 12 - 52) * bn.mV

    Pi = P[Ne:(Ne + Ni)]
    Pi.tm = ti
    Pi.t_ampa = tie_ampa
    Pi.t_nmda = tie_nmda
    Pi.t_gaba = tii_gaba
    Pi.t_input = teo_input
    Pi.I_ampa = 0 * bn.mV
    Pi.I_nmda = 0 * bn.mV
    Pi.I_gaba = 0 * bn.mV
    Pi.I_input = 0 * bn.mV
    Pi.V = (np.random.rand(Pi.V.size) * 12 - 52) * bn.mV

    Pe.J_ampa = Jee * (1 - qee)  #*SEE1
    Pe.J_nmda = Jee * qee  #*SEE1

    Pi.J_ampa = Jie * (1 - qie)  #*SEE1
    Pi.J_nmda = Jie * qie  #*SEE1

    Pe.J_gaba = Jei
    Pi.J_gaba = Jii

    Pe.J_input = Jeo
    Pi.J_input = Jeo

    #==============================================================================
    # Define inputs
    #==============================================================================
    if osc:
        Pe.mu = 2.0 * bn.mV
        holder = np.zeros((n_tsteps, ))
        t_freq = np.linspace(0, 10, n_tsteps)

        fo = 0.2  # Smallest frequency in the signal
        fe = 10.0  # Largest frequency in the signal
        F = int(fe / 0.2)
        for m in range(1, F + 1):
            holder = holder + np.cos(2 * np.pi * m * fo * t_freq - m *
                                     (m - 1) * np.pi / F)
        holder = holder / np.max(holder)
        Pe.eta = bn.TimedArray(0.0 * bn.mV * holder)  #, dt=0.5*bn.ms)
        Pe.eta_corr = 0 * bn.mV

        Background_eo = bn.PoissonInput(Pe,
                                        N=1000,
                                        rate=1.0 * bn.Hz,
                                        weight=0.2 * bn.mV,
                                        state='I_input')
        Background_io = bn.PoissonInput(Pi,
                                        N=1000,
                                        rate=1.05 * bn.Hz,
                                        weight=0.2 * bn.mV,
                                        state='I_input')

        Pi.mu = 0 * bn.mV
        Pi.eta = 0 * bn.mV  #, dt=0.5*bn.ms)
        Pi.eta_corr = 0 * bn.mV

        Po = bn.PoissonGroup(No, rates=0 * bn.Hz)

    else:
        Background_eo = bn.PoissonInput(Pe,
                                        N=1000,
                                        rate=1.0 * bn.Hz,
                                        weight=0.2 * bn.mV,
                                        state='I_input')
        Background_io = bn.PoissonInput(Pi,
                                        N=1000,
                                        rate=1.05 * bn.Hz,
                                        weight=0.2 * bn.mV,
                                        state='I_input')

        holder_pe = np.zeros((n_tsteps, ))
        time_steps = np.linspace(0, T / bn.second, n_tsteps)
        holder_pe[time_steps < 0.5] = 0.0 * bn.mV
        holder_pe[time_steps >= 0.5] = 3.0 * bn.mV  # 35.0/Jeo *bn.mV #25
        Pe.mu = bn.TimedArray(holder_pe)

        def firing_function(t, ro):
            if t > 0.5 * bn.second and t < 3.5 * bn.second:
                return 0.0 * bn.Hz
            else:
                return 0.0 * bn.Hz

#    Pe.mu = 0*bn.mV

        Pe.eta = 0 * bn.mV  #, dt=0.5*bn.ms)
        Pi.mu = 0.0 * bn.mV
        Pi.eta = 0 * bn.mV  #, dt=0.5*bn.ms)

        Po = bn.PoissonGroup(No, rates=lambda t: firing_function(t, ro))

#==============================================================================
# Define synapses
#==============================================================================

    See = bn.Synapses(Pe, Pe, model=Se_model, pre=Se_pre)
    Sie = bn.Synapses(Pe, Pi, model=Se_model, pre=Se_pre)

    Sei = bn.Synapses(Pi, Pe, model=Si_model, pre=Si_pre)
    Sii = bn.Synapses(Pi, Pi, model=Si_model, pre=Si_pre)

    Seo = bn.Synapses(Po, Pe, model=So_model, pre=So_pre)

    #==============================================================================
    #  Define monitors
    #==============================================================================

    Pe_mon_V = bn.StateMonitor(Pe, 'V', timestep=1, record=True)
    Pe_mon_eta = bn.StateMonitor(Pe, 'eta', timestep=1, record=True)
    Pe_mon_ampa = bn.StateMonitor(Pe, 'I_ampa', timestep=1, record=True)
    Pe_mon_nmda = bn.StateMonitor(Pe, 'I_nmda', timestep=1, record=True)
    Pe_mon_gaba = bn.StateMonitor(Pe, 'I_gaba', timestep=1, record=True)
    Pe_ratemon = bn.PopulationRateMonitor(Pe, bin=10.0 * bn.ms)

    #==============================================================================
    # Define random connections
    #==============================================================================

    if new_connectivity:
        See.connect_random(Pe, Pe, sparseness=pcon)
        Sie.connect_random(Pe, Pi, sparseness=pcon)
        Sii.connect_random(Pi, Pi, sparseness=pcon)
        Sei.connect_random(Pi, Pe, sparseness=pcon)
        Seo.connect_random(Po, Pe, sparseness=pcon)

        print 'Saving'
        See.save_connectivity('./See_connections_nostd_saver_p20' +
                              str(run_num))
        Sie.save_connectivity('./Sie_connections_nostd_saver_p20' +
                              str(run_num))
        Sii.save_connectivity('./Sii_connections_nostd_saver_p20' +
                              str(run_num))
        Sei.save_connectivity('./Sei_connections_nostd_saver_p20' +
                              str(run_num))
        Seo.save_connectivity('./Seo_connections_nostd_saver_p20' +
                              str(run_num))

    else:
        print 'Loading'
        See.load_connectivity('./See_connections_nostd_saver_p20' +
                              str(run_num))
        Sie.load_connectivity('./Sie_connections_nostd_saver_p20' +
                              str(run_num))
        Sii.load_connectivity('./Sii_connections_nostd_saver_p20' +
                              str(run_num))
        Sei.load_connectivity('./Sei_connections_nostd_saver_p20' +
                              str(run_num))
        Seo.load_connectivity('./Seo_connections_nostd_saver_p20' +
                              str(run_num))

    See.we_ampa = 1.0 * bn.mV / tee_ampa
    See.we_nmda = 1.0 * bn.mV / tee_nmda

    Sie.we_ampa = 1.0 * bn.mV / tie_ampa
    Sie.we_nmda = 1.0 * bn.mV / tie_nmda

    Sei.wi_gaba = 1.0 * bn.mV / tei_gaba
    Sii.wi_gaba = 1.0 * bn.mV / tii_gaba

    Seo.wo_input = 1.0 * bn.mV / teo_input

    #==============================================================================
    # Run model
    #==============================================================================

    timer = 0 * bn.second
    t_start = time.time()
    bn.run(T, report='graphical')
    timer = timer + T
    print '-------------------------------------------------------'
    print 'Time is ' + str(timer) + ' seconds'
    t_end = time.time()
    print 'Time to compute last ' +str(T)+' seconds is: ' + \
          str(t_end - t_start) + ' seconds'
    print '-------------------------------------------------------\n'

    #==============================================================================
    # Save into a Matlab file
    #==============================================================================

    if osc:
        Pe_output = Pe.J_ampa[0] * Pe_mon_ampa.values + Pe.J_nmda[
            0] * Pe_mon_nmda.values - Pe.J_gaba[0] * Pe_mon_gaba.values
        Pe_output = Pe_output[:, fft_start:, ]
        Pe_glut = Pe.J_ampa[0] * Pe_mon_ampa.values + Pe.J_nmda[
            0] * Pe_mon_nmda.values
        Pe_glut = Pe_glut[:, fft_start:, ]
        Pe_gaba = Pe.J_gaba[0] * Pe_mon_gaba.values[:, fft_start:, ]

        Pe_V = Pe_mon_V.values[:, fft_start:, ]
        Pe_input = Pe_mon_eta[:, fft_start:, ]
        T_step = bn.defaultclock.dt

        holder = {
            'Pe_output': Pe_output,
            'Pe_input': Pe_input,
            'Pe_V': Pe_V,
            'Pe_glut': Pe_glut,
            'Pe_gaba': Pe_gaba,
            'T_step': T_step
        }
        scipy.io.savemat(fft_file + 'qee' + str(qee) + '_' + str(rep),
                         mdict=holder)

    else:
        holder = {'Pe_rate': Pe_ratemon.rate, 'Pe_time': Pe_ratemon.times}
        scipy.io.savemat(rate_file + 'qee_' + str(qee) + '_' + str(run_num) +
                         'rep' + str(rep),
                         mdict=holder)