class Izhikevich(cells.Izhikevich): __doc__ = cells.Izhikevich.__doc__ translations = build_translations( ('a', 'a', 1/ms), ('b', 'b', 1/ms), ('c', 'v_reset', mV), ('d', 'd', mV/ms), ('i_offset', 'i_offset', nA) ) eqs = brian.Equations(''' dv/dt = (0.04/ms/mV)*v**2 + (5/ms)*v + 140*mV/ms - u + (i_offset + i_inj)/pF : mV du/dt = a*(b*v-u) : mV/ms a : 1/ms b : 1/ms v_reset : mV d : mV/ms i_offset : nA i_inj : nA ''') post_synaptic_variables = {'excitatory': 'v', 'inhibitory': 'v'} state_variable_translations = build_translations( ('v', 'v', mV), ('u', 'u', mV/ms)) brian_model = IzhikevichNeuronGroup
class IF_cond_alpha(cells.IF_cond_alpha): __doc__ = cells.IF_cond_alpha.__doc__ translations = build_translations( ('v_rest', 'v_rest', mV), ('v_reset', 'v_reset'), ('cm', 'c_m', nF), ('tau_m', 'tau_m', ms), ('tau_refrac', 'tau_refrac'), ('tau_syn_E', 'tau_syn_E', ms), ('tau_syn_I', 'tau_syn_I', ms), ('v_thresh', 'v_thresh'), ('i_offset', 'i_offset', nA), ('e_rev_E', 'e_rev_E', mV), ('e_rev_I', 'e_rev_I', mV), ) eqs = brian.Equations(''' dv/dt = (v_rest-v)/tau_m + (ge*(e_rev_E-v) + gi*(e_rev_I-v) + i_offset + i_inj)/c_m : mV dge/dt = (2.7182818284590451*ye-ge)/tau_syn_E : uS dye/dt = -ye/tau_syn_E : uS dgi/dt = (2.7182818284590451*yi-gi)/tau_syn_I : uS dyi/dt = -yi/tau_syn_I : uS tau_syn_E : ms tau_syn_I : ms tau_m : ms v_rest : mV e_rev_E : mV e_rev_I : mV c_m : nF i_offset : nA i_inj : nA ''') synapses = {'excitatory': 'ye', 'inhibitory': 'yi'} brian_model = ThresholdNeuronGroup
class IF_cond_exp(cells.IF_cond_exp): __doc__ = cells.IF_cond_exp.__doc__ translations = build_translations( ('v_rest', 'v_rest', mV), ('v_reset', 'v_reset'), ('cm', 'c_m', nF), ('tau_m', 'tau_m', ms), ('tau_refrac', 'tau_refrac'), ('tau_syn_E', 'tau_syn_E', ms), ('tau_syn_I', 'tau_syn_I', ms), ('v_thresh', 'v_thresh'), ('i_offset', 'i_offset', nA), ('e_rev_E', 'e_rev_E', mV), ('e_rev_I', 'e_rev_I', mV), ) eqs = brian.Equations(''' dv/dt = (v_rest-v)/tau_m + (ge*(e_rev_E-v) + gi*(e_rev_I-v) + i_offset + i_inj)/c_m : mV dge/dt = -ge/tau_syn_E : uS dgi/dt = -gi/tau_syn_I : uS tau_syn_E : ms tau_syn_I : ms tau_m : ms c_m : nF v_rest : mV e_rev_E : mV e_rev_I : mV i_offset : nA i_inj : nA ''') synapses = {'excitatory': 'ge', 'inhibitory': 'gi'} brian_model = ThresholdNeuronGroup
class Izikevich(cells.Izikevich): __doc__ = cells.Izikevich.__doc__ translations = build_translations( ('a', 'a', 1 / ms), ('b', 'b', 1 / ms), ('v_reset', 'v_reset'), ('d', 'd', mV / ms), ('tau_refrac', 'tau_refrac')) eqs = brian.Equations(''' dv/dt = (0.04/ms/mV)*v**2+(5/ms)*v+140*mV/ms - u + (ie + ii) * (mV/ms) / nA : mV du/dt = a*(b*v-u) : mV/ms die/dt = -ie/(1*ms) : nA dii/dt = -ii/(1*ms) : nA a : 1/ms b : 1/ms v_reset : mV d : mV/ms ''') synapses = {'excitatory': 'ie', 'inhibitory': 'ii'} @property def reset(self): reset = IzikevichReset(self.parameters['v_reset'] * mV, self.parameters['d']) return SimpleCustomRefractoriness( reset, period=self.parameters['tau_refrac'] * ms) @property def threshold(self): return 30 * mV
class IF_curr_exp(cells.IF_curr_exp): __doc__ = cells.IF_curr_exp.__doc__ translations = build_translations( ('v_rest', 'v_rest', mV), ('v_reset', 'v_reset'), ('cm', 'c_m', nF), ('tau_m', 'tau_m', ms), ('tau_refrac', 'tau_refrac'), ('tau_syn_E', 'tau_syn_E', ms), ('tau_syn_I', 'tau_syn_I', ms), ('v_thresh', 'v_thresh'), ('i_offset', 'i_offset', nA), ) eqs = brian.Equations(''' dv/dt = (ie + ii + i_offset + i_inj)/c_m + (v_rest-v)/tau_m : mV die/dt = -ie/tau_syn_E : nA dii/dt = -ii/tau_syn_I : nA tau_syn_E : ms tau_syn_I : ms tau_m : ms c_m : nF v_rest : mV i_offset : nA i_inj : nA ''') synapses = {'excitatory': 'ie', 'inhibitory': 'ii'} brian_model = ThresholdNeuronGroup
class IF_curr_exp(cells.IF_curr_exp): """Leaky integrate and fire model with fixed threshold and decaying-exponential post-synaptic current. (Separate synaptic currents for excitatory and inhibitory synapses.""" translations = common.build_translations( ('v_rest', 'v_rest', mV), ('v_reset', 'v_reset'), ('cm', 'c_m', nF), ('tau_m', 'tau_m', ms), ('tau_refrac', 'tau_refrac'), ('tau_syn_E', 'tau_syn_E', ms), ('tau_syn_I', 'tau_syn_I', ms), ('v_thresh', 'v_thresh'), ('i_offset', 'i_offset', nA), ('v_init', 'v_init', mV), ) eqs = brian.Equations(''' dv/dt = (ie + ii + i_offset + i_inj)/c_m + (v_rest-v)/tau_m : mV die/dt = -ie/tau_syn_E : nA dii/dt = -ii/tau_syn_I : nA tau_syn_E : ms tau_syn_I : ms tau_m : ms c_m : nF v_rest : mV i_offset : nA i_inj : nA ''') synapses = {'excitatory': 'ie', 'inhibitory': 'ii'}
class IF_curr_alpha(cells.IF_curr_alpha): """Leaky integrate and fire model with fixed threshold and alpha-function- shaped post-synaptic current.""" translations = common.build_translations( ('v_rest', 'v_rest', mV), ('v_reset', 'v_reset'), ('cm', 'c_m', nF), ('tau_m', 'tau_m', ms), ('tau_refrac', 'tau_refrac'), ('tau_syn_E', 'tau_syn_E', ms), ('tau_syn_I', 'tau_syn_I', ms), ('v_thresh', 'v_thresh'), ('i_offset', 'i_offset', nA), ('v_init', 'v_init', ms), ) eqs = brian.Equations(''' dv/dt = (ge + gi + i_offset + i_inj)/c_m + (v_rest-v)/tau_m : mV dge/dt = (2.7182818284590451*ye-ge)/tau_syn_E : nA dye/dt = -ye/tau_syn_E : nA dgi/dt = (2.7182818284590451*yi-gi)/tau_syn_I : nA dyi/dt = -yi/tau_syn_I : nA c_m : nF tau_syn_E : ms tau_syn_I : ms tau_m : ms v_rest : mV i_offset : nA i_inj : nA ''') synapses = {'excitatory': 'ye', 'inhibitory': 'yi'}
class IF_cond_exp(cells.IF_cond_exp): """Leaky integrate and fire model with fixed threshold and exponentially-decaying post-synaptic conductance.""" translations = common.build_translations( ('v_rest', 'v_rest', mV), ('v_reset', 'v_reset'), ('cm', 'cm', nF), ('tau_m', 'tau_m', ms), ('tau_refrac', 'tau_refrac'), ('tau_syn_E', 'tau_syn_E', ms), ('tau_syn_I', 'tau_syn_I', ms), ('v_thresh', 'v_thresh'), ('i_offset', 'i_offset', nA), ('e_rev_E', 'e_rev_E', mV), ('e_rev_I', 'e_rev_I', mV), ('v_init', 'v_init', mV), ) eqs = brian.Equations(''' dv/dt = (v_rest-v)/tau_m + (ge*(e_rev_E-v) + gi*(e_rev_I-v) + i_offset + i_inj)/cm : mV dge/dt = -ge/tau_syn_E : uS dgi/dt = -gi/tau_syn_I : uS tau_syn_E : ms tau_syn_I : ms tau_m : ms cm : nF v_rest : mV e_rev_E : mV e_rev_I : mV i_offset : nA i_inj : nA ''') synapses = {'excitatory': 'ge', 'inhibitory': 'gi'}
class EIF_cond_alpha_isfa_ista(cells.EIF_cond_alpha_isfa_ista): __doc__ = cells.EIF_cond_alpha_isfa_ista.__doc__ translations = build_translations( ('cm', 'c_m', nF), ('v_spike', 'v_spike'), ('v_rest', 'v_rest', mV), ('v_reset', 'v_reset'), ('tau_m', 'tau_m', ms), ('tau_refrac', 'tau_refrac'), ('i_offset', 'i_offset', nA), ('a', 'a', nA), ('b', 'b', nA), ('delta_T', 'delta_T', mV), ('tau_w', 'tau_w', ms), ('v_thresh', 'v_thresh', mV), ('e_rev_E', 'e_rev_E', mV), ('tau_syn_E', 'tau_syn_E', ms), ('e_rev_I', 'e_rev_I', mV), ('tau_syn_I', 'tau_syn_I', ms), ) eqs = brian.Equations(''' dv/dt = ((v_rest-v) + delta_T*exp((v-v_thresh)/delta_T))/tau_m + (ge*(e_rev_E-v) + gi*(e_rev_I-v) + i_offset + i_inj - w)/c_m : mV dge/dt = (2.7182818284590451*ye-ge)/tau_syn_E : uS dye/dt = -ye/tau_syn_E : uS dgi/dt = (2.7182818284590451*yi-gi)/tau_syn_I : uS dyi/dt = -yi/tau_syn_I : uS dw/dt = (a*(v-v_rest) - w)/tau_w : nA tau_syn_E : ms tau_syn_I : ms tau_m : ms v_rest : mV e_rev_E : mV e_rev_I : mV c_m : nF i_offset : nA i_inj : nA delta_T : mV a : uS b : nA tau_w : ms v_thresh : mV v_spike : mV ''') synapses = {'excitatory': 'ye', 'inhibitory': 'yi'} @property def threshold(self): return self.parameters['v_spike'] * mV @property def reset(self): reset = AdaptiveReset(self.parameters['v_reset'] * mV, self.parameters['b'] * amp) return SimpleCustomRefractoriness( reset, period=self.parameters['tau_refrac'] * ms)
class HH_cond_exp(cells.HH_cond_exp): translations = build_translations( ('gbar_Na', 'gbar_Na', uS), ('gbar_K', 'gbar_K', uS), ('g_leak', 'g_leak', uS), ('cm', 'c_m', nF), ('v_offset', 'v_offset', mV), ('e_rev_Na', 'e_rev_Na', mV), ('e_rev_K', 'e_rev_K', mV), ('e_rev_leak', 'e_rev_leak', mV), ('e_rev_E', 'e_rev_E', mV), ('e_rev_I', 'e_rev_I', mV), ('tau_syn_E', 'tau_syn_E', ms), ('tau_syn_I', 'tau_syn_I', ms), ('i_offset', 'i_offset', nA), ) eqs = brian.Equations(''' dv/dt = (g_leak*(e_rev_leak-v)+ge*(e_rev_E-v)+gi*(e_rev_I-v)-gbar_Na*(m*m*m)*h*(v-e_rev_Na)-gbar_K*(n*n*n*n)*(v-e_rev_K) + i_offset + i_inj)/c_m : mV dm/dt = (alpham*(1-m)-betam*m) : 1 dn/dt = (alphan*(1-n)-betan*n) : 1 dh/dt = (alphah*(1-h)-betah*h) : 1 dge/dt = -ge/tau_syn_E : uS dgi/dt = -gi/tau_syn_I : uS alpham = 0.32*(mV**-1)*(13*mV-v+v_offset)/(exp((13*mV-v+v_offset)/(4*mV))-1.)/ms : Hz betam = 0.28*(mV**-1)*(v-v_offset-40*mV)/(exp((v-v_offset-40*mV)/(5*mV))-1)/ms : Hz alphah = 0.128*exp((17*mV-v+v_offset)/(18*mV))/ms : Hz betah = 4./(1+exp((40*mV-v+v_offset)/(5*mV)))/ms : Hz alphan = 0.032*(mV**-1)*(15*mV-v+v_offset)/(exp((15*mV-v+v_offset)/(5*mV))-1.)/ms : Hz betan = .5*exp((10*mV-v+v_offset)/(40*mV))/ms : Hz tau_syn_E : ms tau_syn_I : ms e_rev_E : mV e_rev_I : mV e_rev_Na : mV e_rev_K : mV e_rev_leak : mV gbar_Na : uS gbar_K : uS g_leak : uS v_offset : mV c_m : nF i_offset : nA i_inj : nA ''') synapses = {'excitatory': 'ge', 'inhibitory': 'gi'} @property def threshold(self): return brian.EmpiricalThreshold(threshold=-40 * mV, refractory=2 * ms) @property def reset(self): return 0 * mV @property def extra(self): return {'implicit': True}
def _build(self): '''Create populations.''' eqs = brian.Equations(''' dV/dt = ge/ms : volt dge/dt = ge/ms : volt dgi/dt = ge/ms : volt ''') pop = brian.NeuronGroup(self._N_s + self._N_t, model=eqs, threshold=brian.mV, reset=brian.mV) self._source_pop = pop.subgroup(self._N_s) self._target_pop = pop.subgroup(self._N_t)
class HH_cond_exp(cells.HH_cond_exp): __doc__ = cells.HH_cond_exp.__doc__ translations = build_translations( ('gbar_Na', 'gbar_Na', uS), ('gbar_K', 'gbar_K', uS), ('g_leak', 'g_leak', uS), ('cm', 'c_m', nF), ('v_offset', 'v_offset', mV), ('e_rev_Na', 'e_rev_Na', mV), ('e_rev_K', 'e_rev_K', mV), ('e_rev_leak', 'e_rev_leak', mV), ('e_rev_E', 'e_rev_E', mV), ('e_rev_I', 'e_rev_I', mV), ('tau_syn_E', 'tau_syn_E', ms), ('tau_syn_I', 'tau_syn_I', ms), ('i_offset', 'i_offset', nA), ) eqs = brian.Equations(''' dv/dt = (g_leak*(e_rev_leak-v)+ge*(e_rev_E-v)+gi*(e_rev_I-v)-gbar_Na*(m*m*m)*h*(v-e_rev_Na)-gbar_K*(n*n*n*n)*(v-e_rev_K) + i_offset + i_inj)/c_m : mV dm/dt = (alpham*(1-m)-betam*m) : 1 dn/dt = (alphan*(1-n)-betan*n) : 1 dh/dt = (alphah*(1-h)-betah*h) : 1 dge/dt = -ge/tau_syn_E : uS dgi/dt = -gi/tau_syn_I : uS alpham = 0.32*(mV**-1)*(13*mV-v+v_offset)/(exp((13*mV-v+v_offset)/(4*mV))-1.)/ms : Hz betam = 0.28*(mV**-1)*(v-v_offset-40*mV)/(exp((v-v_offset-40*mV)/(5*mV))-1)/ms : Hz alphah = 0.128*exp((17*mV-v+v_offset)/(18*mV))/ms : Hz betah = 4./(1+exp((40*mV-v+v_offset)/(5*mV)))/ms : Hz alphan = 0.032*(mV**-1)*(15*mV-v+v_offset)/(exp((15*mV-v+v_offset)/(5*mV))-1.)/ms : Hz betan = .5*exp((10*mV-v+v_offset)/(40*mV))/ms : Hz tau_syn_E : ms tau_syn_I : ms e_rev_E : mV e_rev_I : mV e_rev_Na : mV e_rev_K : mV e_rev_leak : mV gbar_Na : uS gbar_K : uS g_leak : uS v_offset : mV c_m : nF i_offset : nA i_inj : nA ''') synapses = {'excitatory': 'ge', 'inhibitory': 'gi'} brian_model = BiophysicalNeuronGroup
class EIF_cond_alpha_isfa_ista(cells.EIF_cond_alpha_isfa_ista): __doc__ = cells.EIF_cond_alpha_isfa_ista.__doc__ translations = build_translations( ('cm', 'c_m', nF), ('v_spike', 'v_spike'), ('v_rest', 'v_rest', mV), ('v_reset', 'v_reset'), ('tau_m', 'tau_m', ms), ('tau_refrac', 'tau_refrac'), ('i_offset', 'i_offset', nA), ('a', 'a', nA), ('b', 'b', nA), ('delta_T', 'delta_T', mV), ('tau_w', 'tau_w', ms), ('v_thresh', 'v_thresh', mV), ('e_rev_E', 'e_rev_E', mV), ('tau_syn_E', 'tau_syn_E', ms), ('e_rev_I', 'e_rev_I', mV), ('tau_syn_I', 'tau_syn_I', ms), ) eqs= brian.Equations(''' dv/dt = ((v_rest-v) + delta_T*exp((v-v_thresh)/delta_T))/tau_m + (ge*(e_rev_E-v) + gi*(e_rev_I-v) + i_offset + i_inj - w)/c_m : mV dge/dt = (2.7182818284590451*ye-ge)/tau_syn_E : uS dye/dt = -ye/tau_syn_E : uS dgi/dt = (2.7182818284590451*yi-gi)/tau_syn_I : uS dyi/dt = -yi/tau_syn_I : uS dw/dt = (a*(v-v_rest) - w)/tau_w : nA tau_syn_E : ms tau_syn_I : ms tau_m : ms v_rest : mV e_rev_E : mV e_rev_I : mV c_m : nF i_offset : nA i_inj : nA delta_T : mV a : uS b : nA tau_w : ms v_thresh : mV v_spike : mV ''' ) synapses = {'excitatory': 'ye', 'inhibitory': 'yi'} brian_model = AdaptiveNeuronGroup
def run_sim(number_neurons=default_number_neurons, connection_probability=default_connection_probability, synaptic_weights=default_synaptic_weights, synaptic_time_constant=default_synaptic_time_constant, tend=300): '''run a simulation of a population of leaky integrate-and-fire excitatory neurons that are randomly connected. The population is injected with a transient current.''' from brian.units import mvolt, msecond, namp, Mohm import brian brian.clear() El = 0 * mvolt tau_m = 30 * msecond tau_syn = synaptic_time_constant * msecond R = 20 * Mohm v_threshold = 30 * mvolt v_reset = 0 * mvolt tau_refractory = 4 * msecond eqs = brian.Equations(''' dv/dt = (-(v - El) + R*I)/tau_m : volt I = I_syn + I_stim : amp dI_syn/dt = -I_syn/tau_syn : amp I_stim : amp ''') external_current = np.zeros(tend) external_current[np.arange(0, 100)] = 5 * namp group = brian.NeuronGroup( model=eqs, N=number_neurons, threshold=v_threshold, reset=v_reset, refractory=tau_refractory) group.I_stim = brian.TimedArray(external_current, dt=1*msecond) connections = brian.Connection(group, group, 'I_syn') connections.connect_random(sparseness=connection_probability, weight=synaptic_weights*namp) spike_monitor = brian.SpikeMonitor(group) population_rate_monitor = brian.PopulationRateMonitor(group, bin=10*msecond) brian.reinit() brian.run(tend * msecond) return spike_monitor, population_rate_monitor
def __init__(self, C, taup, taum, Ap, Am, mu_p, mu_m, wmin=0, wmax=None, delay_pre=None, delay_post=None): if wmax is None: raise AttributeError, "You must specify the maximum synaptic weight" wmax = float(wmax) # removes units wmin = float(wmin) Ap *= wmax # removes units Am *= wmax # removes units eqs = brian.Equations(''' dA_pre/dt = -A_pre/taup : 1 dA_post/dt = -A_post/taum : 1''', taup=taup, taum=taum, wmax=wmax, mu_m=mu_m, mu_p=mu_p) pre = 'A_pre += Ap' pre += '\nw += A_post*pow(w/wmax, mu_m)' post = 'A_post += Am' post += '\nw += A_pre*pow(1-w/wmax, mu_p)' brian.STDP.__init__(self, C, eqs=eqs, pre=pre, post=post, wmin=wmin, wmax=wmax, delay_pre=None, delay_post=None, clock=None)
class Izhikevich(cells.Izhikevich): __doc__ = cells.Izhikevich.__doc__ translations = build_translations( ('a', 'a', 1 / ms), ('b', 'b', 1 / ms), ('v_reset', 'v_reset'), ('d', 'd', mV / ms), ('tau_refrac', 'tau_refrac')) eqs = brian.Equations(''' dv/dt = (0.04/ms/mV)*v**2+(5/ms)*v+140*mV/ms - u + (ie + ii) * (mV/ms) / nA : mV du/dt = a*(b*v-u) : mV/ms die/dt = -ie/(1*ms) : nA dii/dt = -ii/(1*ms) : nA a : 1/ms b : 1/ms v_reset : mV d : mV/ms ''') synapses = {'excitatory': 'ie', 'inhibitory': 'ii'} brian_model = IzhikevichNeuronGroup
class IF_cond_exp(cells.IF_cond_exp): __doc__ = cells.IF_cond_exp.__doc__ translations = build_translations( ('v_rest', 'v_rest', mV), ('v_reset', 'v_reset'), ('cm', 'c_m', nF), ('tau_m', 'tau_m', ms), ('tau_refrac', 'tau_refrac'), ('tau_syn_E', 'tau_syn_E', ms), ('tau_syn_I', 'tau_syn_I', ms), ('v_thresh', 'v_thresh'), ('i_offset', 'i_offset', nA), ('e_rev_E', 'e_rev_E', mV), ('e_rev_I', 'e_rev_I', mV), ) eqs = brian.Equations(''' dv/dt = (v_rest-v)/tau_m + (ge*(e_rev_E-v) + gi*(e_rev_I-v) + i_offset + i_inj)/c_m : mV dge/dt = -ge/tau_syn_E : uS dgi/dt = -gi/tau_syn_I : uS tau_syn_E : ms tau_syn_I : ms tau_m : ms c_m : nF v_rest : mV e_rev_E : mV e_rev_I : mV i_offset : nA i_inj : nA ''') synapses = {'excitatory': 'ge', 'inhibitory': 'gi'} @property def threshold(self): return self.parameters['v_thresh'] * mV @property def reset(self): return self.parameters['v_reset'] * mV
class IF_cond_alpha(cells.IF_cond_alpha): translations = build_translations( ('v_rest', 'v_rest', mV), ('v_reset', 'v_reset'), ('cm', 'c_m', nF), ('tau_m', 'tau_m', ms), ('tau_refrac', 'tau_refrac'), ('tau_syn_E', 'tau_syn_E', ms), ('tau_syn_I', 'tau_syn_I', ms), ('v_thresh', 'v_thresh'), ('i_offset', 'i_offset', nA), ('e_rev_E', 'e_rev_E', mV), ('e_rev_I', 'e_rev_I', mV), ) eqs = brian.Equations(''' dv/dt = (v_rest-v)/tau_m + (ge*(e_rev_E-v) + gi*(e_rev_I-v) + i_offset + i_inj)/c_m : mV dge/dt = (2.7182818284590451*ye-ge)/tau_syn_E : uS dye/dt = -ye/tau_syn_E : uS dgi/dt = (2.7182818284590451*yi-gi)/tau_syn_I : uS dyi/dt = -yi/tau_syn_I : uS tau_syn_E : ms tau_syn_I : ms tau_m : ms v_rest : mV e_rev_E : mV e_rev_I : mV c_m : nF i_offset : nA i_inj : nA ''') synapses = {'excitatory': 'ye', 'inhibitory': 'yi'} @property def threshold(self): return self.parameters['v_thresh'] * mV @property def reset(self): return self.parameters['v_reset'] * mV
def create_cells(cellclass, cellparams=None, n=1, parent=None): """ Create cells in Brian. `cellclass` -- a PyNN standard cell or a native Brian cell class. `cellparams` -- a dictionary of cell parameters. `n` -- the number of cells to create `parent` -- the parent Population, or None if the cells don't belong to a Population. This function is used by both `create()` and `Population.__init__()` Return: - a 1D array of all cell IDs - a 1D boolean array indicating which IDs are present on the local MPI node - the ID of the first cell created - the ID of the last cell created """ # currently, we create a single NeuronGroup for create(), but # arguably we should use n NeuronGroups each containing a single cell # either that or use the subgroup() method in connect(), etc assert n > 0, 'n must be a positive integer' if isinstance(cellclass, basestring): # celltype is not a standard cell try: eqs = brian.Equations(cellclass) except Exception, errmsg: raise common.InvalidModelError(errmsg) v_thresh = cellparams['v_thresh'] v_reset = cellparams['v_reset'] tau_refrac = cellparams['tau_refrac'] brian_cells = brian.NeuronGroup(n, model=eqs, threshold=v_thresh, reset=v_reset, clock=state.simclock, compile=True, max_delay=state.max_delay) cell_parameters = cellparams or {}
class IF_curr_exp(cells.IF_curr_exp): __doc__ = cells.IF_curr_exp.__doc__ translations = build_translations( ('v_rest', 'v_rest', mV), ('v_reset', 'v_reset'), ('cm', 'c_m', nF), ('tau_m', 'tau_m', ms), ('tau_refrac', 'tau_refrac'), ('tau_syn_E', 'tau_syn_E', ms), ('tau_syn_I', 'tau_syn_I', ms), ('v_thresh', 'v_thresh'), ('i_offset', 'i_offset', nA), ) eqs = brian.Equations(''' dv/dt = (ie + ii + i_offset + i_inj)/c_m + (v_rest-v)/tau_m : mV die/dt = -ie/tau_syn_E : nA dii/dt = -ii/tau_syn_I : nA tau_syn_E : ms tau_syn_I : ms tau_m : ms c_m : nF v_rest : mV i_offset : nA i_inj : nA ''') synapses = {'excitatory': 'ie', 'inhibitory': 'ii'} @property def threshold(self): return self.parameters['v_thresh'] * mV @property def reset(self): return self.parameters['v_reset'] * mV
from copy import deepcopy import brian from brian import mV, ms, nF, nA, uS, Hz from pyNN.standardmodels import cells, build_translations from ..simulator import state from ..cells import (ThresholdNeuronGroup, SpikeGeneratorGroup, PoissonGroup, BiophysicalNeuronGroup, AdaptiveNeuronGroup, IzhikevichNeuronGroup) import logging logger = logging.getLogger("PyNN") leaky_iaf = brian.Equations(''' dv/dt = (v_rest-v)/tau_m + (i_syn + i_offset + i_inj)/c_m : mV tau_m : ms c_m : nF v_rest : mV i_offset : nA i_inj : nA ''') adexp_iaf = brian.Equations(''' dv/dt = ((v_rest-v) + delta_T*exp((v - v_thresh)/delta_T))/tau_m + (i_syn + i_offset + i_inj - w)/c_m : mV dw/dt = (a*(v-v_rest) - w)/tau_w : nA a : uS tau_m : ms tau_w : ms c_m : nF v_rest : mV v_thresh : mV delta_T : mV i_offset : nA
class EIF_cond_exp_isfa_ista(cells.EIF_cond_exp_isfa_ista): """ Exponential integrate and fire neuron with spike triggered and sub-threshold adaptation currents (isfa, ista reps.) according to: Brette R and Gerstner W (2005) Adaptive Exponential Integrate-and-Fire Model as an Effective Description of Neuronal Activity. J Neurophysiol 94:3637-3642 See also: IF_cond_exp_gsfa_grr, EIF_cond_exp_isfa_ista """ translations = build_translations( ('cm', 'c_m', nF), ('v_spike', 'v_spike'), ('v_rest', 'v_rest', mV), ('v_reset', 'v_reset'), ('tau_m', 'tau_m', ms), ('tau_refrac', 'tau_refrac'), ('i_offset', 'i_offset', nA), ('a', 'a', nA), ('b', 'b', nA), ('delta_T', 'delta_T', mV), ('tau_w', 'tau_w', ms), ('v_thresh', 'v_thresh', mV), ('e_rev_E', 'e_rev_E', mV), ('tau_syn_E', 'tau_syn_E', ms), ('e_rev_I', 'e_rev_I', mV), ('tau_syn_I', 'tau_syn_I', ms), ) eqs = brian.Equations(''' dv/dt = ((v_rest-v) + delta_T*exp((v - v_thresh)/delta_T))/tau_m + (ge*(e_rev_E-v) + gi*(e_rev_I-v) + i_offset + i_inj - w)/c_m : mV dge/dt = -ge/tau_syn_E : uS dgi/dt = -gi/tau_syn_I : uS dw/dt = (a*(v-v_rest) - w)/tau_w : nA tau_syn_E : ms tau_syn_I : ms tau_m : ms v_rest : mV e_rev_E : mV e_rev_I : mV c_m : nF i_offset : nA i_inj : nA delta_T : mV a : uS b : nA tau_w : ms v_thresh : mV v_spike : mV ''') synapses = {'excitatory': 'ge', 'inhibitory': 'gi'} @property def threshold(self): return self.parameters['v_spike'] * mV @property def reset(self): reset = AdaptiveReset(self.parameters['v_reset'] * mV, self.parameters['b'] * amp) return SimpleCustomRefractoriness( reset, period=self.parameters['tau_refrac'] * ms)
import brian_no_units import brian from pylab import * eq1=brian.Equations('g=gmax*c0 :volt') #eq1+=brian.Equations('g_ch : 1') #uncomment this to make it work eq1+=brian.Equations('dc0/dt=-1 :volt') eq1+=brian.Equations('gmax :1') g1=brian.NeuronGroup(1, model=eq1) eq2=brian.Equations('dv/dt=-v+gch*(erev-v): volt') eq2+=brian.Equations('erev :1') eq2+=brian.Equations('gch :1') g2=brian.NeuronGroup(1, model=eq2) #g1.g_ch = brian.linked_var(g1, 'g') #uncomment this to make it work g2.gch = brian.linked_var(g1, 'g') #comment this to make it work #g2.gch = brian.linked_var(g1, 'g_ch') #uncomment this to make it work s1=brian.StateMonitor(g1, 'g', record=0) s2=brian.StateMonitor(g1, 'c0', record=0) s3=brian.StateMonitor(g2, 'v', record=0) s4=brian.StateMonitor(g2, 'gch', record=0) s5=brian.StateMonitor(g1, 'gmax', record=0) #initialize g1.g=0.0 #commenting this ALONE will make it work #g1.g_ch=0.0 #uncomment this to make it work
def __init__(self, input_dim, output_dim, dtype, input_scaling=100, input_conn_frac=.5, dt=1, we_scaling=2, wi_scaling=.5, we_sparseness=.1, wi_sparseness=.1): super(BrianIFReservoirNode, self).__init__(input_dim=input_dim, output_dim=output_dim, dtype=dtype) self.taum = 20 * brian.ms self.taue = 5 * brian.ms self.taui = 10 * brian.ms self.Vt = 15 * brian.mV self.Vr = 0 * brian.mV self.frac_e = .75 self.input_scaling = input_scaling self.input_conn_frac = input_conn_frac self.dt = dt self.we_scaling = we_scaling self.wi_scaling = wi_scaling self.we_sparseness = we_sparseness self.wi_sparseness = wi_sparseness self.eqs = brian.Equations(''' dV/dt = (I-V+ge-gi)/self.taum : volt dge/dt = -ge/self.taue : volt dgi/dt = -gi/self.taui : volt I: volt ''') self.G = brian.NeuronGroup(N=output_dim, model=self.eqs, threshold=self.Vt, reset=self.Vr) self.Ge = self.G.subgroup(int(scipy.floor( output_dim * self.frac_e))) # Excitatory neurons self.Gi = self.G.subgroup( int(scipy.floor(output_dim * (1 - self.frac_e)))) self.internal_conn = brian.Connection(self.G, self.G) self.we = self.we_scaling * scipy.random.rand(len(self.Ge), len( self.G)) * brian.nS self.wi = self.wi_scaling * scipy.random.rand(len(self.Ge), len( self.G)) * brian.nS self.Ce = brian.Connection(self.Ge, self.G, 'ge', sparseness=self.we_sparseness, weight=self.we) self.Ci = brian.Connection(self.Gi, self.G, 'gi', sparseness=self.wi_sparseness, weight=self.wi) #self.internal_conn.connect(self.G, self.G, self.w_res) self.Mv = brian.StateMonitor(self.G, 'V', record=True, timestep=10) self.Ms = brian.SpikeMonitor(self.G, record=True) self.w_in = self.input_scaling * (scipy.random.rand( self.output_dim, self.input_dim)) * (scipy.random.rand( self.output_dim, self.input_dim) < self.input_conn_frac) self.network = brian.Network(self.G, self.Ce, self.Ci, self.Ge, self.Gi, self.Mv, self.Ms)
connENetWeight = 0.3 connINetWeight = 9.55 internalSparseness = 0.02 spontAddRate = -4.48 # found via optimization to give mean 5 spk/s spont rate nNet = 10000 nExc = int(nNet * 0.8) nInh = int(nNet * 0.2) condAddNeurNs = r_[0:nExc:4] ffExcInputNTargs = 2500 ffInhInputNTargs = 666 eqs = brian.Equations(''' dv/dt = (-v+ge*(Ee-v)+gi*(Ei-v)+gAdd*(Ee-v) ) *(1./taum) : volt dge/dt = -ge*(1./taue) : 1 dgi/dt = -gi*(1./taui) : 1 gAdd : 1 ''') contRecNs = [ 0 ] # record continuous variables (Vm, ge, gi) from one example neuron contRecStepMs = 1.0 ############### # Functions def create_input_vectors(doDebugPlot=True): """Constructs the feedforward and conductance-add vectors.