Correlate a behavioral covariate with binned photometry - #425
Merged
Conversation
pauladkisson
added a commit
that referenced
this pull request
Aug 11, 2026
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
pauladkisson
marked this pull request as draft
August 11, 2026 21:28
pauladkisson
added a commit
that referenced
this pull request
Aug 13, 2026
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
pauladkisson
force-pushed
the
covariates
branch
from
August 13, 2026 22:20
b0c9837 to
a92ff94
Compare
pauladkisson
added a commit
that referenced
this pull request
Aug 21, 2026
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
pauladkisson
force-pushed
the
covariates
branch
from
August 21, 2026 15:56
5533f6d to
1befd7d
Compare
pauladkisson
added a commit
that referenced
this pull request
Aug 21, 2026
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
pauladkisson
force-pushed
the
covariates
branch
from
August 21, 2026 16:05
1befd7d to
37f4b3c
Compare
pauladkisson
marked this pull request as ready for review
August 21, 2026 16:16
pauladkisson
added a commit
that referenced
this pull request
Aug 21, 2026
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
pauladkisson
force-pushed
the
covariates
branch
from
August 21, 2026 16:31
b772cfe to
396a448
Compare
This was referenced Aug 21, 2026
pauladkisson
added a commit
that referenced
this pull request
Aug 21, 2026
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
pauladkisson
force-pushed
the
covariates
branch
from
August 21, 2026 19:18
b057d51 to
2ade6a4
Compare
pauladkisson
added a commit
that referenced
this pull request
Aug 22, 2026
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
pauladkisson
force-pushed
the
covariates
branch
from
August 22, 2026 00:22
4501888 to
07357cf
Compare
Adds a "behavioral covariate" store type: a continuous variable measured outside the rig is ingested as an ordinary GuPPy-CSV, labeled in Step 1, averaged onto the bins Step 4 already produces, and correlated against every per-bin metric. Pearson r and Spearman rho are reported as descriptive statistics with no p-value, since both series are autocorrelated across bins. Consolidates the ten copies of the "control"/"signal" substring test into is_channel_label / is_covariate_label / is_event_label. Without a single predicate a covariate went down the event path, which dropped its scored values and computed a PSTH around its sample times. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Merging #427 left two spellings of "should this store be treated as an event" in the tree: is_event_label at one site and is_channel_label at eight others. Step 4 crashed as a result — execute_compute_psth skipped the covariate while execute_compute_psth_peak_and_area did not, then tried to read the PSTH file that was never written. Replaces is_event_label with is_continuous_label, the union of channels and covariates, which is what every one of those sites is really asking. Call sites read positively, matching the shape #427 settled on. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
pauladkisson
force-pushed
the
covariates
branch
from
August 23, 2026 22:43
645559d to
c95bc7d
Compare
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.
Follow-ups
Details (AI-generated)
Closes #420. Stacked on #422 — base is
binned_metrics, notmain.Adds a behavioral covariate store type. A continuous variable measured outside the rig is written as an ordinary GuPPy-CSV (
timestamps,data,sampling_rate), dropped in the session folder, and labeled in Step 1; Step 2 carries it into the run folder, Step 3 skips it, and Step 4 averages it onto the bins from #422 and correlates it against every per-bin metric. Outputs arebinned_covariates_<site>andcovariate_correlations_<site>(.h5and.csv). Step 5 gains a Covariates tab: a scatter colored by bin number, plus the full correlations table.No new input parameter — labeling the store is the opt-in. Combine mode and
concatenateartifact removal are rejected, since covariate timestamps cannot be interpreted against either time axis.No p-value, deliberately. Per Harris (2020), Nonsense correlations in neuroscience, per-bin photometry and a slowly varying behavioral score are both strongly autocorrelated, and the standard tests assume independent samples — false-positive rates reach 100% in simulation, and circular shifting and phase randomization do not fix it. The only defensible null here is a session permutation, which needs the group-analysis overhaul. So
pearson_r,spearman_rhoandn_binsship as descriptive numbers, with the reasoning in the how-to andoutputs.md.Builds on #427, which names the
is_channel_labelstore-label predicate. That refactor started here: with nothing but "is this a channel" to test, a covariate went down the event path — Step 3 wrote a timestamps-only artifact that dropped the scored values, and Step 4 computed a PSTH around its sample times. This PR addsis_covariate_labelandis_event_label(neither a channel nor a covariate), and moves the sites that mean "skip anything that is not an event" — artifact removal, session combining, PSTH computation and group averaging, the visualization event list — onto it. That switch is the fix, so it stays visible here.Verification: 30 new unit tests plus
tests/integration/test_covariate_correlations.py(10 tests), including regression guards that nocovariate_*_<site>.hdf5is written and that the correlations table has no p-value column. Correlation literals were cross-checked againstscipy.stats.pearsonr/spearmanr.test_integration_step3/4/5andtest_binned_metricspass unchanged.pre-commitclean.Follow-ups: session-permutation inference (with the explanation page it needs) and format relaxations from beta feedback — the
sampling_ratecolumn is required by the format but read by nothing here.🤖 Generated with Claude Code