Tutorial 3: loading spike times from previous simulation runs

In this tutorial, we will use VERTEX’s spike loading functionality to simulate LFPs in a network from previously generated spike times. VERTEX can do this in two ways. Firstly, a VERTEX simulation can be run with spike times generated by the network, and these spike times can then be re-loaded into the simulation so that the LFP can be re-generated using the same spike times, but purely passive neurons. This is useful for checking results from simulations using AdEx neurons: the AdEx mechanism can influence the measured LFP in potentially un-biological ways (see Fig ESM1 in the supplementary material for Tomsett et al. 2014). The extent of this influence will depend on the size of the network, the strength of the synaptic currents, and the network dynamics.


Load parameters and run the simulation

We will use the same model as in tutorial 2. We have stored the parameters for this model in a Matlab script called tutorial_3_params.m, so first we will load this script:


You may want to change the save directory:

RecordingSettings.saveDir = '~/VERTEX_results_tutorial_3/';

Next we will create the network, run the simulation, load the results, and plot the spike raster and LFPs:

[networkParams, connections, electrodes] = ...
  initNetwork(TissueParams, NeuronParams, ConnectionParams, ...
                    RecordingSettings, SimulationSettings);

runSimulation(networkParams, connections, electrodes);
Results = loadResults(RecordingSettings.saveDir);

rasterParams.colors = {'k', 'm'};
rasterParams.groupBoundaryLines = 'c';
rasterParams.title = 'Tutorial 3 Spike Raster (original)';
rasterParams.xlabel = 'Time (ms)';
rasterParams.ylabel = 'Neuron ID';
rasterParams.figureID = 1;
rasterFigure1 = plotSpikeRaster(Results, rasterParams);

plot(Results.LFP', 'LineWidth', 2)
set(gcf, 'color', 'w');
title('Tutorial 3: LFP at all electrodes (with AdEx neurons)','FontSize',16)
xlabel('Time (ms)', 'FontSize', 16)
ylabel('LFP (mV)', 'FontSize', 16)

Tutorial 3 spike raster 1

Tutorial 3 LFP 1

Re-running the simulation with loaded spikes

We want to keep all aspects of the simulation the same, but now use the previously calculated spike times with passive neurons. We can therefore keep our parameter structures the same, but alter the neuron model. Note that the initNetwork function groups our parameter structures together for input to the runSimulation function, so we need to access the parameter structures within this previously returned structure:

networkParams.NeuronParams(1).neuronModel = 'passive';
networkParams.NeuronParams(2).neuronModel = 'passive';

Next we tell VERTEX to load the previously generated spike times from the output directory of the previous simulation run. We set the spikeLoad parameter to an array containing the IDs of all the neurons we want to load the spike times of. For the moment, we want to load spikes from all 5000 neurons:

networkParams.SimulationSettings.spikeLoad = 1:5000;

If we don’t set the SimulationSettings.spikeLoadDir parameter, then VERTEX will load spikes from the RecordingSettings.saveDir directory. However, VERTEX will output its results to this same directory, overwriting the previous simulation’s saved files. We therefore change these locations:

networkParams.SimulationSettings.spikeLoadDir = ...
networkParams.RecordingSettings.saveDir = ...

Re-run the simulation

We want to run the simulation again using the same network, so we don’t call initNetwork again, just runSimulation:

runSimulation(networkParams, connections, electrodes);
Results = loadResults(networkParams.RecordingSettings.saveDir);

We then plot the results from this re-run. The spike raster should be identical to the spike raster we plotted in figure 1, while the LFP should show some small differences.

rasterParams.title = 'Tutorial 3 Spike Raster (spike load)';
rasterParams.figureID = 3;
rasterFigure2 = plotSpikeRaster(Results, rasterParams);

plot(Results.LFP', 'LineWidth', 2)
set(gcf, 'color', 'w');
title('Tutorial 3: LFP at all electrodes (with passive neurons)','FontSize',16)
xlabel('Time (ms)', 'FontSize', 16)
ylabel('LFP (mV)', 'FontSize', 16)

Tutorial 3 spikes 2

Tutorial 3 LFP 2

Re-run the simulation with a sub-set of the loaded spikes

We can also re-run our simulation using a subset of neurons. This can be useful for investigating the influence of a particular presynaptic neuron type on the total LFP, for example.

For this simulation run we’ll load just the pyramidal neurons’ spikes. We can find out the boundary IDs of the groups by looking at the groupBoundaryIdArr field in the TissueParams structure returned by the initNetwork function:


groupBoundaryIDArr stores the boundary IDs for each group in order. To get the IDs for all neurons in group 1, then, we do:

group1IDs = networkParams.TissueParams.groupBoundaryIDArr(1)+1 : ...

We then set the SimulationSettings.spikeLoad parameter to these IDs:

networkParams.SimulationSettings.spikeLoad = group1IDs;

… and set a new save directory:

networkParams.RecordingSettings.saveDir = ...

Now we can rerun the simulation with just pyramidal neuron spikes loaded

runSimulation(networkParams, connections, electrodes);
Results = loadResults(networkParams.RecordingSettings.saveDir);

rasterParams.title = 'Tutorial 3 Spike Raster (spike load, group 1)';
rasterParams.figureID = 5;
rasterFigure3 = plotSpikeRaster(Results, rasterParams);

plot(Results.LFP', 'LineWidth', 2)
set(gcf, 'color', 'w');
set(gca, 'FontSize', 16);
title('Tutorial 3: LFP at all electrodes (just group 1 spikes)','FontSize',16)
xlabel('Time (ms)', 'FontSize', 16)
ylabel('LFP (mV)', 'FontSize', 16)

Tutorial 3 spikes 3

Tutorial 3 LFP 3

In the next tutorial, we will look at how to pre-specify spike times to load into the network rather than generating them in a simulation using spiking neurons.


Tomsett RJ, Ainsworth M, Thiele A, Sanayei M, Chen X et al. (2014) Virtual Electrode Recording Tool for EXtracellular potentials (VERTEX): comparing multi-electrode recordings from simulated and biological mammalian cortical tissue, Brain Structure and Function. doi:10.1007/s00429-014-0793-x