aind-ecephys-s3-to-phy
Convert AIND ecephys sorted recordings from S3 into phy directories for manual curation, with raw trace access via compressed binary (mtscomp).
Two S3 assets are needed per session: a sorted asset (postprocessed SortingAnalyzer Zarrs) and its corresponding raw asset (compressed Zarr recordings). The tool reconstructs the full SpikeInterface preprocessing chain — including bad-channel removal — from the analyzer, streams traces from S3, and compresses them to .cbin for phy's trace viewer.
Installation
pip install aind-ecephys-s3-to-phy
Quick start
SORTED=s3://aind-open-data/ecephys_786867_2025-09-25_12-43-56_sorted_2025-12-24_08-46-14
RAW=s3://aind-open-data/ecephys_786867_2025-09-25_12-43-56
# List available recordings (and matched raw files)
s3-to-phy list --sorted-uri $SORTED --raw-uri $RAW
# Convert all recordings to phy (streams from S3, compresses to .cbin)
s3-to-phy convert --sorted-uri $SORTED --raw-uri $RAW
# Convert only recordings for a specific probe
s3-to-phy convert --sorted-uri $SORTED --raw-uri $RAW --probe 46101
# Convert only a specific experiment
s3-to-phy convert --sorted-uri $SORTED --raw-uri $RAW --experiment experiment1
# Write no traces: phy reads them from the raw asset on S3 when you view them
s3-to-phy convert --sorted-uri $SORTED --raw-uri $RAW --probe 46101 --lazy
# Extract preprocessed traces as flat binary (for non-phy pipelines, e.g. mipmap)
s3-to-phy extract-recording \
--analyzer-uri $SORTED/postprocessed/experiment1_...46101_recording1.zarr \
--raw-uri $RAW/ecephys/ecephys_compressed/experiment1_...46101.zarr \
--output preprocessed.dat
# Compress an existing recording.dat to .cbin
s3-to-phy compress --phy-dir ./phy_output
Motion correction
convert and extract-recording correct the traces with the drift estimate Kilosort 4 applied, read through
aind-ephys-assets from the sort's spikesorted/motion/<recording>/. Sorts made before sorting capsule
cdef667 (2026-04-16), the example asset above among them, did not save it; those export uncorrected, and
preprocessing's never-applied dredge_fast estimate is not used as a substitute. Integer traces stay integer.
Pass --no-motion-correct to skip it.
Lazy traces
--lazy exports in about a minute per probe instead of hours, with no trace file:
recording.jsonholds the analyzer's preprocessing chain over the raw Zarr on S3, andparams.py'sdat_pathnames it. phylib opens it through SpikeInterface: this needs a phylib withSpikeInterfaceEphysReader(cortex-lab/phylib#68).- Waveforms come from the analyzer's stored subset, written as
_phy_spikes_subset.*(most of the folder's size, a few GB per probe). Phy reads traces only in the trace view, or for a waveform outside the subset (about 0.5 s per spike from S3). No PC features are computed. - Traces are read on demand: a jump to a new window costs about a second, and scrolling is cached.
- Traces are not motion-corrected, matching the analyzer's waveforms. SpikeInterface's motion interpolation does not survive a round trip through JSON.
Python API
from aind_ecephys_s3_to_phy.analyzer import load_analyzer, attach_recording, discover_pairs
from aind_ecephys_s3_to_phy.recording import reconstruct_recording
from aind_ecephys_s3_to_phy.export import export_phy
# Discover and convert
pairs = discover_pairs(sorted_uri, raw_uri)
analyzer_name, raw_name = pairs[0]
analyzer_zarr = f"{sorted_uri}/postprocessed/{analyzer_name}"
raw_zarr = f"{raw_uri}/ecephys/ecephys_compressed/{raw_name}"
analyzer = load_analyzer(analyzer_zarr)
recording = reconstruct_recording(analyzer_zarr, raw_zarr)
attach_recording(analyzer, recording)
export_phy(analyzer, recording, "./phy_output", compress=True)
# Or just get the preprocessed recording for other pipelines
recording = reconstruct_recording(analyzer_zarr, raw_zarr)
# → SpikeInterface BaseRecording (filtered, bad channels removed, 373 ch)
S3 credentials
Public buckets (like aind-open-data) work without credentials. For private buckets, configure AWS credentials via the standard methods (~/.aws/credentials, environment variables, IAM roles). SpikeInterface uses s3fs/fsspec which follows the standard AWS credential chain.
Development
uv sync # Set up environment
./scripts/run_linters_and_checks.sh -c # Full lint + test suite
uv run --frozen pytest -m integration # Integration tests (requires S3)
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for aind-ecephys-s3-to-phy 0.4.0
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 |
|---|---|---|---|---|
| aind_ecephys_s3_to_phy-0.4.0.tar.gz | 402.8 kB | Without provenance | Details for aind_ecephys_s3_to_phy-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aind_ecephys_s3_to_phy-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for aind_ecephys_s3_to_phy-0.4.0-py3-none-any.whl |
Total release size: 420.6 kB
Release files / aind_ecephys_s3_to_phy-0.4.0.tar.gz
| Download URL | aind_ecephys_s3_to_phy-0.4.0.tar.gz |
|---|---|
| Size | 402.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f801fa27e40d037d5186e7feb37f6d7b4f73b47f5d5092aac777e28f73910580
|
|
BLAKE2b-256 checksum How to use checksums |
c473196800de5cf6e2cb8c02da938bc11404c8243b20752327342c6b4c7b1137
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / aind_ecephys_s3_to_phy-0.4.0-py3-none-any.whl
| Download URL | aind_ecephys_s3_to_phy-0.4.0-py3-none-any.whl |
|---|---|
| Size | 17.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b5c6c2aa80d4b96775d5eddb7da71633454658784fcda820184ec0e805494cc6
|
|
BLAKE2b-256 checksum How to use checksums |
4178191d737ebaed7d80956ac705307057f1e2727c2ad63d8816e275d76fe138
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for aind-ecephys-s3-to-phy 0.4.0
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.