Skip to main content

dr-datacube

Access to the Dynamic Routing datacube.

pip install dr-datacube

Loading data

Use get_lf to read a consolidated table as a polars.LazyFrame; apply .select(...) to choose specific columns and .collect() to materialize as a DataFrame.

Pass session_id to restrict the result to one session. By default, parquet results are restricted to behavior-passing brainwide sessions in the published datacube session list. Use session_type to select "brainwide", "naive", or "templeton" sessions, pass a collection to select multiple types, or pass session_type=None and with_behavior_filter=False to include all sessions.

Pass nwb=True to read directly from NWB files. With session_id, this reads that session's NWB file; without it, it reads all NWB sources available from the configured data source.

get_lf("units") always loads the full units table, including spike times, and can be slow. Use get_lf("unit_metrics") for the table without spike times and other large array-like columns. The spike-inclusive parquet files are only available in the cache; when using the datacube asset, units is automatically read from NWB.

Pass only_in_data_asset=False to bypass the published session list, for example to load another session available in the cache.

import polars as pl
from dr_datacube import get_lf

performance = get_lf("performance").collect()
session_units = (
    get_lf("units", session_id="123456_2024-01-01")
    # filter to reduce the number of rows fetched:
    .filter(
        'is_qc_pass', 
        pl.col('structure') == 'MOs',
    )
    # drop large columns that aren't needed to save time/memory:
    .drop('spike_amplitudes', 'waveform_mean', 'waveform_std')
    # alternatively, select the columns you need directly:
    .select('spike_times', 'unit_id') 
    .collect()
)

# Load all behavior-passing sessions from multiple standard session sets:
ephys = get_lf(
    "unit_metrics",
    session_type=["brainwide", "templeton"],
).collect()

Use get_session_table for the standard session sets. By default it applies the behavior filter and keeps only sessions in the configured data asset:

from dr_datacube import get_session_table

brainwide = get_session_table(["brainwide", "templeton"])
all_sessions = get_session_table(None, with_behavior_filter=False)

Datacube session IDs

A list of standard ephys sets is published in assets/datacube_sessions.csv. The table contains the session and subject IDs, the standard session type (brainwide, naive, and templeton), and whether the session passed the relevant behavior filter for its type. The table is generated by scripts/dump_datacube_sessions.py and updated automatically in GitHub Actions when changes are made to the filtering logic or the datacube default version (as it requires CO and AWS credentials).

Read it directly from GitHub with pandas:

import pandas as pd

url = "https://raw.githubusercontent.com/allenneuraldynamics/dr-datacube/main/assets/datacube_sessions.csv"
session_ids = pd.read_csv(url).query("is_behavior_pass and session_type == 'brainwide'")["session_id"].tolist()

Or with Polars:

import polars as pl

url = "https://raw.githubusercontent.com/allenneuraldynamics/dr-datacube/main/assets/datacube_sessions.csv"
session_ids = (
    pl.read_csv(url)
    .filter(pl.col("is_behavior_pass") & (pl.col("session_type") == "brainwide"))["session_id"]
    .to_list()
)

This package also provides a convenience function to get the list of session IDs directly:

from dr_datacube import get_session_ids_from_github

good_session_ids = get_session_ids_from_github("brainwide")
all_session_ids = get_session_ids_from_github(["brainwide", "templeton"], with_behavior_filter=False)

Data source and configuration

The datacube version and data source are controlled by dr_datacube.config. Set configuration near the top of your script or notebook before loading data:

import dr_datacube

dr_datacube.config.version = "v0.0.301"

By default, the package uses a matching local dynamicrouting_datacube asset when running on Code Ocean. If no matching local asset is available, it streams from the datacube asset directory on S3 through fsspec/boto. The S3 asset directory is currently private, so credentials are required for this fallback.

The main configuration options are:

Option Effect
version Select the datacube version.
use_cache Use the public scratch bucket (aind-scratch-data) for both NWB files and parquet tables.
disable_asset_streaming Disable streaming the datacube asset through fsspec/boto; a matching asset must be attached locally in Code Ocean.
anon Use anonymous access: AWS credentials are not required and are not used, even if available.
nwb_only Disable access to parquet tables, so reads use NWB data only.

To use the public scratch-bucket cache instead, enable the cache:

dr_datacube.config.use_cache = True

If credentials are not available, enable anonymous access as well:

dr_datacube.config.anon = True

Temporary configuration

Use config.override(...) when an operation needs different settings without changing the module-level config. The temporary configuration is restored when the context exits, even if an exception is raised:

from dr_datacube import config, get_lf

with config.override(use_cache=True):
    units = get_lf("units")

Metadata

Release files for dr-datacube 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dr-datacube 0.1.2
File Size Uploaded Provenance Actions
dr_datacube-0.1.2.tar.gz 10.3 kB Without provenance Details for dr_datacube-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dr-datacube 0.1.2
File Interpreter ABI Platform Actions
dr_datacube-0.1.2-py3-none-any.whl Python 3 none any Details for dr_datacube-0.1.2-py3-none-any.whl

Total release size: 21.7 kB

Release files / dr_datacube-0.1.2.tar.gz

Download URL dr_datacube-0.1.2.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
582e7359e0bd9c272ab999155f9b7d45d4a955c2b75864fec341da4697c26ecf
BLAKE2b-256 checksum
How to use checksums
832dab430d0df546bb72c456f16dad01f1235f1955372e7a9d8a490aae36192a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.0 {"installer":{"name":"uv","version":"0.11.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / dr_datacube-0.1.2-py3-none-any.whl

Download URL dr_datacube-0.1.2-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
52be4b69ee0cfd88ee0f81f45f5f4c138ab283b429e161fa9c5edba5a035d811
BLAKE2b-256 checksum
How to use checksums
4cf9447ed18ed444b50592d214dbfbfe6e47ed728d8be974fc1916fcd625519f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.0 {"installer":{"name":"uv","version":"0.11.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for dr-datacube 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page