Skip to main content

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.1

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.1
File Size Uploaded Provenance Actions
dr_datacube-0.1.1.tar.gz 10.2 kB Without provenance Details for dr_datacube-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 21.7 kB

Release files / dr_datacube-0.1.1.tar.gz

Download URL dr_datacube-0.1.1.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5917ed4284a1fb7d42a341e8796c7ea84fff1241624c7cda253e8517053ee1e5
BLAKE2b-256 checksum
How to use checksums
fa76ecbeb28f0344901cab871f040a2101ba49ad8506cbb6bfad4c23a464bcd0
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.1-py3-none-any.whl

Download URL dr_datacube-0.1.1-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ad7b4aa232854805fe7fb32c688ca486516f452666d2cd0fd3bab27653f87ac
BLAKE2b-256 checksum
How to use checksums
12c0151b56f49d9c88fc31ef26dc6cec90574442f96b6d589fb313da8b99cc7a
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.1

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