Site icon Neurofrontiers

Analyzing a virtual neuron – part 1

A construction site for the brain, with a partly constructed brain viewed from the front right side. The brain is suspended on scaffolding and the frontal part of the right lobe is missing. On the left of the brain, there is a large black computer. The brain is hooked to the computer through wires, and the wires run further along to the right side of the image, where we see a monitor displaying some EEG traces and some circuits. In between the brain and the monitor is a large white scaffolding, with a TMS coil hanging from it. In front of the monitor there is a green man holding a neuron and an ion channel, and in front of the man, there is a toolbox with ions and neurons. The background color is purple-ish?

Image credit: Ionut Stefan

Last time we dealt with virtual neurons in The Practical Corner, we went through the full implementation of the Hodgkin-Huxley model. To recap, it was quite painful we had so much fun building a realistic model of action potentials, and learning all about capacitors, voltage-dependent gating variables, and how the interplay between fast sodium channels, delayed activation of potassium channels, and a steady leak current produce the characteristic neuronal spike.

The HH model is simultaneously complex and relatively simple. It’s a complex model because, as we’ve seen, it has a set of 4 differential equations. That means it’s not possible to analyze analytically (i.e., work out a solution to the equations on paper). It’s also a bit tricky to analyze numerically (i.e., through simulations) because there are a lot of parameters that influence its behavior (by parameters, I mean the stuff for which we chose some fixed values last time). At the same time, it’s a simple model because it doesn’t take into account the geometry of the neuron (for example, that the dendrites behave differently compared to the axon) and it only has two types of ion channels.

If we were guided by a specific practical task instead of pure learning joy, this is the point where we might consider choosing another model. But remember, there is no such thing as a perfect model, and whatever we can learn by analyzing the HH model will be transferable to other similar tasks. So for the time being, we’ll stick with it.

An ocean of data

Going through the model implementation feels at times like barreling through a violent waterfall. Making it on the other side is as if the free ocean suddenly stretches out in front of you. Except the ocean is raw data and you’re now lost at sea with no land in sight. Who said computational neuroscientists can’t be poets, right?

To give you a more concrete example: if you remember from last time, our model didn’t spike all on its own. It had to be driven by an external input current, which can take pretty much any value (yes, including negative ones; and as we’ll see in an upcoming tutorial, different shapes too). A reasonable question to ask here is: will the neuron react in the exact same way to these different inputs? In the image below, you’ll find a clue. We’re looking at the membrane voltage (in blue) over a period of 500 ms in response to an external current that takes values between 0 and 160 μA/cm2 applied from 100 to 400 ms.

It’s pretty obvious that the answer is no. But, dear reader, we’ve packed 160 plots in here. What if we want to look at even more values? Or more shapes? Or what if we want to vary one of the conductance values at the same time as the external input? Even if we look at a measly 10 conductances, that’s 1600 individual cases. You get the point. Don’t get me wrong, inspecting individual traces can come in handy, but clearly we need a better way to sail through this ocean.

Information will be lost

In essence, we need to find a way to summarize the information from above. Typically, we do that by using various metrics, which give us one (or a couple of) numbers describing our cases. For example, we might choose to look at the amplitude of the signal – the difference between the maximum and the minimum values of the voltage. Or we might look at the frequency – the number of spikes per second. Or any other number of measures that capture some aspect of our signal.

But how to choose them? To be perfectly honest, there’s no clear rulebook for that. Usually, you need to think carefully about what you want to get out of your analysis. And that will vary a lot from task to task. In today’s example, our main goal is to highlight the fact that the behavior of the neuron changes in response to increasing depolarization (higher external inputs). We also want to quantify that by using metrics that are easy to follow and that can be quickly spotted in the animation above. That’s why we’re choosing amplitude and frequency. If we wanted a more fine-grained understanding of depolarization effects on sodium and potassium channel dynamics separately, we would have to consider other metrics as well.

A key factor that you have to bear in mind is that, no matter what summary metric you choose, some information will always be lost. And because of that, you need to think about what it is that you’re discarding: is it important? If so, you should consider adding an additional metric sensitive to that. Again, an example. In the two traces below, the amplitude of the membrane voltage is almost identical: 126.9 mV vs 126.3 mV, but the behavior is very different.

Amplitude alone can never tell us the full picture here. (As a side note: frequency is also not good at distinguishing between bursting, i.e. grouped spikes, and tonic behavior, i.e. roughly equally spaced spikes.) So if we were interested in that, we would need to use a metric that tells us about the spacing between these spikes.

Intuition

Of course, these are just some basic, carefully chosen examples. In practice, things will not always be so trivial, so the eternal question remains: “how am I supposed to know what to choose?”. Well, as all good things, it comes with time and with experience. By working through increasingly more complicated examples, you will one day reach the much-touted “intuition”.

Fair warning: on this journey, you might sometimes hear more experienced researchers provide “explanations” through the magic phrase “it’s intuitive”, only for you to spend ungodly amounts of time trying to figure out this “intuitive” solution. To save you mountains of guilt and self-doubt: “it’s intuitive” is code for “it’s intuitive to me because I’ve solved this a thousand times and I’ve forgotten what it’s like not to have the knowledge, but it’s, in fact, not intuitive at all”.

Pre-analysis considerations

With that in mind, here are a couple of “intuitive”, self-implied tidbits that you won’t necessarily find in a textbook, or at least not in so many words.

Transients

In dynamical systems (such as our spiking neuron), there are some temporary states called transients. As a more tangible example, imagine that you drop a ball into a bowl (try saying that ten times fast). It’ll eventually settle in the middle, but beforehand, it’ll roll around for a bit. The “roll-around time” is the transient. The ball exists in a temporary state, before it settles down into a so-called attractor, i.e. the center of the bowl, where it’s no longer moving.

In our virtual neuron, the attractor might be a stable resting voltage (fixed point) or ongoing repetitive firing (limit cycle). The path the system takes before reaching that steady behavior is the transient.

Later, you’ll learn there are many kinds of attractors and a lot of research devoted to them. You’ll also learn that in numerical simulations, detecting when a transient is “over” isn’t always trivial. For now, the key message is simple: when we analyze a system, we usually want to measure it after it has settled into its attractor, not while it’s still in the transient phase.

Be specific

That brings me to the second “intuitive” tidbit: you have to be specific about what you’re doing. Here’s an example of what not to do: in today’s analysis, we will discard as a transient the first 200 ms. At first glance, it might sound clear, right? Except… 200 ms from when? From the start of the simulation? After the current turns on? After your third coffee kicks in? Without details, no one can reproduce the experiment, including you six months from now.

Here’s the correct version: in today’s analysis, we will simulate the membrane voltage of an HH model with default parameters for 1000 ms. We will apply an external input current with varying strength from 0 – 160 μA/cm2 in steps of 1, from 100 ms to 900 ms of the simulation, and we will discard the first 200 ms after stimulus onset to exclude transient effects. On this data, we will compute the amplitude of the membrane voltage as the maximum minus the minimum of the voltage signal, and the frequency or firing rate as the number of spikes per second, where a spike is defined as an upward crossing of the membrane voltage of -55 mV (if the voltage does not return below -55 mV between events, no spikes are counted). The code to follow along can be found here.

Justify your choices

We’ve already highlighted above that there a lot of metrics to choose from and that you should think about why you’re picking one over the other. We’ve explained why we went for amplitude and frequency. But another point to consider in terms of choices is that, quite often, you will see there are multiple ways of computing the same metric.

In our case, there are lots of options for getting the frequency of a signal. We’ve opted to count the spikes and divide that by the time interval to get the firing rate in Hz. This method is easy to follow and, for the clean periodic spiking in the HH model, it’s very accurate. Another option would be to use a Fourier transform, which decomposes the signal into sine waves at different frequencies and tells you how much “energy” is at each one. While powerful, it’s less straightforward for sharp, brief events like spikes, and especially if the spiking isn’t perfectly regular, because the spectrum will include many harmonics and may smear the fundamental frequency.

Finally, keep in mind that the purpose here isn’t to be defensive. Instead, by considering what the strengths and weaknesses of your choices might be, you will get a clearer picture of what your results mean and you might even end up reconsidering your initial picks and using something more suitable instead.

The results

It took us a while, but finally, we got our results. These two plots are a lot easier to read than the animation we started with. Here is what we can clearly see now:

Don’t forget the biology

We could spend a long time analyzing virtual neurons and losing ourselves in their peculiar behaviors, but we shouldn’t forget the bigger picture: eventually, the point of all this is to model and to understand biological systems.

The sharp jump in frequency which we just saw is a called a “type II” response. (This is in contrast to type I responses, where there is a smooth increase in frequency when the external stimulus is increased.) But does that have any biological meaning? Are there any real neurons that behave like that? After all, our model is a simplification.

As it turns out, yes, type II neurons are quite important, particularly for reliably detecting inputs and for precise timing in circuits. Being able to respond with strong firing rather than a few lazy spikes here and there seems to be crucial for these tasks. And importantly, our understanding of type II neurons in real circuits comes from painstaking experimental work, not just models. Modeling doesn’t exist in a vacuum.

Finally, accounting for the biology means keeping in mind the biological constraints too. If we were to inject a current of 135 μA/cm2 into a real neuron, would we really see such high-frequency, low amplitude oscillations? Most likely not, because the neuron would be toast. That’s why using biological plausibility to limit the parameter space is a key part of building models that are more than just mathematical toys.

That’s all for today, see you next time.

What did you think about this post? Let us know in the comments below. And if you’d like to support our work, feel free to share it with your friends, buy us a coffee here, or even both.

Subscribe to our RSS feed here.

You might also like:

Exit mobile version