1. Transform your RC model from HW #1.2 into an integrateandfire (IAF) neuron model by adding a voltage threshold. Whenever the voltage crosses the threshold, set the voltage on that time step to +70 mV to represent the generation of an action potential, and then reset the voltage to 0 mV on the next time step to represent the repolarization phase of the action potential. 
(a) Using the following parameters: R=10 MOhm, C=1 nF, V_{thr}=5 mV, V_{spk}=70 mV, and a time step of 1 ms, simulate the response of the integrateandfire model using Euler integration. Generate a representative plot of the membrane voltage as a function of time for a step current injection with I=1 nA for 10 <= t < 60 ms and I=0 otherwise. Your graph should look similar to the attached plot. 
(b) Now examine the behavior of this
model as you change the magnitude of the injection current. Compute a firing
rate (spikes per second) by dividing the number of spikes by the duration
of the stimulus.
Generate a plot of "firing frequency vs. injected current"
for currents from 0 to 10 nA.
You'll need to determine a set of current injection values to use
(make the spacing fine enough to map out the threshold transition).
For each injection level, have your program count the number of spikes
in a 1second window to determine the firing rate (spikes/s).
Your graph should look similar to the attached plot. What is the minimum current that results in spike generation? Why does the firing rate saturate for large injection currents? 
(c) EXTRA CREDIT:
Repeat part (b), but now add random gaussian noise to the injected
current. Use Inoise=2*randn(size(t)) to generate a vector of noise
values with a standard deviation of 2 nA.
Graphically overlay a plot of firingfrequency versus injectedcurrent
on top of the noisefree case (use a different linestyle).
With 2 nA of noise, what is the minimum current that results in spike
generation?
VIEW SOLUTION
