1. Home
  2. Glossary
  3. Neural encoding and decoding
Biocomputing glossary

Neural encoding and decoding: translating between the world and neural activity

Neural encoding describes how neurons represent information; decoding reads it back out. Learn the methods and why both are central to biocomputing interfaces.

By Organoid Programming5 min readHow we source and fact-check

Definition

Neural encoding and decoding: Neural encoding is how neurons represent information, such as a stimulus, in their activity, and encoding models predict activity from that information. Neural decoding is the reverse: inferring the stimulus, intention or task variable from recorded activity. Together they form the input and output interface between living neurons and machines.

Also known as: neural coding, neural decoding, encoding models, decoders, readout

Neural encoding and decoding describe how information moves between the world and neurons. Encoding is how a stimulus or variable is represented in neural activity; decoding is the reverse, inferring the stimulus, intention or task variable from recorded activity. In biocomputing, encoding defines how inputs are sent to living neurons and decoding defines how answers are read out.

Key takeaways

  • Encoding maps the world to activity; decoding maps activity back to the world.
  • Information can be carried by spike counts (rate codes), spike timing (temporal codes) or patterns across a population.
  • Decoders range from simple linear models to deep neural networks; simpler decoders make it easier to attribute computation to the neurons.
  • Brain-computer interfaces, such as the handwriting decoder reported by Willett et al. (Nature, 2021), are high-profile applications.
  • In organoid computing, stimulation patterns are the encoding and a trained readout is the decoding.

What is neural encoding?

Neurons communicate with action potentials, brief all-or-none spikes. A single spike carries little information on its own, so information must be represented in patterns: how often neurons fire, when they fire and which neurons fire together. The study of these patterns is called neural coding.

Common coding schemes

  • Rate coding: information is carried by the number of spikes in a time window. A classic example is a sensory neuron firing faster as a stimulus grows stronger.
  • Temporal coding: information is carried by precise spike timing, such as first-spike latency or phase relative to an oscillation.
  • Population coding: information is spread across many neurons, each broadly tuned, so the pattern across the group carries the message.
  • Sparse coding: only a small fraction of neurons are active for any given input, making representations efficient and distinct.

Encoding models

An encoding model predicts a neuron’s activity from a stimulus. Pillow et al. (Nature, 2008) fitted generalized linear models to a complete population of recorded retinal ganglion cells and showed that accounting for correlations between neurons improved how well the model captured both their responses and the visual information they carried. Models like this are useful in biocomputing because they predict how a culture will respond to a given stimulation pattern.

What is neural decoding?

Decoding asks: given activity, what caused it, or what is the network “saying”? Quian Quiroga and Panzeri reviewed decoding and information-theoretic approaches in Nature Reviews Neuroscience (2009), describing how decoders quantify how much information a population carries about a stimulus.

A typical decoding pipeline looks like this:

  1. Record activity, for example with a microelectrode array.
  2. Detect spikes and optionally assign them to neurons with spike sorting.
  3. Build features, such as spike counts per electrode in short time bins.
  4. Train a decoder on labeled examples (activity paired with known stimuli or targets).
  5. Test the decoder on held-out data to measure accuracy.

Types of decoders

Decoder type How it works Strengths Weaknesses
Linear regression or classifier Weighted sum of features Fast, interpretable, low risk of overfitting Misses nonlinear structure
Population vector Averages neurons’ preferred directions Simple, historically important in motor control Assumes specific tuning
Bayesian decoder Inverts an encoding model with probabilities Principled uncertainty estimates Needs a good encoding model
Kalman filter Tracks a changing variable over time Smooth, real-time Assumes linear dynamics
Recurrent or deep networks Learns complex mappings High accuracy with enough data Opaque, can do the computation itself

Encoding vs decoding in biocomputing

In a biocomputing system, the terms take on an engineering meaning:

Encoding (input) Decoding (output)
Question How do we put information into neurons? How do we get answers out?
Mechanism Electrical, optical or chemical stimulation patterns Recorded spikes or field potentials, mapped by a model
Design choices Which electrodes, timing, amplitude, frequency Features, time windows, decoder type
Example Ball position encoded by stimulation location and rate Activity in motor regions moving a paddle

The DishBrain study by Kagan et al. (Neuron, 2022) used both: the ball’s position was encoded through stimulation across electrodes, and activity in designated regions was decoded into paddle movement, within a closed-loop stimulation system. We walk through it in how neurons learn in a dish.

A simple worked example

Imagine a culture on a 60-electrode array, and a task with two possible inputs, A and B. Encoding might deliver input A as a pulse train to electrodes on the left of the array and input B to electrodes on the right. To decode, you count spikes on every electrode in a short window after each stimulus, giving a 60-number vector per trial. You collect many labeled trials, train a linear classifier to tell A from B, and test it on trials it has not seen. If accuracy is well above chance, the network’s responses carry information about the input. If accuracy improves across training sessions while the decoder is held fixed, that is evidence that the network itself changed.

The reservoir computing approach

In reservoir computing, the living network acts as a fixed, nonlinear dynamical system and only the decoder is trained. Cai et al. (Nature Electronics, 2023) used this approach in Brainoware: audio and other inputs were encoded as stimulation patterns delivered to a brain organoid, and a trained readout decoded the organoid’s responses for tasks including speech recognition. Details are in reservoir computing with brain organoids.

Why do encoding and decoding matter for biocomputing?

For organoid intelligence, encoding and decoding define the interface, and the interface determines what can be claimed.

  • Input bandwidth: the number of electrodes and the stimulation patterns available limit how much information can be sent in.
  • Output bandwidth: recording density and quality limit how much can be read out. Electrophysiology hardware sets the ceiling.
  • Attribution: if the decoder is a large deep network, it may perform most of the computation itself. Simple, fixed decoders make it clearer that the neurons are doing the work.
  • Learning versus readout: a decoder can extract information from an unchanged network. Showing that the neurons learned requires evidence that their activity changed with training, compared with controls.
  • Drift: living networks change over days, so decoders may need recalibration.

What are the limitations?

Recording captures only a sample of neurons, mostly near electrodes, so decoders work with partial information. Stimulation artifacts can obscure early responses. Codes differ between cultures, so a decoder trained on one organoid rarely transfers directly to another. And comparisons between spiking neural networks in software and living networks depend on matching encoding schemes carefully.

Making encoding and decoding choices explicit, versioned and comparable is one of the problems we are working on at Organoid Programming. For the hardware underneath, read microelectrode arrays explained.

Frequently asked questions

What is the difference between neural encoding and decoding?

Neural encoding asks how information in the world is represented in neural activity, for example how a neuron’s firing rate changes with a stimulus. Neural decoding asks the reverse question: given recorded activity, what was the stimulus or intended action? Encoding models predict activity from inputs, and decoding models predict inputs or outputs from activity.

What is a rate code versus a temporal code?

In a rate code, information is carried by how many spikes a neuron fires in a time window. In a temporal code, information is carried by the precise timing of spikes, such as their latency after a stimulus or their relation to other neurons’ spikes. Real neural populations likely use both, and which matters depends on the system and time scale.

What is an example of neural decoding?

Brain-computer interfaces are a prominent example. Willett et al. (Nature, 2021) reported a system that decoded neural activity recorded from motor cortex of a person with paralysis while they attempted to handwrite, converting it into text in real time. In biocomputing, decoding turns activity in cultured neurons into actions such as moving a game paddle.

How is decoding used in organoid computing?

In organoid reservoir computing, input is encoded as electrical stimulation, the organoid’s responses are recorded, and a simple trained decoder, often a linear model, maps those responses to outputs. Cai et al. (Nature Electronics, 2023) used this approach in Brainoware. The decoder is trained in software while the living network provides the nonlinear transformation.

Does a good decoder mean the neurons learned?

Not necessarily. A powerful decoder can extract information from activity even if the network itself did not change. Demonstrating learning in the neurons requires showing that activity or task performance changes over time in response to training, compared with controls, ideally with a fixed or simple decoder. This distinction is important when evaluating biocomputing claims.

Sources

  1. Quian Quiroga & Panzeri (2009). Extracting information from neuronal populations: information theory and decoding approaches. Nature Reviews Neuroscience.
  2. Pillow et al. (2008). Spatio-temporal correlations and visual signalling in a complete neuronal population. Nature.
  3. Willett et al. (2021). High-performance brain-to-text communication via handwriting. Nature.
  4. Cai et al. (2023). Brain organoid reservoir computing for artificial intelligence. Nature Electronics.
  5. Kagan et al. (2022). In vitro neurons learn and exhibit sentience when embodied in a simulated game-world. Neuron.