Project E: Large-scale neural data
Hundreds of neurons recorded at once from a mouse's visual cortex, downloaded free. Spike sorting, quality metrics, tuning curves, and the population view that Phase 3's decoders were pointing at.
On this pageTwo to three weekends
The Allen Brain Observatory recorded thousands of neurons across the mouse visual system with NeuropixelsNeuropixels Silicon probes with hundreds to thousands of recording sites along a thin shank, the current standard for large-scale animal recording. Related: Spike sortingSpike sorting Deciding which spikes on an electrode came from which neuron, by clustering their waveform shapes.. Glossary entry probes while the animals watched images and movies, and put all of it online with a Python SDK. It is the largest, cleanest, best-documented electrophysiology dataset there is, and an undergraduate can load it in an afternoon. Working with it is how you learn what “a population of neurons” means, what spike sortingSpike sorting Deciding which spikes on an electrode came from which neuron, by clustering their waveform shapes. Related: SpikeSpike Shorthand for an action potential as seen by an electrode, a brief blip about a millisecond wide. , NeuropixelsNeuropixels Silicon probes with hundreds to thousands of recording sites along a thin shank, the current standard for large-scale animal recording. . Glossary entry produces and how much to trust it, and why the decodersDecoder The algorithm that maps neural signals to intended actions, such as a classifier or a Kalman filter. Related: ClassifierClassifier An algorithm that assigns each trial a label, such as left hand or right hand, after being trained on labelled examples. , Kalman filterKalman filter An estimator that blends a prediction from a motion model with a noisy measurement, weighting each by how much it trusts it; the decoder behind most intracortical cursor control. , Brain-computer interface (BCI)Brain-computer interface (BCI) A system that turns measured brain activity into control of something outside the body, from a cursor to a wheelchair to a speech synthesizer. . Glossary entry in Phase 3 work at all.
A Neuropixels probe has 384 recording sites along a 1 cm shank. Roughly how many well-isolated neurons does one insertion yield?
A few hundred, typically 200 to 400 after quality filtering. Each neuron’s spikeSpike Shorthand for an action potential as seen by an electrode, a brief blip about a millisecond wide. Related: Action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. , Spike sortingSpike sorting Deciding which spikes on an electrode came from which neuron, by clustering their waveform shapes. , Extracellular recordingExtracellular recording Recording with an electrode near neurons rather than inside one; you see small, fast blips from nearby cells rather than the full membrane swing. . Glossary entry appears on several neighbouring sites, and each site hears several neurons; spike sortingSpike sorting Deciding which spikes on an electrode came from which neuron, by clustering their waveform shapes. Related: SpikeSpike Shorthand for an action potential as seen by an electrode, a brief blip about a millisecond wide. , NeuropixelsNeuropixels Silicon probes with hundreds to thousands of recording sites along a thin shank, the current standard for large-scale animal recording. . Glossary entry untangles them and discards the units it cannot isolate. The count depends on the brain region and the sorting criteria, and the criteria are where honest analysis begins.
Get the data
The AllenSDK gives you a session as an object: spikeSpike Shorthand for an action potential as seen by an electrode, a brief blip about a millisecond wide. Related: Action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. , Spike sortingSpike sorting Deciding which spikes on an electrode came from which neuron, by clustering their waveform shapes. , Extracellular recordingExtracellular recording Recording with an electrode near neurons rather than inside one; you see small, fast blips from nearby cells rather than the full membrane swing. . Glossary entry times per unit, unit quality metrics, stimulus presentation times, running speed, pupil size, and the LFPLocal field potential (LFP) The slow, summed electrical activity of many neurons near an electrode, below a few hundred hertz, as opposed to individual spikes. Related: Electroencephalography (EEG)Electroencephalography (EEG) Recording the brain's electrical activity from electrodes on the scalp, a few tens of microvolts of blurred, summed cortical activity. , Extracellular recordingExtracellular recording Recording with an electrode near neurons rather than inside one; you see small, fast blips from nearby cells rather than the full membrane swing. . Glossary entry. Start with one session from the “Brain Observatory 1.1” NeuropixelsNeuropixels Silicon probes with hundreds to thousands of recording sites along a thin shank, the current standard for large-scale animal recording. Related: Spike sortingSpike sorting Deciding which spikes on an electrode came from which neuron, by clustering their waveform shapes. . Glossary entry dataset.
from allensdk.brain_observatory.ecephys.ecephys_project_cache import EcephysProjectCache
cache = EcephysProjectCache.from_warehouse(manifest='./ecephys_cache/manifest.json')
sessions = cache.get_session_table()
session = cache.get_session_data(sessions.index[0])
units = session.units # one row per sorted unit with quality metrics
spikes = session.spike_times # dict: unit id -> array of spike times in seconds
Trust, but verify the units
Each unit comes with metrics: signal-to-noise, ISI violation rate (how often two spikesSpike Shorthand for an action potential as seen by an electrode, a brief blip about a millisecond wide. Related: Action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. , Spike sortingSpike sorting Deciding which spikes on an electrode came from which neuron, by clustering their waveform shapes. , Extracellular recordingExtracellular recording Recording with an electrode near neurons rather than inside one; you see small, fast blips from nearby cells rather than the full membrane swing. . Glossary entry are closer than a neuron can fire, which means two neurons got merged), presence ratio, amplitude cutoff. FilterFilter An operation that passes some frequencies and attenuates others; every filter also delays or distorts the timing of what it passes. Related: High-pass filterHigh-pass filter Removes slow drifts and DC offsets, passing everything above a cutoff; set it too high and you erase slow brain activity. , Low-pass filterLow-pass filter Removes fast content above a cutoff; the anti-alias filter is one, and so is the smoothing you apply to a noisy trace. , Notch filterNotch filter A very narrow filter that removes one frequency, usually 60 Hz mains hum; it also rings and distorts nearby content, so fix the hum at the source first. , Phase distortionPhase distortion Different frequencies being delayed by different amounts, which smears and shifts waveforms such as an ERP peak. . Glossary entry with the standard thresholds, then look at a few units’ waveforms and autocorrelograms yourself. A unit with a clean refractory gap in its autocorrelogram is a neuron. One without is a mixture. The practice of looking is what separates people who analyze spikeSpike Shorthand for an action potential as seen by an electrode, a brief blip about a millisecond wide. Related: Action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. , Spike sortingSpike sorting Deciding which spikes on an electrode came from which neuron, by clustering their waveform shapes. , Extracellular recordingExtracellular recording Recording with an electrode near neurons rather than inside one; you see small, fast blips from nearby cells rather than the full membrane swing. . Glossary entry data from people who analyze spreadsheets.
Tuning curves
Take the drifting-gratings stimulus: eight directions, several temporal frequencies. For each unit and each direction, count spikesSpike Shorthand for an action potential as seen by an electrode, a brief blip about a millisecond wide. Related: Action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. , Spike sortingSpike sorting Deciding which spikes on an electrode came from which neuron, by clustering their waveform shapes. , Extracellular recordingExtracellular recording Recording with an electrode near neurons rather than inside one; you see small, fast blips from nearby cells rather than the full membrane swing. . Glossary entry in the stimulus window across repeats and average. Plot rate against direction. Some units have a clear preferred direction (a peak), some are orientation-selective (two peaks, 180 degrees apart), some are flat. Compute an orientation selectivity index. Plot the distribution across a few hundred units. You have reproduced the classical physiology of visual cortex from public data in an afternoon.
The population
Now stop looking at one neuron. Build a matrix: trials by neurons, each entry the spikeSpike Shorthand for an action potential as seen by an electrode, a brief blip about a millisecond wide. Related: Action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. , Spike sortingSpike sorting Deciding which spikes on an electrode came from which neuron, by clustering their waveform shapes. , Extracellular recordingExtracellular recording Recording with an electrode near neurons rather than inside one; you see small, fast blips from nearby cells rather than the full membrane swing. . Glossary entry count in a window. Run principal component analysis on it. The first few components capture most of the variance; the population’s activity lives on a low-dimensional manifold. Colour the trials by stimulus direction in the space of the first three components and watch them separate. Train a linear decoderDecoder The algorithm that maps neural signals to intended actions, such as a classifier or a Kalman filter. Related: ClassifierClassifier An algorithm that assigns each trial a label, such as left hand or right hand, after being trained on labelled examples. , Kalman filterKalman filter An estimator that blends a prediction from a motion model with a noisy measurement, weighting each by how much it trusts it; the decoder behind most intracortical cursor control. , Brain-computer interface (BCI)Brain-computer interface (BCI) A system that turns measured brain activity into control of something outside the body, from a cursor to a wheelchair to a speech synthesizer. . Glossary entry (LDALinear discriminant analysis (LDA) A simple, robust classifier that draws a straight boundary between classes; the workhorse of EEG decoding for two decades. Related: ClassifierClassifier An algorithm that assigns each trial a label, such as left hand or right hand, after being trained on labelled examples. . Glossary entry, from Phase 3) to predict direction from the population vectorPopulation vector A way to read out intended movement direction by adding up the preferred directions of many motor cortex neurons, weighted by how fast each is firing. Related: DecoderDecoder The algorithm that maps neural signals to intended actions, such as a classifier or a Kalman filter. , Rate codeRate code The idea that a neuron carries information in how many spikes per second it fires. . Glossary entry, with honest cross-validationCross-validation Testing a model on data it never saw during training, repeatedly, so the reported accuracy means something. Related: Data leakageData leakage Information from the test set sneaking into training, for example by shuffling trials from one session across both; it inflates accuracy and is the most common flaw in student BCI papers. , OverfittingOverfitting A model that has memorized its training data, including its noise, and fails on anything new. . Glossary entry by trial block. Then reduce the number of neurons and plot accuracy against neuron count. That curve is the argument for recording more neurons, and it is why NeuropixelsNeuropixels Silicon probes with hundreds to thousands of recording sites along a thin shank, the current standard for large-scale animal recording. Related: Spike sortingSpike sorting Deciding which spikes on an electrode came from which neuron, by clustering their waveform shapes. . Glossary entry exist.
LFP versus spikes
The same probe recorded the local field potential. Plot its spectrogramSpectrogram A spectrum computed over sliding windows and plotted against time, showing how frequency content changes. Related: Wavelet transformWavelet transform A time-frequency analysis that uses short wiggles at high frequencies and long ones at low, matching the trade-off to the frequency. , SpectrumSpectrum A plot of how much of a signal lives at each frequency. . Glossary entry around stimulus onset alongside the population firing rate. See the gamma increase during visual stimulation and its relation to spiking. This is the same relationship you will need in Phase 6 when intracortical recordingsIntracortical recording Recording from tiny electrodes inserted into the cortex itself, close enough to hear individual neurons. Related: Utah ArrayUtah Array The 10-by-10 grid of 1.5 mm silicon needles invented at the University of Utah, the electrode in nearly every human intracortical BCI study to date. , Extracellular recordingExtracellular recording Recording with an electrode near neurons rather than inside one; you see small, fast blips from nearby cells rather than the full membrane swing. . Glossary entry offer you both.
Spike sorting yourself
The Allen units are already sorted. To see what sorting does, take a raw NeuropixelsNeuropixels Silicon probes with hundreds to thousands of recording sites along a thin shank, the current standard for large-scale animal recording. Related: Spike sortingSpike sorting Deciding which spikes on an electrode came from which neuron, by clustering their waveform shapes. . Glossary entry recording (SpikeInterface’s tutorials point to short public ones), run Kilosort or Mountainsort through SpikeInterfaceSpike sorting Deciding which spikes on an electrode came from which neuron, by clustering their waveform shapes. Related: SpikeSpike Shorthand for an action potential as seen by an electrode, a brief blip about a millisecond wide., NeuropixelsNeuropixels Silicon probes with hundreds to thousands of recording sites along a thin shank, the current standard for large-scale animal recording.. Glossary entry, compute the same quality metrics, and look at what the sorter got right and what it merged or split. An hour with a raw recording teaches humility about every spikeSpike Shorthand for an action potential as seen by an electrode, a brief blip about a millisecond wide. Related: Action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. , Spike sortingSpike sorting Deciding which spikes on an electrode came from which neuron, by clustering their waveform shapes. , Extracellular recordingExtracellular recording Recording with an electrode near neurons rather than inside one; you see small, fast blips from nearby cells rather than the full membrane swing. . Glossary entry-based result you will ever read.
- Install AllenSDK, download one session, and list its units with quality metrics.
- FilterFilter An operation that passes some frequencies and attenuates others; every filter also delays or distorts the timing of what it passes. Related: High-pass filterHigh-pass filter Removes slow drifts and DC offsets, passing everything above a cutoff; set it too high and you erase slow brain activity. , Low-pass filterLow-pass filter Removes fast content above a cutoff; the anti-alias filter is one, and so is the smoothing you apply to a noisy trace. , Notch filterNotch filter A very narrow filter that removes one frequency, usually 60 Hz mains hum; it also rings and distorts nearby content, so fix the hum at the source first. , Phase distortionPhase distortion Different frequencies being delayed by different amounts, which smears and shifts waveforms such as an ERP peak. . Glossary entry units by standard thresholds. Plot ten waveforms and autocorrelograms and judge them.
- Compute direction tuning curves for all units and the distribution of selectivity.
- Build the trials-by-neurons matrix, run PCA, plot trials in component space coloured by direction.
- Decode direction with LDALinear discriminant analysis (LDA) A simple, robust classifier that draws a straight boundary between classes; the workhorse of EEG decoding for two decades. Related: ClassifierClassifier An algorithm that assigns each trial a label, such as left hand or right hand, after being trained on labelled examples. . Glossary entry, cross-validated by block. Plot accuracy against neuron count.
- Run a spikeSpike Shorthand for an action potential as seen by an electrode, a brief blip about a millisecond wide. Related: Action potentialAction potential The brief, all-or-nothing voltage spike a neuron fires, about a millisecond long and about 100 millivolts tall across its membrane. , Spike sortingSpike sorting Deciding which spikes on an electrode came from which neuron, by clustering their waveform shapes. , Extracellular recordingExtracellular recording Recording with an electrode near neurons rather than inside one; you see small, fast blips from nearby cells rather than the full membrane swing. . Glossary entry sorter on a short raw recording via SpikeInterface and compare its output to the provided sorting.