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.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dr_datacube-0.1.3.tar.gz | 10.8 kB | Without provenance | Details for dr_datacube-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dr_datacube-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for dr_datacube-0.1.3-py3-none-any.whl |
Total release size: 22.1 kB
Release files / dr_datacube-0.1.3.tar.gz
| Download URL | dr_datacube-0.1.3.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
694b5d05f188fefb9b6c11b5def2bf31d03e275a3afa79e01419e376e0220652
|
|
BLAKE2b-256 checksum How to use checksums |
8b4ef4a9ed9465e550e3fc23cdfc6f2d04ea1898819246de5213798b325dd3c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / dr_datacube-0.1.3-py3-none-any.whl
| Download URL | dr_datacube-0.1.3-py3-none-any.whl |
|---|---|
| Size | 11.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
97ef2452e79deb8c73498d0ce6c58c7c51ac7f765869ab3dffe8d4807afb2abc
|
|
BLAKE2b-256 checksum How to use checksums |
b1dae04cce7e693cbf10affd0eddc7ab0ca6236182a6a8d881c749b59b5a1f86
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for dr-datacube 0.1.3
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.