def getting_started(): """ An example to quickly get started with the LIF module. Returns: """ # specify step current step_current = input_factory.get_step_current(t_start=10, t_end=190, unit_time=b2.ms, amplitude=20 * b2.namp) # run the LIF model (state_monitor, spike_monitor) = simulate_LIF_neuron(input_current=step_current, simulation_time=200 * b2.ms) # plot the membrane voltage plot_tools.plot_voltage_and_current_traces(state_monitor, step_current, title="Leaky Integrate-and-Fire Neuron", firing_threshold=FIRING_THRESHOLD) print("nr of spikes: {}".format(len(spike_monitor.t))) plt.show() # second example: sinusoidal current. note the higher resolution 0.1 * b2.ms sinusoidal_current = input_factory.get_sinusoidal_current( 500, 1500, unit_time=0.1 * b2.ms, amplitude=2.5 * b2.namp, frequency=150 * b2.Hz, direct_current=2. * b2.namp) (state_monitor, spike_monitor) = simulate_LIF_neuron( input_current=sinusoidal_current, simulation_time=200 * b2.ms) plot_tools.plot_voltage_and_current_traces( state_monitor, sinusoidal_current, title="Sinusoidal input current", firing_threshold=FIRING_THRESHOLD) print("nr of spikes: {}".format(spike_monitor.count[0])) plt.show()
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_exponential_IF_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) plt.show() print("nr of spikes: {}".format(spike_monitor.count[0]))
def getting_started(): """ An example to quickly get started with the LIF module. Returns: """ # specify step current step_current = input_factory.get_step_current( t_start=100, t_end=200, unit_time=b2.ms, amplitude=1.2 * b2.namp) # run the LIF model (state_monitor, spike_monitor) = simulate_LIF_neuron(input_current=step_current, simulation_time=300 * b2.ms) # plot the membrane voltage plot_tools.plot_voltage_and_current_traces(state_monitor, step_current, title="Step current", firing_threshold=FIRING_THRESHOLD) print("nr of spikes: {}".format(len(spike_monitor.t))) plt.show() # second example: sinusoidal current. note the higher resolution 0.1 * b2.ms sinusoidal_current = input_factory.get_sinusoidal_current( 500, 1500, unit_time=0.1 * b2.ms, amplitude=2.5 * b2.namp, frequency=150 * b2.Hz, direct_current=2. * b2.namp) # run the LIF model (state_monitor, spike_monitor) = simulate_LIF_neuron( input_current=sinusoidal_current, simulation_time=200 * b2.ms) # plot the membrane voltage plot_tools.plot_voltage_and_current_traces( state_monitor, sinusoidal_current, title="Sinusoidal input current", firing_threshold=FIRING_THRESHOLD) print("nr of spikes: {}".format(spike_monitor.count[0])) plt.show()
def testIt(): # specify step current step_current = only_input_step_current(t_start=100, t_end=600, unit_time=b2.ms, amplitude=1.2 * b2.mamp) # run the LIF model M = simulate_WORM_neuron(input_current=step_current, simulation_time=1000 * b2.ms) # plot the membrane voltage plt.plot(M.t / b2.ms, M.v[0], label='Neuron 0') plt.plot(M.t / b2.ms, M.v[1], label='Neuron 1') #plot_tools.plot_voltage_and_current_traces(state_monitor, step_current,title="Step current") plt.show() sinusoidal_current = input_factory.get_sinusoidal_current( 200, 800, unit_time=b2.ms, amplitude=2.5 * b2.mamp, frequency=5 * b2.Hz, direct_current=2. * b2.namp) # run the LIF model state_monitor = simulate_1_WORM_neuron(input_current=sinusoidal_current, simulation_time=1000 * b2.ms) # plot the membrane voltage plot_tools.plot_voltage_and_current_traces( state_monitor, sinusoidal_current, title="Sinusoidal input current") plt.show()
def getting_started(): """ Simple example to get started """ from neurodynex.tools import plot_tools current = input_factory.get_step_current(10, 200, 1. * b2.ms, 65.0 * b2.pA) state_monitor, spike_monitor = simulate_AdEx_neuron(I_stim=current, simulation_time=300 * b2.ms) plot_tools.plot_voltage_and_current_traces(state_monitor, current) plot_adex_state(state_monitor) print("nr of spikes: {}".format(spike_monitor.count[0]))
def getting_started(): """ A simple example """ 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_exponential_IF_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])) plt.show()
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_exponential_IF_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) plt.show() print("nr of spikes: {}".format(spike_monitor.count[0]))
def getting_started(): """ Simple example to get started """ from neurodynex.tools import plot_tools current = input_factory.get_step_current(10, 200, 1. * b2.ms, 500 * b2.pA) ic = input_factory.get_zero_current() state_monitor, spike_monitor = simulate_AdEx_neuron(I_stim=current, simulation_time=300 * b2.ms) # plot_tools.plot_network_activity(rate_monitor, spike_monitor, state_monitor) # plt.show() plot_tools.plot_voltage_and_current_traces(state_monitor, current, title="AdEx neuron simulations") plt.show() plot_adex_state(state_monitor) print("nr of spikes: {}".format(spike_monitor.count[0]))
from neurodynex.tools import plot_tools, input_factory """ MEMBRANE_TIME_SCALE_tau_m = 5 * b2.ms MEMBRANE_RESISTANCE_R = 500*b2.Mohm V_REST = -70.0 * b2.mV V_RESET = -51.0 * b2.mV RHEOBASE_THRESHOLD_v_rh = -50.0 * b2.mV SHARPNESS_delta_T = 2.0 * b2.mV ADAPTATION_VOLTAGE_COUPLING_a = 0.5 * b2.nS ADAPTATION_TIME_CONSTANT_tau_w = 100.0 * b2.ms SPIKE_TRIGGERED_ADAPTATION_INCREMENT_b = 7.0 * b2.pA """ current = input_factory.get_step_current(10, 250, 1. * b2.ms, 65.0 * b2.pA) # Variare l'adaptation voltage coupling influisce sul numero di spikes # Il bursting si ottiene cambiando il valore del reset del potenziale, ovviamente # in tal modo ti posizioni in un altro punto dello spazio delle fasi # "a" cambia anche la posizione dei punti di equilibrio a seconda della positività o negatività state_monitor, spike_monitor = AdEx.simulate_AdEx_neuron(I_stim=current, simulation_time=400 * b2.ms, a=-0.5 * b2.nS, v_reset=-46 * b2.mV) plt.figure(1) plot_tools.plot_voltage_and_current_traces(state_monitor, current) print("nr of spikes: {}".format(spike_monitor.count[0])) plt.figure(2) AdEx.plot_adex_state(state_monitor) plt.show()
resistance = self.resistance if (threshold == None): threshold = self.threshold eqs = "dv/dt = (-(v-v_rest) +delta_t*exp((v-rheo_threshold)/delta_t)+ resistance * current(t,i))/(time_scale) : volt" neuron = b2.NeuronGroup(1, model=eqs, reset="v=v_reset", threshold="v>threshold", method="euler") neuron.v = v_rest voltage_monitor = b2.StateMonitor(neuron, ["v"], record=True) spike_monitor = b2.SpikeMonitor(neuron) net = b2.Network(neuron, voltage_monitor, spike_monitor) net.run(time) return voltage_monitor, spike_monitor lif_neuron = expLIF() print('7 repetitive spikes : current = 0.8 nA') 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 = lif_neuron.simulate(current=input_current, time=200 * b2.ms) plot_tools.plot_voltage_and_current_traces( state_monitor, input_current, title="step current", firing_threshold=lif_neuron.threshold) print("nr of spikes: {}".format(spike_monitor.count[0]))
durations = [1, 2, 5, 10, 20, 50, 100] min_amp = [0., 4.42, 0., 1.10, .70, .48, 0.] t = durations[i] I_amp = min_amp[i] * b2.namp title_txt = "I_amp={}, t={}".format(I_amp, t * b2.ms) 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 = exp_IF.simulate_exponential_IF_neuron( I_stim=input_current, simulation_time=(t + 20) * b2.ms) plt.figure(1) plot_tools.plot_voltage_and_current_traces( state_monitor, input_current, title=title_txt, firing_threshold=exp_IF.FIRING_THRESHOLD_v_spike, legend_location=2) print("nr of spikes: {}".format(spike_monitor.count[0])) plt.figure(2) plt.plot(durations, min_amp) plt.title("Strength-Duration curve") plt.xlabel("t [ms]") plt.ylabel("min amplitude [nAmp]") plt.show()