Skip to main content

Population and element-level analysis of neuronal computations

Project description

DRIADA

Dimensionality Reduction for Integrated Activity Data - A unified framework bridging single-neuron selectivity analysis with population-level dimensionality reduction for biological and artificial neural systems.

Python Version PyPI version License

🎯 Vision

DRIADA creates a seamless bridge between understanding individual neurons and population-level neural dynamics. Our framework enables researchers to:

  1. Identify which neurons encode specific variables (using INTENSE)
  2. Extract collective latent variables from population activity
  3. Connect single-cell selectivity to population manifolds
  4. Interpret how neural populations represent information

The DRIADA Workflow

DRIADA uniquely combines single-neuron and population-level analyses in one framework. While traditional methods analyze neurons in isolation OR populations as a whole, DRIADA reveals how individual neural selectivity gives rise to collective representations.

Dimensionality reduction  ←  Population Activity  ←  Single Neurons  →  INTENSE
         ↓                                                                ↓
Latent Variables                                                 Individual Selectivity
         ↓                                                                ↓
          → → → → → → → → →  Integration Analysis ← ← ← ← ← ← ← ← ← ← ← ← ←
                                       ↓
         Connect single-cell selectivity to population-level variables

Overview

DRIADA provides a comprehensive toolkit for analyzing both individual neural selectivity and collective population dynamics:

  • 🔍 Individual Analysis: Discover which neurons encode specific behavioral variables using information theory
  • 🌐 Population Analysis: Extract latent variables and manifolds from neural population activity
  • 🔗 Integrated Workflows: Connect single-cell properties to population-level representations
  • 🧪 Validation Tools: Generate synthetic populations with known ground truth for algorithm testing

Key Capabilities

🧠 INTENSE Module - Single Neuron Analysis

  • Detect both linear and nonlinear relationships using mutual information
  • Rigorous two-stage statistical testing with multiple comparison correction
  • Handle temporal delays between neural activity and behavior
  • Disentangle mixed selectivity when neurons respond to multiple variables

📊 Population-Level Analysis - Collective Neural Dynamics

  • Dimensionality Estimation: Measure intrinsic dimensionality of neural manifolds
    • Linear methods: PCA-based dimension, effective rank
    • Nonlinear methods: k-NN dimension, correlation dimension
  • Dimensionality Reduction: Extract latent variables from population activity
    • Classical: PCA, Factor Analysis
    • Manifold learning: Isomap, UMAP, diffusion maps
    • Specialized neural methods (coming soon)
  • Latent Variable Extraction: Recover behavioral variables from neural populations
    • Extract circular variables (e.g., head direction)
    • Reconstruct spatial maps from place cell activity
    • Identify task-relevant population subspaces

🔗 Integrated Analysis - Bridging Scales

  • Map single-cell selectivity to population manifolds
  • Understand how individual neurons contribute to collective representations
  • Visualize relationships between neural selectivity and population structure

🧪 Synthetic Data Generation - Algorithm Validation

  • Generate populations with known ground truth:
    • Head direction cells on circular manifolds
    • Place cells on 2D/3D spatial manifolds
    • Mixed populations with manifold + feature-selective neurons
  • Test and validate analysis methods before applying to real data
  • Benchmark different algorithms on controlled datasets

Perfect for:

  • 🧠 Cognitive neuroscience: Identify task-relevant neural subspaces and their dynamics
  • 🤖 AI interpretability: Understand representations in artificial neural networks
  • 🔬 Systems neuroscience: Bridge cellular and population-level descriptions

Quick Start

Installation

# Basic installation
pip install driada

# With GPU support (recommended for large datasets)
pip install driada[gpu]

Getting Started with DRIADA

1. Generate Synthetic Data for Testing

import driada
import numpy as np

# Generate a population with head direction cells
exp = driada.generate_circular_manifold_exp(
    n_neurons=50,           # 50 head direction cells
    duration=600,           # 10 minutes of recording
    noise_level=0.1,        # 10% noise
    seed=42
)

# Or generate place cells in 2D environment
exp = driada.generate_2d_manifold_exp(
    n_neurons=64,           # 8x8 grid of place cells
    duration=900,           # 15 minutes of exploration
    environments=['env1']   # Single environment
)

# Or create mixed populations
exp = driada.generate_mixed_population_exp(
    n_neurons=100,
    manifold_type='circular',
    manifold_fraction=0.4,  # 40% manifold cells, 60% feature-selective
    duration=600
)

2. Analyze Single-Neuron Selectivity (INTENSE)

# Discover which neurons encode which variables
stats, significance, info, results = driada.compute_cell_feat_significance(
    exp,
    n_shuffles_stage1=100,    # Quick screening
    n_shuffles_stage2=1000,   # Rigorous validation
    verbose=True
)

# View results
significant_neurons = exp.get_significant_neurons()
print(f"Found {len(significant_neurons)} selective neurons")

# Visualize selectivity
if significant_neurons:
    neuron_id = list(significant_neurons.keys())[0]
    feature = significant_neurons[neuron_id][0]
    driada.intense.plot_neuron_feature_pair(exp, neuron_id, feature)

3. Extract Population-Level Manifolds

# Get neural activity matrix
neural_data = exp.calcium  # Shape: (n_neurons, n_timepoints)

# Estimate intrinsic dimensionality
from driada.dimensionality import nn_dimension, pca_dimension, effective_rank

intrinsic_dim = nn_dimension(neural_data.T, k=5)      # k-NN estimator
linear_dim = pca_dimension(neural_data.T, threshold=0.95)  # PCA 95% variance
eff_rank = effective_rank(neural_data.T)             # Effective rank

print(f"Intrinsic dimension: {intrinsic_dim:.2f}")
print(f"Linear dimension (95%): {linear_dim}")
print(f"Effective rank: {eff_rank:.2f}")

# Apply dimensionality reduction
from sklearn.decomposition import PCA
from sklearn.manifold import Isomap
import umap

# Linear embedding
pca = PCA(n_components=2)
pca_embedding = pca.fit_transform(neural_data.T)

# Nonlinear manifold learning
isomap = Isomap(n_components=2, n_neighbors=10)
isomap_embedding = isomap.fit_transform(neural_data.T)

umap_reducer = umap.UMAP(n_components=2, random_state=42)
umap_embedding = umap_reducer.fit_transform(neural_data.T)

4. Using Your Own Data

# Load your neural recordings
calcium_traces = np.load('path/to/calcium_data.npy')  # Shape: (n_neurons, n_timepoints)

# Load behavioral variables
behavior_data = {
    'position_x': np.load('path/to/x_position.npy'),
    'position_y': np.load('path/to/y_position.npy'),
    'head_direction': np.load('path/to/head_direction.npy'),
    'speed': np.load('path/to/speed.npy')
}

# Create experiment object
exp = driada.Experiment(
    signature='MyExperiment',
    calcium=calcium_traces,
    dynamic_features=behavior_data,
    static_features={'fps': 20.0}  # 20 Hz sampling rate
)

# Follow steps 2-3 above for analysis

Documentation & Examples

📚 Core Documentation

🔬 Working Examples

📓 Interactive Notebooks

🎯 Specialized Guides

  1. Single-Neuron Analysis: Start with README_INTENSE.md for selectivity analysis
  2. Population Analysis: Use examples/extract_circular_manifold.py for manifold extraction
  3. Interactive Learning: Explore notebooks/ for hands-on tutorials
  4. Synthetic Data: Generate test populations with driada.generate_*_manifold_exp() functions
  5. Real Data: Follow the "Using Your Own Data" section above

Requirements

  • Python 3.8+
  • NumPy, SciPy, scikit-learn
  • numba (for performance optimization)
  • matplotlib, seaborn (for visualization)
  • See pyproject.toml for complete list

Installation from Source

git clone https://github.com/iabs-neuro/driada.git
cd driada
pip install -e .  # Editable installation

Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

Development Setup

# Clone the repository
git clone https://github.com/iabs-neuro/driada.git
cd driada

# Create conda environment
conda create -n driada python=3.9
conda activate driada

# Install in development mode
pip install -e .[gpu]

# Run tests
pytest

Citation

If you use DRIADA in your research, please cite:

@software{driada2024,
  title = {DRIADA: Dimensionality Reduction for Integrated Activity Data},
  author = {Pospelov, Nikita and contributors},
  year = {2025},
  url = {https://github.com/iabs-neuro/driada}
}

Support

License

This project is licensed under the MIT License - see the LICENSE file for details.


Note: DRIADA is actively developed. We recommend using the latest stable release for production work.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

driada-0.3.0.tar.gz (9.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

driada-0.3.0-py3-none-any.whl (214.8 kB view details)

Uploaded Python 3

File details

Details for the file driada-0.3.0.tar.gz.

File metadata

  • Download URL: driada-0.3.0.tar.gz
  • Upload date:
  • Size: 9.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for driada-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f5f7b5350262073d8751502b0e5c886c1cc9abcbe7d616c90c332f866e5c4d35
MD5 6e9b02c858ffaa4fdc7cfb912e711bc1
BLAKE2b-256 a4b0159b1032e2af021a3d26ba20dc8597473119b1561ebf1cd608d0aa0e465d

See more details on using hashes here.

File details

Details for the file driada-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: driada-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 214.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for driada-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 991a1d864d72679a431874c7a956851038e47f8aa20e95a19c7dd6f6279c859f
MD5 9d530df5e88a241ec93741b338d7f0cc
BLAKE2b-256 a40068019c97f36f88ab607e246b9af4331639403b0f1fa5e7e415764601b104

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page