Skip to content

Add np_sync module for VR-to-NP barcode alignment and tests - #343

Open
CeliaBenquet wants to merge 39 commits into
mainfrom
celia/np-vr-sync
Open

Add np_sync module for VR-to-NP barcode alignment and tests#343
CeliaBenquet wants to merge 39 commits into
mainfrom
celia/np-vr-sync

Conversation

@CeliaBenquet

@CeliaBenquet CeliaBenquet commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator
  • Update cron scenario workflow.
  • change to PROBE barcode.
  • Test once vr barcode is properly populated.

This pull request introduces a new pipeline for aligning VR (behavior) time to Neuropixels (NP) native time using shared barcode events, along with documentation and unit tests. The main changes include adding the barcode alignment fitting logic, a DataJoint table for storing and applying the alignment, and updating configuration and documentation to support and describe the new functionality.

Barcode alignment pipeline for VR-to-NP time synchronization:

  • Added a new module vr4mice/analysis/np_sync.py implementing the barcode alignment logic, including a dataclass BarcodeAlignmentFit and the align_barcodes function to fit a linear mapping and interpolator from VR to NP time using shared barcode events.
  • Added a new DataJoint computed table BarcodeSync in vr4mice/schema/np_sync.py to store the fitted alignment for each dataset/recording/DAQ, with methods to convert VR times to NP times using either the interpolator or the linear fit. This table handles missing data gracefully and logs errors.

Configuration and integration:

  • Updated .env.compose.example and docker-compose.yml to mount the np_pipeline source directory into the container, ensuring that the VR pipeline can import NP schema definitions for alignment.

Documentation:

  • Extended the DataJoint schema documentation (docs/software/datajoint.md) to include the new barcode alignment table and describe its dependencies and usage.

Testing:

  • Added unit tests for the barcode alignment logic in test_np_sync.py, covering correct recovery of known fits, handling of missing values, skipping of unreliable early events, and correctness of the interpolator.This PR introduces a new utility for aligning VR and Neuropixels (NP) event streams using shared barcode values, along with its configuration and unit tests. The main addition is a function that computes a linear mapping and interpolator from VR event times to NP event times based on shared barcodes, addressing issues with unreliable early events. The changes also include Docker configuration updates to ensure the necessary code is available in the container.

Barcode alignment utility:

  • Added align_barcodes function and BarcodeAlignmentFit dataclass in vr4mice/analysis/np_sync.py to compute a linear regression and interpolator from VR to NP time using shared barcode events, with an option to skip unreliable early events.
  • Added unit tests in tests/unit/test_np_sync.py to verify correct recovery of linear fits, handling of missing/extra barcodes, skipping of early events, and the interpolator’s accuracy.

Docker and environment configuration:

  • Added NP_PIPELINE_SRC_PATH to .env.compose.example to specify the path to the required np_pipeline source code for imports.
  • Updated docker-compose.yml to mount the np_pipeline source directory into the container using the new environment variable.

@CeliaBenquet CeliaBenquet self-assigned this Aug 5, 2026
@CeliaBenquet
CeliaBenquet force-pushed the celia/add-batch-tables branch from 25590e9 to 25ba627 Compare August 5, 2026 13:51
@CeliaBenquet CeliaBenquet added the enhancement New feature or request label Aug 5, 2026
@CeliaBenquet CeliaBenquet added the Datajoint For issues related to the datajoint pipeline rather than the vr4mice game label Aug 5, 2026
@CeliaBenquet
CeliaBenquet changed the base branch from celia/add-batch-tables to main August 10, 2026 13:06
Signed-off-by: Célia Benquet <32598028+CeliaBenquet@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Datajoint For issues related to the datajoint pipeline rather than the vr4mice game enhancement New feature or request wip

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant