API Reference#

This is the complete API reference for NeuRodent.

Modules#

Core Module#

Core module for loading, organizing, and analyzing EEG data.

This module provides the fundamental building blocks for the NeuRodent analysis pipeline, handling everything from raw data loading to feature extraction.

Typical Workflow:

from neurodent import visualization

# 1. Organize recordings for an animal
ao = visualization.AnimalOrganizer(
    data_path, animal_id, mode="nest",
)

# 2. Run windowed feature analysis
war = ao.compute_windowed_analysis(
    features=['psdband', 'cohere'],
    window_s=5,
    multiprocess_mode="dask",
)

# 3. Access results (WindowAnalysisResult)
df = war.result  # pandas DataFrame with all features
war.save_pickle_and_json('output/')

The lower-level classes can also be used directly:

from neurodent import core

# Load a single recording
lro = core.LongRecordingOrganizer(day_folder_path)

# Analyze in fragments
analyzer = core.LongRecordingAnalyzer(lro, fragment_len_s=5)
rms = analyzer.compute_rms(fragment_index=0)
psd = analyzer.compute_psdband(fragment_index=0)

What Gets Computed:

  • Power features: RMS, amplitude variance, band power (delta, theta, alpha, beta, gamma)

  • Connectivity: Coherence, imaginary coherence, Pearson correlation between channels

  • Spikes: Spike counts via frequency-domain detection

See Also:

RecordingMetadata

Stores metadata information for neural recordings.

LongRecordingOrganizer

Construct a long recording from various file formats or an existing recording object.

LongRecordingAnalyzer

Class for analyzing LongRecordings by breaking them into smaller time windows (fragments).

FragmentAnalyzer

Static class for analyzing fragments of EEG data.

FrequencyDomainSpikeDetector

Static class for frequency-domain spike detection using STFT and SNEO.

Visualization Module#

Visualization module for organizing analysis results and creating plots.

This module provides tools to aggregate, organize, and visualize the outputs of the neurodent.core analysis pipeline across animals and experiments.

Typical Workflow:

from neurodent import visualization as viz
from neurodent.core import LongRecordingAnalyzer

# 1. Wrap analysis results for easier access
war = viz.WindowAnalysisResult.load('analysis_results.pkl')

# 2. Aggregate across sessions for one animal
organizer = viz.AnimalOrganizer([war1, war2, war3])
combined_df = organizer.get_combined_features()

# 3. Plot temporal heatmaps
plotter = viz.AnimalPlotter(organizer)
fig = plotter.plot_temporal_heatmap(feature='psdband', band='theta')

# 4. Experiment-wide comparisons (multiple animals)
exp_plotter = viz.ExperimentPlotter([animal1_org, animal2_org])
fig = exp_plotter.plot_genotype_comparison(feature='cohere')

Output Types:

  • Temporal heatmaps: Feature values over time (x) and channels (y)

  • Band comparisons: Power across frequency bands

  • Statistical plots: Genotype/condition comparisons with error bars

  • Export to CSV/TIF: Publication-ready outputs

See Also:

AnimalOrganizer

Organizes and analyzes recording data from a single animal across multiple sessions.

WindowAnalysisResult

Wrapper for output of windowed analysis.

FrequencyDomainSpikeAnalysisResult

Wrapper for frequency-domain spike detection results.

AnimalPlotter

Class for plotting results from an AnimalOrganizer/WindowAnalysisResult.

ExperimentPlotter

A class for creating various plots from a list of multiple experimental datasets.

Constants#

Constants used throughout NeuRodent.

This module centralizes all configuration values, feature definitions, and lookup tables used by the neurodent.core and neurodent.visualization modules.

Quick Reference:

from neurodent import constants

# Frequency bands (Hz ranges)
constants.FREQ_BANDS
# {'delta': (1, 4), 'theta': (4, 8), 'alpha': (8, 13), 'beta': (13, 25), 'gamma': (25, 40)}

# Available features
constants.LINEAR_FEATURES   # ['rms', 'ampvar', 'psdtotal', 'nspike', ...]
constants.LINEAR_2D_FEATURES  # ['psdslope']
constants.BAND_FEATURES     # ['psdband', 'psdfrac', 'logpsdband', 'logpsdfrac']
constants.MATRIX_FEATURES   # ['cohere', 'zcohere', 'imcoh', 'zimcoh', 'pcorr', 'zpcorr']

# Global settings
constants.GLOBAL_SAMPLING_RATE  # 1000 Hz
constants.LINE_FREQ             # 60 Hz (for notch filter)

# Colorblind-friendly colors
constants.OKABE_ITO_COLORS["blue"]   # '#0072B2'
constants.OKABE_ITO_COLORS["orange"] # '#E69F00'

Customization:

To override defaults, import and modify before running analysis:

from neurodent.constants import config
config.GLOBAL_SAMPLING_RATE = 500  # If your data is 500 Hz

See Also:

analysis

config

Global configuration constants for neurodent.

mappings

Channel and metadata mapping constants.

plotting

Plotting style constants.