matlab代写 – Python编程代做 – CCN Lab 1代写
Matlab代写价格

matlab代写 – Python编程代做 – CCN Lab 1代写

CCN Lab 1

Angus Chadwick January 2021 (Week 3)

 

 

matlab代写 In this tutorial you will learn to do the following:Implementa model of a single neuron in Matlab or PythonSimulatethe model numerically ···

 

Learning Outcomes  matlab代写

In this tutorial you will learn to do the following:

  • Implementa model of a single neuron in Matlab or Python
  • Simulatethe model numerically and plot the results
  • Interpretyour findings and their relevance to biology
  • Understandwhere analytical approximations may be used alongside numerical simulation and how the two approaches complement each other

Introduction

In this tutorial you will code and simulate a simple neuron model that we discussed at length in Lecture 4: the leaky integrate and fire neuron. You will see how the spike statistics and membrane potential dynamics of the model depend on the statistics of the input the neuron receives, and how analytical approximations can be made to understand this behaviour in limiting situations.

Getting Started matlab代写

Before starting, you will need to have a programming language of your choice installed on the com- puter you intend to use. This would typically be either Matlab or Python. You can download Matlab

for your personal computer using the university software licence here https://www.ed.ac.uk/information- services/computing/desktop-personal/software/main-software-deals/matlab/matlab-homeuse.

Python is fine if you are comfortable with using it already, but the specific information we provide in this tutorial will be based on Matlab.

Matlab Knowledge for This Tutorial  matlab代写

You will need to know how to use the following concepts in Matlab, or the equivalent in Python. If these are not familiar to you, you should to review the Matlab tutorial (on the course Learn page).

  • arrays(vectors and matrices, creating an array of zeroes)
  • indexing(calling elements of an array, find, logical indexing, )
  • loops(for and if-then, nested loops)
  • plot(and plotting commands such as hold on, subplot, xlim, ylim, )
  • histogram(plot histogram of data)
  • diff(difference between consecutive elements of a vector or array)
  • randomvariables (randn for normal distribution and rand for uniform distribution)
  • mathematicalfunctions (scalar addition, multiplication, exp, )

Part 1: Setting up the Model for Passive Dynamics  matlab代写

We first consider how to numerically simulate the passive membrane potential dynamics of a simple neuron model – the leaky integrate and fire neuron.

The membrane potential of the leaky integrate and fire model obeys the following equation while below spiking threshold:

dV

τ dt  (V  Em) + Iext/gm

  • Write a short script to solve this equation numerically using the Euler method1. To do this,you will need to first write lines of code which assign values to the parameters (τ, Em, Iext, gm), the number of iterations Nt, the timestep δt. You should also create an array of size [Nt + 1, 1] to store the values of the membrane potential2. You will then need a for loop to fill in the entries of this

AND  matlab代写

Choose Nt = 10000 and δt = 0.1ms, giving a total simulation time of 1 s. Run a simulation from the initial condition V = Em, with model parameters τ = 10ms, Em = 70mV , gm = 1, and Iext = 20. Check that your simulation runs without returning any errors and, if so, plot the membrane potential as a function of time. Inspect the plot – did the simulation run as expected? How can you tell?

  • Try varying the input current, time constant, and initial condition3. How does each affect themembrane potential?
  • Forvarious parameter choices, find the steady-state membrane potential (make sure to check that the neuron has reached steady state by the end of your simulation). How does the steady-state membrane potential vary as you change the input current? What about time constant or initial condition?
  • Can you find an analytical equation for the steady state membrane potential based on theequationbeing simulated? Does it agree with your numerical simulation?

1Review lecture 3 if you need a refresher on the Euler method

2After Nt iterations you will have Nt + 1 time points  matlab代写

3It may help if you modify the code to allow you to simulate the model under multiple parameter values in one

  1. Oneway to do this is to write a for loop around your simulation that iterates over parameters (although for

loops are inefficient in Matlab – if you convert the set of equations into a vector equation it will run faster). You can create a membrane potential array of size [Nt + 1, Nparameters] and store all the simulations in this array.

Part 2: Incorporating Spiking Into the Model  matlab代写

Next, we will add spikes to the model and see how these change its behaviour. To model spikes, we add the following spike-reset rule: if V (t)  Vthreshold then we immediately set V (t Vreset.

  • Modify your code to include this spike-reset rule.To do this, you can add an if-then loop inside your loop over time steps. You will also need to store spike times for later use.
  • Set Vthreshold=    50mV , Vreset =    75mV . Try running the simulation with different values of input current and time constant and plotting the membrane potential in each case. How does each parameter influence the spiking activity?
  • For each choice of parameters, compute the interspike intervals from the stored spike times(if any). Plot the interspike interval against input current. Now do the same for the spike  Review the analytical expression for the f-I curve derived in lecture 4 – do your simu- lations agree? (you can compare the numerical and analytical results both qualitatively and quantitatively)

Part 3: Adding Noise to the Input  matlab代写

We now consider what happens when the neuron is driven by noisy, fluctuating input. We will initially return to the case of purely passive dynamics, as in Part 1. You can modify your spiking code to do this is by setting Vthreshold = Inf, which will ensure that the neuron never spikes.

We will model the noisy input as Iext(t) = I0 + σξ(t), where ξ(t) is a normally distributed random variable with zero mean and unit variance drawn independently at each timestep 45.

  • Trysimulating with σ = 50 and different values of I0. Plot the membrane potential for each input current value. Based on these plots, how would you expect this noise to influence spiking?
  • Now repeat these simulations with the spike-reset rule included (set Vthreshold= 50mV again). Compute the f-I curve by dividing the total number of spikes by the simulation time for each value of I0. Plot the f-I curve – how does it compare to the noise-free case? What is the explanation for the change in f-I curve?

AND  matlab代写

  • Try varying both I0and σ. Compute interspike interval distributions for different choices of these  Make histograms of the interspike interval distribution for simulations with various parameter values (use histogram in Matlab). How does the shape of the distribution depend on the input parameters? (You can increase the number of simulation timesteps if you need to get a higher sample size)
  • If the spiking of the neuron were to follow a Poisson distribution, the interspike intervals wouldbe exponentially distributed as p(tISI ) = rertISI , where r Nspikes/(Ntδt) is the spike

4In Matlab, use randn to generate the noise. If you prefer, you can sample the full time series of input noise in advance using randn([Nt, 1])

5When simulating a continuous noise process in discrete time, one has to also scale the variance by δt by setting

σ δtσ, otherwise the noise will grow larger as the timestep is made smaller.  Here we will keep the time step

fixed and sidestep this issue

Do the spike times in any of your simulations appear to be Poisson distributed? Under what conditions might your simulations become approximately Poisson? Check if this is true by comparing the histogram of inter-spike intervals to an exponential probability distribution with the same rate.

Part 4: Conductance-Based Synaptic Input  matlab代写

We next replace the above current input with a conductance-based synaptic input Iext gsyn(t)(V Esyn). We will use a model gsyn

(t) = w Σ  e(tt(i))syn   with t(i) the presynaptic spike times.

  • Considera scenario in which there is a single presynaptic spike at time t(1) = 100ms. To model an inhibitory synaptic input, set Esyn = 80mV , τsyn = 2ms, w = 5 and simulate the membrane potential for a period of 1s 6. To simulate an excitatory synaptic input, set Esyn = 0mV and repeat the  How did the effects of the inhibitory and excitatory synaptic input differ? How might the reversal potential Esyn and synaptic weight w play different contributions in determining the influence of synaptic input on the membrane potential under more physiological conditions?

AND  matlab代写

  • Now consider a barrage of presynaptic spikes with times generated from a Poisson process.Generate presynaptic spike times over a time window of duration T = 1s with spike rate r = 1000Hz (see lecture notes for how to simulate a Poisson process). Now use these spike times to compute the synaptic conductance gsyn(t) (try using w = 0.1, Esyn = 0mV , τsyn = 2ms). Simulate the membrane potential of the neuron driven by these input spikes (you can try with or without the spike-reset rule enabled). Try varying rw, and Esyn. How does this influence the statistics of the subthreshold and/or spiking activity of the neuron?
  • Under what conditions does a Poisson distribution become approximately a Gaussian distri-bution? Based on this, under what conditions would you expect that the conductance-based Poisson input will become well-approximated by the current-based Gaussian noise input as considered in Part 3? Based on your knowledge of the brain, do you think that real neurons are in that regime? Why/why not?

6hint: The membrane potential and input are now coupled differential equations. To numerically integrate, use the Euler method, at each timestep updating voltage based on the current in previous timestep and then updating current based on the updated voltage.

 

更多代写:OS操作系统 GMAT考试代考 history代写 HRMessay代写  paper代写 贝叶斯代写

合作平台:天才代写 幽灵代  写手招聘  paper代写

发表回复