Navigation

Introduction to AI

Machine Learning

Deep Learning

Generative AI

Tools & Frameworks

General

AI in Neuroscience

AI in Neuroscience

Artificial intelligence and neuroscience share a deep bidirectional relationship. Neuroscience has long inspired AI architecture — perceptrons mirror neurons, convolutional networks mimic visual cortex hierarchy, reinforcement learning borrows from dopamine reward signaling. In return, modern AI tools are transforming how neuroscientists map, decode, simulate, and interpret the brain.

Neural Decoding and Brain-Computer Interfaces

Neural Decoding

Neural decoding translates recorded brain activity into intended actions or perceptions. Classic approaches used linear decoders (Wiener filters, linear discriminant analysis), but deep learning now dominates high-dimensional settings.

Motor decoding from electrocorticography (ECoG):

import torch
import torch.nn as nn


class ECoGDecoder(nn.Module):
    """Decode intended cursor velocity from ECoG high-gamma power."""

    def __init__(self, n_channels: int, seq_len: int, output_dim: int = 2):
        super().__init__()
        self.cnn = nn.Sequential(
            nn.Conv1d(n_channels, 128, kernel_size=5, padding=2),
            nn.ReLU(),
            nn.Conv1d(128, 64, kernel_size=3, padding=1),
            nn.ReLU(),
        )
        self.lstm = nn.LSTM(64, 128, batch_first=True, num_layers=2, dropout=0.3)
        self.head = nn.Linear(128, output_dim)

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        # x: (B, channels, time)
        feat = self.cnn(x).permute(0, 2, 1)   # (B, time, 64)
        out, _ = self.lstm(feat)
        return self.head(out[:, -1, :])         # (B, 2) — x,y velocity

BrainGate and similar clinical BCIs achieve up to 90 words-per-minute speech decoding from multielectrode array recordings in people with paralysis.

Speech Decoding from Neural Activity

Large transformer models fine-tuned on neural recordings decode imagined or attempted speech with high accuracy. Meta’s brain-to-speech decoder uses non-invasive MEG (magnetoencephalography) and a wav2vec 2.0 backbone, achieving state-of-the-art word error rates without surgery.

Non-Invasive BCIs

  • fMRI decoding: reconstruct perceived images using diffusion model priors conditioned on BOLD signal (MinD-Vis, Brain-Diffuser)
  • EEG-based control: classifying motor imagery for wheelchair and prosthetic control
  • fNIRS: near-infrared spectroscopy for portable cognitive state monitoring

Connectomics

Connectomics aims to map the complete wiring diagram of the nervous system at nanometer resolution. The outputs — connectomes — reveal how neural circuits compute.

Automated Volume Segmentation

Electron microscopy (EM) produces terabyte-scale image stacks. AI segments individual neurons and synapses:

  1. Affinity prediction: 3D U-Net predicts edge affinities between adjacent voxels
  2. Watershed clustering: affinities → instance segments (neuron IDs)
  3. Synapse detection: separate classifier localizes pre- and post-synaptic densities

The H01 connectome (Google / Harvard) mapped $1,\text{mm}^3$ of human cortex: 57,000 cells, 150 million synapses, using flood-filling networks.

# Simplified affinity U-Net architecture
import torch.nn as nn

class AffinityUNet(nn.Module):
    def __init__(self, in_channels=1, out_channels=3):
        super().__init__()
        self.enc1 = self._block(in_channels, 32)
        self.enc2 = self._block(32, 64)
        self.bottleneck = self._block(64, 128)
        self.dec2 = self._block(128 + 64, 64)
        self.dec1 = self._block(64 + 32, 32)
        self.out = nn.Conv3d(32, out_channels, 1)  # x,y,z affinities

    def _block(self, inc, outc):
        return nn.Sequential(
            nn.Conv3d(inc, outc, 3, padding=1), nn.BatchNorm3d(outc), nn.ReLU(),
            nn.Conv3d(outc, outc, 3, padding=1), nn.BatchNorm3d(outc), nn.ReLU(),
        )

    def forward(self, x):
        e1 = self.enc1(x)
        e2 = self.enc2(nn.functional.max_pool3d(e1, 2))
        b = self.bottleneck(nn.functional.max_pool3d(e2, 2))
        d2 = self.dec2(torch.cat([nn.functional.interpolate(b, scale_factor=2), e2], 1))
        d1 = self.dec1(torch.cat([nn.functional.interpolate(d2, scale_factor=2), e1], 1))
        return torch.sigmoid(self.out(d1))

Graph Analysis of Connectomes

Once segmented, connectomes are analyzed as graphs. AI identifies:

  • Motifs: recurring circuit patterns (e.g., disinhibitory motifs in cortex)
  • Community structure: functional modules within the connectome
  • Hub neurons: high-centrality cells whose ablation disrupts network function

Single-Cell and Spatial Transcriptomics

Cell Type Classification

Single-cell RNA sequencing (scRNA-seq) profiles gene expression of individual neurons. Dimensionality reduction (UMAP, PCA) followed by clustering reveals cell types, but deep learning improves resolution:

from scvi.model import SCVI
import anndata as ad

adata = ad.read_h5ad("neurons.h5ad")
SCVI.setup_anndata(adata, layer="counts")
model = SCVI(adata, n_latent=30)
model.train(max_epochs=400)
latent = model.get_latent_representation()

scVI uses a variational autoencoder to learn a batch-corrected latent space of cell-type identity robust to technical noise.

Spatial Transcriptomics

Technologies like Visium and MERFISH measure gene expression at spatial positions within tissue slices. AI methods:

  • Cell2location: deconvolve bulk spatial spots into single-cell types
  • Squidpy: graph-based neighborhood enrichment analysis
  • SpatialDE: identify spatially variable genes using Gaussian processes

Psychiatric and Neurological Diagnosis

Alzheimer’s Detection from MRI

3D CNNs and graph neural networks applied to structural MRI detect Alzheimer’s disease 6–10 years before clinical symptoms:

  • VoxCNN: 3D ResNet on volumetric MRI; AUC 0.92 on ADNI dataset
  • BrainNetCNN: CNN over functional connectivity matrices for dementia staging
  • Graph transformers: treat brain regions as nodes, functional correlations as edges

Autism Spectrum Disorder (ASD)

Resting-state fMRI functional connectivity matrices fed to graph neural networks classify ASD vs. controls, revealing hyper-connectivity in default mode network and reduced long-range connectivity.

Depression and Psychiatric States

EEG oscillation patterns (alpha, theta, beta power) decoded by recurrent networks predict treatment response to antidepressants and classify major depressive disorder with ~80% accuracy in research settings.

Neural Population Dynamics

Dimensionality Reduction of Neural Activity

Neural populations live in low-dimensional manifolds. AI tools extract these latent dynamics:

  • LFADS (Latent Factor Analysis via Dynamical Systems): sequential VAE with RNN dynamics — smooths spiking data and extracts trial-to-trial variability
  • pi-VAE: condition latent dynamics on behavioral variables (velocity, position)
  • CEBRA: self-supervised contrastive learning to align neural geometry with behavioral labels
from cebra import CEBRA

model = CEBRA(model_architecture="offset10-model", batch_size=512, learning_rate=3e-4,
              temperature=1.0, output_dimension=3, max_iterations=5000)
model.fit(neural_data, behavior_labels)
embedding = model.transform(neural_data)  # (T, 3) low-dimensional embedding

Neural Manifolds and Geometry

AI reveals that neural representations of tasks (reaching, navigation, working memory) lie on toroidal, ring, or cylindrical manifolds — structures that reflect the geometry of the underlying computation.

AI for Calcium Imaging

Calcium imaging with two-photon microscopy records thousands of neurons simultaneously. Processing pipelines:

  1. Motion correction: rigid/non-rigid registration (NoRMCorre)
  2. Cell detection: U-Net or Suite2p extracts regions of interest
  3. Deconvolution: infer spike trains from slow calcium transients (OASIS, CaImAn)
# Run Suite2p pipeline
python -c "
import suite2p
ops = suite2p.default_ops()
ops['data_path'] = ['/data/raw']
suite2p.run_s2p(ops=ops)
"

Drug Discovery for Neurological Conditions

Target Identification

Graph neural networks applied to protein interaction networks identify therapeutic targets for Parkinson’s (alpha-synuclein aggregation), ALS (TDP-43 mislocalization), and Huntington’s disease.

Blood-Brain Barrier Penetration Prediction

from rdkit import Chem
from chemprop import train, predict

# Predict BBB permeability for candidate neuro-drugs
smiles_list = ["CC(=O)Oc1ccccc1C(=O)O", "CN1CCC[C@H]1c2cccnc2"]
predictions = predict.predict(
    test_data=smiles_list, checkpoint_dir="bbb_model/"
)

Neuroscience-Inspired AI

The relationship is bidirectional — neuroscience continues to inform AI:

Neuroscience ConceptAI Analog
Hippocampal place cellsPositional encodings, spatial memory
Predictive codingEnergy-based models, world models
Dopamine reward prediction errorTD learning, advantage functions
Working memory (PFC)LSTM, attention mechanisms
Sparse coding (V1)Sparse autoencoders, dictionary learning
Lateral inhibitionSoftmax, competitive normalization

Ethical Considerations

  • Neural privacy: decoded thoughts from BCIs raise profound privacy risks — whose property is mental content?
  • Identity and agency: BCIs that modify mood or cognition blur personal responsibility
  • Access equity: experimental BCIs are expensive — equitable access is critical
  • Dual use: neural decoding developed for medical use could enable surveillance

Summary

AI is transforming neuroscience across every scale — from segmenting individual synapses in petabyte connectomes, to decoding speech from cortical recordings, to diagnosing Alzheimer’s from MRI years before symptoms appear. Deep learning tools adapted for neural data (LFADS, scVI, CEBRA, Suite2p) now form the computational backbone of modern systems and cognitive neuroscience. At the same time, insights from brain organization — sparse coding, predictive processing, hierarchical representations — continue to inspire the next generation of AI architectures.