Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit


COMS30017 Coursework exam 2021/22


Overview

This coursework exam will have two main parts: data analysis (part 1) and modelling (part 2). The modelling part will also contain two sub-parts: Associative networks (part 2.1) and Integrate and fire neurons (part 2.2). Write a brief report, including the figures and the comments specified. No need to be verbose, just say what you are asked to say. Use at least 2 cm margins and 10 pt fonts. You can use whatever programming language you like (and it won't affect your mark), however we will only support Python in the QA sessions. And Python would probably be the easiest. Submit both your report and code. Do not put them together in a zip file or similar. Submit the report as pdf; make sure to set the size of the graphs in your plotting program, not by shrinking the graph to fit in the reprt, this makes the figure legends and axis numbers tiny and is super annoying. And don't use screenshots as your figures. All plots should have clear x- and y-axis labels, and units. Marks will be docked for every plot that has missing or unclear labels, or looks like a screenshot. To help you decide which results to include in your report, I will encode meaning in my text colour and formatting. If a sentence is in red italics, I expect to see a written response. For sentences formatted bold I expect to see a plot. Most sections have a basic part and an advanced part. Doing all the basic parts (implementing what you are asked to do correctly, generating the plots, etc) will get you reasonable mark, perhaps up to 〜60%. To get a higher mark you will also need to answer the advanced parts well, which require some thinking and further analysis. Other logistic information is included at the end of this document.

1 Data analysis [30 marks]

This part will focus on analysing some fictional spike train data and the randomdot motion task.

1.0.1 Question 1 [10 marks]

In the data folder associated with the coursework, you will find a file called neuron A data.csv. Load this file, for example using the python command np.loadtxt('neuron A.csv', delimiter=','). This contains a set of spike times from a fictional neuron, in milliseconds.

Compute the coefficient of variation (CV) for the inter-spike intervals. Also compute the Fano factor for time bins of 100 ms, 200 ms, 500ms and 1 s (start the first bin at 0 ms, so the first bin runs from 0-100 ms, 0-200 ms etc.) State the values of both the CV and Fano factor in your report. Now load the file trial ID.csv, which contains an array of zeros and ones. Assume that the spike times above came from a neuron recorded from the visual cortex of a monkey during a series of sequential trials, each lasting one second long. So trial 4 lasts from t = 3000 to t = 3999, trial 18 lasts from t = 17000 to t = 17999, and so on. The corresponding trial IDs are given by the values in the trial ID array. trial id = 0 corresponds to a random-dot visual stimulus where there was no net motion. trial id = 1 corresponds to a moving random-dot stimulus. Now separate the spike times corresponding to trials where trial id =0 and trials where trial id = 1. Compute the CV and Fano factors again separately on the data corresponding to each trial type. For Fano factor, use the same time bins as before. For the CV, just include spike intervals for pairs within the same time bin (exclude spike pairs that span across bins). State the values you find in your report. Do these values differ from what you found above on the total data? Offer an explanation for why or why not.

1.0.2 Question 2 [10 marks]

Now you will decode the stimulus from the spike data using the procedure described in week 3 video 5. You will work with the spike counts. Count the number of spikes on each trial, and plot histograms of the spike count for the stimulus off and stimulus on trials. Compute the d! value for these data. Now write a function to do the decoding. It should take as input a spike count from a single trial, and the decision boundary. If the spike count is greater than the decision boundary, predict the motion stimulus (1), if it is less than the boundary, predict the no-motion stimulus (0). Then run the decoder on all the trials in the dataset, multiple times for various values of the decision boundary between 0 and 40 spikes/trial. Call a correct detection of a motion stimulus a ‘true positive', a correct detection of no-motion stimulus a ‘true negative'. Make a plot overlaying three curves: the true positive rate, the true negative rate, and the total correct rate, all as a function of the decision boundary value. Note that random guessing would correspond to a total correct rate of 50%. Comment on what you observe in the plots. If we wanted to maximise the total fraction of correct responses, what would you estimate the optimal decision boundary to be? Explain how this relates to the count histograms you calculated above.

1.0.3 Question 3 [10 marks]

Now load the other data file neuron B data. This contains spike times from another neuron simultaneously recorded during the same task. Compute the d! value for these data. Recompute the true-positive rate, true-negative rate, and total correct rate for neuron B as a function of the decision boundary and plot the three together on a graph, as you did before for neuron A. Now let's try to decode the stimulus from the joint activity from the pair of neurons. Let xa and xb correspond to single-trial spike counts from neurons A and B respectively. Write a function to decode the stimulus value from a single trial
spike count pair (xa, xb), using the following rule:

if xa — xb — 4 > 0 otherwise

Apply this function to the spike data to decode the stimulus state on each trial. Report the total correct rate you find using this joint rule. Com- ment on how this compares with the best decoding accuracy you found for the individual neurons above. Offer an explanation for what you observe, including additional plots if necessary to support your explanation.

2 Modelling [70 marks]

2.1 Auto-associative networks [30 marks]

This part is on Hopfield networks.

2.1.1 Question 1 [10 marks]

Begin by loading the partial Fashion MNIST dataset stored in the files trai^images.csv and test_images.csv (originally taken from github.com/zalandoresearch/fashion- mnist). The total dataset consists of three training patterns and two test patterns. Each individual image is actually a 784-element array of +ls and -1s, corresponding to pixels in a 28x28 image. You can visualise the images using a command like plt.imshow(np.reshape(x,(28,28))). The values of the weights in a Hopfield network are zero on-diagonal,

wn = 0 (2)

and off-diagonal, they are given by,

wi=j = N £ xi xj

a

x is the activation of the ith node in the ath pattern, and N is the total number of training patterns (here, N = 3). You should:

• Create a weight matrix of Wjs.

• Fix the weight values to store the three training patterns. Plot the weight matrix as a 784 x 784 image.

• Write a function to evolve the network according to the McCulloch- Pitts formula; this should be done asynchronously, so one random node is update each timestep. Assume the threshold 0 = 0.

• For each of the two test patterns, evolve the patterns until they stop changing. For each case make plots of the network state at timesteps 0, 1000, and 3000.

2.1.2 Question 2 [10 marks]

Now write a function to calculate the energy of a configuration

Re-run the two test plot simulations, recording the energy value at each iteration. For each case, make plots of the energy as a function of timestep number. Describe what the plots show. Explain in your own words why this happens, referring to the network update equation or energy equation if needed.

2.1.3 Question 3 [10 marks]

Now we will examine the network's “basins of attraction”. Write a function that when given a pair of images A and B, can generate a mixed image which has p% of the pixels from image A and the remaining (100 — p)% pixels from image B. For each of three pairs of images in the training set, compute such mixed images, varying p in increments between 0 and 100%, and compute the energy of the mixed image at each increment. Plot the energy as a function of the mixing fraction p, overlaid for each of the three pairs of images. Comment on the relative shapes of the three curves. List some predictions for the model dynamics based on these curves, explaining your reasoning in each

case.

2.2 Integrate-and-fire neurons [40 marks]

This part will look at integrate-and-fire neurons and short-term plasticity.

2.2.1 Question 1 [7 marks]

Make a simulation of a single leaky-integrate-and-fire neuron. Set the resting potential VTest = El = —70 mV, spike threshold Vth = —50 mV, reset voltage VTeset = —60 mV, a passive membrane leak conductance gL = 10nSiemens, and a membrane capacitance of C = 0.3nF. Use:

9l(El — V (t)) + Ie (5)

Set the injected current Ie = 0.21 nA. Use Euler's method with timestep 况= 0.1 ms to solve the differential equations numerically. Make sure to use the differential equations, do not just plot the analytical solution for V(t) given in the lectures — this will be useless for later questions anyway. For simplicity assume that the neuron does not have a refractory period after producing a spike. You do not need to plot spikes — once the membrane potential exceeds threshold, simply set the membrane potential to Preset. To keep track of the units I recommend converting everything to S.I. units inside your simulation code — you don't strictly have to do this but it often makes things easier. Set the initial voltage value V(t = 0) to a random number between VTest and Vth. Run the simulation for one second and plot the voltage as a function of time. Now run the simulation for ten seconds, for various levels of injected input current Ie between 0 nA and 0.5 nA, and computing the spike frequency



in each case. Plot the spike frequency as a function of the input current (the ‘f-I, curve). Analytically calculate the threshold input current and report its value.

2.2.2 Question 2 [8 marks]

Now turn off the background input current, Ie = 0. Add N = 100 total incoming synapses, split into two equal sized groups, (Ni = 50, N = 50). We will make these groups have different firing rates. You should just model the synaptic responses to spike trains, do not explicitly simulate the somatic voltages of these presynaptic neurons. Model all synapses as a conductance-based, following a single-exponential timecourse with decay time constant ts = 2 ms, the peak conductances (strengths) all S = 0.5 nanoSiemens for all synapses, E = 0, and As = 1. Let Si(t = 0) = 0 for all 100 synapses. It's probably easier to store them all in arrays and update them together, rather than code each one by hand. Again use the Euler method to solve the system of ODEs (100 s variables and 1 voltage variable), with the same timestep 况=0.1 ms. Simulate each input spike train as an independent homogeneous Poisson process with the same average firing rate r. A homogeneous Poisson process implies that average firing rate r is fixed in time, but that the spikes themselves arrive randomly. Initially set the rate for group 1 ri = 10 Hz and the rate for group 2 r? = 100 Hz. There are multiple ways to simulate Poisson spike trains. One simple method is to draw a random number on the unit interval for each synapse at every timestep, then if that number is less than r况,assume a spike has occurred at that synapse. This method is valid as long as r况《1. Simulating your model at this stage should result in the neuron firing irregularly. Plot the neuron's voltage for one second of simulation time. Now run the simulation for ten seconds, for various levels of ri and r? separately between 0 Hz and 150 Hz, and compute the spike frequency in each case. When varying ri, keep r? fixed at 100Hz. When varying r?, keep ri fixed at 10Hz. Plot the output spike frequency as a function of the input spike frequency, overlaid for both cases. Describe what is shown in the plots and offer an explanation for the shapes of the curves.

2.2.3 Question 3 [10 marks]

Now we will make the mean firing rate for each group vary sinusoidally in time:

r(t) = r + B sin(2nft) (6)

where r is the average firing rate. The amplitude of the oscillation depends on the parameter B, while the timescale of oscillations depends on /. Fix / = 2 Hz, ri = 10 Hz, r? = 100 Hz. Running the simulation for 1 s in each case, make plots of the voltage as a function of time, for two different scenarios (visualised in the left and centre panels in the figure below):

• Bi = 0 Hz and B? = 50 Hz.

• Bi = 5 Hz and B? = 0 Hz.

Describe what you see in the plots. What was the mean firing rate of the neuron in each case, as averaged over a 30 second simulation? Note that the mean total input firing rate (averaged over time) is the same in both cases, and also
identical to that used in question 2. Explain why the three different cases lead to different output firing rates.

2.2.4 Question 4 [15 marks]

Now implement short-term depression at each synapse. Introduce an additional variable A for each synapse, so that the total synaptic conductance will be gi(t) = Ai (t)si(t)gi. A is going to represent the effects of short-term depression. Every time a spike arrives at the ith synapse, set Ai — aAi, where a = 0.75. In between spikes, let Ai recover back towards 1 by letting it follow the differential equation with ta = 300 ms. Also change all the synaptic strengths to g = 3nS (to counter the effects of depression). Now repeat the two simulations from Q3 but with synaptic depression turned on. In this case run the simulation for 1 second first to let it ‘settle down', then run it for a further 3 seconds to observe the steady-state dynamics. Make plots of the voltage as a function of time in each case. Describe what you observe, and compare it to the plots obtained in Question 3. Offer an explanation for what is going on. You can make extra plots if they support your argument. Finally, run the simulation with synaptic depression still on, but with Bi = 0 Hz and B2 = 5 Hz (visualised in the right panel of the above figure). Again run the simulation for 1 second warmup plus a further 3 seconds. Make a plot of the voltage vs time. Describe the results and and offer an explanation for what you observe, commenting on how it compares with the previous two plots.

Logistical information

This coursework is for Computational Neuroscience (Teaching unit: COMS30017, Coursework unit: COMS30063) and is worth 15 credit points.

The coursework will be released on Monday 22 November (Week 9) at 9am and must be submitted by Friday 10 December (Week 11) at 1pm at the very latest. The intention is that you submit by 12pm and keep the last hour as emergency reserve for e.g. technical problems. In case of problems with your submission, you must e-mail [email protected] before the 1pm final deadline to avoid your work being counted as late.

You must submit the coursework on the Blackboard page for the assessment unit COMS30063 (not the teaching unit COMS30017). On the assessment unit, go to the menu item “Assessment, Submission and Feedback” and follow the instructions there.

You are expected to work on both your courseworks in the 3-week period from Week 9 to Week 11 as if it were a working week in a regular job, that is 5 days a week for no more than 8 hours a day. It is up to you how you distribute your time and workload between the two units within those constraints. You are strongly advised not to try and work excessive hours during the coursework period: this is more likely to make your health worse than to make your marks better. If you need further pastoral/mental health support, please talk to your personal tutor, a senior tutor, or the university wellbeing service.

The coursework will be supported in Q&A sessions at 12-1 Mondays.

This coursework is individual work. You must not collaborate with other students, which would be considered cheating.

Mark scheme

mark range

criteria

100-80

All plots completed and correct

Excellent presentation

Outstanding critical analysis and discussion of results

Evidence of study and originality well beyond what has been taught

70-79

All plots completed and correct

Excellent presentation

Good critical analysis and discussion of results

Some evidence of study and originality beyond what has been taught

60-69

Almost all plots completed and correct

Good presentation

Some critical analysis and discussion of results

50-59

Most plots completed and correct Coherent presentation

Some discussion of results

40-49

Some plots completed and correct

Coherent presentation

Attempt at discussion of results

0-39

Insufficient plots completed and correct. Understandable presentation

Little or no discussion of results

Broadly speaking, marks above 〜60 require not only most plots completed and correct, but also critical analysis and discussion of the results.

What does this mean? Computational neuroscience is a science. In science, we don't just compute numbers and make plots. Those numbers and plots are supposed to tell us something about the brain. So for the highest marks, it is important to think about the following issues when answering the written parts:

• do the numbers/plots we've computed make sense?

• what do the numbers/plots tell us about the underlying system?

• do the numbers/plots really capture what we want them to capture? (e.g. is FF/CV a “good” measure of variability?)