Reproducing Li, Daie, Svoboda & Druckmann (2016) from CRCNS alm-3¶
Paper. Li N, Daie K, Svoboda K, Druckmann S (2016). Robust neuronal dynamics in premotor cortex during motor planning. Nature 532, 459-464. doi:10.1038/nature17643. The claims file was written from the accepted author manuscript in PubMed Central (PMC5081260): main text, Methods and the legends of Figures 1 to 6 and Extended Data Figures 1 to 10.
Data set. CRCNS alm-3, doi:10.6080/K0RB72JW, "Data and
simulations related to: Robust neuronal dynamics in premotor cortex during motor planning",
data description version 0.71 (April 19, 2018). Files are streamed from the public S3 bucket
crcnsarchive, under alm-3/live/. Version: unversioned. CRCNS data sets have no versions, and
the paper cites none, so the pinned version is the live copy, the only copy of the data files
(alm-3/orig/ holds only documentation); the MD5 sum of each of the 91 session files is computed from the
bytes read and compared in the data check with the data set's checksums.md5, and printed, so
that a later change can be detected. The raw voltage traces (data/RawVoltageTraces/, 6 to 12 GB per session) are not used.
Methods from the authors' code. The data set holds the authors' MATLAB analysis scripts
(alm-3/live/analyses_scripts/), which its description says reproduce the paper's figures. The
claims file did not read them. Where the claims file leaves a detail open, this notebook takes it
from the Methods, and where the Methods leave it open, from these scripts, citing the file and
section; where the scripts disagree with the Methods (cd as a linear discriminant in place of
the mean difference), the Methods give the main result and the scripts a variant. The helper
module alm3.py says where each parameter comes from.
Claims.
| Claim | Tested here |
|---|---|
| units-and-sessions | tested |
| ed1-selective-fraction | tested |
| fig1d-late-delay-ipsilateral-bias | blocked: no condition ending at the go cue in the recording sessions; the behaviour-only sessions are not in the data set |
| fig1d-earlier-photoinhibition-minimal | tested, on the recording sessions of Experiment 1 |
| ed3-recovery-interval | blocked: behaviour-only sessions not in the data set |
| ed2b-silencing | tested |
| ed2d-spatial-extent | blocked: recordings in untrained mice not in the data set |
| ed2e-no-rebound | tested |
| fig1f-rate-recovery | tested |
| fig1g-selectivity-recovery | tested |
| ed4-return-to-trajectory | tested |
| ed5-photoactivation | blocked: photoactivation data not in the data set |
| fig2b-bilateral-behaviour | tested, on the recording sessions |
| ed6-bilateral-bias-inconsistent | tested |
| fig2-bilateral-recovery | tested |
| ed7-unilateral-4-spots-bilateral-1-spot | tested |
| ed7e-size-and-roc | tested |
| fig3-cd-roc | tested |
| ed8-roc-during-photoinhibition | tested |
| ed9b-cd-stability | tested |
| ed8a-mode-variance | tested |
| fig3-cd-predicts-movement | tested |
| fig3-other-modes | tested |
| ed9f-reaction-time | blocked: the lick trace shows no licks in any Experiment 2 session (data check) |
| fig5b-callosotomy-behaviour | tested, after the cut only (no sessions before the cut) |
| fig5-callosotomy-recovery | tested |
| ed10e-callosotomy-preparatory-activity | tested |
| models-monolithic-fail | tested in part: three of the five models are simulated |
| fig6-modular-models-robust | tested in part: the attractor and the integrator are simulated |
import os
os.environ.setdefault("OMP_NUM_THREADS", "1")
import time
import warnings
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from scipy import stats
import alm3
warnings.filterwarnings("ignore", category=RuntimeWarning)
pd.set_option("display.width", 200)
pd.set_option("display.max_columns", 40)
pd.set_option("display.max_rows", 300)
started = time.time()
files = alm3.list_files()
md5 = alm3.checksums()
names = alm3.session_names()
sessions = alm3.load_all(names, workers=3)
units = [u for s in sessions for u in alm3.reduce_units(s)]
meta = alm3.load_meta()
import resource
print(f"loaded {len(sessions)} sessions and {len(units)} units in {time.time() - started:.0f} s; "
f"peak memory of this process {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1e6:.2f} GB "
f"(each of the 3 loading processes holds one session file, about 1.5 GB at most)")
loaded 91 sessions and 1579 units in 172 s; peak memory of this process 0.59 GB (each of the 3 loading processes holds one session file, about 1.5 GB at most)
SD = {s["name"]: s for s in sessions}
EXP = {s["name"]: alm3.experiment(s) for s in sessions}
CONDS = {"unilateral": [1, 2, 3], "exp2": [4, 5, 6], "exp2b": [4, 5, 7], "exp3": [7, 8, 9], "ccx": [10, 11, 12], "none": []}
N_SCREEN = {"unilateral": 5, "exp2": 10, "exp2b": 10, "exp3": 10, "ccx": 10, "none": 10}
trials = pd.concat([alm3.trial_table(s).assign(experiment=EXP[s["name"]]) for s in sessions], ignore_index=True)
info = pd.DataFrame([{k: u[k] for k in ["session", "mouse", "unit", "experiment", "cell_type", "spike_width_ms", "n_spikes"]} for u in units])
read = sorted(k for k in files if k.startswith("alm-3/live/data/data_structure_files/") and k.endswith(".mat"))
print(f"Files read: {len(read)} session files, {sum(files[k] for k in read) / 1e9:.2f} GB in the bucket listing.")
print("Session files without an MD5 sum in checksums.md5:", sum(k.replace("alm-3/live/", "") not in md5 for k in read))
# MD5 sums computed from the bytes read (alm3.load_session), against those listed in checksums.md5.
md5_read = {s["name"]: s["md5"] for s in sessions}
key = lambda name: f"data/data_structure_files/data_structure_{name}.mat"
print("Session files whose computed MD5 differs from checksums.md5:",
sum(md5_read[n] != md5.get(key(n)) for n in md5_read), "of", len(md5_read))
print("MD5 sums computed from the files read:")
for n in sorted(md5_read):
print(" ", f"data_structure_{n}.mat", md5_read[n], "" if md5_read[n] == md5.get(key(n)) else "DIFFERS from checksums.md5")
Files read: 91 session files, 12.26 GB in the bucket listing. Session files without an MD5 sum in checksums.md5: 0 Session files whose computed MD5 differs from checksums.md5: 0 of 91 MD5 sums computed from the files read: data_structure_ANM255200_20140910.mat c87235d095840620e37afa15737d1f1d data_structure_ANM255200_20140911.mat 5e3beb9aca6b2e63e67d751c93362742 data_structure_ANM255200_20140912.mat b00303d7bea983db9aae18adc330e312 data_structure_ANM255200_20140913.mat 388d1d35069ba8b4c8a10813301823c3 data_structure_ANM255200_20140914.mat 04489e014c562efdb11ad521f9de4f4a data_structure_ANM255200_20140915.mat 19d72ba8ef6cdf1dce20b8de2fa944bc data_structure_ANM255200_20140916.mat dd1dbe5e4caa486c56fdf64b78cfc670 data_structure_ANM255201_20141120.mat 53a7fa277622221f7f12c8027adfa021 data_structure_ANM255201_20141121.mat cebda0e5500adc31c6cd1e3e23465d5f data_structure_ANM255201_20141122.mat fc1d23a3960135d3cb4bbbc0a23cfbd4 data_structure_ANM255201_20141123.mat d8b555fe97da3aebe3ee2984bf7203f8 data_structure_ANM255201_20141124.mat 6217dcce4792b3dee86a9d983d42e4a9 data_structure_ANM255201_20141125.mat 69c67f084debd8842a4bb787ba1cdea4 data_structure_ANM255203_20141112.mat 889c5d8b654357dafaae2c869a1d39ea data_structure_ANM255203_20141113.mat 047b7d7e104e8c7f247245cbe55b074b data_structure_ANM255203_20141114.mat d4636f0b3c59aa82f3d59cd09d774b16 data_structure_ANM255203_20141115.mat d42038342eba09d9a68502ed1cf6a832 data_structure_ANM255203_20141116.mat 7563bd16f3248f1afa0cd22823e6e4e6 data_structure_ANM257636_20150330.mat 3064573505d6e30a138dcd5132e28e4e data_structure_ANM257636_20150331.mat 1198546724dff1327320084954e787f3 data_structure_ANM257636_20150401.mat d309fe7d8bc805b4ce28f3fb90e1bb07 data_structure_ANM257636_20150403.mat 7e6cdccbf952f6eb273f8377c95d347a data_structure_ANM257636_20150404.mat 038f81678e2227b1a1085d764ca232c0 data_structure_ANM257637_20141222.mat 055289d4b506a47257e6c487d2438fcf data_structure_ANM257637_20141223.mat 2571e2e75a17e80af548335b93d0962d data_structure_ANM257637_20141224.mat 5298c4da13225affe287921a68a82fa6 data_structure_ANM257772_20141120.mat 391a462a627adf6e71c265b4b931ada0 data_structure_ANM257772_20141121.mat 76956e93ea750648e95e53eef952903a data_structure_ANM257772_20141122.mat 0f87cda892d10bd7cef01f7703860a01 data_structure_ANM257772_20141123.mat 3aa47bcb080196027b4c9b52ec9ff340 data_structure_ANM257772_20141124.mat a90a8ec5b49dfaadf93666a4f33222db data_structure_ANM257772_20141125.mat d67adebc38d2ab3fa6d993b70e1fcd3b data_structure_ANM258250_20141201.mat 06c359e58191b6fe9125a4e4489bf748 data_structure_ANM258250_20141202.mat c30bf4d4144fa3b0faff94d202eabdca data_structure_ANM258250_20141203.mat ed4239acaf7091f421fc881a6064fe9d data_structure_ANM258250_20141205.mat e719516ccfe8e3853bcef02ff68d122b data_structure_ANM263808_20150121.mat d081842507084066063bb37ee831d8a3 data_structure_ANM263808_20150122.mat 7883cb19ec2171e4033c28ff504a67f1 data_structure_ANM263808_20150123.mat 9fb0adefe6d60962fb5e9e986d434d33 data_structure_ANM263808_20150124.mat 9a95efa85bbf5dc7876d40a2cafabd23 data_structure_ANM263808_20150125.mat a374a6b44b9d98b71c168e7902384948 data_structure_ANM263808_20150126.mat 6084f3ffa2e2cda7193188201ccfc8f8 data_structure_ANM263810_20150121.mat 6ab2522576b7fd7c0b72f4fd1e906274 data_structure_ANM263810_20150122.mat 79dbbacea6135c676ed6a804936c6a7b data_structure_ANM263810_20150123.mat 9a52e57f6260fbd9bd1fe12d6ad7e0a4 data_structure_ANM263810_20150124.mat c307a1adb41ab500b0c36fcad14961a8 data_structure_ANM263810_20150125.mat 0eaba0d4d3a793b1f8ec45f40b009a07 data_structure_ANM263810_20150126.mat cd0d388a7335a95e57cd197d548f075f data_structure_ANM264411_20141222.mat 63d7c77b48f727c6d27d97d6426a3b29 data_structure_ANM264411_20141223.mat 234f3070a9e01946a13c765e425ad373 data_structure_ANM264411_20141224.mat 2d0420bfecb69e2b6cf47f270df41114 data_structure_ANM270337_20150303.mat d0e20db498a04fa48b3ceb2071203db8 data_structure_ANM270337_20150304.mat b7230f2af3bf3518902c6f0a2e34335d data_structure_ANM270337_20150306.mat 706947bd35a6b7153c75301d8e8c4b1e data_structure_ANM270340_20150618.mat 6edac269ccb98de7d534aff77739b4eb data_structure_ANM270340_20150619.mat da5be3388b134d782d172d3ad1b4059c data_structure_ANM270340_20150620.mat 4f98992843d82f4eedce20dbbb4ae201 data_structure_ANM270340_20150621.mat 9d61d16eebfd8604f0f2c6840732aaa4 data_structure_ANM270340_20150623.mat 524207dd3427130f7290bb07bc2f3315 data_structure_ANM273657_20150321.mat 7f7c10fc0fc1c77709ba40808198b829 data_structure_ANM273657_20150322.mat b53a8bb9ec1ac3f80bdeea2b8e4e2377 data_structure_ANM273657_20150323.mat 03658d3d83f25b983422b42fe98fe62e data_structure_ANM273657_20150325.mat 54ccaf9878216b219fa1a61516aa90ae data_structure_ANM278733_20150528.mat 861c1c429764e80200b91944255f4e5a data_structure_ANM278733_20150530.mat e59d283a240584df61ef3ddbf7753215 data_structure_ANM278733_20150531.mat 7c70e63873677892eaeb3206c11aad87 data_structure_ANM278733_20150601.mat fbeeb8fa0ff3de640224ff9f8206e225 data_structure_ANM278733_20150602.mat f348c12688a3957bb32cbaee95636579 data_structure_ANM278733_20150603.mat 3f614f6a341215287c4c80e83a79a564 data_structure_ANM291063_20150902.mat c10cdfa90f30d3886fa87f934200f7a3 data_structure_ANM291063_20150904.mat a2b10d9c307dd8d1b6db21ef4d338117 data_structure_ANM291063_20150906.mat 11ad66f82f5494c6865cb5f9fd7ceca8 data_structure_ANM291063_20150907.mat 47813945550faa60f8213a2a3a64bab5 data_structure_ANM291064_20150906.mat f647ec70fbce36d7f1a1be455943b4f4 data_structure_ANM291064_20150907.mat a4fe585ce682799da6bdb5e10f53b7b9 data_structure_ANM291064_20150908.mat b27703e8f5a40fa7ab83f5bb426ca3a1 data_structure_ANM291064_20150909.mat 401feb5b191984e1590889f394a611d7 data_structure_ANM297634_20150907.mat 86bc357ccffd113c47506ea685840dd1 data_structure_ANM297634_20150908.mat 24e8ffe85006a5cd21bb50a1b26473cf data_structure_ANM297634_20150909.mat 15f0f1f597ac68ad1109cc4aee5eb65a data_structure_ANM297634_20150910.mat 72979a2b2abde953062e789cd5a87f76 data_structure_ANM297634_20150911.mat 22f5065b730eb8934c84875491b178d2 data_structure_ANM298738_20150724.mat 91a17d5c86c792b8a452ac0b67afcad3 data_structure_ANM298738_20150725.mat 5d02a63c6f60f55cf0979c2a51cc0731 data_structure_ANM298738_20150727.mat 6d456df965f7baac21b09fbf1a46c2e7 data_structure_ANM298738_20150728.mat 3220d46f159e6214146c72713e06810d data_structure_ANM298738_20150729.mat b7cce198104af8e7037060a60bd42e48 data_structure_ANM298740_20150723.mat 70ea513aeedfd635c1474a969acc3dbd data_structure_ANM298740_20150724.mat 44608484d1ff4ef9ccee85e6c9992c34 data_structure_ANM298740_20150726.mat f7a70c37209fa8a2312ea5a623c4ba46 data_structure_ANM298740_20150729.mat fdb972d1ea42539d4d299b0712cd3935
ses = pd.DataFrame([{
"session": s["name"], "mouse": s["mouse"], "experiment": EXP[s["name"]],
"line": alm3.mouse_line(meta[s["name"]]["gene_modification"]), "trials": len(s["trial_ids"]), "good": int(s["good"].sum()),
"units": len(s["units"]),
"stim_types": " ".join(str(int(x)) for x in sorted(np.unique(s["stim_type"][s["good"] & np.isfinite(s["stim_type"])]))),
} for s in sessions])
print(ses.groupby("experiment").agg(sessions=("session", "size"), mice=("mouse", "nunique"), units=("units", "sum"), good_trials=("good", "sum")).to_string())
print("\nSessions per mouse and experiment:")
print(pd.crosstab(ses.mouse, ses.experiment).to_string())
print("\nPhotostimulus types present (good trials), by experiment:")
print(ses.groupby(["experiment", "stim_types"]).size().to_string())
print("\nSessions with no good trials:", ses[ses.good == 0].session.tolist())
print("Trial ids are 1..n in every session:", all((s["trial_ids"] == np.arange(1, len(s["trial_ids"]) + 1)).all() for s in sessions))
print("Trial types:", sorted({tuple(s["trial_type_names"]) for s in sessions}))
LINE = ses.groupby("mouse").line.first().to_dict()
print("\nMouse lines from the meta data files (gene modification), by experiment group:")
print(ses.assign(group=np.where(ses.experiment == "ccx", "callosotomy", "control")).groupby(["group", "line"]).mouse.nunique().to_string())
print("Mice whose sessions disagree on the line:", [m for m, g in ses.groupby("mouse") if g.line.nunique() > 1])
print("Data description: 5 VGAT-ChR2-EYFP and 7 PV x ReaChR mice for electrophysiology; callosotomy 6 VGAT-ChR2-EYFP and 1 PV x ReaChR.")
print("Time units (2 = second):", sorted({s["time_unit"] for s in sessions}), sorted({u["time_unit"] for s in sessions for u in s["units"]}))
sessions mice units good_trials
experiment
ccx 33 7 567 7306
exp2 26 7 488 6958
exp2b 6 3 88 1521
exp3 6 3 102 1715
unilateral 20 4 334 5292
Sessions per mouse and experiment:
experiment ccx exp2 exp2b exp3 unilateral
mouse
ANM255200 0 0 0 0 7
ANM255201 0 2 0 0 4
ANM255203 0 0 0 0 5
ANM257636 0 0 3 2 0
ANM257637 0 3 0 0 0
ANM257772 0 2 0 0 4
ANM258250 0 4 0 0 0
ANM263808 0 6 0 0 0
ANM263810 0 6 0 0 0
ANM264411 0 3 0 0 0
ANM270337 0 0 2 1 0
ANM270340 5 0 0 0 0
ANM273657 0 0 1 3 0
ANM278733 6 0 0 0 0
ANM291063 4 0 0 0 0
ANM291064 4 0 0 0 0
ANM297634 5 0 0 0 0
ANM298738 5 0 0 0 0
ANM298740 4 0 0 0 0
Photostimulus types present (good trials), by experiment:
experiment stim_types
ccx 1
0 10 11 12 32
exp2 0 4 5 6 26
exp2b 0 4 5 7 6
exp3 0 7 8 9 6
unilateral -3 -2 -1 0 3
0 1 2 3 17
Sessions with no good trials: ['ANM270340_20150618']
Trial ids are 1..n in every session: True
Trial types: [('HitR', 'HitL', 'ErrR', 'ErrL', 'NoLickR', 'NoLickL', 'LickEarly', 'StimTrials')]
Mouse lines from the meta data files (gene modification), by experiment group:
group line
callosotomy PV x ReaChR 1
VGAT-ChR2 6
control PV x ReaChR 7
VGAT-ChR2 5
Mice whose sessions disagree on the line: []
Data description: 5 VGAT-ChR2-EYFP and 7 PV x ReaChR mice for electrophysiology; callosotomy 6 VGAT-ChR2-EYFP and 1 PV x ReaChR.
Time units (2 = second): [2] [2]
g = trials[trials.good & trials.cue.notna()].copy()
g["sample"] = g.pole_out - g.pole_in
g["delay"] = g.cue - g.pole_out
print("Epoch durations (s) on good trials, by experiment, excluding lick-early trials:")
print(g[~g.lick_early].groupby("experiment")[["sample", "delay"]].describe(percentiles=[0.01, 0.5, 0.99]).round(3).to_string())
print("\nLick-early trials: delay duration quantiles", g[g.lick_early].delay.quantile([0.01, 0.5, 0.99]).round(2).tolist(),
"; sample", g[g.lick_early]["sample"].quantile([0.01, 0.5, 0.99]).round(2).tolist())
print("\nOutcomes on good trials (fractions):")
print(g.assign(outcome=np.select([g.hit, g.err, g.nolick], ["hit", "err", "nolick"], "other")).groupby("experiment").outcome.value_counts(normalize=True).unstack().round(3).to_string())
print("Trials with both or no side:", int((g.side == 0).sum()))
Epoch durations (s) on good trials, by experiment, excluding lick-early trials:
sample delay
count mean std min 1% 50% 99% max count mean std min 1% 50% 99% max
experiment
ccx 5918.0 1.3 0.000 1.3 1.3 1.3 1.3 1.3 5918.0 1.7 0.000 1.7 1.7 1.7 1.7 1.701
exp2 5449.0 1.3 0.000 1.3 1.3 1.3 1.3 1.3 5449.0 1.7 0.000 1.7 1.7 1.7 1.7 1.701
exp2b 1379.0 1.3 0.000 1.3 1.3 1.3 1.3 1.3 1379.0 1.7 0.000 1.7 1.7 1.7 1.7 1.701
exp3 1447.0 1.3 0.000 1.3 1.3 1.3 1.3 1.3 1447.0 1.7 0.000 1.7 1.7 1.7 1.7 1.701
unilateral 4427.0 1.3 0.018 0.1 1.3 1.3 1.3 1.3 4427.0 1.3 0.021 -0.1 1.3 1.3 1.3 1.300
Lick-early trials: delay duration quantiles [1.3, 1.7, 4.58] ; sample [1.3, 1.64, 9.28]
Outcomes on good trials (fractions):
outcome err hit nolick other
experiment
ccx 0.313 0.657 0.030 NaN
exp2 0.282 0.706 0.012 NaN
exp2b 0.233 0.751 0.016 NaN
exp3 0.220 0.764 0.015 NaN
unilateral 0.213 0.769 0.017 0.0
Trials with both or no side: 1
# Laser timing against the trial table: onset and offset of the laser power trace (above 5% of
# its maximum), relative to the sample onset, delay onset and cue, per photostimulus type.
gl = g[~g.lick_early].copy()
gl["on_from_delay"] = gl.laser_on - gl.pole_out
gl["off_from_cue"] = gl.laser_off - gl.cue
gl["on_from_sample"] = gl.laser_on - gl.pole_in
lt = gl.groupby("stim").agg(n=("trial", "size"), with_laser=("laser_max", lambda x: int(x.notna().sum())),
power_mW=("laser_max", "median"), on_from_sample=("on_from_sample", "median"),
on_from_delay=("on_from_delay", "median"), off_from_cue=("off_from_cue", "median"),
duration=("laser_off", lambda x: np.nan))
lt["duration"] = gl.groupby("stim").apply(lambda d: (d.laser_off - d.laser_on).median())
print(lt.round(3).to_string())
print("Control trials with laser power above 0:", int(gl[(gl.stim == 0)].laser_max.gt(0).sum()), "of", int((gl.stim == 0).sum()))
n with_laser power_mW on_from_sample on_from_delay off_from_cue duration stim -3.0 98 98 4.148 1.809 0.508 -0.308 0.485 -2.0 84 84 4.148 1.309 0.008 -0.808 0.485 -1.0 94 94 4.151 0.508 -0.792 -1.608 0.485 0.0 11140 0 NaN NaN NaN NaN NaN 1.0 491 491 4.162 0.504 -0.796 -1.609 0.488 2.0 497 497 4.162 1.305 0.004 -0.808 0.488 3.0 527 527 4.164 1.805 0.504 -0.308 0.488 4.0 745 743 4.219 1.305 0.004 -0.908 0.788 5.0 728 727 4.217 1.305 0.004 -0.908 0.788 6.0 980 978 12.735 1.301 0.000 -0.911 0.789 7.0 435 435 3.266 1.301 0.000 -0.909 0.791 8.0 195 195 6.321 1.301 0.000 -0.909 0.791 9.0 170 170 6.336 1.301 0.000 -0.910 0.790 10.0 827 827 4.220 1.305 0.004 -0.908 0.788 11.0 799 799 4.231 1.305 0.004 -0.908 0.788 12.0 810 810 12.718 1.301 0.000 -0.910 0.790 Control trials with laser power above 0: 0 of 11140
# Clock check. (1) Spikes against the laser trace: the mean rate of putative pyramidal neurons in
# 20 ms bins around the laser onset measured on each trial's own laser trace, ipsilateral
# photoinhibition trials (types 2, 4 and 10, which start at delay onset) against control trials
# aligned to the same nominal time (delay onset + 4 ms). The spike times are aligned through the
# trial table's cue time, so a drop that starts at the laser onset shows that spikes, laser trace
# and trial table share one clock. (2) The same, per session, over its photostimulus types that
# include the left (recorded) ALM, that is all but the contralateral ones (5, 9, 11).
def onset_aligned(u, s, times):
tr = u["trials"]
st = s["stim_type"][tr]
ok = u["stable"] & ~s["trial_types"]["LickEarly"][tr]
res = {}
for name, m in (("stim", ok & np.isin(st, [2, 4, 10])), ("control", ok & (st == 0))):
idx = np.flatnonzero(m)
if len(idx) < 3:
return None
if name == "stim":
ref = (s["laser_on"] - s["cue"])[tr[idx]]
ok2 = np.isfinite(ref)
idx, ref = idx[ok2], ref[ok2]
else:
ref = (s["pole_out"] - s["cue"])[tr[idx]] + 0.004
# counts in 20 ms bins at times relative to ref, from the 10 ms bins (rounded to 10 ms)
t = np.round((ref[:, None] + times[None, :]) / 0.01) * 0.01
cs = np.concatenate([np.zeros((len(idx), 1)), np.cumsum(u["binned"][idx], 1)], 1)
a = np.clip(np.round((t - alm3.T0) / 0.01).astype(int), 0, alm3.NB10)
b = np.clip(a + 2, 0, alm3.NB10)
res[name] = (np.take_along_axis(cs, b, 1) - np.take_along_axis(cs, a, 1)).mean(0) / 0.02
return res
tt_on = np.round(np.arange(-0.2, 0.3, 0.02), 3)
acc = {"stim": [], "control": []}
for u in units:
s = SD[u["session"]]
if u["cell_type"] != "pyramidal" or EXP[u["session"]] == "exp3":
continue
r = onset_aligned(u, s, tt_on)
if r is None:
continue
for k in acc:
acc[k].append(r[k])
on_tab = pd.DataFrame({"t_from_laser_onset_s": tt_on, "control": np.mean(acc["control"], 0), "photoinhibition": np.mean(acc["stim"], 0)})
on_tab["ratio"] = on_tab.photoinhibition / on_tab.control
print(f"{len(acc['stim'])} pyramidal neurons; mean rate (spikes/s) in 20 ms bins starting at each time from laser onset:")
print(on_tab.round(2).to_string(index=False))
sess_rows = []
for name in ses.session:
s = SD[name]
us = [u for u in units if u["session"] == name and u["cell_type"] == "pyramidal"]
pre, post = [], []
for u in us:
tr = u["trials"]
st = s["stim_type"][tr]
ok = u["stable"] & ~s["trial_types"]["LickEarly"][tr] & np.isin(st, [1, 2, 3, -1, -2, -3, 4, 6, 7, 8, 10, 12]) & np.isfinite((s["laser_on"])[tr])
idx = np.flatnonzero(ok)
if len(idx) < 5:
continue
ref = (s["laser_on"] - s["cue"])[tr[idx]]
cs = np.concatenate([np.zeros((len(idx), 1)), np.cumsum(u["binned"][idx], 1)], 1)
a0 = np.round((ref - 0.2 - alm3.T0) / 0.01).astype(int)
a1 = np.round((ref - alm3.T0) / 0.01).astype(int)
a2 = np.round((ref + 0.2 - alm3.T0) / 0.01).astype(int)
r = np.arange(len(idx))
pre.append((cs[r, a1] - cs[r, a0]).mean() / 0.2)
post.append((cs[r, a2] - cs[r, a1 + 2]).mean() / 0.18)
if pre:
sess_rows.append({"session": name, "experiment": EXP[name], "neurons": len(pre), "rate_before": np.mean(pre), "rate_after_onset": np.mean(post)})
clk = pd.DataFrame(sess_rows)
clk["ratio"] = clk.rate_after_onset / clk.rate_before
print("\nPer session (types including left ALM): pyramidal rate 0.2 s before laser onset against 0.02 to 0.2 s after it")
print(clk.ratio.describe().round(3).to_string())
print("Sessions with ratio above 0.5:", clk[clk.ratio > 0.5][["session", "experiment", "neurons", "ratio"]].round(2).to_dict("records"))
print("Sessions with photostimulation but no pyramidal neuron to check:", sorted(set(ses[ses.stim_types.str.len() > 1].session) - set(clk.session)))
1250 pyramidal neurons; mean rate (spikes/s) in 20 ms bins starting at each time from laser onset:
t_from_laser_onset_s control photoinhibition ratio
-0.20 3.18 3.04 0.95
-0.18 3.13 3.00 0.96
-0.16 3.09 3.03 0.98
-0.14 3.20 3.07 0.96
-0.12 3.17 3.05 0.96
-0.10 3.12 3.08 0.99
-0.08 3.08 2.94 0.96
-0.06 3.23 3.05 0.95
-0.04 3.30 3.15 0.96
-0.02 3.42 3.25 0.95
-0.00 3.36 1.96 0.58
0.02 3.36 0.30 0.09
0.04 3.30 0.20 0.06
0.06 3.41 0.31 0.09
0.08 3.36 0.29 0.09
0.10 3.46 0.28 0.08
0.12 3.40 0.27 0.08
0.14 3.37 0.19 0.06
0.16 3.37 0.29 0.09
0.18 3.30 0.27 0.08
0.20 3.29 0.29 0.09
0.22 3.28 0.27 0.08
0.24 3.29 0.21 0.06
0.26 3.26 0.24 0.07
0.28 3.26 0.32 0.10
Per session (types including left ALM): pyramidal rate 0.2 s before laser onset against 0.02 to 0.2 s after it
count 90.000
mean 0.108
std 0.327
min 0.000
25% 0.009
50% 0.028
75% 0.069
max 2.181
Sessions with ratio above 0.5: [{'session': 'ANM257636_20150404', 'experiment': 'exp2b', 'neurons': 6, 'ratio': 2.04}, {'session': 'ANM264411_20141224', 'experiment': 'exp2', 'neurons': 21, 'ratio': 0.82}, {'session': 'ANM273657_20150325', 'experiment': 'exp2b', 'neurons': 13, 'ratio': 0.71}, {'session': 'ANM298738_20150727', 'experiment': 'ccx', 'neurons': 19, 'ratio': 2.18}]
Sessions with photostimulation but no pyramidal neuron to check: []
# The lick trace (channel "lick_trace", a photodiode signal). The first lick after the cue is the
# first upward crossing of a threshold halfway between the trace's median and its 99.9th
# percentile (helper). On correct trials a lick follows the cue within the 1.4 s the trace covers.
lk = []
for s in sessions:
g = s["good"] & np.isfinite(s["cue"]) & (s["trial_types"]["HitR"] | s["trial_types"]["HitL"]) & ~s["trial_types"]["LickEarly"]
if g.sum() == 0:
continue
rt = (s["first_lick"] - s["cue"])[g]
lk.append({"session": s["name"], "experiment": EXP[s["name"]], "trace_range": s["lick_p999"] - s["lick_median"],
"median_first_lick_s": np.nanmedian(rt) if np.isfinite(rt).any() else np.nan, "frac_first_lick_under_20ms": np.nanmean(rt < 0.02),
"trace_seconds_after_cue": np.nanmedian((s["trace_end"] - s["cue"])[g])})
lk = pd.DataFrame(lk)
usable = (lk.median_first_lick_s > 0.05) & (lk.frac_first_lick_under_20ms < 0.2)
print("Sessions with correct trials:", len(lk), "; sessions whose first threshold crossing after the cue looks like a lick (median > 50 ms, < 20% within 20 ms):", int(usable.sum()))
print(lk.groupby(usable.map({True: "lick-like", False: "noise-like"})).agg(sessions=("session", "size"), trace_range=("trace_range", "median"),
median_first_lick_s=("median_first_lick_s", "median")).round(4).to_string())
print("Trace length after the cue (s), median over sessions:", round(lk.trace_seconds_after_cue.median(), 3))
Sessions with correct trials: 90 ; sessions whose first threshold crossing after the cue looks like a lick (median > 50 ms, < 20% within 20 ms): 42
sessions trace_range median_first_lick_s
lick-like 42 0.0513 0.1938
noise-like 48 0.0018 0.0017
Trace length after the cue (s), median over sessions: 1.427
# Per-unit measures used by the selectivity and rate claims. The screening trials that set each
# neuron's preferred trial type are drawn with a generator seeded from the unit's position.
t_m = time.time()
M = []
for k, u in enumerate(units):
e = EXP[u["session"]]
M.append(alm3.unit_measures(u, SD[u["session"]], N_SCREEN[e], CONDS[e], seed=1000 + k))
info["nR"] = [m["nR"] for m in M]
info["nL"] = [m["nL"] for m in M]
info["fr_mean"] = [m["fr_mean"] for m in M]
print(f"measures for {len(M)} units in {time.time() - t_m:.0f} s")
measures for 1579 units in 20 s
units-and-sessions¶
Claim: "1012 single units were recorded in left ALM during behaviour across 58 sessions (20
unilateral, 38 bilateral) from 12 mice; 72 are fast-spiking, 890 putative pyramidal and 50 of
intermediate width are excluded." Criterion: counts over the non-callosotomy sessions, units
classed by the spike-width bounds of the Methods. The data set gives each unit a cellType
label; the trough-to-peak width of the mean of the 29-sample waveforms (19.53 kHz, so widths
come in steps of 0.051 ms) is computed as a second reading, and a third reading upsamples the
mean waveform 10 times by cubic spline before measuring.
from scipy.interpolate import CubicSpline
def width_upsampled(mw, factor=10):
x = np.arange(len(mw))
xs = np.linspace(0, len(mw) - 1, (len(mw) - 1) * factor + 1)
y = CubicSpline(x, mw)(xs)
tr = int(np.argmin(y))
pk = tr + int(np.argmax(y[tr:]))
return (xs[pk] - xs[tr]) / alm3.SAMPLE_RATE_WAVEFORM * 1e3
info["width_up_ms"] = [width_upsampled(SD[u["session"]]["units"][u["unit"]]["mean_waveform"].astype(float)) for u in units]
def width_class(w):
return np.where(w > 0.45, "pyramidal", np.where(w < 0.35, "FS", "intermediate"))
info["class_width"] = width_class(info.spike_width_ms)
info["class_width_up"] = width_class(info.width_up_ms)
nc = info[info.experiment != "ccx"]
print("Non-callosotomy sessions:", nc.session.nunique(), "with units;", (ses.experiment != "ccx").sum(), "in all;",
"unilateral", (ses.experiment == "unilateral").sum(), "; bilateral (exp2, exp2b, exp3)",
ses.experiment.isin(["exp2", "exp2b", "exp3"]).sum(), "; mice", nc.mouse.nunique())
print("Single units:", len(nc))
print("\nBy the data set's cellType label:", nc.cell_type.value_counts().to_dict())
print("By the width of the mean waveform:", nc.class_width.value_counts().to_dict())
print("By the width of the upsampled mean waveform:", nc.class_width_up.value_counts().to_dict())
print("\nLabel against width class (mean waveform):")
print(pd.crosstab(nc.cell_type, nc.class_width).to_string())
print("\nLabel against width class (upsampled):")
print(pd.crosstab(nc.cell_type, nc.class_width_up).to_string())
print("\nWidth (ms) by label, mean waveform:")
print(nc.groupby("cell_type").spike_width_ms.describe().round(3).to_string())
print("\nPaper: 1012 units, 20 + 38 sessions, 12 mice, 890 pyramidal, 72 FS, 50 intermediate.")
print("Units per experiment:", nc.experiment.value_counts().to_dict())
Non-callosotomy sessions: 58 with units; 58 in all; unilateral 20 ; bilateral (exp2, exp2b, exp3) 38 ; mice 12
Single units: 1012
By the data set's cellType label: {'pyramidal': 890, 'FS': 89, 'none': 33}
By the width of the mean waveform: {'pyramidal': 890, 'FS': 98, 'intermediate': 24}
By the width of the upsampled mean waveform: {'pyramidal': 889, 'FS': 104, 'intermediate': 19}
Label against width class (mean waveform):
class_width FS intermediate pyramidal
cell_type
FS 74 15 0
none 24 9 0
pyramidal 0 0 890
Label against width class (upsampled):
class_width_up FS intermediate pyramidal
cell_type
FS 79 10 0
none 25 8 0
pyramidal 0 1 889
Width (ms) by label, mean waveform:
count mean std min 25% 50% 75% max
cell_type
FS 89.0 0.249 0.065 0.154 0.205 0.256 0.256 0.358
none 33.0 0.332 0.043 0.307 0.307 0.307 0.358 0.410
pyramidal 890.0 0.686 0.099 0.461 0.614 0.666 0.666 0.922
Paper: 1012 units, 20 + 38 sessions, 12 mice, 890 pyramidal, 72 FS, 50 intermediate.
Units per experiment: {'exp2': 488, 'unilateral': 334, 'exp3': 102, 'exp2b': 88}
Result: not reproduced. The non-callosotomy sessions hold 1012 single units in 58 sessions (20 unilateral, 38 bilateral) from 12 mice, and 890 are labelled pyramidal, all as the paper reports. The FS count differs: 89 units are labelled FS and 33 carry no label, against 72 and 50 in the paper; by the width of the deposited mean waveforms there are 98 FS and 24 intermediate units, and 104 and 19 after upsampling. Five of the six counts match exactly; the criterion needs all of them, or the class counts within 10%, and the FS count is 24% above the paper's.
ed1-selective-fraction¶
Claim: "Most ALM pyramidal neurons distinguish trial types (634 of 890), 176 during the sample,
337 during the delay and 493 during the response epoch." Two-tailed t-test of epoch spike rates,
lick right against lick left control trials, p < 0.05. Readings: trials (a) correct only,
(b) correct and error grouped by instructed movement (the code's choice, i_yes_trial in
analysis_compile_all_data_unilateral.m), each with lick-early trials excluded or included (M1);
response epoch the 1.3 s after the cue (code), the first 400 ms, or 1.5 s (M2).
pyr = (info.cell_type == "pyramidal") & (info.experiment != "ccx")
rows = []
for trials_name, label in (("correct", "correct, lick-early excluded"), ("all", "correct+error, lick-early excluded"), ("all_le", "correct+error, lick-early included")):
P = np.array([M[i][f"p_sel_{trials_name}"] for i in np.flatnonzero(pyr)])
for j, resp in ((2, "1.3 s"), (3, "0.4 s"), (4, "1.5 s")):
sig = P[:, [0, 1, j]] < 0.05
rows.append({"trials": label, "response epoch": resp, "any": int(sig.any(1).sum()), "sample": int(sig[:, 0].sum()),
"delay": int(sig[:, 1].sum()), "response": int(sig[:, 2].sum()), "n": int(len(P)),
"untestable": int(np.isnan(P[:, 0]).sum())})
ed1 = pd.DataFrame(rows)
exp_ = {"any": 634, "sample": 176, "delay": 337, "response": 493}
for k, v in exp_.items():
ed1[f"{k}_ok"] = (ed1[k] - v).abs() <= 0.1 * v
print(ed1.to_string(index=False))
print("Paper: 634 any, 176 sample, 337 delay, 493 response of 890; tolerance 10%.")
print("Readings with all four counts within tolerance:", int(ed1[[f"{k}_ok" for k in exp_]].all(1).sum()))
print("\nBy mouse (code reading: correct+error, lick-early excluded, 1.3 s):")
P = np.array([M[i]["p_sel_all"] for i in np.flatnonzero(pyr)])
bym = pd.DataFrame({"mouse": info[pyr].mouse.values, "any": (P[:, [0, 1, 2]] < 0.05).any(1)}).groupby("mouse")["any"].agg(["sum", "size", "mean"])
print(bym.round(2).to_string())
trials response epoch any sample delay response n untestable any_ok sample_ok delay_ok response_ok
correct, lick-early excluded 1.3 s 633 176 336 493 890 1 True True True True
correct, lick-early excluded 0.4 s 582 176 336 411 890 1 True True True False
correct, lick-early excluded 1.5 s 635 176 336 490 890 1 True True True True
correct+error, lick-early excluded 1.3 s 571 152 287 404 890 1 True False False False
correct+error, lick-early excluded 0.4 s 532 152 287 364 890 1 False False False False
correct+error, lick-early excluded 1.5 s 572 152 287 408 890 1 True False False False
correct+error, lick-early included 1.3 s 596 161 315 433 890 1 True True True False
correct+error, lick-early included 0.4 s 550 161 315 382 890 1 False True True False
correct+error, lick-early included 1.5 s 591 161 315 422 890 1 True True True False
Paper: 634 any, 176 sample, 337 delay, 493 response of 890; tolerance 10%.
Readings with all four counts within tolerance: 2
By mouse (code reading: correct+error, lick-early excluded, 1.3 s):
sum size mean
mouse
ANM255200 49 74 0.66
ANM255201 67 97 0.69
ANM255203 37 90 0.41
ANM257636 19 38 0.50
ANM257637 36 47 0.77
ANM257772 70 104 0.67
ANM258250 41 55 0.75
ANM263808 76 120 0.63
ANM263810 58 88 0.66
ANM264411 24 44 0.55
ANM270337 58 66 0.88
ANM273657 36 67 0.54
/tmp/ipykernel_2300/3293745457.py:16: Pandas4Warning: Starting with pandas version 4.0 all arguments of all will be keyword-only.
print("Readings with all four counts within tolerance:", int(ed1[[f"{k}_ok" for k in exp_]].all(1).sum()))
Result: reproduced. With correct control trials, lick-early trials excluded and the 1.3 s response epoch, 633 of 890 pyramidal neurons are selective in some epoch, 176 in the sample, 336 in the delay and 493 in the response epoch, against 634, 176, 337 and 493. The 1.5 s response epoch also matches (635, 490 in the response epoch). With correct and error trials, the reading of the deposited code, the counts are lower (571, 152, 287, 404).
# Shared pieces for the rate and selectivity recovery claims.
GT = alm3.GRID_T
# Photoinhibition offsets from the cue (end of the ramp), as the code uses them and as the laser
# trace shows (data check above): unilateral sample -1.6 s, early delay -0.8 s, middle delay
# -0.3 s; all 0.8 s conditions -0.9 s.
OFFSET = {1: -1.6, 2: -0.8, 3: -0.3, 4: -0.9, 5: -0.9, 6: -0.9, 7: -0.9, 8: -0.9, 9: -0.9, 10: -0.9, 11: -0.9, 12: -0.9}
ONSET = {1: -2.1, 2: -1.3, 3: -0.8, 4: -1.7, 5: -1.7, 6: -1.7, 7: -1.7, 8: -1.7, 9: -1.7, 10: -1.7, 11: -1.7, 12: -1.7}
RAMP = {1: 0.1, 2: 0.1, 3: 0.1}
# Readings of M4 for the screening trials that set each neuron's preferred type: "code", the
# deposited scripts' rule (5 trials of each type in Experiment 1, 10 elsewhere); "10 per type",
# M4 reading (a); "10 in total", M4 reading (b). Measures other than the code's 200 ms traces are
# computed when first needed, with the same seed per unit.
MV_CACHE = {}
def MV(k, screen="code", width=0.2):
if screen == "code" and width == 0.2:
return M[k]
key = (k, screen, width)
if key not in MV_CACHE:
u = units[k]
e = EXP[u["session"]]
n, mode = {"code": (N_SCREEN[e], "per_type"), "10 per type": (10, "per_type"), "10 in total": (10, "total")}[screen]
MV_CACHE[key] = alm3.unit_measures(u, SD[u["session"]], n, CONDS[e], seed=1000 + k, width_psth=width, screen=mode)
return MV_CACHE[key]
def screens(exp):
return ("code", "10 per type", "10 in total") if N_SCREEN[exp] != 10 else ("code", "10 in total")
def selective(k, trials="all", rule="code"):
"""Selective by the t-test of M3. rule "code": in the sample or delay epoch (the deposited
scripts, Fig. 1g and 2e sections); rule "M3": in any of the sample, delay or response (1.3 s)
epochs (claims file, M3)."""
p = np.nan_to_num(M[k][f"p_sel_{trials}"][:3], nan=1)
return bool((p[:2] < 0.05).any()) if rule == "code" else bool((p < 0.05).any())
def selection(exp, conds, sel_trials="all", min_stim=2, min_ctrl=5, fr_min=None, pref_min=1.0, experiments=None,
rule="code", screen="code", steps=False):
"""Indices of the neurons of the selectivity recovery figures: putative pyramidal, enough
control trials for the screening subset, selective (rule), more than `min_ctrl` control and
more than `min_stim` trials of each type in every condition. Rule "code" adds the scripts'
|preference count| > 1 (Fig. 1g and 2e sections); rule "M3" has no such filter. With steps,
also returns the number of neurons left after each step."""
exps = experiments or [exp]
out = []
n = {"pyramidal": 0, "screening trials": 0, "selective": 0, "|preference| > 1": 0, "control trials": 0, "trials per condition": 0}
for k, u in enumerate(units):
if EXP[u["session"]] not in exps or u["cell_type"] != "pyramidal":
continue
n["pyramidal"] += 1
m = MV(k, screen)
if m["pref_counts"] is None:
continue
n["screening trials"] += 1
if not selective(k, sel_trials, rule):
continue
n["selective"] += 1
if rule == "code" and abs(m["pref_counts"][0]) <= pref_min:
continue
n["|preference| > 1"] += 1
if m["nR"] <= min_ctrl or m["nL"] <= min_ctrl:
continue
n["control trials"] += 1
if any(c not in m["cond"] or m["cond"][c]["nR"] <= min_stim or m["cond"][c]["nL"] <= min_stim for c in conds):
continue
n["trials per condition"] += 1
if fr_min is not None and not (m["fr_mean"] > fr_min):
continue
out.append(k)
return (out, n) if steps else out
def sel_traces(ks, cond, width=0.2, screen="code", pref="whole"):
"""Selectivity (preferred minus non-preferred, spikes/s) on control test trials and on
photoinhibition trials of `cond`, neurons x time. pref "whole": preferred type from the count
from sample onset to 1.3 s after the cue (M4 reading a; code); "best": from the epoch where the
neuron is most selective on the screening trials (M4 reading b)."""
ctrl, stim = [], []
for k in ks:
m0 = MV(k, screen)
m = MV(k, screen, width)
sgn = (1 if m0["pref_counts"][0] >= 0 else -1) if pref == "whole" else m0["pref_best"][1]
ctrl.append(sgn * (m["psth_ctrl"][1] - m["psth_ctrl"][-1]))
c = m["cond"][cond]["psth"]
stim.append(sgn * (c[1] - c[-1]))
return np.array(ctrl), np.array(stim)
def recovery_table(exp, conds, t_end, sel_trials, min_stim, width, stamp_shift, seed, experiments=None, min_ctrl=5,
rule="code", screen="code", pref="whole"):
ks = selection(exp, conds, sel_trials=sel_trials, min_stim=min_stim, min_ctrl=min_ctrl, experiments=experiments, rule=rule, screen=screen)
rng = np.random.default_rng(seed)
rows = []
for c in conds:
ctrl, stim = sel_traces(ks, c, width=width, screen=screen, pref=pref)
mean, sd, frac, cens = alm3.recovery_time(ctrl, stim, GT + stamp_shift, OFFSET[c], t_end, rng)
ratio = (ctrl - stim).mean(0) / ctrl.mean(0)
late = float(ratio[np.argmin(np.abs(GT + stamp_shift - (-0.2)))])
rows.append({"condition": c, "label": alm3.STIM_LABELS[c], "neurons": len(ks), "mice": len({units[k]["mouse"] for k in ks}),
"recovery_ms": mean * 1000, "sd_ms": sd * 1000, "frac_boot_recovered": frac, "censored_ms": cens * 1000,
"deficit_at_-0.2s": late})
return pd.DataFrame(rows), ks
def mean_rate_traces(exp, conds, fr_min=1.0, min_ctrl=8, min_stim=3, experiments=None):
"""Population mean rate (spikes/s, 200 ms boxcar) on control and photoinhibition trials, lick
right and lick left averaged per neuron; neurons as in the code's Fig. 1f and 2d sections."""
exps = experiments or [exp]
out = {}
for c in conds:
ks = [k for k, u in enumerate(units) if EXP[u["session"]] in exps and u["cell_type"] == "pyramidal"
and M[k]["nR"] > min_ctrl and M[k]["nL"] > min_ctrl and c in M[k]["cond"]
and M[k]["cond"][c]["nR"] > min_stim and M[k]["cond"][c]["nL"] > min_stim and M[k]["fr_mean"] > fr_min]
ctrl = np.array([(M[k]["psth_ctrl_all"][1] + M[k]["psth_ctrl_all"][-1]) / 2 for k in ks])
stim = np.array([(M[k]["cond"][c]["psth"][1] + M[k]["cond"][c]["psth"][-1]) / 2 for k in ks])
P = np.array([M[k]["cond"][c]["p_rate"] for k in ks])
out[c] = {"ks": ks, "ctrl": ctrl, "stim": stim, "p": P}
return out
def rate_summary(R, times):
rows = []
for c, d in R.items():
r = {"condition": c, "label": alm3.STIM_LABELS[c], "neurons": len(d["ks"])}
for t in times:
i = np.argmin(np.abs(GT - t))
j = np.argmin(np.abs(alm3.RATE_T - t))
r[f"rate_ratio@{t:+.2f}"] = d["stim"][:, i].mean() / d["ctrl"][:, i].mean()
r[f"frac_changed@{t:+.2f}"] = (d["p"][:, j] < 0.01).mean()
rows.append(r)
return pd.DataFrame(rows)
WINDOWS = ((0.2, 0.0, "200 ms, centre"), (0.4, 0.2, "400 ms, end"))
def recovery_readings(exp, conds, t_end, expected, seed, experiments=None):
"""Recovery times under every reading of M4 and of the selection: trials of the selectivity
test, minimum trials per condition, window and time stamp, screening subset, preference window
and selection rule. A condition is within tolerance only when most resamples (at least half)
reach 80% before `t_end` and their mean recovery time is within tolerance of the paper's;
'censored_ms' counts the resamples that do not recover at `t_end`."""
rows = []
for rule in ("code", "M3"):
for screen in screens(exp):
for pref in ("whole", "best"):
for sel_trials in ("all", "correct"):
for min_stim in (2, 3):
for width, shift, lab in WINDOWS:
tab, ks = recovery_table(exp, conds, t_end, sel_trials, min_stim, width, shift, seed=seed, experiments=experiments,
rule=rule, screen=screen, pref=pref)
for r in tab.to_dict("records"):
rows.append({"rule": rule, "screen": screen, "pref": pref, "selective_on": sel_trials, "min_trials": f">{min_stim}", "window": lab, **r})
t = pd.DataFrame(rows)
t["within_tol"] = [(r.frac_boot_recovered >= 0.5 and abs(r.recovery_ms - expected[r.condition][0]) <= expected[r.condition][1]) if r.condition in expected else np.nan
for r in t.itertuples()]
return t
READING = ["rule", "screen", "pref", "selective_on", "min_trials", "window"]
def readings_wide(t):
"""One row per reading: neurons, and per condition the conditional mean recovery time, the
fraction of resamples that recover, the censored mean and the deficit 0.2 s before the cue."""
w = t.pivot_table(index=READING, columns="condition", values=["recovery_ms", "frac_boot_recovered", "censored_ms", "deficit_at_-0.2s"], aggfunc="first")
w.columns = [f"{a.replace('frac_boot_recovered', 'frac').replace('recovery_ms', 'ms').replace('censored_ms', 'cens_ms').replace('deficit_at_-0.2s', 'def')}_{c}" for a, c in w.columns]
w = w[sorted(w.columns, key=lambda x: (x.split("_")[-1], x))]
w.insert(0, "neurons", t.groupby(READING).neurons.first())
return w.reset_index()
fig1f-rate-recovery¶
Claim: "Within 400 ms after unilateral photoinhibition, spike rates are indistinguishable from
control in 90% of neurons; only 10% keep a sustained change." Per neuron and condition of
Experiment 1, the rate test (400 ms windows every 50 ms, control against photoinhibition, lick
right and lick left pooled, p < 0.01). Neurons: putative pyramidal, mean rate > 1 spike/s, more
than 8 control trials of each type and more than 3 photoinhibition trials of each type (code,
Fig. 1f section: i_cell, i_n_trial); without the rate exclusion as a reading (M3). "Within
400 ms after" read as (a) the 400 ms window starting at offset (centre offset + 0.2 s) and (b)
the window centred 400 ms after offset. The code's own measure, the fraction in the window
centred 0.25 s before the cue (frac_persist), is shown too.
def rate_fraction_table(exp, conds, fr_min=1.0, min_ctrl=8, min_stim=3):
rows = []
for c in conds:
ks = [k for k, u in enumerate(units) if EXP[u["session"]] == exp and u["cell_type"] == "pyramidal"
and M[k]["nR"] > min_ctrl and M[k]["nL"] > min_ctrl and c in M[k]["cond"]
and M[k]["cond"][c]["nR"] > min_stim and M[k]["cond"][c]["nL"] > min_stim
and M[k]["cond"][c]["p_rate"] is not None and (fr_min is None or M[k]["fr_mean"] > fr_min)]
P = np.array([M[k]["cond"][c]["p_rate"] for k in ks])
frac = (P < 0.01).mean(0)
def at(t):
return float(frac[np.argmin(np.abs(alm3.RATE_T - t))])
rows.append({"condition": c, "label": alm3.STIM_LABELS[c], "neurons": len(ks), "mice": len({units[k]["mouse"] for k in ks}),
"during": at(OFFSET[c] - 0.25), "a_window_from_offset": at(OFFSET[c] + 0.2),
"b_centre_offset+0.4": at(OFFSET[c] + 0.4), "code_frac_persist(-0.25)": at(-0.25),
"before_onset": at(ONSET[c] - 0.25)})
return pd.DataFrame(rows), ks
for fr_min in (1.0, None):
tab, _ = rate_fraction_table("unilateral", [1, 2, 3], fr_min=fr_min)
print(f"Rate exclusion: {'mean rate > 1 spike/s' if fr_min else 'none'}")
print(tab.round(3).to_string(index=False))
for col in ("a_window_from_offset", "b_centre_offset+0.4"):
v = tab[col].values
print(f" {col}: per condition within 0.1 +- 0.01: {list(np.abs(v - 0.1) <= 0.01)}; mean {v.mean():.3f}; all below 0.2: {bool((v < 0.2).all())}")
print()
print("Paper: 168, 168, 175 neurons; 10% with a sustained change. 'during' is the window centred 0.25 s before offset; 'before_onset' the window centred 0.25 s before onset (the false-positive level of the test).")
Rate exclusion: mean rate > 1 spike/s
condition label neurons mice during a_window_from_offset b_centre_offset+0.4 code_frac_persist(-0.25) before_onset
1 ipsi 1 spot sample (0.5 s) 168 4 0.720 0.179 0.131 0.054 0.000
2 ipsi 1 spot early delay (0.5 s) 168 4 0.702 0.196 0.143 0.125 0.006
3 ipsi 1 spot middle delay (0.5 s) 175 4 0.714 0.109 0.091 0.383 0.011
a_window_from_offset: per condition within 0.1 +- 0.01: [np.False_, np.False_, np.True_]; mean 0.161; all below 0.2: True
b_centre_offset+0.4: per condition within 0.1 +- 0.01: [np.False_, np.False_, np.True_]; mean 0.122; all below 0.2: True
Rate exclusion: none
condition label neurons mice during a_window_from_offset b_centre_offset+0.4 code_frac_persist(-0.25) before_onset
1 ipsi 1 spot sample (0.5 s) 224 4 0.545 0.147 0.121 0.049 0.004
2 ipsi 1 spot early delay (0.5 s) 225 4 0.524 0.160 0.124 0.107 0.009
3 ipsi 1 spot middle delay (0.5 s) 241 4 0.523 0.095 0.087 0.286 0.008
a_window_from_offset: per condition within 0.1 +- 0.01: [np.False_, np.False_, np.True_]; mean 0.134; all below 0.2: True
b_centre_offset+0.4: per condition within 0.1 +- 0.01: [np.False_, np.False_, np.False_]; mean 0.111; all below 0.2: True
Paper: 168, 168, 175 neurons; 10% with a sustained change. 'during' is the window centred 0.25 s before offset; 'before_onset' the window centred 0.25 s before onset (the false-positive level of the test).
Result: partially reproduced. The code's selection gives exactly the paper's 168, 168 and 175 neurons. In the window centred 400 ms after offset (reading b), 13.1%, 14.3% and 9.1% of neurons still have a significant rate change (mean 12.2%), and in the window starting at offset (reading a) 17.9%, 19.6% and 10.9%; only the third condition is within 10 +- 1%, and all are below 20%, the criterion's bound for partial reproduction. Before photoinhibition the test flags 0 to 1.1% of neurons.
fig1g-selectivity-recovery¶
Claim: recovery of > 80% of control selectivity within 514 ms; recovery times 373 +- 260 ms (sample), 510 +- 218 ms (early delay) and 327 +- 112 ms (window ending 0.3 s before the cue); 55 selective neurons. Method of the code (Fig. 1g section of analysis_compile_all_data_unilateral.m), which fills the open details of M4: preference from 5 control trials of each type drawn at random (10 in total, the Methods' "subset of 10 trials"), on the spike count from sample onset to 1.3 s after the cue; selectivity traces on the remaining trials, 200 ms boxcar centred on each time; recovery time the mean over 1000 bootstrap resamples of neurons of the first time after offset (and before 1 s after the cue) at which (control minus photoinhibition) / control mean selectivity < 0.2, +- the standard deviation over resamples. Readings shown: trials of the selectivity test (all, the code's, or correct, M3), more than 2 (code) or more than 3 (legend) trials per condition, 200 ms windows stamped at their centre or 400 ms windows stamped at their end (M4).
Every reading of M4 and of the selection is run, as the criterion asks (verifier, round 1): the selection rule, "code" (selective in the sample or delay epoch with |preference count| > 1, the scripts) or "M3" (selective in any of the sample, delay or response epochs, the claims file); the screening trials, the code's, 10 of each type (M4 reading a) or 10 in total (M4 reading b); the preference, from the whole count (M4 reading a) or from the epoch where the screening trials differ most (M4 reading b); the trials of the selectivity test; the minimum trials per condition; and the window. A condition counts as within tolerance only when at least half the resamples reach 80% before the end of the search and their mean is within tolerance; the mean with the other resamples counted at the end of the search is also shown.
f1g = recovery_readings("unilateral", [1, 2, 3], 1.0, {1: (373, 260), 2: (510, 218), 3: (327, 112)}, seed=11)
w1g = readings_wide(f1g)
ok = f1g.groupby(READING).agg(all_within=("within_tol", "all"), all_recover=("frac_boot_recovered", lambda x: bool((x >= 0.5).all())))
w1g = w1g.merge(ok.reset_index(), on=READING)
w1g["neurons_within"] = (w1g.neurons - 55).abs() <= 5.5
print("Per reading: neurons; per condition (1 sample, 2 early delay, 3 middle delay) the mean recovery time over resamples that recover (ms_c),")
print("the fraction of resamples that recover before 1 s after the cue (frac_c), the mean with the others counted at 1 s after the cue (cens_ms_c)")
print("and (control - photoinhibition) / control 0.2 s before the cue (def_c):")
print(w1g.round(2).to_string(index=False))
print(f"\nReadings: {len(w1g)}; all three times within tolerance: {int(w1g.all_within.sum())}; every condition recovers in at least half the resamples: "
f"{int(w1g.all_recover.sum())}; neuron count within 55 +- 5.5: {int(w1g.neurons_within.sum())} (range {w1g.neurons.min()} to {w1g.neurons.max()})")
code_row = w1g[(w1g["rule"] == "code") & (w1g.screen == "code") & (w1g.pref == "whole") & (w1g.selective_on == "all")
& (w1g.min_trials == ">2") & (w1g.window == "200 ms, centre")].iloc[0]
print("Fraction of resamples recovering, code reading:", ", ".join(f"{code_row[f'frac_{c}']:.3f}" for c in (1, 2, 3)),
"; lowest over all readings:", ", ".join(f"{w1g[f'frac_{c}'].min():.3f}" for c in (1, 2, 3)))
print("\nNeurons left after each selection step (selective on all trials, > 2 trials per condition):")
print(pd.DataFrame([{"rule": r, "screen": sc, **selection("unilateral", [1, 2, 3], rule=r, screen=sc, steps=True)[1]}
for r in ("code", "M3") for sc in screens("unilateral")]).to_string(index=False))
print("Paper: 55 neurons; 373 +- 260, 510 +- 218, 327 +- 112 ms. Rule 'code': selective in the sample or delay epoch with |preference| > 1 (scripts);")
print("'M3': selective in any epoch (claims file). Screen: trials that set the preference. Pref: 'whole' count, or 'best' epoch.")
Per reading: neurons; per condition (1 sample, 2 early delay, 3 middle delay) the mean recovery time over resamples that recover (ms_c), the fraction of resamples that recover before 1 s after the cue (frac_c), the mean with the others counted at 1 s after the cue (cens_ms_c) and (control - photoinhibition) / control 0.2 s before the cue (def_c): rule screen pref selective_on min_trials window neurons cens_ms_1 def_1 frac_1 ms_1 cens_ms_2 def_2 frac_2 ms_2 cens_ms_3 def_3 frac_3 ms_3 all_within all_recover neurons_within M3 10 in total best all >2 200 ms, centre 135 279.60 0.03 1.0 279.60 537.76 0.36 1.00 537.76 416.79 0.50 1.00 416.79 True True False M3 10 in total best all >2 400 ms, end 135 693.56 -0.04 1.0 693.56 935.93 0.38 1.00 935.07 671.28 0.88 1.00 670.02 False True False M3 10 in total best all >3 200 ms, centre 133 253.13 0.04 1.0 253.13 515.53 0.31 1.00 515.53 413.93 0.48 1.00 413.93 True True False M3 10 in total best all >3 400 ms, end 133 664.51 -0.03 1.0 664.51 893.03 0.37 1.00 893.03 671.83 0.88 1.00 671.20 False True False M3 10 in total best correct >2 200 ms, centre 158 255.83 -0.24 1.0 255.83 338.79 0.30 1.00 337.33 402.13 0.42 1.00 402.13 True True False M3 10 in total best correct >2 400 ms, end 158 555.38 -0.27 1.0 555.38 710.82 0.31 1.00 709.73 731.24 0.89 1.00 729.53 False True False M3 10 in total best correct >3 200 ms, centre 156 253.57 -0.23 1.0 253.57 312.57 0.25 1.00 312.57 386.56 0.41 1.00 386.56 True True False M3 10 in total best correct >3 400 ms, end 156 542.95 -0.26 1.0 542.95 669.08 0.30 1.00 669.08 734.47 0.89 1.00 733.34 False True False M3 10 in total whole all >2 200 ms, centre 135 367.86 -0.03 1.0 367.86 299.64 0.24 1.00 299.64 336.34 0.48 1.00 336.34 True True False M3 10 in total whole all >2 400 ms, end 135 737.11 -0.02 1.0 737.11 729.31 0.30 0.99 714.11 624.15 0.90 1.00 620.75 False True False M3 10 in total whole all >3 200 ms, centre 133 387.72 -0.04 1.0 387.72 361.25 0.27 1.00 361.25 319.93 0.48 1.00 319.93 True True False M3 10 in total whole all >3 400 ms, end 133 744.24 -0.02 1.0 744.24 788.55 0.31 1.00 786.52 595.74 0.90 1.00 595.74 False True False M3 10 in total whole correct >2 200 ms, centre 158 321.47 -0.05 1.0 321.47 183.24 0.17 1.00 183.24 339.08 0.45 1.00 339.08 False True False M3 10 in total whole correct >2 400 ms, end 158 618.90 -0.09 1.0 618.90 518.49 0.23 1.00 518.49 680.54 0.90 0.99 675.54 False True False M3 10 in total whole correct >3 200 ms, centre 156 333.30 -0.06 1.0 333.30 204.29 0.20 1.00 204.29 319.31 0.45 1.00 318.33 False True False M3 10 in total whole correct >3 400 ms, end 156 629.72 -0.09 1.0 629.72 555.62 0.24 1.00 553.13 654.94 0.90 1.00 652.35 False True False M3 10 per type best all >2 200 ms, centre 137 229.11 -0.10 1.0 229.11 425.84 0.21 1.00 425.84 187.24 0.44 1.00 187.24 False True False M3 10 per type best all >2 400 ms, end 137 479.16 -0.05 1.0 479.16 761.77 0.44 1.00 761.77 414.97 0.94 1.00 414.08 False True False M3 10 per type best all >3 200 ms, centre 135 199.73 -0.08 1.0 199.73 404.12 0.17 1.00 404.12 186.56 0.43 1.00 186.56 False True False M3 10 per type best all >3 400 ms, end 135 450.48 -0.04 1.0 450.48 727.34 0.44 1.00 727.34 422.04 0.94 1.00 421.16 True True False M3 10 per type best correct >2 200 ms, centre 160 324.45 -0.00 1.0 324.45 439.93 0.37 1.00 439.93 190.93 0.43 1.00 190.93 False True False M3 10 per type best correct >2 400 ms, end 160 617.68 -0.06 1.0 617.68 885.62 0.57 1.00 883.79 432.16 0.93 1.00 432.16 False True False M3 10 per type best correct >3 200 ms, centre 158 301.52 0.01 1.0 301.52 409.17 0.33 1.00 409.17 192.01 0.42 1.00 192.01 False True False M3 10 per type best correct >3 400 ms, end 158 594.81 -0.05 1.0 594.81 833.71 0.57 1.00 833.71 435.26 0.93 1.00 435.26 False True False M3 10 per type whole all >2 200 ms, centre 137 237.66 -0.15 1.0 237.66 445.19 0.32 1.00 445.19 230.57 0.56 1.00 230.57 True True False M3 10 per type whole all >2 400 ms, end 137 472.21 -0.03 1.0 472.21 799.20 0.49 1.00 798.20 464.22 0.95 1.00 463.38 False True False M3 10 per type whole all >3 200 ms, centre 135 211.86 -0.14 1.0 211.86 417.92 0.29 1.00 417.92 232.78 0.55 1.00 232.78 True True False M3 10 per type whole all >3 400 ms, end 135 445.36 -0.02 1.0 445.36 762.45 0.48 1.00 762.45 475.09 0.95 1.00 473.44 False True False M3 10 per type whole correct >2 200 ms, centre 160 276.56 -0.12 1.0 276.56 463.01 0.39 1.00 463.01 247.12 0.44 1.00 247.12 True True False M3 10 per type whole correct >2 400 ms, end 160 533.40 -0.04 1.0 533.40 906.68 0.55 1.00 903.99 516.52 0.93 1.00 512.58 False True False M3 10 per type whole correct >3 200 ms, centre 158 256.11 -0.11 1.0 256.11 418.17 0.35 1.00 418.17 253.26 0.43 1.00 253.26 True True False M3 10 per type whole correct >3 400 ms, end 158 517.41 -0.02 1.0 517.41 843.77 0.54 1.00 841.85 519.63 0.93 1.00 518.85 False True False M3 code best all >2 200 ms, centre 137 285.40 -0.36 1.0 285.40 663.97 0.52 1.00 663.97 240.21 0.67 1.00 240.21 True True False M3 code best all >2 400 ms, end 137 541.11 -0.11 1.0 541.11 1021.60 0.87 0.98 1009.75 480.86 0.97 1.00 480.04 False True False M3 code best all >3 200 ms, centre 135 263.10 -0.35 1.0 263.10 623.16 0.46 1.00 623.16 246.39 0.65 1.00 246.39 True True False M3 code best all >3 400 ms, end 135 514.98 -0.09 1.0 514.98 955.10 0.86 1.00 951.71 487.78 0.97 1.00 486.97 False True False M3 code best correct >2 200 ms, centre 160 450.23 -0.24 1.0 450.23 726.82 0.70 1.00 725.75 272.39 0.59 1.00 272.39 True True False M3 code best correct >2 400 ms, end 160 743.85 -0.10 1.0 743.85 1046.14 1.08 0.99 1039.29 520.01 0.95 1.00 519.23 False True False M3 code best correct >3 200 ms, centre 158 419.45 -0.23 1.0 419.45 675.96 0.64 1.00 675.96 279.42 0.57 1.00 279.42 True True False M3 code best correct >3 400 ms, end 158 735.87 -0.08 1.0 735.87 982.17 1.07 1.00 978.89 526.98 0.95 1.00 526.98 False True False M3 code whole all >2 200 ms, centre 137 257.56 -0.38 1.0 257.56 336.66 0.03 1.00 336.66 141.73 0.30 1.00 141.73 False True False M3 code whole all >2 400 ms, end 137 594.62 -0.38 1.0 594.62 658.45 0.38 1.00 657.31 351.06 0.93 1.00 351.06 True True False M3 code whole all >3 200 ms, centre 135 236.03 -0.36 1.0 236.03 315.05 -0.05 1.00 315.05 133.16 0.28 1.00 133.16 False True False M3 code whole all >3 400 ms, end 135 555.91 -0.37 1.0 555.91 614.35 0.36 1.00 613.16 348.58 0.94 1.00 348.58 True True False M3 code whole correct >2 200 ms, centre 160 412.10 -0.16 1.0 412.10 404.20 0.22 1.00 404.20 147.34 0.28 1.00 147.34 False True False M3 code whole correct >2 400 ms, end 160 753.02 -0.38 1.0 753.02 805.54 0.61 1.00 804.54 359.73 0.88 1.00 359.73 False True False M3 code whole correct >3 200 ms, centre 158 381.96 -0.14 1.0 381.96 373.99 0.15 1.00 373.99 142.04 0.26 1.00 142.04 False True False M3 code whole correct >3 400 ms, end 158 732.54 -0.37 1.0 732.54 722.50 0.60 1.00 721.42 359.58 0.88 1.00 359.58 False True False code 10 in total best all >2 200 ms, centre 69 355.78 0.02 1.0 355.78 433.18 0.20 0.99 424.93 341.46 0.55 1.00 341.46 True True False code 10 in total best all >2 400 ms, end 69 812.23 0.00 1.0 812.23 839.62 0.30 0.97 809.92 571.60 0.93 1.00 571.60 False True False code 10 in total best all >3 200 ms, centre 68 377.23 0.03 1.0 377.23 423.25 0.19 1.00 420.49 336.41 0.54 1.00 336.41 True True False code 10 in total best all >3 400 ms, end 68 815.07 0.01 1.0 815.07 807.55 0.30 1.00 802.56 565.71 0.93 1.00 565.71 False True False code 10 in total best correct >2 200 ms, centre 87 270.52 -0.14 1.0 270.52 262.08 0.10 1.00 262.08 346.93 0.61 1.00 346.93 False True False code 10 in total best correct >2 400 ms, end 87 577.17 -0.19 1.0 577.17 591.27 0.22 1.00 591.27 587.43 0.93 1.00 586.00 False True False code 10 in total best correct >3 200 ms, centre 86 264.42 -0.14 1.0 264.42 265.46 0.10 1.00 265.46 343.22 0.60 1.00 343.22 False True False code 10 in total best correct >3 400 ms, end 86 569.76 -0.18 1.0 569.76 594.68 0.22 1.00 594.68 583.63 0.93 1.00 581.47 False True False code 10 in total whole all >2 200 ms, centre 69 621.13 -0.01 1.0 621.13 357.41 0.18 1.00 350.16 338.97 0.57 1.00 338.97 True True False code 10 in total whole all >2 400 ms, end 69 974.10 0.01 1.0 972.47 749.83 0.24 0.97 717.35 570.92 0.93 1.00 570.19 False True False code 10 in total whole all >3 200 ms, centre 68 638.39 -0.00 1.0 638.39 332.94 0.18 1.00 330.00 330.61 0.56 1.00 330.61 False True False code 10 in total whole all >3 400 ms, end 68 993.50 0.02 1.0 993.50 727.68 0.24 0.99 717.94 567.57 0.93 1.00 566.84 False True False code 10 in total whole correct >2 200 ms, centre 87 427.03 -0.09 1.0 427.03 208.66 0.14 1.00 208.66 298.34 0.61 1.00 298.34 False True False code 10 in total whole correct >2 400 ms, end 87 737.03 -0.12 1.0 737.03 550.09 0.18 1.00 550.09 559.19 0.94 0.99 554.72 False True False code 10 in total whole correct >3 200 ms, centre 86 424.53 -0.09 1.0 424.53 214.69 0.13 1.00 214.69 288.60 0.60 1.00 288.60 False True False code 10 in total whole correct >3 400 ms, end 86 738.54 -0.12 1.0 738.54 540.40 0.18 1.00 540.40 558.26 0.94 1.00 556.77 False True False code 10 per type best all >2 200 ms, centre 68 325.83 -0.04 1.0 325.83 488.63 0.25 1.00 484.68 236.84 0.63 1.00 236.84 True True False code 10 per type best all >2 400 ms, end 68 586.89 -0.07 1.0 586.89 813.55 0.37 0.97 785.13 474.41 0.96 1.00 471.93 False True False code 10 per type best all >3 200 ms, centre 66 290.33 -0.03 1.0 290.33 464.20 0.21 1.00 464.20 238.69 0.62 1.00 238.69 True True False code 10 per type best all >3 400 ms, end 66 557.29 -0.06 1.0 557.29 781.97 0.36 0.99 767.52 479.15 0.97 1.00 479.15 False True False code 10 per type best correct >2 200 ms, centre 79 376.37 0.04 1.0 376.37 544.04 0.26 1.00 544.04 268.91 0.63 1.00 268.91 True True False code 10 per type best correct >2 400 ms, end 79 657.59 0.00 1.0 657.59 853.93 0.42 0.99 845.34 520.50 0.95 1.00 516.58 False True False code 10 per type best correct >3 200 ms, centre 77 361.14 0.05 1.0 361.14 511.04 0.22 1.00 511.04 271.38 0.63 1.00 271.38 True True False code 10 per type best correct >3 400 ms, end 77 636.82 0.01 1.0 636.82 807.16 0.41 1.00 805.17 529.53 0.96 1.00 526.44 False True False code 10 per type whole all >2 200 ms, centre 68 311.54 -0.09 1.0 311.54 483.42 0.28 1.00 478.13 240.35 0.63 1.00 240.35 True True False code 10 per type whole all >2 400 ms, end 68 587.31 -0.10 1.0 587.31 832.92 0.35 0.96 794.72 473.57 0.96 1.00 471.08 False True False code 10 per type whole all >3 200 ms, centre 66 274.71 -0.08 1.0 274.71 468.52 0.24 1.00 467.19 242.64 0.62 1.00 242.64 True True False code 10 per type whole all >3 400 ms, end 66 565.77 -0.09 1.0 565.77 803.95 0.35 0.98 778.41 476.43 0.96 1.00 476.43 False True False code 10 per type whole correct >2 200 ms, centre 79 355.38 -0.06 1.0 355.38 485.49 0.23 1.00 485.49 306.37 0.58 1.00 306.37 True True False code 10 per type whole correct >2 400 ms, end 79 628.69 -0.03 1.0 628.69 841.53 0.34 0.98 820.97 603.16 0.95 0.97 580.12 False True False code 10 per type whole correct >3 200 ms, centre 77 328.05 -0.04 1.0 328.05 461.65 0.19 1.00 461.65 309.75 0.57 1.00 309.75 True True False code 10 per type whole correct >3 400 ms, end 77 602.42 -0.02 1.0 602.42 789.30 0.34 0.99 782.18 617.92 0.95 0.99 611.03 False True False code code best all >2 200 ms, centre 72 349.37 -0.23 1.0 349.37 596.63 0.38 1.00 593.01 202.40 0.62 1.00 202.40 False True False code code best all >2 400 ms, end 72 609.34 -0.06 1.0 609.34 899.34 0.65 0.97 868.60 421.67 0.95 1.00 419.91 False True False code code best all >3 200 ms, centre 70 322.32 -0.21 1.0 322.32 564.42 0.32 1.00 563.18 200.52 0.60 1.00 200.52 False True False code code best all >3 400 ms, end 70 584.53 -0.05 1.0 582.51 836.13 0.63 0.98 820.46 418.97 0.95 1.00 418.97 False True False code code best correct >2 200 ms, centre 87 515.22 -0.11 1.0 515.22 621.49 0.41 1.00 621.49 230.71 0.67 1.00 230.71 True True False code code best correct >2 400 ms, end 87 833.55 0.04 1.0 833.55 887.34 0.79 1.00 884.59 462.62 0.95 1.00 461.78 False True False code code best correct >3 200 ms, centre 85 483.49 -0.09 1.0 483.49 604.51 0.34 1.00 604.51 225.45 0.66 1.00 225.45 True True False code code best correct >3 400 ms, end 85 796.98 0.05 1.0 796.98 852.62 0.78 1.00 851.67 462.33 0.95 1.00 462.33 False True False code code whole all >2 200 ms, centre 72 347.34 -0.19 1.0 347.34 424.46 0.28 1.00 420.32 236.60 0.64 1.00 235.54 True True False code code whole all >2 400 ms, end 72 627.61 -0.31 1.0 627.61 781.81 0.45 0.98 759.97 449.00 0.96 1.00 448.15 False True False code code whole all >3 200 ms, centre 70 315.71 -0.18 1.0 315.71 395.78 0.21 1.00 391.55 234.77 0.62 1.00 234.77 True True False code code whole all >3 400 ms, end 70 611.83 -0.29 1.0 605.85 723.26 0.43 0.99 707.97 449.14 0.96 1.00 449.14 False True False code code whole correct >2 200 ms, centre 87 386.37 -0.09 1.0 386.37 376.66 0.10 1.00 376.66 233.51 0.55 1.00 233.51 True True False code code whole correct >2 400 ms, end 87 697.64 -0.28 1.0 697.64 679.92 0.41 1.00 679.92 458.42 0.92 1.00 458.42 False True False code code whole correct >3 200 ms, centre 85 364.25 -0.08 1.0 364.25 362.31 0.03 1.00 362.31 230.08 0.53 1.00 230.08 True True False code code whole correct >3 400 ms, end 85 671.43 -0.26 1.0 671.43 655.51 0.39 1.00 654.36 460.77 0.93 1.00 460.77 False True False Readings: 96; all three times within tolerance: 34; every condition recovers in at least half the resamples: 96; neuron count within 55 +- 5.5: 0 (range 66 to 160) Fraction of resamples recovering, code reading: 1.000, 0.997, 0.999 ; lowest over all readings: 0.997, 0.962, 0.968 Neurons left after each selection step (selective on all trials, > 2 trials per condition): rule screen pyramidal screening trials selective |preference| > 1 control trials trials per condition code code 292 289 99 88 88 72 code 10 per type 292 271 98 83 83 68 code 10 in total 292 288 98 84 84 69 M3 code 292 289 169 169 169 137 M3 10 per type 292 271 164 164 164 137 M3 10 in total 292 288 168 168 167 135 Paper: 55 neurons; 373 +- 260, 510 +- 218, 327 +- 112 ms. Rule 'code': selective in the sample or delay epoch with |preference| > 1 (scripts); 'M3': selective in any epoch (claims file). Screen: trials that set the preference. Pref: 'whole' count, or 'best' epoch.
Result: partially reproduced. Under the code's reading (selective on all trials, more than 2 trials per condition, 200 ms windows), selectivity recovers to 80% of control 347 ms after the sample photoinhibition, 420 ms after the early delay one and 236 ms after the middle delay one, within the paper's 373 +- 260, 510 +- 218 and 327 +- 112 ms, and at least 99% of resamples recover in each condition. In all 96 readings every condition recovers in at least 96% of resamples, and 34 put all three times within tolerance. No reading gives the paper's 55 neurons: the selections hold 66 to 160 neurons (72 under the code's reading), so the times match on a different neuron set. Of the 292 Experiment 1 pyramidal neurons, 99 are selective in the sample or delay epoch and 72 remain after the code's preference and trial filters; selection by any epoch (M3) leaves 135 to 137.
fig2-bilateral-recovery¶
Claim: spike rate and selectivity of left ALM neurons recover within 600 ms after ipsilateral photoinhibition, contralateral photoinhibition hardly affects activity, and after bilateral photoinhibition the rate recovers on average but selectivity does not; recovery 538 +- 178 ms (ipsilateral), 192 +- 114 ms (contralateral), none (bilateral); 143 selective neurons. Experiment 2 sessions (types 4, 5, 6). Method of the code (analysis_compile_all_data_bilateral.m, Fig. 2e section): as for fig1g, with 10 screening trials of each type and the recovery searched from offset (0.9 s before the cue) up to the cue. "Spike rate (> 90 %)" read as (a) more than 90% of neurons without a significant rate change in the window centred 600 ms after offset, or (b) population mean rate within 10% of control there. Rate neurons as in the code's Fig. 2d section (pyramidal, mean rate > 1 spike/s, > 8 control and > 3 photoinhibition trials per type).
Every reading of M4 and of the selection is run, as the criterion asks (verifier, round 1): the selection rule, "code" (selective in the sample or delay epoch with |preference count| > 1, the scripts) or "M3" (selective in any of the sample, delay or response epochs, the claims file); the screening trials, the code's, 10 of each type (M4 reading a) or 10 in total (M4 reading b); the preference, from the whole count (M4 reading a) or from the epoch where the screening trials differ most (M4 reading b); the trials of the selectivity test; the minimum trials per condition; and the window. A condition counts as within tolerance only when at least half the resamples reach 80% before the end of the search and their mean is within tolerance; the mean with the other resamples counted at the end of the search is also shown.
for fr_min, lab in ((1.0, "neurons above 1 spike/s (code)"), (0.0, "no rate exclusion")):
R2 = mean_rate_traces("exp2", [4, 5, 6], fr_min=fr_min)
rs2 = rate_summary(R2, [-1.3, -0.3, -0.05])
print(f"Rates, {lab}: ratio of photoinhibition to control population mean rate and fraction of neurons with a significant change (p < 0.01),")
print("at 0.4 s after onset (-1.3), 0.6 s after offset (-0.3) and just before the cue (-0.05):")
print(rs2.drop(columns="label").round(3).to_string(index=False))
f2 = recovery_readings("exp2", [4, 5, 6], 0.0, {4: (538, 178), 5: (192, 114)}, seed=21)
w2 = readings_wide(f2)
ok = f2.groupby(READING).agg(times_within=("within_tol", lambda x: bool(x.dropna().all())))
w2 = w2.merge(ok.reset_index(), on=READING)
w2["bilateral_no_recovery"] = w2.frac_6 < 0.5
w2["neurons_within"] = (w2.neurons - 143).abs() <= 14.3
print("\nSelectivity recovery, every reading (4 ipsilateral, 5 contralateral, 6 bilateral; columns as for fig1g-selectivity-recovery, censored at the cue):")
print(w2.round(2).to_string(index=False))
print(f"\nReadings: {len(w2)}; ipsilateral and contralateral times within tolerance (each from at least half the resamples): {int(w2.times_within.sum())}; "
f"of these with bilateral not recovering: {int((w2.times_within & w2.bilateral_no_recovery).sum())}, and with the neuron count within 143 +- 14.3: "
f"{int((w2.times_within & w2.bilateral_no_recovery & w2.neurons_within).sum())}")
print("Ipsilateral: fraction of resamples recovering", round(w2.frac_4.min(), 2), "to", round(w2.frac_4.max(), 2), "; deficit 0.2 s before the cue",
round(w2.def_4.min(), 2), "to", round(w2.def_4.max(), 2))
six = w2[w2.times_within & w2.bilateral_no_recovery]
print(f"In the {len(six)} readings with both times within tolerance and bilateral not recovering: ipsilateral deficit 0.2 s before the cue",
round(six.def_4.min(), 2), "to", round(six.def_4.max(), 2), "; fraction of resamples recovering", round(six.frac_4.min(), 2), "to", round(six.frac_4.max(), 2))
print("\nNeurons left after each selection step:")
print(pd.DataFrame([{"rule": r, "screen": sc, **selection("exp2", [4, 5, 6], rule=r, screen=sc, steps=True)[1]}
for r in ("code", "M3") for sc in screens("exp2")]).to_string(index=False))
ks2 = selection("exp2", [4, 5, 6])
ctrl2, ipsi2 = sel_traces(ks2, 4)
pts = [-1.7, -1.3, -0.9, -0.7, -0.5, -0.3, -0.1]
print(f"\nCode reading ({len(ks2)} neurons): mean selectivity (spikes/s, 200 ms windows) at times from the cue")
print(pd.DataFrame({"t_s": pts, "control": [ctrl2[:, np.argmin(np.abs(GT - t))].mean() for t in pts],
"ipsilateral": [ipsi2[:, np.argmin(np.abs(GT - t))].mean() for t in pts]}).round(2).to_string(index=False))
print("\nPaper: 143 neurons; ipsilateral 538 +- 178 ms, contralateral 192 +- 114 ms, bilateral no recovery.")
Rates, neurons above 1 spike/s (code): ratio of photoinhibition to control population mean rate and fraction of neurons with a significant change (p < 0.01),
at 0.4 s after onset (-1.3), 0.6 s after offset (-0.3) and just before the cue (-0.05):
condition neurons rate_ratio@-1.30 frac_changed@-1.30 rate_ratio@-0.30 frac_changed@-0.30 rate_ratio@-0.05 frac_changed@-0.05
4 267 0.094 0.663 0.958 0.094 0.990 0.090
5 273 0.901 0.165 1.057 0.051 1.052 0.029
6 320 0.031 0.797 1.164 0.322 1.114 0.328
Rates, no rate exclusion: ratio of photoinhibition to control population mean rate and fraction of neurons with a significant change (p < 0.01),
at 0.4 s after onset (-1.3), 0.6 s after offset (-0.3) and just before the cue (-0.05):
condition neurons rate_ratio@-1.30 frac_changed@-1.30 rate_ratio@-0.30 frac_changed@-0.30 rate_ratio@-0.05 frac_changed@-0.05
4 356 0.097 0.506 0.963 0.084 0.996 0.076
5 368 0.917 0.136 1.063 0.046 1.049 0.024
6 423 0.034 0.636 1.181 0.298 1.134 0.284
Selectivity recovery, every reading (4 ipsilateral, 5 contralateral, 6 bilateral; columns as for fig1g-selectivity-recovery, censored at the cue): rule screen pref selective_on min_trials window neurons cens_ms_4 def_4 frac_4 ms_4 cens_ms_5 def_5 frac_5 ms_5 cens_ms_6 def_6 frac_6 ms_6 times_within bilateral_no_recovery neurons_within M3 10 in total best all >2 200 ms, centre 251 690.44 0.41 0.62 560.36 197.38 0.23 0.99 192.43 899.43 0.91 0.00 330.00 True True False M3 10 in total best all >2 400 ms, end 251 863.28 0.46 0.23 738.24 515.73 0.21 0.83 435.34 900.00 0.75 0.00 NaN False True False M3 10 in total best all >3 200 ms, centre 224 741.30 0.48 0.45 546.55 207.92 0.22 0.98 195.95 898.28 0.88 0.00 326.67 False True False M3 10 in total best all >3 400 ms, end 224 878.56 0.49 0.09 664.40 505.92 0.17 0.80 409.24 900.00 0.74 0.00 NaN False True False M3 10 in total best correct >2 200 ms, centre 272 737.15 0.49 0.46 542.09 147.17 0.22 0.99 141.86 898.74 0.93 0.00 270.00 False True False M3 10 in total best correct >2 400 ms, end 272 877.16 0.52 0.15 744.63 423.79 0.17 0.87 350.10 900.00 0.77 0.00 NaN False True False M3 10 in total best correct >3 200 ms, centre 242 765.33 0.54 0.39 552.91 137.23 0.22 1.00 134.17 900.00 0.92 0.00 NaN False True False M3 10 in total best correct >3 400 ms, end 242 881.22 0.53 0.08 670.98 398.67 0.13 0.90 344.20 900.00 0.78 0.00 NaN False True False M3 10 in total whole all >2 200 ms, centre 251 555.74 0.28 0.79 463.68 265.38 0.28 0.97 243.72 894.92 0.86 0.01 335.56 True True False M3 10 in total whole all >2 400 ms, end 251 814.55 0.35 0.45 710.11 593.38 0.27 0.74 483.40 900.00 0.70 0.00 NaN False True False M3 10 in total whole all >3 200 ms, centre 224 574.63 0.35 0.66 405.52 291.21 0.27 0.94 250.28 896.20 0.83 0.01 357.14 True True False M3 10 in total whole all >3 400 ms, end 224 829.73 0.37 0.26 630.77 600.17 0.24 0.69 466.72 900.00 0.69 0.00 NaN False True False M3 10 in total whole correct >2 200 ms, centre 272 638.41 0.34 0.70 527.89 211.11 0.20 0.97 192.72 894.31 0.81 0.01 331.00 True True False M3 10 in total whole correct >2 400 ms, end 272 845.39 0.40 0.33 733.51 515.02 0.21 0.81 427.05 899.67 0.67 0.00 570.00 False True False M3 10 in total whole correct >3 200 ms, centre 242 659.62 0.38 0.60 502.02 209.99 0.19 0.97 190.11 896.05 0.79 0.01 335.71 True True False M3 10 in total whole correct >3 400 ms, end 242 840.18 0.40 0.21 615.14 491.19 0.17 0.84 414.48 900.00 0.67 0.00 NaN False True False M3 code best all >2 200 ms, centre 252 827.64 0.41 0.28 639.71 256.25 0.15 0.99 247.11 900.00 0.76 0.00 NaN False True False M3 code best all >2 400 ms, end 252 892.24 0.48 0.06 766.21 533.94 0.13 0.90 495.07 900.00 0.70 0.00 NaN False True False M3 code best all >3 200 ms, centre 225 853.17 0.45 0.23 693.70 162.89 0.15 1.00 160.67 900.00 0.78 0.00 NaN False True False M3 code best all >3 400 ms, end 225 896.09 0.50 0.03 755.19 434.45 0.06 0.94 406.83 900.00 0.70 0.00 NaN False True False M3 code best correct >2 200 ms, centre 273 802.04 0.40 0.36 629.39 146.57 0.02 1.00 143.54 900.00 0.76 0.00 NaN False True False M3 code best correct >2 400 ms, end 273 886.88 0.48 0.10 772.62 403.46 0.05 0.98 391.25 900.00 0.69 0.00 NaN False True False M3 code best correct >3 200 ms, centre 243 810.09 0.45 0.30 599.30 100.96 0.05 1.00 99.36 899.56 0.80 0.00 460.00 False True False M3 code best correct >3 400 ms, end 243 888.16 0.48 0.07 733.24 338.11 -0.01 0.98 328.97 900.00 0.68 0.00 NaN False True False M3 code whole all >2 200 ms, centre 252 805.86 0.48 0.42 677.45 195.24 0.14 0.99 188.12 900.00 0.77 0.00 NaN False True False M3 code whole all >2 400 ms, end 252 890.52 0.49 0.06 742.00 485.96 0.15 0.92 449.47 900.00 0.70 0.00 NaN False True False M3 code whole all >3 200 ms, centre 225 834.19 0.54 0.30 678.42 124.03 0.09 1.00 123.25 900.00 0.78 0.00 NaN False True False M3 code whole all >3 400 ms, end 225 893.18 0.52 0.03 637.69 354.56 0.05 0.97 338.27 900.00 0.68 0.00 NaN False True False M3 code whole correct >2 200 ms, centre 273 788.18 0.49 0.42 633.13 158.84 0.11 0.99 150.60 900.00 0.77 0.00 NaN False True False M3 code whole correct >2 400 ms, end 273 888.09 0.50 0.09 771.94 415.21 0.10 0.94 385.36 900.00 0.69 0.00 NaN False True False M3 code whole correct >3 200 ms, centre 243 804.91 0.55 0.29 570.97 105.05 0.10 1.00 104.25 899.12 0.80 0.00 460.00 False True False M3 code whole correct >3 400 ms, end 243 888.13 0.51 0.06 688.04 330.25 0.00 0.98 318.62 900.00 0.68 0.00 NaN False True False code 10 in total best all >2 200 ms, centre 146 790.74 0.43 0.51 684.50 235.50 0.24 0.99 228.79 900.00 0.88 0.00 NaN True True True code 10 in total best all >2 400 ms, end 146 890.56 0.54 0.13 829.55 521.84 0.17 0.87 463.83 900.00 0.73 0.00 NaN False True True code 10 in total best all >3 200 ms, centre 127 854.93 0.53 0.23 704.04 247.10 0.24 0.98 234.45 900.00 0.85 0.00 NaN False True False code 10 in total best all >3 400 ms, end 127 898.02 0.58 0.02 813.91 503.13 0.13 0.88 451.56 900.00 0.72 0.00 NaN False True False code 10 in total best correct >2 200 ms, centre 161 809.58 0.49 0.31 608.32 335.35 0.32 0.93 294.80 900.00 0.89 0.00 NaN False True False code 10 in total best correct >2 400 ms, end 161 894.29 0.55 0.07 819.58 632.32 0.26 0.63 472.40 900.00 0.75 0.00 NaN False True False code 10 in total best correct >3 200 ms, centre 141 846.13 0.57 0.15 547.91 326.20 0.32 0.90 261.74 900.00 0.86 0.00 NaN False True True code 10 in total best correct >3 400 ms, end 141 897.69 0.58 0.02 790.00 590.77 0.20 0.68 448.57 900.00 0.74 0.00 NaN False True True code 10 in total whole all >2 200 ms, centre 146 832.74 0.47 0.33 698.02 192.48 0.25 1.00 188.92 900.00 0.85 0.00 NaN False True True code 10 in total whole all >2 400 ms, end 146 896.43 0.56 0.06 840.50 482.03 0.16 0.90 434.04 900.00 0.72 0.00 NaN False True True code 10 in total whole all >3 200 ms, centre 127 877.48 0.56 0.11 689.53 204.83 0.25 0.99 199.22 900.00 0.82 0.00 NaN False True False code 10 in total whole all >3 400 ms, end 127 899.89 0.60 0.00 790.00 464.18 0.12 0.92 424.73 900.00 0.70 0.00 NaN False True False code 10 in total whole correct >2 200 ms, centre 161 843.88 0.52 0.21 628.89 290.64 0.31 0.94 254.49 899.49 0.86 0.00 390.00 False True False code 10 in total whole correct >2 400 ms, end 161 897.56 0.57 0.04 830.29 595.70 0.25 0.69 457.70 900.00 0.72 0.00 NaN False True False code 10 in total whole correct >3 200 ms, centre 141 874.28 0.59 0.07 552.43 290.00 0.32 0.91 231.87 899.48 0.84 0.00 380.00 False True True code 10 in total whole correct >3 400 ms, end 141 899.50 0.59 0.00 800.00 566.91 0.18 0.71 432.83 900.00 0.71 0.00 NaN False True True code code best all >2 200 ms, centre 146 847.08 0.43 0.30 721.82 286.39 0.23 0.97 265.45 900.00 0.73 0.00 NaN False True True code code best all >2 400 ms, end 146 897.28 0.51 0.04 826.49 577.78 0.18 0.82 505.12 900.00 0.69 0.00 NaN False True True code code best all >3 200 ms, centre 129 868.57 0.48 0.19 737.15 222.21 0.24 0.98 206.96 900.00 0.74 0.00 NaN False True True code code best all >3 400 ms, end 129 898.99 0.55 0.01 827.86 489.02 0.12 0.89 437.71 900.00 0.67 0.00 NaN False True True code code best correct >2 200 ms, centre 167 839.30 0.43 0.27 672.66 155.14 0.10 1.00 151.40 900.00 0.75 0.00 NaN False True False code code best correct >2 400 ms, end 167 895.78 0.49 0.05 810.21 408.74 0.10 0.97 391.45 900.00 0.69 0.00 NaN False True False code code best correct >3 200 ms, centre 148 850.98 0.48 0.14 547.34 106.49 0.13 1.00 106.49 900.00 0.77 0.00 NaN False True True code code best correct >3 400 ms, end 148 897.97 0.53 0.02 787.22 326.39 0.03 0.99 320.60 900.00 0.67 0.00 NaN False True True code code whole all >2 200 ms, centre 146 853.90 0.48 0.25 716.33 255.51 0.19 0.98 240.34 900.00 0.76 0.00 NaN False True True code code whole all >2 400 ms, end 146 898.30 0.53 0.02 822.73 540.38 0.17 0.88 489.94 900.00 0.73 0.00 NaN False True True code code whole all >3 200 ms, centre 129 880.28 0.54 0.12 739.67 168.70 0.16 0.99 162.06 900.00 0.77 0.00 NaN False True True code code whole all >3 400 ms, end 129 899.37 0.58 0.01 830.00 411.21 0.07 0.95 387.10 900.00 0.70 0.00 NaN False True True code code whole correct >2 200 ms, centre 167 820.93 0.48 0.30 637.31 185.05 0.14 0.99 177.10 900.00 0.73 0.00 NaN False True False code code whole correct >2 400 ms, end 167 894.61 0.48 0.06 805.44 465.37 0.15 0.92 428.09 900.00 0.68 0.00 NaN False True False code code whole correct >3 200 ms, centre 148 839.75 0.55 0.16 532.62 123.03 0.14 1.00 119.13 899.52 0.74 0.00 420.00 False True True code code whole correct >3 400 ms, end 148 897.63 0.53 0.02 751.88 341.05 0.04 0.98 332.54 900.00 0.65 0.00 NaN False True True Readings: 64; ipsilateral and contralateral times within tolerance (each from at least half the resamples): 6; of these with bilateral not recovering: 6, and with the neuron count within 143 +- 14.3: 1 Ipsilateral: fraction of resamples recovering 0.0 to 0.79 ; deficit 0.2 s before the cue 0.28 to 0.6 In the 6 readings with both times within tolerance and bilateral not recovering: ipsilateral deficit 0.2 s before the cue 0.28 to 0.43 ; fraction of resamples recovering 0.51 to 0.79 Neurons left after each selection step: rule screen pyramidal screening trials selective |preference| > 1 control trials trials per condition code code 427 423 186 167 167 146 code 10 in total 427 426 187 168 168 146 M3 code 427 423 287 287 287 252 M3 10 in total 427 426 287 287 287 251 Code reading (146 neurons): mean selectivity (spikes/s, 200 ms windows) at times from the cue t_s control ipsilateral -1.7 1.89 0.69 -1.3 2.27 0.06 -0.9 2.49 0.53 -0.7 2.75 1.32 -0.5 2.70 1.14 -0.3 2.63 1.35 -0.1 2.51 1.58 Paper: 143 neurons; ipsilateral 538 +- 178 ms, contralateral 192 +- 114 ms, bilateral no recovery.
Result: partially reproduced. After ipsilateral photoinhibition the population rate is back to 0.96 of control 600 ms after offset (0.96 without the rate exclusion) and 9.4% of neurons have a significant change there, so the rate recovers under both readings. Contralateral photoinhibition leaves the rate at 0.90 of control during photoinhibition, and its selectivity recovers in 240 ms (code reading), within 192 +- 114 ms. Bilateral selectivity reaches 80% before the cue in at most 1% of resamples in every reading, but the bilateral rate is 1.11 of control just before the cue (1.13 without the rate exclusion), outside the criterion's 10%. Ipsilateral selectivity recovers in some readings only: under the code's reading 25% of resamples reach 80% before the cue (mean 716 ms; 854 ms counting the others at the cue), and across the 64 readings 0% to 79% do. Six readings, all with the 10 screening trials drawn in total (M4 reading b), have at least half the resamples recovering with both times within tolerance and bilateral selectivity not recovering; one of them (code rule, preference from the most selective epoch) also has 146 neurons, within 143 +- 14.3 (684 ms from 51% of resamples, contralateral 229 ms). In every reading the ipsilateral selectivity 0.2 s before the cue is still 28% to 60% below control, and 28% to 43% in those six readings, so where it reaches 80% it falls back before the cue. The ordering (ipsilateral recovers, bilateral does not) holds under those six readings, and the bilateral rate misses the criterion, so the claim holds in part, on few readings. The criterion's partial rule names a time outside tolerance; here both times are within tolerance and the bilateral rate fails, so the partial outcome follows the protocol's general meaning (the effect holds only in part), not the criterion's wording.
ed7-unilateral-4-spots-bilateral-1-spot¶
Claim: bilateral photoinhibition with one spot per side causes a larger persistent change in selectivity than unilateral photoinhibition with four spots; recovery 490 +- 280 ms (ipsilateral 4 spots), 235 +- 156 ms (contralateral 4 spots), none (bilateral 1 spot); 40 selective neurons. Experiment 3 sessions (types 7, 8, 9), method as fig2-bilateral-recovery. The "persistent change" is the mean delta selectivity (photoinhibition minus control, spikes/s) in the last 400 ms of the delay (criterion).
Every reading of M4 and of the selection is run, as the criterion asks (verifier, round 1): the selection rule, "code" (selective in the sample or delay epoch with |preference count| > 1, the scripts) or "M3" (selective in any of the sample, delay or response epochs, the claims file); the screening trials, the code's, 10 of each type (M4 reading a) or 10 in total (M4 reading b); the preference, from the whole count (M4 reading a) or from the epoch where the screening trials differ most (M4 reading b); the trials of the selectivity test; the minimum trials per condition; and the window. A condition counts as within tolerance only when at least half the resamples reach 80% before the end of the search and their mean is within tolerance; the mean with the other resamples counted at the end of the search is also shown. As a variant for a question to a reader, the bilateral 1-spot neurons of the sessions with types 4, 5 and 7 are pooled with Experiment 3 (ED Fig. 2b gives n = 102 for that condition).
e7 = recovery_readings("exp3", [7, 8, 9], 0.0, {8: (490, 280), 9: (235, 156)}, seed=31)
w7 = readings_wide(e7)
ok = e7.groupby(READING).agg(times_within=("within_tol", lambda x: bool(x.dropna().all())))
w7 = w7.merge(ok.reset_index(), on=READING)
w7["bilateral_no_recovery"] = w7.frac_7 < 0.5
print("Every reading (7 bilateral 1 spot, 8 ipsilateral 4 spots, 9 contralateral 4 spots):")
print(w7.round(2).to_string(index=False))
print(f"\nReadings: {len(w7)}; times within tolerance: {int(w7.times_within.sum())}; bilateral 1 spot reaching 80% before the cue in fewer than half the resamples: "
f"{int(w7.bilateral_no_recovery.sum())}; both: {int((w7.times_within & w7.bilateral_no_recovery).sum())}")
print("Bilateral 1 spot: fraction of resamples recovering", round(w7.frac_7.min(), 2), "to", round(w7.frac_7.max(), 2))
print("\nNeurons left after each selection step:")
print(pd.DataFrame([{"rule": r, "screen": sc, **selection("exp3", [7, 8, 9], rule=r, screen=sc, steps=True)[1]}
for r in ("code", "M3") for sc in screens("exp3")]).to_string(index=False))
print("\nMean delta selectivity (photoinhibition minus control, spikes/s) in the last 400 ms of the delay:")
win = (GT > -0.4) & (GT <= 0)
for rule in ("code", "M3"):
ks7 = selection("exp3", [7, 8, 9], sel_trials="all", min_stim=2, rule=rule)
ctrl, s7 = sel_traces(ks7, 7)
_, s8 = sel_traces(ks7, 8)
d7, d8 = (s7 - ctrl)[:, win].mean(1), (s8 - ctrl)[:, win].mean(1)
print(f" rule {rule}, {len(ks7)} neurons: bilateral 1 spot {d7.mean():+.2f} (s.e.m. {d7.std(ddof=1) / np.sqrt(len(d7)):.2f}), ipsilateral 4 spots {d8.mean():+.2f} "
f"(s.e.m. {d8.std(ddof=1) / np.sqrt(len(d8)):.2f}); control selectivity {ctrl[:, win].mean():.2f}; "
f"difference {np.mean(d7 - d8):+.2f}, paired t-test p = {stats.ttest_rel(d7, d8).pvalue:.3g}")
# Variant for the question to a reader: ED Fig. 2b gives Experiment 3 n = 52, 52, 102, which suggests that the bilateral
# 1-spot neurons of the sessions with types 4, 5, 7 were pooled with Experiment 3 for that condition.
print("\nVariant: bilateral 1 spot (type 7) with the sessions holding types 4, 5, 7 pooled with Experiment 3:")
rows = []
for rule in ("code", "M3"):
for sel_trials in ("all", "correct"):
for width, shift, lab in WINDOWS:
tab, ks = recovery_table("exp3", [7], 0.0, sel_trials, 2, width, shift, seed=32, experiments=["exp3", "exp2b"], rule=rule)
rows.append({"rule": rule, "selective_on": sel_trials, "window": lab, **tab.iloc[0].drop(["label", "condition"]).to_dict()})
print(pd.DataFrame(rows).round(2).to_string(index=False))
print("\nPaper: 40 neurons; 490 +- 280 and 235 +- 156 ms; bilateral 1 spot does not recover.")
Every reading (7 bilateral 1 spot, 8 ipsilateral 4 spots, 9 contralateral 4 spots): rule screen pref selective_on min_trials window neurons cens_ms_7 def_7 frac_7 ms_7 cens_ms_8 def_8 frac_8 ms_8 cens_ms_9 def_9 frac_9 ms_9 times_within bilateral_no_recovery M3 10 in total best all >2 200 ms, centre 58 203.42 -0.07 0.98 189.20 257.53 -0.16 1.00 257.53 180.42 0.35 0.98 168.72 True False M3 10 in total best all >2 400 ms, end 58 407.77 -0.37 0.94 375.79 557.96 0.25 0.93 531.02 436.10 0.07 0.86 361.21 True False M3 10 in total best all >3 200 ms, centre 58 203.42 -0.07 0.98 189.20 257.53 -0.16 1.00 257.53 180.42 0.35 0.98 168.72 True False M3 10 in total best all >3 400 ms, end 58 407.77 -0.37 0.94 375.79 557.96 0.25 0.93 531.02 436.10 0.07 0.86 361.21 True False M3 10 in total best correct >2 200 ms, centre 60 234.99 -0.01 0.96 210.87 265.32 -0.14 1.00 265.32 181.68 0.44 0.98 170.74 True False M3 10 in total best correct >2 400 ms, end 60 446.91 -0.28 0.91 399.90 550.83 0.29 0.91 515.03 419.38 0.16 0.85 332.56 True False M3 10 in total best correct >3 200 ms, centre 59 215.89 -0.02 0.98 198.35 265.84 -0.17 1.00 265.84 172.17 0.44 0.98 159.58 True False M3 10 in total best correct >3 400 ms, end 59 425.40 -0.33 0.91 379.03 532.46 0.26 0.94 507.75 401.00 0.13 0.87 327.10 True False M3 10 in total whole all >2 200 ms, centre 58 177.04 -0.14 0.98 165.28 190.21 -0.09 1.00 190.21 159.56 0.32 1.00 156.59 False False M3 10 in total whole all >2 400 ms, end 58 371.44 -0.49 0.95 343.62 501.23 0.27 0.92 467.02 391.61 -0.06 0.93 350.98 True False M3 10 in total whole all >3 200 ms, centre 58 177.04 -0.14 0.98 165.28 190.21 -0.09 1.00 190.21 159.56 0.32 1.00 156.59 False False M3 10 in total whole all >3 400 ms, end 58 371.44 -0.49 0.95 343.62 501.23 0.27 0.92 467.02 391.61 -0.06 0.93 350.98 True False M3 10 in total whole correct >2 200 ms, centre 60 171.75 -0.08 0.98 156.13 179.89 -0.09 1.00 179.17 141.90 0.41 0.99 137.32 False False M3 10 in total whole correct >2 400 ms, end 60 379.52 -0.39 0.92 336.71 467.73 0.29 0.93 433.19 377.70 0.07 0.91 325.41 True False M3 10 in total whole correct >3 200 ms, centre 59 154.00 -0.10 0.98 140.33 186.00 -0.12 1.00 185.29 134.39 0.41 1.00 132.86 False False M3 10 in total whole correct >3 400 ms, end 59 352.44 -0.46 0.94 316.25 457.67 0.26 0.93 425.40 356.70 0.03 0.92 312.65 True False M3 code best all >2 200 ms, centre 59 519.82 0.28 0.70 356.11 557.53 0.04 1.00 556.50 146.82 -0.02 1.00 146.82 True False M3 code best all >2 400 ms, end 59 742.16 0.32 0.47 564.88 805.22 0.39 0.79 779.57 538.23 0.18 0.98 530.47 False True M3 code best all >3 200 ms, centre 59 519.82 0.28 0.70 356.11 557.53 0.04 1.00 556.50 146.82 -0.02 1.00 146.82 True False M3 code best all >3 400 ms, end 59 742.16 0.32 0.47 564.88 805.22 0.39 0.79 779.57 538.23 0.18 0.98 530.47 False True M3 code best correct >2 200 ms, centre 61 564.79 0.27 0.69 416.99 554.97 0.07 1.00 554.28 104.48 -0.12 1.00 104.48 True False M3 code best correct >2 400 ms, end 61 772.48 0.33 0.40 579.60 822.80 0.42 0.72 792.93 416.95 0.01 1.00 416.95 False True M3 code best correct >3 200 ms, centre 60 550.32 0.27 0.70 398.31 558.67 0.05 1.00 557.64 115.31 -0.11 1.00 115.31 True False M3 code best correct >3 400 ms, end 60 767.36 0.32 0.42 581.92 813.41 0.41 0.77 787.11 418.79 -0.00 1.00 418.79 False True M3 code whole all >2 200 ms, centre 59 543.67 0.30 0.67 367.37 545.20 0.03 1.00 544.49 140.92 -0.03 1.00 140.92 True False M3 code whole all >2 400 ms, end 59 754.60 0.35 0.44 568.04 790.74 0.36 0.84 769.15 503.09 0.15 0.99 498.27 False True M3 code whole all >3 200 ms, centre 59 543.67 0.30 0.67 367.37 545.20 0.03 1.00 544.49 140.92 -0.03 1.00 140.92 True False M3 code whole all >3 400 ms, end 59 754.60 0.35 0.44 568.04 790.74 0.36 0.84 769.15 503.09 0.15 0.99 498.27 False True M3 code whole correct >2 200 ms, centre 61 583.74 0.29 0.66 420.09 552.07 0.06 1.00 551.72 102.38 -0.12 1.00 102.38 True False M3 code whole correct >2 400 ms, end 61 785.92 0.36 0.36 585.73 810.83 0.39 0.78 785.68 394.40 -0.02 1.00 394.40 False True M3 code whole correct >3 200 ms, centre 60 573.79 0.29 0.66 403.49 547.52 0.04 1.00 547.17 113.36 -0.12 1.00 113.36 True False M3 code whole correct >3 400 ms, end 60 778.09 0.35 0.39 584.99 801.67 0.38 0.80 777.55 394.57 -0.04 1.00 394.57 False True code 10 in total best all >2 200 ms, centre 32 167.91 -0.17 0.99 159.77 318.10 -0.01 0.99 314.00 115.87 0.32 0.98 99.87 True False code 10 in total best all >2 400 ms, end 32 358.68 -0.62 0.96 336.71 646.46 0.46 0.75 562.40 376.09 0.13 0.89 310.01 True False code 10 in total best all >3 200 ms, centre 32 167.91 -0.17 0.99 159.77 318.10 -0.01 0.99 314.00 115.87 0.32 0.98 99.87 True False code 10 in total best all >3 400 ms, end 32 358.68 -0.62 0.96 336.71 646.46 0.46 0.75 562.40 376.09 0.13 0.89 310.01 True False code 10 in total best correct >2 200 ms, centre 33 192.48 -0.12 0.99 183.89 210.49 -0.08 1.00 209.80 136.13 0.45 1.00 133.83 False False code 10 in total best correct >2 400 ms, end 33 388.11 -0.52 0.95 361.74 532.14 0.47 0.89 485.28 342.69 0.13 0.92 297.50 True False code 10 in total best correct >3 200 ms, centre 32 177.15 -0.14 0.99 169.11 216.86 -0.11 1.00 216.86 132.76 0.45 0.99 128.13 True False code 10 in total best correct >3 400 ms, end 32 371.34 -0.59 0.96 347.01 541.67 0.44 0.89 497.38 337.40 0.09 0.93 293.10 True False code 10 in total whole all >2 200 ms, centre 32 176.55 -0.16 0.99 168.50 331.22 0.00 0.99 326.05 114.98 0.33 0.98 99.78 True False code 10 in total whole all >2 400 ms, end 32 366.39 -0.60 0.96 343.58 656.10 0.46 0.75 575.66 365.93 0.12 0.90 304.60 True False code 10 in total whole all >3 200 ms, centre 32 176.55 -0.16 0.99 168.50 331.22 0.00 0.99 326.05 114.98 0.33 0.98 99.78 True False code 10 in total whole all >3 400 ms, end 32 366.39 -0.60 0.96 343.58 656.10 0.46 0.75 575.66 365.93 0.12 0.90 304.60 True False code 10 in total whole correct >2 200 ms, centre 33 192.48 -0.12 0.99 183.89 210.49 -0.08 1.00 209.80 136.13 0.45 1.00 133.83 False False code 10 in total whole correct >2 400 ms, end 33 388.11 -0.52 0.95 361.74 532.14 0.47 0.89 485.28 342.69 0.13 0.92 297.50 True False code 10 in total whole correct >3 200 ms, centre 32 177.15 -0.14 0.99 169.11 216.86 -0.11 1.00 216.86 132.76 0.45 0.99 128.13 True False code 10 in total whole correct >3 400 ms, end 32 371.34 -0.59 0.96 347.01 541.67 0.44 0.89 497.38 337.40 0.09 0.93 293.10 True False code code best all >2 200 ms, centre 32 447.25 0.25 0.80 334.77 533.03 0.02 0.99 530.44 119.95 -0.01 1.00 119.17 True False code code best all >2 400 ms, end 32 674.28 0.21 0.63 543.41 793.13 0.37 0.84 773.53 480.57 0.13 0.97 466.26 False False code code best all >3 200 ms, centre 32 447.25 0.25 0.80 334.77 533.03 0.02 0.99 530.44 119.95 -0.01 1.00 119.17 True False code code best all >3 400 ms, end 32 674.28 0.21 0.63 543.41 793.13 0.37 0.84 773.53 480.57 0.13 0.97 466.26 False False code code best correct >2 200 ms, centre 30 516.06 0.27 0.72 365.26 542.14 0.04 1.00 540.70 79.24 -0.08 1.00 79.24 True False code code best correct >2 400 ms, end 30 718.99 0.27 0.51 545.08 817.83 0.40 0.69 780.22 357.14 0.09 0.99 350.55 False False code code best correct >3 200 ms, centre 29 493.07 0.26 0.76 364.57 541.96 0.02 1.00 540.52 71.82 -0.08 1.00 71.82 False False code code best correct >3 400 ms, end 29 709.56 0.25 0.56 556.86 809.97 0.39 0.73 777.34 352.82 0.08 0.99 348.41 False False code code whole all >2 200 ms, centre 32 447.25 0.25 0.80 334.77 533.03 0.02 0.99 530.44 119.95 -0.01 1.00 119.17 True False code code whole all >2 400 ms, end 32 674.28 0.21 0.63 543.41 793.13 0.37 0.84 773.53 480.57 0.13 0.97 466.26 False False code code whole all >3 200 ms, centre 32 447.25 0.25 0.80 334.77 533.03 0.02 0.99 530.44 119.95 -0.01 1.00 119.17 True False code code whole all >3 400 ms, end 32 674.28 0.21 0.63 543.41 793.13 0.37 0.84 773.53 480.57 0.13 0.97 466.26 False False code code whole correct >2 200 ms, centre 30 516.06 0.27 0.72 365.26 542.14 0.04 1.00 540.70 79.24 -0.08 1.00 79.24 True False code code whole correct >2 400 ms, end 30 718.99 0.27 0.51 545.08 817.83 0.40 0.69 780.22 357.14 0.09 0.99 350.55 False False code code whole correct >3 200 ms, centre 29 493.07 0.26 0.76 364.57 541.96 0.02 1.00 540.52 71.82 -0.08 1.00 71.82 False False code code whole correct >3 400 ms, end 29 709.56 0.25 0.56 556.86 809.97 0.39 0.73 777.34 352.82 0.08 0.99 348.41 False False Readings: 64; times within tolerance: 40; bilateral 1 spot reaching 80% before the cue in fewer than half the resamples: 8; both: 0 Bilateral 1 spot: fraction of resamples recovering 0.36 to 0.99 Neurons left after each selection step: rule screen pyramidal screening trials selective |preference| > 1 control trials trials per condition code code 91 91 40 32 32 32 code 10 in total 91 90 40 32 32 32 M3 code 91 91 59 59 59 59 M3 10 in total 91 90 58 58 58 58 Mean delta selectivity (photoinhibition minus control, spikes/s) in the last 400 ms of the delay: rule code, 32 neurons: bilateral 1 spot -0.55 (s.e.m. 0.52), ipsilateral 4 spots -0.21 (s.e.m. 0.23); control selectivity 2.42; difference -0.33, paired t-test p = 0.533 rule M3, 59 neurons: bilateral 1 spot -0.46 (s.e.m. 0.30), ipsilateral 4 spots -0.11 (s.e.m. 0.15); control selectivity 1.35; difference -0.35, paired t-test p = 0.269 Variant: bilateral 1 spot (type 7) with the sessions holding types 4, 5, 7 pooled with Experiment 3:
rule selective_on window neurons mice recovery_ms sd_ms frac_boot_recovered censored_ms deficit_at_-0.2s code all 200 ms, centre 54 3 442.87 145.92 0.59 629.38 0.46 code all 400 ms, end 54 3 623.81 149.70 0.32 810.79 0.34 code correct 200 ms, centre 57 3 421.24 185.95 0.65 590.24 0.42 code correct 400 ms, end 57 3 608.55 170.78 0.39 785.17 0.33 M3 all 200 ms, centre 113 3 462.35 179.43 0.65 616.84 0.41 M3 all 400 ms, end 113 3 644.24 157.58 0.38 803.58 0.38 M3 correct 200 ms, centre 121 3 469.05 186.08 0.77 567.31 0.32 M3 correct 400 ms, end 121 3 674.10 172.73 0.51 785.47 0.35 Paper: 40 neurons; 490 +- 280 and 235 +- 156 ms; bilateral 1 spot does not recover.
Result: not reproduced. In the six Experiment 3 sessions, the ipsilateral and contralateral 4-spot recovery times are within tolerance in 40 of 64 readings (code reading 530 ms and 119 ms, against 490 +- 280 and 235 +- 156 ms). But bilateral 1-spot selectivity reaches 80% of control before the cue in 36% to 99% of resamples (80% under the code's reading), where the paper reports no recovery; in no reading are both the times within tolerance and the bilateral selectivity unrecovered. The bilateral 1-spot change in the last 400 ms of the delay is larger in magnitude than the ipsilateral 4-spot one (-0.55 against -0.21 spikes/s with 32 neurons, -0.46 against -0.11 with 59), but neither difference is significant (paired p = 0.53 and 0.27). The selections hold 29 to 61 neurons against 40. With the bilateral 1-spot neurons of the sessions with types 4, 5 and 7 pooled (54 to 121 neurons), 32% to 77% of resamples recover.
ed2b-silencing¶
Claim: photoinhibition silences more than 90% of putative pyramidal activity, similarly with ipsilateral and bilateral photoinhibition and in both mouse lines, while contralateral photoinhibition barely changes the average rate. Per neuron, spike rate during photoinhibition over the rate in the same window of control trials, neurons with mean rate < 1 spike/s excluded (criterion). Window (a) photoinhibition before the ramp, (b) the whole period with the ramp. Reduction = 1 minus the mean normalized rate. Neurons need at least 3 photoinhibition trials and 5 control trials (a standard choice). Mouse lines from the data set's meta data files (gene_modification field), as in the data check.
def silencing_rows(window):
rows = []
for k, u in enumerate(units):
e = EXP[u["session"]]
if u["cell_type"] != "pyramidal" or not (M[k]["fr_mean"] >= 1) or e == "none":
continue
s = SD[u["session"]]
tr = u["trials"]
st = s["stim_type"][tr]
ok = u["stable"] & ~s["trial_types"]["LickEarly"][tr]
for c in CONDS[e]:
a = ONSET[c]
b = OFFSET[c] - (RAMP.get(c, 0.2) if window == "a" else 0.0)
ci, si = np.flatnonzero(ok & (st == 0)), np.flatnonzero(ok & (st == c))
if len(si) < 3 or len(ci) < 5:
continue
cnt = alm3.binned_window(u["binned"], [(a + b) / 2], b - a)[:, 0]
rc, rs = cnt[ci].mean(), cnt[si].mean()
if rc > 0:
rows.append({"session": u["session"], "experiment": e, "condition": c, "label": alm3.STIM_LABELS[c], "mouse": u["mouse"],
"line": LINE[u["mouse"]], "norm_rate": rs / rc})
return pd.DataFrame(rows)
for window in ("a", "b"):
sil = silencing_rows(window)
print(f"Window ({window}): {'onset to start of ramp' if window == 'a' else 'onset to end of ramp'}")
t = sil.groupby(["experiment", "condition", "label"]).norm_rate.agg(["size", "mean", "median"])
t["reduction"] = 1 - t["mean"]
print(t.round(3).to_string())
print("By mouse line, ipsilateral and bilateral conditions (types 1-4, 6-8):")
t2 = sil[sil.condition.isin([1, 2, 3, 4, 6, 7, 8])].groupby(["line", "experiment"]).norm_rate.agg(["size", "mean"])
t2["reduction"] = 1 - t2["mean"]
print(t2.round(3).to_string())
t3 = sil[(sil.condition == 4) & (sil.experiment == "exp2")].groupby("line").norm_rate.agg(["size", "mean"])
t3["reduction"] = 1 - t3["mean"]
print("By mouse line, Experiment 2 ipsilateral (type 4), as ED Fig. 2b right:")
print(t3.round(3).to_string())
print("By mouse, Experiment 2 ipsilateral (type 4):")
print(sil[(sil.condition == 4) & (sil.experiment == "exp2")].groupby("mouse").norm_rate.agg(["size", "mean"]).round(3).to_string())
print()
NOSIL = set(clk[clk.ratio > 0.5].session)
sil = silencing_rows("a")
print("Neurons per condition (window a) against the ED Fig. 2b legend (Experiment 1: 117, 110, 109; Experiment 2: 300, 294, 301; Experiment 3: 52, 52, 102):")
print(sil.groupby(["experiment", "condition"]).size().to_string())
print("Bilateral 1 spot (type 7), Experiment 3 and the sessions with types 4, 5, 7 together:", int((sil.condition == 7).sum()))
print("\nVariant, window (a), without the four sessions in which photoinhibition does not lower the rate (data check):", sorted(NOSIL))
sx = sil[~sil.session.isin(NOSIL)]
t = sx.groupby(["experiment", "condition", "label"]).norm_rate.agg(["size", "mean"])
t["reduction"] = 1 - t["mean"]
print(t.round(3).to_string())
t2 = sx[sx.condition.isin([1, 2, 3, 4, 6, 7, 8])].groupby(["line", "experiment"]).norm_rate.agg(["size", "mean"])
t2["reduction"] = 1 - t2["mean"]
print(t2.round(3).to_string())
t3 = sx[(sx.condition == 4) & (sx.experiment == "exp2")].groupby("line").norm_rate.agg(["size", "mean"])
t3["reduction"] = 1 - t3["mean"]
print("Experiment 2 ipsilateral by line:")
print(t3.round(3).to_string())
print("Criterion: reduction at least 0.81 for ipsilateral and bilateral photoinhibition in each experiment and each line; contralateral mean normalized rate within 0.8 to 1.2.")
Window (a): onset to start of ramp
size mean median reduction
experiment condition label
ccx 10 CCX ipsi 1 spot (0.8 s) 317 0.120 0.036 0.880
11 CCX contra 1 spot (0.8 s) 317 0.959 0.911 0.041
12 CCX bilateral 4 spots (0.8 s) 322 0.236 0.048 0.764
exp2 4 ipsi 1 spot (0.8 s) 322 0.084 0.014 0.916
5 contra 1 spot (0.8 s) 319 0.945 0.809 0.055
6 bilateral 4 spots (0.8 s) 323 0.076 0.029 0.924
exp2b 4 ipsi 1 spot (0.8 s) 61 0.115 0.000 0.885
5 contra 1 spot (0.8 s) 61 0.986 0.893 0.014
7 bilateral 1 spot (0.8 s) 61 0.114 0.000 0.886
exp3 7 bilateral 1 spot (0.8 s) 56 0.060 0.024 0.940
8 ipsi 4 spots (0.8 s) 56 0.038 0.000 0.962
9 contra 4 spots (0.8 s) 56 1.152 0.819 -0.152
unilateral 1 ipsi 1 spot sample (0.5 s) 180 0.062 0.019 0.938
2 ipsi 1 spot early delay (0.5 s) 180 0.069 0.017 0.931
3 ipsi 1 spot middle delay (0.5 s) 180 0.090 0.017 0.910
By mouse line, ipsilateral and bilateral conditions (types 1-4, 6-8):
size mean reduction
line experiment
PV x ReaChR exp2 433 0.052 0.948
exp2b 70 0.014 0.986
exp3 34 0.068 0.932
unilateral 540 0.074 0.926
VGAT-ChR2 exp2 212 0.137 0.863
exp2b 52 0.250 0.750
exp3 78 0.041 0.959
By mouse line, Experiment 2 ipsilateral (type 4), as ED Fig. 2b right:
size mean reduction
line
PV x ReaChR 216 0.049 0.951
VGAT-ChR2 106 0.155 0.845
By mouse, Experiment 2 ipsilateral (type 4):
size mean
mouse
ANM255201 34 0.105
ANM257637 34 0.088
ANM257772 26 0.057
ANM258250 39 0.245
ANM263808 91 0.023
ANM263810 65 0.055
ANM264411 33 0.117
Window (b): onset to end of ramp
size mean median reduction
experiment condition label
ccx 10 CCX ipsi 1 spot (0.8 s) 317 0.124 0.039 0.876
11 CCX contra 1 spot (0.8 s) 317 0.951 0.880 0.049
12 CCX bilateral 4 spots (0.8 s) 322 0.312 0.067 0.688
exp2 4 ipsi 1 spot (0.8 s) 322 0.087 0.015 0.913
5 contra 1 spot (0.8 s) 319 0.958 0.808 0.042
6 bilateral 4 spots (0.8 s) 323 0.090 0.025 0.910
exp2b 4 ipsi 1 spot (0.8 s) 61 0.108 0.006 0.892
5 contra 1 spot (0.8 s) 61 0.992 0.888 0.008
7 bilateral 1 spot (0.8 s) 61 0.115 0.007 0.885
exp3 7 bilateral 1 spot (0.8 s) 56 0.114 0.076 0.886
8 ipsi 4 spots (0.8 s) 56 0.091 0.029 0.909
9 contra 4 spots (0.8 s) 56 1.222 0.874 -0.222
unilateral 1 ipsi 1 spot sample (0.5 s) 180 0.058 0.015 0.942
2 ipsi 1 spot early delay (0.5 s) 180 0.067 0.015 0.933
3 ipsi 1 spot middle delay (0.5 s) 180 0.079 0.015 0.921
By mouse line, ipsilateral and bilateral conditions (types 1-4, 6-8):
size mean reduction
line experiment
PV x ReaChR exp2 433 0.046 0.954
exp2b 70 0.011 0.989
exp3 34 0.075 0.925
unilateral 540 0.068 0.932
VGAT-ChR2 exp2 212 0.176 0.824
exp2b 52 0.246 0.754
exp3 78 0.115 0.885
By mouse line, Experiment 2 ipsilateral (type 4), as ED Fig. 2b right:
size mean reduction
line
PV x ReaChR 216 0.047 0.953
VGAT-ChR2 106 0.169 0.831
By mouse, Experiment 2 ipsilateral (type 4):
size mean
mouse
ANM255201 34 0.120
ANM257637 34 0.109
ANM257772 26 0.051
ANM258250 39 0.265
ANM263808 91 0.018
ANM263810 65 0.049
ANM264411 33 0.117
Neurons per condition (window a) against the ED Fig. 2b legend (Experiment 1: 117, 110, 109; Experiment 2: 300, 294, 301; Experiment 3: 52, 52, 102):
experiment condition
ccx 10 317
11 317
12 322
exp2 4 322
5 319
6 323
exp2b 4 61
5 61
7 61
exp3 7 56
8 56
9 56
unilateral 1 180
2 180
3 180
Bilateral 1 spot (type 7), Experiment 3 and the sessions with types 4, 5, 7 together: 117
Variant, window (a), without the four sessions in which photoinhibition does not lower the rate (data check): ['ANM257636_20150404', 'ANM264411_20141224', 'ANM273657_20150325', 'ANM298738_20150727']
size mean reduction
experiment condition label
ccx 10 CCX ipsi 1 spot (0.8 s) 309 0.094 0.906
11 CCX contra 1 spot (0.8 s) 309 0.963 0.037
12 CCX bilateral 4 spots (0.8 s) 314 0.208 0.792
exp2 4 ipsi 1 spot (0.8 s) 305 0.078 0.922
5 contra 1 spot (0.8 s) 302 0.935 0.065
6 bilateral 4 spots (0.8 s) 306 0.071 0.929
exp2b 4 ipsi 1 spot (0.8 s) 47 0.025 0.975
5 contra 1 spot (0.8 s) 47 1.026 -0.026
7 bilateral 1 spot (0.8 s) 47 0.009 0.991
exp3 7 bilateral 1 spot (0.8 s) 56 0.060 0.940
8 ipsi 4 spots (0.8 s) 56 0.038 0.962
9 contra 4 spots (0.8 s) 56 1.152 -0.152
unilateral 1 ipsi 1 spot sample (0.5 s) 180 0.062 0.938
2 ipsi 1 spot early delay (0.5 s) 180 0.069 0.931
3 ipsi 1 spot middle delay (0.5 s) 180 0.090 0.910
size mean reduction
line experiment
PV x ReaChR exp2 433 0.052 0.948
exp2b 70 0.014 0.986
exp3 34 0.068 0.932
unilateral 540 0.074 0.926
VGAT-ChR2 exp2 178 0.130 0.870
exp2b 24 0.025 0.975
exp3 78 0.041 0.959
Experiment 2 ipsilateral by line:
size mean reduction
line
PV x ReaChR 216 0.049 0.951
VGAT-ChR2 89 0.148 0.852
Criterion: reduction at least 0.81 for ipsilateral and bilateral photoinhibition in each experiment and each line; contralateral mean normalized rate within 0.8 to 1.2.
Result: reproduced. With the window before the offset ramp (reading a), the mean normalized rate of pyramidal neurons gives a reduction of at least 0.91 for ipsilateral and bilateral photoinhibition in Experiment 1 (0.910 to 0.938), Experiment 2 (0.916, 0.924) and Experiment 3 (0.962, 0.940), and 0.885 and 0.886 in the six sessions with types 4, 5 and 7, and in Experiment 2 ipsilateral 0.951 in PV x ReaChR and 0.845 in VGAT-ChR2 mice, all at least 0.81. Contralateral photoinhibition leaves the mean normalized rate at 0.945 (Experiment 2) and 1.152 (Experiment 3), within 0.8 to 1.2. With the whole period (reading b) the Experiment 3 contralateral value is 1.222, outside. Without the four sessions in which photoinhibition does not lower the rate, the VGAT-ChR2 reduction in the sessions with types 4, 5 and 7 rises from 0.750 to 0.975 and in Experiment 2 ipsilateral from 0.845 to 0.852. The neuron counts of Experiments 1 and 2 (180 per condition, 319 to 323) are above the legend's 117, 110, 109 and 300, 294, 301; Experiment 3 has 56 per condition, above the legend's 52 and 52 and below its 102 for bilateral 1 spot.
ed2e-no-rebound¶
Claim: no rebound excitation on average after photoinhibition offset; a small proportion of neurons show rebound, balanced by low-level sustained inhibition in a larger proportion. Experiment 2, lick right trials, ipsilateral photoinhibition (type 4); windows 0 to 400 ms and 400 to 800 ms after offset; per neuron two-tailed t-test of counts, control against photoinhibition, p < 0.01; population test a paired t-test over neurons of the mean rates (criterion). Neurons: pyramidal with more than 3 lick right photoinhibition trials, with and without the 1 spike/s exclusion (M3).
for fr_min in (1.0, None):
rows = []
for k, u in enumerate(units):
if EXP[u["session"]] != "exp2" or u["cell_type"] != "pyramidal":
continue
if fr_min is not None and not (M[k]["fr_mean"] > fr_min):
continue
s = SD[u["session"]]
tr = u["trials"]
st, sd_ = s["stim_type"][tr], alm3.side(s)[tr]
ok = u["stable"] & ~s["trial_types"]["LickEarly"][tr] & (sd_ == 1)
ci, si = np.flatnonzero(ok & (st == 0)), np.flatnonzero(ok & (st == 4))
if len(si) <= 3 or len(ci) <= 3:
continue
r = {}
for name, (a, b) in (("w1", (-0.9, -0.5)), ("w2", (-0.5, -0.1))):
cnt = alm3.binned_window(u["binned"], [(a + b) / 2], b - a)[:, 0]
r[name + "_ctrl"], r[name + "_stim"] = cnt[ci].mean() / 0.4, cnt[si].mean() / 0.4
r[name + "_p"] = stats.ttest_ind(cnt[ci], cnt[si]).pvalue
rows.append(r)
rb = pd.DataFrame(rows)
print(f"Rate exclusion: {'> 1 spike/s' if fr_min else 'none'}; neurons {len(rb)}")
for w, lab in (("w1", "0-400 ms after offset"), ("w2", "400-800 ms after offset")):
d = rb[w + "_stim"] - rb[w + "_ctrl"]
t = stats.ttest_rel(rb[w + "_stim"], rb[w + "_ctrl"])
exc = int(((rb[w + "_p"] < 0.01) & (d > 0)).sum())
sup = int(((rb[w + "_p"] < 0.01) & (d < 0)).sum())
print(f" {lab}: mean control {rb[w + '_ctrl'].mean():.2f}, photoinhibition {rb[w + '_stim'].mean():.2f} spikes/s; "
f"difference {d.mean():+.2f}, paired t = {t.statistic:.2f}, p = {t.pvalue:.3g}; excited {exc}, suppressed {sup} (p < 0.01)")
exc5, sup5 = int(((rb[w + "_p"] < 0.05) & (d > 0)).sum()), int(((rb[w + "_p"] < 0.05) & (d < 0)).sum())
print(f" at p < 0.05: excited {exc5}, suppressed {sup5}; any difference: higher {int((d > 0).sum())}, lower {int((d < 0).sum())} "
f"(median difference {d.median():+.2f} spikes/s)")
Rate exclusion: > 1 spike/s; neurons 306
0-400 ms after offset: mean control 4.73, photoinhibition 4.60 spikes/s; difference -0.14, paired t = -0.58, p = 0.565; excited 24, suppressed 9 (p < 0.01)
at p < 0.05: excited 36, suppressed 21; any difference: higher 125, lower 177 (median difference -0.28 spikes/s)
400-800 ms after offset: mean control 4.67, photoinhibition 4.77 spikes/s; difference +0.10, paired t = 0.50, p = 0.617; excited 22, suppressed 3 (p < 0.01)
at p < 0.05: excited 34, suppressed 15; any difference: higher 139, lower 163 (median difference -0.13 spikes/s)
Rate exclusion: none; neurons 408
0-400 ms after offset: mean control 3.65, photoinhibition 3.59 spikes/s; difference -0.06, paired t = -0.32, p = 0.747; excited 30, suppressed 9 (p < 0.01)
at p < 0.05: excited 48, suppressed 21; any difference: higher 161, lower 229 (median difference -0.14 spikes/s)
400-800 ms after offset: mean control 3.61, photoinhibition 3.74 spikes/s; difference +0.13, paired t = 0.87, p = 0.383; excited 27, suppressed 3 (p < 0.01)
at p < 0.05: excited 48, suppressed 15; any difference: higher 175, lower 215 (median difference -0.06 spikes/s)
Result: not reproduced. On lick right trials after ipsilateral photoinhibition (306 neurons above 1 spike/s), the population rate is not higher than control in the first 400 ms after offset (difference -0.14 spikes/s, p = 0.565) or the next 400 ms (+0.10, p = 0.617), so there is no rebound on average. But more neurons are significantly excited (24) than suppressed (9) at p < 0.01 in the first 400 ms, the opposite of the balance the criterion requires; without the rate exclusion the counts are 30 and 9, and at p < 0.05 36 and 21. Counting every neuron by the sign of its change, more are lower (177) than higher (125), with a median change of -0.28 spikes/s, which fits the paper's "low level of sustained inhibition in a larger proportion"; whether the criterion's count at p < 0.01 is the right reading is asked of a reader.
ed4-return-to-trajectory¶
Claim: neurons whose rates decrease during the delay epoch also recover after unilateral photoinhibition, returning to the time-matched control trajectory and not decaying to the end-point rate (27 neurons from 6 mice; paired t-test p < 0.001). Criterion: Experiment 1 pyramidal neurons with a lower rate at the end of the delay than at its start (two-tailed t-test, 400 ms windows, trial types pooled, p < 0.05); rates normalized to each neuron's mean rate, preferred and non-preferred types separately; per neuron, RMS over the time from photoinhibition offset to the cue of (perturbed minus time-matched control) and of (perturbed minus the control rate in the last 400 ms of the delay). Conditions (a) early delay (type 2), (b) the three conditions pooled per neuron. The windows "start" and "end" of the delay are read as its first and last 400 ms. Increasing neurons are shown as a variant. The RMS windows start after photoinhibition has ended (verifier, round 1): 200 ms windows stamped at their centre from 0.1 s after offset to 0.1 s before the cue, or 400 ms windows stamped at their end from 0.4 s after offset to the cue; the end point is the control rate in the last 400 ms of the delay.
def ed4_rows(direction, exp="unilateral", conds=(1, 2, 3), width=0.2):
"""Per neuron and condition, the RMS of (perturbed minus time-matched control) and of
(perturbed minus the control rate in the last 400 ms of the delay), in units of the neuron's
mean rate, preferred and non-preferred types. The rate is the `width` boxcar; 200 ms windows
are stamped at their centre and taken from 0.1 s after offset to 0.1 s before the cue, 400 ms
windows at their end and taken from 0.4 s after offset to the cue, so that no window overlaps
photoinhibition or the response epoch."""
rows = []
for k, u in enumerate(units):
if EXP[u["session"]] != exp or u["cell_type"] != "pyramidal" or M[k]["pref_counts"] is None:
continue
m = M[k] if width == 0.2 else MV(k, "code", width)
s = SD[u["session"]]
tr = u["trials"]
st = s["stim_type"][tr]
sd_ = alm3.side(s)[tr]
ok = u["stable"] & ~s["trial_types"]["LickEarly"][tr] & (st == 0)
if ok.sum() < 10:
continue
d0 = -1.3 if exp == "unilateral" else -1.7
early = alm3.binned_window(u["binned"][ok], [d0 + 0.2], 0.4)[:, 0]
late = alm3.binned_window(u["binned"][ok], [-0.2], 0.4)[:, 0]
p = stats.ttest_ind(early, late).pvalue
if not (p < 0.05) or (late.mean() < early.mean()) != (direction == "decrease"):
continue
norm = M[k]["fr_mean"] if M[k]["fr_mean"] > 0 else np.nan
sgn = 1 if M[k]["pref_counts"][0] >= 0 else -1
# end point: control rate in the last 400 ms of the delay, per trial type
last = alm3.binned_window(u["binned"], [-0.2], 0.4)[:, 0] / 0.4
endpoint = {typ: last[np.flatnonzero(ok & (sd_ == typ))].mean() / norm for typ in (1, -1)}
stamp = GT if width == 0.2 else GT + width / 2
r = {"k": k, "mouse": u["mouse"]}
for c in conds:
cd = m["cond"].get(c)
if cd is None or cd["psth"][1] is None or cd["psth"][-1] is None or cd["nR"] < 3 or cd["nL"] < 3:
r[c] = None
continue
win = (stamp >= OFFSET[c] + 0.1 - 1e-9) & (stamp <= -0.1 + 1e-9) if width == 0.2 else (stamp >= OFFSET[c] + 0.4 - 1e-9) & (stamp <= 1e-9)
if not win.any():
r[c] = None
continue
vals_tm, vals_ep = [], []
for typ in (sgn, -sgn):
ctrl = m["psth_ctrl_all"][typ] / norm
pert = cd["psth"][typ] / norm
vals_tm.append(pert[win] - ctrl[win])
vals_ep.append(pert[win] - endpoint[typ])
r[c] = (np.sqrt(np.mean(np.concatenate(vals_tm) ** 2)), np.sqrt(np.mean(np.concatenate(vals_ep) ** 2)))
rows.append(r)
return rows
for width in (0.2, 0.4):
print(f"Windows of {int(width * 1000)} ms " + ("stamped at their centre, from 0.1 s after offset to 0.1 s before the cue:" if width == 0.2
else "stamped at their end, from 0.4 s after offset to the cue:"))
for direction, exp, readings in (("decrease", "unilateral", (("(a) early delay", [2]), ("(b) pooled", [1, 2, 3]))),
("increase", "unilateral", (("(a) early delay", [2]), ("(b) pooled", [1, 2, 3]))),
("decrease", "exp2", (("variant, Experiment 2 ipsilateral", [4]),))):
rows = ed4_rows(direction, exp, sorted({c for _, cs in readings for c in cs}), width=width)
print(f" {direction}, {exp}: {len(rows)} neurons from {len({r['mouse'] for r in rows})} mice")
for lab, conds in readings:
tm, ep = [], []
for r in rows:
v = [r[c] for c in conds if r.get(c) is not None]
if v:
tm.append(np.mean([x[0] for x in v]))
ep.append(np.mean([x[1] for x in v]))
tm, ep = np.array(tm), np.array(ep)
t = stats.ttest_rel(tm, ep)
print(f" {lab}: n = {len(tm)}; RMS to time-matched control {tm.mean():.3f}, to end point {ep.mean():.3f}; "
f"paired t = {t.statistic:.2f}, p = {t.pvalue:.3g}; smaller to time-matched in {(tm < ep).sum()} of {len(tm)}")
print("RMS in units of the neuron's mean rate; the end point is the control rate in the last 400 ms of the delay (criterion).")
Windows of 200 ms stamped at their centre, from 0.1 s after offset to 0.1 s before the cue:
decrease, unilateral: 55 neurons from 4 mice
(a) early delay: n = 47; RMS to time-matched control 0.462, to end point 0.429; paired t = 1.12, p = 0.268; smaller to time-matched in 18 of 47
(b) pooled: n = 47; RMS to time-matched control 0.500, to end point 0.494; paired t = 0.33, p = 0.742; smaller to time-matched in 17 of 47
increase, unilateral: 44 neurons from 4 mice
(a) early delay: n = 34; RMS to time-matched control 1.040, to end point 1.100; paired t = -1.77, p = 0.0857; smaller to time-matched in 23 of 34
(b) pooled: n = 34; RMS to time-matched control 0.970, to end point 1.051; paired t = -2.13, p = 0.0407; smaller to time-matched in 22 of 34
decrease, exp2: 111 neurons from 7 mice
variant, Experiment 2 ipsilateral: n = 106; RMS to time-matched control 0.731, to end point 0.729; paired t = 0.10, p = 0.918; smaller to time-matched in 57 of 106
Windows of 400 ms stamped at their end, from 0.4 s after offset to the cue:
decrease, unilateral: 55 neurons from 4 mice
(a) early delay: n = 47; RMS to time-matched control 0.378, to end point 0.367; paired t = 0.46, p = 0.651; smaller to time-matched in 20 of 47
(b) pooled: n = 47; RMS to time-matched control 0.451, to end point 0.470; paired t = -0.65, p = 0.519; smaller to time-matched in 20 of 47
increase, unilateral: 44 neurons from 4 mice
(a) early delay: n = 34; RMS to time-matched control 0.905, to end point 0.941; paired t = -1.10, p = 0.28; smaller to time-matched in 19 of 34
(b) pooled: n = 34; RMS to time-matched control 0.836, to end point 0.942; paired t = -2.04, p = 0.0494; smaller to time-matched in 22 of 34
decrease, exp2: 111 neurons from 7 mice
variant, Experiment 2 ipsilateral: n = 106; RMS to time-matched control 0.617, to end point 0.627; paired t = -0.80, p = 0.428; smaller to time-matched in 64 of 106
RMS in units of the neuron's mean rate; the end point is the control rate in the last 400 ms of the delay (criterion).
Result: not reproduced. 55 Experiment 1 pyramidal neurons (4 mice) decrease their rate through the delay, against 27 from 6 mice. For the 47 with enough photoinhibition trials, the RMS distance to the time-matched control is not smaller than to the end point: with 200 ms windows 0.462 against 0.429 after early-delay photoinhibition (paired p = 0.27) and 0.500 against 0.494 pooled (p = 0.74); with 400 ms windows 0.378 against 0.367 (p = 0.65) and 0.451 against 0.470 (p = 0.52). In Experiment 2 (106 neurons, 7 mice) the two are equal (p = 0.92 and 0.43). For neurons with increasing rates the time-matched distance is smaller when the conditions are pooled (p = 0.041 and 0.049) and not significantly after early-delay photoinhibition (p = 0.086 and 0.28).
ed10e-callosotomy-preparatory-activity¶
Claim: preparatory activity after callosotomy is similar to that of control mice, with 254 of 496 putative pyramidal neurons selective. Selectivity test of M3 on callosotomy control trials, under the same readings as ed1-selective-fraction; "similar" read as the selective fraction within 10 percentage points of the control mice's fraction under the same reading, and the population delay selectivity present and rising toward the cue (criterion).
pyr_c = (info.cell_type == "pyramidal") & (info.experiment == "ccx")
print("Callosotomy putative pyramidal neurons:", int(pyr_c.sum()), "(paper 496) from", info[pyr_c].mouse.nunique(), "mice,", info[pyr_c].session.nunique(), "sessions")
cc = info[info.experiment == "ccx"]
print("Callosotomy units by label:", cc.cell_type.value_counts().to_dict(), "; by width of the mean waveform:", cc.class_width.value_counts().to_dict(),
"; upsampled:", cc.class_width_up.value_counts().to_dict())
rows = []
for trials_name, label in (("correct", "correct"), ("all", "correct+error")):
for mask, grp in ((pyr_c, "callosotomy"), (pyr, "control mice")):
P = np.array([M[i][f"p_sel_{trials_name}"] for i in np.flatnonzero(mask)])
sig = P[:, [0, 1, 2]] < 0.05
rows.append({"trials": label, "group": grp, "n": len(P), "selective": int(sig.any(1).sum()), "fraction": sig.any(1).mean(),
"sample": int(sig[:, 0].sum()), "delay": int(sig[:, 1].sum()), "response": int(sig[:, 2].sum())})
e10 = pd.DataFrame(rows)
print(e10.round(3).to_string(index=False))
print("Paper: 254 of 496 callosotomy pyramidal neurons selective; control 634 of 890.")
# population delay selectivity (preferred minus non-preferred, control test trials), selective neurons
for grp, exps in (("callosotomy", ["ccx"]), ("control mice, 1.7 s delay", ["exp2", "exp2b", "exp3"])):
ks = [k for k, u in enumerate(units) if EXP[u["session"]] in exps and u["cell_type"] == "pyramidal" and M[k]["pref_counts"] is not None
and selective(k, "correct")]
sel = np.array([(1 if M[k]["pref_counts"][0] >= 0 else -1) * (M[k]["psth_ctrl"][1] - M[k]["psth_ctrl"][-1]) for k in ks])
pts = [-1.5, -1.0, -0.5, -0.1]
print(f"{grp}: {len(ks)} selective neurons; mean selectivity (spikes/s) at " + ", ".join(f"{t:+.1f} s: {sel[:, np.argmin(np.abs(GT - t))].mean():.2f}" for t in pts))
Callosotomy putative pyramidal neurons: 519 (paper 496) from 7 mice, 33 sessions
Callosotomy units by label: {'pyramidal': 519, 'FS': 45, 'none': 3} ; by width of the mean waveform: {'pyramidal': 521, 'intermediate': 31, 'FS': 15} ; upsampled: {'pyramidal': 521, 'FS': 36, 'intermediate': 10}
trials group n selective fraction sample delay response
correct callosotomy 519 303 0.584 66 137 222
correct control mice 890 633 0.711 176 336 493
correct+error callosotomy 519 259 0.499 50 122 179
correct+error control mice 890 571 0.642 152 287 404
Paper: 254 of 496 callosotomy pyramidal neurons selective; control 634 of 890.
callosotomy: 176 selective neurons; mean selectivity (spikes/s) at -1.5 s: 1.08, -1.0 s: 1.61, -0.5 s: 2.25, -0.1 s: 2.44
control mice, 1.7 s delay: 284 selective neurons; mean selectivity (spikes/s) at -1.5 s: 1.60, -1.0 s: 1.93, -0.5 s: 1.99, -0.1 s: 1.96
Result: not reproduced. The callosotomy sessions hold 519 units labelled pyramidal, against 496 (521 by the width of the mean waveform, also 521 after upsampling). With correct and error trials, 259 are selective, within 254 +- 25; with correct trials only, 303. The selective fraction is 0.50 against 0.64 in control mice under the same reading (0.58 against 0.71 with correct trials), more than the criterion's 10 points lower. Delay selectivity is present and rises toward the cue (1.08 spikes/s 1.5 s before the cue, 2.44 at 0.1 s before). The neuron count and the similarity of fractions fail, and the criterion has no partial rule.
fig5-callosotomy-recovery¶
Claim: after callosotomy, ALM neurons recover their average spike rate after ipsilateral photoinhibition but not their selectivity; selectivity recovers after contralateral photoinhibition (217 +- 228 ms) and not after bilateral; selectivity along cd is reduced; 129 selective neurons, 16 sessions. Method of the code (analysis_compile_all_data_bilateralCCX.m) as for fig2-bilateral-recovery; conditions as the data set labels them (types 10, 11, 12). The cd part is tested in the population section below.
Every reading of M4 and of the selection is run, as the criterion asks (verifier, round 1): the selection rule, "code" (selective in the sample or delay epoch with |preference count| > 1, the scripts) or "M3" (selective in any of the sample, delay or response epochs, the claims file); the screening trials, the code's, 10 of each type (M4 reading a) or 10 in total (M4 reading b); the preference, from the whole count (M4 reading a) or from the epoch where the screening trials differ most (M4 reading b); the trials of the selectivity test; the minimum trials per condition; and the window. A condition counts as within tolerance only when at least half the resamples reach 80% before the end of the search and their mean is within tolerance; the mean with the other resamples counted at the end of the search is also shown.
R5 = mean_rate_traces("ccx", [10, 11, 12])
rs5 = rate_summary(R5, [-1.3, -0.5, -0.3, -0.05])
print("Rates: photoinhibition over control population mean rate, and fraction of neurons with a significant change:")
print(rs5.drop(columns="label").round(3).to_string(index=False))
f5 = recovery_readings("ccx", [10, 11, 12], 0.0, {11: (217, 228)}, seed=51)
w5 = readings_wide(f5)
ok = f5.groupby(READING).agg(contra_within=("within_tol", lambda x: bool(x.dropna().all())))
w5 = w5.merge(ok.reset_index(), on=READING)
w5["ipsi_no_recovery"] = w5.frac_10 < 0.5
w5["bilateral_no_recovery"] = w5.frac_12 < 0.5
print("\nSelectivity recovery, every reading (10 ipsilateral, 11 contralateral, 12 bilateral):")
print(w5.round(2).to_string(index=False))
allok = w5.contra_within & w5.ipsi_no_recovery & w5.bilateral_no_recovery
print(f"\nReadings: {len(w5)}; contralateral within tolerance: {int(w5.contra_within.sum())}; ipsilateral not recovering: {int(w5.ipsi_no_recovery.sum())}; "
f"bilateral not recovering: {int(w5.bilateral_no_recovery.sum())}; all three: {int(allok.sum())}")
print("Ipsilateral: fraction of resamples recovering", round(w5.frac_10.min(), 2), "to", round(w5.frac_10.max(), 2), "; deficit 0.2 s before the cue",
round(w5.def_10.min(), 2), "to", round(w5.def_10.max(), 2))
print("Bilateral: fraction of resamples recovering at most", round(w5.frac_12.max(), 4), "; readings with at least one resample recovering:",
int((w5.frac_12 > 0).sum()))
print("Paper: 129 neurons; contralateral 217 +- 228 ms; ipsilateral and bilateral selectivity do not recover.")
Rates: photoinhibition over control population mean rate, and fraction of neurons with a significant change:
condition neurons rate_ratio@-1.30 frac_changed@-1.30 rate_ratio@-0.50 frac_changed@-0.50 rate_ratio@-0.30 frac_changed@-0.30 rate_ratio@-0.05 frac_changed@-0.05
10 311 0.121 0.643 1.106 0.174 1.081 0.145 1.053 0.087
11 308 0.963 0.081 0.956 0.062 0.998 0.032 0.969 0.013
12 300 0.091 0.700 1.027 0.273 1.034 0.230 1.062 0.180
Selectivity recovery, every reading (10 ipsilateral, 11 contralateral, 12 bilateral): rule screen pref selective_on min_trials window neurons cens_ms_10 def_10 frac_10 ms_10 cens_ms_11 def_11 frac_11 ms_11 cens_ms_12 def_12 frac_12 ms_12 contra_within ipsi_no_recovery bilateral_no_recovery M3 10 in total best all >2 200 ms, centre 253 895.02 0.80 0.01 485.00 345.58 0.06 0.98 332.53 900.00 0.92 0.0 NaN True True True M3 10 in total best all >2 400 ms, end 253 900.00 0.72 0.00 NaN 611.95 0.18 0.92 585.53 900.00 0.97 0.0 NaN False True True M3 10 in total best all >3 200 ms, centre 247 896.96 0.80 0.01 520.00 343.55 0.07 0.98 329.28 900.00 0.86 0.0 NaN True True True M3 10 in total best all >3 400 ms, end 247 900.00 0.72 0.00 NaN 612.32 0.19 0.90 581.06 900.00 0.95 0.0 NaN False True True M3 10 in total best correct >2 200 ms, centre 295 890.92 0.76 0.02 446.00 270.39 0.03 1.00 269.13 899.35 0.97 0.0 250.0 True True True M3 10 in total best correct >2 400 ms, end 295 900.00 0.70 0.00 NaN 512.20 0.10 0.98 502.66 900.00 0.97 0.0 NaN False True True M3 10 in total best correct >3 200 ms, centre 286 890.12 0.75 0.02 470.43 247.49 0.05 0.99 243.55 900.00 0.94 0.0 NaN True True True M3 10 in total best correct >3 400 ms, end 286 899.40 0.67 0.00 600.00 511.55 0.14 0.96 493.67 900.00 0.95 0.0 NaN False True True M3 10 in total whole all >2 200 ms, centre 253 887.69 0.79 0.03 475.52 282.12 0.02 1.00 280.26 899.13 0.89 0.0 30.0 True True True M3 10 in total whole all >2 400 ms, end 253 899.04 0.70 0.00 580.00 545.16 0.14 0.97 534.94 900.00 0.97 0.0 NaN False True True M3 10 in total whole all >3 200 ms, centre 247 889.79 0.79 0.02 456.09 284.36 0.03 0.99 278.77 900.00 0.83 0.0 NaN True True True M3 10 in total whole all >3 400 ms, end 247 900.00 0.69 0.00 NaN 551.74 0.15 0.96 536.09 900.00 0.94 0.0 NaN False True True M3 10 in total whole correct >2 200 ms, centre 295 893.49 0.82 0.02 466.00 286.06 -0.05 1.00 286.06 900.00 0.94 0.0 NaN True True True M3 10 in total whole correct >2 400 ms, end 295 898.51 0.74 0.00 403.33 516.76 0.11 0.99 514.45 900.00 0.99 0.0 NaN False True True M3 10 in total whole correct >3 200 ms, centre 286 891.64 0.81 0.02 408.24 256.87 -0.03 1.00 254.29 899.32 0.91 0.0 220.0 True True True M3 10 in total whole correct >3 400 ms, end 286 899.10 0.71 0.00 600.00 512.66 0.15 0.99 507.56 900.00 0.97 0.0 NaN False True True M3 code best all >2 200 ms, centre 253 895.12 0.74 0.01 290.00 368.99 0.28 0.85 272.33 900.00 0.82 0.0 NaN True True True M3 code best all >2 400 ms, end 253 900.00 0.66 0.00 NaN 662.15 0.30 0.48 407.56 900.00 0.98 0.0 NaN False True True M3 code best all >3 200 ms, centre 247 889.44 0.74 0.02 240.00 336.57 0.26 0.89 264.79 900.00 0.82 0.0 NaN True True True M3 code best all >3 400 ms, end 247 899.45 0.67 0.00 350.00 621.42 0.27 0.57 414.67 900.00 0.98 0.0 NaN True True True M3 code best correct >2 200 ms, centre 295 851.48 0.68 0.08 253.07 216.95 0.21 0.97 192.91 900.00 0.79 0.0 NaN True True True M3 code best correct >2 400 ms, end 295 896.65 0.59 0.01 527.78 461.98 0.21 0.85 382.25 900.00 0.94 0.0 NaN True True True M3 code best correct >3 200 ms, centre 286 838.62 0.68 0.09 232.83 195.87 0.20 0.98 182.96 900.00 0.82 0.0 NaN True True True M3 code best correct >3 400 ms, end 286 892.11 0.59 0.02 461.67 430.65 0.21 0.86 354.24 900.00 0.94 0.0 NaN True True True M3 code whole all >2 200 ms, centre 253 899.64 0.79 0.00 540.00 544.11 0.29 0.65 350.79 900.00 0.93 0.0 NaN True True True M3 code whole all >2 400 ms, end 253 900.00 0.71 0.00 NaN 802.50 0.34 0.24 485.11 900.00 1.03 0.0 NaN False True True M3 code whole all >3 200 ms, centre 247 900.00 0.79 0.00 NaN 494.62 0.27 0.74 350.70 900.00 0.93 0.0 NaN True True True M3 code whole all >3 400 ms, end 247 900.00 0.72 0.00 NaN 772.20 0.31 0.30 480.98 900.00 1.03 0.0 NaN False True True M3 code whole correct >2 200 ms, centre 295 897.12 0.75 0.01 488.57 347.84 0.24 0.88 273.26 900.00 0.90 0.0 NaN True True True M3 code whole correct >2 400 ms, end 295 899.70 0.66 0.00 600.00 660.17 0.28 0.58 484.35 900.00 0.99 0.0 NaN False True True M3 code whole correct >3 200 ms, centre 286 897.47 0.75 0.00 267.50 309.12 0.23 0.90 244.92 900.00 0.93 0.0 NaN True True True M3 code whole correct >3 400 ms, end 286 899.70 0.66 0.00 600.00 624.69 0.28 0.62 457.38 900.00 0.99 0.0 NaN False True True code 10 in total best all >2 200 ms, centre 124 896.96 0.71 0.01 520.00 276.37 0.06 0.98 264.94 900.00 0.90 0.0 NaN True True True code 10 in total best all >2 400 ms, end 124 900.00 0.64 0.00 NaN 541.75 0.18 0.91 507.18 900.00 0.95 0.0 NaN False True True code 10 in total best all >3 200 ms, centre 122 894.41 0.71 0.02 527.33 265.79 0.06 0.99 258.74 899.78 0.87 0.0 680.0 True True True code 10 in total best all >3 400 ms, end 122 900.00 0.64 0.00 NaN 533.38 0.17 0.91 498.00 900.00 0.95 0.0 NaN False True True code 10 in total best correct >2 200 ms, centre 136 891.74 0.66 0.02 506.67 308.63 0.04 0.98 299.01 900.00 0.87 0.0 NaN True True True code 10 in total best correct >2 400 ms, end 136 900.00 0.64 0.00 NaN 531.30 0.13 0.92 501.41 900.00 0.91 0.0 NaN False True True code 10 in total best correct >3 200 ms, centre 133 889.75 0.66 0.03 505.77 319.57 0.06 0.98 307.12 900.00 0.85 0.0 NaN True True True code 10 in total best correct >3 400 ms, end 133 900.00 0.62 0.00 NaN 566.25 0.17 0.88 519.87 900.00 0.90 0.0 NaN False True True code 10 in total whole all >2 200 ms, centre 124 889.65 0.72 0.02 429.55 284.17 0.02 1.00 281.70 900.00 0.89 0.0 NaN True True True code 10 in total whole all >2 400 ms, end 124 900.00 0.65 0.00 NaN 522.18 0.13 0.97 512.09 900.00 0.98 0.0 NaN False True True code 10 in total whole all >3 200 ms, centre 122 886.37 0.72 0.03 413.21 269.42 0.01 1.00 268.16 898.93 0.86 0.0 365.0 True True True code 10 in total whole all >3 400 ms, end 122 898.88 0.65 0.00 620.00 510.82 0.12 0.98 500.84 900.00 0.97 0.0 NaN False True True code 10 in total whole correct >2 200 ms, centre 136 889.93 0.71 0.02 480.42 277.93 -0.03 1.00 277.31 899.07 0.85 0.0 435.0 True True True code 10 in total whole correct >2 400 ms, end 136 899.68 0.66 0.00 580.00 484.24 0.07 0.98 474.45 900.00 0.93 0.0 NaN False True True code 10 in total whole correct >3 200 ms, centre 133 890.98 0.71 0.02 490.00 277.29 -0.01 1.00 275.42 899.17 0.83 0.0 70.0 True True True code 10 in total whole correct >3 400 ms, end 133 900.00 0.63 0.00 NaN 501.57 0.11 0.98 492.19 900.00 0.91 0.0 NaN False True True code code best all >2 200 ms, centre 125 893.40 0.64 0.01 300.00 316.34 0.17 0.92 266.28 900.00 0.91 0.0 NaN True True True code code best all >2 400 ms, end 125 900.00 0.61 0.00 NaN 586.82 0.24 0.71 458.28 900.00 1.01 0.0 NaN False True True code code best all >3 200 ms, centre 123 892.58 0.64 0.01 225.45 296.50 0.17 0.93 248.27 900.00 0.90 0.0 NaN True True True code code best all >3 400 ms, end 123 899.50 0.61 0.00 400.00 565.34 0.23 0.75 453.19 900.00 1.01 0.0 NaN False True True code code best correct >2 200 ms, centre 142 894.98 0.63 0.01 398.00 305.97 0.19 0.93 258.50 900.00 0.84 0.0 NaN True True True code code best correct >2 400 ms, end 142 899.73 0.61 0.00 630.00 551.66 0.19 0.81 469.95 900.00 0.94 0.0 NaN False True True code code best correct >3 200 ms, centre 138 889.24 0.63 0.02 469.60 276.94 0.17 0.94 239.98 900.00 0.87 0.0 NaN True True True code code best correct >3 400 ms, end 138 900.00 0.61 0.00 NaN 525.74 0.19 0.82 440.79 900.00 0.95 0.0 NaN True True True code code whole all >2 200 ms, centre 125 898.04 0.67 0.00 246.67 410.11 0.24 0.81 297.43 900.00 0.93 0.0 NaN True True True code code whole all >2 400 ms, end 125 900.00 0.64 0.00 NaN 693.13 0.29 0.45 444.34 900.00 1.02 0.0 NaN False True True code code whole all >3 200 ms, centre 123 900.00 0.68 0.00 NaN 388.72 0.23 0.81 268.79 900.00 0.92 0.0 NaN True True True code code whole all >3 400 ms, end 123 900.00 0.64 0.00 NaN 669.00 0.29 0.50 438.92 900.00 1.02 0.0 NaN True True True code code whole correct >2 200 ms, centre 142 898.95 0.66 0.00 375.00 370.67 0.24 0.85 277.99 900.00 0.86 0.0 NaN True True True code code whole correct >2 400 ms, end 142 900.00 0.64 0.00 NaN 622.82 0.23 0.67 488.14 900.00 0.95 0.0 NaN False True True code code whole correct >3 200 ms, centre 138 898.46 0.66 0.00 515.00 333.78 0.23 0.88 260.20 900.00 0.89 0.0 NaN True True True code code whole correct >3 400 ms, end 138 900.00 0.63 0.00 NaN 596.92 0.24 0.69 461.39 900.00 0.96 0.0 NaN False True True Readings: 64; contralateral within tolerance: 37; ipsilateral not recovering: 64; bilateral not recovering: 64; all three: 37 Ipsilateral: fraction of resamples recovering 0.0 to 0.09 ; deficit 0.2 s before the cue 0.59 to 0.82 Bilateral: fraction of resamples recovering at most 0.002 ; readings with at least one resample recovering: 7 Paper: 129 neurons; contralateral 217 +- 228 ms; ipsilateral and bilateral selectivity do not recover.
def performance_table(exps, conds, by="mouse_pooled"):
"""Fraction correct (hits over hits and errors; lick-early and no-lick trials excluded, as in
the data set's Demo_get_performance.m and the Methods) per mouse and condition, on performing
trials. by = "mouse_pooled": trials pooled over a mouse's sessions (M7 a); "session_mean": the
mean of its session values (M7 b)."""
g = trials[trials.experiment.isin(exps) & trials.good & ~trials.lick_early & (trials.hit | trials.err) & trials.stim.isin([0] + conds)]
if by == "mouse_pooled":
t = g.groupby(["mouse", "stim"]).hit.mean().unstack()
else:
t = g.groupby(["mouse", "session", "stim"]).hit.mean().unstack().groupby("mouse").mean()
n = g.groupby(["mouse", "stim"]).size().unstack()
return t * 100, n
def perf_tests(t, conds, paired=True):
rows = []
for c in conds:
d = t[[0, c]].dropna()
test = stats.ttest_rel(d[c], d[0]) if paired else stats.ttest_ind(t[c].dropna(), t[0].dropna())
rows.append({"condition": c, "label": alm3.STIM_LABELS[c], "mice": len(d), "control_%": d[0].mean(), "photoinhibition_%": d[c].mean(),
"drop": d[0].mean() - d[c].mean(), "t": test.statistic, "p": test.pvalue})
return pd.DataFrame(rows)
fig1d-earlier-photoinhibition-minimal¶
Claim: unilateral photoinhibition ending at least 0.3 s before the go cue (early and middle delay) has minimal behavioural effect (p > 0.1). A claim of absence, judged on the paper's test: per condition, performance with photoinhibition against control, two-tailed t-test across mice, paired (M7 a; unpaired as a variant), at p < 0.05 (criterion). The paper's Fig. 1d comes from behaviour-only sessions, which the data set does not hold; this uses the recording sessions of Experiment 1 (types 1, 2, 3; the sessions with the no-ramp types -1 to -3 are left out, as the data set says not to analyse them). The sample condition is reported as well.
for by in ("mouse_pooled", "session_mean"):
t, n = performance_table(["unilateral"], [1, 2, 3], by=by)
print(f"Performance (% correct) per mouse, {by}:")
print(t.round(1).to_string())
for paired in (True, False):
print(f" {'paired' if paired else 'unpaired'} t-test against control:")
print(perf_tests(t, [2, 3, 1], paired=paired).round(4).to_string(index=False))
print("\nTrials per mouse and condition:")
print(n.to_string())
Performance (% correct) per mouse, mouse_pooled:
stim 0.0 1.0 2.0 3.0
mouse
ANM255200 79.2 78.3 73.8 80.9
ANM255201 85.1 90.9 83.5 81.0
ANM255203 74.2 69.0 60.0 70.8
ANM257772 79.5 82.2 80.6 66.9
paired t-test against control:
condition label mice control_% photoinhibition_% drop t p
2 ipsi 1 spot early delay (0.5 s) 4 79.4999 74.4574 5.0425 -1.5123 0.2277
3 ipsi 1 spot middle delay (0.5 s) 4 79.4999 74.8932 4.6068 -1.5588 0.2169
1 ipsi 1 spot sample (0.5 s) 4 79.4999 80.1359 -0.6360 0.2678 0.8062
unpaired t-test against control:
condition label mice control_% photoinhibition_% drop t p
2 ipsi 1 spot early delay (0.5 s) 4 79.4999 74.4574 5.0425 -0.8886 0.4084
3 ipsi 1 spot middle delay (0.5 s) 4 79.4999 74.8932 4.6068 -1.0973 0.3146
1 ipsi 1 spot sample (0.5 s) 4 79.4999 80.1359 -0.6360 0.1261 0.9038
Performance (% correct) per mouse, session_mean:
stim 0.0 1.0 2.0 3.0
mouse
ANM255200 79.3 78.1 74.3 80.5
ANM255201 84.8 92.0 84.3 80.0
ANM255203 76.1 68.8 59.2 72.6
ANM257772 79.8 82.8 80.7 67.8
paired t-test against control:
condition label mice control_% photoinhibition_% drop t p
2 ipsi 1 spot early delay (0.5 s) 4 80.0006 74.6172 5.3834 -1.3336 0.2745
3 ipsi 1 spot middle delay (0.5 s) 4 80.0006 75.2080 4.7926 -1.7627 0.1762
1 ipsi 1 spot sample (0.5 s) 4 80.0006 80.4400 -0.4393 0.1429 0.8954
unpaired t-test against control:
condition label mice control_% photoinhibition_% drop t p
2 ipsi 1 spot early delay (0.5 s) 4 80.0006 74.6172 5.3834 -0.9242 0.3910
3 ipsi 1 spot middle delay (0.5 s) 4 80.0006 75.2080 4.7926 -1.3458 0.2270
1 ipsi 1 spot sample (0.5 s) 4 80.0006 80.4400 -0.4393 0.0854 0.9347
Trials per mouse and condition:
stim 0.0 1.0 2.0 3.0
mouse
ANM255200 1173 157 168 157
ANM255201 562 132 127 147
ANM255203 357 84 85 89
ANM257772 498 107 108 121
Result: reproduced. In the Experiment 1 recording sessions (4 mice), early delay photoinhibition lowers performance by 5.0 points (paired t-test p = 0.23) and middle delay photoinhibition by 4.6 points (p = 0.22), neither significant at p < 0.05; both p-values are above the paper's 0.1. The other readings give p from 0.18 to 0.41. Sample photoinhibition changes performance by +0.6 points (p = 0.81). With four mice the test has little power.
fig2b-bilateral-behaviour¶
Claim: unilateral photoinhibition in the early delay reduces performance only slightly (1 spot 70.3%, 4 spots 67.7%), bilateral photoinhibition severely (1 spot per side 58.0%) or to near chance (4 spots per side 51.4%). Performance per condition over mice, tests of M7. The paper's values come from 13 mice including behaviour-only sessions; here the recording sessions of the bilateral experiments (types 4, 8, 7, 6), 0.8 s photoinhibition from delay onset.
exps_b = ["exp2", "exp2b", "exp3"]
cmap = {4: 70.3, 8: 67.7, 7: 58.0, 6: 51.4}
for by in ("mouse_pooled", "session_mean"):
t, n = performance_table(exps_b, [4, 8, 7, 6], by=by)
print(f"Performance (% correct) per mouse, {by}:")
print(t.round(1).to_string())
for paired in (True, False):
r = perf_tests(t, [4, 8, 7, 6], paired=paired)
r["paper_%"] = r.condition.map(cmap)
r["within_10%"] = (r["photoinhibition_%"] - r["paper_%"]).abs() <= 0.1 * r["paper_%"]
print(f" {'paired' if paired else 'unpaired'} t-tests against control:")
print(r.round(4).to_string(index=False))
d = t[[7, 8]].dropna()
tt = stats.ttest_rel(d[7], d[8]) if paired else stats.ttest_ind(t[7].dropna(), t[8].dropna())
print(f" bilateral 1 spot against unilateral 4 spots: {d[7].mean():.1f} vs {d[8].mean():.1f} % over {len(d)} mice with both, t = {tt.statistic:.2f}, p = {tt.pvalue:.4f}")
print("\nTrials per mouse and condition:")
print(n.to_string())
Performance (% correct) per mouse, mouse_pooled:
stim 0.0 4.0 6.0 7.0 8.0
mouse
ANM255201 81.2 88.7 72.1 NaN NaN
ANM257636 77.2 77.6 NaN 59.3 71.6
ANM257637 77.8 73.8 55.4 NaN NaN
ANM257772 79.1 65.5 65.5 NaN NaN
ANM258250 73.4 72.2 51.9 NaN NaN
ANM263808 75.3 70.6 53.0 NaN NaN
ANM263810 78.5 63.6 55.6 NaN NaN
ANM264411 76.0 59.2 53.3 NaN NaN
ANM270337 83.7 71.7 NaN 75.8 78.1
ANM273657 77.5 50.0 NaN 62.2 77.0
paired t-tests against control:
condition label mice control_% photoinhibition_% drop t p paper_% within_10%
4 ipsi 1 spot (0.8 s) 10 77.9648 69.2857 8.6791 -2.6980 0.0245 70.3 True
8 ipsi 4 spots (0.8 s) 3 79.4711 75.5860 3.8851 -2.3113 0.1470 67.7 False
7 bilateral 1 spot (0.8 s) 3 79.4711 65.7704 13.7007 -4.5635 0.0448 58.0 False
6 bilateral 4 spots (0.8 s) 7 77.3192 58.1117 19.2074 -9.1335 0.0001 51.4 False
bilateral 1 spot against unilateral 4 spots: 65.8 vs 75.6 % over 3 mice with both, t = -2.57, p = 0.1235
unpaired t-tests against control:
condition label mice control_% photoinhibition_% drop t p paper_% within_10%
4 ipsi 1 spot (0.8 s) 10 77.9648 69.2857 8.6791 -2.5060 0.0220 70.3 True
8 ipsi 4 spots (0.8 s) 3 79.4711 75.5860 3.8851 -1.1922 0.2583 67.7 False
7 bilateral 1 spot (0.8 s) 3 79.4711 65.7704 13.7007 -4.0352 0.0020 58.0 False
6 bilateral 4 spots (0.8 s) 7 77.3192 58.1117 19.2074 -7.5310 0.0000 51.4 False
bilateral 1 spot against unilateral 4 spots: 65.8 vs 75.6 % over 3 mice with both, t = -1.80, p = 0.1469
Performance (% correct) per mouse, session_mean:
stim 0.0 4.0 6.0 7.0 8.0
mouse
ANM255201 81.4 88.0 71.2 NaN NaN
ANM257636 77.2 77.5 NaN 59.4 71.6
ANM257637 77.0 74.4 53.6 NaN NaN
ANM257772 79.1 66.2 67.3 NaN NaN
ANM258250 73.4 72.2 52.9 NaN NaN
ANM263808 75.5 69.7 51.8 NaN NaN
ANM263810 78.5 64.2 56.7 NaN NaN
ANM264411 75.2 57.2 52.5 NaN NaN
ANM270337 84.0 71.7 NaN 75.5 78.1
ANM273657 77.4 50.0 NaN 63.5 77.6
paired t-tests against control:
condition label mice control_% photoinhibition_% drop t p paper_% within_10%
4 ipsi 1 spot (0.8 s) 10 77.8588 69.0990 8.7598 -2.7517 0.0224 70.3 True
8 ipsi 4 spots (0.8 s) 3 79.5076 75.7789 3.7287 -1.9182 0.1951 67.7 False
7 bilateral 1 spot (0.8 s) 3 79.5076 66.1109 13.3967 -4.9672 0.0382 58.0 False
6 bilateral 4 spots (0.8 s) 7 77.1522 57.9839 19.1683 -8.8797 0.0001 51.4 False
bilateral 1 spot against unilateral 4 spots: 66.1 vs 75.8 % over 3 mice with both, t = -2.73, p = 0.1119
unpaired t-tests against control:
condition label mice control_% photoinhibition_% drop t p paper_% within_10%
4 ipsi 1 spot (0.8 s) 10 77.8588 69.0990 8.7598 -2.5136 0.0217 70.3 True
8 ipsi 4 spots (0.8 s) 3 79.5076 75.7789 3.7287 -0.9935 0.3418 67.7 False
7 bilateral 1 spot (0.8 s) 3 79.5076 66.1109 13.3967 -3.9454 0.0023 58.0 False
6 bilateral 4 spots (0.8 s) 7 77.1522 57.9839 19.1683 -7.2670 0.0000 51.4 False
bilateral 1 spot against unilateral 4 spots: 66.1 vs 75.8 % over 3 mice with both, t = -1.84, p = 0.1395
Trials per mouse and condition:
stim 0.0 4.0 6.0 7.0 8.0
mouse
ANM255201 271.0 53.0 61.0 NaN NaN
ANM257636 636.0 85.0 NaN 145.0 74.0
ANM257637 343.0 61.0 112.0 NaN NaN
ANM257772 296.0 58.0 84.0 NaN NaN
ANM258250 433.0 97.0 106.0 NaN NaN
ANM263808 570.0 85.0 183.0 NaN NaN
ANM263810 989.0 143.0 304.0 NaN NaN
ANM264411 379.0 71.0 120.0 NaN NaN
ANM270337 533.0 53.0 NaN 157.0 32.0
ANM273657 503.0 26.0 NaN 127.0 87.0
Result: partially reproduced. In the bilateral recording sessions, performance (pooled per mouse) is 69.3% with unilateral 1-spot photoinhibition (10 mice, within 70.3 +- 7.0), 75.6% with unilateral 4 spots (3 mice, paper 67.7%), 65.8% with bilateral 1 spot (3 mice, paper 58.0%) and 58.1% with bilateral 4 spots (7 mice, paper 51.4%), against control 78.0%. Every condition is below control; the paired tests give p = 0.025, 0.15, 0.045 and 0.0001, and bilateral 1 spot against unilateral 4 spots p = 0.12. The order unilateral above bilateral 1 spot above bilateral 4 spots holds, but three values are outside tolerance and two tests are not significant.
fig5b-callosotomy-behaviour¶
Claim: callosotomy leaves performance unaffected but makes it highly sensitive to unilateral photoinhibition, with a significant interaction, dropping to the level of bilateral photoinhibition in control mice (58.0%). The data set holds only sessions after the cut, so the before-and-after comparison and the interaction cannot be tested; the after-cut test is unilateral photoinhibition (type 10) against control (p < 0.01) and its performance against 58.0 +- 5.8% (criterion).
print("Callosotomy sessions per mouse with dates:", ses[ses.experiment == "ccx"].groupby("mouse").session.apply(lambda x: f"{len(x)}: {x.str[-8:].min()} to {x.str[-8:].max()}").to_dict())
for by in ("mouse_pooled", "session_mean"):
t, n = performance_table(["ccx"], [10, 11, 12], by=by)
print(f"\nPerformance (% correct) per mouse, {by}:")
print(t.round(1).to_string())
for paired in (True, False):
print(f" {'paired' if paired else 'unpaired'} t-tests against control:")
print(perf_tests(t, [10, 11, 12], paired=paired).round(4).to_string(index=False))
tc, _ = performance_table(exps_b, [4], by="mouse_pooled")
t5, _ = performance_table(["ccx"], [10], by="mouse_pooled")
print(f"\nControl-trial performance, control mice (bilateral experiments) {tc[0].mean():.1f}% over {tc[0].notna().sum()} mice; callosotomy mice {t5[0].mean():.1f}% over {t5[0].notna().sum()} mice; "
f"unpaired t-test p = {stats.ttest_ind(tc[0].dropna(), t5[0].dropna()).pvalue:.3f} (different mice; not the paper's before/after test)")
print(f"Ipsilateral 1 spot: control mice {tc[4].mean():.1f}%, callosotomy mice {t5[10].mean():.1f}%")
Callosotomy sessions per mouse with dates: {'ANM270340': '5: 20150618 to 20150623', 'ANM278733': '6: 20150528 to 20150603', 'ANM291063': '4: 20150902 to 20150907', 'ANM291064': '4: 20150906 to 20150909', 'ANM297634': '5: 20150907 to 20150911', 'ANM298738': '5: 20150724 to 20150729', 'ANM298740': '4: 20150723 to 20150729'}
Performance (% correct) per mouse, mouse_pooled:
stim 0.0 10.0 11.0 12.0
mouse
ANM270340 70.9 69.5 62.9 48.8
ANM278733 76.8 67.1 74.0 57.9
ANM291063 74.3 59.8 67.0 54.6
ANM291064 70.0 46.5 62.5 49.3
ANM297634 71.0 47.4 49.6 44.2
ANM298738 80.9 56.8 64.8 50.8
ANM298740 78.3 66.7 68.8 54.7
paired t-tests against control:
condition label mice control_% photoinhibition_% drop t p
10 CCX ipsi 1 spot (0.8 s) 7 74.5779 59.1038 15.4741 -4.7084 0.0033
11 CCX contra 1 spot (0.8 s) 7 74.5779 64.2254 10.3526 -4.3732 0.0047
12 CCX bilateral 4 spots (0.8 s) 7 74.5779 51.4775 23.1004 -15.0276 0.0000
unpaired t-tests against control:
condition label mice control_% photoinhibition_% drop t p
10 CCX ipsi 1 spot (0.8 s) 7 74.5779 59.1038 15.4741 -3.9667 0.0019
11 CCX contra 1 spot (0.8 s) 7 74.5779 64.2254 10.3526 -3.1705 0.0081
12 CCX bilateral 4 spots (0.8 s) 7 74.5779 51.4775 23.1004 -9.7941 0.0000
Performance (% correct) per mouse, session_mean:
stim 0.0 10.0 11.0 12.0
mouse
ANM270340 69.3 69.9 61.8 53.0
ANM278733 76.1 67.1 72.6 57.2
ANM291063 74.2 60.8 66.1 55.1
ANM291064 68.8 38.7 57.9 45.7
ANM297634 71.2 46.8 49.9 42.9
ANM298738 80.0 56.9 62.2 49.8
ANM298740 77.5 65.4 67.5 56.0
paired t-tests against control:
condition label mice control_% photoinhibition_% drop t p
10 CCX ipsi 1 spot (0.8 s) 7 73.8748 57.9340 15.9408 -4.0071 0.0071
11 CCX contra 1 spot (0.8 s) 7 73.8748 62.5748 11.3000 -4.8249 0.0029
12 CCX bilateral 4 spots (0.8 s) 7 73.8748 51.3969 22.4779 -11.6071 0.0000
unpaired t-tests against control:
condition label mice control_% photoinhibition_% drop t p
10 CCX ipsi 1 spot (0.8 s) 7 73.8748 57.9340 15.9408 -3.4595 0.0047
11 CCX contra 1 spot (0.8 s) 7 73.8748 62.5748 11.3000 -3.5344 0.0041
12 CCX bilateral 4 spots (0.8 s) 7 73.8748 51.3969 22.4779 -8.5889 0.0000
Control-trial performance, control mice (bilateral experiments) 78.0% over 10 mice; callosotomy mice 74.6% over 7 mice; unpaired t-test p = 0.068 (different mice; not the paper's before/after test)
Ipsilateral 1 spot: control mice 69.3%, callosotomy mice 59.1%
Result: partially reproduced. The data set holds only sessions after the cut, so the before-and-after comparison and the interaction cannot be tested. After the cut, unilateral (ipsilateral 1 spot) photoinhibition lowers performance from 74.6% to 59.1% (7 mice, paired p = 0.0033), and 59.1% is within 58.0 +- 5.8%.
# Population analyses (Methods, Analysis of population dynamics in the activity space; code,
# analysis_compile_all_data_bilateral_activityModes.m).
def tidx(t):
return int(np.argmin(np.abs(alm3.POP_T - t)))
I_LATE = tidx(-0.4) # window [-0.4, 0]: last 400 ms of the delay
def cd_windows(reading):
"""Windows (by start time) counted as in the sample and delay epochs (-3.0 to 0 s from the
cue, 1.3 s sample and 1.7 s delay): (b) wholly inside, as the code (start > -3, <= -0.4);
(a) centre inside."""
if reading == "inside":
return np.flatnonzero((alm3.POP_T > -3.0 - 1e-9) & (alm3.POP_T <= -0.4 + 1e-9))
return np.flatnonzero((alm3.POP_T + 0.2 >= -3.0 - 1e-9) & (alm3.POP_T + 0.2 <= 0 + 1e-9))
def cd_vector(P, train_R, train_L, kind, win_reading):
X = P["X"]
win = cd_windows(win_reading)
if kind == "meandiff":
w = (X[train_R][:, :, win].mean(0) - X[train_L][:, :, win].mean(0)).mean(1)
else: # the code's LDA per window, averaged
w = np.mean([alm3.lda_direction(X[train_R][:, :, i], X[train_L][:, :, i]) for i in win[::5]], axis=0)
return w / np.linalg.norm(w)
def cd_projections(P, kind="meandiff", win_reading="inside", w=None):
"""Projection of every trial on cd at every window, minus the decision boundary in the last
400 ms of the delay, from correct training trials."""
hit = P["hit"]
tR = P["train"][1][hit[P["train"][1]]]
tL = P["train"][-1][hit[P["train"][-1]]]
if w is None:
w = cd_vector(P, tR, tL, kind, win_reading)
proj = np.einsum("tnw,n->tw", P["X"], w)
b = alm3.boundary(proj[tR, I_LATE], proj[tL, I_LATE])
return proj - b, w, (tR, tL)
def cd_projections_loo(P, win_reading="inside"):
"""Leave-one-out projections (M6 reading b): each control trial is projected on a cd and a
boundary computed without it; photoinhibition trials on the cd of all correct control trials."""
X = P["X"]
hit = P["hit"]
win = cd_windows(win_reading)
tR = P["train"][1][hit[P["train"][1]]]
tL = P["train"][-1][hit[P["train"][-1]]]
proj, w, _ = cd_projections(P, "meandiff", win_reading)
mR = X[tR][:, :, win].mean(axis=(0, 2)) * len(tR)
mL = X[tL][:, :, win].mean(axis=(0, 2)) * len(tL)
xi_win = X[:, :, win].mean(2)
for i in np.r_[P["test"][1], P["test"][-1]]:
r_, l_ = tR, tL
sR, sL = mR, mL
if i in set(tR):
r_ = tR[tR != i]
sR = mR - xi_win[i]
elif i in set(tL):
l_ = tL[tL != i]
sL = mL - xi_win[i]
wi = sR / len(r_) - sL / len(l_)
wi /= np.linalg.norm(wi)
b = alm3.boundary(X[r_][:, :, I_LATE] @ wi, X[l_][:, :, I_LATE] @ wi)
proj[i] = X[i].T @ wi - b
return proj
def session_rocs(P, proj, conds, t_index=I_LATE, average=None):
out = {}
def val(idx):
return proj[idx][:, average].mean(1) if average is not None else proj[idx, t_index]
out[0] = alm3.auc(val(P["test"][1]), val(P["test"][-1]))
for c in conds:
out[c] = alm3.auc(val(P["groups"][(c, 1)]), val(P["groups"][(c, -1)]))
return out
def build_population(exp, conds, cell_types=("pyramidal",), split="code", seed=7, min_group=5):
pops = []
for i, name in enumerate(ses[ses.experiment == exp].session):
su = [u for u in units if u["session"] == name]
if not su:
continue
P = alm3.population_session(SD[name], su, conds, cell_types=cell_types, seed=seed + i, split=split, min_group=min_group)
if P is not None:
pops.append(P)
return pops
POP = {}
for exp, conds in (("exp2", [4, 5, 6]), ("exp3", [7, 8, 9]), ("exp2b", [4, 5, 7]), ("ccx", [10, 11, 12])):
for cells in ("pyramidal", "all"):
for split in ("code", "half", "loo"):
ct = ("pyramidal",) if cells == "pyramidal" else ("pyramidal", "FS", "none")
POP[(exp, cells, split)] = build_population(exp, conds, ct, split)
for k, v in POP.items():
print(k, "sessions", len(v), "mice", len({p["mouse"] for p in v}), "neurons", sum(p["n_neurons"] for p in v))
# Reading of M6 with more than 5 trials in every group (the Methods' "> 5 trials per condition");
# the code keeps groups of 5.
POP6 = {exp: build_population(exp, conds, min_group=6) for exp, conds in (("exp2", [4, 5, 6]), ("ccx", [10, 11, 12]))}
for exp, v in POP6.items():
print(f"{exp}, pyramidal, code split, more than 5 trials per group: sessions {len(v)}, mice {len({p['mouse'] for p in v})}")
('exp2', 'pyramidal', 'code') sessions 16 mice 7 neurons 175
('exp2', 'pyramidal', 'half') sessions 16 mice 7 neurons 175
('exp2', 'pyramidal', 'loo') sessions 16 mice 7 neurons 175
('exp2', 'all', 'code') sessions 17 mice 7 neurons 211
('exp2', 'all', 'half') sessions 17 mice 7 neurons 211
('exp2', 'all', 'loo') sessions 17 mice 7 neurons 211
('exp3', 'pyramidal', 'code') sessions 4 mice 3 neurons 48
('exp3', 'pyramidal', 'half') sessions 4 mice 3 neurons 48
('exp3', 'pyramidal', 'loo') sessions 4 mice 3 neurons 48
('exp3', 'all', 'code') sessions 5 mice 3 neurons 58
('exp3', 'all', 'half') sessions 5 mice 3 neurons 58
('exp3', 'all', 'loo') sessions 5 mice 3 neurons 58
('exp2b', 'pyramidal', 'code') sessions 5 mice 3 neurons 47
('exp2b', 'pyramidal', 'half') sessions 5 mice 3 neurons 47
('exp2b', 'pyramidal', 'loo') sessions 5 mice 3 neurons 47
('exp2b', 'all', 'code') sessions 6 mice 3 neurons 57
('exp2b', 'all', 'half') sessions 6 mice 3 neurons 57
('exp2b', 'all', 'loo') sessions 6 mice 3 neurons 57
('ccx', 'pyramidal', 'code') sessions 16 mice 7 neurons 259
('ccx', 'pyramidal', 'half') sessions 16 mice 7 neurons 259
('ccx', 'pyramidal', 'loo') sessions 16 mice 7 neurons 259
('ccx', 'all', 'code') sessions 17 mice 7 neurons 290
('ccx', 'all', 'half') sessions 17 mice 7 neurons 290
('ccx', 'all', 'loo') sessions 17 mice 7 neurons 290
exp2, pyramidal, code split, more than 5 trials per group: sessions 12, mice 6 ccx, pyramidal, code split, more than 5 trials per group: sessions 13, mice 6
fig3-cd-roc¶
Claim: along the coding direction, trajectories recover after ipsilateral photoinhibition (ROC at the end of the delay 0.73 +- 0.02 against control 0.76 +- 0.03), are little affected by contralateral photoinhibition (0.74 +- 0.03) and stay collapsed after bilateral photoinhibition (0.58 +- 0.03); 16 sessions. Readings run: neurons pyramidal only (code) or all units; split of control trials as the code or random halves (M6 a); cd as the mean difference of the Methods with windows wholly inside (code) or centred in the sample and delay, and the code's LDA as a variant. ROC: area under the ROC curve of lick right against lick left projections in the last 400 ms of the delay, control test trials and each photoinhibition condition, per session, mean +- s.e.m. over sessions.
def roc_table(exp, conds, kinds=(("meandiff", "inside"), ("meandiff", "centre"), ("lda", "inside")), **kw):
rows = []
for (e, cells, split), pops in POP.items():
if e != exp:
continue
for kind, wr in kinds:
if split == "loo" and kind != "meandiff":
continue
R = []
for P in pops:
proj = cd_projections_loo(P, wr) if split == "loo" else cd_projections(P, kind, wr)[0]
R.append(session_rocs(P, proj, conds, **kw))
R = pd.DataFrame(R)
r = {"cells": cells, "split": split, "cd": f"{kind}/{wr}", "sessions": len(R)}
for c in [0] + conds:
r[f"roc_{c}"] = R[c].mean()
r[f"sem_{c}"] = R[c].std(ddof=1) / np.sqrt(len(R))
rows.append(r)
return pd.DataFrame(rows)
rt3 = roc_table("exp2", [4, 5, 6])
exp3v = {0: (0.76, 0.03), 4: (0.73, 0.02), 5: (0.74, 0.03), 6: (0.58, 0.03)}
rt3["all_within"] = np.all([(rt3[f"roc_{c}"] - v).abs() <= tol for c, (v, tol) in exp3v.items()], axis=0)
rt3["order"] = (rt3[["roc_0", "roc_4", "roc_5"]].min(1) - rt3["roc_6"]) > 0.1
print(rt3.round(3).to_string(index=False))
print("Paper: 16 sessions; control 0.76 +- 0.03, ipsilateral 0.73 +- 0.02, contralateral 0.74 +- 0.03, bilateral 0.58 +- 0.03.")
P0 = POP[("exp2", "pyramidal", "code")]
print("\nSessions (code selection, pyramidal):", [(p["session"], p["n_neurons"]) for p in P0])
R = pd.DataFrame([session_rocs(P, cd_projections(P)[0], [4, 5, 6]) for P in P0])
R["mouse"] = [p["mouse"] for p in P0]
print("Per mouse (mean over sessions), mean-difference cd, code split:")
print(R.groupby("mouse").mean().round(3).to_string())
R6 = pd.DataFrame([session_rocs(P, cd_projections(P)[0], [4, 5, 6]) for P in POP6["exp2"]])
print(f"\nReading with more than 5 trials per group ({len(R6)} sessions), mean-difference cd, code split, pyramidal: "
+ ", ".join(f"{c}: {R6[c].mean():.3f}" for c in [0, 4, 5, 6]))
cells split cd sessions roc_0 sem_0 roc_4 sem_4 roc_5 sem_5 roc_6 sem_6 all_within order
pyramidal code meandiff/inside 16 0.719 0.033 0.706 0.024 0.738 0.033 0.595 0.036 False True
pyramidal code meandiff/centre 16 0.723 0.035 0.710 0.023 0.744 0.032 0.597 0.036 False True
pyramidal code lda/inside 16 0.721 0.030 0.710 0.024 0.745 0.033 0.584 0.035 False True
pyramidal half meandiff/inside 16 0.716 0.030 0.702 0.030 0.684 0.039 0.596 0.036 False False
pyramidal half meandiff/centre 16 0.721 0.030 0.705 0.029 0.683 0.039 0.596 0.037 False False
pyramidal half lda/inside 16 0.718 0.030 0.705 0.032 0.683 0.039 0.595 0.037 False False
pyramidal loo meandiff/inside 16 0.731 0.025 0.713 0.023 0.742 0.033 0.592 0.033 True True
pyramidal loo meandiff/centre 16 0.733 0.025 0.712 0.022 0.749 0.032 0.593 0.034 True True
all code meandiff/inside 17 0.740 0.028 0.672 0.027 0.745 0.035 0.587 0.026 False False
all code meandiff/centre 17 0.746 0.029 0.671 0.028 0.754 0.035 0.587 0.026 False False
all code lda/inside 17 0.735 0.028 0.678 0.024 0.742 0.037 0.574 0.025 False True
all half meandiff/inside 17 0.731 0.027 0.667 0.034 0.703 0.039 0.587 0.027 False False
all half meandiff/centre 17 0.729 0.028 0.668 0.035 0.707 0.037 0.588 0.027 False False
all half lda/inside 17 0.723 0.026 0.681 0.033 0.702 0.042 0.578 0.026 False True
all loo meandiff/inside 17 0.743 0.023 0.675 0.025 0.744 0.037 0.585 0.026 False False
all loo meandiff/centre 17 0.745 0.023 0.673 0.027 0.752 0.035 0.586 0.026 False False
Paper: 16 sessions; control 0.76 +- 0.03, ipsilateral 0.73 +- 0.02, contralateral 0.74 +- 0.03, bilateral 0.58 +- 0.03.
Sessions (code selection, pyramidal): [('ANM255201_20141121', 13), ('ANM255201_20141123', 16), ('ANM257637_20141222', 16), ('ANM257637_20141223', 13), ('ANM257772_20141121', 20), ('ANM257772_20141123', 6), ('ANM258250_20141201', 10), ('ANM258250_20141203', 9), ('ANM258250_20141205', 6), ('ANM263808_20150124', 12), ('ANM263810_20150122', 9), ('ANM263810_20150123', 9), ('ANM263810_20150125', 9), ('ANM263810_20150126', 7), ('ANM264411_20141222', 6), ('ANM264411_20141224', 14)]
Per mouse (mean over sessions), mean-difference cd, code split:
0 4 5 6
mouse
ANM255201 0.727 0.811 0.616 0.629
ANM257637 0.532 0.756 0.860 0.650
ANM257772 0.710 0.706 0.697 0.663
ANM258250 0.831 0.659 0.826 0.526
ANM263808 0.851 0.700 0.679 0.719
ANM263810 0.693 0.667 0.719 0.580
ANM264411 0.723 0.705 0.714 0.511
Reading with more than 5 trials per group (12 sessions), mean-difference cd, code split, pyramidal: 0: 0.681, 4: 0.692, 5: 0.723, 6: 0.554
/tmp/ipykernel_2300/1221663667.py:24: Pandas4Warning: Starting with pandas version 4.0 all arguments of min will be keyword-only. rt3["order"] = (rt3[["roc_0", "roc_4", "roc_5"]].min(1) - rt3["roc_6"]) > 0.1
Result: reproduced. The session rule gives the paper's 16 sessions from 7 mice. With the leave-one-out split of control trials (M6 reading b), the mean-difference cd and pyramidal neurons, the end-of-delay ROC is 0.731 +- 0.025 (control), 0.713 +- 0.023 (ipsilateral), 0.742 +- 0.033 (contralateral) and 0.592 +- 0.033 (bilateral), all within the paper's 0.76 +- 0.03, 0.73 +- 0.02, 0.74 +- 0.03 and 0.58 +- 0.03; windows centred in the epochs give the same. With the code's split the control and ipsilateral values fall just below tolerance (0.719 and 0.706), and with random halves the contralateral value is 0.684; with all units the ipsilateral value is 0.667 to 0.681 in every split. With more than 5 trials in every group (the Methods' wording; the code keeps groups of 5), 12 sessions remain and the control ROC is 0.681, outside tolerance; the result rests on the code's session rule, which gives the paper's 16 sessions.
ed8-roc-during-photoinhibition¶
Claim: during photoinhibition the cd separation falls (ROC 0.54 +- 0.03 ipsilateral, 0.64 +- 0.03 contralateral, 0.54 +- 0.01 bilateral, against control 0.72 +- 0.02). Window (a) the 400 ms window ending at the start of the offset ramp (1.5 to 1.1 s before the cue), (b) the projection averaged over the windows inside the 0.8 s photoinhibition (criterion). Other readings as fig3-cd-roc.
exp8 = {0: (0.72, 0.02), 4: (0.54, 0.03), 5: (0.64, 0.03), 6: (0.54, 0.01)}
during_avg = np.flatnonzero((alm3.POP_T >= -1.7 - 1e-9) & (alm3.POP_T <= -1.3 + 1e-9))
tabs = []
for lab, kw in (("(a) 400 ms ending at ramp start", {"t_index": tidx(-1.5)}), ("(b) average over photoinhibition", {"average": during_avg})):
t = roc_table("exp2", [4, 5, 6], **kw)
t.insert(0, "window", lab)
tabs.append(t)
rt8 = pd.concat(tabs, ignore_index=True)
rt8["all_within"] = np.all([(rt8[f"roc_{c}"] - v).abs() <= tol for c, (v, tol) in exp8.items()], axis=0)
print(rt8.round(3).to_string(index=False))
print("Paper: control 0.72 +- 0.02, ipsilateral 0.54 +- 0.03, contralateral 0.64 +- 0.03, bilateral 0.54 +- 0.01.")
window cells split cd sessions roc_0 sem_0 roc_4 sem_4 roc_5 sem_5 roc_6 sem_6 all_within (a) 400 ms ending at ramp start pyramidal code meandiff/inside 16 0.705 0.036 0.519 0.035 0.637 0.031 0.475 0.019 False (a) 400 ms ending at ramp start pyramidal code meandiff/centre 16 0.710 0.037 0.523 0.037 0.637 0.031 0.473 0.019 False (a) 400 ms ending at ramp start pyramidal code lda/inside 16 0.710 0.036 0.490 0.037 0.630 0.032 0.496 0.018 False (a) 400 ms ending at ramp start pyramidal half meandiff/inside 16 0.709 0.024 0.525 0.035 0.619 0.038 0.489 0.018 False (a) 400 ms ending at ramp start pyramidal half meandiff/centre 16 0.712 0.024 0.523 0.034 0.622 0.038 0.486 0.018 False (a) 400 ms ending at ramp start pyramidal half lda/inside 16 0.713 0.025 0.490 0.034 0.617 0.041 0.488 0.020 False (a) 400 ms ending at ramp start pyramidal loo meandiff/inside 16 0.686 0.021 0.520 0.035 0.620 0.030 0.483 0.017 False (a) 400 ms ending at ramp start pyramidal loo meandiff/centre 16 0.688 0.022 0.527 0.036 0.624 0.030 0.478 0.017 False (a) 400 ms ending at ramp start all code meandiff/inside 17 0.692 0.036 0.521 0.044 0.631 0.035 0.505 0.024 False (a) 400 ms ending at ramp start all code meandiff/centre 17 0.694 0.036 0.518 0.045 0.627 0.035 0.506 0.024 False (a) 400 ms ending at ramp start all code lda/inside 17 0.692 0.035 0.529 0.044 0.631 0.039 0.526 0.023 False (a) 400 ms ending at ramp start all half meandiff/inside 17 0.702 0.023 0.522 0.042 0.608 0.039 0.508 0.025 False (a) 400 ms ending at ramp start all half meandiff/centre 17 0.707 0.023 0.510 0.045 0.608 0.038 0.505 0.026 False (a) 400 ms ending at ramp start all half lda/inside 17 0.708 0.021 0.534 0.044 0.605 0.042 0.514 0.025 False (a) 400 ms ending at ramp start all loo meandiff/inside 17 0.684 0.022 0.544 0.044 0.625 0.034 0.498 0.027 False (a) 400 ms ending at ramp start all loo meandiff/centre 17 0.685 0.022 0.526 0.044 0.630 0.034 0.509 0.024 False (b) average over photoinhibition pyramidal code meandiff/inside 16 0.714 0.036 0.590 0.041 0.631 0.031 0.509 0.019 False (b) average over photoinhibition pyramidal code meandiff/centre 16 0.718 0.036 0.583 0.040 0.632 0.031 0.508 0.017 False (b) average over photoinhibition pyramidal code lda/inside 16 0.717 0.035 0.561 0.038 0.630 0.031 0.526 0.020 False (b) average over photoinhibition pyramidal half meandiff/inside 16 0.714 0.025 0.595 0.041 0.617 0.039 0.515 0.023 False (b) average over photoinhibition pyramidal half meandiff/centre 16 0.717 0.025 0.589 0.041 0.613 0.037 0.515 0.023 False (b) average over photoinhibition pyramidal half lda/inside 16 0.719 0.027 0.561 0.035 0.614 0.041 0.515 0.023 False (b) average over photoinhibition pyramidal loo meandiff/inside 16 0.694 0.022 0.596 0.041 0.618 0.030 0.510 0.019 False (b) average over photoinhibition pyramidal loo meandiff/centre 16 0.695 0.023 0.595 0.041 0.619 0.030 0.506 0.018 False (b) average over photoinhibition all code meandiff/inside 17 0.703 0.038 0.534 0.043 0.642 0.036 0.539 0.023 True (b) average over photoinhibition all code meandiff/centre 17 0.702 0.038 0.534 0.044 0.640 0.036 0.537 0.023 True (b) average over photoinhibition all code lda/inside 17 0.707 0.037 0.541 0.043 0.636 0.037 0.546 0.022 True (b) average over photoinhibition all half meandiff/inside 17 0.712 0.023 0.548 0.046 0.608 0.041 0.528 0.027 False (b) average over photoinhibition all half meandiff/centre 17 0.715 0.023 0.531 0.047 0.610 0.040 0.529 0.028 False (b) average over photoinhibition all half lda/inside 17 0.717 0.021 0.546 0.046 0.606 0.042 0.539 0.025 False (b) average over photoinhibition all loo meandiff/inside 17 0.693 0.023 0.564 0.039 0.633 0.035 0.520 0.026 False (b) average over photoinhibition all loo meandiff/centre 17 0.693 0.023 0.541 0.041 0.632 0.035 0.535 0.023 False Paper: control 0.72 +- 0.02, ipsilateral 0.54 +- 0.03, contralateral 0.64 +- 0.03, bilateral 0.54 +- 0.01.
Result: reproduced. With projections averaged over the photoinhibition period (reading b), all units and the code's split, the ROC is 0.703 (control), 0.534 (ipsilateral), 0.642 (contralateral) and 0.539 (bilateral), all within the paper's 0.72 +- 0.02, 0.54 +- 0.03, 0.64 +- 0.03 and 0.54 +- 0.01; three of the 32 readings match. With pyramidal neurons only the bilateral value is 0.51 and outside its narrow tolerance. With window (a) the ipsilateral values are 0.490 to 0.544 and the bilateral values 0.473 to 0.526, and no reading matches.
ed7e-size-and-roc¶
Claim: recovery of selectivity after unilateral photoinhibition is less robust with larger photoinhibition, and cd trajectories separate at the end of the delay with ROC 0.80 +- 0.08 (control), 0.64 +- 0.10 (ipsilateral 4 spots), 0.68 +- 0.15 (contralateral 4 spots) and 0.54 (bilateral 1 spot; tolerance 0.054, 0.08 as a variant). Experiment 3 sessions with > 5 neurons and enough trials (the session rule of fig3-cd-roc); "less robust" judged by the ipsilateral 4-spot ROC below the Experiment 2 ipsilateral 1-spot ROC.
rt7 = roc_table("exp3", [7, 8, 9])
exp7 = {0: (0.80, 0.08), 8: (0.64, 0.10), 9: (0.68, 0.15), 7: (0.54, 0.054)}
rt7["all_within"] = np.all([(rt7[f"roc_{c}"] - v).abs() <= tol for c, (v, tol) in exp7.items()], axis=0)
rt7["all_within_bilat_tol_0.08"] = np.all([(rt7[f"roc_{c}"] - v).abs() <= (0.08 if c == 7 else tol) for c, (v, tol) in exp7.items()], axis=0)
print(rt7.round(3).to_string(index=False))
m = rt3.set_index(["cells", "split", "cd"])["roc_4"]
rt7["exp2_ipsi_1spot"] = [m.get((r.cells, r.split, r.cd)) for r in rt7.itertuples()]
print("\nIpsilateral 4 spots (Experiment 3) against ipsilateral 1 spot (Experiment 2):")
print(rt7[["cells", "split", "cd", "roc_8", "exp2_ipsi_1spot"]].round(3).to_string(index=False))
print("Sessions (code selection, pyramidal):", [(p["session"], p["n_neurons"], p["counts"]) for p in POP[("exp3", "pyramidal", "code")]])
print("Experiment 3 sessions in the data set:", ses[ses.experiment == "exp3"].session.tolist())
# Variant for the question to a reader (ED Fig. 2b gives n = 102 for Experiment 3 bilateral 1 spot): the bilateral 1-spot
# sessions with types 4, 5, 7 pooled with Experiment 3 for the bilateral ROC.
rows = []
for cells in ("pyramidal", "all"):
for split in ("code", "half", "loo"):
vals = []
for exp, conds in (("exp3", [7, 8, 9]), ("exp2b", [4, 5, 7])):
for P in POP[(exp, cells, split)]:
proj = cd_projections_loo(P) if split == "loo" else cd_projections(P)[0]
vals.append(session_rocs(P, proj, conds)[7])
rows.append({"cells": cells, "split": split, "sessions": len(vals), "roc_7_pooled": np.mean(vals), "within_0.054": abs(np.mean(vals) - 0.54) <= 0.054})
print("\nBilateral 1 spot, Experiment 3 and the sessions with types 4, 5, 7 pooled (mean-difference cd):")
print(pd.DataFrame(rows).round(3).to_string(index=False))
cells split cd sessions roc_0 sem_0 roc_7 sem_7 roc_8 sem_8 roc_9 sem_9 all_within all_within_bilat_tol_0.08
pyramidal code meandiff/inside 4 0.762 0.142 0.604 0.071 0.621 0.096 0.702 0.055 False True
pyramidal code meandiff/centre 4 0.762 0.142 0.634 0.044 0.652 0.066 0.703 0.055 False False
pyramidal code lda/inside 4 0.765 0.141 0.601 0.070 0.624 0.097 0.705 0.054 False True
pyramidal half meandiff/inside 4 0.754 0.112 0.600 0.072 0.624 0.092 0.697 0.066 False True
pyramidal half meandiff/centre 4 0.754 0.111 0.598 0.071 0.620 0.091 0.698 0.066 False True
pyramidal half lda/inside 4 0.762 0.107 0.622 0.043 0.654 0.062 0.688 0.062 False False
pyramidal loo meandiff/inside 4 0.736 0.085 0.606 0.072 0.626 0.097 0.709 0.051 False True
pyramidal loo meandiff/centre 4 0.738 0.085 0.608 0.072 0.624 0.096 0.709 0.052 False True
all code meandiff/inside 5 0.723 0.114 0.620 0.057 0.586 0.084 0.665 0.063 False False
all code meandiff/centre 5 0.722 0.113 0.642 0.035 0.611 0.069 0.678 0.056 False False
all code lda/inside 5 0.732 0.112 0.618 0.056 0.589 0.083 0.672 0.060 False True
all half meandiff/inside 5 0.713 0.096 0.609 0.057 0.594 0.079 0.649 0.072 False False
all half meandiff/centre 5 0.713 0.095 0.606 0.056 0.592 0.078 0.650 0.074 False False
all half lda/inside 5 0.722 0.092 0.628 0.035 0.613 0.064 0.648 0.071 False False
all loo meandiff/inside 5 0.690 0.081 0.606 0.056 0.625 0.075 0.701 0.049 False False
all loo meandiff/centre 5 0.692 0.081 0.606 0.056 0.623 0.075 0.704 0.050 False False
Ipsilateral 4 spots (Experiment 3) against ipsilateral 1 spot (Experiment 2):
cells split cd roc_8 exp2_ipsi_1spot
pyramidal code meandiff/inside 0.621 0.706
pyramidal code meandiff/centre 0.652 0.710
pyramidal code lda/inside 0.624 0.710
pyramidal half meandiff/inside 0.624 0.702
pyramidal half meandiff/centre 0.620 0.705
pyramidal half lda/inside 0.654 0.705
pyramidal loo meandiff/inside 0.626 0.713
pyramidal loo meandiff/centre 0.624 0.712
all code meandiff/inside 0.586 0.672
all code meandiff/centre 0.611 0.671
all code lda/inside 0.589 0.678
all half meandiff/inside 0.594 0.667
all half meandiff/centre 0.592 0.668
all half lda/inside 0.613 0.681
all loo meandiff/inside 0.625 0.675
all loo meandiff/centre 0.623 0.673
Sessions (code selection, pyramidal): [('ANM257636_20150331', 6, [58, 71, 16, 16, 16, 12, 17, 19, 20, 11]), ('ANM270337_20150306', 18, [41, 71, 18, 18, 19, 22, 14, 15, 10, 27]), ('ANM273657_20150321', 9, [55, 29, 13, 13, 14, 16, 14, 11, 14, 8]), ('ANM273657_20150322', 15, [53, 44, 13, 13, 14, 13, 13, 17, 10, 12])]
Experiment 3 sessions in the data set: ['ANM257636_20150331', 'ANM257636_20150403', 'ANM270337_20150306', 'ANM273657_20150321', 'ANM273657_20150322', 'ANM273657_20150323']
Bilateral 1 spot, Experiment 3 and the sessions with types 4, 5, 7 pooled (mean-difference cd):
cells split sessions roc_7_pooled within_0.054
pyramidal code 9 0.585 True
pyramidal half 9 0.600 False
pyramidal loo 9 0.570 True
all code 11 0.593 True
all half 11 0.602 False
all loo 11 0.571 True
Result: not reproduced. Four of the six Experiment 3 sessions pass the session rule. With the mean-difference cd and pyramidal neurons, the ROC is 0.762 (control), 0.621 (ipsilateral 4 spots) and 0.702 (contralateral 4 spots), within tolerance, and 0.604 for bilateral 1 spot, outside 0.54 +- 0.054; no reading puts the bilateral value within 0.054 (0.598 to 0.642), and it is within only the 0.08 variant. The ipsilateral 4-spot ROC is below the Experiment 2 ipsilateral 1-spot ROC (0.621 against 0.706), so recovery is less robust with the larger photoinhibition. With the bilateral 1-spot sessions holding types 4, 5 and 7 pooled (9 sessions), the bilateral ROC is 0.570 to 0.602, within 0.054 in 4 of 6 readings; whether the paper pooled them is asked of a reader.
ed9b-cd-stability¶
Claim: the direction of the lick right minus lick left response difference is stable through the sample and delay epochs (correlation between late sample and late delay 0.61 +- 0.05). Per session of fig3-cd-roc, Pearson correlation of w in the last 400 ms of the sample epoch (1.7 to 2.1 s before the cue) and in the last 400 ms of the delay, correct control trials (criterion); all correct control trials (a reading) or the correct training trials (as for cd).
rows = []
for (e, cells, split), pops in POP.items():
if e != "exp2" or split != "code":
continue
for trial_set in ("all correct control", "correct training"):
rr = []
for P in pops:
hit = P["hit"]
if trial_set == "all correct control":
R_ = np.r_[P["train"][1], P["test"][1]]
L_ = np.r_[P["train"][-1], P["test"][-1]]
else:
R_, L_ = P["train"][1], P["train"][-1]
R_, L_ = R_[hit[R_]], L_[hit[L_]]
X = P["X"]
w1 = X[R_][:, :, tidx(-2.1)].mean(0) - X[L_][:, :, tidx(-2.1)].mean(0)
w2 = X[R_][:, :, I_LATE].mean(0) - X[L_][:, :, I_LATE].mean(0)
rr.append(np.corrcoef(w1, w2)[0, 1])
rr = np.array(rr)
rows.append({"cells": cells, "trials": trial_set, "sessions": len(rr), "mean_r": np.nanmean(rr), "sem": np.nanstd(rr, ddof=1) / np.sqrt(np.isfinite(rr).sum()),
"within_0.61+-0.05": abs(np.nanmean(rr) - 0.61) <= 0.05})
print(pd.DataFrame(rows).round(3).to_string(index=False))
print("Paper: 0.61 +- 0.05.")
cells trials sessions mean_r sem within_0.61+-0.05
pyramidal all correct control 16 0.590 0.075 True
pyramidal correct training 16 0.520 0.081 False
all all correct control 17 0.622 0.060 True
all correct training 17 0.570 0.057 True
Paper: 0.61 +- 0.05.
Result: reproduced. Over all correct control trials, the correlation of the lick right minus lick left difference between the last 400 ms of the sample and of the delay is 0.590 +- 0.075 over 16 sessions (0.622 with all units), within 0.61 +- 0.05.
ed8a-mode-variance¶
Claim: the projection on cd captures 65.6 +- 5.1% of population selectivity and 36.4 +- 6.3% of
task-related activity variance over the sample and delay epochs; modes 1 to 5 together explain
98.5 +- 0.5% of the variance and 95.8 +- 1.2% of the selectivity. Modes as in the Methods and
the code: mode 1 cd; modes 2 and 3 the ipsilateral perturbed minus unperturbed mean response in
the last 400 ms of the delay, lick right and lick left; modes 4 and 5 the first singular vectors
of the baseline-subtracted lick right and lick left mean responses concatenated over the sample
and delay windows; each Gram-Schmidt orthogonal to the earlier ones. Training control trials
(code). Baseline (a) the window before the sample (3.4 to 3.0 s before the cue, the code's
time_bins <= -3.4), (b) the mean over the trial. Share (a) RMS ratio, (b) squared norms (the
code). Total variance and selectivity: the squared norm over the full neuron space (code). cd
as the mean difference (Methods) or LDA (code). The shares use only the training trials, so the
leave-one-out split (M6 b) amounts to using all control trials.
def gram_schmidt(vs):
out = []
for v in vs:
v = v.astype(float).copy()
for o in out:
v -= (v @ o) * o
n = np.linalg.norm(v)
if n > 1e-12:
out.append(v / n)
return out
SD_WIN = np.flatnonzero((alm3.POP_T > -3.0 - 1e-9) & (alm3.POP_T <= -0.4 + 1e-9))
def modes_for(P, kind="meandiff", baseline="pre", trials="all"):
"""Modes 1 to 5 (Methods). trials "all": modes 2, 3 and the PSTHs of modes 4, 5 from correct
and error trials grouped by instructed movement (code); "correct": from correct trials only
(criterion)."""
X = P["X"]
trR, trL = P["train"][1], P["train"][-1]
_, w1, _ = cd_projections(P, kind, "inside")
iR, iL = P["groups"][(4, 1)], P["groups"][(4, -1)]
if trials == "correct":
hit = P["hit"]
trR, trL, iR, iL = trR[hit[trR]], trL[hit[trL]], iR[hit[iR]], iL[hit[iL]]
w2 = X[iR][:, :, I_LATE].mean(0) - X[trR][:, :, I_LATE].mean(0)
w3 = X[iL][:, :, I_LATE].mean(0) - X[trL][:, :, I_LATE].mean(0)
R = X[trR][:, :, SD_WIN].mean(0)
L = X[trL][:, :, SD_WIN].mean(0)
if baseline == "pre":
base = X[np.r_[trR, trL]][:, :, tidx(-3.4)].mean(0)
else:
base = X[np.r_[trR, trL]].mean(axis=(0, 2))
A = np.concatenate([R, L], axis=1) - base[:, None]
u, sv, vt = np.linalg.svd(A, full_matrices=False)
basis = gram_schmidt([w1, w2, w3] + [u[:, i] for i in range(u.shape[1])])
return basis, A, R - L
rows = []
for cells, split in [(c, sp) for c in ("pyramidal", "all") for sp in ("code", "half", "loo")]:
pops = POP[("exp2", cells, split)]
for (kind, trials_m) in (("meandiff", "all"), ("meandiff", "correct"), ("lda", "all"), ("lda", "correct")):
for baseline in ("pre", "trial"):
vals = []
for P in pops:
basis, A, S = modes_for(P, kind, baseline, trials_m)
tot_v, tot_s = (A ** 2).sum(), (S ** 2).sum()
pv = [((A.T @ b) ** 2).sum() / tot_v for b in basis[:5]]
ps = [((S.T @ b) ** 2).sum() / tot_s for b in basis[:5]]
vals.append({"var_cd": pv[0], "sel_cd": ps[0], "var_1_5": sum(pv), "sel_1_5": sum(ps),
"var_cd_rms": np.sqrt(pv[0]), "sel_cd_rms": np.sqrt(ps[0]), "var_1_5_rms": np.sqrt(sum(pv)), "sel_1_5_rms": np.sqrt(sum(ps)),
"var_mode4": pv[3], "n": P["n_neurons"]})
v = pd.DataFrame(vals)
for share in ("squared", "rms"):
suf = "" if share == "squared" else "_rms"
r = {"cells": cells, "split": split, "cd": kind, "mode_trials": trials_m, "baseline": baseline, "share": share, "sessions": len(v)}
for q in ("sel_cd", "var_cd", "var_1_5", "sel_1_5"):
r[q] = 100 * v[q + suf].mean()
r[q + "_sem"] = 100 * v[q + suf].std(ddof=1) / np.sqrt(len(v))
rows.append(r)
e8a = pd.DataFrame(rows)
expa = {"sel_cd": (65.6, 5.1), "var_cd": (36.4, 6.3), "var_1_5": (98.5, 0.5), "sel_1_5": (95.8, 1.2)}
e8a["all_within"] = np.all([(e8a[q] - v).abs() <= t for q, (v, t) in expa.items()], axis=0)
e8a["cd_within"] = np.all([(e8a[q] - v).abs() <= t for q, (v, t) in list(expa.items())[:2]], axis=0)
print(e8a.round(1).to_string(index=False))
print("Paper: selectivity on cd 65.6 +- 5.1%, variance on cd 36.4 +- 6.3%, modes 1-5: variance 98.5 +- 0.5%, selectivity 95.8 +- 1.2%.")
print("Neurons per session (pyramidal):", [p["n_neurons"] for p in POP[("exp2", "pyramidal", "code")]])
cells split cd mode_trials baseline share sessions sel_cd sel_cd_sem var_cd var_cd_sem var_1_5 var_1_5_sem sel_1_5 sel_1_5_sem all_within cd_within
pyramidal code meandiff all pre squared 16 72.5 3.6 39.5 6.2 97.1 0.6 93.9 1.2 False False
pyramidal code meandiff all pre rms 16 84.7 2.2 60.3 4.6 98.5 0.3 96.9 0.6 False False
pyramidal code meandiff all trial squared 16 72.5 3.6 40.7 5.6 95.5 0.9 93.7 1.4 False False
pyramidal code meandiff all trial rms 16 84.7 2.2 61.7 4.2 97.7 0.5 96.8 0.7 False False
pyramidal code meandiff correct pre squared 16 78.7 2.8 43.8 5.9 97.3 0.6 95.4 1.2 False False
pyramidal code meandiff correct pre rms 16 88.5 1.6 63.9 4.4 98.6 0.3 97.6 0.6 False False
pyramidal code meandiff correct trial squared 16 78.7 2.8 46.2 5.6 95.9 0.8 94.9 1.2 False False
pyramidal code meandiff correct trial rms 16 88.5 1.6 66.1 4.1 97.9 0.4 97.4 0.7 False False
pyramidal code lda all pre squared 16 66.1 4.1 36.6 5.9 96.9 0.7 93.4 1.4 False True
pyramidal code lda all pre rms 16 80.7 2.5 57.8 4.6 98.4 0.3 96.6 0.7 False False
pyramidal code lda all trial squared 16 66.1 4.1 37.6 5.5 95.2 1.0 93.0 1.6 False True
pyramidal code lda all trial rms 16 80.7 2.5 59.0 4.3 97.6 0.5 96.4 0.9 False False
pyramidal code lda correct pre squared 16 72.5 3.7 40.8 5.7 96.5 1.0 93.6 2.2 False False
pyramidal code lda correct pre rms 16 84.7 2.3 61.5 4.4 98.2 0.5 96.6 1.2 False False
pyramidal code lda correct trial squared 16 72.5 3.7 43.0 5.6 95.5 1.0 93.5 2.2 False False
pyramidal code lda correct trial rms 16 84.7 2.3 63.4 4.3 97.7 0.5 96.6 1.2 False False
pyramidal half meandiff all pre squared 16 67.1 4.4 39.9 5.9 96.3 0.8 92.5 1.7 False True
pyramidal half meandiff all pre rms 16 81.2 2.7 61.0 4.3 98.1 0.4 96.1 0.9 False False
pyramidal half meandiff all trial squared 16 67.1 4.4 41.3 5.7 94.7 1.0 92.4 1.8 False True
pyramidal half meandiff all trial rms 16 81.2 2.7 62.0 4.4 97.3 0.5 96.0 0.9 False False
pyramidal half meandiff correct pre squared 16 72.8 3.7 42.7 5.7 96.8 0.7 94.5 1.2 False False
pyramidal half meandiff correct pre rms 16 84.9 2.2 63.4 4.1 98.4 0.3 97.2 0.6 False False
pyramidal half meandiff correct trial squared 16 72.8 3.7 45.4 5.7 95.0 0.9 94.1 1.3 False False
pyramidal half meandiff correct trial rms 16 84.9 2.2 65.4 4.2 97.5 0.5 97.0 0.7 False False
pyramidal half lda all pre squared 16 60.6 4.9 35.7 5.8 96.2 0.7 92.1 1.9 False True
pyramidal half lda all pre rms 16 76.9 3.2 57.0 4.6 98.1 0.4 95.9 1.0 False False
pyramidal half lda all trial squared 16 60.6 4.9 37.8 5.7 94.5 1.2 91.7 2.2 False True
pyramidal half lda all trial rms 16 76.9 3.2 58.8 4.7 97.2 0.6 95.7 1.2 False False
pyramidal half lda correct pre squared 16 66.4 4.3 38.4 5.6 96.4 0.8 93.6 1.8 False True
pyramidal half lda correct pre rms 16 80.8 2.8 59.6 4.3 98.2 0.4 96.7 1.0 False False
pyramidal half lda correct trial squared 16 66.4 4.3 41.6 5.8 94.5 1.2 93.2 2.0 False True
pyramidal half lda correct trial rms 16 80.8 2.8 62.1 4.6 97.2 0.6 96.4 1.1 False False
pyramidal loo meandiff all pre squared 16 74.7 3.7 41.5 6.2 97.6 0.6 94.3 1.3 False False
pyramidal loo meandiff all pre rms 16 86.0 2.3 61.8 4.7 98.8 0.3 97.1 0.7 False False
pyramidal loo meandiff all trial squared 16 74.7 3.7 42.2 5.7 95.9 0.9 94.0 1.4 False False
pyramidal loo meandiff all trial rms 16 86.0 2.3 62.7 4.3 97.9 0.5 96.9 0.7 False False
pyramidal loo meandiff correct pre squared 16 80.9 2.7 45.6 6.1 97.9 0.6 96.0 1.0 False False
pyramidal loo meandiff correct pre rms 16 89.7 1.6 65.3 4.5 98.9 0.3 98.0 0.5 False False
pyramidal loo meandiff correct trial squared 16 80.9 2.7 47.6 5.5 96.2 0.8 95.6 1.0 False False
pyramidal loo meandiff correct trial rms 16 89.7 1.6 67.2 4.0 98.1 0.4 97.7 0.5 False False
pyramidal loo lda all pre squared 16 68.6 4.3 38.3 6.1 97.4 0.6 94.0 1.4 False True
pyramidal loo lda all pre rms 16 82.2 2.7 59.0 4.9 98.7 0.3 96.9 0.7 False False
pyramidal loo lda all trial squared 16 68.6 4.3 39.6 5.7 95.7 1.0 93.4 1.6 False True
pyramidal loo lda all trial rms 16 82.2 2.7 60.4 4.6 97.8 0.5 96.6 0.9 False False
pyramidal loo lda correct pre squared 16 74.8 3.6 42.5 6.0 97.5 0.7 94.9 1.7 False False
pyramidal loo lda correct pre rms 16 86.1 2.1 62.6 4.7 98.7 0.4 97.4 0.9 False False
pyramidal loo lda correct trial squared 16 74.8 3.6 44.6 5.6 95.8 1.0 95.1 1.3 False False
pyramidal loo lda correct trial rms 16 86.1 2.1 64.7 4.3 97.9 0.5 97.5 0.7 False False
all code meandiff all pre squared 17 73.2 3.5 41.2 5.5 97.3 0.5 93.5 1.3 False False
all code meandiff all pre rms 17 85.2 2.1 61.8 4.3 98.6 0.2 96.7 0.7 False False
all code meandiff all trial squared 17 73.2 3.5 42.8 4.9 95.6 0.7 93.6 1.3 False False
all code meandiff all trial rms 17 85.2 2.1 63.5 3.9 97.7 0.4 96.7 0.7 False False
all code meandiff correct pre squared 17 79.6 2.5 45.0 5.3 97.6 0.4 95.0 1.0 False False
all code meandiff correct pre rms 17 89.0 1.4 65.2 4.0 98.8 0.2 97.4 0.5 False False
all code meandiff correct trial squared 17 79.6 2.5 48.2 4.8 95.8 0.7 94.6 1.2 False False
all code meandiff correct trial rms 17 89.0 1.4 68.0 3.6 97.8 0.4 97.2 0.6 False False
all code lda all pre squared 17 67.9 3.9 37.3 5.1 97.0 0.5 93.3 1.3 False True
all code lda all pre rms 17 81.8 2.4 59.0 4.0 98.5 0.3 96.6 0.7 False False
all code lda all trial squared 17 67.9 3.9 39.2 4.5 95.5 0.7 93.4 1.3 False True
all code lda all trial rms 17 81.8 2.4 60.9 3.6 97.7 0.4 96.6 0.7 False False
all code lda correct pre squared 17 73.6 3.4 41.0 5.0 97.1 0.6 94.1 1.5 False False
all code lda correct pre rms 17 85.4 2.1 62.3 3.8 98.6 0.3 97.0 0.8 False False
all code lda correct trial squared 17 73.6 3.4 44.4 4.6 95.4 0.8 94.3 1.4 False False
all code lda correct trial rms 17 85.4 2.1 65.1 3.5 97.7 0.4 97.1 0.7 False False
all half meandiff all pre squared 17 68.2 4.1 42.6 5.3 96.7 0.6 91.9 1.7 False True
all half meandiff all pre rms 17 81.9 2.6 63.2 4.1 98.3 0.3 95.8 0.9 False False
all half meandiff all trial squared 17 68.2 4.1 43.3 5.0 95.0 0.8 92.0 1.7 False False
all half meandiff all trial rms 17 81.9 2.6 63.9 4.0 97.4 0.4 95.9 0.9 False False
all half meandiff correct pre squared 17 74.7 3.0 45.2 5.2 97.1 0.5 94.2 1.2 False False
all half meandiff correct pre rms 17 86.1 1.8 65.4 3.9 98.6 0.3 97.0 0.6 False False
all half meandiff correct trial squared 17 74.7 3.0 47.8 4.9 95.1 0.9 93.8 1.3 False False
all half meandiff correct trial rms 17 86.1 1.8 67.6 3.6 97.5 0.5 96.8 0.7 False False
all half lda all pre squared 17 62.3 4.9 36.9 5.1 96.6 0.6 91.8 1.7 False True
all half lda all pre rms 17 77.8 3.2 58.5 4.0 98.3 0.3 95.8 0.9 False False
all half lda all trial squared 17 62.3 4.9 38.4 4.8 94.8 0.9 91.9 1.7 False True
all half lda all trial rms 17 77.8 3.2 59.9 3.9 97.4 0.5 95.8 0.9 False False
all half lda correct pre squared 17 67.9 4.2 39.2 5.1 96.9 0.5 93.4 1.5 False True
all half lda correct pre rms 17 81.7 2.7 60.7 3.9 98.4 0.3 96.6 0.8 False False
all half lda correct trial squared 17 67.9 4.2 42.5 5.0 94.9 0.9 93.3 1.6 False True
all half lda correct trial rms 17 81.7 2.7 63.4 3.8 97.4 0.5 96.5 0.8 False False
all loo meandiff all pre squared 17 74.6 3.9 42.7 5.0 97.6 0.4 93.5 1.7 False False
all loo meandiff all pre rms 17 85.8 2.5 63.5 3.8 98.8 0.2 96.6 0.9 False False
all loo meandiff all trial squared 17 74.6 3.9 43.2 4.6 95.9 0.7 93.5 1.7 False False
all loo meandiff all trial rms 17 85.8 2.5 64.1 3.7 97.9 0.4 96.6 0.9 False False
all loo meandiff correct pre squared 17 81.5 2.6 46.6 4.9 97.7 0.5 95.3 1.0 False False
all loo meandiff correct pre rms 17 90.1 1.5 66.7 3.6 98.8 0.3 97.6 0.5 False False
all loo meandiff correct trial squared 17 81.5 2.6 48.9 4.4 96.0 0.7 94.8 1.2 False False
all loo meandiff correct trial rms 17 90.1 1.5 68.7 3.2 98.0 0.3 97.3 0.6 False False
all loo lda all pre squared 17 69.5 4.5 38.6 4.9 97.5 0.4 93.4 1.7 False True
all loo lda all pre rms 17 82.6 2.9 60.2 3.8 98.7 0.2 96.6 0.9 False False
all loo lda all trial squared 17 69.5 4.5 39.7 4.5 95.8 0.7 93.2 1.7 False True
all loo lda all trial rms 17 82.6 2.9 61.3 3.6 97.9 0.4 96.5 0.9 False False
all loo lda correct pre squared 17 75.7 3.6 42.4 4.9 97.6 0.5 95.0 1.4 False False
all loo lda correct pre rms 17 86.6 2.2 63.4 3.7 98.8 0.3 97.4 0.7 False False
all loo lda correct trial squared 17 75.7 3.6 45.0 4.5 95.6 0.8 94.6 1.4 False False
all loo lda correct trial rms 17 86.6 2.2 65.7 3.4 97.8 0.4 97.2 0.7 False False
Paper: selectivity on cd 65.6 +- 5.1%, variance on cd 36.4 +- 6.3%, modes 1-5: variance 98.5 +- 0.5%, selectivity 95.8 +- 1.2%.
Neurons per session (pyramidal): [13, 16, 16, 13, 20, 6, 10, 9, 6, 12, 9, 9, 9, 7, 6, 14]
Result: partially reproduced. With the mean-difference cd of the Methods and random halves of the control trials (M6 reading a), cd captures 67.1% of the selectivity and 39.9% of the variance (pyramidal neurons, pre-sample baseline, squared-norm shares, modes from correct and error trials), both within the paper's 65.6 +- 5.1% and 36.4 +- 6.3%. Modes 1 to 5 capture 96.3% of the variance and 92.5% of the selectivity, outside 98.5 +- 0.5% and 95.8 +- 1.2%; no reading puts all four values within tolerance, also with modes 2 and 3 and the mean responses from correct trials only (pyramidal, random halves: 96.8% and 94.5% for modes 1 to 5, with cd at 72.8% of the selectivity, outside). With the code's split the cd selectivity share is 72.5%, outside; with the code's discriminant as cd it is 66.1%.
fig3-cd-predicts-movement¶
Claim: deviations along the coding direction predict the upcoming movement trial by trial, in control trials and after unilateral and bilateral perturbation. Trials pooled over the sessions of fig3-cd-roc (Methods); per condition, the fraction of trials whose lick (the instructed side on correct trials, the other side on errors) is on the side of the decision boundary where the projection lies, with a binomial test against 0.5, and a logistic regression of lick right on the signed projection (criterion). Control trials are the test trials. cd of unit length (reading b of the scaling; the tests do not depend on the scale).
import statsmodels.api as sm
def pooled_projections(pops, conds, kind="meandiff", which="cd", t_index=I_LATE):
rows = []
for P in pops:
if which == "cd":
proj, _, _ = cd_projections(P, kind, "inside")
else:
proj = which(P)
lick_right = np.where(P["hit"], P["side"] == 1, P["side"] == -1)
for c in [0] + conds:
idx = np.r_[P["test"][1], P["test"][-1]] if c == 0 else np.r_[P["groups"][(c, 1)], P["groups"][(c, -1)]]
for i in idx:
rows.append({"session": P["session"], "mouse": P["mouse"], "condition": c, "proj": proj[i, t_index],
"lick_right": bool(lick_right[i]), "instructed_right": P["side"][i] == 1, "hit": bool(P["hit"][i])})
return pd.DataFrame(rows)
def prediction_table(df):
rows = []
for c, d in df.groupby("condition"):
pred = d.proj > 0
correct = int((pred == d.lick_right).sum())
b = stats.binomtest(correct, len(d), 0.5, alternative="greater")
lr = sm.Logit(d.lick_right.astype(float), sm.add_constant(d.proj.values)).fit(disp=0)
rows.append({"condition": c, "label": "control" if c == 0 else alm3.STIM_LABELS[c], "trials": len(d), "accuracy": correct / len(d),
"binom_p": b.pvalue, "logit_slope": np.asarray(lr.params)[1], "logit_p": np.asarray(lr.pvalues)[1],
"accuracy_error_trials": ((d.proj > 0) == d.lick_right)[~d.hit].mean(), "error_trials": int((~d.hit).sum())})
return pd.DataFrame(rows)
for cells in ("pyramidal", "all"):
dfp = pooled_projections(POP[("exp2", cells, "code")], [4, 5, 6])
print(f"Neurons: {cells}")
print(prediction_table(dfp).to_string(index=False, float_format=lambda x: f"{x:.3g}"))
dfp = pooled_projections(POP[("exp2", "pyramidal", "code")], [4, 5, 6])
print("\nFraction of lick right responses by projection bin (control and bilateral, pyramidal):")
dfp["bin"] = pd.cut(dfp.proj, [-np.inf, -10, -5, -2, 0, 2, 5, 10, np.inf])
print(dfp[dfp.condition.isin([0, 6])].groupby(["condition", "bin"], observed=True).lick_right.agg(["mean", "size"]).round(2).to_string())
print("Projection range (spikes/s along unit-length cd):", round(dfp.proj.min(), 1), "to", round(dfp.proj.max(), 1))
Neurons: pyramidal
condition label trials accuracy binom_p logit_slope logit_p accuracy_error_trials error_trials
0 control 412 0.728 3.23e-21 0.145 1.02e-16 0.675 83
4 ipsi 1 spot (0.8 s) 328 0.686 6.94e-12 0.138 2.5e-12 0.581 93
5 contra 1 spot (0.8 s) 351 0.684 2.42e-12 0.105 2.49e-10 0.529 104
6 bilateral 4 spots (0.8 s) 566 0.671 1.27e-16 0.105 1.66e-16 0.641 231
Neurons: all
condition label trials accuracy binom_p logit_slope logit_p accuracy_error_trials error_trials
0 control 444 0.739 8.29e-25 0.123 6.04e-18 0.659 91
4 ipsi 1 spot (0.8 s) 354 0.709 1.09e-15 0.0899 7.71e-11 0.673 101
5 contra 1 spot (0.8 s) 379 0.686 1.72e-13 0.0864 7.42e-11 0.532 111
6 bilateral 4 spots (0.8 s) 611 0.653 1.68e-14 0.0684 4.65e-13 0.634 257
Fraction of lick right responses by projection bin (control and bilateral, pyramidal):
mean size
condition bin
0 (-inf, -10.0] 0.03 72
(-10.0, -5.0] 0.23 56
(-5.0, -2.0] 0.36 47
(-2.0, 0.0] 0.53 32
(0.0, 2.0] 0.63 54
(2.0, 5.0] 0.63 59
(5.0, 10.0] 0.75 52
(10.0, inf] 0.80 40
6 (-inf, -10.0] 0.33 100
(-10.0, -5.0] 0.32 88
(-5.0, -2.0] 0.39 80
(-2.0, 0.0] 0.60 57
(0.0, 2.0] 0.74 73
(2.0, 5.0] 0.71 75
(5.0, 10.0] 0.81 67
(10.0, inf] 0.77 26
Projection range (spikes/s along unit-length cd): -60.2 to 51.5
Result: reproduced. On trials pooled over the 16 sessions, the side of the decision boundary predicts the lick on 72.8% of control, 68.6% of ipsilateral, 68.4% of contralateral and 67.1% of bilateral trials (binomial p below 1e-6 in each), and the logistic regression slope of lick right on the projection is positive with p below 1e-6 in each condition. After bilateral photoinhibition the fraction of lick right responses is 0.33 in the most negative projection bin and 0.77 in the most positive.
fig3-other-modes¶
Claim: the persistent mode is altered by perturbation but neither discriminates trial type nor predicts behaviour; the ramping mode shows non-selective ramping, is resistant to perturbation and does not predict behaviour. Modes 2 (persistent, lick right) and 4 (ramping) of ed8a-mode-variance, mean-difference cd, pre-sample baseline; decision boundaries as for cd and signs so that lick right projects higher on training trials (code). Criterion: ROC in the last 400 ms of the delay within 0.5 +- 0.1 over sessions and control prediction accuracy with binomial p > 0.05; ramping-mode projection for ipsilateral and bilateral trials within the s.e.m. band of the control projection over sessions, persistent-mode projection outside it for ipsilateral. Splits: the code's and random halves (M6 a); the leave-one-out split (M6 b) is not run here, as it needs all five modes recomputed for every control trial.
def mode_projection(P, mode_index, kind="meandiff"):
basis, _, _ = modes_for(P, kind, "pre")
w = basis[mode_index]
proj = np.einsum("tnw,n->tw", P["X"], w)
hit = P["hit"]
tR = P["train"][1][hit[P["train"][1]]]
tL = P["train"][-1][hit[P["train"][-1]]]
if proj[tR, I_LATE].mean() < proj[tL, I_LATE].mean():
proj = -proj
return proj - alm3.boundary(proj[tR, I_LATE], proj[tL, I_LATE]), proj
for cells, split in (("pyramidal", "code"), ("all", "code"), ("pyramidal", "half"), ("all", "half")):
pops = POP[("exp2", cells, split)]
print(f"Neurons: {cells}, split: {split}")
for mi, name in ((1, "persistent (mode 2)"), (3, "ramping (mode 4)"), (0, "cd (mode 1), for comparison")):
rocs, raw = [], []
for P in pops:
pr, praw = mode_projection(P, mi)
rocs.append(session_rocs(P, pr, [4, 5, 6]))
# mean raw projection in the last 400 ms of the delay, per condition, both trial types
r = {0: praw[np.r_[P["test"][1], P["test"][-1]], I_LATE].mean()}
for c in (4, 5, 6):
r[c] = praw[np.r_[P["groups"][(c, 1)], P["groups"][(c, -1)]], I_LATE].mean()
raw.append(r)
rocs, raw = pd.DataFrame(rocs), pd.DataFrame(raw)
dfm = pooled_projections(pops, [4, 5, 6], which=lambda P, mi=mi: mode_projection(P, mi)[0])
pt = prediction_table(dfm).set_index("condition")
diff = raw[[4, 5, 6]].sub(raw[0], axis=0)
sem0 = raw[0].std(ddof=1) / np.sqrt(len(raw))
print(f" {name}: ROC control {rocs[0].mean():.3f} +- {rocs[0].std(ddof=1) / np.sqrt(len(rocs)):.3f}, ipsi {rocs[4].mean():.3f}, contra {rocs[5].mean():.3f}, bilateral {rocs[6].mean():.3f}; "
f"control accuracy {pt.loc[0, 'accuracy']:.3f} (binomial p {pt.loc[0, 'binom_p']:.3g}); "
f"perturbed minus control projection (mean over sessions): ipsi {diff[4].mean():+.2f}, contra {diff[5].mean():+.2f}, bilateral {diff[6].mean():+.2f}; "
f"control s.e.m. band {sem0:.2f}")
Neurons: pyramidal, split: code
persistent (mode 2): ROC control 0.567 +- 0.043, ipsi 0.497, contra 0.587, bilateral 0.550; control accuracy 0.568 (binomial p 0.00333); perturbed minus control projection (mean over sessions): ipsi -2.09, contra -2.40, bilateral -2.01; control s.e.m. band 2.17
ramping (mode 4): ROC control 0.577 +- 0.032, ipsi 0.600, contra 0.606, bilateral 0.550; control accuracy 0.570 (binomial p 0.00246); perturbed minus control projection (mean over sessions): ipsi +0.51, contra -0.54, bilateral -0.48; control s.e.m. band 1.00
cd (mode 1), for comparison: ROC control 0.719 +- 0.033, ipsi 0.706, contra 0.738, bilateral 0.595; control accuracy 0.728 (binomial p 3.23e-21); perturbed minus control projection (mean over sessions): ipsi +0.53, contra -0.77, bilateral -0.22; control s.e.m. band 2.40 Neurons: all, split: code
persistent (mode 2): ROC control 0.530 +- 0.036, ipsi 0.451, contra 0.539, bilateral 0.550; control accuracy 0.547 (binomial p 0.0258); perturbed minus control projection (mean over sessions): ipsi -2.36, contra -1.71, bilateral -3.59; control s.e.m. band 2.91
ramping (mode 4): ROC control 0.546 +- 0.031, ipsi 0.581, contra 0.593, bilateral 0.544; control accuracy 0.529 (binomial p 0.118); perturbed minus control projection (mean over sessions): ipsi -0.15, contra -0.36, bilateral -0.07; control s.e.m. band 2.08
cd (mode 1), for comparison: ROC control 0.740 +- 0.028, ipsi 0.672, contra 0.745, bilateral 0.587; control accuracy 0.739 (binomial p 8.29e-25); perturbed minus control projection (mean over sessions): ipsi +0.35, contra -1.10, bilateral -2.80; control s.e.m. band 5.99 Neurons: pyramidal, split: half
persistent (mode 2): ROC control 0.583 +- 0.029, ipsi 0.479, contra 0.539, bilateral 0.541; control accuracy 0.570 (binomial p 1.01e-05); perturbed minus control projection (mean over sessions): ipsi -1.96, contra -0.89, bilateral -0.97; control s.e.m. band 2.16
ramping (mode 4): ROC control 0.590 +- 0.024, ipsi 0.609, contra 0.609, bilateral 0.545; control accuracy 0.548 (binomial p 0.00197); perturbed minus control projection (mean over sessions): ipsi -0.06, contra -0.81, bilateral -0.91; control s.e.m. band 0.88
cd (mode 1), for comparison: ROC control 0.716 +- 0.030, ipsi 0.702, contra 0.684, bilateral 0.596; control accuracy 0.716 (binomial p 4.05e-41); perturbed minus control projection (mean over sessions): ipsi +0.45, contra -0.67, bilateral +0.35; control s.e.m. band 2.65 Neurons: all, split: half
persistent (mode 2): ROC control 0.577 +- 0.024, ipsi 0.475, contra 0.552, bilateral 0.556; control accuracy 0.581 (binomial p 1.82e-07); perturbed minus control projection (mean over sessions): ipsi -3.24, contra -1.18, bilateral -4.33; control s.e.m. band 2.73
ramping (mode 4): ROC control 0.565 +- 0.018, ipsi 0.592, contra 0.590, bilateral 0.576; control accuracy 0.544 (binomial p 0.00303); perturbed minus control projection (mean over sessions): ipsi -0.37, contra -0.63, bilateral -1.01; control s.e.m. band 2.52
cd (mode 1), for comparison: ROC control 0.731 +- 0.027, ipsi 0.667, contra 0.703, bilateral 0.587; control accuracy 0.729 (binomial p 1.72e-49); perturbed minus control projection (mean over sessions): ipsi +0.63, contra -0.62, bilateral -1.82; control s.e.m. band 6.08
Result: not reproduced. The persistent and ramping modes discriminate trial type only weakly (control ROC 0.567 and 0.577), within 0.5 +- 0.1, but both predict the lick on control trials above chance (accuracy 0.568 and 0.570, binomial p = 0.003 and 0.002). The ramping mode is little changed by ipsilateral and bilateral photoinhibition (+0.51 and -0.48 against a control band of 1.00), but the persistent mode's ipsilateral change (-2.09) is also inside its band (2.17).
ed6-bilateral-bias-inconsistent¶
Claim: bilateral photoinhibition biases movements inconsistently across mice and sessions, and the direction of a session's bias follows which control trajectory its perturbed cd trajectories approach. Sessions of fig3-cd-roc, bilateral photoinhibition (type 6). Per session, bias = performance on lick right minus lick left trials under photoinhibition; biased when Fisher's exact test of the two performances gives p < 0.05; side of the mean perturbed projection in the last 400 ms of the delay (a) relative to the decision boundary, (b) nearer of the mean control lick right and lick left projections. Reproduced when biased sessions of both signs occur and the sign agrees with the side in at least 80% of biased sessions (criterion).
for cells in ("pyramidal", "all"):
rows = []
for P in POP[("exp2", cells, "code")]:
proj, _, _ = cd_projections(P)
gR, gL = P["groups"][(6, 1)], P["groups"][(6, -1)]
hR, hL = P["hit"][gR], P["hit"][gL]
bias = hR.mean() - hL.mean()
p = stats.fisher_exact([[hR.sum(), (~hR).sum()], [hL.sum(), (~hL).sum()]]).pvalue
mp = proj[np.r_[gR, gL], I_LATE].mean()
cR, cL = proj[P["test"][1], I_LATE].mean(), proj[P["test"][-1], I_LATE].mean()
rows.append({"session": P["session"], "mouse": P["mouse"], "perf_R": hR.mean(), "perf_L": hL.mean(), "bias": bias, "fisher_p": p,
"mean_proj": mp, "side_a": np.sign(mp), "side_b": 1 if abs(mp - cR) < abs(mp - cL) else -1})
b6 = pd.DataFrame(rows)
biased = b6[b6.fisher_p < 0.05]
print(f"Neurons: {cells}")
print(b6.round(3).to_string(index=False))
for s_ in ("side_a", "side_b"):
agree = (np.sign(biased.bias) == biased[s_]).mean() if len(biased) else np.nan
print(f" biased sessions {len(biased)} (lick right bias {int((biased.bias > 0).sum())}, lick left bias {int((biased.bias < 0).sum())}); sign agrees with {s_}: {agree:.2f}")
allc = (np.sign(b6.bias) == b6.side_a).mean()
print(f" all sessions: sign of bias agrees with side (a) in {allc:.2f}; Spearman of bias with mean projection r = {stats.spearmanr(b6.bias, b6.mean_proj).statistic:.2f}, p = {stats.spearmanr(b6.bias, b6.mean_proj).pvalue:.3g}")
Neurons: pyramidal
session mouse perf_R perf_L bias fisher_p mean_proj side_a side_b
ANM255201_20141121 ANM255201 0.769 0.556 0.214 0.376 11.463 1.0 -1
ANM255201_20141123 ANM255201 1.000 0.500 0.500 0.006 -4.496 -1.0 1
ANM257637_20141222 ANM257637 1.000 0.062 0.938 0.000 5.400 1.0 1
ANM257637_20141223 ANM257637 0.882 0.250 0.632 0.001 -7.080 -1.0 1
ANM257772_20141121 ANM257772 0.692 0.789 -0.097 0.684 -16.361 -1.0 -1
ANM257772_20141123 ANM257772 0.630 0.542 0.088 0.578 -7.925 -1.0 -1
ANM258250_20141201 ANM258250 0.188 0.818 -0.631 0.002 -4.273 -1.0 -1
ANM258250_20141203 ANM258250 0.526 0.400 0.126 0.700 2.154 1.0 1
ANM258250_20141205 ANM258250 0.600 0.722 -0.122 0.621 -3.753 -1.0 -1
ANM263808_20150124 ANM263808 0.667 0.842 -0.175 0.384 -4.418 -1.0 1
ANM263810_20150122 ANM263810 0.538 0.500 0.038 0.793 -1.148 -1.0 1
ANM263810_20150123 ANM263810 0.900 0.500 0.400 0.030 3.159 1.0 1
ANM263810_20150125 ANM263810 0.870 0.281 0.588 0.000 2.379 1.0 1
ANM263810_20150126 ANM263810 0.389 0.708 -0.319 0.060 -5.584 -1.0 1
ANM264411_20141222 ANM264411 0.800 0.333 0.467 0.008 -2.294 -1.0 -1
ANM264411_20141224 ANM264411 0.160 0.875 -0.715 0.000 -2.690 -1.0 -1
biased sessions 8 (lick right bias 6, lick left bias 2); sign agrees with side_a: 0.62
biased sessions 8 (lick right bias 6, lick left bias 2); sign agrees with side_b: 0.88
all sessions: sign of bias agrees with side (a) in 0.69; Spearman of bias with mean projection r = 0.34, p = 0.196
Neurons: all
session mouse perf_R perf_L bias fisher_p mean_proj side_a side_b
ANM255201_20141121 ANM255201 0.769 0.556 0.214 0.376 -18.893 -1.0 -1
ANM255201_20141123 ANM255201 1.000 0.500 0.500 0.006 -1.175 -1.0 -1
ANM257637_20141222 ANM257637 1.000 0.062 0.938 0.000 5.630 1.0 1
ANM257637_20141223 ANM257637 0.882 0.250 0.632 0.001 -7.543 -1.0 1
ANM257772_20141121 ANM257772 0.692 0.789 -0.097 0.684 -16.310 -1.0 -1
ANM257772_20141123 ANM257772 0.630 0.542 0.088 0.578 -8.561 -1.0 -1
ANM258250_20141201 ANM258250 0.188 0.818 -0.631 0.002 -3.230 -1.0 -1
ANM258250_20141203 ANM258250 0.526 0.400 0.126 0.700 2.064 1.0 1
ANM258250_20141205 ANM258250 0.600 0.722 -0.122 0.621 -3.454 -1.0 -1
ANM263808_20150124 ANM263808 0.667 0.842 -0.175 0.384 -4.759 -1.0 1
ANM263810_20150122 ANM263810 0.538 0.500 0.038 0.793 -0.682 -1.0 1
ANM263810_20150123 ANM263810 0.900 0.500 0.400 0.030 3.159 1.0 1
ANM263810_20150124 ANM263810 0.360 0.500 -0.140 0.379 -16.212 -1.0 -1
ANM263810_20150125 ANM263810 0.870 0.281 0.588 0.000 3.398 1.0 1
ANM263810_20150126 ANM263810 0.389 0.708 -0.319 0.060 -5.584 -1.0 1
ANM264411_20141222 ANM264411 0.800 0.333 0.467 0.008 -2.294 -1.0 -1
ANM264411_20141224 ANM264411 0.160 0.875 -0.715 0.000 -2.690 -1.0 -1
biased sessions 8 (lick right bias 6, lick left bias 2); sign agrees with side_a: 0.62
biased sessions 8 (lick right bias 6, lick left bias 2); sign agrees with side_b: 0.75
all sessions: sign of bias agrees with side (a) in 0.65; Spearman of bias with mean projection r = 0.40, p = 0.107
Result: reproduced. Under bilateral photoinhibition 8 of 16 sessions are biased (Fisher p < 0.05), 6 toward lick right and 2 toward lick left. The sign of the bias agrees with the nearer control trajectory (reading b) in 88% of biased sessions, and with the side of the decision boundary (reading a) in 62%.
fig5-callosotomy-recovery: selectivity along cd¶
The cd part of fig5-callosotomy-recovery: the ipsilateral cd ROC at the end of the delay in the callosotomy sessions (session rule of fig3-cd-roc), against (a) the callosotomy control ROC and (b) the Experiment 2 ipsilateral ROC; reduced read as lower by a paired (a) or unpaired (b) t-test over sessions at p < 0.05, a standard choice.
rt5 = roc_table("ccx", [10, 11, 12])
print(rt5.round(3).to_string(index=False))
for cells in ("pyramidal", "all"):
P5 = POP[("ccx", cells, "code")]
R5c = pd.DataFrame([session_rocs(P, cd_projections(P)[0], [10, 11, 12]) for P in P5])
R2c = pd.DataFrame([session_rocs(P, cd_projections(P)[0], [4, 5, 6]) for P in POP[("exp2", cells, "code")]])
ta = stats.ttest_rel(R5c[10], R5c[0])
tb = stats.ttest_ind(R5c[10], R2c[4])
print(f"{cells}: callosotomy sessions {len(R5c)}; ipsilateral ROC {R5c[10].mean():.3f} against callosotomy control {R5c[0].mean():.3f} (paired t = {ta.statistic:.2f}, p = {ta.pvalue:.3g}); "
f"against Experiment 2 ipsilateral {R2c[4].mean():.3f} (t = {tb.statistic:.2f}, p = {tb.pvalue:.3g})")
print("Paper: 16 callosotomy sessions in Fig. 5f.")
cells split cd sessions roc_0 sem_0 roc_10 sem_10 roc_11 sem_11 roc_12 sem_12
pyramidal code meandiff/inside 16 0.718 0.046 0.566 0.036 0.660 0.044 0.549 0.035
pyramidal code meandiff/centre 16 0.716 0.047 0.571 0.034 0.669 0.044 0.552 0.035
pyramidal code lda/inside 16 0.710 0.046 0.559 0.032 0.662 0.044 0.544 0.034
pyramidal half meandiff/inside 16 0.707 0.040 0.567 0.036 0.649 0.044 0.538 0.036
pyramidal half meandiff/centre 16 0.704 0.042 0.579 0.034 0.647 0.044 0.542 0.035
pyramidal half lda/inside 16 0.699 0.040 0.558 0.035 0.645 0.046 0.540 0.034
pyramidal loo meandiff/inside 16 0.711 0.039 0.574 0.035 0.673 0.042 0.547 0.038
pyramidal loo meandiff/centre 16 0.714 0.038 0.581 0.033 0.673 0.042 0.549 0.036
all code meandiff/inside 17 0.718 0.039 0.605 0.030 0.656 0.044 0.562 0.025
all code meandiff/centre 17 0.716 0.041 0.607 0.030 0.660 0.044 0.570 0.024
all code lda/inside 17 0.712 0.036 0.597 0.028 0.657 0.044 0.565 0.024
all half meandiff/inside 17 0.715 0.034 0.605 0.032 0.643 0.048 0.563 0.026
all half meandiff/centre 17 0.715 0.034 0.605 0.031 0.641 0.050 0.567 0.026
all half lda/inside 17 0.712 0.033 0.606 0.031 0.648 0.048 0.566 0.026
all loo meandiff/inside 17 0.722 0.032 0.609 0.029 0.663 0.046 0.560 0.030
all loo meandiff/centre 17 0.725 0.032 0.611 0.030 0.664 0.045 0.572 0.029
pyramidal: callosotomy sessions 16; ipsilateral ROC 0.566 against callosotomy control 0.718 (paired t = -3.19, p = 0.00609); against Experiment 2 ipsilateral 0.706 (t = -3.27, p = 0.00272)
all: callosotomy sessions 17; ipsilateral ROC 0.605 against callosotomy control 0.718 (paired t = -2.67, p = 0.0168); against Experiment 2 ipsilateral 0.672 (t = -1.67, p = 0.105) Paper: 16 callosotomy sessions in Fig. 5f.
Result: reproduced. In the callosotomy sessions the population rate is back to 1.05 of control just before the cue after ipsilateral photoinhibition, while ipsilateral selectivity stays 67% below control 0.2 s before the cue and recovers in under 1% of resamples. Contralateral selectivity recovers in 297 ms (code reading, 81% of resamples), within 217 +- 228 ms, and bilateral selectivity does not recover (0 of 1000 resamples). Across the 64 readings ipsilateral selectivity reaches 80% in at most 9% of resamples and bilateral in at most 0.2% (one or two of 1000 resamples in seven readings, none in the others), and 37 readings also put the contralateral time within tolerance. The selection has 125 neurons against 129. The session rule gives 16 callosotomy sessions, as Fig. 5f, and the ipsilateral cd ROC at the end of the delay is 0.566, lower than the callosotomy control (0.718, paired p = 0.006) and the Experiment 2 ipsilateral ROC (0.706, p = 0.003).
ed9f-reaction-time¶
Claim: reaction times are faster on trials whose cd trajectory lies far from the decision boundary at the go cue. Sessions of fig3-cd-roc whose lick trace shows licks (data check above); reaction time the first lick after the cue (criterion's reading), relative to the session mean, lick right and lick left trials pooled, correct and error trials; Spearman correlation with the absolute projection in the last 400 ms of the delay, negative with p < 0.05 (criterion). Trials (a) control test trials, (b) all conditions.
print("Sessions whose lick trace shows licks, by experiment:")
print(pd.crosstab(lk.experiment, usable.map({True: "lick-like", False: "noise-like"})).to_string())
ok_sessions = set(lk[usable].session)
print("Time series channels of the Experiment 2 sessions:", sorted({tuple(SD[n]["ts_channels"]) for n in ses[ses.experiment == "exp2"].session}))
print("Experiment 2 lick traces, range (99.9th percentile minus median) per session:", sorted(lk[lk.experiment == "exp2"].trace_range.round(4).tolist()))
for exp, conds in (("exp2", (4, 5, 6)), ("exp3", (7, 8, 9)), ("exp2b", (4, 5, 7)), ("ccx", (10, 11, 12))):
rows = []
for P in POP[(exp, "pyramidal", "code")]:
if P["session"] not in ok_sessions:
continue
s = SD[P["session"]]
proj, _, _ = cd_projections(P)
rt = (s["first_lick"] - s["cue"])[P["trials"]]
for c in (0,) + conds:
idx = np.r_[P["test"][1], P["test"][-1]] if c == 0 else np.r_[P["groups"][(c, 1)], P["groups"][(c, -1)]]
for i in idx:
if np.isfinite(rt[i]):
rows.append({"session": P["session"], "mouse": P["mouse"], "condition": c, "rt": rt[i], "dist": abs(proj[i, I_LATE])})
print(f"\n{exp}: population sessions with lick-like traces: {len({r['session'] for r in rows})}")
if not rows:
continue
d9 = pd.DataFrame(rows)
d9["rt_rel"] = d9.rt - d9.groupby("session").rt.transform("mean")
print(f" {d9.mouse.nunique()} mice, {len(d9)} trials; reaction time (s) median {d9.rt.median():.3f}, range {d9.rt.min():.3f} to {d9.rt.max():.3f}")
for lab, m in (("(a) control", d9.condition == 0), ("(b) all conditions", d9.condition >= 0)):
r = stats.spearmanr(d9[m].dist, d9[m].rt_rel)
print(f" {lab}: n = {int(m.sum())}, Spearman r = {r.statistic:.3f}, p = {r.pvalue:.3g}")
Sessions whose lick trace shows licks, by experiment:
col_0 lick-like noise-like
experiment
ccx 29 3
exp2 0 26
exp2b 6 0
exp3 6 0
unilateral 1 19
Time series channels of the Experiment 2 sessions: [('lick_trace', 'aom_input_trace', 'laser_power')]
Experiment 2 lick traces, range (99.9th percentile minus median) per session: [0.0013, 0.0013, 0.0013, 0.0013, 0.0013, 0.0013, 0.0013, 0.0013, 0.0016, 0.0016, 0.0016, 0.0016, 0.0016, 0.0016, 0.0016, 0.0016, 0.0016, 0.0016, 0.0019, 0.0019, 0.0019, 0.0019, 0.0019, 0.0019, 0.0019, 0.0019]
exp2: population sessions with lick-like traces: 0
exp3: population sessions with lick-like traces: 4
3 mice, 452 trials; reaction time (s) median 0.192, range 0.060 to 1.408
(a) control: n = 118, Spearman r = -0.019, p = 0.839
(b) all conditions: n = 452, Spearman r = -0.153, p = 0.00109
exp2b: population sessions with lick-like traces: 5
3 mice, 433 trials; reaction time (s) median 0.199, range 0.049 to 1.425
(a) control: n = 109, Spearman r = 0.017, p = 0.864
(b) all conditions: n = 433, Spearman r = 0.029, p = 0.547
ccx: population sessions with lick-like traces: 15
7 mice, 1223 trials; reaction time (s) median 0.181, range 0.000 to 1.311
(a) control: n = 319, Spearman r = -0.025, p = 0.655
(b) all conditions: n = 1223, Spearman r = -0.025, p = 0.376
Result: blocked. None of the 26 Experiment 2 sessions has a lick trace with detectable licks (trace range 0.0013 to 0.0019; their only channels are lick_trace, aom_input_trace and laser_power), so the claim's reaction times cannot be measured. As variants on other sessions whose traces show licks: in the 4 Experiment 3 population sessions, reaction time does not correlate with the distance from the boundary on control trials (Spearman r = -0.019, p = 0.84) and correlates negatively over all conditions (r = -0.153, p = 0.001); in the 5 sessions with types 4, 5 and 7, r = 0.017 (p = 0.86) and 0.029 (p = 0.55); in the 15 callosotomy sessions, r = -0.025 (p = 0.66) and -0.025 (p = 0.38).
models-monolithic-fail¶
Claim: monolithic network models (fixed-point attractor, integrators, trained recurrent
networks) do not recover their unperturbed trajectory after transient silencing of half of their
neurons. A simulation that uses no recorded data; parameters from the Methods and the ED Fig. 1
legend, open details as stated in models.py. Criterion: in each model, the output at t = 2 s
after perturbation differs from the unperturbed output by more than 20% of the unperturbed
selectivity in at least two of three draws. Run here: the simple integrator (three draws of its
connectivity), the monolithic attractor (one module of Fig. 6b; either neuron silenced; noise
realizations as draws) and the FORCE-trained network (three draws). Not run: the integrator with
corrective feedback (ED Fig. 1g), whose weights the paper does not give, and the tamed-chaos
network (ED Fig. 1i), whose pruning threshold and retuning the paper does not give.
import models
rng_m = np.random.default_rng(2016)
rows = []
for d in range(3):
u = rng_m.normal(size=100)
u /= np.linalg.norm(u)
sil = rng_m.choice(100, 50, replace=False)
o = {tr: models.run_simple_integrator(tr, None, u)[-1] for tr in (1, -1)}
p = {tr: models.run_simple_integrator(tr, sil, u)[-1] for tr in (1, -1)}
sel = o[1] - o[-1]
rows.append({"model": "simple integrator", "draw": d, "unperturbed_out": o[1], "perturbed_out": p[1],
"deviation_over_selectivity": max(abs(p[1] - o[1]), abs(p[-1] - o[-1])) / abs(sel)})
W1 = models.attractor_weights()[:2, :2]
for d in range(3):
for silenced in ([0], [1]):
seed = int(rng_m.integers(1e9))
o = {tr: models.run_attractor(tr, None, np.random.default_rng(seed + tr), W=W1)[-1] for tr in (1, -1)}
p = {tr: models.run_attractor(tr, silenced, np.random.default_rng(seed + tr), W=W1)[-1] for tr in (1, -1)}
sel = (o[1][0] - o[1][1]) - (o[-1][0] - o[-1][1])
dev = max(abs((p[tr][0] - p[tr][1]) - (o[tr][0] - o[tr][1])) for tr in (1, -1))
rows.append({"model": f"monolithic attractor, neuron {silenced[0] + 1} silenced", "draw": d, "unperturbed_out": o[1][0] - o[1][1],
"perturbed_out": p[1][0] - p[1][1], "deviation_over_selectivity": dev / abs(sel)})
t_f = time.time()
for d in range(3):
net = models.Force(np.random.default_rng(300 + d))
net.train(30)
sil = np.random.default_rng(400 + d).choice(400, 200, replace=False)
o = {tr: net.run(tr) for tr in (1, -1)}
p = {tr: net.run(tr, sil) for tr in (1, -1)}
sel = o[1][-1] - o[-1][-1]
rows.append({"model": "FORCE network", "draw": d, "unperturbed_out": o[1][-1], "perturbed_out": p[1][-1],
"deviation_over_selectivity": max(abs(p[tr][-1] - o[tr][-1]) for tr in (1, -1)) / abs(sel),
"train_error_rms": float(np.sqrt(np.mean((o[1] - net.target(np.arange(2000) * 0.001, 1)) ** 2)))})
print(f"FORCE networks trained and run in {time.time() - t_f:.0f} s")
mono = pd.DataFrame(rows)
mono["not_recovered"] = mono.deviation_over_selectivity > 0.2
print(mono.round(3).to_string(index=False))
print("\nDraws not recovered (deviation > 20% of selectivity), per model:")
print(mono.groupby("model").not_recovered.agg(["sum", "size"]).to_string())
FORCE networks trained and run in 44 s
model draw unperturbed_out perturbed_out deviation_over_selectivity train_error_rms not_recovered
simple integrator 0 16.310 9.387 0.212 NaN True
simple integrator 1 16.310 9.400 0.212 NaN True
simple integrator 2 16.310 9.321 0.214 NaN True
monolithic attractor, neuron 1 silenced 0 0.932 -1.020 1.079 NaN True
monolithic attractor, neuron 2 silenced 0 0.903 0.992 1.071 NaN True
monolithic attractor, neuron 1 silenced 1 0.973 -0.994 1.030 NaN True
monolithic attractor, neuron 2 silenced 1 0.835 0.992 1.093 NaN True
monolithic attractor, neuron 1 silenced 2 0.944 -0.977 1.023 NaN True
monolithic attractor, neuron 2 silenced 2 0.917 1.018 1.047 NaN True
FORCE network 0 0.998 0.915 0.247 0.0 True
FORCE network 1 0.998 0.351 0.475 0.0 True
FORCE network 2 0.999 0.769 0.868 0.0 True
Draws not recovered (deviation > 20% of selectivity), per model:
sum size
model
FORCE network 3 3
monolithic attractor, neuron 1 silenced 3 3
monolithic attractor, neuron 2 silenced 3 3
simple integrator 3 3
Result: partially reproduced. Each of the three simulated monolithic models fails to recover in all three draws: the simple integrator ends 21% of its selectivity from the unperturbed output, the single-module attractor switches to the other fixed point (deviation 1.02 to 1.09 of its selectivity), and the FORCE-trained networks end 25% to 87% away. The corrective-feedback integrator and the tamed-chaos network were not simulated, as the paper does not give their weights or retuning. The criterion has no partial rule; the outcome is partial because two of the five models could not be tested. The simple integrator's deviation (0.212 against the threshold of 0.2) depends on the assumed rank-one matrix.
fig6-modular-models-robust¶
Claim: modular networks of two coupled modules restore activity after transient silencing of
one module but drift to a random fixed point when both are silenced. Modular attractor and
modular integrator with the Methods' parameters (models.py); the modular FORCE network is not
run, as its training of the inter-module weights is not specified. Criterion: for the attractor
and the integrator, the silenced module returns within 10% of its unperturbed state by t = 2 s in
at least 90% of 100 noisy runs, and after bilateral silencing the attractor ends at the wrong
fixed point in 25% to 75% of runs. The module's state is read as its selectivity (right minus
left preferring neuron), compared with the same noise realization without silencing; the fixed
point at t = 2 s by the sign of that selectivity. The integrator has no noise, so one run per
trial type stands for all. Bilateral silencing of the attractor is also run to 4 s, so that every
run settles at a fixed point (verifier, round 1).
rows = []
for noise in ("step", "time"):
for tr in (1, -1):
rec, wrong, wrong_ctrl, undecided = [], [], [], []
for i in range(100):
seed = 10_000 * (1 if noise == "step" else 2) + 100 * (tr + 1) + i
o = models.run_attractor(tr, None, np.random.default_rng(seed), noise=noise)
p = models.run_attractor(tr, [0, 1], np.random.default_rng(seed), noise=noise)
b = models.run_attractor(tr, [0, 1, 2, 3], np.random.default_rng(seed), noise=noise)
so, sp, sb = o[-1, 0] - o[-1, 1], p[-1, 0] - p[-1, 1], b[-1, 0] - b[-1, 1]
rec.append(abs(sp - so) <= 0.1 * abs(so))
wrong.append(np.sign(sb) != tr)
wrong_ctrl.append(np.sign(so) != tr)
undecided.append(abs(sb) < 0.5 * abs(so))
rows.append({"model": "modular attractor", "noise": noise, "trial": tr, "runs": 100,
"unilateral_recovered": np.mean(rec), "bilateral_wrong_fixed_point": np.mean(wrong),
"bilateral_not_settled_at_2s": np.mean(undecided), "control_wrong": np.mean(wrong_ctrl)})
for tr in (1, -1):
o = models.run_integrator(tr, None)
p = models.run_integrator(tr, [0, 1, 2, 3])
b = models.run_integrator(tr, list(range(8)))
so, sp, sb = o[-1, 0] - o[-1, 1], p[-1, 0] - p[-1, 1], b[-1, 0] - b[-1, 1]
rows.append({"model": "modular integrator", "noise": "none", "trial": tr, "runs": 1,
"unilateral_recovered": float(abs(sp - so) <= 0.1 * abs(so)), "bilateral_wrong_fixed_point": float(np.sign(sb) != tr),
"selectivity_unperturbed": so, "selectivity_after_unilateral": sp, "selectivity_after_bilateral": sb})
m6 = pd.DataFrame(rows)
print(m6.round(3).to_string(index=False))
# Bilateral silencing run to 4 s, so that the attractor settles (noise drawn each step).
rows = []
for tr in (1, -1):
end = []
for i in range(100):
seed = 30_000 + 100 * (tr + 1) + i
o = models.run_attractor(tr, None, np.random.default_rng(seed), t_end=4.0)
b = models.run_attractor(tr, [0, 1, 2, 3], np.random.default_rng(seed), t_end=4.0)
so = o[-1, 0] - o[-1, 1]
end.append({"at_2s": b[1999, 0] - b[1999, 1], "at_4s": b[-1, 0] - b[-1, 1], "so": so})
e = pd.DataFrame(end)
settled = e.at_4s.abs() >= 0.5 * e.so.abs()
rows.append({"trial": tr, "runs": len(e), "settled_at_2s": float((e.at_2s.abs() >= 0.5 * e.so.abs()).mean()), "settled_at_4s": float(settled.mean()),
"right_fixed_point_at_4s": float((settled & (np.sign(e.at_4s) == 1)).mean()), "left_fixed_point_at_4s": float((settled & (np.sign(e.at_4s) == -1)).mean()),
"wrong_fixed_point_at_4s": float((settled & (np.sign(e.at_4s) != tr)).mean()),
"wrong_among_settled": float((np.sign(e.at_4s[settled]) != tr).mean()) if settled.any() else np.nan})
print("\nModular attractor, bilateral silencing, run to 4 s (settled: |R - L| at least half the unperturbed value):")
print(pd.DataFrame(rows).round(3).to_string(index=False))
model noise trial runs unilateral_recovered bilateral_wrong_fixed_point bilateral_not_settled_at_2s control_wrong selectivity_unperturbed selectivity_after_unilateral selectivity_after_bilateral modular attractor step 1 100 1.00 0.45 0.80 0.00 NaN NaN NaN modular attractor step -1 100 0.98 0.63 0.83 0.00 NaN NaN NaN modular attractor time 1 100 0.50 0.41 0.14 0.45 NaN NaN NaN modular attractor time -1 100 0.43 0.61 0.14 0.49 NaN NaN NaN modular integrator none 1 1 1.00 0.00 NaN NaN 14.401 13.619 7.201 modular integrator none -1 1 0.00 0.00 NaN NaN -14.400 -7.200 -7.200
Modular attractor, bilateral silencing, run to 4 s (settled: |R - L| at least half the unperturbed value):
trial runs settled_at_2s settled_at_4s right_fixed_point_at_4s left_fixed_point_at_4s wrong_fixed_point_at_4s wrong_among_settled
1 100 0.23 1.0 0.53 0.47 0.47 0.47
-1 100 0.25 1.0 0.55 0.45 0.55 0.55
Result: not reproduced. With noise drawn each step, the modular attractor recovers after unilateral silencing in 100% and 98% of runs (lick right and lick left). After bilateral silencing it ends at the wrong fixed point at 2 s in 45% and 63% of runs, but 80% and 83% of those runs have not settled; run to 4 s, every run settles, at the wrong fixed point in 47% and 55%, within 25% to 75%. With noise of the same intensity per unit time the unperturbed attractor already ends at the wrong fixed point in 45% to 49% of runs. The modular integrator with the printed matrix recovers on lick right trials (selectivity 13.6 against 14.4) but not on lick left trials (-7.2 against -14.4). The attractor part of the criterion holds; the integrator part holds for one trial type, so the integrator recovers in 50% of trial types where the criterion needs 90% of runs. The criterion has no partial rule, so by the rule applied to the other criteria without one this result is not reproduced; the verifier agreed in its third round. Whether the printed matrix lacks part of the network of Fig. 6c is a question about the paper's methods and does not make the outcome partial.
print(f"Notebook run time: {time.time() - started:.0f} s from the start of loading.")
Notebook run time: 464 s from the start of loading.
Summary¶
A failure to reproduce here may be a failure of this attempt, not of the paper: see the reasoning and the differences from the paper's method.
| Claim | Outcome |
|---|---|
| units-and-sessions | not reproduced (FS count 89 against 72; the other five counts exact) |
| ed1-selective-fraction | reproduced |
| fig1d-late-delay-ipsilateral-bias | blocked: data missing |
| fig1d-earlier-photoinhibition-minimal | reproduced |
| ed3-recovery-interval | blocked: data missing |
| ed2b-silencing | reproduced |
| ed2d-spatial-extent | blocked: data missing |
| ed2e-no-rebound | not reproduced (more neurons significantly excited than suppressed) |
| fig1f-rate-recovery | partially reproduced |
| fig1g-selectivity-recovery | partially reproduced (times match; 66 to 160 neurons against 55) |
| ed4-return-to-trajectory | not reproduced |
| ed5-photoactivation | blocked: data missing |
| fig2b-bilateral-behaviour | partially reproduced |
| ed6-bilateral-bias-inconsistent | reproduced (under reading b only) |
| fig2-bilateral-recovery | partially reproduced (ipsilateral recovery in 6 of 64 readings; bilateral rate 11% above control) |
| ed7-unilateral-4-spots-bilateral-1-spot | not reproduced (bilateral 1-spot selectivity recovers) |
| ed7e-size-and-roc | not reproduced (bilateral 1-spot ROC above tolerance) |
| fig3-cd-roc | reproduced |
| ed8-roc-during-photoinhibition | reproduced |
| ed9b-cd-stability | reproduced |
| ed8a-mode-variance | partially reproduced |
| fig3-cd-predicts-movement | reproduced |
| fig3-other-modes | not reproduced |
| ed9f-reaction-time | blocked: data missing (no licks in the Experiment 2 lick traces) |
| fig5b-callosotomy-behaviour | partially reproduced (after the cut only) |
| fig5-callosotomy-recovery | reproduced |
| ed10e-callosotomy-preparatory-activity | not reproduced (519 neurons against 496; fraction 14 points lower) |
| models-monolithic-fail | partially reproduced (three of five models simulated) |
| fig6-modular-models-robust | not reproduced (the integrator recovers on one trial type only) |
How the analysis differs from the paper's. Open method details are taken from the authors'
MATLAB scripts deposited in the data set: trial selection (correct and error trials, stable trials,
lick-early trials dropped), the preference screening, the recovery-time bootstrap, the neuron
selections and the population session rule. The scripts reproduce several of the paper's counts
exactly (168, 168 and 175 neurons in Fig. 1f; 16 sessions in Fig. 3 and Fig. 5f). The coding
direction is the mean difference of the Methods; the scripts' linear discriminant is shown as a
variant. Every reading of the preference screening and of the neuron selection (the scripts' or the
claims file's) is run for the recovery times, and a recovery time counts only when most bootstrap
resamples recover. The population session rule keeps groups of 5 trials, as the scripts do, which
gives the paper's 16 sessions; the Methods' "> 5 trials" gives 12. Rates and PSTHs are computed from
10 ms bins, and recovery times are resolved to 10 ms.
Behavioural claims use the recording sessions, as the behaviour-only sessions are not in the data
set. The network simulations use standard choices where the Methods leave details open
(models.py).
What was found about the data set. It holds what its description says: 91 sessions from 19
mice, 1012 single units in the 58 non-callosotomy sessions and 567 in the 33 callosotomy
sessions, with trial tables, photostimulus types whose laser timing matches their description,
and the gene modification of each mouse in the meta data files. The FS labels do not match the
paper's count (89 against 72) or the deposited waveforms' widths. The units have no depth
field, which the description lists. The lick trace shows no licks in 48 of 90 sessions, all 26
Experiment 2 sessions among them, so reaction times cannot be measured there. In four sessions
photoinhibition does not reduce activity, so the clock check by the laser fails there. Type 9 is
still described in the files as "Right ALM (ipsilateral)", which the FAQ says is contralateral.
One callosotomy session has no performing trials. The behaviour-only sessions, the photoactivation
data, the recordings in untrained mice and the simulations named in the title are not in the data
set.