Skip to content

Implement phy curation support for updating ALF spike tables#20

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-19
Draft

Implement phy curation support for updating ALF spike tables#20
Copilot wants to merge 3 commits intomainfrom
copilot/fix-19

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 4, 2025

This PR implements functionality to allow users to manually curate spike sorting results in phy and update the ALF format spike tables accordingly, as requested in issue #19.

Overview

The implementation adds a new convert_ks_to_alf.py script in the postprocess module that handles updating ALF tables after manual curation in phy. This is inspired by ibllib's populate_cluster_table.py but removes the datajoint dependency while maintaining full ALF format compatibility.

Key Features

  • Seamless phy integration: Process cluster labels, notes, and merges from phy output files
  • Cluster merge detection: Automatically detect merged clusters by comparing spikes.clusters.npy vs spikes.templates.npy
  • UUID tracking: Maintain cluster identities across curation sessions using persistent UUIDs
  • Flexible CLI: Support for initial export, update-only, or combined operations
  • Pipeline integration: Works with existing cibrrig spike sorting pipeline

Workflow Enabled

  1. Run initial pipeline: npx_run_all (creates spike sorting + initial ALF export)
  2. Manual curation: phy template-gui kilosort4/params.py (label clusters, merge, add notes)
  3. Update ALF: convert_ks_to_alf ./ kilosort4 --update-only (ALF tables updated with curation)

Files Created/Updated

  • cibrrig/postprocess/convert_ks_to_alf.py - Main implementation with complete functionality
  • cibrrig/postprocess/README.md - Documentation for the new functionality
  • readme.md - Updated workflow documentation and CLI command descriptions
  • pyproject.toml - CLI entry point already existed but now has working implementation

ALF Files Generated

  • clusters.uuids.csv - Cluster UUID tracking for identity persistence
  • clusters.labels.csv - Updated cluster labels and metadata from phy
  • merge_info.csv - Information about merged clusters (when applicable)
  • Updated spike files with curation results

The implementation ensures that ALF tables remain compatible with existing ibllib/brainbox workflows while providing the manual curation capabilities that were missing from the pipeline.

Fixes #19.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Sep 4, 2025

@nbush257 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Copilot AI changed the title [WIP] Allow user to curate in phy and update the spike table Implement phy curation support for updating ALF spike tables Sep 4, 2025
Copilot AI requested a review from nbush257 September 4, 2025 20:14
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.

Allow user to curate in phy and update the spike table

2 participants