本文整理汇总了Python中brian2.NeuronGroup.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python NeuronGroup.__init__方法的具体用法?Python NeuronGroup.__init__怎么用?Python NeuronGroup.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类brian2.NeuronGroup
的用法示例。
在下文中一共展示了NeuronGroup.__init__方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from brian2 import NeuronGroup [as 别名]
# 或者: from brian2.NeuronGroup import __init__ [as 别名]
def __init__(self, source, n_per_channel=1, params=None):
params = ZhangSynapse._get_parameters(params)
c_0, c_1 = params['c_0'], params['c_1']
s_0, s_1 = params['s_0'], params['s_1']
R_A = params['R_A']
ns = dict(s_0=s_0, s_1=s_1, c_0=c_0, c_1=c_1)
eqs = '''
# time-varying discharge rate, input into this model
s : Hz
# discharge-history effect (Equation 20 in differential equation form)
H = c_0*e_0 + c_1*e_1 : 1
de_0/dt = -e_0/s_0 : 1 (unless refractory)
de_1/dt = -e_1/s_1 : 1 (unless refractory)
# final time-varying discharge rate for the Poisson process, equation 19
R = s * (1 - H) : Hz
'''
# make sure that the s value is first updated in
# ZhangSynapseRate, then this NeuronGroup is
# updated by setting order+1
@network_operation(dt=source.dt[:], when='start', order=source.order+1)
def distribute_input():
self.s[:] = source.s[:].repeat(n_per_channel)
NeuronGroup.__init__(self, len(source) * n_per_channel,
model=eqs,
threshold='rand()<R*dt',
reset='''
e_0 = 1
e_1 = 1
''',
refractory=R_A,
dt=source.dt[:], order=source.order+1,
namespace=ns,
method='euler',
)
self.contained_objects.append(distribute_input)
示例2: __init__
# 需要导入模块: from brian2 import NeuronGroup [as 别名]
# 或者: from brian2.NeuronGroup import __init__ [as 别名]
def __init__(self, filterbank, targetvar, *args, **kwds):
# Make sure we're not in standalone mode (which won't work)
if not isinstance(get_device(), RuntimeDevice):
raise RuntimeError("Cannot use standalone mode with brian2hears")
self.targetvar = targetvar
self.filterbank = filterbank
filterbank.buffer_init()
# Sanitize the clock - does it have the right dt value?
if 'clock' in kwds:
if int(1/kwds['clock'].dt)!=int(filterbank.samplerate):
raise ValueError('Clock should have 1/dt=samplerate')
elif 'dt' in kwds:
if int(1 / kwds['dt']) != int(filterbank.samplerate):
raise ValueError('Require 1/dt=samplerate')
else:
kwds['dt'] = 1/filterbank.samplerate
buffersize = kwds.pop('buffersize', 32)
if not isinstance(buffersize, int):
if not have_same_dimensions(buffersize, second):
raise DimensionMismatchError("buffersize argument should be an integer or in seconds")
buffersize = int(buffersize*filterbank.samplerate)
self.buffersize = buffersize
self.apply_filterbank = ApplyFilterbank(self, targetvar, filterbank, buffersize)
NeuronGroup.__init__(self, filterbank.nchannels, *args, **kwds)
if self.variables[targetvar].dim is not DIMENSIONLESS:
raise DimensionMismatchError("Target variable must be dimensionless")
apply_filterbank_output = NetworkOperation(self.apply_filterbank.__call__, when='start', clock=self.clock)
self.contained_objects.append(apply_filterbank_output)