3 add change detection events and trials table#5
Merged
arielleleon merged 17 commits intoJul 17, 2026
Conversation
build_events_table initialized lick_classification, bout_start, and reward_type with np.nan (float64), then _classify_rewards/_classify_licks assigned strings into them. Older pandas silently upcast to object; pandas 3.0 enforces the dtype and raises "Invalid value ... for dtype float64" when packaging a change-detection session. Initialize these three columns as object dtype up front, preserving the NaN sentinels the NWB layer reads via pd.notna. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
pynwb 4.0 moved events/HED support into core, so the native NWBFile `events` field collides with the one the standalone ndx-events adds via NdxEventsNWBFile, raising "NdxEventsNWBFile.__init__: names duplicated: ['events']". The library was declared with unbounded deps, so a plain pip install resolved pynwb 4 and broke. Add version bounds (pynwb <4, ndx-events <0.5, ndx-hed <0.3) matching the standalone-extension / pynwb 3.x line the code targets, and re-lock. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Extract encoder lookup into `_encoder_from_pkl` and add an `encoder_keys`
argument to `compute_running_speed` (default `("behavior",)`, unchanged for
change-detection). The passive SweepStim path passes `("foraging", "behavior")`
so it can read the foraging-item encoder, falling back to behavior.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Port the capsule's `sweepstim_packaging` into the library, refactored into the two-layer architecture: - load_data/sweepstim.py: `classify_sweepstim_session`, `compute_sweepstim_timestamp_alignment`, and `build_sweepstim_session` returning a new `SweepStimData` (presentation + epoch DataFrames + timing). Pure numpy/pandas/h5py; HED is left to the nwb layer. - nwb/sweepstim.py: subject/file builder, `stimulus_presentations` and flat `intervals` TimeIntervals builders, sidecar, `assemble_sweepstim_nwbfile`, and the one-call `package_sweepstim_nwb` (NWB-Zarr + events.json), mirroring `package_nwb`. HED fragments/helpers for passive sessions live in nwb/hed_tags.py (single source of truth). Classification/session builders are re-exported eagerly; `package_sweepstim_nwb` is lazy (pynwb). Full synthetic pkl+sync fixtures and tests keep flake8, interrogate (100%), and coverage (100%) green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
package_nwb is change-detection-only, so a passive SweepStim pkl (no items['behavior']) fails deep inside the Stage-1 extractor with a confusing KeyError. Add package_session, which loads the pkl, classifies it with classify_sweepstim_session, and dispatches to package_sweepstim_nwb (passive) or package_nwb (change-detection), forwarding all keyword arguments. This lets a mixed batch be packaged through one entry point without knowing each session's type up front. - nwb/__init__.py: new package_session + __all__/docstring updates. - __init__.py: lazy root re-export (pynwb stays off the eager import path). - tests/test_package_session.py: routing (both branches via the real classifier) + kwargs-forwarding. Gates green: flake8, interrogate 100%, 152 tests, coverage 100%. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
matchings
reviewed
Jul 17, 2026
matchings
reviewed
Jul 17, 2026
matchings
reviewed
Jul 17, 2026
matchings
reviewed
Jul 17, 2026
matchings
reviewed
Jul 17, 2026
matchings
reviewed
Jul 17, 2026
matchings
reviewed
Jul 17, 2026
matchings
reviewed
Jul 17, 2026
matchings
approved these changes
Jul 17, 2026
matchings
left a comment
Collaborator
There was a problem hiding this comment.
i noted a few places where task parameter descriptions could be changed but i dont think that needs to block merge of this PR, as long as they are noted for the future.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.