Skip to content

Conversation

@colehanan1
Copy link
Owner

@colehanan1 colehanan1 commented Jan 8, 2026

Adds control-subtraction support in LASSO fits, CLI for ΔPER runs, tests, and doc update.

Summary by CodeRabbit

  • New Features

    • Added control-subtracted (ΔPER) mode for LASSO behavioral predictions, enabling analysis of control-corrected behavioral responses with flexible missing-data handling policies
    • New command-line script for executing behavioral predictions with control-subtraction support
  • Documentation

    • Updated with control-subtracted workflow examples and command-line usage patterns
  • Tests

    • Added comprehensive test coverage for control-subtraction functionality

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 8, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR introduces control-subtraction (ΔPER) functionality to LASSO-based behavioral prediction. It adds a new CLI script, extends the core behavioral prediction library with control-condition matching and missing-control policies, updates documentation with usage examples, and includes comprehensive tests for the new workflow.

Changes

Cohort / File(s) Summary
Documentation
docs/BEHAVIORAL_PREDICTION_ANALYSIS.md
Added new subsection "5.6 Control-Subtracted (ΔPER) Runs" with CLI examples for LASSO fitting on control-subtracted targets, including --subtract_control, --missing_control_policy, and optional control-condition overrides.
Core Library
src/door_toolkit/pathways/behavioral_prediction.py
Extended LassoBehavioralPredictor.fit_behavior() with control-subtraction parameters (subtract_control, control_condition, missing_control_policy). Added BehaviorModelResults fields for tracking control metadata. Introduced helper methods for control-condition resolution and dataset normalization.
CLI Script
scripts/run_lasso_behavioral_prediction.py
New script orchestrating LASSO behavioral prediction with control subtraction support. Handles condition parsing, missing-control fallback logic, per-condition output generation, and optional summary CSV export.
Tests
tests/test_lasso_behavioral_prediction.py
Added control-subtraction test fixtures and new TestLassoBehavioralPredictorControlSubtraction suite validating control alignment, NaN handling, and missing-control error policies.

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as run_lasso_behavioral_prediction.py
    participant Parser as Argument Parser
    participant Predictor as LassoBehavioralPredictor
    participant DataLoader as Data Alignment
    participant LASSO as LASSO Fitting
    participant FileOutput as Output Generation

    User->>CLI: Execute with --subtract_control flags
    CLI->>Parser: Parse conditions, lambda range, policies
    Parser->>CLI: Return parsed arguments
    loop Per Condition
        CLI->>Predictor: fit_behavior(condition, subtract_control=True)
        Predictor->>Predictor: _infer_control_condition()
        Predictor->>DataLoader: Load opto & control behavior data
        DataLoader->>DataLoader: Align pairs by missing_control_policy
        DataLoader->>Predictor: Return ΔPER (opto − control)
        Predictor->>LASSO: Fit model on ΔPER targets
        LASSO->>Predictor: Return BehaviorModelResults
        Predictor->>CLI: Return results with metadata
        CLI->>FileOutput: Save plots, CSV, JSON (with mode prefix)
    end
    FileOutput->>User: Generated outputs per condition
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

  • colehanan1/door-python-toolkit#1: Introduces new subtract_control, control_condition, and missing_control_policy parameters to LassoBehavioralPredictor.fit_behavior() that the CLI script directly depends on.

Poem

🐰 Control-subtracted deltas hop and bound,
ΔPER whispers calculations profound,
When opto meets control in paired embrace,
The neural predictions find their rightful place! ✨

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3225982 and 64c79ce.

📒 Files selected for processing (4)
  • docs/BEHAVIORAL_PREDICTION_ANALYSIS.md
  • scripts/run_lasso_behavioral_prediction.py
  • src/door_toolkit/pathways/behavioral_prediction.py
  • tests/test_lasso_behavioral_prediction.py

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@colehanan1 colehanan1 merged commit a3dfa99 into main Jan 8, 2026
0 of 16 checks passed
@colehanan1 colehanan1 deleted the feature/lasso-subtract-control branch January 8, 2026 19:51
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.

2 participants