Getting Started¶
Installation¶
Add to a uv project:
Or install into the active environment:
Quick start — sites table¶
Load a raw session directory and compute the sites table (one row per site):
from aind_behavior_vr_foraging.data_contract import dataset
from aind_behavior_vr_foraging_packaging.pipeline.session import resolve_site_table_processor
ds = dataset("path/to/session") # load the raw session
sites_df = resolve_site_table_processor(ds).compute() # version-dispatch automatic
print(f"{len(sites_df)} sites, {sites_df['has_reward'].sum()} rewarded")
sites_df.to_parquet("sites.parquet") # optional: persist to disk
resolve_site_table_processor automatically picks the current or legacy
SiteTableProcessor based on the dataset's schema version.
Quick start — all tables at once¶
To produce every table in a single call, use process_session. It writes one
parquet per processor and returns them keyed by name:
from aind_behavior_vr_foraging.data_contract import dataset
from aind_behavior_vr_foraging_packaging.pipeline.session import process_session
ds = dataset("path/to/session")
results = process_session(ds, output_dir="output/")
# → output/sites.parquet, output/position_velocity.parquet, …
print(results.keys())
# dict_keys(['session', 'sites', 'position_velocity', 'licks', 'sniffing',
# 'software_events', 'events'])
Quick start — CLI export¶
Install the CLI tool with uvx:
Then export a folder of raw session directories
(--input-dir must contain one subdirectory per session):
The export directory receives:
/data/export/
├── session.parquet # session catalogue (one row per session)
├── sites.parquet # aggregated sites table (all sessions)
└── sessions/
└── <session_id>/
├── sites.parquet
├── position_velocity.parquet
└── …
Subcommands¶
| Command | --input-dir is |
What it does |
|---|---|---|
session |
one raw session directory | Export that session's tables (and optionally NWB) |
batch |
a folder of raw session directories | Export every session, then aggregate |
aggregate |
a sessions/ tree from an earlier run |
Rebuild the experiment-level tables only |
# One session
vr-foraging-packaging session --input-dir /data/raw/behavior_123_2025-01-01 --write-nwb
# Aggregate later, re-processing nothing
vr-foraging-packaging aggregate --input-dir /data/export/sessions --output-dir /data/export
Common CLI flags¶
| Flag | Default | Description | Commands |
|---|---|---|---|
--include-processors a b |
(all) | Run only the listed processors | session, batch |
--exclude-processors a b |
(none) | Skip named processors | session, batch |
--strict-parsing |
false |
Treat a known data anomaly as fatal | session, batch |
--write-nwb |
false |
Also write an NWB-Zarr store per session | session, batch |
--no-write-parquet |
(parquet on) | Skip the parquet tables | session, batch |
--workers N |
1 |
Parallel threads for the per-session phase | batch |
--skip-aggregation |
false |
Write only per-session outputs | batch |
--no-clean |
(clean on) | Keep --output-dir instead of wiping it |
batch |
--log-file path |
(none) | Append a structured log to this path | all |
Run vr-foraging-packaging --help, or vr-foraging-packaging <command> --help,
for the full flag reference.
Next steps¶
-
Session from disk
Individual processors, selective computation, and the processor lifecycle.
-
Parquet files
Query the export output with pandas, DuckDB, or Polars.
-
AWS S3
Query data directly from S3 without downloading it.
-
API reference
Full API documentation for all public functions and classes.