Skip to content

feat: add CaDecon Python bridge for automated deconvolution export#108

Merged
daharoni merged 2 commits into
mainfrom
feat/cadecon-python-bridge
Mar 22, 2026
Merged

feat: add CaDecon Python bridge for automated deconvolution export#108
daharoni merged 2 commits into
mainfrom
feat/cadecon-python-bridge

Conversation

@daharoni
Copy link
Copy Markdown
Contributor

@daharoni daharoni commented Mar 22, 2026

Summary

  • calab.decon(traces, fs) — new Python bridge that opens CaDecon in the browser and returns structured CaDeconResult (activity matrix, per-cell alphas/baselines/PVEs, kernel waveforms, metadata)
  • Binary transport — two-POST pattern sends activity as .npy (potentially 10s of MB) followed by JSON scalars/metadata, mirroring the inbound data flow
  • calab cadecon CLI — new subcommand for file-based automated deconvolution with optional output saving
  • Export button wired — CaDecon UI ExportButton now functional with bridge detection, loading states, and completion feedback

New files

File Purpose
packages/io/src/npy-writer.ts Write .npy binary (inverse of npy-parser)
packages/io/src/__tests__/npy-writer.test.ts Roundtrip + format tests
apps/cadecon/src/lib/export-utils.ts Collect iteration-store results for export
python/tests/test_decon.py CaDeconResult + biexp waveform tests

Modified files

File Changes
packages/io/src/bridge.ts postActivityToBridge, postResultsToBridge, exportCaDeconToBridge
packages/io/src/index.ts Export new functions
apps/cadecon/.../GroundTruthControls.tsx Wire ExportButton with bridge export
python/.../_{compute,server,apps,cli,init} CaDeconResult, server endpoints, decon(), CLI
python/tests/test_bridge.py 5 new CaDecon endpoint tests

Test plan

  • npy-writer roundtrip tests pass (7 tests)
  • Python bridge endpoint tests pass (5 new + 11 existing = 16 total)
  • CaDeconResult + biexp waveform tests pass (7 tests)
  • Full Python suite passes (118 tests)
  • Full IO package TS tests pass (42 tests)
  • TypeScript type-check passes (no new errors)
  • Formatting clean (npm run format)
  • E2E: calab.decon(traces, fs=30, app_url="http://localhost:5175/") → run solver → Export to Python → verify result fields

🤖 Generated with Claude Code

daharoni and others added 2 commits March 21, 2026 22:22
Enable `calab.decon(traces, fs)` to open CaDecon in the browser and
receive structured results (activity matrix + per-cell scalars + kernel
params) back to Python via a two-POST binary transport pattern.

- Add npy-writer.ts (inverse of npy-parser) for binary activity export
- Extend bridge server with /api/v1/results/activity (.npy) and
  /api/v1/results (JSON) endpoints, plus configurable app param
- Add decon() orchestrator, CaDeconResult NamedTuple, biexp waveform
  builder, and `calab cadecon` CLI subcommand
- Wire ExportButton in CaDecon UI with loading/disabled states
- 22 new tests (7 npy-writer, 5 bridge endpoints, 7 CaDeconResult, 3 waveform)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extract shared _run_bridge() helper from tune()/decon() to eliminate
~60 lines of duplicated polling/heartbeat/shutdown boilerplate. Extract
sortedCellIndices() in export-utils to avoid double-sorting lookup keys.
Remove postActivityToBridge/postResultsToBridge from public io exports
since they're internal to exportCaDeconToBridge.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@daharoni daharoni merged commit 2909604 into main Mar 22, 2026
2 checks passed
@daharoni daharoni deleted the feat/cadecon-python-bridge branch March 22, 2026 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant