The Dataset Viewer has been disabled on this dataset.

MICrONS Functional Activity Dataset & Reader

This repository contains a curated portion of the MICrONS (Multi-Scale Networked Analysis of Cellular Responding Order) dataset. It consists of functional calcium imaging data from the visual cortex of mice in response to various visual stimuli: natural clips (Clip) and parametric videos (Monet2, Trippy).

Videos have been downsampled to match the neural activity scan frequency, with each frame corresponding to the stimulus frame appearing at least 66 ms before scan time. Neural responses are linearly interpolated at each stimulus frame timestamp to align with the video.

The data is organized into a highly efficient, indexed HDF5 format, allowing for rapid cross-session analysis based on either stimulus identity or brain anatomy.


πŸ“Š Dataset Overview

Property Detail
Sessions 14 sessions of registered neural activity
Stimuli 3 categories (Clip, Monet2, Trippy) identified by unique condition hashes
Neural Data Calcium traces from thousands of neurons across V1, LM, RL, AL
Treadmill Running speed (cm/s) synchronized to stimulus frames
Pupil Size Major and minor radius of the fitted pupil ellipse (in pixels)
Eye Tracking Pupil center coordinates (x, y) for gaze analysis

Temporal alignment & sampling

All data streams β€” neural responses, pupil, and treadmill β€” were independently interpolated to 30 Hz to match the stimulus frame rate, aligning every signal to a common stimulus clock. The full 30 Hz timeseries was then uniformly downsampled by a factor of 4, yielding a final sampling rate of 7.5 Hz for all stored signals. As a result, responses, treadmill, pupil, and stim_times share an identical time axis within every trial, with each sample corresponding to a stimulus frame spaced ~133 ms apart.


πŸ—‚οΈ Internal HDF5 Structure

The file is organized to minimize redundancy: each unique video stimulus is stored once under /videos/ and linked to every trial across all sessions via HDF5 SoftLinks. The /sessions/ group is the source of truth for all neural and behavioral recordings.

root/
β”œβ”€β”€ πŸ“‚ BRAIN_AREAS/                              # Anatomical index (SoftLinks only)
β”‚   └── πŸ“‚ <area_name>/                          # e.g., V1, AL, LM, RL
β”‚       └── πŸ”— <session_id>                      -> /sessions/<session_id>
β”‚
β”œβ”€β”€ πŸ“‚ SESSIONS/                                 # Primary neural data storage
β”‚   └── πŸ“‚ <session_id>/                         # e.g., 4_7, 5_6
β”‚       β”œβ”€β”€ πŸ“‚ META/                             # Session-wide metadata
β”‚       β”‚   β”œβ”€β”€ πŸ“‚ AREA_INDICES/                 # Pre-computed neuron index masks per area
β”‚       β”‚   β”‚   └── πŸ“„ <area_name>               [Dataset: (N_area_neurons,), int]
β”‚       β”‚   β”œβ”€β”€ πŸ“„ brain_areas                   [Dataset: (N_neurons,), bytes β€” area label per neuron]
β”‚       β”‚   β”œβ”€β”€ πŸ“„ coordinates                   [Dataset: (N_neurons, 3), float β€” motor coordinates x/y/z]
β”‚       β”‚   β”œβ”€β”€ πŸ“„ unit_ids                      [Dataset: (N_neurons,), int β€” unique neuron IDs]
β”‚       β”‚   β”œβ”€β”€ πŸ“„ condition_hashes              [Dataset: (N_trials,), bytes β€” hash per trial, in order]
β”‚       β”‚   └── (Attr) fps                       [Float β€” scan acquisition rate]
β”‚       └── πŸ“‚ TRIALS/                           # One group per trial, indexed chronologically
β”‚           └── πŸ“‚ <trial_idx>/
β”‚               β”œβ”€β”€ πŸ“„ responses                 [Dataset: (N_neurons, F), float β€” Ξ”F/F calcium traces]
β”‚               β”œβ”€β”€ πŸ“„ treadmill                 [Dataset: (F,), float β€” running speed in cm/s]
β”‚               β”œβ”€β”€ πŸ“„ pupil                     [Dataset: (4, F), float β€” rows: x, y, major_r, minor_r]
β”‚               β”œβ”€β”€ πŸ“„ stim_times               [Dataset: (F,), float β€” stimulus frame timestamps in seconds]
β”‚               └── (Attr) condition_hash        [String β€” identifies the video shown in this trial]
β”‚
β”œβ”€β”€ πŸ“‚ TYPES/                                    # Stimulus category index (SoftLinks only)
β”‚   └── πŸ“‚ <stim_type>/                          # e.g., Clip, Monet2, Trippy
β”‚       └── πŸ”— <encoded_hash>                    -> /videos/<encoded_hash>
β”‚
└── πŸ“‚ VIDEOS/                                   # Stimulus library β€” each video stored once
    └── πŸ“‚ <encoded_hash>/                       # URL-encoded condition hash (/ β†’ %2F)
        β”œβ”€β”€ πŸ“„ clip                              [Dataset: (F, H, W), uint8 β€” grayscale frames]
        β”œβ”€β”€ πŸ“„ times                             [Dataset: (F,), float β€” relative frame timestamps in seconds, starting at 0]
        β”œβ”€β”€ πŸ“‚ INSTANCES/                        # Reverse index: all trials that showed this video
        β”‚   └── πŸ”— <session_id>_tr<trial_idx>    -> /sessions/<session_id>/trials/<trial_idx>
        β”œβ”€β”€ (Attr) original_hash                 [String β€” raw unencoded hash]
        β”œβ”€β”€ (Attr) type                          [String β€” one of: Clip, Monet2, Trippy]
        β”‚
        β”‚   # Clip-specific attributes/datasets:
        β”œβ”€β”€ (Attr) movie_name                    [String]
        β”œβ”€β”€ (Attr) short_movie_name              [String]
        β”œβ”€β”€ (Attr) duration                      [Float β€” clip duration in seconds]
        β”œβ”€β”€ (Attr) fps                           [Float β€” original stimulus frame rate]
        β”‚
        β”‚   # Monet2-specific attributes/datasets:
        β”œβ”€β”€ πŸ“„ directions                        [Dataset: (N_orientations,), float β€” grating directions in degrees]
        β”œβ”€β”€ πŸ“„ onsets                            [Dataset: (N_orientations,), float β€” onset times per grating]
        β”œβ”€β”€ (Attr) duration                      [Float]
        β”œβ”€β”€ (Attr) ori_coherence                 [Float β€” orientation coherence parameter]
        β”œβ”€β”€ (Attr) fps                           [Float]
        β”‚
        β”‚   # Trippy-specific attributes/datasets:
        β”œβ”€β”€ (Attr) temp_freq                     [Float β€” temporal frequency in Hz]
        β”œβ”€β”€ (Attr) spatial_freq                  [Float β€” spatial frequency in cycles/degree]
        β”œβ”€β”€ (Attr) duration                      [Float]
        └── (Attr) fps                           [Float]

Key design notes

  • /brain_areas/ and /types/ contain only SoftLinks β€” no data. They serve as fast lookup indices.
  • /videos/<hash>/instances/ allows reverse lookup: given a video, find every session and trial that presented it.
  • condition_hashes in session metadata are stored in trial order and may contain duplicates (the same video can be shown multiple times per session).
  • pupil rows are ordered [x, y, major_r, minor_r] consistently across all sessions.
  • stim_times are absolute timestamps in seconds; times inside /videos/ are relative (starting at 0), computed as stim_times - stim_times.min().

βš™οΈ Setup & Installation

Option 1 β€” Clone the repository

Since the dataset is stored as a large HDF5 file, Git LFS is required.

git lfs install
git clone https://huggingface.co/datasets/NeuroBLab/MICrONS
cd MICrONS
pip install -r requirements.txt

Option 2 β€” Programmatic download (no clone)

import sys
import importlib.util
from huggingface_hub import hf_hub_download

REPO_ID = "NeuroBLab/MICrONS"

print("Downloading files from Hugging Face...")
reader_path = hf_hub_download(repo_id=REPO_ID, filename="reader.py")
data_path   = hf_hub_download(repo_id=REPO_ID, filename="microns.h5")

spec = importlib.util.spec_from_file_location("reader", reader_path)
reader_module = importlib.util.module_from_spec(spec)
sys.modules["reader"] = reader_module
spec.loader.exec_module(reader_module)

from reader import MicronsReader

with MicronsReader(data_path) as reader:
    reader.print_structure(max_items=2)

πŸ› οΈ Reader API

Initialize

from reader import MicronsReader

with MicronsReader("microns.h5") as reader:
    # all calls go here
    pass

Explore structure

with MicronsReader("microns.h5") as reader:
    # Tree view β€” SoftLinks are shown without dereferencing by default
    reader.print_structure(max_items=3, follow_links=False)

Query available metadata

with MicronsReader("microns.h5") as reader:
    # All stimulus types in the file
    types = list(reader.f['types'].keys())          # ['Clip', 'Monet2', 'Trippy']

    # All hashes for a given stimulus type
    monet_hashes = reader.get_hashes_by_type('Monet2')

    # All (or unique) hashes shown in a session
    all_hashes    = reader.get_hashes_by_session('4_7')
    unique_hashes = reader.get_hashes_by_session('4_7', return_unique=True)

    # Brain areas recorded in a session, or all areas in the file
    areas_in_session = reader.get_available_brain_areas('4_7')  # ['AL', 'LM', 'RL', 'V1']
    all_areas        = reader.get_available_brain_areas()

Load video + all associated trials

get_full_data_by_hash is the primary access method. It aggregates the video and every neural/behavioral trial across all sessions that presented that stimulus.

target_hash = "0JcYLY6eaQxNgD0AqyHf"

with MicronsReader("microns.h5") as reader:
    # Optionally filter responses to a single brain area
    data = reader.get_full_data_by_hash(target_hash, brain_area='V1')

    print(data['clip'].shape)       # (F, H, W)  β€” grayscale video frames
    print(data['stim_type'])        # e.g. 'Clip'

    for trial in data['trials']:
        print(trial['session'])             # e.g. '4_7'
        print(trial['trial_idx'])           # e.g. '12'
        print(trial['responses'].shape)     # (N_V1_neurons, F)
        print(trial['treadmill'].shape)     # (F,)   β€” running speed in cm/s
        print(trial['pupil'].shape)         # (4, F) β€” rows: x, y, major_r, minor_r
        print(trial['stim_times'].shape)    # (F,)   β€” absolute timestamps in seconds

Load only neural responses

with MicronsReader("microns.h5") as reader:
    trials = reader.get_responses_by_hash(target_hash, brain_area='LM')
    # Returns: [{'session': str, 'trial_idx': str, 'responses': np.array}, ...]

Direct single-trial access

with MicronsReader("microns.h5") as reader:
    trial = reader.get_trial('4_7', trial_idx=12, brain_area='V1')
    print(trial['responses'].shape)   # (N_V1_neurons, F)
    print(trial['stim_times'])        # absolute timestamps for this trial

Load only the video

with MicronsReader("microns.h5") as reader:
    clip, stim_type = reader.get_video_data("0JcYLY6eaQxNgD0AqyHf")
    print(clip.shape)    # (F, H, W)
    print(stim_type)     # 'Clip'

πŸ“ Citation

If you use this dataset or reader in your research, please cite the original MICrONS Phase 3 release and this repository.

Downloads last month
72