summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYurenHao0426 <Blackhao0426@gmail.com>2026-07-22 20:01:34 -0500
committerYurenHao0426 <Blackhao0426@gmail.com>2026-07-22 20:01:34 -0500
commita5ba631e7e5562246a9f339fad1303747c72e6ac (patch)
treec1d687971885b578386f07197bc71128f5638e74
parent081bea6bfa20cdb8efdf1432281703eb2f47998e (diff)
test: verify temporal plasticity lesion boundary
-rw-r--r--experiments/bci_smoke.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/experiments/bci_smoke.py b/experiments/bci_smoke.py
index 1fda89e..89f07ef 100644
--- a/experiments/bci_smoke.py
+++ b/experiments/bci_smoke.py
@@ -149,6 +149,35 @@ def check_temporal_difference_role_vectorizer():
f"cos={cosine:.6f}, sign_index={sign_index.item():.6f}")
+def check_temporal_difference_plasticity_boundary():
+ cfg = BCIConfig(
+ days=2, episodes_per_day=32, steps_per_episode=6,
+ feedback="performance_velocity", forward_eta=0.03, kappa=0.0)
+ trajectories = generate_trajectories(cfg, 14)
+ initial = BCISDIL(cfg, model_seed=15)
+ initial.P.copy_(initial.coupling)
+ initial.A[:, 0].copy_(initial.role)
+ intact = initial.clone()
+ lesion = initial.clone()
+ report_intact = run_day(
+ intact, trajectories, 0, plasticity_gain=1.0,
+ control_gain=0.0, learn_vectorizer=False, learn_predictor=False,
+ collect=True)
+ report_control_sham = run_day(
+ initial.clone(), trajectories, 0, plasticity_gain=1.0,
+ control_gain=1.0, learn_vectorizer=False, learn_predictor=False,
+ collect=True)
+ run_day(
+ lesion, trajectories, 0, plasticity_gain=0.0,
+ control_gain=0.0, learn_vectorizer=False, learn_predictor=False)
+ assert not torch.equal(intact.W, initial.W)
+ assert torch.equal(lesion.W, initial.W)
+ for left, right in zip(
+ report_intact["events"], report_control_sham["events"]):
+ assert torch.equal(left["soma"], right["soma"])
+ print("BCI temporal-difference plasticity/online boundary: exact")
+
+
def check_grouped_decoders_and_metrics():
generator = torch.Generator().manual_seed(9)
groups = torch.arange(200)
@@ -193,5 +222,6 @@ if __name__ == "__main__":
check_predictor_identification()
check_phase_masks_and_velocity_reset()
check_temporal_difference_role_vectorizer()
+ check_temporal_difference_plasticity_boundary()
check_grouped_decoders_and_metrics()
print("ALL BCI MECHANICS CHECKS PASSED")