In [1]:
from brian import *
# Set the parameters from the specified file first
from utils import set_model_ps
PSFILE = 'paramsets/std_beta.py'
set_model_ps(PSFILE)
import model
from model.network_input import NetworkInput
from model.mitral_cells import MitralCells
from model.synapse import Synapse
from model.granule_cells import GranuleCells
import numpy as np
In [2]:
clear(erase=True, all=True)
defaultclock.reinit()
In [3]:
psmt = model.PARAMETERS['Mitral']
psgr = model.PARAMETERS['Granule']
pscommon = model.PARAMETERS['Common']
print model.PARAMETERS
N_mitral = pscommon['N_mitral']
N_glomerule = N_granule = N_mitral_subpop = pscommon['N_subpop']
Simulation timestep, always set before any NeuronGroup creation, bugs otherwise.
In [4]:
defaultclock.dt = pscommon['simu_dt']
t_simu = pscommon['simu_length']
Create and initialize it
In [5]:
netin = NetworkInput()
netin.set_eqs_model()
netin.get_eqs_model()
Out[5]:
Excitatory synapse (mitral --> granule)
In [6]:
synexc = Synapse(synapse_type='exc')
synexc.set_eqs_model()
synexc.get_eqs_model()
Out[6]:
Inhibitory synapse (granule --> mitral)
In [7]:
syninhib = Synapse(synapse_type='inhib')
syninhib.set_eqs_model()
syninhib.get_eqs_model()
Out[7]:
Create the mitral cells
In [8]:
mt = MitralCells()
Initialize it with the default equation model and input and synaptic currents
In [9]:
mt_supp_eqs = {'var': ['-I_input', '-I_syn'],
'eqs': [netin.get_eqs_model(), synexc.get_eqs_model()]}
mt.add_eqs(supp_eqs=mt_supp_eqs)
print mt.eqs_model
Create the NeuronGroup
of mitral cells and initialize their membrane potential
In [10]:
mt.make_pop(N_mitral)
mt.pop.V = (psmt['E_L'] - psmt['V_r'])*np.random.random_sample(np.shape(mt.pop.V)) + psmt['V_r']
Create the granule cells
In [11]:
gr = GranuleCells()
Add the equation model with the synaptic current
In [12]:
gr_supp_eqs = {'var': ['-I_syn'],
'eqs': [syninhib.get_eqs_model()]}
gr.add_eqs(supp_eqs=gr_supp_eqs)
print gr.eqs_model
Create the NeuronGroup
of granule cells and initialize their membrane potential
In [13]:
gr.make_pop(N_granule)
gr.pop.V_D = psgr['E_L']
gr.pop.V_S = psgr['E_L']
Setting the connections between mitral and granule cells
In [14]:
connections = ones((N_mitral,N_granule))
@network_operation(when='start')
def graded_synapse():
#connections
mt.pop.state('T')[:]=0.
mt.pop.state('T')[mt.pop.get_refractory_indices()]=1.
gr.pop.s_syn = dot(mt.pop.s, connections)
mt.pop.s_syn = dot(gr.pop.s, transpose(connections))
@network_operation(when='after_groups')
def keep_reset():
mt.pop.state('V')[mt.pop.get_refractory_indices()] = psmt['V_r']
Setting the monitors
In [15]:
monit_mitral = {}
monit_granule = {}
rec_mitral = [0, N_mitral/2, N_mitral-1]
for pname in ('s', 's_syn', 'V', 'T', 'g_Ein'):
monit_mitral[pname] = StateMonitor(mt.pop, pname, record=rec_mitral)
for pname in ('V_D', 's_syn', 's', 'T'):
monit_granule[pname] = StateMonitor(gr.pop, pname, record=True)
monit_mitral['spikes'] = SpikeMonitor(mt.pop, record=True)
Creating and running the network
In [16]:
nn = Network(mt.pop, gr.pop, [mgr for mgr in monit_granule.values()], [mmt for mmt in monit_mitral.values()],
graded_synapse, keep_reset)
nn.run(t_simu, report='text')
Granule membrane potential over time
In [17]:
figure()
plot(monit_granule['V_D'].times/msecond, monit_granule['V_D'][0]/mvolt)
xlabel('time (ms)')
ylabel('membrane potential of granule : V_D (mvolt)')
Out[17]:
Mitral membrane potential over time
In [18]:
figure()
for n in rec_mitral:
plot(monit_mitral['V'].times / msecond, monit_mitral['V'][n]/mvolt, label="mitral #"+str(n))
legend()
xlabel('time (ms)')
ylabel('membrane potential of mitral : V (mvolt)')
Out[18]:
s
and s_syn
from mitral and granule cells
In [19]:
figure()
plot(monit_mitral['s'].times/msecond, monit_mitral['s'][0], label="s mitral")
plot(monit_mitral['s_syn'].times/msecond, monit_mitral['s_syn'][0], label="s_syn mitral")
plot(monit_granule['s_syn'].times/msecond, monit_granule['s_syn'][0], label="s_syn granule")
plot(monit_granule['s'].times/msecond, monit_granule['s'][0], label="s granule")
legend()
xlabel('time (ms)')
ylabel('s mitral & s_syn granule & s granule')
Out[19]:
Raster plot
In [20]:
print 'Spikes of', N_mitral, ' mitral:', monit_mitral['spikes'].nspikes
raster_plot(monit_mitral['spikes'], newfigure=True)
In [21]:
show()