Skip to content

Instantly share code, notes, and snippets.

@lebedov
Created March 3, 2015 21:57
Show Gist options
  • Save lebedov/043f89a7185cbe259f76 to your computer and use it in GitHub Desktop.
Save lebedov/043f89a7185cbe259f76 to your computer and use it in GitHub Desktop.
Morris-Lecar neuron model implemented using Brian.
#!/usr/bin/env python
"""
Morris-Lecar neuron model implemented using Brian.
"""
import numpy as np
import matplotlib
matplotlib.use('agg')
from brian import *
I = 200*uamp
# Parameters from Rinzel & Ermentrout: Analysis of Neural Excitability and
# Oscillations, ch.7 (pp. 251-292) in
# Methods in Neural Modeling: From Ions to Networks, 2nd Ed., 1998.
C = 20.0*uF
VL = -60.0*mV
VCa = 120.0*mV
VK = -84.0*mV
gCa = 4.4*msiemens
gK = 8.0*msiemens
gL = 2.0*msiemens
V1 = -1.2*mV
V2 = 18.0*mV
V3 = 2.0*mV
V4 = 30.0*mV
phi = 0.04/ms
model = Equations("""
dV/dt=(I-gL*(V-VL)-gCa*Minf*(V-VCa)-gK*N*(V-VK))/C : volt
dN/dt=(Ninf-N)*TauN : 1
Minf=(1+tanh((V-V1)/V2))/2.0 : 1
Ninf=(1+tanh((V-V3)/V4))/2.0 : 1
TauN=phi*cosh((V-V3)/(2*V4)) : 1/second
""")
dt = 0.1*ms
g = NeuronGroup(1, model=model, clock=Clock(dt=dt))
# Initial state values:
g.V = -10.0*mV
g.N = (1+tanh((g.V-V3)/V4))/2.0
# Execute model:
state_mon = MultiStateMonitor(g, record=True)
dur = 300*ms
run(dur)
# Visualize results:
subplot(211)
plot(state_mon['V'].times/ms, state_mon['V'][0]/mV)
xlabel('t (ms)')
ylabel('V (mV)')
title('Membrane Potential')
subplot(212)
plot(state_mon['N'][0], state_mon['V'][0])
xlabel('N')
ylabel('V')
title('Phase Portrait')
tight_layout()
savefig('ml.png')
@Nedaeepour
Copy link

Hi sir,

thanks a lot fo code.
How can I find input Data for this code?

@lebedov
Copy link
Author

lebedov commented Jul 29, 2020

What do you mean by "input"? If you are referring to the neuron's input current I (which is set to a constant), that's up to you to decide depending upon what you are trying to simulate.

@Nedaeepour
Copy link

Nedaeepour commented Jul 29, 2020 via email

@lebedov
Copy link
Author

lebedov commented Jul 31, 2020

You need to decide what sort of input to provide the neuron based upon what the goal of your simulation is; you may wish to take a look at Brian's tools for input stimulus generation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment