[1]:
%load_ext autoreload
%autoreload 2
Event Related Potentials (ERPs)¶
Getting Started¶
Please Note this tutorial is a work in progress. Not all features from the original HNN-GUI are reproduced here.
In order to understand the workflow and initial parameter sets provided with this tutorial, we must first briefly describe prior studies that led to the creation of the provided data and evoked response parameter set that you will work with. This tutorial is based on results from our 2007 study where we recorded and simulated tactile evoked responses source localized to the primary somatosensory cortex (SI) 1.
In our 2007 study, we investigated the early evoked activity (0-175 ms) elicited by a brief tap to the D3 digit and source localized to an an equivalent current dipole in the contralateral hand area of the primary somatosensory cortex (SI) 1. The strength of the tap was set at either suprathreshold (100% detection probability) or perceptual threshold (50% detection) levels (see Figure 1, left panel below). Note, to be precise, this data represents source localized event related field (ERF) activity because it was collected using MEG. We use the terminology ERP for simplicity, since the primary current dipoles generating evoked fields and potentials are the same.
We found that we could reproduce evoked responses that accurately reflected the recorded waveform in our neocortical model from a layer specific sequence of exogenous excitatory synaptic drive to the local SI circuit, see Figure 1right panel below. This drive consisted of “feedforward” / proximal input at ~25 ms post-stimulus, followed by “feedback” / distal input at ~60 ms, followed by a subsequent “feedforward” / proximal input at ~125 ms (Gaussian distribution of input times on each simulated trial). This sequence of drive generated spiking activity and intracellular dendritic current flow in the pyramidal neuron dendrites to reproduce the current dipole signal. This sequence of drive can be interpreted as initial “feedforward” input from the lemniscal thalamus, followed by “feedback” input from higher order cortex or non-lemniscal thalamus, followed by a re-emergent leminsical thalamic drive. Intracranial recordings in non-human primates motivated and supported this assumption 2.
In our model, the exogenous driving inputs were simulated as predefined trains of action potentials (pre-synaptic spikes) that activated excitatory synapses in the local cortical circuit in proximal and distal projection patterns (i.e. feedforward, and feedback, respectively, as shown schematically in Figure 1 right, and in the HNN GUI Model Schematics). The number, timing and strength (post-synaptic conductance) of the driving spikes were manually adjusted in the model until a close representation of the data was found (all other model parameters were tuned and fixed based on the morphology, physiology and connectivity within layered neocortical circuits 1. Note, a scaling factor was applied to net dipole output to match to the magnitude of the recorded ERP data and used to predict the number of neurons contributing to the recorded ERP (purple circle, Figure 1, right panel). The dipole units were in nAm, with a one-to-one comparison between data and model output due to the biophysical detail in our model.
Adapted from Jones et al. 2007 1. Comparison of SI evoked response in experiment and neural model simulation. Left: MEG data showing tactile evoked response (ERP) source localized to the hand area of SI. Red: suprathreshold stimulation; Blue: Threshold stimulation (avg. n=100 trials). Right: Neural model simulation depicting proximal/distal inputs needed to replicate the ERP waveform (avg. n=25 trials)
In summary, to simulate the SI evoked response, a sequence of exogenous excitatory synaptic drive was simulated (by creating presynaptic spikes that activate layer specific synapses in the neocortical network) consisting of proximal drive at ~25 ms, followed by distal drive at ~60 ms, followed by a second proximal drive at ~122 ms. Given this background information, we can now walk you through the steps of simulating a similar ERP, using a subset of the data shown in Figure 1.
Launch GUI¶
There are two ways you can launch the new GUI: 1. Standalone: execute hnn-gui
in the terminal and access the GUI with your favorite browser. 2. Jupyter notebook: 1. Create a jupyter notebook in a environment with hnn-core[gui]
installed. 2. Import HNNGUI
and show it with its compose
method.
Here we adopt the second one for the demonstration purpose. In practice you may find the former more convenient.
[2]:
import time
from hnn_core.gui.gui import HNNGUI
from ipywidgets import Output
from IPython.display import Javascript
# do not mix this with GUI operatiXons
gui = HNNGUI(total_width=1000, total_height=600)
[3]:
# In practice, set return_layout to false to show the dashboard
# gui.compose()
gui.compose(return_layout=False)
[4]:
gui.capture()
Load/view parameters to define network structure & to “activate” the network¶
An initial parameter set that will simulate an evoked response in close agreement with the SI data described in Step 1 in this tutorial can be downloaded using the following hyperlink: ERPYes100Trials.param.
But before uploading files, we need to first clear existing drives:
[5]:
gui._simulate_left_tab_click("External drives")
[6]:
gui.capture()
[7]:
gui.delete_drive_button.click()
[8]:
gui.capture(width=1000, height=600)
Once you have this param file downloaded and existing drive deleted, upload the file to the GUI through the Load connectivity
button under “Cell connectivity” tab and Load drives
under “Drices” tab.
[9]:
param_url = "https://raw.githubusercontent.com/jonescompneurolab/hnn/master/param/ERPYes100Trials.param"
gui._simulate_upload_connectivity(param_url)
gui._simulate_upload_drives(param_url)
After uploading, you’ll notice that drives in ERPYes100Trials.param
have been successfully added to the new GUI.
[10]:
gui.capture()
You can also view all cell connectivity paramters, i.e., weight and connectivity probability, in the Cell connectivity
tab:
[11]:
gui._simulate_left_tab_click("Network connectivity")
[12]:
gui.capture()
Running the simulation and visualizing net current dipole¶
Now that we have an initial parameter set, we can run a series of simulations (3 trials) that will produce the output shown below.
To do so, first we need to set Trials
to 1
.
[13]:
gui.widget_ntrials.value = 1
gui._simulate_left_tab_click("Simulation")
[14]:
gui.capture()
Now let’s click the “Run” button to launch the simulation.
[15]:
gui.run_button.click()
After simulation, you can immediately find simulation results (dipoles) at the right side of the GUI. In the figures below, the thin gray traces are dipole signals from individual trials while the green trace is the average ERP. In the left panel, the aggregated dipole data is plotted while in the right panel layer-specific dipole data are also shwon so you can check the contribution per layer.
[16]:
gui.capture()
Viewing network spiking activity¶
By selecting “spikes” from dropdown menus, you can check the spiking activity produced in each population in response to the evoked inputs.
[17]:
gui._simulate_viz_action(
"edit_figure",
"Figure 1",
"ax1",
"default",
"spikes",
{},
"plot"
)
[18]:
gui.capture()
Viewing ERP Spectrograms¶
Next, you can click the ‘Make figure’ button to create another figure and show thespectrogram there.
[19]:
gui._simulate_viz_action('switch_fig_template', 'single figure')
gui._simulate_viz_action('add_fig')
gui._simulate_viz_action(
"edit_figure",
"Figure 2",
"ax0",
"default",
"spectrogram",
{},
"plot"
)
[20]:
gui.capture()
Adjusting parameters¶
Parameter adjustments will be key to developing and testing hypotheses on the circuit origin of your own ERP data. HNN is designed so that many of parameters in the model can be adjusted from the GUI. Here, we’ll walk through examples of how to adjust several “Evoked Input” parameters to investigate how they impact the evoked response.
References¶
- 1(1,2,3,4)
Jones, S. R., Pritchett, D. L., Stufflebeam, S. M., Hämäläinen, M. & Moore, C. I. Neural correlates of tactile detection: a combined magnetoencephalography and biophysically based computational modeling study. J. Neurosci. 27, 10751–10764 (2007).
- 2
Cauller, L. J. & Kulics, A. T. The neural basis of the behaviorally relevant N1 component of the somatosensory-evoked potential in SI cortex of awake monkeys: evidence that backward cortical projections signal conscious touch sensation. Exp. Brain Res. 84, 607–619 (1991).
[21]:
# # change drive parameters is not very intuitive but that's all we can do for now.
# # example:
# idx = 1
# gui.drive_boxes[idx].children # use this line to identify the correct drive box
# gui.drive_widgets[idx]['tstart'] = 500 # use this line to change value
[ ]:
[22]:
Javascript(gui.run_notebook_cells())
[22]: