Source code for neurodynex.exponential_lif.expLIF

import brian2 as b2
import matplotlib.pyplot as plt
import numpy
from neurodynex.tools import input_factory

b2.defaultclock.dt = 0.05 * b2.ms

# default values.
MEMBRANE_TIME_SCALE_tau = 12.0 * b2.ms
MEMBRANE_RESISTANCE_R = 20.0 * b2.Mohm
V_REST = -65.0 * b2.mV
V_RESET = -60.0 * b2.mV
RHEOBASE_THRESHOLD_v_rh = -55.0 * b2.mV
SHARPNESS_delta_T = 2.0 * b2.mV

# a technical threshold to tell the algorithm when to reset vm to v_reset
FIRING_THRESHOLD_v_spike = -30. * b2.mV

[docs]def simulate_exponentialLIF_neuron( tau=MEMBRANE_TIME_SCALE_tau, R=MEMBRANE_RESISTANCE_R, v_rest=V_REST, v_reset=V_RESET, v_rh=RHEOBASE_THRESHOLD_v_rh, v_spike=FIRING_THRESHOLD_v_spike, delta_T=SHARPNESS_delta_T, I_stim=input_factory.get_zero_current(), simulation_time=200 * b2.ms ): eqs = """ dv/dt = (-(v-v_rest) +delta_T*exp((v-v_rh)/delta_T)+ R * I_stim(t,i))/(tau) : volt """ v_reset_str = "v={:f}*mvolt".format(v_reset / b2.mvolt) v_spike_str = "v>{:f}*mvolt".format(v_spike / b2.mvolt) # making neuron using Brian library neuron = b2.NeuronGroup(1, model=eqs, reset=v_reset_str, threshold=v_spike_str) # b2.reinit() # initialization of simulator neuron.v = v_rest # monitoring membrane potential of neuron and injecting current rec = b2.StateMonitor(neuron, ["v"], record=True) spike_monitor = b2.SpikeMonitor(neuron) # run the simulation b2.run(simulation_time) return rec, spike_monitor
[docs]def getting_started(): import neurodynex.tools.plot_tools as plot_tools input_current = input_factory.get_step_current(t_start=20, t_end=120, unit_time=b2.ms, amplitude=0.8 * b2.namp) state_monitor, spike_monitor = simulate_exponentialLIF_neuron(I_stim=input_current, simulation_time=180*b2.ms) plot_tools.plot_voltage_and_current_traces(state_monitor, input_current, title="step current", firing_threshold=FIRING_THRESHOLD_v_spike) print("nr of spikes: {}".format(spike_monitor.count[0]))
def _min_curr_expl(): from neurodynex.tools import plot_tools, input_factory durations = [1, 2, 5, 10, 20, 50, 100, 200] min_amp = [8.6, 4.45, 2., 1.15, .70, .48, 0.43, .4] i=1 t=durations[i] I_amp = min_amp[i]*b2.namp input_current = input_factory.get_step_current(t_start=10, t_end=10+t-1, unit_time=b2.ms, amplitude=I_amp) state_monitor, spike_monitor = simulate_exponentialLIF_neuron(I_stim=input_current, simulation_time=(t+20)*b2.ms) plot_tools.plot_voltage_and_current_traces(state_monitor, input_current, title="step current", firing_threshold=FIRING_THRESHOLD_v_spike, legend_location=2) print("nr of spikes: {}".format(spike_monitor.count[0])) if __name__ == "__main__": _min_curr_expl() # getting_started()