aind-ecephys-s3-to-phy 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. aind_ecephys_s3_to_phy-0.4.0/.copier-answers.yml +23 -0
  2. aind_ecephys_s3_to_phy-0.4.0/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
  3. aind_ecephys_s3_to_phy-0.4.0/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  4. aind_ecephys_s3_to_phy-0.4.0/.github/ISSUE_TEMPLATE/user-story.md +27 -0
  5. aind_ecephys_s3_to_phy-0.4.0/.github/dependabot.yml +19 -0
  6. aind_ecephys_s3_to_phy-0.4.0/.github/workflows/bump-call.yml +33 -0
  7. aind_ecephys_s3_to_phy-0.4.0/.github/workflows/ci-call.yml +38 -0
  8. aind_ecephys_s3_to_phy-0.4.0/.github/workflows/publish-call.yml +25 -0
  9. aind_ecephys_s3_to_phy-0.4.0/.gitignore +148 -0
  10. aind_ecephys_s3_to_phy-0.4.0/.python-version +1 -0
  11. aind_ecephys_s3_to_phy-0.4.0/.readthedocs.yaml +26 -0
  12. aind_ecephys_s3_to_phy-0.4.0/CHANGELOG.md +53 -0
  13. aind_ecephys_s3_to_phy-0.4.0/CLAUDE.md +135 -0
  14. aind_ecephys_s3_to_phy-0.4.0/LICENSE +22 -0
  15. aind_ecephys_s3_to_phy-0.4.0/PKG-INFO +133 -0
  16. aind_ecephys_s3_to_phy-0.4.0/README.md +112 -0
  17. aind_ecephys_s3_to_phy-0.4.0/pyproject.toml +105 -0
  18. aind_ecephys_s3_to_phy-0.4.0/scripts/run_linters_and_checks.sh +64 -0
  19. aind_ecephys_s3_to_phy-0.4.0/scripts/test_data_access.py +529 -0
  20. aind_ecephys_s3_to_phy-0.4.0/src/aind_ecephys_s3_to_phy/__init__.py +8 -0
  21. aind_ecephys_s3_to_phy-0.4.0/src/aind_ecephys_s3_to_phy/analyzer.py +236 -0
  22. aind_ecephys_s3_to_phy-0.4.0/src/aind_ecephys_s3_to_phy/cli.py +392 -0
  23. aind_ecephys_s3_to_phy-0.4.0/src/aind_ecephys_s3_to_phy/export.py +362 -0
  24. aind_ecephys_s3_to_phy-0.4.0/src/aind_ecephys_s3_to_phy/py.typed +1 -0
  25. aind_ecephys_s3_to_phy-0.4.0/src/aind_ecephys_s3_to_phy/recording.py +196 -0
  26. aind_ecephys_s3_to_phy-0.4.0/tests/__init__.py +1 -0
  27. aind_ecephys_s3_to_phy-0.4.0/tests/conftest.py +29 -0
  28. aind_ecephys_s3_to_phy-0.4.0/tests/test_analyzer.py +62 -0
  29. aind_ecephys_s3_to_phy-0.4.0/tests/test_cli.py +117 -0
  30. aind_ecephys_s3_to_phy-0.4.0/tests/test_example.py +9 -0
  31. aind_ecephys_s3_to_phy-0.4.0/tests/test_export.py +177 -0
  32. aind_ecephys_s3_to_phy-0.4.0/tests/test_motion_correct.py +47 -0
  33. aind_ecephys_s3_to_phy-0.4.0/tests/test_recording.py +178 -0
  34. aind_ecephys_s3_to_phy-0.4.0/uv.lock +6217 -0
@@ -0,0 +1,23 @@
1
+ # Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
2
+ _commit: 0.1.6
3
+ _src_path: /home/galen.lynch/Documents/Code/aind-python-copier-template
4
+ author_email: galen@galenlynch.com
5
+ author_fullname: Galen Lynch
6
+ current_year: '2026'
7
+ github_org: AllenNeuralDynamics
8
+ github_url: https://github.com/AllenNeuralDynamics/aind-ecephys-s3-to-phy
9
+ include_cli: false
10
+ include_docs: false
11
+ include_notebooks: false
12
+ include_type_hints: true
13
+ institute_name: Allen Institute for Neural Dynamics
14
+ license: MIT
15
+ project_description: Tools to get phy-ready data from AIND ecephys data on S3
16
+ project_name: aind-ecephys-s3-to-phy
17
+ project_slug: aind-ecephys-s3-to-phy
18
+ publish_to_pypi: false
19
+ python_package_import_name: aind_ecephys_s3_to_phy
20
+ python_version: '3.10'
21
+ target_python_version: '3.13'
22
+ workflow_source: AllenNeuralDynamics/galen-uv-workflows
23
+ workflow_version: v2
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe the bug**
11
+ A clear and concise description of what the bug is.
12
+
13
+ **To Reproduce**
14
+ Steps to reproduce the behavior:
15
+ 1. Go to '...'
16
+ 2. Click on '....'
17
+ 3. Scroll down to '....'
18
+ 4. See error
19
+
20
+ **Expected behavior**
21
+ A clear and concise description of what you expected to happen.
22
+
23
+ **Screenshots**
24
+ If applicable, add screenshots to help explain your problem.
25
+
26
+ **Desktop (please complete the following information):**
27
+ - OS: [e.g. iOS]
28
+ - Browser [e.g. chrome, safari]
29
+ - Version [e.g. 22]
30
+
31
+ **Smartphone (please complete the following information):**
32
+ - Device: [e.g. iPhone6]
33
+ - OS: [e.g. iOS8.1]
34
+ - Browser [e.g. stock browser, safari]
35
+ - Version [e.g. 22]
36
+
37
+ **Additional context**
38
+ Add any other context about the problem here.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,27 @@
1
+ ---
2
+ name: User story
3
+ about: This template provides a basic structure for user story issues.
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ # User story
11
+ As a ..., I want to ..., so I can ...
12
+
13
+ *Ideally, this is in the issue title, but if not, you can put it here. If so, delete this section.*
14
+
15
+ # Acceptance criteria
16
+ - [ ] This is something that can be verified to show that this user story is satisfied.
17
+
18
+ # Sprint Ready Checklist
19
+ - [ ] 1. Acceptance criteria defined
20
+ - [ ] 2. Team understands acceptance criteria
21
+ - [ ] 3. Team has defined solution / steps to satisfy acceptance criteria
22
+ - [ ] 4. Acceptance criteria is verifiable / testable
23
+ - [ ] 5. External / 3rd Party dependencies identified
24
+ - [ ] 6. Ticket is prioritized and sized
25
+
26
+ # Notes
27
+ *Add any helpful notes here.*
@@ -0,0 +1,19 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5
+
6
+ version: 2
7
+ updates:
8
+ # Enable version updates for GitHub Actions
9
+ - package-ecosystem: "github-actions"
10
+ # Workflow files stored in the default location of `.github/workflows`
11
+ # You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.
12
+ directory: "/"
13
+ schedule:
14
+ interval: "weekly"
15
+ # Enable version updates for pip
16
+ - package-ecosystem: "pip"
17
+ directory: "/"
18
+ schedule:
19
+ interval: "weekly"
@@ -0,0 +1,33 @@
1
+ name: Bump Version
2
+
3
+ on:
4
+ workflow_run:
5
+ workflows: ["CI"]
6
+ branches: [ main ]
7
+ types: [ completed ]
8
+ workflow_dispatch:
9
+
10
+ permissions:
11
+ contents: write # needed to push commits/tags
12
+ id-token: write # needed if your reusable workflow exchanges OIDC tokens
13
+
14
+ concurrency:
15
+ group: bump-${{ github.workflow }}-${{ github.event.workflow_run.head_branch || github.ref }}
16
+ cancel-in-progress: true
17
+
18
+ jobs:
19
+ bump:
20
+ # Only run when:
21
+ # • a CI run just succeeded (and the head commit message doesn't start with 'bump:')
22
+ # • OR this is a manual dispatch
23
+ if: >
24
+ (github.event_name == 'workflow_run' &&
25
+ github.event.workflow_run.conclusion == 'success' &&
26
+ !startsWith(github.event.workflow_run.head_commit.message, 'bump:')) ||
27
+ (github.event_name == 'workflow_dispatch' &&
28
+ github.ref == 'refs/heads/main')
29
+ uses: AllenNeuralDynamics/galen-uv-workflows/.github/workflows/bump-version.yml@v2
30
+ with:
31
+ default-branch: main
32
+ secrets:
33
+ repo-token: ${{ secrets.SERVICE_TOKEN }}
@@ -0,0 +1,38 @@
1
+ name: CI
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ branches: [ main ]
7
+ pull_request:
8
+ branches: [ main ]
9
+ types: [opened, synchronize, reopened, ready_for_review]
10
+
11
+ permissions:
12
+ contents: read
13
+ pull-requests: read
14
+
15
+ concurrency:
16
+ group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
17
+ cancel-in-progress: true
18
+
19
+ jobs:
20
+ run-ci:
21
+ strategy:
22
+ matrix:
23
+ os: [ubuntu-latest]
24
+ python-version: ["3.11", "3.13"]
25
+
26
+ if: >
27
+ (github.event_name != 'pull_request' || github.event.pull_request.draft == false) &&
28
+ github.actor != 'github-actions[bot]' &&
29
+ !(github.event_name == 'push' && startsWith(github.event.head_commit.message, 'bump:'))
30
+
31
+ uses: AllenNeuralDynamics/galen-uv-workflows/.github/workflows/ci.yml@v2
32
+ with:
33
+ os: ${{ matrix.os }}
34
+ python-version: ${{ matrix.python-version }}
35
+ package-name: aind_ecephys_s3_to_phy
36
+ run-mypy: true
37
+ secrets:
38
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,25 @@
1
+ name: "Release"
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v[0-9]*' # semver tags
7
+ workflow_dispatch:
8
+
9
+ permissions:
10
+ contents: write # create release + upload assets
11
+
12
+ concurrency:
13
+ group: release
14
+ cancel-in-progress: false # let releases finish
15
+
16
+ jobs:
17
+ run-release:
18
+ uses: AllenNeuralDynamics/galen-uv-workflows/.github/workflows/publish.yml@v2
19
+ with:
20
+ tag-name: ${{ github.ref_name }}
21
+ python-version: "3.13"
22
+ publish-to-pypi: true
23
+ secrets:
24
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
25
+ pypi-token: ${{ secrets.AIND_PYPI_TOKEN }}
@@ -0,0 +1,148 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ pip-wheel-metadata/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/build/
73
+
74
+ # PyBuilder
75
+ target/
76
+
77
+ # Jupyter Notebook
78
+ .ipynb_checkpoints
79
+
80
+ # IPython
81
+ profile_default/
82
+ ipython_config.py
83
+
84
+ # pyenv
85
+ # .python-version
86
+
87
+ # pipenv
88
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
90
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
91
+ # install all needed dependencies.
92
+ #Pipfile.lock
93
+
94
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
95
+ __pypackages__/
96
+
97
+ # Celery stuff
98
+ celerybeat-schedule
99
+ celerybeat.pid
100
+
101
+ # SageMath parsed files
102
+ *.sage.py
103
+
104
+ # Environments
105
+ .env
106
+ .venv
107
+ env/
108
+ venv/
109
+ ENV/
110
+ env.bak/
111
+ venv.bak/
112
+
113
+ # Spyder project settings
114
+ .spyderproject
115
+ .spyproject
116
+
117
+ # Rope project settings
118
+ .ropeproject
119
+
120
+ # mkdocs documentation
121
+ /site
122
+
123
+ # mypy
124
+ .mypy_cache/
125
+ .dmypy.json
126
+ dmypy.json
127
+
128
+ # Pyre type checker
129
+ .pyre/
130
+
131
+ # PyCharm
132
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
133
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
134
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
135
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
136
+ .idea/
137
+
138
+ # MacOs
139
+ **/.DS_Store
140
+
141
+ # VSCode
142
+ .vscode/
143
+
144
+ # Claude
145
+ .claude/
146
+
147
+ # MWE working directory
148
+ mwe_workdir/
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,26 @@
1
+ # .readthedocs.yaml
2
+ version: 2
3
+
4
+ # RTD will run `sphinx-build` for you using this conf.py
5
+ sphinx:
6
+ configuration: docs/source/conf.py
7
+
8
+ build:
9
+ os: ubuntu-24.04
10
+ tools:
11
+ python: "3.13"
12
+
13
+ jobs:
14
+ # Install uv once at the OS level, before creating the venv
15
+ pre_create_environment:
16
+ - asdf plugin add uv
17
+ - asdf install uv latest
18
+ - asdf global uv latest
19
+
20
+ # Create the RTD virtualenv using uv so RTD will use it for the build
21
+ create_environment:
22
+ - uv venv "$READTHEDOCS_VIRTUALENV_PATH"
23
+
24
+ # Install your docs deps from pyproject (respects uv.lock if present)
25
+ install:
26
+ - UV_PROJECT_ENVIRONMENT="$READTHEDOCS_VIRTUALENV_PATH" uv sync --frozen --group docs
@@ -0,0 +1,53 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## v0.4.0 (2026-10-24)
9
+
10
+ ### Feat
11
+
12
+ - add lazy-trace export to convert
13
+
14
+ ### Fix
15
+
16
+ - correct traces with KS4's saved motion via aind-ephys-assets
17
+
18
+ ## v0.3.0 (2026-04-12)
19
+
20
+ ### Feat
21
+
22
+ - apply KS4 motion correction when exporting to phy
23
+ - populate cluster_group.tsv from KSLabel + decoder_label
24
+
25
+ ### Fix
26
+
27
+ - remove unsupported overwrite kwarg from Motion.save() in tests (#4)
28
+ - stash binary files in parent dir during re-export
29
+
30
+ ## v0.2.0 (2026-03-30)
31
+
32
+ ### Feat
33
+
34
+ - write binary before spike export, compute PCs from local disk
35
+ - make export_phy idempotent for binary write and compression
36
+ - add --check-compression flag to skip mtscomp verification
37
+ - enable kebab-case CLI flags and subcommand names
38
+ - support local paths in discovery functions
39
+ - add --compress flag to extract_recording subcommand
40
+ - add extract_recording subcommand and rewrite README
41
+ - implement S3-to-phy conversion pipeline with CLI
42
+
43
+ ### Fix
44
+
45
+ - guarantee binary file restoration with try/finally
46
+ - stash binary files in parent dir during re-export
47
+ - preserve binary files when re-exporting spike data
48
+ - enable amplitudes and PC features in phy export
49
+ - use thread pool for binary writing instead of fork
50
+
51
+ ### Refactor
52
+
53
+ - switch CLI from pydantic-settings to tyro
@@ -0,0 +1,135 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ **aind-ecephys-s3-to-phy** — CLI tools to convert AIND ecephys sorted recordings and raw recordings (two separate S3 assets) into [phy](https://github.com/cortex-lab/phy) directories for manual curation, including raw trace access. Uses [SpikeInterface](https://github.com/SpikeInterface/spikeinterface) for the conversion and [pydantic-settings](https://docs.pydantic.dev/latest/concepts/pydantic_settings/) for CLI argument parsing.
8
+
9
+ `src/` layout, `hatchling` build backend, `uv` for dependency management.
10
+
11
+ ## Commands
12
+
13
+ ```bash
14
+ # Setup
15
+ uv sync
16
+
17
+ # Full linting + tests (use before committing)
18
+ ./scripts/run_linters_and_checks.sh -c
19
+
20
+ # Format only (no checks)
21
+ ./scripts/run_linters_and_checks.sh
22
+
23
+ # Individual tools (when venv is active, drop "uv run --frozen")
24
+ uv run --frozen ruff format
25
+ uv run --frozen ruff check
26
+ uv run --frozen mypy
27
+ uv run --frozen interrogate -v
28
+ uv run --frozen codespell --check-filenames
29
+ uv run --frozen pytest --cov aind_ecephys_s3_to_phy
30
+
31
+ # Run a single test
32
+ uv run --frozen pytest tests/test_example.py -k "test_name"
33
+
34
+ # Pass extra pytest args via the script
35
+ ./scripts/run_linters_and_checks.sh -c -- -k "test_name"
36
+ ```
37
+
38
+ ## Code Style & Tooling
39
+
40
+ - **Line length**: 120
41
+ - **Target Python**: 3.11+ (minimum 3.10)
42
+ - **Ruff rules**: Q, RUF100, C90, I, F, E, W, D, UP, ANN, PYI (type annotations not required in tests)
43
+ - **Docstrings**: NumPy convention, 30% coverage minimum (interrogate)
44
+ - **Type checking**: mypy strict mode on `src/` (relaxed in tests)
45
+ - **Commits**: Angular convention via commitizen (semantic versioning)
46
+
47
+ ## Architecture
48
+
49
+ ### Domain: AIND Ecephys Data on S3
50
+
51
+ Two separate S3 assets are involved per session:
52
+
53
+ 1. **Raw asset** (e.g. `s3://aind-open-data/ecephys_786867_2025-09-25_12-43-56/`)
54
+ - Contains compressed Zarr recordings under `ecephys/ecephys_compressed/`
55
+ - One Zarr per probe per experiment (e.g. `experiment1_Record Node 109#Neuropix-PXI-100.46101.zarr`)
56
+
57
+ 2. **Sorted asset** (e.g. `s3://aind-open-data/ecephys_786867_2025-09-25_12-43-56_sorted_2025-12-24_08-46-14/`)
58
+ - `postprocessed/` — SortingAnalyzer as Zarr (one per recording), with precomputed extensions (templates, waveforms, PCs, quality metrics, etc.)
59
+ - `preprocessed/` — JSON files describing SpikeInterface preprocessing chains (not actual trace data)
60
+ - `spikesorted/` — NumpySorting format
61
+ - `curated/` — Subset with auto-curation labels
62
+
63
+ Each sorted asset can have many recordings (e.g. 10 probes x 3 experiments = 30). Users select specific probes/streams/experiments to export.
64
+
65
+ ### Conversion Pipeline
66
+
67
+ ```
68
+ SortingAnalyzer (S3)
69
+ ├─ Load from S3 (stream, don't download)
70
+ ├─ Extract recording dict (full preprocessing chain with ChannelSlice)
71
+ └─ Load templates extension (lazy, on demand)
72
+ │
73
+ ▼
74
+ Recording dict ──→ Substitute raw Zarr S3 URI at leaf
75
+ ──→ _load_extractor_from_dict()
76
+ ──→ Preprocessed recording (373 ch, filtered)
77
+ │
78
+ ├─ Attach to analyzer via _recording = rec
79
+ │
80
+ ▼
81
+ si.export_to_phy(analyzer, copy_binary=False)
82
+ ──→ spike data (.npy, .tsv, params.py)
83
+ │
84
+ ▼
85
+ write_binary_recording(rec, "recording.dat")
86
+ ──→ Streams from S3 → flat .dat
87
+ │
88
+ ▼
89
+ mtscomp.compress("recording.dat")
90
+ ──→ recording.cbin + recording.ch
91
+ ──→ Update params.py, delete .dat
92
+ ```
93
+
94
+ Key details:
95
+ - **Preprocessing reconstruction**: `get_preprocessing_dict_from_analyzer()` extracts the chain from the SortingAnalyzer Zarr. `apply_preprocessing_pipeline()` applies it to the raw recording, so phy shows filtered/referenced traces (not raw).
96
+ - **mtscomp (.cbin)**: Phy natively supports `.cbin` files via phylib's `MtscompEphysReader`. ~3x lossless compression with random-access decompression. Avoids storing massive flat `.dat` files.
97
+ - **Phy trace format support**: `.dat`/`.bin`/`.raw`/`.mda` (flat binary), `.cbin` (mtscomp), `.npy` (numpy). No Zarr/HDF5.
98
+ - **`export_to_phy` requires**: SortingAnalyzer with at least `templates` extension computed. Single-segment recordings only.
99
+ - **S3 access**: SpikeInterface uses fsspec/s3fs. Anonymous access tried first (works for public `aind-open-data`). Standard AWS credential chain for private buckets.
100
+
101
+ ### MWE Results & Design Decisions (from `scripts/test_data_access.py`)
102
+
103
+ **Data access strategy** (benchmarked on a single recording, 60s binary write):
104
+ - **SortingAnalyzer**: Stream from S3 (3s load + 2.4s templates). Do NOT download first (55s download + 9s load is much slower). Extensions are lazy-loaded on demand for remote paths.
105
+ - **Raw recording → binary**: Stream directly from S3 during `write_binary_recording` (87s for 60s of data). Only 1.35x slower than local, and avoids the ~290s download of 30 GB raw zarr. **Streaming is the right default.**
106
+ - **mtscomp**: 2.52x compression ratio, 10s for 1.3 GB. Fast and worth doing by default.
107
+
108
+ **Critical gotchas discovered**:
109
+ - **`get_preprocessing_dict_from_analyzer()` skips `ChannelSlice` steps** (by design). The AIND pipeline applies bad-channel removal via `ChannelSliceRecording`, so the simplified pipeline produces a recording with 384 channels while the analyzer expects ~373. **Must reconstruct the full chain** from the analyzer's stored recording dict (`zarr_root["recording"][0]`) and substitute the raw recording path at the leaf `ZarrRecordingExtractor`.
110
+ - **`export_to_phy` ignores `_temporary_recording`**: The function checks `has_recording()` which only looks at `_recording`, not `_temporary_recording`. Workaround: set `analyzer._recording = preprocessed_rec` directly after validation via `set_temporary_recording()`.
111
+ - **Raw recordings use WavPack codec**: Requires `wavpack-numcodecs` package.
112
+ - **Analyzer naming**: Postprocessed zarr names have `_recording1` suffix (e.g. `...50213-1_recording1.zarr`) while raw zarr names don't (e.g. `...50213-1.zarr`). Strip `_recording\d+` to match.
113
+ - **Only experiment1 has postprocessed data** in the test dataset, and raw recordings are ~30 GB each (95 GB as flat .dat).
114
+
115
+ ### CLI Design (pydantic-settings)
116
+
117
+ Uses `pydantic_settings.BaseSettings` with `CliApp.run` pattern and subcommands:
118
+
119
+ - **Happy-path command**: One command that downloads + preprocesses + exports + compresses
120
+ - **Subcommands**: Separate steps for download, export, compress — for flexibility/debugging
121
+ - **Entry point**: `[project.scripts]` in pyproject.toml
122
+
123
+ Output structure: working directory based on S3 asset name, with phy folders per probe/experiment.
124
+
125
+ ### Key Dependencies
126
+
127
+ - **spikeinterface** (PyPI) — SortingAnalyzer loading, preprocessing pipeline, `export_to_phy`
128
+ - **pydantic-settings** — CLI argument parsing via BaseSettings
129
+ - **mtscomp** — Compress recording.dat → .cbin for phy trace view
130
+ - **s3fs/fsspec** — S3 access (transitive via spikeinterface)
131
+
132
+ ### Local Reference Repos
133
+
134
+ - SpikeInterface: `~/Documents/Code/spikeinterface`
135
+ - phy: `~/Documents/Code/phy`
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Allen Institute for Neural Dynamics
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+