Analyzing Large-Scale Neural Probe Data with NVIDIA GPU-Accelerated MATLAB
By Vijay Iyer and Andy Thé, MathWorks
For decades, scientists studying brain activity at the level of individual brain cells have only been able to record from a few dozen neurons at a time. Since there are typically more than 10,000 neurons relating to a single functional area of the brain, these recordings have provided no more than a glimpse of the activity within local brain circuits.
Neuropixels probes (Figure 1) are a new class of device based on silicon fabrication technology that will change this, enabling neuroscientists to record activity from hundreds of individual neurons simultaneously. These breakthrough probes have been developed via a collaboration between the Howard Hughes Medical Institute, the Allen Institute of Brain Science, the Gatsby Charitable Foundation, and the Wellcome Trust. Early adopters of these new silicon probes are undertaking pilot experiments to better map brain circuits. In the process, they’re getting an early glimpse of a new challenge soon to face neuroscientists: managing datasets nearly 100x larger than they’ve encountered before—on the order of 100 gigabytes for a single experiment.
One early adopter, neuroscientist Dr. Marius Pachitariu, recognized that dealing with these large datasets would require two key advances: more automation and acceleration with GPUs. Dr. Pachitariu and colleagues at University College London (UCL) subsequently created Kilosort, an open-source MATLAB® application for implementing semi-automated, NVIDIA® GPU-accelerated data processing pipelines.
Analysis Results Acquired in Hours Instead of Weeks
Using MATLAB, Dr. Pachitariu developed a new algorithm that sped up processing by 25x compared with previous approaches. He then turned to off-the-shelf NVIDIA GPUs, such as the GeForce GTX 1080 Ti, to accelerate key steps, such as signal preprocessing and template feature extraction. Using a single GPU-equipped workstation led to a further speedup of about 40x. Overall, his prototype cut the processing time for 50 GB (30 minutes of recorded silicon probe data) from two weeks to just 20 minutes. This increase in analysis speed enabled researchers to run experiments, analyze results, adjust parameters, rerun experiments, and generate new results in hours instead of waiting weeks between each iteration.
Detecting Neural Activity
When a neuron sends an impulse, the resulting change in electrical potential is called an action potential, or spike, a brief event lasting approximately one millisecond. This action potential propagates not only forward to other neurons, but also back through the neuron’s input branches (the dendritic tree). As a result, spikes from each individual neuron produce a unique pattern of electrical field deflections spread along the various channels of the electrical probe (Figure 2). By spike sorting—examining the duration, amplitude, and shape of signals at each electrical probe channel—neuroscientists can identify the electrical signature of spikes from individual neurons and infer the timing of spikes from individual neurons.
Before Neuropixels probes, researchers seeking to record spikes from hundreds of neurons turned to optical imaging techniques. These techniques report on spikes only indirectly, by measuring an increase in calcium ion concentration that occurs when neurons fire. These optical techniques have key limitations: They can neither readily reach deep regions in the brain nor match the millisecond temporal precision of neural probe recordings. Optical approaches still offer the highest density recordings from the greatest number of neurons (more than 1000), but the Neuropixels probes close that gap with nearly 1000 available recording sites spaced 20 µm apart.
The Need for Speed
When the Neuropixels probe expanded the number of recording sites from a handful to hundreds, it underscored the impracticality of manual methods. Dr. Pachitariu and his team needed a more effective spike sorting method capable of clustering in the thousands.
He set out to create a new method to achieve this speedup with three ideas in mind: creating algorithms that leveraged NVIDIA GPUs, simplifying algorithms to avoid possible bias, and minimizing design iterations. They were able to implement several GPU operations directly within MATLAB using gpuArray
, a high-level construct in Parallel Computing Toolbox™. Kilosort required additional custom GPU operations, which the researchers implemented with custom CUDA kernels and called directly from MATLAB.
Accelerating Spike Sorting Nearly 1000-Fold
Kilosort is designed to process in vivo electrophysiological recordings captured across hundreds of electrode channels, typically at a sampling rate of 25 kHz. A single action potential spike shows up as simultaneous signals on several electrodes. One way to visualize this data is to plot the channels as a function of time, with each deflection in the plot representing signal peaks arising from a neuron’s action potential (Figure 3).
Kilosort preprocesses the recorded data by applying a high-pass Butterworth filter. Next, it applies an iterative clustering algorithm that repeatedly performs a two-step process: identifying a pattern of signal shapes and then finding instances of these patterns in the raw data (Figure 4). The second part of the loop—determining at what times each identifiable signal pattern appears in the data—is performed on an NVIDIA GPU with 3584 cores using custom CUDA kernels integrated into MATLAB. The algorithm continues to optimize its templates until the original recorded data set can be accurately reconstructed by assembling these individual signal patterns at the detected spike times. Kilosort enables the user to remove false positives.
It took the team just two weeks to develop the core algorithm for Kilosort in MATLAB. Once they saw that the algorithm produced results nearly 1000 times faster than existing spike-sorting software, and with the same level of accuracy, they spent several more weeks validating the algorithm against different datasets and making it easier for other researchers to use.
Future Developments
Neuropixels probes have been publicly released ahead of the 2018 annual Society for Neuroscience meeting, and demand from researchers is already outstripping supply. Neuroscientists worldwide will soon begin to electrically map the function of a wide variety of brain circuits at this unprecedented scale. For analyzing their large volumes of data, they can turn to Kilosort.
Dr. Pachitariu and his collaborators are currently working on an automated drift correction algorithm to help improve accuracy when the subject is engaged in an activity such as running, which tends to make the probe move. This new algorithm is also GPU-accelerated, sequentially solving thousands of small clustering problems for each two-second batch of data to determine at what depth that batch was recorded. Accurate drift correction is the next major step toward fully automated spike sorting and will be included into the upcoming Kilosort2 software.
Published 2018