当前位置: 首页>>代码示例>>Python>>正文


Python brian2.Synapses类代码示例

本文整理汇总了Python中brian2.Synapses的典型用法代码示例。如果您正苦于以下问题:Python Synapses类的具体用法?Python Synapses怎么用?Python Synapses使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Synapses类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_store_restore_magic

def test_store_restore_magic():
    source = NeuronGroup(10, '''dv/dt = rates : 1
                                rates : Hz''', threshold='v>1', reset='v=0')
    source.rates = 'i*100*Hz'
    target = NeuronGroup(10, 'v:1')
    synapses = Synapses(source, target, model='w:1', pre='v+=w', connect='i==j')
    synapses.w = 'i*1.0'
    synapses.delay = 'i*ms'
    state_mon = StateMonitor(target, 'v', record=True)
    spike_mon = SpikeMonitor(source)
    store()  # default time slot
    run(10*ms)
    store('second')
    run(10*ms)
    v_values = state_mon.v[:, :]
    spike_indices, spike_times = spike_mon.it_

    restore() # Go back to beginning
    assert magic_network.t == 0*ms
    run(20*ms)
    assert defaultclock.t == 20*ms
    assert_equal(v_values, state_mon.v[:, :])
    assert_equal(spike_indices, spike_mon.i[:])
    assert_equal(spike_times, spike_mon.t_[:])

    # Go back to middle
    restore('second')
    assert magic_network.t == 10*ms
    run(10*ms)
    assert defaultclock.t == 20*ms
    assert_equal(v_values, state_mon.v[:, :])
    assert_equal(spike_indices, spike_mon.i[:])
    assert_equal(spike_times, spike_mon.t_[:])
开发者ID:appusom,项目名称:brian2,代码行数:33,代码来源:test_network.py

示例2: run_network

def run_network(traj):
    """Runs brian network consisting of
        200 inhibitory IF neurons"""

    eqs = '''
    dv/dt=(v0-v)/(5*ms) : volt (unless refractory)
    v0 : volt
    '''
    group = NeuronGroup(100, model=eqs, threshold='v>10 * mV',
                        reset='v = 0*mV', refractory=5*ms)
    group.v0 = traj.par.v0
    group.v = np.random.rand(100) * 10.0 * mV

    syn = Synapses(group, group, on_pre='v-=1*mV')
    syn.connect('i != j', p=0.2)

    spike_monitor = SpikeMonitor(group, variables=['v'])
    voltage_monitor = StateMonitor(group, 'v', record=True)
    pop_monitor = PopulationRateMonitor(group, name='pop' + str(traj.v_idx))

    net = Network(group, syn, spike_monitor, voltage_monitor, pop_monitor)
    net.run(0.25*second, report='text')

    traj.f_add_result(Brian2MonitorResult, 'spikes',
                      spike_monitor)
    traj.f_add_result(Brian2MonitorResult, 'v',
                      voltage_monitor)
    traj.f_add_result(Brian2MonitorResult, 'pop',
                      pop_monitor)
开发者ID:SmokinCaterpillar,项目名称:pypet,代码行数:29,代码来源:another_network_test.py

示例3: test_magic_collect

def test_magic_collect():
    '''
    Make sure all expected objects are collected in a magic network
    '''
    P = PoissonGroup(10, rates=100*Hz)
    G = NeuronGroup(10, 'v:1')
    S = Synapses(G, G, '')
    G_runner = G.custom_operation('')
    S_runner = S.custom_operation('')

    state_mon = StateMonitor(G, 'v', record=True)
    spike_mon = SpikeMonitor(G)
    rate_mon = PopulationRateMonitor(G)

    objects = collect()

    assert len(objects) == 8, ('expected %d objects, got %d' % (8, len(objects)))
开发者ID:msGenDev,项目名称:brian2,代码行数:17,代码来源:test_network.py

示例4: do_synapse

    def do_synapse(self):

        # Maybe should import
        from brian2 import Synapses

        # Check
        if len(self.SynapsingDelayDict) > 0.0:

            # map
            map(lambda __ItemTuple: self.setDelay(*__ItemTuple), self.SynapsingDelayDict.items())

            # debug
        """
		self.debug(('self.',self,[
								'SynapsingBrianKwargDict'
								]))
		"""

        # init
        self.SynapsedBrianVariable = Synapses(**self.SynapsingBrianKwargDict)

        # connect
        if type(self.SynapsingProbabilityVariable) == float:

            # debug
            """
			self.debug('we connect with a sparsity of '+str(self.SynapsingProbabilityVariable))
			"""

            self.SynapsedBrianVariable.connect(True, p=self.SynapsingProbabilityVariable)

            # Check
        if self.SynapsingWeigthSymbolStr != "":

            # debug
            """
			self.debug(
				('self.',self,[
					'SynapsedBrianVariable',
					'SynapsingWeigthSymbolStr'
					])
			)
			"""

            # connect
            self.SynapsedBrianVariable.connect(True)

            # get
            self.SynapsedWeigthFloatsArray = getattr(self.SynapsedBrianVariable, self.SynapsingWeigthSymbolStr)

            # set
            self.SynapsedWeigthFloatsArray[:] = np.reshape(
                self.SynapsingWeigthFloatsArray,
                self.SynapsedBrianVariable.source.N * self.SynapsedBrianVariable.target.N,
            )

            # debug
            self.debug(("self.", self, ["SynapsedWeigthFloatsArray"]))
开发者ID:BinWang20140601,项目名称:ShareYourSystem,代码行数:58,代码来源:__init__.py

示例5: create_net

    def create_net():
        # Use a bit of a complicated spike and connection pattern with
        # heterogeneous delays

        # Note: it is important that all objects have the same name, this would
        # be the case if we were running this in a new process but to not rely
        # on garbage collection we will assign explicit names here
        source = SpikeGeneratorGroup(5, np.arange(5).repeat(3),
                                     [3, 4, 1, 2, 3, 7, 5, 4, 1, 0, 5, 9, 7, 8, 9]*ms,
                                     name='source')
        target = NeuronGroup(10, 'v:1', name='target')
        synapses = Synapses(source, target, model='w:1', pre='v+=w', connect='j>=i',
                            name='synapses')
        synapses.w = 'i*1.0 + j*2.0'
        synapses.delay = '(5-i)*ms'
        state_mon = StateMonitor(target, 'v', record=True, name='statemonitor')
        input_spikes = SpikeMonitor(source, name='input_spikes')
        net = Network(source, target, synapses, state_mon, input_spikes)
        return net
开发者ID:moritzaugustin,项目名称:brian2,代码行数:19,代码来源:test_network.py

示例6: SynapserClass

class SynapserClass(BaseClass):
    def default_init(
        self,
        _SynapsingBrianKwargDict=None,
        _SynapsingProbabilityVariable=None,
        _SynapsingTagStr="",
        _SynapsingWeigthSymbolStr="",
        _SynapsingWeigthFloatsArray=None,
        _SynapsingDelayDict=0.0,
        _SynapsedBrianVariable=None,
        _SynapsedWeigthFloatsArray=None,
        _SynapsedCustomOperationStr="",
        _SynapsedDelayStateStrsList="",
        **_KwargVariablesDict
    ):

        # init
        self.PostModelInsertStrsList = []
        self.PostModelAddDict = {}

        # Call the parent __init__ method
        BaseClass.__init__(self, **_KwargVariablesDict)

    def setDelay(self, _SymbolStr, _DelayVariable):

        # debug
        """
		self.debug(
			[
				"self.SynapsingBrianKwargDict['source'].clock is ",
				self.SynapsingBrianKwargDict['source'].clock
			]
		)
		"""

        # define
        if type(_DelayVariable).__name__ == "Quantity":

            # divide
            DelayEquationsInt = (int)(_DelayVariable / self.SynapsingBrianKwargDict["source"].clock.dt)

        else:

            # debug
            """
			self.debug(
				[
					"float of dt is ",
					float(
						self.SynapsingBrianKwargDict['source'].clock.dt
					)
				]
			)
			"""

            # divide and put that in ms...(rough)
            DelayEquationsInt = (int)(_DelayVariable * 0.001 / float(self.SynapsingBrianKwargDict["source"].clock.dt))

            # join
        self.SynapsedCustomOperationStr = "\n".join(
            map(
                lambda __EquationIndexInt: _SymbolStr
                + "_delayer_"
                + str(__EquationIndexInt)
                + "="
                + _SymbolStr
                + "_delayer_"
                + str(__EquationIndexInt - 1),
                xrange(DelayEquationsInt, 1, -1),
            )
            + [_SymbolStr + "delayer_1=" + _SymbolStr]
        )

        # debug
        self.debug(("self.", self, ["SynapsedCustomOperationStr"]))

        # custom
        self.SynapsingBrianKwargDict["source"].custom_operation(self.SynapsedCustomOperationStr)

        # join
        self.SynapsedDelayStateStrsListsList = map(
            lambda __EquationIndexInt: _SymbolStr + "_delayer_ : 1", xrange(DelayEquationsInt)
        )

        # debug
        self.debug(("self.", self, ["SynapsedDelayStateStrsList"]))

        # add in the PreModelInsertStrsList
        if hasattr(self, "AttentionUpdateVariable") == False:
            self.AttentionUpdateVariable = {"PreModelInsertStrsList": []}
        self.AttentionUpdateVariable["PreModelInsertStrsList"] += self.SynapsedDelayStateStrsListsList

    def do_synapse(self):

        # Maybe should import
        from brian2 import Synapses

        # Check
        if len(self.SynapsingDelayDict) > 0.0:

#.........这里部分代码省略.........
开发者ID:BinWang20140601,项目名称:ShareYourSystem,代码行数:101,代码来源:__init__.py

示例7: simulate_wm


#.........这里部分代码省略.........
    Jneg_excit2excit = (1. - Jpos_excit2excit * tmp) / (1. - tmp)
    presyn_weight_kernel = \
        [(Jneg_excit2excit +
          (Jpos_excit2excit - Jneg_excit2excit) *
          math.exp(-.5 * (360. * min(j, N_excitatory - j) / N_excitatory) ** 2 / sigma_weight_profile ** 2))
         for j in range(N_excitatory)]
    # validate the normalization condition: (360./N_excitatory)*sum(presyn_weight_kernel)/360.
    fft_presyn_weight_kernel = rfft(presyn_weight_kernel)
    weight_profile_45 = deque(presyn_weight_kernel)
    rot_dist = int(round(len(weight_profile_45) / 8))
    weight_profile_45.rotate(rot_dist)

    # define the inhibitory population
    inhib_lif_dynamics = """
        s_NMDA_total : 1  # the post synaptic sum of s. compare with s_NMDA_presyn
        dv/dt = (
        - G_leak_inhib * (v-E_leak_inhib)
        - G_extern2inhib * s_AMPA * (v-E_AMPA)
        - G_inhib2inhib * s_GABA * (v-E_GABA)
        - G_excit2inhib * s_NMDA_total * (v-E_NMDA)/(1.0+1.0*exp(-0.062*v/volt)/3.57)
        )/Cm_inhib : volt (unless refractory)
        ds_AMPA/dt = -s_AMPA/tau_AMPA : 1
        ds_GABA/dt = -s_GABA/tau_GABA : 1
    """

    inhib_pop = NeuronGroup(
        N_inhibitory, model=inhib_lif_dynamics,
        threshold="v>v_firing_threshold_inhib", reset="v=v_reset_inhib", refractory=t_abs_refract_inhib,
        method="rk2")
    # initialize with random voltages:
    inhib_pop.v = numpy.random.uniform(v_reset_inhib / b2.mV, high=v_firing_threshold_inhib / b2.mV,
                                       size=N_inhibitory) * b2.mV
    # set the connections: inhib2inhib
    syn_inhib2inhib = Synapses(inhib_pop, target=inhib_pop, on_pre="s_GABA += 1.0", delay=0.0 * b2.ms)
    syn_inhib2inhib.connect(condition="i!=j", p=1.0)
    # set the connections: extern2inhib
    input_ext2inhib = PoissonInput(target=inhib_pop, target_var="s_AMPA",
                                   N=N_extern_poisson, rate=poisson_firing_rate, weight=1.0)

    # specify the excitatory population:
    excit_lif_dynamics = """
        I_stim : amp
        s_NMDA_total : 1  # the post synaptic sum of s. compare with s_NMDA_presyn
        dv/dt = (
        - G_leak_excit * (v-E_leak_excit)
        - G_extern2excit * s_AMPA * (v-E_AMPA)
        - G_inhib2excit * s_GABA * (v-E_GABA)
        - G_excit2excit * s_NMDA_total * (v-E_NMDA)/(1.0+1.0*exp(-0.062*v/volt)/3.57)
        + I_stim
        )/Cm_excit : volt (unless refractory)
        ds_AMPA/dt = -s_AMPA/tau_AMPA : 1
        ds_GABA/dt = -s_GABA/tau_GABA : 1
        ds_NMDA/dt = -s_NMDA/tau_NMDA_s + alpha_NMDA * x * (1-s_NMDA) : 1
        dx/dt = -x/tau_NMDA_x : 1
    """

    excit_pop = NeuronGroup(N_excitatory, model=excit_lif_dynamics,
                            threshold="v>v_firing_threshold_excit", reset="v=v_reset_excit; x+=1.0",
                            refractory=t_abs_refract_excit, method="rk2")
    # initialize with random voltages:
    excit_pop.v = numpy.random.uniform(v_reset_excit / b2.mV, high=v_firing_threshold_excit / b2.mV,
                                       size=N_excitatory) * b2.mV
    excit_pop.I_stim = 0. * b2.namp
    # set the connections: extern2excit
    input_ext2excit = PoissonInput(target=excit_pop, target_var="s_AMPA",
                                   N=N_extern_poisson, rate=poisson_firing_rate, weight=1.0)
开发者ID:accssharma,项目名称:neuronaldynamics-exercises,代码行数:67,代码来源:wm_model.py

示例8: brianInteraction


#.........这里部分代码省略.........
			]
		)
		"""

        # Check
        if self.ConnectedToVariable.BrianedNeurongroupVariable == None:

            # parent brian
            self.ConnectedToVariable.parent().brian()

            # set
        BrianedNameStr = (
            self.BrianedParentPopulationDeriveBrianerVariable.StructureTagStr
            + "_To_"
            + self.ConnectedToVariable.StructureTagStr
        )

        # debug
        """
		self.debug(
			[
				'We set the synapses',
				'self.BrianedParentPopulationDeriveBrianerVariable.BrianedNeurongroupVariable is ',
				str(self.BrianedParentPopulationDeriveBrianerVariable.BrianedNeurongroupVariable),
				'self.ConnectedToVariable.BrianedNeurongroupVariable is ',
				str(self.ConnectedToVariable.BrianedNeurongroupVariable),
				'Maybe we have to make brian the post',
				'BrianedNameStr is '+BrianedNameStr
			]
		)
		"""

        # import
        from brian2 import Synapses

        # init
        self.BrianedSynapsesVariable = Synapses(
            source=self.BrianedParentPopulationDeriveBrianerVariable.BrianedNeurongroupVariable,
            target=self.ConnectedToVariable.BrianedNeurongroupVariable,
            # name=BrianedNameStr.replace('/','_'),
            **self.BrianingSynapsesDict
        )

        # /####################/#
        # Connect options
        #

        # connect
        if type(self.BrianingConnectVariable) == float:

            # debug
            """
			self.debug(
				[
					'we connect with a sparsity of ',
					('self.',self,[
						'BrianingConnectVariable'
					])
				]
			)
			"""

            # connect
            self.BrianedSynapsesVariable.connect(True, p=self.BrianingConnectVariable)

            # /####################/#
开发者ID:BinWang20140601,项目名称:ShareYourSystem,代码行数:67,代码来源:__init__+copy+7.py

示例9: brianInteraction


#.........这里部分代码省略.........
				('self.',self,['ConnectedToVariable'])
			]
		)

		#Check
		if self.ConnectedToVariable==None:

			#debug
			self.debug(
				[
					'We setConnection here'
				]
			)

			#setConnection
			self.setConnection(
				self.ManagementTagStr,
				self,
				self.BrianedParentNeurongroupDeriveBrianerVariable
			)

		#/####################/#
		# Set the BrianedParentNeurongroupDeriveBrianerVariable
		#

		#debug
		self.debug(
			[
				'Do we have to make parent-brian the connected variable ?',
				'self.ConnectedToVariable.BrianedNeurongroupVariable is ',
				str(self.ConnectedToVariable.BrianedNeurongroupVariable)
			]
		)

		#Check 
		if self.ConnectedToVariable.BrianedNeurongroupVariable==None:

			#parent brian
			self.ConnectedToVariable.parent(
				).brian(
				)

		#set
		BrianedNameStr=self.BrianedParentNeurongroupDeriveBrianerVariable.StructureTagStr+'_To_'+self.ConnectedToVariable.StructureTagStr

		#debug
		self.debug(
			[
				'We set the synapses',
				'self.BrianedParentNeurongroupDeriveBrianerVariable.BrianedNeurongroupVariable is ',
				str(self.BrianedParentNeurongroupDeriveBrianerVariable.BrianedNeurongroupVariable),
				'self.ConnectedToVariable.BrianedNeurongroupVariable is ',
				str(self.ConnectedToVariable.BrianedNeurongroupVariable),
				'Maybe we have to make brian the post',
				'BrianedNameStr is '+BrianedNameStr
			]
		)

		#import
		from brian2 import Synapses

		#init
		self.BrianedSynapsesVariable=Synapses(
			source=self.BrianedParentNeurongroupDeriveBrianerVariable.BrianedNeurongroupVariable,
			target=self.ConnectedToVariable.BrianedNeurongroupVariable,
			name=BrianedNameStr.replace('/','_'),
			**self.BrianingSynapsesDict
		)

		#/####################/#
		# Connect options
		#

		#connect
		if type(self.BrianingConnectVariable)==float:

			#debug
			self.debug(
				[
					'we connect with a sparsity of ',
					('self.',self,[
						'BrianingConnectVariable'
					])
				]
			)

			#connect
			self.BrianedSynapsesVariable.connect(
				True,
				p=self.BrianingConnectVariable
			)

		#/####################/#
		# add to the structure
		#

		#add
		self.BrianedParentNetworkDeriveBrianerVariable.BrianedNetworkVariable.add(
			self.BrianedSynapsesVariable
		)
开发者ID:BinWang20140601,项目名称:ShareYourSystem,代码行数:101,代码来源:__init__+copy+5.py

示例10: do_brian


#.........这里部分代码省略.........

			#debug
			self.debug(
				[
					'We make brian the Spikes'
				]
			)

			#Check
			if 'Events' in self.TeamDict:

				#map
				map(
					lambda __DeriveBrianer:
					__DeriveBrianer.brian(),
					self.TeamDict['Events'].ManagementDict.values()
				)

			#debug
			self.debug(
				[
					'We have made brian the spikes'
				]
			)
			"""

		elif self.ParentDeriveTeamerVariable.TeamTagStr=='Postlets':

			#debug
			self.debug(
				[
					'It is a Synapser level, we set the Synapser',
					('self.',self,[
								'BrianingSynapsesDict'
								]
					),
					'self.PointToVariable.BrianedNeurongroupVariable is ',
					str(self.PointToVariable.BrianedNeurongroupVariable)
				]
			)

			#/####################/#
			# Set the BrianedParentNeurongroupDeriveBrianerVariable
			#

			#get
			self.BrianedParentNeurongroupDeriveBrianerVariable=self.ParentDeriveTeamerVariable.ParentDeriveTeamerVariable

			#get
			self.BrianedParentNetworkDeriveBrianerVariable=self.BrianedParentNeurongroupDeriveBrianerVariable.BrianedParentNetworkDeriveBrianerVariable


			#/####################/#
			# Set the BrianedParentNeurongroupDeriveBrianerVariable
			#

			#import
			from brian2 import Synapses

			#init
			self.BrianedSynapsesVariable=Synapses(
				source=self.BrianedParentNeurongroupDeriveBrianerVariable.BrianedNeurongroupVariable,
				target=self.PointToVariable.BrianedNeurongroupVariable,
				**self.BrianingSynapsesDict
			)
开发者ID:BinWang20140601,项目名称:ShareYourSystem,代码行数:66,代码来源:__init__+copy+4.py

示例11: _build_connections

    def _build_connections(self, traj, brian_list, network_dict):
        """Connects neuron groups `neurons_i` and `neurons_e`.

        Adds all connections to `brian_list` and adds a list of connections
        with the key 'connections' to the `network_dict`.

        """

        connections = traj.connections

        neurons_i = network_dict['neurons_i']
        neurons_e = network_dict['neurons_e']

        print('Connecting ii')
        self.conn_ii = Synapses(neurons_i,neurons_i, on_pre='y_i += %f' % connections.J_ii)
        self.conn_ii.connect('i != j', p=connections.p_ii)

        print('Connecting ei')
        self.conn_ei = Synapses(neurons_i,neurons_e, on_pre='y_i += %f' % connections.J_ei)
        self.conn_ei.connect('i != j', p=connections.p_ei)

        print('Connecting ie')
        self.conn_ie = Synapses(neurons_e,neurons_i, on_pre='y_e += %f' % connections.J_ie)
        self.conn_ie.connect('i != j', p=connections.p_ie)

        conns_list = [self.conn_ii, self.conn_ei, self.conn_ie]


        if connections.R_ee > 1.0:
            # If we come here we want to create clusters

            cluster_list=[]
            cluster_conns_list=[]
            model=traj.model

            # Compute the number of clusters
            clusters = int(model.N_e/connections.clustersize_e)
            traj.f_add_derived_parameter('connections.clusters', clusters, comment='Number of clusters')

            # Compute outgoing connection probability
            p_out = (connections.p_ee*model.N_e) / \
                    (connections.R_ee*connections.clustersize_e+model.N_e- connections.clustersize_e)

            # Compute within cluster connection probability
            p_in = p_out * connections.R_ee

            # We keep these derived parameters
            traj.f_add_derived_parameter('connections.p_ee_in', p_in ,
                                         comment='Connection prob within cluster')
            traj.f_add_derived_parameter('connections.p_ee_out', p_out ,
                                         comment='Connection prob to outside of cluster')


            low_index = 0
            high_index = connections.clustersize_e
            # Iterate through cluster and connect within clusters and to the rest of the neurons
            for irun in range(clusters):

                cluster = neurons_e[low_index:high_index]

                # Connections within cluster
                print('Connecting ee cluster #%d of %d' % (irun, clusters))
                conn = Synapses(cluster,cluster,
                                on_pre='y_e += %f' % (connections.J_ee*connections.strength_factor))
                conn.connect('i != j', p=p_in)
                cluster_conns_list.append(conn)

                # Connections reaching out from cluster
                # A cluster consists of `clustersize_e` neurons with consecutive indices.
                # So usually the outside world consists of two groups, neurons with lower
                # indices than the cluster indices, and neurons with higher indices.
                # Only the clusters at the index boundaries project to neurons with only either
                # lower or higher indices
                if low_index > 0:
                    rest_low = neurons_e[0:low_index]
                    print('Connecting cluster with other neurons of lower index')
                    low_conn = Synapses(cluster,rest_low,
                                on_pre='y_e += %f' % connections.J_ee)
                    low_conn.connect('i != j', p=p_out)

                    cluster_conns_list.append(low_conn)

                if high_index < model.N_e:
                    rest_high = neurons_e[high_index:model.N_e]
                    print('Connecting cluster with other neurons of higher index')

                    high_conn = Synapses(cluster,rest_high,
                                on_pre='y_e += %f' % connections.J_ee)
                    high_conn.connect('i != j', p=p_out)

                    cluster_conns_list.append(high_conn)

                low_index=high_index
                high_index+=connections.clustersize_e

            self.cluster_conns=cluster_conns_list
            conns_list+=cluster_conns_list
        else:
            # Here we don't cluster and connection probabilities are homogeneous
            print('Connectiong ee')
#.........这里部分代码省略.........
开发者ID:SmokinCaterpillar,项目名称:pypet,代码行数:101,代码来源:clusternet.py

示例12: CNConnections


#.........这里部分代码省略.........
        :param network_dict:

            Dictionary of elements shared among the components

            Expects:

            'neurons_i': Inhibitory neuron group

            'neurons_e': Excitatory neuron group

            Adds:

            Connections, amount depends on clustering

        """
        if not hasattr(self, '_pre_build') or not self._pre_build:
            self._build_connections(traj, brian_list, network_dict)


    def _build_connections(self, traj, brian_list, network_dict):
        """Connects neuron groups `neurons_i` and `neurons_e`.

        Adds all connections to `brian_list` and adds a list of connections
        with the key 'connections' to the `network_dict`.

        """

        connections = traj.connections

        neurons_i = network_dict['neurons_i']
        neurons_e = network_dict['neurons_e']

        print('Connecting ii')
        self.conn_ii = Synapses(neurons_i,neurons_i, on_pre='y_i += %f' % connections.J_ii)
        self.conn_ii.connect('i != j', p=connections.p_ii)

        print('Connecting ei')
        self.conn_ei = Synapses(neurons_i,neurons_e, on_pre='y_i += %f' % connections.J_ei)
        self.conn_ei.connect('i != j', p=connections.p_ei)

        print('Connecting ie')
        self.conn_ie = Synapses(neurons_e,neurons_i, on_pre='y_e += %f' % connections.J_ie)
        self.conn_ie.connect('i != j', p=connections.p_ie)

        conns_list = [self.conn_ii, self.conn_ei, self.conn_ie]


        if connections.R_ee > 1.0:
            # If we come here we want to create clusters

            cluster_list=[]
            cluster_conns_list=[]
            model=traj.model

            # Compute the number of clusters
            clusters = int(model.N_e/connections.clustersize_e)
            traj.f_add_derived_parameter('connections.clusters', clusters, comment='Number of clusters')

            # Compute outgoing connection probability
            p_out = (connections.p_ee*model.N_e) / \
                    (connections.R_ee*connections.clustersize_e+model.N_e- connections.clustersize_e)

            # Compute within cluster connection probability
            p_in = p_out * connections.R_ee

            # We keep these derived parameters
开发者ID:SmokinCaterpillar,项目名称:pypet,代码行数:67,代码来源:clusternet.py

示例13: sim_decision_making_network


#.........这里部分代码省略.........

    # define the three excitatory subpopulations.
    # A: subpop receiving stimulus A
    excit_pop_A = NeuronGroup(N_Group_A, model=excit_lif_dynamics,
                              threshold="v>v_spike_thr_excit", reset="v=v_reset_excit",
                              refractory=t_abs_refract_excit, method="rk2")
    excit_pop_A.v = rnd.uniform(E_leak_excit / b2.mV, high=E_leak_excit / b2.mV + 5., size=excit_pop_A.N) * b2.mV

    # B: subpop receiving stimulus B
    excit_pop_B = NeuronGroup(N_Group_B, model=excit_lif_dynamics, threshold="v>v_spike_thr_excit",
                              reset="v=v_reset_excit", refractory=t_abs_refract_excit, method="rk2")
    excit_pop_B.v = rnd.uniform(E_leak_excit / b2.mV, high=E_leak_excit / b2.mV + 5., size=excit_pop_B.N) * b2.mV
    # Z: non-sensitive
    excit_pop_Z = NeuronGroup(N_Group_Z, model=excit_lif_dynamics,
                              threshold="v>v_spike_thr_excit", reset="v=v_reset_excit",
                              refractory=t_abs_refract_excit, method="rk2")
    excit_pop_Z.v = rnd.uniform(v_reset_excit / b2.mV, high=v_spike_thr_excit / b2.mV - 1., size=excit_pop_Z.N) * b2.mV

    # now define the connections:
    # projections FROM EXTERNAL POISSON GROUP: ####################################################
    poisson2Inhib = PoissonInput(target=inhib_pop, target_var="s_AMPA",
                                 N=N_extern, rate=firing_rate_extern, weight=w_ext2inhib)
    poisson2A = PoissonInput(target=excit_pop_A, target_var="s_AMPA",
                             N=N_extern, rate=firing_rate_extern, weight=w_ext2excit)

    poisson2B = PoissonInput(target=excit_pop_B, target_var="s_AMPA",
                             N=N_extern, rate=firing_rate_extern, weight=w_ext2excit)
    poisson2Z = PoissonInput(target=excit_pop_Z, target_var="s_AMPA",
                             N=N_extern, rate=firing_rate_extern, weight=w_ext2excit)

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

    # GABA projections FROM INHIBITORY population: ################################################
    syn_inhib2inhib = Synapses(inhib_pop, target=inhib_pop, on_pre="s_GABA += 1.0", delay=0.5 * b2.ms)
    syn_inhib2inhib.connect(p=1.)
    syn_inhib2A = Synapses(inhib_pop, target=excit_pop_A, on_pre="s_GABA += 1.0", delay=0.5 * b2.ms)
    syn_inhib2A.connect(p=1.)
    syn_inhib2B = Synapses(inhib_pop, target=excit_pop_B, on_pre="s_GABA += 1.0", delay=0.5 * b2.ms)
    syn_inhib2B.connect(p=1.)
    syn_inhib2Z = Synapses(inhib_pop, target=excit_pop_Z, on_pre="s_GABA += 1.0", delay=0.5 * b2.ms)
    syn_inhib2Z.connect(p=1.)
    ###############################################################################################

    # AMPA projections FROM EXCITATORY A: #########################################################
    syn_AMPA_A2A = Synapses(excit_pop_A, target=excit_pop_A, on_pre="s_AMPA += w_pos", delay=0.5 * b2.ms)
    syn_AMPA_A2A.connect(p=1.)
    syn_AMPA_A2B = Synapses(excit_pop_A, target=excit_pop_B, on_pre="s_AMPA += w_neg", delay=0.5 * b2.ms)
    syn_AMPA_A2B.connect(p=1.)
    syn_AMPA_A2Z = Synapses(excit_pop_A, target=excit_pop_Z, on_pre="s_AMPA += 1.0", delay=0.5 * b2.ms)
    syn_AMPA_A2Z.connect(p=1.)
    syn_AMPA_A2inhib = Synapses(excit_pop_A, target=inhib_pop, on_pre="s_AMPA += 1.0", delay=0.5 * b2.ms)
    syn_AMPA_A2inhib.connect(p=1.)
    ###############################################################################################

    # AMPA projections FROM EXCITATORY B: #########################################################
    syn_AMPA_B2A = Synapses(excit_pop_B, target=excit_pop_A, on_pre="s_AMPA += w_neg", delay=0.5 * b2.ms)
    syn_AMPA_B2A.connect(p=1.)
    syn_AMPA_B2B = Synapses(excit_pop_B, target=excit_pop_B, on_pre="s_AMPA += w_pos", delay=0.5 * b2.ms)
    syn_AMPA_B2B.connect(p=1.)
    syn_AMPA_B2Z = Synapses(excit_pop_B, target=excit_pop_Z, on_pre="s_AMPA += 1.0", delay=0.5 * b2.ms)
    syn_AMPA_B2Z.connect(p=1.)
    syn_AMPA_B2inhib = Synapses(excit_pop_B, target=inhib_pop, on_pre="s_AMPA += 1.0", delay=0.5 * b2.ms)
    syn_AMPA_B2inhib.connect(p=1.)
    ###############################################################################################

    # AMPA projections FROM EXCITATORY Z: #########################################################
开发者ID:accssharma,项目名称:neuronaldynamics-exercises,代码行数:67,代码来源:decision_making.py

示例14: BrianerClass

class BrianerClass(BaseClass):
    def default_init(
        self,
        _BrianingNeurongroupDict=None,
        _BrianingSynapsesDict=None,
        _BrianingConnectVariable=None,
        _BrianingTraceDict=None,
        _BrianingMoniterTuple=None,
        _BrianingSpikesDict=None,
        _BrianingPyplotDict=None,
        _BrianingTimeQuantityStr="ms",
        _BrianingPyplotBool=True,
        _BrianingStepTimeFloat=0.1,
        _BrianingDebugVariable=0,
        _BrianingRecordBool=True,
        _BrianedTimeQuantityVariable=None,
        _BrianedNetworkVariable=None,
        _BrianedNeurongroupVariable=None,
        _BrianedSynapsesVariable=None,
        _BrianedStateMonitorVariable=None,
        _BrianedSpikeMonitorVariable=None,
        _BrianedClockVariable=None,
        _BrianedParentSingularStr=None,
        _BrianedRecordKeyStrsList=None,
        _BrianedTraceDeriveBrianersList=None,
        _BrianedSynapsesDeriveBrianersList=None,
        _BrianedStateDeriveBrianersList=None,
        _BrianedSpikeDeriveBrianersList=None,
        _BrianedParentNetworkDeriveBrianerVariable=None,
        _BrianedParentPopulationDeriveBrianerVariable=None,
        _BrianedParentInteractomeDeriveBrianerVariable=None,
        _BrianedParentDeriveRecorderVariable=None,
        **_KwargVariablesDict
    ):

        # Call the parent __init__ method
        BaseClass.__init__(self, **_KwargVariablesDict)

    def do_brian(self):

        # /#################/#
        # Determine if it is an inside structure or the top
        #

        # debug
        """
		self.debug(
			[
				'We brian here',
				'First look for deeper teams in the structure',
			]
		)
		"""

        # Check
        if self.ParentedTotalSingularListDict != None and len(self.ParentedTotalSingularListDict) > 0:

            # debug
            """
			self.debug(
				[
					'self.ParentedTotalSingularListDict.keys() is ',
					str(self.ParentedTotalSingularListDict.keys())
				]
			)
			"""

            # get
            self.BrianedParentSingularStr = self.ParentedTotalSingularListDict.keys()[0]

            # debug
        """
		self.debug(
			[
				'Ok',
				('self.',self,[
					'BrianedParentSingularStr'
				])
			]
		)
		"""

        # /########################/#
        # Network level
        #

        # Check
        if (
            self.ParentDeriveTeamerVariable == None
            or "Populations" in self.TeamDict
            or self.ParentDeriveTeamerVariable.TeamTagStr
            not in ["Clocks", "Traces", "Samples", "Events", "Interactomes", "Interactions"]
        ) and self.BrianedParentSingularStr != "Population":

            # debug
            """
			self.debug(
				[
					'It is a Network level',
					'We set the brian network'
#.........这里部分代码省略.........
开发者ID:BinWang20140601,项目名称:ShareYourSystem,代码行数:101,代码来源:__init__+copy+7.py

示例15: simulate_brunel_network

def simulate_brunel_network(
        N_Excit=5000,
        N_Inhib=None,
        N_extern=N_POISSON_INPUT,
        connection_probability=CONNECTION_PROBABILITY_EPSILON,
        w0=SYNAPTIC_WEIGHT_W0,
        g=RELATIVE_INHIBITORY_STRENGTH_G,
        synaptic_delay=SYNAPTIC_DELAY,
        poisson_input_rate=POISSON_INPUT_RATE,
        w_external=None,
        v_rest=V_REST,
        v_reset=V_RESET,
        firing_threshold=FIRING_THRESHOLD,
        membrane_time_scale=MEMBRANE_TIME_SCALE,
        abs_refractory_period=ABSOLUTE_REFRACTORY_PERIOD,
        monitored_subset_size=100,
        random_vm_init=False,
        sim_time=100.*b2.ms):
    """
    Fully parametrized implementation of a sparsely connected network of LIF neurons (Brunel 2000)

    Args:
        N_Excit (int): Size of the excitatory popluation
        N_Inhib (int): optional. Size of the inhibitory population.
            If not set (=None), N_Inhib is set to N_excit/4.
        N_extern (int): optional. Number of presynaptic excitatory poisson neurons. Note: if set to a value,
            this number does NOT depend on N_Excit and NOT depend on connection_probability (this is different
            from the book and paper. Only if N_extern is set to 'None', then N_extern is computed as
            N_Excit*connection_probability.
        connection_probability (float): probability to connect to any of the (N_Excit+N_Inhib) neurons
            CE = connection_probability*N_Excit
            CI = connection_probability*N_Inhib
            Cexternal = N_extern
        w0 (float): Synaptic strength J
        g (float): relative importance of inhibition. J_exc = w0. J_inhib = -g*w0
        synaptic_delay (Quantity): Delay between presynaptic spike and postsynaptic increase of v_m
        poisson_input_rate (Quantity): Poisson rate of the external population
        w_external (float): optional. Synaptic weight of the excitatory external poisson neurons onto all
            neurons in the network. Default is None, in that case w_external is set to w0, which is the
            standard value in the book and in the paper Brunel2000.
            The purpose of this parameter is to see the effect of external input in the
            absence of network feedback(setting w0 to 0mV and w_external>0).
        v_rest (Quantity): Resting potential
        v_reset (Quantity): Reset potential
        firing_threshold (Quantity): Spike threshold
        membrane_time_scale (Quantity): tau_m
        abs_refractory_period (Quantity): absolute refractory period, tau_ref
        monitored_subset_size (int): nr of neurons for which a VoltageMonitor is recording Vm
        random_vm_init (bool): if true, the membrane voltage of each neuron is initialized with a
            random value drawn from Uniform(v_rest, firing_threshold)
        sim_time (Quantity): Simulation time

    Returns:
        (rate_monitor, spike_monitor, voltage_monitor, idx_monitored_neurons)
        PopulationRateMonitor: Rate Monitor
        SpikeMonitor: SpikeMonitor for ALL (N_Excit+N_Inhib) neurons
        StateMonitor: membrane voltage for a selected subset of neurons
        list: index of monitored neurons. length = monitored_subset_size
    """
    if N_Inhib is None:
        N_Inhib = int(N_Excit/4)
    if N_extern is None:
        N_extern = int(N_Excit*connection_probability)
    if w_external is None:
        w_external = w0

    J_excit = w0
    J_inhib = -g*w0

    lif_dynamics = """
    dv/dt = -(v-v_rest) / membrane_time_scale : volt (unless refractory)"""

    network = NeuronGroup(
        N_Excit+N_Inhib, model=lif_dynamics,
        threshold="v>firing_threshold", reset="v=v_reset", refractory=abs_refractory_period,
        method="linear")
    if random_vm_init:
        network.v = random.uniform(v_rest/b2.mV, high=firing_threshold/b2.mV, size=(N_Excit+N_Inhib))*b2.mV
    else:
        network.v = v_rest
    excitatory_population = network[:N_Excit]
    inhibitory_population = network[N_Excit:]

    exc_synapses = Synapses(excitatory_population, target=network, on_pre="v += J_excit", delay=synaptic_delay)
    exc_synapses.connect(p=connection_probability)

    inhib_synapses = Synapses(inhibitory_population, target=network, on_pre="v += J_inhib", delay=synaptic_delay)
    inhib_synapses.connect(p=connection_probability)

    external_poisson_input = PoissonInput(target=network, target_var="v", N=N_extern,
                                          rate=poisson_input_rate, weight=w_external)

    # collect data of a subset of neurons:
    monitored_subset_size = min(monitored_subset_size, (N_Excit+N_Inhib))
    idx_monitored_neurons = sample(range(N_Excit+N_Inhib), monitored_subset_size)
    rate_monitor = PopulationRateMonitor(network)
    # record= some_list is not supported? :-(
    spike_monitor = SpikeMonitor(network, record=idx_monitored_neurons)
    voltage_monitor = StateMonitor(network, "v", record=idx_monitored_neurons)

#.........这里部分代码省略.........
开发者ID:EPFL-LCN,项目名称:neuronaldynamics-exercises,代码行数:101,代码来源:LIF_spiking_network.py


注:本文中的brian2.Synapses类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。