Reproducing McGuire, Telian, Laboy-Juarez et al. (2016) from CRCNS ssc-4: behaviour and single units¶
Paper: McGuire LM, Telian G, Laboy-Juarez KJ, Miyashita T, Lee DJ, Smith KA, Feldman DE (2016), "Short Time-Scale Sensory Coding in S1 during Discrimination of Whisker Vibrotactile Sequences", PLoS Biology 14(8) e1002549, doi:10.1371/journal.pbio.1002549.
Dataset: CRCNS ssc-4 (doi:10.6080/K06D5QXN), the single file ssc-4/live/AllRats.mat, streamed
from the public bucket crcnsarchive. Version: CRCNS data sets are not versioned, so the version
is recorded as unversioned and the file is pinned by the MD5 sum in the data set's
checksums.md5, a929b803ca0feab5270e807f571d13eb (printed below from the bucket). There is only
this one version of the data set in the bucket (live/, no old/), so it is the one pinned; the
paper cites the data set by accession only. Outside inputs: the paper's supporting information
S1 Data (doi:10.1371/journal.pbio.1002549.s001) and S2 Data (doi:10.1371/journal.pbio.1002549.s002),
read for the three claims whose data are there (data: elsewhere) and as variants, and the
paper's S1 Table (doi:10.1371/journal.pbio.1002549.s010), set beside the baseline rates as a variant.
This is the second run of the notebook, revised after the verifier's first report: the claims that depend on temporal modulation now use the data set's own modulated units, with the set recomputed by the Methods' test as a variant (see the note after temporal-modulation-count).
The claims file (claims/mcguire-2016.yaml) was written from the version of record (Europe PMC,
PMC5004814) with the Methods and the supporting legends.
This notebook covers the behavioural and single-unit claims. The decoders (Figure 9) are in
decoders.ipynb, which uses the same helper (ssc4.py).
| claim | here |
|---|---|
| fig2ab-fms-smf-not-discriminated | tested (5 of 8 rats in the data) |
| training-days | tested (5 of 8 rats) |
| fig2c-choice-follows-mean-speed | tested (5 of 8 rats) |
| fig2d-fixed-panel-impairs | tested on S2 Data (elsewhere), after a reader's answer |
| dprime-fff-sss-range | tested (5 of 8 rats) |
| fig3-fsfs-sffs-intensity-only | tested on S1 Data (elsewhere) |
| units-recorded | tested |
| baseline-rates | tested |
| temporal-modulation-count | tested |
| modulated-higher-baseline | tested |
| fig4d-evoked-modulation-by-layer | tested |
| latency-by-layer | tested |
| fig4d-gradual-decrease | tested |
| fig6-regression-significant | tested |
| fig6e-unit-classes | tested |
| fig6fg-laminar-classes | tested |
| fig7c-fast-impulse-velocity | tested |
| fig7c-fast-sequence-rate | tested |
| fig7-fff-adaptation | tested |
| fig7-sss-no-adaptation | tested |
| s4-fms-middle-pulse | tested |
| fig7de-medium-suppressed | tested |
| fig8a-slow-positive-no-sequence-difference | tested |
| fig8b-slow-negative-no-impulse-response | tested |
| fig8d-slow-positive-right-choice-l5 | tested |
| fig8d-fast-medium-no-choice-bias | tested |
| fig8e-choice-divergence-125ms | tested |
| s5-slow-positive-no-integration | tested |
| s6-head-position-choice | tested on S2 Data (elsewhere) |
| s7-no-fs-l5-slow-positive | tested |
| fig9b, fig9c, fig9d, fig9e, fig9f, fig9g (seven claims) | in decoders.ipynb |
import collections, warnings
import numpy as np, pandas as pd, fsspec
from scipy import stats
from statsmodels.stats.proportion import proportions_ztest
from scipy.stats import chi2_contingency
import ssc4
warnings.filterwarnings("ignore", category=UserWarning)
pd.set_option("display.width", 200)
pd.set_option("display.max_columns", 40)
print(fsspec.open("https://crcnsarchive.s3-us-west-2.amazonaws.com/ssc-4/live/checksums.md5").open().read().decode())
D = ssc4.Data(ssc4.load_mat())
T, U = D.trials, D.units
S1 = ssc4.fetch_xlsx(ssc4.S1_DATA)
S2 = ssc4.fetch_xlsx(ssc4.S2_DATA)
print("S1 Data sheets", list(S1), "S2 Data sheets", list(S2))
a929b803ca0feab5270e807f571d13eb AllRats.mat 5302f4f1dd7055fc72484b6ea7dab402 docs/crcns_ssc-4_data_description.docx 71ab6b260e031c252a2af1db85c5b620 docs/crcns_ssc-4_data_description.pdf b8c483faa24ce741b46372230f86bc43 filelist.txt
S1 Data sheets ['Fig 1', 'Fig 2', 'Fig 3', 'Fig 6 A-C', 'Fig 6D-G', 'Fig 9'] S2 Data sheets ['Fig S1', 'Fig S2', 'Fig S6']
Data check¶
print("sessions", len(D.A), "rats", T.rat.nunique())
print(T.groupby("rat").agg(sessions=("session", "nunique"), days=("date", "nunique"), trials=("trial", "size")))
print("\ntrials by sequence (StimNumber) and outcome")
T["outcome"] = np.select([T.complete, T.withdrew, T.timeout], ["choice", "early withdrawal", "no choice"], "other")
print(pd.crosstab(T.stim, T.outcome, margins=True))
print("\nStimName irregular names, by the StimNumber they carry (the descriptor says to use StimNumber)")
irr = T[~T.stim_name.isin(ssc4.STIMS)]
print(pd.crosstab(irr.stim_name, irr.stim))
print("\nchosen port codes", T.chosen.value_counts().to_dict(), " target codes", T.target.value_counts().to_dict())
print("completed trials with nose poke <= 250 ms:", int((T.complete & (T.np_dur <= 250)).sum()))
print("nose poke duration (ms), completed trials: min %.0f, median %.0f, max %.0f" % tuple(T[T.complete].np_dur.quantile([0, .5, 1])))
print("stimulus onset delay (ms): min %.0f max %.0f (Methods: 75-100)" % (T.delay.min(), T.delay.max()))
print("required nose poke (ms)", T.np_req.value_counts().to_dict())
print("\nunits", len(U))
print(pd.crosstab(U.layer, U.type, margins=True))
print("depth range (um) %.0f to %.0f" % (U.depth.min(), U.depth.max()))
print("electrodes per session", collections.Counter(len(np.atleast_1d(e.HistDepth)) for e in D.A))
print("distinct depths across electrodes within a session:", max(len(set(np.atleast_1d(e.HistDepth).round(3))) for e in D.A))
print("\nimpulse onset sets (ms) across sessions, StimTimes[:,0] by sequence FMS SMF FFF SSS:")
sets = collections.Counter(str([D.stimtimes[s][k][:, 0].tolist() for k in range(4)]) for s in range(len(D.A)))
for k, v in sets.items():
ss = [s for s in range(len(D.A)) if str([D.stimtimes[s][j][:, 0].tolist() for j in range(4)]) == k]
print(v, "sessions", k, "rats", sorted(set(T[T.session.isin(ss)].rat)))
print("\nfields of a session:", D.A[0]._fieldnames)
print("MapPosition (column of each electrode, named in the descriptor) present:", "MapPosition" in D.A[0]._fieldnames)
print("deposited labels", U.dep_label.value_counts().to_dict())
print("deposited TemporalPval < 0.05:", int((U.dep_temp_p < 0.05).sum()))
print("TempSig.Params:", {k: getattr(D.A[0].TempSig.Params, k) for k in D.A[0].TempSig.Params._fieldnames})
spk_all = np.concatenate([M.sum(axis=(0, 2)) for M in D.spk])
print("spikes per unit in the -100..400 ms span: min %d, median %d" % (spk_all.min(), np.median(spk_all)))
sessions 80 rats 5
sessions days trials
rat
107St 12 12 2541
18FB 12 11 2109
18Ri 15 12 3506
18Ro 19 19 4174
62BS 22 20 5742
trials by sequence (StimNumber) and outcome
outcome choice early withdrawal no choice All
stim
FFF 3482 956 27 4465
FMS 3547 949 34 4530
SMF 3599 927 27 4553
SSS 3558 928 38 4524
All 14186 3760 126 18072
StimName irregular names, by the StimNumber they carry (the descriptor says to use StimNumber)
stim FFF FMS SMF SSS
stim_name
Stim0_isi30_5/17.25/4.5_9/21.25/5_15/27.25/6.1 0 428 0 0
Stim1_isi30_15/27.25/6.1_9/21.25/5_5/17.25/4.5 0 0 406 0
Stim2_isi30_15/27.25/6.1 0 0 0 363
Stim2_isi30_5/17.25/4.5 372 0 0 0
chosen port codes {0: 7596, 1: 6590, -1: 3886} target codes {0: 9077, 1: 8995}
completed trials with nose poke <= 250 ms: 0
nose poke duration (ms), completed trials: min 252, median 280, max 444
stimulus onset delay (ms): min 75 max 99 (Methods: 75-100)
required nose poke (ms) {250: 18062, 300: 10}
units 506
type MU SU_FS SU_RS All
layer
L2/3 26 5 10 41
L4 53 15 58 126
L5a 34 8 77 119
L5b 31 16 67 114
L6 32 29 45 106
All 176 73 257 506
depth range (um) 480 to 2052
electrodes per session Counter({4: 53, 5: 27})
distinct depths across electrodes within a session: 1
impulse onset sets (ms) across sessions, StimTimes[:,0] by sequence FMS SMF FFF SSS:
32 sessions [[0.0, 50.25, 105.5], [0.0, 60.25, 115.5], [0.0, 50.25, 100.5], [0.0, 60.25, 120.5]] rats ['18FB', '18Ri', '18Ro']
26 sessions [[0.0, 47.25, 99.5], [0.0, 57.25, 109.5], [0.0, 47.25, 94.5], [0.0, 57.25, 114.5]] rats ['107St', '18Ri', '18Ro']
22 sessions [[0.0, 47.25, 98.5], [0.0, 57.25, 108.5], [0.0, 47.25, 94.5], [0.0, 57.25, 114.5]] rats ['62BS']
fields of a session: ['Trialn', 'StartTime', 'NPDuration', 'NPTimeReq', 'StimOnsetDelay', 'StimNumber', 'StimName', 'TargetDP', 'ChosenDP', 'Complete', 'Withdrew', 'Timeout', 'Correct', 'DPopentime', 'HistDepth', 'RecName', 'RecTime', 'TrialCells', 'TempSig', 'StimReg', 'BestBin', 'RatName', 'StimTimes', 'TrialCellInfo', 'LongShortInfo']
MapPosition (column of each electrode, named in the descriptor) present: False
deposited labels {'NoTempMod': 195, 'FastPos': 166, 'SlowPos': 51, 'FastNeg': 47, 'SlowNeg': 46, 'ImproperPeakBin': 1}
deposited TemporalPval < 0.05: 310
TempSig.Params: {'window': 10, 'starttime': -50, 'endtime': 300, 'nperm': 10000}
spikes per unit in the -100..400 ms span: min 2, median 1182
Checks of the description against the values¶
- The regression inputs deposited with each unit (
StimReg(...).Yval) against spike counts fromTrialCells, to find which trials the authors analysed. - The regressor (
Xval) is the same for every unit and session. - The deposited regression R2 and p against a fresh OLS fit.
- Recordings deposited twice: identical trial tables or spike trains across sessions.
- Columns: the descriptor says to drop units in columns A1 and B2 using
MapPosition.
sel_names = {"all trials": lambda t: np.ones(len(t), bool), "nose poke > 250 ms": lambda t: (t.np_dur > 250).values,
"completed": lambda t: t.complete.values}
match = collections.Counter()
for uid in U.uid:
r = U.iloc[uid]
Y = np.asarray(np.atleast_2d(D.A[r.session].StimReg)[r.unit][0].Yval).reshape(4, 36)
for name, f in sel_names.items():
M, t, _ = D.unit_trials(uid, f)
C = np.stack([M[(t.stim == s).values, -ssc4.T0:180 - ssc4.T0].reshape(-1, 36, 5).sum((0, 2)) for s in ssc4.STIMS])
match[name] += int(np.array_equal(C, Y))
print("units whose deposited Yval equals the summed counts, by trial selection:", dict(match), "of", len(U))
tset = {si: str([D.stimtimes[si][k][:, 0].tolist() for k in range(4)]) for si in range(len(D.A))}
X0 = {}
dx = collections.defaultdict(float)
for r in U.itertuples():
x = np.array([np.asarray(np.atleast_2d(D.A[r.session].StimReg)[r.unit][w].Xval)[:, 1] for w in range(36)])
k = tset[r.session]
X0.setdefault(k, x)
dx[k] = max(dx[k], np.abs(x - X0[k]).max())
print("largest difference of Xval between units, within each impulse-timing set:", [round(v, 6) for v in dx.values()])
print("between timing sets, largest difference:", round(float(np.abs(np.subtract(*list(X0.values())[:2])).max()), 1))
R2, P, B = ssc4.regress_all(D)
dep = np.array([[np.atleast_2d(D.A[r.session].StimReg)[r.unit][w].Regress.Stats[[0, 2]] for w in range(36)] for r in U.itertuples()])
print("units with no spikes in 0-180 ms (regression undefined):", int(np.isnan(R2).all(1).sum()))
print("max |R2 - deposited R2| = %.2e, max |log10 p - deposited| = %.2e" % (np.nanmax(np.abs(R2 - dep[..., 0])),
np.nanmax(np.abs(np.log10(P + 1e-300) - np.log10(dep[..., 1] + 1e-300)))))
R2 = np.nan_to_num(R2, nan=0.0); P = np.nan_to_num(P, nan=1.0); B = np.nan_to_num(B)
dep_best = U.dep_peakbin.values
same = (R2.argmax(1) + 1) * 5 == dep_best
print("best window (highest R2) equals deposited PeakBin for", int(same.sum()), "of", len(U), "units; the others:",
U.loc[~same, ["session", "unit", "dep_label", "dep_peakbin"]].to_dict("records"))
fp = T.groupby("session").apply(lambda t: hash((tuple(t.np_dur), tuple(t.stim), tuple(t.delay))))
print("sessions sharing a trial table with another:", int(fp.duplicated(keep=False).sum()))
sp = {}
for r in U.itertuples():
M = D.spk[r.session][:, r.unit, :]
sp.setdefault(hash(M[:20].tobytes()), []).append((r.session, r.unit))
print("unit pairs with identical spike matrices over the first 20 trials:", [v for v in sp.values() if len(v) > 1])
units whose deposited Yval equals the summed counts, by trial selection: {'all trials': 1, 'nose poke > 250 ms': 204, 'completed': 506} of 506
largest difference of Xval between units, within each impulse-timing set: [0.0, np.float64(11291.47), 0.0]
between timing sets, largest difference: 11291.5
units with no spikes in 0-180 ms (regression undefined): 1
max |R2 - deposited R2| = 1.63e-15, max |log10 p - deposited| = 1.82e-13
best window (highest R2) equals deposited PeakBin for 505 of 506 units; the others: [{'session': 6, 'unit': 3, 'dep_label': 'ImproperPeakBin', 'dep_peakbin': nan}]
sessions sharing a trial table with another: 0
unit pairs with identical spike matrices over the first 20 trials: []
What the checks show (numbers above):
- The stored regression inputs equal the spike counts summed over completed trials for all 506 units (204 units for nose poke > 250 ms, 1 for all trials). The authors' unit analyses used completed trials, and so does this notebook.
- The stored regressor is identical across units within two of the three impulse-timing sets and differs within the third; each unit's own stored regressor is used. A fresh fit reproduces the stored R2 and p to numerical precision; one unit has no spikes from 0 to 180 ms (stored label ImproperPeakBin).
- No two sessions share a trial table and no two units share spikes: no recording is deposited twice. The paper says a new set of units was sampled in every session (Methods, Neural Recordings), so units are counted once per session, an assumption the data cannot check.
- The data set holds 506 units (330 single, 176 multi) where the paper reports 473 (306, 167).
The descriptor says units in columns A1 and B2 must be dropped using
MapPosition, which the file does not contain; leaving out the fifth electrode of 18FB and 18Ri gives 459, not 473. The extra units cannot be identified. - The stored temporal-modulation p-values were computed with a -50 to 300 ms window
(
TempSig.Params), where the Methods say 0 to 180 ms after nose poke entry. - The impulse onsets differ between sessions: in 32 sessions (18FB, 18Ri, 18Ro) the second impulse starts at 50.25 or 60.25 ms, in 48 (all rats but 18FB) at 47.25 or 57.25 ms; each session's own onsets are used.
- Withdrawal times (nose poke duration minus onset delay) and the descriptor's trial fields are consistent with the Methods: delays 75 to 99 ms, completed trials all held over 250 ms.
Clock of the spikes against the trial table¶
Spike times are said to be in ms from the first impulse onset. The second impulse starts about 50 ms after the first in FFF and FMS (the F-first sequences) and about 60 ms after it in SMF and SSS. If the spikes share the trial clock, the population rate 55 to 60 ms after onset (an early response to impulse 2 at 50 ms) is higher in FFF and FMS trials than in SMF and SSS trials, and a window before stimulus onset shows no such difference.
def group_contrast(a, b):
out = []
for si, M in enumerate(D.spk):
t = T[T.session == si]
m = t.complete.values
st = t.stim.values[m]
r = M[m][:, :, a - ssc4.T0:b - ssc4.T0].sum((1, 2)) * 1000 / (b - a)
out.append(r[np.isin(st, ["FFF", "FMS"])].mean() - r[np.isin(st, ["SMF", "SSS"])].mean())
return np.array(out)
for a, b in [(55, 60), (-60, -55)]:
d = group_contrast(a, b)
print("window %d to %d ms: sessions with F-first > S-first rate %d of %d; mean difference %.1f Hz (summed over units); sign test p = %.2g"
% (a, b, (d > 0).sum(), len(d), d.mean(), stats.binomtest(int((d > 0).sum()), len(d)).pvalue))
for rat in sorted(T.rat.unique()):
ss = sorted(T[T.rat == rat].session.unique())
d = group_contrast(55, 60)[ss]
print(" %s: %d of %d sessions F-first higher" % (rat, (d > 0).sum(), len(d)))
window 55 to 60 ms: sessions with F-first > S-first rate 61 of 80; mean difference 18.4 Hz (summed over units); sign test p = 2.7e-06 window -60 to -55 ms: sessions with F-first > S-first rate 35 of 80; mean difference -0.1 Hz (summed over units); sign test p = 0.31
107St: 10 of 12 sessions F-first higher 18FB: 10 of 12 sessions F-first higher 18Ri: 13 of 15 sessions F-first higher 18Ro: 11 of 19 sessions F-first higher
62BS: 17 of 22 sessions F-first higher
The response to impulse 2 is earlier in F-first sequences in 61 of 80 sessions (sign test p = 2.7e-06), and a window before onset shows no difference (35 of 80, p = 0.31): consistent with spikes and trial table sharing one clock. By rat this holds in 10 to 17 sessions of 12 to 22, and in 18Ro in 11 of 19, where the check is weak.
Behaviour (Figure 2)¶
Only the five recorded rats are in the data set (18FB, 18Ri, 18Ro, 62BS, 107St); the paper's behaviour is from eight rats, and 62SC, 107Si and 62SS are not here. A trial enters when the rat chose a port. The two trial readings of fig2ab-fms-smf-not-discriminated are (i) every trial with a choice and (ii) completed trials with no premature withdrawal and nose poke over 250 ms.
def behav_trials(reading):
t = T[T.chosen >= 0]
if reading == "ii":
t = t[t.complete & ~t.withdrew & (t.np_dur > 250)]
return t
for rd in ["i", "ii"]:
print("reading", rd, "trials", len(behav_trials(rd)))
bt = behav_trials("i")
frac = bt.groupby(["rat", "stim"]).chosen.mean().unstack()[["FFF", "FMS", "SMF", "SSS"]]
ntr = bt.groupby(["rat", "stim"]).chosen.size().unstack()[["FFF", "FMS", "SMF", "SSS"]]
print("\nfraction of right choices, all sessions pooled (reading i)\n", frac.round(3))
print("\ntrials\n", ntr)
reading i trials 14186 reading ii trials 14186 fraction of right choices, all sessions pooled (reading i) stim FFF FMS SMF SSS rat 107St 0.579 0.410 0.415 0.347 18FB 0.537 0.456 0.477 0.360 18Ri 0.698 0.471 0.497 0.308 18Ro 0.641 0.394 0.370 0.234 62BS 0.641 0.510 0.477 0.390 trials stim FFF FMS SMF SSS rat 107St 463 478 467 501 18FB 402 388 434 420 18Ri 590 618 604 584 18Ro 861 835 873 869 62BS 1166 1228 1221 1184
fig2ab-fms-smf-not-discriminated¶
All eight rats discriminated FFF from SSS but treated FMS and SMF as equivalent and intermediate; seven of eight showed no difference between FMS and SMF, and one rat (62SC) made more right choices to FMS than to SMF.
rows = []
for rd in ["i", "ii"]:
bt = behav_trials(rd)
for rat, t in bt.groupby("rat"):
f = t.groupby("stim").chosen.agg(["sum", "size"])
p = f["sum"] / f["size"]
cnt, nob = f.loc[["FMS", "SMF"], "sum"].values, f.loc[["FMS", "SMF"], "size"].values
z, pz = proportions_ztest(cnt, nob)
tab = np.array([cnt, nob - cnt])
chi_c = chi2_contingency(tab, correction=True)[1]
rows.append(dict(reading=rd, rat=rat, FFF=p.FFF, FMS=p.FMS, SMF=p.SMF, SSS=p.SSS,
FFF_gt_SSS=p.FFF > p.SSS,
between=(min(p.FMS, p.SMF) > p.SSS) and (max(p.FMS, p.SMF) < p.FFF),
FMS_minus_SMF=p.FMS - p.SMF, p_z=pz, p_chi2_corrected=chi_c,
sig_z=pz < 0.00625, sig_chi=chi_c < 0.00625))
fig2ab = pd.DataFrame(rows)
print(fig2ab.round(4).to_string())
print("\n62SC is not in the data set:", "62SC" not in set(T.rat))
print("\nVariant: the paper's own per-rat means (S1 Data, Figure 2B, mean over sessions), against the same from the data set")
f2 = S1["Fig 2"]
paper2b = pd.DataFrame(f2.iloc[23:31, 1:5].values.astype(float), index=f2.iloc[23:31, 0], columns=["FFF", "FMS", "SMF", "SSS"])
bt = behav_trials("i")
sess = bt.groupby(["rat", "session", "stim"]).chosen.mean().unstack().groupby("rat").mean()[["FFF", "FMS", "SMF", "SSS"]]
name = {"18FB": "18FB", "18Ri": "18Ri", "18Ro": "18Ro", "62BS": "62BS", "107St": "107ST"}
cmp = pd.concat({"data set (mean of sessions)": sess.rename(index=name), "S1 Data": paper2b.loc[[name[r] for r in sess.index]]}, axis=1)
print(cmp.round(3))
print("largest absolute difference: %.3f" % np.abs(cmp["data set (mean of sessions)"].values - cmp["S1 Data"].values).max())
print("\nS1 Data, all eight rats: FFF > SSS for", int((paper2b.FFF > paper2b.SSS).sum()), "of 8; FMS and SMF between for",
int(((paper2b[["FMS", "SMF"]].min(axis=1) > paper2b.SSS) & (paper2b[["FMS", "SMF"]].max(axis=1) < paper2b.FFF)).sum()), "of 8")
reading rat FFF FMS SMF SSS FFF_gt_SSS between FMS_minus_SMF p_z p_chi2_corrected sig_z sig_chi
0 i 107St 0.5788 0.4100 0.4154 0.3473 True True -0.0054 0.8667 0.9190 False False
1 i 18FB 0.5373 0.4562 0.4770 0.3595 True True -0.0208 0.5512 0.5990 False False
2 i 18Ri 0.6983 0.4709 0.4967 0.3082 True True -0.0258 0.3666 0.3978 False False
3 i 18Ro 0.6411 0.3940 0.3700 0.2336 True True 0.0240 0.3070 0.3312 False False
4 i 62BS 0.6407 0.5098 0.4767 0.3902 True True 0.0331 0.1012 0.1099 False False
5 ii 107St 0.5788 0.4100 0.4154 0.3473 True True -0.0054 0.8667 0.9190 False False
6 ii 18FB 0.5373 0.4562 0.4770 0.3595 True True -0.0208 0.5512 0.5990 False False
7 ii 18Ri 0.6983 0.4709 0.4967 0.3082 True True -0.0258 0.3666 0.3978 False False
8 ii 18Ro 0.6411 0.3940 0.3700 0.2336 True True 0.0240 0.3070 0.3312 False False
9 ii 62BS 0.6407 0.5098 0.4767 0.3902 True True 0.0331 0.1012 0.1099 False False
62SC is not in the data set: True
Variant: the paper's own per-rat means (S1 Data, Figure 2B, mean over sessions), against the same from the data set
data set (mean of sessions) S1 Data
stim FFF FMS SMF SSS FFF FMS SMF SSS
107ST 0.586 0.404 0.431 0.346 0.586 0.404 0.431 0.346
18FB 0.530 0.445 0.470 0.354 0.554 0.472 0.495 0.356
18Ri 0.695 0.461 0.508 0.302 0.695 0.461 0.508 0.302
18Ro 0.656 0.395 0.375 0.242 0.656 0.395 0.375 0.242
62BS 0.643 0.521 0.472 0.393 0.643 0.521 0.472 0.393
largest absolute difference: 0.026
S1 Data, all eight rats: FFF > SSS for 8 of 8; FMS and SMF between for 8 of 8
Result: partially reproduced. In all five rats the data hold, FFF draws more right choices than SSS and FMS and SMF lie between them, and FMS against SMF is not significant at 0.00625 in any of them (smallest p 0.10 without and 0.11 with continuity correction, 62BS), under both trial readings, which select the same 14186 trials. Rat 62SC, the one the paper finds discriminating FMS from SMF, is not in the data set, nor are two other behaviour-only rats, so the claim is tested on 5 of 8 rats. The data set's per-rat means of sessions equal the S1 Data values for four rats and differ by up to 0.026 for 18FB.
training-days¶
Rats trained on FFF-FMS-SMF-SSS discrimination for 14.2 days on average (s.d. 4.4, range 8 to 22).
days = T.groupby("rat").date.nunique()
sess = T.groupby("rat").session.nunique()
print(pd.DataFrame(dict(distinct_dates=days, sessions=sess)).to_string())
for nm, d in [("distinct recording dates", days), ("sessions (the paper's '12-22 d of recording' matches these)", sess)]:
print("%s: mean %.1f, s.d. %.1f, min %d, max %d (n = %d rats)" % (nm, d.mean(), d.std(), d.min(), d.max(), len(d)))
print("first and last recording date per rat:")
print(T.groupby("rat").date.agg(["min", "max"]))
distinct_dates sessions
rat
107St 12 12
18FB 11 12
18Ri 12 15
18Ro 19 19
62BS 20 22
distinct recording dates: mean 14.8, s.d. 4.3, min 11, max 20 (n = 5 rats)
sessions (the paper's '12-22 d of recording' matches these): mean 16.0, s.d. 4.4, min 12, max 22 (n = 5 rats)
first and last recording date per rat:
min max
rat
107St 2011-10-01 2011-10-12
18FB 2011-10-14 2011-10-24
18Ri 2011-10-13 2011-10-24
18Ro 2011-10-01 2011-10-19
62BS 2011-08-01 2011-08-20
Result: partially reproduced. Counting distinct recording dates, the five rats in the data set have 11 to 20 days, mean 14.8 (s.d. 4.3): the mean and the maximum are within tolerance of 14.2 and 22, the minimum (11) is not within 0.8 of 8. Counting sessions, which match the paper's "12-22 d of recording", gives 12 to 22, mean 16.0: the minimum is still outside. The data hold only the recording days of five of the eight rats.
fig2c-choice-follows-mean-speed¶
Relative right-port choice (fraction of right choices for a stimulus minus the mean over all stimuli) was strongly related to the mean speed of the sequence for all rats.
speed = pd.Series(ssc4.MEAN_SPEED)[["FFF", "FMS", "SMF", "SSS"]]
def fig2c_table(fr):
rel = fr.sub(fr.mean(axis=1), axis=0)
out = pd.DataFrame(dict(
order_a=(rel.FFF > rel[["FMS", "SMF"]].max(axis=1)) & (rel[["FMS", "SMF"]].min(axis=1) > rel.SSS),
r=[stats.pearsonr(speed.values, rel.loc[i].values)[0] for i in rel.index]))
out["r_gt_0.8"] = out.r > 0.8
return pd.concat([rel.round(3), out], axis=1)
for rd in ["i", "ii"]:
fr = behav_trials(rd).groupby(["rat", "stim"]).chosen.mean().unstack()[["FFF", "FMS", "SMF", "SSS"]]
print("reading", rd); print(fig2c_table(fr).round(3))
print("\nVariant, all eight rats from S1 Data Figure 2B means:")
print(fig2c_table(paper2b).round(3))
reading i
FFF FMS SMF SSS order_a r r_gt_0.8
rat
107St 0.141 -0.028 -0.022 -0.091 True 0.967 True
18FB 0.080 -0.001 0.019 -0.098 True 0.978 True
18Ri 0.205 -0.023 0.003 -0.185 True 0.998 True
18Ro 0.231 -0.016 -0.040 -0.176 True 0.986 True
62BS 0.136 0.005 -0.028 -0.114 True 0.986 True
reading ii
FFF FMS SMF SSS order_a r r_gt_0.8
rat
107St 0.141 -0.028 -0.022 -0.091 True 0.967 True
18FB 0.080 -0.001 0.019 -0.098 True 0.978 True
18Ri 0.205 -0.023 0.003 -0.185 True 0.998 True
18Ro 0.231 -0.016 -0.040 -0.176 True 0.986 True
62BS 0.136 0.005 -0.028 -0.114 True 0.986 True
Variant, all eight rats from S1 Data Figure 2B means:
FFF FMS SMF SSS order_a r r_gt_0.8
0
62BS 0.136 0.014 -0.035 -0.115 True 0.976 True
107ST 0.144 -0.038 -0.010 -0.096 True 0.968 True
18Ro 0.239 -0.022 -0.042 -0.175 True 0.983 True
18Ri 0.203 -0.030 0.016 -0.189 True 0.995 True
18FB 0.085 0.003 0.026 -0.113 True 0.967 True
107Si 0.229 0.028 -0.047 -0.211 True 0.983 True
62SS 0.248 0.019 -0.051 -0.216 True 0.985 True
62SC 0.180 0.051 -0.030 -0.200 True 0.968 True
Result: reproduced. For each of the five rats relative right choice orders FFF > FMS and SMF > SSS, and its Pearson correlation with mean speed is 0.967 to 0.998, under both trial readings. The S1 Data means of all eight rats give the same (r 0.967 to 0.995).
fig2d-fixed-panel-impairs (S2 Data, S2B Fig; S1 Data, Figure 2D)¶
Fixing the panel in place, with the piezo moving behind it, impaired FFF against SSS discrimination in all but one of six rats tested.
The data set holds only the four normal sequences (StimNumber 1 to 4, table above); the fixed-panel control was behaviour only and is not deposited. Following the reader's answer (questions/mcguire-2016.yaml), the claim is tested on the per-rat values of S2B Fig in S2 Data: FFF minus SSS right-choice fraction on normal (moving-panel) and fixed-panel trials, paired t test across rats, two-sided (S2B Fig legend). The rat at 0 enters under reading (ii) and is left out under reading (i). The d-prime of Figure 2D, from S1 Data, is a variant. A last check asks which normal sessions the moving-panel values summarise, by setting them beside the S1 Data Figure 2B means and the data set's sessions.
def paired(d, a, b):
dd = d[b] - d[a]
r = stats.ttest_rel(d[a], d[b])
ci = stats.t.interval(0.95, len(dd) - 1, dd.mean(), stats.sem(dd))
return "n = %d, fixed lower in %d of %d, mean change %.3f (95%% CI %.3f to %.3f), paired t = %.2f, p = %.4f" % (
len(d), (d[b] < d[a]).sum(), len(d), dd.mean(), *ci, r.statistic, r.pvalue)
s2b = S2["Fig S2"].iloc[38:41, 0:9]
s2b = pd.DataFrame(s2b.iloc[1:, 1:].values.astype(float), index=s2b.iloc[1:, 0].values, columns=s2b.iloc[0, 1:].values).T
s2b["fixed_minus_moving"] = s2b.FixedPanel - s2b.MovingPanel
print("S2 Data, S2B Fig: FFF minus SSS right-choice fraction per rat (range %.3f to %.3f)" % (s2b.iloc[:, :2].min().min(), s2b.iloc[:, :2].max().max()))
print(s2b.round(4))
both = s2b.dropna()
print("rats with a fixed-panel value:", len(both))
for nm, d in [("(ii) rat at 0 kept", both), ("(i) rat at 0 left out", both[both.FixedPanel > 0])]:
print("%s: %s" % (nm, paired(d, "MovingPanel", "FixedPanel")))
f2 = S1["Fig 2"]
dp = pd.DataFrame(f2.iloc[45:47, 2:10].values.astype(float), index=["normal", "fixed"], columns=f2.iloc[44, 2:10].values).T
print("\nVariant: S1 Data, Figure 2D d-prime per rat")
print(dp)
db = dp.dropna()
for nm, d in [("(ii) rat at 0 kept", db), ("(i) rat at 0 left out", db[db.fixed > 0])]:
print("%s: %s" % (nm, paired(d, "normal", "fixed")))
p2b = pd.DataFrame(f2.iloc[23:31, [1, 4]].values.astype(float), index=f2.iloc[23:31, 0].str.upper(), columns=["FFF", "SSS"])
ses = T[T.chosen >= 0].groupby(["rat", "session", "stim"]).chosen.mean().unstack()
ses = (ses.FFF - ses.SSS).rename("d").reset_index()
cmp = pd.DataFrame({"S2B moving panel": s2b.MovingPanel.rename(index=str.upper), "S1 2B means, FFF-SSS": p2b.FFF - p2b.SSS})
cmp["data set, mean of sessions"] = ses.groupby("rat").d.mean().rename(index=str.upper)
cmp["data set, last session"] = ses.sort_values("session").groupby("rat").d.last().rename(index=str.upper)
print("\nWhich normal sessions the moving-panel values summarise")
print(cmp.round(4))
a = f2.iloc[4:17, 1:5].values.astype(float); fx = f2.iloc[4:8, 6].values.astype(float)
print("\nS1 Data, Figure 2A sheet (labelled 'Rat 107ST'): mean FFF over its 13 days %.4f; fixed-panel FFF minus SSS %.4f, d-prime %.3f"
% (a[:, 0].mean(), fx[0] - fx[3], stats.norm.ppf(fx[0]) - stats.norm.ppf(fx[3])))
print("S1 Data, Figure 2B mean FFF fraction: 107ST %.4f, 107Si %.4f" % (paper2b.loc["107ST", "FFF"], paper2b.loc["107Si", "FFF"]))
S2 Data, S2B Fig: FFF minus SSS right-choice fraction per rat (range 0.000 to 0.473)
MovingPanel FixedPanel fixed_minus_moving
62BS 0.2376 0.0808 -0.1567
107ST 0.3077 0.1358 -0.1719
18Ro 0.2337 0.1317 -0.1019
18Ri 0.3700 0.3029 -0.0671
18FB 0.1414 0.0000 -0.1414
107SI 0.4728 0.0991 -0.3737
62SS 0.4645 NaN NaN
62SC 0.3798 NaN NaN
rats with a fixed-panel value: 6
(ii) rat at 0 kept: n = 6, fixed lower in 6 of 6, mean change -0.169 (95% CI -0.282 to -0.056), paired t = 3.85, p = 0.0120
(i) rat at 0 left out: n = 5, fixed lower in 5 of 5, mean change -0.174 (95% CI -0.322 to -0.026), paired t = 3.27, p = 0.0308
Variant: S1 Data, Figure 2D d-prime per rat
normal fixed
62BS 0.639 0.206
107ST 0.591 0.342
18Ro 1.090 0.370
18Ri 1.020 0.782
18FB 0.497 0.000
107Si 1.168 0.276
62SS 1.347 NaN
62SC 1.094 NaN
(ii) rat at 0 kept: n = 6, fixed lower in 6 of 6, mean change -0.505 (95% CI -0.778 to -0.232), paired t = 4.76, p = 0.0051
(i) rat at 0 left out: n = 5, fixed lower in 5 of 5, mean change -0.506 (95% CI -0.867 to -0.145), paired t = 3.90, p = 0.0176
Which normal sessions the moving-panel values summarise
S2B moving panel S1 2B means, FFF-SSS data set, mean of sessions data set, last session
62BS 0.2376 0.2502 0.2502 0.2492
107ST 0.3077 0.2399 0.2399 0.3750
18RO 0.2337 0.4141 0.4141 0.2798
18RI 0.3700 0.3926 0.3926 0.3291
18FB 0.1414 0.1988 0.1758 0.1586
107SI 0.4728 0.4401 NaN NaN
62SS 0.4645 0.4645 NaN NaN
62SC 0.3798 0.3798 NaN NaN
S1 Data, Figure 2A sheet (labelled 'Rat 107ST'): mean FFF over its 13 days 0.7485; fixed-panel FFF minus SSS 0.0991, d-prime 0.277
S1 Data, Figure 2B mean FFF fraction: 107ST 0.5856, 107Si 0.7485
Result: reproduced. In S2 Data, fixed-panel discrimination is lower than moving-panel discrimination in all six rats tested, by 0.067 (18Ri) to 0.374 (107SI); the paired t test gives p = 0.0120 with the rat at 0 kept (reading ii, the paper's p = 0.012) and p = 0.0308 without it (reading i), mean change -0.169 (95% CI -0.282 to -0.056) and -0.174 (-0.322 to -0.026). Five or more of six lower and p < 0.05 hold under both readings. The d-prime of Figure 2D from S1 Data is also lower in all six rats (p = 0.0051 and 0.0176). The moving-panel values of S2B equal the Figure 2B means for the two rats without the control and differ from them, and from the data set's mean and last session, for the six with it, so they summarise sessions this data set does not hold. The S1 Data Figure 2A sheet, labelled 107ST, has a mean FFF fraction (0.7485) and fixed-panel values (0.0991, d-prime 0.277) that are those of 107Si in Figure 2B, S2B and Figure 2D.
dprime-fff-sss-range¶
Discrimination of FFF against SSS in normal sessions was modest, with d-prime from 0.5 to 1.5 across rats.
def dprime(hr, fa, n1, n2):
hr = np.clip(hr, 0.5 / n1, 1 - 0.5 / n1)
fa = np.clip(fa, 0.5 / n2, 1 - 0.5 / n2)
return stats.norm.ppf(hr) - stats.norm.ppf(fa)
for rd in ["i", "ii"]:
bt = behav_trials(rd)
pooled, persess = {}, {}
for rat, t in bt.groupby("rat"):
f = t.groupby("stim").chosen.agg(["mean", "size"])
pooled[rat] = dprime(f.loc["FFF", "mean"], f.loc["SSS", "mean"], f.loc["FFF", "size"], f.loc["SSS", "size"])
v = []
for s, ts in t.groupby("session"):
g = ts.groupby("stim").chosen.agg(["mean", "size"])
if {"FFF", "SSS"} <= set(g.index):
v.append(dprime(g.loc["FFF", "mean"], g.loc["SSS", "mean"], g.loc["FFF", "size"], g.loc["SSS", "size"]))
persess[rat] = np.mean(v)
dp = pd.DataFrame(dict(pooled=pooled, session_mean=persess))
print("reading", rd); print(dp.round(3))
print(" pooled: range %.2f to %.2f; session mean: range %.2f to %.2f" % (dp.pooled.min(), dp.pooled.max(), dp.session_mean.min(), dp.session_mean.max()))
dp8 = pd.Series(dprime(paper2b.FFF.values, paper2b.SSS.values, 1e9, 1e9), index=paper2b.index)
print("Variant: d-prime from the S1 Data means of all eight rats (mean of sessions, not pooled):", dp8.round(2).to_dict())
reading
i
pooled session_mean
107St 0.592 0.632
18FB 0.453 0.460
18Ri 1.020 1.067
18Ro 1.088 1.232
62BS 0.639 0.659
pooled: range 0.45 to 1.09; session mean: range 0.46 to 1.23
reading ii
pooled session_mean
107St 0.592 0.632
18FB 0.453 0.460
18Ri 1.020 1.067
18Ro 1.088 1.232
62BS 0.639 0.659
pooled: range 0.45 to 1.09; session mean: range 0.46 to 1.23
Variant: d-prime from the S1 Data means of all eight rats (mean of sessions, not pooled): {'62BS': 0.64, '107ST': 0.61, '18Ro': 1.1, '18Ri': 1.03, '18FB': 0.51, '107Si': 1.17, '62SS': 1.32, '62SC': 1.06}
Result: partially reproduced. Per-rat d-prime over pooled sessions is 0.45 to 1.09 (mean of sessions 0.46 to 1.23): the lowest value is within tolerance of 0.5, the highest is below 1.35 under both readings. The three rats missing from the data set include the two with the highest d-prime by S1 Data (62SS 1.32, 107Si 1.17).
fig3-fsfs-sffs-intensity-only (S1 Data, Figure 3)¶
Two rats discriminated FSFS from SFFS when the sequences differed in mean speed (70 and 69.2% correct) but not when mean speed was the same (52 and 53%), even after more than 20 days; d-prime was 1.02 against 0.12.
f3 = S1["Fig 3"]
print("columns:", f3.iloc[2, 2:6].tolist(), f3.iloc[3, 2:6].tolist())
vals = f3.iloc[4:55, 1:6].apply(pd.to_numeric, errors="coerce")
vals.columns = ["day", "58B same", "58B diff", "60W same", "60W diff"]
summ = pd.DataFrame({c: dict(sessions=vals[c].notna().sum(), mean_pct=100 * vals[c].mean(),
sem_pct=100 * vals[c].std() / np.sqrt(vals[c].notna().sum()), last_day=vals.day[vals[c].notna()].max())
for c in vals.columns[1:]}).T
print(summ.round(2))
dpr = f3.iloc[59:62, 0:5]
print(dpr.to_string())
dd = pd.to_numeric(dpr.iloc[1, [1, 3]]).values
ds = pd.to_numeric(dpr.iloc[2, [1, 3]]).values
print("d-prime different intensity: mean of rats %.3f (60W %.3f, 58B %.3f)" % (dd.mean(), dd[0], dd[1]))
print("d-prime same intensity: mean of rats %.3f (60W %.3f, 58B %.3f)" % (ds.mean(), ds[0], ds[1]))
columns: ['Rat 58B', 'Rat 58B', 'Rat 60W', 'Rat 60W'] ['Same Intensity', 'Difft Intensity', 'Same Intensity', 'Difft Intensity']
sessions mean_pct sem_pct last_day
58B same 22.0 51.74 0.81 56.0
58B diff 13.0 69.98 1.47 31.0
60W same 21.0 53.02 0.82 52.0
60W diff 15.0 69.17 1.57 33.0
0 1 2 3 4
59 NaN Rat 60W mean Rat 60W SEM Rat 58B mean Rat 58B sem
60 Difft Intensity 1.061 0.095 0.9472 0.115
61 Same Intensity 0.168 0.044 0.09281 0.0428
d-prime different intensity: mean of rats 1.004 (60W 1.061, 58B 0.947)
d-prime same intensity: mean of rats 0.130 (60W 0.168, 58B 0.093)
Result: reproduced. From S1 Data, 58B is 69.98 +- 1.47% correct and 60W 69.17 +- 1.57% with different intensities, and 51.74 +- 0.81% and 53.02 +- 0.82% with the same intensity, over sessions up to day 56 and 52. The d-prime is 1.004 and 0.130 as the mean of the two rats (reading a), all within tolerance.
su = U.type.str.startswith("SU")
per = U[su].groupby("session").size().reindex(range(len(D.A)), fill_value=0)
print("single units %d (RS %d, FS %d), multi-unit clusters %d, total %d" % (su.sum(), (U.type == "SU_RS").sum(), (U.type == "SU_FS").sum(), (~su).sum(), len(U)))
print("sessions %d, rats %d" % (len(D.A), U.rat.nunique()))
print("single units per session: mean %.2f, min %d, max %d" % (per.mean(), per.min(), per.max()))
print(U.groupby(["rat", "type"]).size().unstack())
print("\nby electrode (18FB and 18Ri have a fifth electrode; leaving it out does not give 473):")
print(pd.crosstab(U.elect, U.type, margins=True))
single units 330 (RS 257, FS 73), multi-unit clusters 176, total 506 sessions 80, rats 5 single units per session: mean 4.12, min 0, max 12 type MU SU_FS SU_RS rat 107St 26 8 32 18FB 42 19 54 18Ri 30 12 65 18Ro 50 20 42 62BS 28 14 64 by electrode (18FB and 18Ri have a fifth electrode; leaving it out does not give 473): type MU SU_FS SU_RS All elect 1 44 18 63 125 2 35 23 67 125 3 31 7 46 84 4 50 15 60 125 5 16 10 21 47 All 176 73 257 506
Result: reproduced. The data set holds 330 single units and 176 multi-unit clusters over 80 sessions in five rats, 4.12 single units per session (0 to 12), each within tolerance. The total is 506 against the paper's 473; the 33 extra units cannot be identified, as the column map is missing.
baseline-rates¶
Mean firing rate in the 25-ms prestimulus baseline in the nose poke was 6 to 10 Hz across layers for RS units, 8 to 32 Hz for FS units, and higher for multi-unit clusters.
U["base25"] = [ssc4.rate(D.unit_trials(u)[0], -25, 0).mean() for u in U.uid]
U["base25_all"] = [ssc4.rate(D.unit_trials(u, lambda t: np.ones(len(t), bool))[0], -25, 0).mean() for u in U.uid]
order = ["L2/3", "L4", "L5a", "L5b", "L6"]
bl = U.groupby(["layer", "type"]).base25.agg(["mean", "size"]).unstack().loc[order]
print(bl.round(2))
for ty in ["SU_RS", "SU_FS"]:
m = bl[("mean", ty)]
print("%s: lowest layer mean %.2f Hz (%s), highest %.2f Hz (%s)" % (ty, m.min(), m.idxmin(), m.max(), m.idxmax()))
mu = bl[("mean", "MU")]
print("MU higher than RS in %d of 5 layers; higher than RS and FS in %d of 5" % ((mu > bl[("mean", "SU_RS")]).sum(),
((mu > bl[("mean", "SU_RS")]) & (mu > bl[("mean", "SU_FS")])).sum()))
rows_s1t, md5_s1t = ssc4.fetch_docx_table(ssc4.S1_TABLE)
print("\nS1 Table of the paper (doi:10.1371/journal.pbio.1002549.s010, MD5 %s when read): baseline mean, units" % md5_s1t)
s1t = pd.DataFrame([dict(layer=r[0].replace("L23", "L2/3"), type={"RS": "SU_RS", "FS": "SU_FS", "MU": "MU"}[r[1]],
s1t_mean=float(r[2].split("±")[0]), s1t_n=int(r[8])) for r in rows_s1t if len(r) > 8 and r[1] in ("RS", "FS", "MU")])
s1t = s1t.set_index(["layer", "type"])
here = U.groupby(["layer", "type"]).base25.agg(["mean", "size"]).rename(columns={"mean": "here_mean", "size": "here_n"})
cmpt = s1t.join(here)
cmpt["n_extra_here"] = cmpt.here_n - cmpt.s1t_n
print(cmpt.round(2).to_string())
print("S1 Table units: %d; here: %d. RS layer means in S1 Table: %.1f to %.1f Hz; FS: %.1f to %.1f Hz"
% (cmpt.s1t_n.sum(), cmpt.here_n.sum(), s1t.xs("SU_RS", level=1).s1t_mean.min(), s1t.xs("SU_RS", level=1).s1t_mean.max(),
s1t.xs("SU_FS", level=1).s1t_mean.min(), s1t.xs("SU_FS", level=1).s1t_mean.max()))
print("\nVariant, all trials (not only completed):")
print(U.groupby(["layer", "type"]).base25_all.mean().unstack().loc[order].round(2))
mean size type MU SU_FS SU_RS MU SU_FS SU_RS layer L2/3 18.15 7.59 5.93 26 5 10 L4 24.89 9.84 8.03 53 15 58 L5a 27.05 11.18 11.40 34 8 77 L5b 23.10 30.18 8.91 31 16 67 L6 25.68 21.78 7.86 32 29 45 SU_RS: lowest layer mean 5.93 Hz (L2/3), highest 11.40 Hz (L5a) SU_FS: lowest layer mean 7.59 Hz (L2/3), highest 30.18 Hz (L5b) MU higher than RS in 5 of 5 layers; higher than RS and FS in 4 of 5
S1 Table of the paper (doi:10.1371/journal.pbio.1002549.s010, MD5 700ac2c8bee44af6725b5ab2854e5bcf when read): baseline mean, units
s1t_mean s1t_n here_mean here_n n_extra_here
layer type
L2/3 SU_RS 6.0 9 5.93 10 1
SU_FS 7.9 5 7.59 5 0
MU 15.9 23 18.15 26 3
L4 SU_RS 7.8 52 8.03 58 6
SU_FS 9.8 15 9.84 15 0
MU 25.3 51 24.89 53 2
L5a SU_RS 10.8 68 11.40 77 9
SU_FS 10.7 6 11.18 8 2
MU 26.6 30 27.05 34 4
L5b SU_RS 9.0 62 8.91 67 5
SU_FS 31.6 15 30.18 16 1
MU 23.3 31 23.10 31 0
L6 SU_RS 7.7 45 7.86 45 0
SU_FS 21.6 29 21.78 29 0
MU 25.2 32 25.68 32 0
S1 Table units: 473; here: 506. RS layer means in S1 Table: 6.0 to 10.8 Hz; FS: 7.9 to 31.6 Hz
Variant, all trials (not only completed):
type MU SU_FS SU_RS
layer
L2/3 18.25 7.80 6.09
L4 25.20 10.07 8.09
L5a 27.13 11.30 11.49
L5b 23.64 29.93 9.26
L6 25.38 21.80 7.77
Result: partially reproduced. RS single-unit layer means span 5.93 (L2/3) to 11.40 Hz (L5a), FS 7.59 to 30.18 Hz, and multi-units are higher than RS in 5 of 5 layers. The RS maximum is above the 11 Hz limit; the other three bounds are within tolerance. With all trials the RS maximum is 11.49 Hz. The paper's S1 Table gives 10.8 Hz for L5a RS units (6.0 to 10.8 Hz for RS, 7.9 to 31.6 Hz for FS) over 68 units where the data set has 77; the data set has 33 more units than S1 Table, all in L2/3 to L5b and none in L6, so the extra units are a likely source of the difference.
temporal-modulation-count¶
305 of 473 units (63.5%) had firing rates significantly modulated in time during the nose poke period.
Readings of the window: (a) 0 to 180 ms after nose poke entry, (b) 0 to 180 ms after stimulus
onset. The two statistics the claim names give the same p-value under the uniform permutation
(helper docstring), so one is run. A third window, -50 to 300 ms after onset, is the one stored
with the data set's own p-values (TempSig.Params), shown as a variant.
pv = {"a: 0-180 after NP entry": ssc4.temporal_pvals(D, "np", seed=1),
"b: 0-180 after onset": ssc4.temporal_pvals(D, "stim", seed=2),
"variant: -50-300 after onset": ssc4.temporal_pvals(D, "deposit", seed=3)}
depmod = U.dep_temp_p.values < 0.05
for k, p in pv.items():
m = p < 0.05
print("%-30s modulated %d of %d (%.1f%%); agrees with the deposited p < 0.05 on %d units (%.1f%%); Spearman r of p with the deposited p %.3f" %
(k, m.sum(), len(m), 100 * m.mean(), (m == depmod).sum(), 100 * np.mean(m == depmod), stats.spearmanr(p, U.dep_temp_p, nan_policy='omit').statistic))
print("deposited TemporalPval < 0.05: %d of %d (%.1f%%)" % (depmod.sum(), len(U), 100 * depmod.mean()))
for thr in [0.01, 0.05, 0.1]:
print("threshold %.2f: reading a %d, reading b %d" % (thr, (pv["a: 0-180 after NP entry"] < thr).sum(), (pv["b: 0-180 after onset"] < thr).sum()))
print("\nVariant null (asked by the verifier): each trial's 10-ms bins shuffled independently, 1000 permutations")
rng = np.random.default_rng(4)
for nm, rd in [("-50-300 after onset (stored window)", "deposit"), ("a: 0-180 after NP entry", "np")]:
p = np.array([ssc4.perm_pval_shuffle(ssc4.temporal_bins(D, u, rd), rng) for u in U.uid])
m = p < 0.05
print("%-38s modulated %d of %d (%.1f%%); agrees with the deposited p < 0.05 on %.1f%% of units; Spearman r of p with the deposited p %.3f"
% (nm, m.sum(), len(m), 100 * m.mean(), 100 * np.mean(m == depmod), stats.spearmanr(p, U.dep_temp_p, nan_policy='omit').statistic))
U["mod_a"] = pv["a: 0-180 after NP entry"] < 0.05
U["mod"] = depmod
print("\nby rat, reading a"); print(U.groupby("rat")["mod_a"].agg(["sum", "size"]))
a: 0-180 after NP entry modulated 310 of 506 (61.3%); agrees with the deposited p < 0.05 on 370 units (73.1%); Spearman r of p with the deposited p 0.595 b: 0-180 after onset modulated 261 of 506 (51.6%); agrees with the deposited p < 0.05 on 379 units (74.9%); Spearman r of p with the deposited p 0.679 variant: -50-300 after onset modulated 363 of 506 (71.7%); agrees with the deposited p < 0.05 on 413 units (81.6%); Spearman r of p with the deposited p 0.863 deposited TemporalPval < 0.05: 310 of 506 (61.3%) threshold 0.01: reading a 242, reading b 218 threshold 0.05: reading a 310, reading b 261 threshold 0.10: reading a 341, reading b 293 Variant null (asked by the verifier): each trial's 10-ms bins shuffled independently, 1000 permutations
-50-300 after onset (stored window) modulated 365 of 506 (72.1%); agrees with the deposited p < 0.05 on 82.0% of units; Spearman r of p with the deposited p 0.841
a: 0-180 after NP entry modulated 321 of 506 (63.4%); agrees with the deposited p < 0.05 on 73.7% of units; Spearman r of p with the deposited p 0.615
by rat, reading a
sum size
rat
107St 40 66
18FB 66 115
18Ri 77 107
18Ro 73 112
62BS 54 106
Result: reproduced. With the Methods' window, 0 to 180 ms after nose poke entry (reading a), 310 of 506 units (61.3%) are modulated, within tolerance of 305 and 63.5%; with 0 to 180 ms after onset (reading b) 261 (51.6%). The data set's own p-values also mark 310, but they agree with reading (a) unit by unit for only 73.1% of units. Neither the stored window (-50 to 300 ms, 363 units, 81.6% agreement) nor a null that shuffles each trial's bins (365 units and 82.0% on the stored window, 321 and 73.7% on the Methods' window) gives the stored set, so the authors' test is not repeated exactly here.
The units used from here on are those the data set marks as temporally modulated
(TempSig.TemporalPval < 0.05, 310 units). The data descriptor names them as the units of the
paper's analyses: "For many analyses in the paper, we only analyzed units whose firing rate was
significantly temporally modulated with time during the trial. These units can be identified by:
AllRats(expt).TempSig.TemporalPval(unit) < 0.05". The set recomputed here with the Methods' test
(reading a) has the same count but is a different set of units (agreement printed above), so it is
not the authors' set. The first run of this attempt used the recomputed set; on the verifier's
report it was replaced by the deposited set, and the recomputed set is shown as a variant in each
claim that depends on it. This is an assumption: the paper's 305 of 473 units cannot be
identified exactly, as the 33 extra units of the data set cannot be told apart (units-recorded).
modulated-higher-baseline¶
Temporally modulated units were distributed uniformly across columns and layers and had higher baseline firing rates than non-modulated units.
for nm, col in [("deposited modulated set (main)", "mod"), ("variant: recomputed set, reading a", "mod_a")]:
rs = U[U.type == "SU_RS"]
tab = rs.groupby(["layer", col]).base25.agg(["mean", "sem", "size"]).unstack().loc[order]
print(nm); print(tab.round(2))
hi = (tab[("mean", True)] > tab[("mean", False)])
print("modulated RS mean higher in %d of 5 layers" % hi.sum())
ct = pd.crosstab(U.layer, U[col]).loc[order]
print(ct.assign(frac=ct[True] / ct.sum(axis=1)).round(3))
print("chi-square layer x modulation (all units): p = %.3f\n" % chi2_contingency(ct.values)[1])
print("columns cannot be tested: the column of each electrode (MapPosition) is not in the data set")
deposited modulated set (main)
mean sem size
mod False True False True False True
layer
L2/3 4.04 6.40 2.94 1.59 2 8
L4 6.55 10.14 0.94 1.28 34 24
L5a 11.35 11.46 1.36 1.32 39 38
L5b 4.60 11.32 0.81 1.27 24 43
L6 2.51 10.54 0.69 3.17 15 30
modulated RS mean higher in 5 of 5 layers
mod False True frac
layer
L2/3 13 28 0.683
L4 54 72 0.571
L5a 61 58 0.487
L5b 31 83 0.728
L6 37 69 0.651
chi-square layer x modulation (all units): p = 0.002
variant: recomputed set, reading a
mean sem size
mod_a False True False True False True
layer
L2/3 5.43 6.26 3.28 1.10 4 6
L4 6.08 10.13 0.86 1.26 30 28
L5a 8.73 13.88 1.29 1.27 37 40
L5b 5.41 11.28 0.87 1.37 27 40
L6 3.00 11.10 0.95 3.48 18 27
modulated RS mean higher in 5 of 5 layers
mod_a False True frac
layer
L2/3 14 27 0.659
L4 49 77 0.611
L5a 58 61 0.513
L5b 37 77 0.675
L6 38 68 0.642
chi-square layer x modulation (all units): p = 0.105
columns cannot be tested: the column of each electrode (MapPosition) is not in the data set
Result: reproduced. On the deposited modulated set, modulated RS single units have higher baseline rates than non-modulated ones in 5 of 5 layers (in L5a 11.46 against 11.35 Hz, a small margin), and the same holds on the recomputed set (5 of 5). The fraction modulated is 0.49 to 0.73 across layers on the deposited set, chi-square p = 0.002, so on this variant the modulated units are not spread evenly over layers (p = 0.105 on the recomputed set). Columns cannot be tested without the column map.
fig4d-evoked-modulation-by-layer¶
The mean impulse-evoked firing rate modulation, above the pre-impulse baseline, was 14.2 Hz in L2/3, 15.2 in L4, 6.3 in L5a, 14.4 in L5b and 7.0 in L6, greatest in L2/3, L4 and L5b.
modu = U.uid[U["mod"] | U["mod_a"]].values
ev = {}
for u in modu:
segs = ssc4.impulse_segments(D, u)
ev[u] = dict(pooled=ssc4.evoked_peak(segs, True), each=ssc4.evoked_peak(segs, False))
expect = pd.Series({"L2/3": 14.2, "L4": 15.2, "L5a": 6.3, "L5b": 14.4, "L6": 7.0})
tol = pd.Series({"L2/3": 2.3, "L4": 1.9, "L5a": 1.2, "L5b": 2.3, "L6": 1.5})
def fig4d_table(units):
rows = []
for u in units:
for pool in ["pooled", "each"]:
pk, mn, lat = ev[u][pool]
rows.append(dict(uid=u, layer=U.layer[u], pool=pool, A_signed=pk, A_abs=abs(pk), B_mean=mn))
EV = pd.DataFrame(rows)
res = {}
for pool in ["pooled", "each"]:
for meas in ["A_signed", "A_abs", "B_mean"]:
res[(meas, pool)] = EV[EV.pool == pool].groupby("layer")[meas].mean().loc[order]
R = pd.DataFrame(res).T
R["n_within"] = [(np.abs(R.loc[i, order] - expect) <= tol).sum() for i in R.index]
R["within_all"] = R.n_within == 5
R["L5a_L6_lowest"] = [set(R.loc[i, order].astype(float).nsmallest(2).index) == {"L5a", "L6"} for i in R.index]
return R, EV
print("expected", expect.to_dict(), "tolerance", tol.to_dict())
for nm, col in [("deposited modulated set (main)", "mod"), ("variant: recomputed set, reading a", "mod_a")]:
R, EV = fig4d_table(U.uid[U[col]].values)
print("\n" + nm); print(R.round(2).to_string())
print("units per layer", EV[EV.pool == "pooled"].groupby("layer").size().loc[order].to_dict())
print("SEM across units, A_abs each:", EV[EV.pool == "each"].groupby("layer").A_abs.sem().loc[order].round(2).to_dict())
expected {'L2/3': 14.2, 'L4': 15.2, 'L5a': 6.3, 'L5b': 14.4, 'L6': 7.0} tolerance {'L2/3': 2.3, 'L4': 1.9, 'L5a': 1.2, 'L5b': 2.3, 'L6': 1.5}
deposited modulated set (main)
layer L2/3 L4 L5a L5b L6 n_within within_all L5a_L6_lowest
A_signed pooled 14.33 14.23 2.55 13.11 5.76 4 False True
A_abs pooled 14.33 16.49 8.67 15.70 8.85 3 False True
B_mean pooled 7.97 6.88 1.57 6.09 2.69 0 False True
A_signed each 17.75 16.50 4.67 15.42 6.27 3 False True
A_abs each 17.75 17.27 8.57 16.58 8.82 1 False True
B_mean each 7.98 6.92 1.61 6.07 2.61 0 False True
units per layer {'L2/3': 28, 'L4': 72, 'L5a': 58, 'L5b': 83, 'L6': 69}
SEM across units, A_abs each: {'L2/3': 3.05, 'L4': 1.91, 'L5a': 1.32, 'L5b': 2.28, 'L6': 1.45}
variant: recomputed set, reading a
layer L2/3 L4 L5a L5b L6 n_within within_all L5a_L6_lowest
A_signed pooled 14.00 13.55 2.05 13.74 5.34 3 False True
A_abs pooled 14.00 15.44 8.19 16.07 8.80 3 False True
B_mean pooled 7.74 6.69 1.36 6.37 2.62 0 False True
A_signed each 16.90 15.51 4.30 15.93 5.90 3 False True
A_abs each 16.90 16.08 7.57 16.81 8.58 1 False True
B_mean each 7.77 6.69 1.47 6.34 2.57 0 False True
units per layer {'L2/3': 27, 'L4': 77, 'L5a': 61, 'L5b': 77, 'L6': 68}
SEM across units, A_abs each: {'L2/3': 3.24, 'L4': 1.81, 'L5a': 1.26, 'L5b': 2.46, 'L6': 1.49}
Result: partially reproduced. On the deposited modulated set no combination puts all five layers within tolerance; the closest, the signed peak over pooled impulses (A, a, i), has 4 of 5 (14.33, 14.23, 2.55, 13.11, 5.76 Hz, L5a outside). L5a and L6 are the two lowest layers under every combination, on both unit sets. The recomputed set gives at most 3 of 5.
latency-by-layer¶
Among impulse-responsive units, peak response latency was shortest in L4, L5a and L5b (9.8, 10.3 and 12.0 ms) and longest in L2/3 and L6 (13.8 and 16.1 ms).
lt = []
for u in modu:
segs = ssc4.impulse_segments(D, u)
tt, p2, p1 = ssc4.impulse_ttest(segs)
row = dict(uid=u, layer=U.layer[u], p_one=p1, p_two=p2)
for sm in ["centred", "trailing", "forward", "none"]:
row[sm] = ev[u]["pooled"][2] if sm == "centred" else ssc4.evoked_peak(segs, True, sm)[2]
lt.append(row)
LT = pd.DataFrame(lt)
lexp = pd.Series({"L4": 9.8, "L5a": 10.3, "L5b": 12.0, "L2/3": 13.8, "L6": 16.1})
print("expected", lexp.loc[order].to_dict(), "tolerance 10%")
rows = []
for setname, col in [("deposited set", "mod"), ("recomputed set (a)", "mod_a")]:
for test in ["p_one", "p_two"]:
r = LT[LT.uid.isin(U.uid[U[col]]) & (LT[test] < 0.05)]
print("%s, %s: impulse-responsive units per layer %s" % (setname, test, r.groupby("layer").size().loc[order].to_dict()))
for sm in ["centred", "trailing", "forward", "none"]:
for summ in ["mean", "median"]:
v = r.groupby("layer")[sm].agg(summ).loc[order]
within = np.abs(v - lexp.loc[order]) <= 0.1 * lexp.loc[order]
rows.append(dict(set=setname, test=test, smoothing=sm, summary=summ, **v.round(2).to_dict(),
n_within=int(within.sum()), ordered=bool(max(v[["L4", "L5a", "L5b"]]) < min(v[["L2/3", "L6"]]))))
LTS = pd.DataFrame(rows)
print(LTS.to_string())
expected {'L2/3': 13.8, 'L4': 9.8, 'L5a': 10.3, 'L5b': 12.0, 'L6': 16.1} tolerance 10%
deposited set, p_one: impulse-responsive units per layer {'L2/3': 25, 'L4': 47, 'L5a': 21, 'L5b': 46, 'L6': 23}
deposited set, p_two: impulse-responsive units per layer {'L2/3': 23, 'L4': 48, 'L5a': 25, 'L5b': 43, 'L6': 25}
recomputed set (a), p_one: impulse-responsive units per layer {'L2/3': 22, 'L4': 50, 'L5a': 18, 'L5b': 43, 'L6': 21}
recomputed set (a), p_two: impulse-responsive units per layer {'L2/3': 19, 'L4': 49, 'L5a': 23, 'L5b': 40, 'L6': 22}
set test smoothing summary L2/3 L4 L5a L5b L6 n_within ordered
0 deposited set p_one centred mean 19.28 16.16 20.34 17.96 22.21 0 False
1 deposited set p_one centred median 17.00 15.00 19.00 15.00 21.00 0 False
2 deposited set p_one trailing mean 23.28 20.16 24.34 21.79 25.58 0 False
3 deposited set p_one trailing median 21.00 19.00 23.00 19.00 25.00 0 False
4 deposited set p_one forward mean 14.28 11.16 15.34 13.27 19.01 1 False
5 deposited set p_one forward median 12.00 10.00 14.00 10.00 16.00 2 False
6 deposited set p_one none mean 18.18 16.26 17.84 16.93 19.31 0 True
7 deposited set p_one none median 17.00 15.00 16.00 14.50 19.00 0 True
8 deposited set p_two centred mean 18.72 15.99 17.22 16.91 20.40 0 True
9 deposited set p_two centred median 17.00 15.00 15.50 15.00 18.00 0 True
10 deposited set p_two trailing mean 22.72 18.93 18.14 20.66 22.77 0 True
11 deposited set p_two trailing median 21.00 19.00 19.00 19.00 22.00 0 True
12 deposited set p_two forward mean 13.72 11.80 14.54 13.06 19.01 2 False
13 deposited set p_two forward median 12.00 10.00 11.50 10.00 16.00 2 True
14 deposited set p_two none mean 17.53 16.67 15.29 15.89 19.07 0 True
15 deposited set p_two none median 15.00 15.00 14.00 13.00 19.00 2 False
16 recomputed set (a) p_one centred mean 19.50 16.75 19.22 17.72 21.17 0 True
17 recomputed set (a) p_one centred median 17.00 15.00 16.75 15.00 17.00 1 True
18 recomputed set (a) p_one trailing mean 23.50 20.75 23.22 21.54 24.56 0 True
19 recomputed set (a) p_one trailing median 21.00 19.00 20.75 19.00 21.00 0 True
20 recomputed set (a) p_one forward mean 14.50 11.75 14.22 13.05 16.99 3 True
21 recomputed set (a) p_one forward median 12.00 10.00 11.75 10.00 12.00 1 True
22 recomputed set (a) p_one none mean 18.89 16.18 17.06 17.04 18.21 0 True
23 recomputed set (a) p_one none median 16.50 15.00 16.00 14.00 18.00 0 True
24 recomputed set (a) p_two centred mean 18.61 16.37 16.39 16.57 19.16 0 True
25 recomputed set (a) p_two centred median 16.00 15.00 15.00 14.25 17.00 1 True
26 recomputed set (a) p_two trailing mean 22.61 20.27 17.04 20.31 21.40 0 True
27 recomputed set (a) p_two trailing median 20.00 19.00 19.00 18.25 20.00 0 True
28 recomputed set (a) p_two forward mean 13.61 11.68 13.91 12.81 17.17 3 False
29 recomputed set (a) p_two forward median 11.00 10.00 10.50 9.75 12.00 2 True
30 recomputed set (a) p_two none mean 17.80 16.12 14.39 15.93 18.73 0 True
31 recomputed set (a) p_two none median 15.00 15.00 14.00 13.00 17.50 3 False
Result: partially reproduced. With the centred 10-ms boxcar, latencies on the deposited set are 15 to 22 ms in every layer, longer than the paper's 9.8 to 16.1 ms, and no layer is within tolerance. The ordering (L4, L5a, L5b below L2/3 and L6) holds with the two-sided test (mean and median) and not with the one-sided test, where L5a is among the latest. Placing the boxcar forward (t to t+9 ms) shortens latencies by about 5 ms and puts at most 2 of 5 layers within tolerance on the deposited set; on that set the trailing boxcar puts none and the unsmoothed PSTH at most 2, and on the recomputed set the forward boxcar and the unsmoothed PSTH put at most 3. No reading puts all five within tolerance. The outcome rests on the two-sided test; the record gives its centred means as measured.
fig4d-gradual-decrease¶
Superimposed on the phasic impulse responses, average firing rate decreased gradually during the nose poke period in all layers except L5a.
def unit_psth(u, a=-25, b=180, sel=None):
M, t, _ = D.unit_trials(u, sel)
return M[:, a - ssc4.T0:b - ssc4.T0].mean(0) * 1000
tax = np.arange(-25, 180)
for nm, col in [("deposited modulated set (main)", "mod"), ("variant: recomputed set, reading a", "mod_a")]:
rows = []
for lay in order:
us = U[U[col] & (U.layer == lay)].uid
pop = np.mean([unit_psth(u) for u in us], 0)
slope = stats.linregress(tax, pop)
rows.append(dict(layer=lay, n=len(us), slope_hz_per_100ms=100 * slope.slope, slope_p=slope.pvalue,
baseline=pop[:25].mean(), last30=pop[-30:].mean(), last30_minus_base=pop[-30:].mean() - pop[:25].mean()))
GD = pd.DataFrame(rows).set_index("layer")
GD["decrease_a"] = GD.slope_hz_per_100ms < 0
GD["decrease_b"] = GD.last30_minus_base < 0
print(nm); print(GD.round(3)); print()
deposited modulated set (main)
n slope_hz_per_100ms slope_p baseline last30 last30_minus_base decrease_a decrease_b
layer
L2/3 28 -2.120 0.000 12.072 10.473 -1.599 True True
L4 72 -2.104 0.000 20.608 17.918 -2.691 True True
L5a 58 -0.940 0.000 16.086 14.388 -1.698 True True
L5b 83 -1.420 0.001 19.385 17.685 -1.700 True True
L6 69 -1.931 0.000 22.612 18.266 -4.347 True True
variant: recomputed set, reading a
n slope_hz_per_100ms slope_p baseline last30 last30_minus_base decrease_a decrease_b
layer
L2/3 27 -2.429 0.000 14.037 11.962 -2.075 True True
L4 77 -1.940 0.000 19.458 16.853 -2.605 True True
L5a 61 -0.878 0.000 17.623 15.978 -1.645 True True
L5b 77 -1.090 0.015 17.840 16.854 -0.987 True True
L6 68 -1.998 0.000 23.052 18.488 -4.564 True True
Result: not reproduced. On the deposited modulated set the population rate decreases in every layer, L5a included: the slope from -25 to 180 ms is -0.94 Hz per 100 ms in L5a (p < 0.001) and -1.42 to -2.12 in the others, and the last 30 ms are below baseline in all five layers (by 1.70 Hz in L5a). The recomputed set gives the same (L5a -0.88 Hz per 100 ms). The claim requires no decrease in L5a.
sig = (P < 0.05 / 36).any(1)
mod = U["mod"].values
mod_a = U["mod_a"].values
print("significant regression among the deposited modulated units (main): %d of %d" % ((sig & mod).sum(), mod.sum()))
print("variant, among units modulated by the recomputed test (reading a): %d of %d" % ((sig & mod_a).sum(), mod_a.sum()))
print("among all units: %d of %d" % (sig.sum(), len(sig)))
R2r, Pr, Br = ssc4.regress_all(D, use_rate=True)
sigr = (Pr < 0.05 / 36).any(1)
print("variant, rate per trial instead of summed counts: %d of %d modulated" % ((sigr & mod).sum(), mod.sum()))
print("by rat:"); print(pd.Series(sig & mod).groupby(U.rat).sum())
significant regression among the deposited modulated units (main): 207 of 310 variant, among units modulated by the recomputed test (reading a): 194 of 310 among all units: 256 of 506
variant, rate per trial instead of summed counts: 207 of 310 modulated by rat: rat 107St 23 18FB 49 18Ri 52 18Ro 47 62BS 36 dtype: int64
Result: reproduced. 207 of the 310 deposited modulated units have a significant regression at p < 0.05/36, within tolerance of 204; on the recomputed set, 194 of 310. The regression reproduces the data set's stored R2 and p to numerical precision.
fig6e-unit-classes¶
Units were classed by best-fit integration window as Fast (5 to 20 ms, 158 units, 52%, positive slopes), Medium (25 to 55 ms, 52 units, largely negative slopes), Slow Positive (51) and Slow Negative (44); 44% of units had very fast (5 to 10 ms) windows.
exp6 = dict(Fast=158, Medium=52, SlowPos=51, SlowNeg=44)
def class_table(modmask):
out, rows = {}, []
for which in ["all", "sig"]:
for m55 in [False, True]:
lab, best, slope, sg = ssc4.unit_classes(R2, P, B, modmask, which, m55)
key = "%s, 55 ms %s" % ("a all modulated" if which == "all" else "b significant only", "Medium" if m55 else "Slow")
out[key] = lab
c = collections.Counter(lab)
fast, med = lab == "Fast", lab == "Medium"
row = dict(reading=key, **{k: c[k] for k in exp6})
row["pct_fast_of_mod"] = 100 * fast.sum() / modmask.sum()
row["pct_5_10_of_mod"] = 100 * ((best <= 10) & (lab != "none")).sum() / modmask.sum()
row["fast_pos_frac"] = np.mean(slope[fast] > 0)
row["medium_neg_frac"] = np.mean(slope[med] < 0)
row["counts_within"] = all(abs(c[k] - v) <= 0.1 * v for k, v in exp6.items())
row["pcts_within"] = abs(row["pct_fast_of_mod"] - 52) <= 5.2 and abs(row["pct_5_10_of_mod"] - 44) <= 4.4
rows.append(row)
return out, pd.DataFrame(rows).set_index("reading")
cls, C6 = class_table(mod)
print("deposited modulated set (main)"); print(C6.round(3).to_string())
cls_a, C6a = class_table(mod_a)
print("\nvariant: recomputed modulated set (reading a)"); print(C6a.round(3).to_string())
depc = ssc4.deposited_classes(D)
print("\ndeposited labels (DFLabel; FastPos/FastNeg split into Fast and Medium at 20 ms by PeakBin):", collections.Counter(depc))
lab_main = cls["a all modulated, 55 ms Medium"]
print("reading (a, 55 ms Medium) on the deposited set against the deposited labels:")
print(pd.crosstab(pd.Series(lab_main, name="this attempt"), pd.Series(depc, name="deposited")))
print("units whose best window is 55 ms:", U.loc[(R2.argmax(1) + 1) * 5 == 55, ["session", "unit", "dep_label", "dep_peakbin"]].to_dict("records"))
deposited modulated set (main)
Fast Medium SlowPos SlowNeg pct_fast_of_mod pct_5_10_of_mod fast_pos_frac medium_neg_frac counts_within pcts_within
reading
a all modulated, 55 ms Slow 160 52 51 47 51.613 43.548 0.938 0.692 True True
a all modulated, 55 ms Medium 160 53 51 46 51.613 43.548 0.938 0.698 True True
b significant only, 55 ms Slow 125 30 28 24 40.323 34.839 0.976 0.733 False False
b significant only, 55 ms Medium 125 31 28 23 40.323 34.839 0.976 0.742 False False
variant: recomputed modulated set (reading a)
Fast Medium SlowPos SlowNeg pct_fast_of_mod pct_5_10_of_mod fast_pos_frac medium_neg_frac counts_within pcts_within
reading
a all modulated, 55 ms Slow 160 48 51 51 51.613 42.903 0.931 0.688 False True
a all modulated, 55 ms Medium 160 50 50 50 51.613 42.903 0.931 0.680 False True
b significant only, 55 ms Slow 119 26 23 26 38.387 32.581 0.975 0.769 False False
b significant only, 55 ms Medium 119 27 23 25 38.387 32.581 0.975 0.778 False False
deposited labels (DFLabel; FastPos/FastNeg split into Fast and Medium at 20 ms by PeakBin): Counter({np.str_('none'): 196, np.str_('Fast'): 160, np.str_('Medium'): 53, np.str_('SlowPos'): 51, np.str_('SlowNeg'): 46})
reading (a, 55 ms Medium) on the deposited set against the deposited labels:
deposited Fast Medium SlowNeg SlowPos none
this attempt
Fast 160 0 0 0 0
Medium 0 53 0 0 0
SlowNeg 0 0 46 0 0
SlowPos 0 0 0 51 0
none 0 0 0 0 196
units whose best window is 55 ms: [{'session': 4, 'unit': 0, 'dep_label': 'NoTempMod', 'dep_peakbin': 55.0}, {'session': 5, 'unit': 1, 'dep_label': 'FastNeg', 'dep_peakbin': 55.0}, {'session': 16, 'unit': 7, 'dep_label': 'NoTempMod', 'dep_peakbin': 55.0}, {'session': 26, 'unit': 1, 'dep_label': 'NoTempMod', 'dep_peakbin': 55.0}, {'session': 35, 'unit': 6, 'dep_label': 'NoTempMod', 'dep_peakbin': 55.0}, {'session': 60, 'unit': 8, 'dep_label': 'NoTempMod', 'dep_peakbin': 55.0}, {'session': 68, 'unit': 0, 'dep_label': 'NoTempMod', 'dep_peakbin': 55.0}, {'session': 75, 'unit': 0, 'dep_label': 'NoTempMod', 'dep_peakbin': 55.0}]
Result: reproduced. Classing all deposited modulated units by their best window (reading a) gives 160 Fast, 52 Medium, 51 Slow Positive and 47 Slow Negative with 55 ms as Slow, and 160, 53, 51 and 46 with 55 ms as Medium; all counts are within tolerance under both. Fast units are 51.6% of modulated units and 43.5% have 5 to 10 ms windows, both within tolerance; 94% of Fast units have positive slopes and 69 to 70% of Medium units negative. Classing only units with a significant regression (reading b) gives 125, 30 or 31, 28, 24 or 23, outside tolerance. With 55 ms as Medium the classes equal the data set's labels unit for unit. On the recomputed modulated set Slow Negative is 50 or 51, above its limit of 48.4.
Downstream claims use the classes of reading (a) on the deposited modulated set, with 55 ms as Medium: the paper's four counts sum to 305, all temporally modulated units, and the Results put 55 ms in Medium ("Units with 25–55 ms integration windows"), as do the data set's own labels for the one unit whose best window is 55 ms. On this set these classes equal the deposited labels unit for unit (table above). The first run used reading (a) with 55 ms Slow on the recomputed set; the classes of reading (a), 55 ms Medium, on the recomputed set are the variant shown from here on.
fig6fg-laminar-classes¶
Fast units were 73% of temporally modulated units in L2/3 and L4, 50% in L5 and 23% in L6; slow units were 13% in L2/3 and L4, 31% in L5 and 56% in L6.
grp = {"L2/3": "L2/3+L4", "L4": "L2/3+L4", "L5a": "L5", "L5b": "L5", "L6": "L6"}
expF = {"L2/3+L4": 73, "L5": 50, "L6": 23}
expS = {"L2/3+L4": 13, "L5": 31, "L6": 56}
def laminar(lab, modmask):
d = pd.DataFrame(dict(layer=U.layer, lab=lab))[modmask]
out = {}
for gname, keyf in [("grouped", lambda l: grp.get(l, "none")), ("separate", lambda l: l)]:
g = d.assign(g=d.layer.map(keyf))
f = g.groupby("g").lab.apply(lambda x: 100 * np.mean(x == "Fast"))
s = g.groupby("g").lab.apply(lambda x: 100 * np.mean(np.isin(x, ["SlowPos", "SlowNeg"])))
out[gname] = pd.DataFrame(dict(fast_pct=f, slow_pct=s, n=g.groupby("g").size()))
return out
for key, lab, mm in [(k, v, mod) for k, v in cls.items()] + [("variant: recomputed set (a), " + k, v, mod_a) for k, v in cls_a.items() if k.startswith("a ")]:
o = laminar(lab, mm)
gr = o["grouped"].loc[["L2/3+L4", "L5", "L6"]]
win = sum(abs(gr.fast_pct[k] - expF[k]) <= 0.1 * expF[k] for k in expF) + sum(abs(gr.slow_pct[k] - expS[k]) <= 0.1 * expS[k] for k in expS)
grad = gr.fast_pct.is_monotonic_decreasing and gr.slow_pct.is_monotonic_increasing
print("\n", key, "| values within tolerance: %d of 6 | gradient holds: %s" % (win, grad))
print(gr.round(1).T.to_string())
print(o["separate"].loc[["L2/3", "L4"]].round(1).T.to_string())
a all modulated, 55 ms Slow | values within tolerance: 6 of 6 | gradient holds: True g L2/3+L4 L5 L6 fast_pct 74.0 49.6 23.2 slow_pct 13.0 32.6 56.5 n 100.0 141.0 69.0 g L2/3 L4 fast_pct 75.0 73.6 slow_pct 17.9 11.1 n 28.0 72.0 a all modulated, 55 ms Medium | values within tolerance: 6 of 6 | gradient holds: True g L2/3+L4 L5 L6 fast_pct 74.0 49.6 23.2 slow_pct 13.0 31.9 56.5 n 100.0 141.0 69.0 g L2/3 L4 fast_pct 75.0 73.6 slow_pct 17.9 11.1 n 28.0 72.0 b significant only, 55 ms Slow | values within tolerance: 0 of 6 | gradient holds: True g L2/3+L4 L5 L6 fast_pct 61.0 36.2 18.8 slow_pct 7.0 19.1 26.1 n 100.0 141.0 69.0 g L2/3 L4 fast_pct 60.7 61.1 slow_pct 14.3 4.2 n 28.0 72.0 b significant only, 55 ms Medium | values within tolerance: 0 of 6 | gradient holds: True g L2/3+L4 L5 L6 fast_pct 61.0 36.2 18.8 slow_pct 7.0 18.4 26.1 n 100.0 141.0 69.0 g L2/3 L4 fast_pct 60.7 61.1 slow_pct 14.3 4.2 n 28.0 72.0 variant: recomputed set (a), a all modulated, 55 ms Slow | values within tolerance: 4 of 6 | gradient holds: True g L2/3+L4 L5 L6 fast_pct 69.2 50.7 26.5 slow_pct 18.3 33.3 54.4 n 104.0 138.0 68.0 g L2/3 L4 fast_pct 59.3 72.7 slow_pct 29.6 14.3 n 27.0 77.0 variant: recomputed set (a), a all modulated, 55 ms Medium | values within tolerance: 4 of 6 | gradient holds: True g L2/3+L4 L5 L6 fast_pct 69.2 50.7 26.5 slow_pct 18.3 32.6 52.9 n 104.0 138.0 68.0 g L2/3 L4 fast_pct 59.3 72.7 slow_pct 29.6 14.3 n 27.0 77.0
Result: reproduced. Under reading (a) on the deposited modulated set, Fast units are 74.0% of modulated units in L2/3 and L4, 49.6% in L5 and 23.2% in L6, and Slow units 13.0%, 31.9 to 32.6% and 56.5%: all 6 values within tolerance, and the gradient holds. Separately, L2/3 is 75.0% Fast and L4 73.6%. On the recomputed set 4 of 6 are within tolerance (L6 Fast 26.5%, L2/3 and L4 Slow 18.3%).
Response classes (Figures 7 and 8)¶
U["cls"] = lab_main
U["cls_dep"] = depc
U["cls_a"] = cls_a["a all modulated, 55 ms Medium"]
print("main classes equal the deposited labels for every unit:", bool((U.cls == U.cls_dep).all()))
U["best"] = (R2.argmax(1) + 1) * 5
KINDS = ["F", "M", "S"]
def net_evoked(u, kinds=KINDS):
"""Mean over impulses of each kind (all sequences) of the rate 5-35 ms after onset minus 0-10 ms before."""
segs = ssc4.impulse_segments(D, u)
out = {}
for k in kinds:
X = np.concatenate([g["X"] for g in segs if g["kind"] == k])
out[k] = X[:, 15:45].mean() * 1000 - X[:, 0:10].mean() * 1000
return out
def seq_rates(u, base, sel=None):
"""Per sequence, mean rate 0-150 ms after onset minus the pre-stimulus baseline (base: '25' or '10')."""
M, t, _ = D.unit_trials(u, sel)
a = -25 if base == "25" else -10
out = {}
for s in ["FFF", "FMS", "SMF", "SSS"]:
m = (t.stim == s).values
out[s] = ssc4.rate(M[m], 0, 150).mean() - ssc4.rate(M[m], a, 0).mean()
return out
def pulse_evoked(u, base, sel=None):
"""Per sequence and pulse, rate 5-35 ms after the pulse onset minus the pre-sequence baseline (S4 Fig)."""
M, t, _ = D.unit_trials(u, sel)
si = int(U.session[u])
a = -25 if base == "25" else -10
out = {}
for s in ["FFF", "FMS", "SMF", "SSS"]:
m = (t.stim == s).values
if m.sum() == 0:
continue
b0 = ssc4.rate(M[m], a, 0).mean()
for p, on in enumerate(D.onsets(si, s)):
out[(s, p + 1)] = ssc4.rate(M[m], on + 5, on + 35).mean() - b0
return out
NE = pd.DataFrame({u: net_evoked(u) for u in U.uid[U.cls != "none"]}).T
SR = {b: pd.DataFrame({u: seq_rates(u, b) for u in U.uid[U.cls != "none"]}).T for b in ["25", "10"]}
NE_a = pd.DataFrame({u: net_evoked(u) for u in U.uid[(U.cls_a != "none")]}).T
SR_a = {b: pd.DataFrame({u: seq_rates(u, b) for u in U.uid[U.cls_a != "none"]}).T for b in ["25", "10"]}
print("class sizes (main):", U.cls.value_counts().to_dict(), "| variant, recomputed set:", U.cls_a.value_counts().to_dict())
main classes equal the deposited labels for every unit: True
class sizes (main): {'none': 196, 'Fast': 160, 'Medium': 53, 'SlowPos': 51, 'SlowNeg': 46} | variant, recomputed set: {'none': 196, 'Fast': 160, 'SlowNeg': 50, 'Medium': 50, 'SlowPos': 50}
fig7c-fast-impulse-velocity¶
In Fast units the evoked rate after an impulse was greater for F than S impulses and intermediate for M impulses.
for nm, ne, c in [("this attempt", NE, "cls"), ("variant: recomputed modulated set (a)", NE_a, "cls_a")]:
f = ne.loc[U.uid[U[c] == "Fast"]]
m = f.mean()
t = stats.ttest_rel(f.F, f.S)
print("%s: n = %d Fast units, net evoked F %.2f, M %.2f, S %.2f Hz (SEM %s); F > M > S: %s; paired t F vs S t = %.2f p = %.2g"
% (nm, len(f), m.F, m.M, m.S, f.sem().round(2).to_dict(), m.F > m.M > m.S, t.statistic, t.pvalue))
f = NE.loc[U.uid[U.cls == "Fast"]]
print("by rat:"); print(f.groupby(U.rat).mean().round(2))
this attempt: n = 160 Fast units, net evoked F 9.99, M 8.54, S 7.77 Hz (SEM {'F': 0.84, 'M': 0.88, 'S': 0.75}); F > M > S: True; paired t F vs S t = 4.47 p = 1.5e-05
variant: recomputed modulated set (a): n = 160 Fast units, net evoked F 9.59, M 8.73, S 7.42 Hz (SEM {'F': 0.84, 'M': 0.88, 'S': 0.77}); F > M > S: True; paired t F vs S t = 4.48 p = 1.4e-05
by rat:
F M S
rat
107St 10.87 3.87 4.84
18FB 12.65 10.39 11.80
18Ri 11.44 12.71 9.36
18Ro 7.63 6.15 4.23
62BS 7.06 6.31 5.78
Result: reproduced. Over 160 Fast units the net evoked rate is 9.99 Hz for F, 8.54 for M and 7.77 for S impulses (paired t F against S p = 1.5e-05); the recomputed set gives the same order (9.59, 8.73, 7.42 Hz).
fig7c-fast-sequence-rate¶
Mean firing rate of Fast units over the whole sequence (0 to 150 ms) followed the mean speed of the sequence, highest for FFF, lowest for SSS, and intermediate and equal for FMS and SMF.
for nm, sr, c in [("this attempt", SR, "cls"), ("variant: recomputed modulated set (a)", SR_a, "cls_a")]:
for b in ["25", "10"]:
f = sr[b].loc[U.uid[U[c] == "Fast"]]
m = f.mean()
t = stats.ttest_rel(f.FMS, f.SMF)
print("%s, baseline %s ms: n = %d, FFF %.2f, FMS %.2f, SMF %.2f, SSS %.2f Hz; FFF > FMS,SMF > SSS: %s; FMS vs SMF diff %.2f Hz, t = %.2f, p = %.3f"
% (nm, b, len(f), m.FFF, m.FMS, m.SMF, m.SSS, m.FFF > max(m.FMS, m.SMF) and min(m.FMS, m.SMF) > m.SSS, m.FMS - m.SMF, t.statistic, t.pvalue))
f = SR["25"].loc[U.uid[U.cls == "Fast"]]
print("by rat (baseline 25 ms):"); print(f.groupby(U.rat).mean().round(2))
this attempt, baseline 25 ms: n = 160, FFF 4.10, FMS 2.68, SMF 3.56, SSS 1.59 Hz; FFF > FMS,SMF > SSS: True; FMS vs SMF diff -0.88 Hz, t = -1.91, p = 0.058
this attempt, baseline 10 ms: n = 160, FFF 4.75, FMS 2.28, SMF 3.19, SSS 1.63 Hz; FFF > FMS,SMF > SSS: True; FMS vs SMF diff -0.91 Hz, t = -1.19, p = 0.234
variant: recomputed modulated set (a), baseline 25 ms: n = 160, FFF 3.76, FMS 2.50, SMF 3.44, SSS 1.48 Hz; FFF > FMS,SMF > SSS: True; FMS vs SMF diff -0.95 Hz, t = -2.01, p = 0.046
variant: recomputed modulated set (a), baseline 10 ms: n = 160, FFF 4.62, FMS 2.09, SMF 2.85, SSS 1.59 Hz; FFF > FMS,SMF > SSS: True; FMS vs SMF diff -0.76 Hz, t = -1.03, p = 0.306
by rat (baseline 25 ms):
FFF FMS SMF SSS
rat
107St 7.96 4.59 5.65 0.56
18FB 3.69 3.38 3.83 3.74
18Ri 3.31 2.06 3.61 2.06
18Ro 3.62 2.05 1.81 -1.42
62BS 4.37 2.25 4.20 1.98
Result: reproduced. The sequence rate of Fast units orders FFF > FMS and SMF > SSS with both baselines, and FMS and SMF do not differ with either (25-ms baseline: -0.88 Hz, p = 0.058; 0 to 10 ms baseline: -0.91 Hz, p = 0.234). On the recomputed set they differ at p = 0.046 with the 25-ms baseline.
fig7-fff-adaptation¶
Fast RS single units adapted modestly in FFF trains, with pulse 2 to pulse 1 ratio 0.80 and pulse 3 to pulse 1 ratio 0.70, significant by t test.
Units: Fast RS single units whose response to F impulses is significant by the impulse t test, with three readings of the test (one-sided and two-sided over all F impulses, and one-sided over the first impulse of FFF and FMS only, whose 0 to 10 ms baseline is free of an earlier response), and all Fast RS single units. The paper's 61 is close to all Fast RS single units (62 here), and every t test selects about half of them, so the paper's test is not the one run here; the outcome is taken on all Fast RS single units, the selection whose count matches the paper's (an assumption). A per-unit ratio is defined only when the unit's pulse 1 response is above 1 Hz, so that near-zero denominators do not enter; units without are counted.
def f_responsive(u, side):
"""side 'one'/'two': paired t test over all F impulses (one- or two-sided); 'first': one-sided,
first impulse of FFF and FMS only, whose 0-10 ms baseline precedes any stimulus."""
segs = ssc4.impulse_segments(D, u, kinds=["F"], pulses=(0,) if side == "first" else (0, 1, 2))
tt, p2, p1 = ssc4.impulse_ttest(segs)
return (p2 if side == "two" else p1) < 0.05
def adaptation(units, seq, base, guard=1.0):
"""Per-unit ratios only where the pulse 1 response is above `guard` Hz (1 Hz, so that near-zero
denominators do not enter)."""
pe = pd.DataFrame({u: pulse_evoked(u, base) for u in units}).T
p1, p2, p3 = pe[(seq, 1)], pe[(seq, 2)], pe[(seq, 3)]
ok = p1 > guard
out = {}
for n, pn in [("2/1", p2), ("3/1", p3)]:
ratio = (pn / p1)[ok]
out[n] = dict(mean_ratio=ratio.mean(), sem=ratio.sem(), ratio_of_means=pn.mean() / p1.mean(),
p_ratio_vs_1=stats.ttest_1samp(ratio, 1).pvalue, p_paired=stats.ttest_rel(pn, p1).pvalue,
n=len(units), n_ratio=int(ok.sum()))
return pd.DataFrame(out).T, pe
fastrs = {c: U.uid[(U[c] == "Fast") & (U.type == "SU_RS")].values for c in ["cls", "cls_a"]}
resp = {(c, side): [u for u in fastrs[c] if f_responsive(u, side)] for c in fastrs for side in ["one", "two", "first"]}
for c in fastrs:
resp[(c, "all Fast RS")] = list(fastrs[c])
for k, v in resp.items():
print(k, "Fast RS single units", len(fastrs[k[0]]), "selected", len(v))
ADAPT, AT = {}, []
for (c, side), units in resp.items():
for base in ["25", "10"]:
tab, pe = adaptation(units, "FFF", base)
ADAPT[(c, side, base)] = pe
AT.append(tab.assign(classes=c, selection=side, baseline=base).reset_index().rename(columns={"index": "ratio"}))
AT = pd.concat(AT)
AT["ratio_of_means_within"] = np.abs(AT.ratio_of_means - AT.ratio.map({"2/1": 0.80, "3/1": 0.70})) <= AT.ratio.map({"2/1": 0.11, "3/1": 0.14})
AT["mean_ratio_within"] = np.abs(AT.mean_ratio - AT.ratio.map({"2/1": 0.80, "3/1": 0.70})) <= AT.ratio.map({"2/1": 0.11, "3/1": 0.14})
print(AT.round(3).to_string(index=False))
ok = AT.groupby(["classes", "selection", "baseline"]).apply(lambda g: pd.Series(dict(
b_within_and_p_paired=bool(g.ratio_of_means_within.all() and (g.p_paired < 0.05).all()),
b_within_and_p_ratio=bool(g.ratio_of_means_within.all() and (g.p_ratio_vs_1 < 0.05).all()),
a_within_and_p_paired=bool(g.mean_ratio_within.all() and (g.p_paired < 0.05).all()),
a_within_and_p_ratio=bool(g.mean_ratio_within.all() and (g.p_ratio_vs_1 < 0.05).all()))))
print("\nboth ratios within tolerance and both tests p < 0.05, per combination:"); print(ok.to_string())
('cls', 'one') Fast RS single units 62 selected 37
('cls', 'two') Fast RS single units 62 selected 34
('cls', 'first') Fast RS single units 62 selected 29
('cls_a', 'one') Fast RS single units 63 selected 34
('cls_a', 'two') Fast RS single units 63 selected 34
('cls_a', 'first') Fast RS single units 63 selected 28
('cls', 'all Fast RS') Fast RS single units 62 selected 62
('cls_a', 'all Fast RS') Fast RS single units 63 selected 63
ratio mean_ratio sem ratio_of_means p_ratio_vs_1 p_paired n n_ratio classes selection baseline ratio_of_means_within mean_ratio_within
2/1 0.713 0.145 0.860 0.058 0.283 37.0 29.0 cls one 25 True True
3/1 0.697 0.183 0.768 0.109 0.093 37.0 29.0 cls one 25 True True
2/1 0.950 0.141 0.878 0.725 0.283 37.0 32.0 cls one 10 True False
3/1 0.948 0.141 0.798 0.714 0.093 37.0 32.0 cls one 10 True False
2/1 0.723 0.150 0.855 0.076 0.273 34.0 28.0 cls two 25 True True
3/1 0.726 0.187 0.788 0.155 0.131 34.0 28.0 cls two 25 True True
2/1 0.956 0.145 0.873 0.764 0.273 34.0 31.0 cls two 10 True False
3/1 0.962 0.145 0.815 0.793 0.131 34.0 31.0 cls two 10 True False
2/1 0.795 0.137 0.821 0.148 0.142 29.0 27.0 cls first 25 True True
3/1 0.851 0.128 0.743 0.255 0.040 29.0 27.0 cls first 25 True False
2/1 0.808 0.142 0.842 0.186 0.142 29.0 29.0 cls first 10 True True
3/1 0.830 0.115 0.773 0.151 0.040 29.0 29.0 cls first 10 True True
2/1 0.660 0.144 0.794 0.026 0.119 34.0 28.0 cls_a one 25 True False
3/1 0.861 0.298 0.800 0.644 0.162 34.0 28.0 cls_a one 25 True False
2/1 0.890 0.145 0.818 0.452 0.119 34.0 30.0 cls_a one 10 True True
3/1 1.133 0.251 0.823 0.599 0.162 34.0 30.0 cls_a one 10 True False
2/1 0.660 0.144 0.810 0.026 0.159 34.0 28.0 cls_a two 25 True False
3/1 0.861 0.298 0.808 0.644 0.185 34.0 28.0 cls_a two 25 True False
2/1 0.890 0.145 0.833 0.452 0.159 34.0 30.0 cls_a two 10 True True
3/1 1.133 0.251 0.831 0.599 0.185 34.0 30.0 cls_a two 10 True False
2/1 0.695 0.136 0.774 0.034 0.070 28.0 26.0 cls_a first 25 True True
3/1 1.051 0.275 0.777 0.854 0.087 28.0 26.0 cls_a first 25 True False
2/1 0.722 0.138 0.798 0.054 0.070 28.0 28.0 cls_a first 10 True True
3/1 1.017 0.250 0.800 0.946 0.087 28.0 28.0 cls_a first 10 True False
2/1 0.418 0.156 0.744 0.001 0.037 62.0 44.0 cls all Fast RS 25 True False
3/1 0.506 0.203 0.663 0.019 0.013 62.0 44.0 cls all Fast RS 25 True False
2/1 0.651 0.148 0.779 0.023 0.037 62.0 45.0 cls all Fast RS 10 True False
3/1 0.775 0.124 0.709 0.076 0.013 62.0 45.0 cls all Fast RS 10 True True
2/1 0.421 0.155 0.701 0.001 0.039 63.0 39.0 cls_a all Fast RS 25 True False
3/1 0.773 0.267 0.773 0.400 0.141 63.0 39.0 cls_a all Fast RS 25 True True
2/1 0.607 0.148 0.754 0.011 0.039 63.0 42.0 cls_a all Fast RS 10 True False
3/1 0.957 0.194 0.813 0.828 0.141 63.0 42.0 cls_a all Fast RS 10 True False
both ratios within tolerance and both tests p < 0.05, per combination:
b_within_and_p_paired b_within_and_p_ratio a_within_and_p_paired a_within_and_p_ratio
classes selection baseline
cls all Fast RS 10 True False False False
25 True True False False
first 10 False False False False
25 False False False False
one 10 False False False False
25 False False False False
two 10 False False False False
25 False False False False
cls_a all Fast RS 10 False False False False
25 False False False False
first 10 False False False False
25 False False False False
one 10 False False False False
25 False False False False
two 10 False False False False
25 False False False False
Result: reproduced, resting on the choice of units. The impulse t test selects 29 to 37 of the 62 Fast RS single units (one-sided, two-sided, first impulse only), not 61, and on those no combination of ratio and test meets the criterion (paired p 0.04 to 0.28, with ratios of means within tolerance). All 62 Fast RS single units, the count closest to the paper's 61, give ratios of population means of 0.744 (2/1) and 0.663 (3/1), within tolerance, with paired t tests p = 0.037 and 0.013 (25-ms baseline; 0.779 and 0.709, the same p, with the 0 to 10 ms baseline). The mean of per-unit ratios (pulse 1 above 1 Hz) is outside tolerance for 2/1 with either baseline (0.42 and 0.65). On the recomputed set the 63 Fast RS units give 0.701 and 0.773 with p = 0.039 and 0.141.
fig7-sss-no-adaptation¶
Adaptation was statistically absent in SSS trains (pulse 2/pulse 1 ratio 1.09, pulse 3/pulse 1 ratio 0.86).
ST = []
for (c, side), units in resp.items():
for base in ["25", "10"]:
tab, _ = adaptation(units, "SSS", base)
ST.append(tab.assign(classes=c, selection=side, baseline=base).reset_index().rename(columns={"index": "ratio"}))
ST = pd.concat(ST)
ST["ratio_of_means_within"] = np.abs(ST.ratio_of_means - ST.ratio.map({"2/1": 1.09, "3/1": 0.86})) <= ST.ratio.map({"2/1": 0.26, "3/1": 0.35})
ST["mean_ratio_within"] = np.abs(ST.mean_ratio - ST.ratio.map({"2/1": 1.09, "3/1": 0.86})) <= ST.ratio.map({"2/1": 0.26, "3/1": 0.35})
print(ST.round(3).to_string(index=False))
print("smallest p of any test: %.3f" % ST[["p_ratio_vs_1", "p_paired"]].min().min())
ratio mean_ratio sem ratio_of_means p_ratio_vs_1 p_paired n n_ratio classes selection baseline ratio_of_means_within mean_ratio_within 2/1 0.817 0.149 0.910 0.231 0.572 37.0 26.0 cls one 25 True False 3/1 0.938 0.278 0.910 0.824 0.663 37.0 26.0 cls one 25 True True 2/1 0.640 0.166 0.895 0.041 0.572 37.0 24.0 cls one 10 True False 3/1 0.774 0.201 0.894 0.274 0.663 37.0 24.0 cls one 10 True True 2/1 0.834 0.150 0.894 0.280 0.490 34.0 25.0 cls two 25 True True 3/1 0.895 0.293 0.896 0.724 0.613 34.0 25.0 cls two 25 True True 2/1 0.659 0.173 0.877 0.061 0.490 34.0 23.0 cls two 10 True False 3/1 0.772 0.210 0.879 0.291 0.613 34.0 23.0 cls two 10 True True 2/1 0.879 0.153 0.883 0.439 0.410 29.0 23.0 cls first 25 True True 3/1 0.956 0.313 0.823 0.891 0.386 29.0 23.0 cls first 25 True True 2/1 0.696 0.179 0.859 0.105 0.410 29.0 21.0 cls first 10 True False 3/1 0.737 0.220 0.787 0.246 0.386 29.0 21.0 cls first 10 True True 2/1 0.887 0.148 0.883 0.454 0.400 34.0 25.0 cls_a one 25 True True 3/1 0.993 0.239 0.881 0.978 0.532 34.0 25.0 cls_a one 25 True True 2/1 0.711 0.164 0.883 0.090 0.400 34.0 25.0 cls_a one 10 True False 3/1 0.819 0.203 0.881 0.381 0.532 34.0 25.0 cls_a one 10 True True 2/1 0.879 0.143 0.878 0.406 0.377 34.0 26.0 cls_a two 25 True True 3/1 0.945 0.234 0.865 0.818 0.473 34.0 26.0 cls_a two 25 True True 2/1 0.711 0.164 0.877 0.090 0.377 34.0 25.0 cls_a two 10 True False 3/1 0.819 0.203 0.863 0.381 0.473 34.0 25.0 cls_a two 10 True True 2/1 0.926 0.144 0.845 0.615 0.203 28.0 24.0 cls_a first 25 True True 3/1 1.008 0.246 0.774 0.973 0.212 28.0 24.0 cls_a first 25 True True 2/1 0.714 0.173 0.838 0.113 0.203 28.0 22.0 cls_a first 10 True False 3/1 0.731 0.214 0.764 0.221 0.212 28.0 22.0 cls_a first 10 True True 2/1 0.713 0.139 0.892 0.046 0.465 62.0 39.0 cls all Fast RS 25 True False 3/1 0.778 0.201 0.871 0.277 0.504 62.0 39.0 cls all Fast RS 25 True True 2/1 0.660 0.150 0.884 0.029 0.465 62.0 40.0 cls all Fast RS 10 True False 3/1 0.780 0.221 0.862 0.325 0.504 62.0 40.0 cls all Fast RS 10 True True 2/1 0.765 0.139 0.875 0.101 0.395 63.0 36.0 cls_a all Fast RS 25 True False 3/1 0.796 0.181 0.850 0.269 0.459 63.0 36.0 cls_a all Fast RS 25 True True 2/1 0.741 0.142 0.880 0.077 0.395 63.0 40.0 cls_a all Fast RS 10 True False 3/1 0.745 0.220 0.856 0.254 0.459 63.0 40.0 cls_a all Fast RS 10 True True smallest p of any test: 0.029
Result: reproduced. On the same 62 Fast RS units, the SSS ratios of population means are 0.892 (2/1) and 0.871 (3/1), within tolerance, and the paired tests are not significant (p = 0.465 and 0.504). The per-unit ratio 2/1 differs from 1 (mean 0.713, p = 0.046 with the 25-ms baseline), outside tolerance, so the claim holds under the ratio of means with the paired test, the combination that gives fig7-fff-adaptation. Over every selection and baseline the ratios of means are 0.76 to 0.91.
s4-fms-middle-pulse¶
The middle M pulse appeared weaker in FMS than in SMF sequences in Fast RS single units, but the difference was not significant.
for (c, side, base), pe in ADAPT.items():
a, b = pe[("FMS", 2)], pe[("SMF", 2)]
t = stats.ttest_rel(a, b)
print("classes %s, selection %s, baseline %s: n = %d, pulse 2 FMS %.2f, SMF %.2f Hz, diff %.2f Hz, paired t = %.2f, p = %.3f"
% (c, side, base, len(a), a.mean(), b.mean(), a.mean() - b.mean(), t.statistic, t.pvalue))
classes cls, selection one, baseline 25: n = 37, pulse 2 FMS 6.62, SMF 8.06 Hz, diff -1.45 Hz, paired t = -1.13, p = 0.266 classes cls, selection one, baseline 10: n = 37, pulse 2 FMS 7.14, SMF 7.58 Hz, diff -0.44 Hz, paired t = -0.27, p = 0.791 classes cls, selection two, baseline 25: n = 34, pulse 2 FMS 7.20, SMF 8.52 Hz, diff -1.32 Hz, paired t = -0.95, p = 0.348 classes cls, selection two, baseline 10: n = 34, pulse 2 FMS 7.72, SMF 7.87 Hz, diff -0.15 Hz, paired t = -0.08, p = 0.933 classes cls, selection first, baseline 25: n = 29, pulse 2 FMS 7.42, SMF 10.00 Hz, diff -2.57 Hz, paired t = -1.75, p = 0.091 classes cls, selection first, baseline 10: n = 29, pulse 2 FMS 7.51, SMF 9.25 Hz, diff -1.74 Hz, paired t = -1.00, p = 0.326 classes cls_a, selection one, baseline 25: n = 34, pulse 2 FMS 7.05, SMF 8.65 Hz, diff -1.60 Hz, paired t = -1.15, p = 0.259 classes cls_a, selection one, baseline 10: n = 34, pulse 2 FMS 7.73, SMF 7.92 Hz, diff -0.20 Hz, paired t = -0.11, p = 0.913 classes cls_a, selection two, baseline 25: n = 34, pulse 2 FMS 7.21, SMF 8.84 Hz, diff -1.62 Hz, paired t = -1.17, p = 0.251 classes cls_a, selection two, baseline 10: n = 34, pulse 2 FMS 7.82, SMF 7.99 Hz, diff -0.17 Hz, paired t = -0.09, p = 0.926 classes cls_a, selection first, baseline 25: n = 28, pulse 2 FMS 7.74, SMF 10.68 Hz, diff -2.94 Hz, paired t = -1.95, p = 0.062 classes cls_a, selection first, baseline 10: n = 28, pulse 2 FMS 7.91, SMF 9.88 Hz, diff -1.97 Hz, paired t = -1.08, p = 0.288 classes cls, selection all Fast RS, baseline 25: n = 62, pulse 2 FMS 3.77, SMF 5.03 Hz, diff -1.26 Hz, paired t = -1.46, p = 0.150 classes cls, selection all Fast RS, baseline 10: n = 62, pulse 2 FMS 3.77, SMF 4.68 Hz, diff -0.91 Hz, paired t = -0.83, p = 0.411 classes cls_a, selection all Fast RS, baseline 25: n = 63, pulse 2 FMS 3.70, SMF 5.30 Hz, diff -1.60 Hz, paired t = -1.74, p = 0.087 classes cls_a, selection all Fast RS, baseline 10: n = 63, pulse 2 FMS 3.59, SMF 4.54 Hz, diff -0.95 Hz, paired t = -0.84, p = 0.403
Result: reproduced. In the 62 Fast RS units the pulse 2 response is 1.26 Hz lower in FMS than SMF with the 25-ms baseline (p = 0.150) and 0.91 Hz lower with the 0 to 10 ms one (p = 0.411). Every selection gives FMS lower and p of 0.06 or more; the 63 units of the recomputed set give 1.60 Hz, p = 0.087, close to the paper's p = 0.08.
fig7de-medium-suppressed¶
Medium units were suppressed by F, M and S impulses and did not distinguish impulse identity or sequence identity.
for nm, ne, sr, c in [("this attempt", NE, SR, "cls"), ("variant: recomputed modulated set (a)", NE_a, SR_a, "cls_a")]:
us = U.uid[U[c] == "Medium"]
f = ne.loc[us]
t1 = stats.ttest_rel(f.F, f.S)
print("%s: n = %d Medium units; net evoked F %.2f, M %.2f, S %.2f Hz; all negative: %s; F vs S t = %.2f p = %.3f"
% (nm, len(f), f.F.mean(), f.M.mean(), f.S.mean(), (f.mean() < 0).all(), t1.statistic, t1.pvalue))
print(" one-sample t against 0:", {k: round(stats.ttest_1samp(f[k], 0).pvalue, 4) for k in KINDS})
for b in ["25", "10"]:
s = sr[b].loc[us]
t2 = stats.ttest_rel(s.FFF, s.SSS)
print(" baseline %s: sequence rates %s; FFF vs SSS diff %.2f t = %.2f p = %.3f" % (b, s.mean().round(2).to_dict(), (s.FFF - s.SSS).mean(), t2.statistic, t2.pvalue))
this attempt: n = 53 Medium units; net evoked F -0.27, M -0.39, S -0.52 Hz; all negative: True; F vs S t = 0.30 p = 0.766
one-sample t against 0: {'F': np.float64(0.7237), 'M': np.float64(0.6906), 'S': np.float64(0.4467)}
baseline 25: sequence rates {'FFF': -3.21, 'FMS': -3.19, 'SMF': -3.35, 'SSS': -4.48}; FFF vs SSS diff 1.27 t = 1.44 p = 0.156
baseline 10: sequence rates {'FFF': -1.99, 'FMS': -2.21, 'SMF': -3.71, 'SSS': -3.93}; FFF vs SSS diff 1.94 t = 1.30 p = 0.200
variant: recomputed modulated set (a): n = 50 Medium units; net evoked F 0.20, M -0.22, S -0.28 Hz; all negative: False; F vs S t = 0.56 p = 0.581
one-sample t against 0: {'F': np.float64(0.8059), 'M': np.float64(0.8229), 'S': np.float64(0.6963)}
baseline 25: sequence rates {'FFF': -3.3, 'FMS': -2.31, 'SMF': -2.99, 'SSS': -3.96}; FFF vs SSS diff 0.67 t = 0.78 p = 0.437
baseline 10: sequence rates {'FFF': -2.73, 'FMS': -1.59, 'SMF': -3.53, 'SSS': -3.86}; FFF vs SSS diff 1.13 t = 0.73 p = 0.467
Result: reproduced, resting on the unit set. The 53 Medium units have negative net evoked rates for all three impulses (-0.27 F, -0.39 M, -0.52 Hz S), and they do not distinguish F from S (p = 0.766) or FFF from SSS (p = 0.156 and 0.200), which meets the criterion. None of the three rates differs from 0 (p 0.45 to 0.72), so the suppression is small. On the recomputed set (50 units) the F rate is +0.20 Hz and the criterion is not met.
fig8a-slow-positive-no-sequence-difference¶
Slow Positive units showed small, sustained responses mostly to the second and third impulses, evident for F and M but not S impulses, and their mean firing did not differ between FFF, FMS, SMF and SSS.
def rm_anova(Y):
"""One-way repeated-measures ANOVA, Y units x conditions."""
Y = np.asarray(Y, float)
n, k = Y.shape
gm = Y.mean()
ss_c = n * ((Y.mean(0) - gm) ** 2).sum()
ss_s = k * ((Y.mean(1) - gm) ** 2).sum()
ss_e = ((Y - gm) ** 2).sum() - ss_c - ss_s
F = (ss_c / (k - 1)) / (ss_e / ((n - 1) * (k - 1)))
return F, stats.f.sf(F, k - 1, (n - 1) * (k - 1))
for nm, ne, sr, c in [("this attempt", NE, SR, "cls"), ("variant: recomputed modulated set (a)", NE_a, SR_a, "cls_a")]:
us = U.uid[U[c] == "SlowPos"]
f = ne.loc[us]
tt = {k: stats.ttest_1samp(f[k], 0) for k in KINDS}
print("%s: n = %d Slow Positive; net evoked %s Hz; one-sample t p: %s" % (nm, len(f), f.mean().round(2).to_dict(),
{k: "%.3g (t %.2f)" % (v.pvalue, v.statistic) for k, v in tt.items()}))
for b in ["25", "10"]:
s = sr[b].loc[us]
F, p = rm_anova(s.values)
print(" baseline %s: sequence rates %s; RM-ANOVA F = %.2f p = %.3f" % (b, s.mean().round(2).to_dict(), F, p))
pp = pd.DataFrame({u: pulse_evoked(u, "25") for u in U.uid[U.cls == "SlowPos"]}).T
print("pulse-evoked rate above the 25-ms baseline by pulse (mean over Slow Positive units and sequences):",
{p: round(pp[[c for c in pp.columns if c[1] == p]].mean(axis=1).mean(), 2) for p in (1, 2, 3)})
this attempt: n = 51 Slow Positive; net evoked {'F': 1.77, 'M': 2.71, 'S': 1.3} Hz; one-sample t p: {'F': '0.000938 (t 3.52)', 'M': '0.00106 (t 3.48)', 'S': '0.0205 (t 2.39)'}
baseline 25: sequence rates {'FFF': 3.38, 'FMS': 2.18, 'SMF': 0.64, 'SSS': 1.81}; RM-ANOVA F = 4.38 p = 0.005
baseline 10: sequence rates {'FFF': 2.51, 'FMS': 2.62, 'SMF': 1.18, 'SSS': 1.84}; RM-ANOVA F = 1.16 p = 0.329
variant: recomputed modulated set (a): n = 50 Slow Positive; net evoked {'F': 1.35, 'M': 2.89, 'S': 1.29} Hz; one-sample t p: {'F': '0.00291 (t 3.13)', 'M': '0.000167 (t 4.08)', 'S': '0.0219 (t 2.37)'}
baseline 25: sequence rates {'FFF': 2.67, 'FMS': 2.06, 'SMF': 0.6, 'SSS': 1.71}; RM-ANOVA F = 2.25 p = 0.085
baseline 10: sequence rates {'FFF': 2.04, 'FMS': 2.48, 'SMF': 0.91, 'SSS': 1.99}; RM-ANOVA F = 1.08 p = 0.361
pulse-evoked rate above the 25-ms baseline by pulse (mean over Slow Positive units and sequences): {1: np.float64(-0.43), 2: np.float64(1.87), 3: np.float64(5.8)}
Result: partially reproduced. Slow Positive units respond to F (1.77 Hz, p = 0.0009) and M impulses (2.71 Hz, p = 0.0011), but also to S (1.30 Hz, p = 0.021), which the claim says they do not. Their sequence rates do not differ with the 0 to 10 ms baseline (repeated-measures ANOVA p = 0.329) and differ with the 25-ms baseline (p = 0.005). Responses grow over the pulses (-0.43, 1.87, 5.80 Hz for pulses 1 to 3). The recomputed set gives the same for the S response (p = 0.022).
fig8b-slow-negative-no-impulse-response¶
Slow Negative units did not respond to impulses, and their firing declined steadily over time.
for nm, ne, c in [("this attempt", NE, "cls"), ("variant: recomputed modulated set (a)", NE_a, "cls_a")]:
us = U.uid[U[c] == "SlowNeg"]
f = ne.loc[us]
tt = {k: stats.ttest_1samp(f[k], 0) for k in KINDS}
pos = [k for k, v in tt.items() if v.statistic > 0 and v.pvalue < 0.05]
pop = np.mean([unit_psth(u, 0, 180) for u in us], 0)
sl = stats.linregress(np.arange(180), pop)
print("%s: n = %d Slow Negative; net evoked %s Hz; t (p): %s; significantly positive kinds: %s; PSTH slope 0-180 ms %.2f Hz/100 ms (p = %.2g)"
% (nm, len(f), f.mean().round(2).to_dict(), {k: "%.2f (%.3g)" % (v.statistic, v.pvalue) for k, v in tt.items()}, pos, 100 * sl.slope, sl.pvalue))
this attempt: n = 46 Slow Negative; net evoked {'F': 0.5, 'M': -0.7, 'S': 0.82} Hz; t (p): {'F': '0.78 (0.439)', 'M': '-0.77 (0.447)', 'S': '0.94 (0.354)'}; significantly positive kinds: []; PSTH slope 0-180 ms -5.90 Hz/100 ms (p = 1.1e-50)
variant: recomputed modulated set (a): n = 50 Slow Negative; net evoked {'F': 1.2, 'M': -0.92, 'S': 0.64} Hz; t (p): {'F': '1.87 (0.0679)', 'M': '-1.06 (0.293)', 'S': '0.77 (0.445)'}; significantly positive kinds: []; PSTH slope 0-180 ms -5.54 Hz/100 ms (p = 2.4e-51)
Result: reproduced. No impulse kind evokes a significant increase in the 46 Slow Negative units (t 0.78, -0.77 and 0.94), and their population rate falls from 0 to 180 ms (-5.90 Hz per 100 ms).
fig8d-slow-positive-right-choice-l5¶
Slow Positive units fired more on right-choice trials (contralateral to the recording) for all stimuli; right-choice bias, measured 5 to 50 ms after the start of the final impulse, was significant in L5a and L5b but not in other layers.
def choice_bias(u):
"""Rate 5-50 ms after the third impulse onset, right minus left: (a) all trials pooled, (b) per sequence, averaged."""
M, t, _ = D.unit_trials(u)
si = int(U.session[u])
r = np.zeros(len(t))
for s in ssc4.STIMS:
m = (t.stim == s).values
on = D.onsets(si, s)[2]
r[m] = ssc4.rate(M[m], on + 5, on + 50)
right = t.chosen.values == 1
a = (r[right].mean(), r[~right].mean())
d = []
for s in ssc4.STIMS:
m = (t.stim == s).values
if (m & right).any() and (m & ~right).any():
d.append((r[m & right].mean(), r[m & ~right].mean()))
b = tuple(np.mean(d, 0))
return a + b
def bias_table(cl, c="cls"):
us = U.uid[U[c].isin(cl)]
cb = pd.DataFrame({u: choice_bias(u) for u in us}, index=["aR", "aL", "bR", "bL"]).T
cb["layer"] = U.layer[us].values
rows = []
for lay in order:
g = cb[cb.layer == lay]
row = dict(layer=lay, n=len(g))
for rd in "ab":
if len(g) > 1:
t = stats.ttest_rel(g[rd + "R"], g[rd + "L"])
row.update({rd + "_diff": (g[rd + "R"] - g[rd + "L"]).mean(), rd + "_t": t.statistic, rd + "_p": t.pvalue})
rows.append(row)
return pd.DataFrame(rows).set_index("layer")
for nm, c in [("this attempt", "cls"), ("variant: recomputed modulated set (a)", "cls_a")]:
bt8 = bias_table(["SlowPos"], c)
print(nm, "Slow Positive"); print(bt8.round(4).to_string())
for rd in "ab":
ok = (bt8.loc[["L5a", "L5b"], rd + "_p"] < 0.05).all() and (bt8.loc[["L5a", "L5b"], rd + "_diff"] > 0).all() and \
not (bt8.loc[["L2/3", "L4", "L6"], rd + "_p"] < 0.05).any()
print(" reading %s: L5a and L5b significant with right higher, other layers not: %s" % (rd, ok))
print("\nVariant (not judged): Fast and Medium units by layer")
print(bias_table(["Fast", "Medium"]).round(4).to_string())
print("paper's starred p-values: 0.022, 9.5e-4, 7.5e-5")
this attempt
Slow Positive
n a_diff a_t a_p b_diff b_t b_p
layer
L2/3 1 NaN NaN NaN NaN NaN NaN
L4 5 0.1985 0.2704 0.8002 0.1653 0.2746 0.7972
L5a 7 4.5793 2.4628 0.0489 4.2039 2.1629 0.0738
L5b 14 6.6218 3.3589 0.0051 7.6923 4.4169 0.0007
L6 24 0.9690 1.0516 0.3039 1.0352 1.0737 0.2941
reading a: L5a and L5b significant with right higher, other layers not: True
reading b: L5a and L5b significant with right higher, other layers not: False
variant: recomputed modulated set (a) Slow Positive
n a_diff a_t a_p b_diff b_t b_p
layer
L2/3 2 -1.2133 -1.0374 0.4883 -2.1042 -1.1172 0.4648
L4 7 0.0811 0.1251 0.9045 0.1420 0.2624 0.8018
L5a 6 4.2658 1.8940 0.1168 4.4351 1.8638 0.1214
L5b 15 6.3173 3.3800 0.0045 7.2414 4.2616 0.0008
L6 20 1.2255 1.1594 0.2607 1.4073 1.3058 0.2072
reading a: L5a and L5b significant with right higher, other layers not: False
reading b: L5a and L5b significant with right higher, other layers not: False
Variant (not judged): Fast and Medium units by layer
n a_diff a_t a_p b_diff b_t b_p layer L2/3 23 1.5763 1.5996 0.1240 0.2959 0.3081 0.7609 L4 64 1.8119 3.1088 0.0028 1.5476 2.5535 0.0131 L5a 39 1.4736 1.8230 0.0762 1.1268 1.3404 0.1881 L5b 57 1.2696 2.1125 0.0391 0.5823 0.8140 0.4191 L6 30 1.6563 1.3830 0.1772 1.5020 1.1455 0.2614 paper's starred p-values: 0.022, 9.5e-4, 7.5e-5
Result: reproduced, resting on the unit set. Under reading (a), Slow Positive units in L5a (7 units, 4.58 Hz, p = 0.049) and L5b (14 units, 6.62 Hz, p = 0.0051) fire more on right-choice trials, and L4 and L6 show no bias (L2/3 has one unit, so no test). Under reading (b) L5a is not significant (p = 0.074). On the recomputed set L5a is not significant under either reading (6 units, p = 0.117 and 0.121). The printed p-values here are not the paper's (0.022, 9.5e-4, 7.5e-5).
fig8e-choice-divergence-125ms¶
In L5 Slow Positive units, firing on right- and left-choice trials diverged after the second impulse and was consistently significant by 125 ms, before the earliest withdrawals (150 ms) and the mean withdrawal time (190 ms).
Per unit the PSTH for each choice is the mean of its per-sequence PSTHs (sequences with trials of that choice). "Lasts to the end of the third impulse" is taken as lasting to 150 ms, the end of the 0-150 ms sequence window of the paper, a standard choice; 140 and 160 ms are shown too. A trailing 10-ms window (value at t the mean of t-9 to t) is a variant of reading (a).
def choice_psth(u, a=-50, b=250):
M, t, _ = D.unit_trials(u)
out = {}
for c in (1, 0):
ps = [M[((t.stim == s) & (t.chosen == c)).values, a - ssc4.T0:b - ssc4.T0].mean(0) * 1000
for s in ssc4.STIMS if ((t.stim == s) & (t.chosen == c)).any()]
out[c] = np.mean(ps, 0)
return out
TAX = np.arange(-50, 250)
def sliding(us, reading):
R = np.array([choice_psth(u)[1] for u in us])
L = np.array([choice_psth(u)[0] for u in us])
if reading == "a": # 10-ms windows stepped by 1 ms, centred
k = np.ones(10) / 10
R = np.array([np.convolve(r, k, "same") for r in R]); L = np.array([np.convolve(r, k, "same") for r in L])
t = TAX
elif reading == "a_trailing": # 10-ms windows stepped by 1 ms, value at t = mean of t-9..t
k = np.ones(10) / 10
R = np.array([np.convolve(r, k)[:len(r)] for r in R]); L = np.array([np.convolve(r, k)[:len(r)] for r in L])
t = TAX
else: # 5-ms bins
R = R.reshape(len(us), -1, 5).mean(2); L = L.reshape(len(us), -1, 5).mean(2)
t = TAX[::5]
tt = stats.ttest_rel(R, L, axis=0)
return t, tt.pvalue, (R - L).mean(0)
def onset_of_run(t, p, end):
s = p < 0.05
m = t <= end
for i in np.where(m & s)[0]:
if s[i:np.searchsorted(t, end, "right")].all():
return t[i]
return np.nan
for nm, c in [("this attempt", "cls"), ("variant: recomputed modulated set (a)", "cls_a")]:
us = U.uid[(U[c] == "SlowPos") & U.layer.isin(["L5a", "L5b"])].values
for rd in ["a", "b", "a_trailing"]:
t, p, d = sliding(us, rd)
ons = {end: onset_of_run(t, p, end) for end in (140, 150, 160)}
first = t[(p < 0.05) & (t >= 0)]
print("%s, reading %s: n = %d L5 Slow Positive; onset of the run lasting to 140/150/160 ms: %s; first significant time after 0: %s"
% (nm, rd, len(us), ons, first[0] if len(first) else None))
us = U.uid[(U.cls == "SlowPos") & U.layer.isin(["L5a", "L5b"])].values
tr = pd.concat([D.unit_trials(u)[1].assign(session=int(U.session[u])) for u in us]).drop_duplicates(["session", "trial"])
print("withdrawal after onset over the %d trials of these units' sessions: min %.0f, 1st percentile %.1f, mean %.1f ms"
% (len(tr), tr.withdraw_t.min(), np.percentile(tr.withdraw_t, 1), tr.withdraw_t.mean()))
t, p, d = sliding(us, "a")
print("right minus left (Hz), 10-ms windows, at 50/75/100/125/150 ms:", {x: round(float(d[TAX == x][0]), 2) for x in (50, 75, 100, 125, 150)})
this attempt, reading a: n = 21 L5 Slow Positive; onset of the run lasting to 140/150/160 ms: {140: np.int64(120), 150: np.int64(120), 160: np.int64(120)}; first significant time after 0: 18
this attempt, reading b: n = 21 L5 Slow Positive; onset of the run lasting to 140/150/160 ms: {140: np.int64(120), 150: np.int64(120), 160: np.int64(160)}; first significant time after 0: 85
this attempt, reading a_trailing: n = 21 L5 Slow Positive; onset of the run lasting to 140/150/160 ms: {140: np.int64(124), 150: np.int64(124), 160: np.int64(124)}; first significant time after 0: 22
variant: recomputed modulated set (a), reading a: n = 21 L5 Slow Positive; onset of the run lasting to 140/150/160 ms: {140: np.int64(122), 150: np.int64(122), 160: nan}; first significant time after 0: 16
variant: recomputed modulated set (a), reading b: n = 21 L5 Slow Positive; onset of the run lasting to 140/150/160 ms: {140: np.int64(125), 150: nan, 160: nan}; first significant time after 0: 45
variant: recomputed modulated set (a), reading a_trailing: n = 21 L5 Slow Positive; onset of the run lasting to 140/150/160 ms: {140: np.int64(126), 150: np.int64(126), 160: nan}; first significant time after 0: 0
withdrawal after onset over the 2443 trials of these units' sessions: min 154, 1st percentile 158.0, mean 193.3 ms
right minus left (Hz), 10-ms windows, at 50/75/100/125/150 ms: {50: -0.36, 75: 2.43, 100: 3.71, 125: 4.05, 150: 10.34}
Result: reproduced. In 21 L5 Slow Positive units the right-left difference is significant without a break from 120 ms to the end of the sequence with 10-ms windows (reading a), whether the end is taken as 140, 150 or 160 ms; a trailing window gives 124 ms. With 5-ms bins the run starts at 120 ms and lasts to 150 ms. Withdrawals over the same sessions are at 154 ms at the earliest and 193.3 ms on average, all three values within tolerance.
fig8d-fast-medium-no-choice-bias¶
Choice-related activity was absent in L4 Fast units.
for nm, c in [("this attempt", "cls"), ("variant: recomputed modulated set (a)", "cls_a")]:
us = U.uid[(U[c] == "Fast") & (U.layer == "L4")].values
for rd in "ab":
t, p, d = sliding(us, rd)
m = (t >= 0) & (t <= 150) if rd == "a" else (t >= 0) & (t + 5 <= 150)
sigt = t[m & (p < 0.05)]
print("%s, reading %s: n = %d L4 Fast; significant times 0-150 ms: %d (%s); run lasting to 150 ms from: %s; largest |R-L| 0-150 ms %.2f Hz"
% (nm, rd, len(us), len(sigt), sigt[:20].tolist(), onset_of_run(t, p, 150), np.abs(d[m]).max()))
print("\nVariant: Fast and Medium right-choice bias by layer is printed under fig8d-slow-positive-right-choice-l5.")
this attempt, reading a: n = 53 L4 Fast; significant times 0-150 ms: 5 ([28, 29, 31, 32, 91]); run lasting to 150 ms from: nan; largest |R-L| 0-150 ms 2.40 Hz
this attempt, reading b: n = 53 L4 Fast; significant times 0-150 ms: 0 ([]); run lasting to 150 ms from: 150; largest |R-L| 0-150 ms 3.31 Hz
variant: recomputed modulated set (a), reading a: n = 56 L4 Fast; significant times 0-150 ms: 5 ([5, 6, 7, 8, 9]); run lasting to 150 ms from: nan; largest |R-L| 0-150 ms 2.57 Hz
variant: recomputed modulated set (a), reading b: n = 56 L4 Fast; significant times 0-150 ms: 0 ([]); run lasting to 150 ms from: 150; largest |R-L| 0-150 ms 2.73 Hz Variant: Fast and Medium right-choice bias by layer is printed under fig8d-slow-positive-right-choice-l5.
Result: reproduced. With 5-ms bins (reading b) no bin from 0 to 150 ms differs between right- and left-choice trials in the 53 L4 Fast units. With 1-ms steps of 10-ms windows (reading a), 5 steps (28, 29, 31, 32 and 91 ms) reach p < 0.05, with no run lasting to the end of the sequence. The largest difference is 2.4 to 3.3 Hz.
s5-slow-positive-no-integration¶
Within right- or left-choice trials, L5 Slow Positive units fired little to pulses 1 and 2, and their pulse 3 firing was the same for FFF, FMS, SMF and SSS and did not correlate with mean speed of the sequence or of the last two impulses.
Impulse mean speed is taken from the S1 Fig speed profiles in S2 Data (sheet "Fig S1"), as the criterion says: each impulse is the span where the panel is more than 0.2 mm from its rest position, and its mean speed the mean of the speed column over that span, per sequence. The first run used a ramp on the Table 1 amplitudes, now a variant.
s1f = S2["Fig S1"].iloc[3:].astype(float).values
tt_ms = s1f[:, 0] * 1000
inst_speed, own_speed = {}, {}
for j, s in enumerate(["FFF", "FMS", "SMF", "SSS"]):
pos, sp = s1f[:, 1 + j], s1f[:, 5 + j]
on = (pos - np.median(pos[tt_ms < 60])) > 0.2 # panel more than 0.2 mm out of its rest position
d = np.diff(np.r_[0, on.astype(int), 0])
seg = [(a, b) for a, b in zip(np.where(d == 1)[0], np.where(d == -1)[0]) if b - a > 12]
inst_speed[s] = [sp[a:b].mean() for a, b in seg]
own = [] # variant: span above 20% of the impulse's own excursion from the lowest position of the 15 ms before it
for a, b in seg:
pk = a + np.argmax(pos[a:b])
lo = pos[max(0, a - 60):a].min()
thr = lo + 0.2 * (pos[pk] - lo)
l, r = pk, pk
while l > 0 and pos[l] > thr:
l -= 1
while r < len(pos) - 1 and pos[r] > thr:
r += 1
own.append(sp[l + 1:r].mean())
own_speed[s] = own
print("%s impulses from S2 Data 'Fig S1' (onset ms, duration ms, mean speed mm/s):" % s,
[(round(tt_ms[a], 1), round(tt_ms[b - 1] - tt_ms[a], 1), round(sp[a:b].mean(), 1)) for a, b in seg])
assert all(len(v) == 3 for v in inst_speed.values())
print("variant, span above 20%% of each impulse's own excursion (mm/s): %s" % {s: [round(v, 1) for v in own_speed[s]] for s in own_speed})
kind_speed = collections.defaultdict(list)
for s in inst_speed:
for k, v in zip(s, inst_speed[s]):
kind_speed[k].append(v)
kind_speed = {k: np.mean(v) for k, v in kind_speed.items()}
print("variant, one speed per impulse kind, the mean of its 0.2-mm spans (mm/s):", {k: round(v, 1) for k, v in kind_speed.items()})
ramp = {"F": 2 * 1.03 / 16 * 1000, "M": 2 * 1.15 / 22 * 1000, "S": 2 * 1.14 / 28 * 1000}
print("Table 1 ramp speeds (first run, now a variant):", {k: round(v, 1) for k, v in ramp.items()})
two_speed = {"0.2-mm span": lambda s, k: inst_speed[s][k], "own excursion": lambda s, k: own_speed[s][k],
"per kind": lambda s, k: kind_speed[s[k]], "Table 1 ramp": lambda s, k: ramp[s[k]]}
s5_rows = []
for nm, c in [("this attempt", "cls"), ("variant: recomputed modulated set (a)", "cls_a")]:
us = U.uid[(U[c] == "SlowPos") & U.layer.isin(["L5a", "L5b"])].values
for ch, chn in [(1, "right"), (0, "left")]:
for base in ["25", "10"]:
pe = pd.DataFrame({u: pulse_evoked(u, base, lambda t, ch=ch: (t.complete & (t.chosen == ch)).values) for u in us}).T
p3 = pe[[(s, 3) for s in ["FFF", "FMS", "SMF", "SSS"]]].dropna()
F, p = rm_anova(p3.values)
pop = p3.mean()
seqs = ["FFF", "FMS", "SMF", "SSS"]
r1 = stats.pearsonr([ssc4.MEAN_SPEED[s] for s in seqs], pop.values)
r2 = stats.pearsonr([np.mean(inst_speed[s][1:3]) for s in seqs], pop.values)
r3 = stats.pearsonr([np.mean(inst_speed[s][0:2]) for s in seqs], pop.values)
r2r = stats.pearsonr([(ramp[s[1]] + ramp[s[2]]) / 2 for s in seqs], pop.values)
p12 = pe[[c2 for c2 in pe.columns if c2[1] in (1, 2)]].mean().mean()
print("%s, %s choice, baseline %s: n = %d; pulse 1-2 mean %.2f Hz; pulse 3 %s; RM-ANOVA F = %.2f p = %.3f; r(seq speed) = %.2f p = %.2f; r(pulses 2,3) = %.2f p = %.2f; r(pulses 1,2) = %.2f p = %.2f; variant, r(pulses 2,3, Table 1 ramp) = %.2f p = %.2f"
% (nm, chn, base, len(p3), p12, pop.round(2).to_dict(), F, p, r1[0], r1[1], r2[0], r2[1], r3[0], r3[1], r2r[0], r2r[1]))
for spn, f in two_speed.items():
for pulses, ks in [("2,3", (1, 2)), ("1,2", (0, 1))]:
rr = stats.pearsonr([np.mean([f(s, k) for k in ks]) for s in seqs], pop.values)
s5_rows.append(dict(set=nm, choice=chn, baseline=base, speeds=spn, pulses=pulses, r=round(rr[0], 3), p=round(rr[1], 3)))
print("\nCorrelation of the pulse 3 population rate with the mean speed of two impulses, by how the impulse speed is taken from S1 Fig:")
print(pd.DataFrame(s5_rows).pivot_table(index=["set", "choice", "baseline", "pulses"], columns="speeds", values="p").to_string())
FFF impulses from S2 Data 'Fig S1' (onset ms, duration ms, mean speed mm/s): [(np.float64(75.8), np.float64(13.8), np.float64(135.0)), (np.float64(127.0), np.float64(12.0), np.float64(150.8)), (np.float64(177.0), np.float64(12.0), np.float64(152.6))]
FMS impulses from S2 Data 'Fig S1' (onset ms, duration ms, mean speed mm/s): [(np.float64(75.8), np.float64(13.8), np.float64(135.3)), (np.float64(127.8), np.float64(14.8), np.float64(123.7)), (np.float64(183.0), np.float64(19.0), np.float64(91.1))]
SMF impulses from S2 Data 'Fig S1' (onset ms, duration ms, mean speed mm/s): [(np.float64(77.2), np.float64(19.5), np.float64(85.1)), (np.float64(136.5), np.float64(18.0), np.float64(103.3)), (np.float64(191.5), np.float64(13.2), np.float64(144.0))]
SSS impulses from S2 Data 'Fig S1' (onset ms, duration ms, mean speed mm/s): [(np.float64(77.2), np.float64(19.8), np.float64(83.5)), (np.float64(137.0), np.float64(20.2), np.float64(81.4)), (np.float64(197.0), np.float64(20.8), np.float64(79.8))]
variant, span above 20% of each impulse's own excursion (mm/s): {'FFF': [np.float64(134.7), np.float64(151.2), np.float64(153.2)], 'FMS': [np.float64(135.7), np.float64(122.4), np.float64(91.4)], 'SMF': [np.float64(85.4), np.float64(103.3), np.float64(144.1)], 'SSS': [np.float64(83.5), np.float64(81.4), np.float64(79.8)]}
variant, one speed per impulse kind, the mean of its 0.2-mm spans (mm/s): {'F': np.float64(143.5), 'M': np.float64(113.5), 'S': np.float64(84.2)}
Table 1 ramp speeds (first run, now a variant): {'F': 128.8, 'M': 104.5, 'S': 81.4}
this attempt, right choice, baseline 25: n = 21; pulse 1-2 mean 2.00 Hz; pulse 3 {('FFF', 3): 11.77, ('FMS', 3): 12.5, ('SMF', 3): 5.32, ('SSS', 3): 12.58}; RM-ANOVA F = 3.73 p = 0.016; r(seq speed) = -0.08 p = 0.92; r(pulses 2,3) = -0.27 p = 0.73; r(pulses 1,2) = 0.35 p = 0.65; variant, r(pulses 2,3, Table 1 ramp) = -0.45 p = 0.55
this attempt, right choice, baseline 10: n = 21; pulse 1-2 mean 1.34 Hz; pulse 3 {('FFF', 3): 9.99, ('FMS', 3): 12.32, ('SMF', 3): 5.98, ('SSS', 3): 11.24}; RM-ANOVA F = 1.44 p = 0.241; r(seq speed) = -0.18 p = 0.82; r(pulses 2,3) = -0.38 p = 0.62; r(pulses 1,2) = 0.32 p = 0.68; variant, r(pulses 2,3, Table 1 ramp) = -0.58 p = 0.42
this attempt, left choice, baseline 25: n = 21; pulse 1-2 mean 0.39 Hz; pulse 3 {('FFF', 3): 3.95, ('FMS', 3): 4.74, ('SMF', 3): 3.31, ('SSS', 3): 6.73}; RM-ANOVA F = 0.56 p = 0.641; r(seq speed) = -0.75 p = 0.25; r(pulses 2,3) = -0.83 p = 0.17; r(pulses 1,2) = -0.45 p = 0.55; variant, r(pulses 2,3, Table 1 ramp) = -0.86 p = 0.14
this attempt, left choice, baseline 10: n = 21; pulse 1-2 mean 0.33 Hz; pulse 3 {('FFF', 3): 3.08, ('FMS', 3): 4.81, ('SMF', 3): 3.72, ('SSS', 3): 6.87}; RM-ANOVA F = 0.47 p = 0.707; r(seq speed) = -0.92 p = 0.08; r(pulses 2,3) = -0.96 p = 0.04; r(pulses 1,2) = -0.66 p = 0.34; variant, r(pulses 2,3, Table 1 ramp) = -0.95 p = 0.05
variant: recomputed modulated set (a), right choice, baseline 25: n = 21; pulse 1-2 mean 1.04 Hz; pulse 3 {('FFF', 3): 9.81, ('FMS', 3): 11.14, ('SMF', 3): 5.4, ('SSS', 3): 12.13}; RM-ANOVA F = 2.72 p = 0.052; r(seq speed) = -0.31 p = 0.69; r(pulses 2,3) = -0.48 p = 0.52; r(pulses 1,2) = 0.13 p = 0.87; variant, r(pulses 2,3, Table 1 ramp) = -0.63 p = 0.37
variant: recomputed modulated set (a), right choice, baseline 10: n = 21; pulse 1-2 mean 0.23 Hz; pulse 3 {('FFF', 3): 8.01, ('FMS', 3): 11.06, ('SMF', 3): 5.73, ('SSS', 3): 10.42}; RM-ANOVA F = 1.09 p = 0.360; r(seq speed) = -0.41 p = 0.59; r(pulses 2,3) = -0.59 p = 0.41; r(pulses 1,2) = 0.10 p = 0.90; variant, r(pulses 2,3, Table 1 ramp) = -0.76 p = 0.24
variant: recomputed modulated set (a), left choice, baseline 25: n = 21; pulse 1-2 mean -0.36 Hz; pulse 3 {('FFF', 3): 2.78, ('FMS', 3): 4.91, ('SMF', 3): 1.98, ('SSS', 3): 6.7}; RM-ANOVA F = 1.18 p = 0.324; r(seq speed) = -0.74 p = 0.26; r(pulses 2,3) = -0.85 p = 0.15; r(pulses 1,2) = -0.36 p = 0.64; variant, r(pulses 2,3, Table 1 ramp) = -0.92 p = 0.08
variant: recomputed modulated set (a), left choice, baseline 10: n = 21; pulse 1-2 mean -0.32 Hz; pulse 3 {('FFF', 3): 2.41, ('FMS', 3): 4.77, ('SMF', 3): 2.63, ('SSS', 3): 6.72}; RM-ANOVA F = 0.65 p = 0.587; r(seq speed) = -0.86 p = 0.14; r(pulses 2,3) = -0.94 p = 0.06; r(pulses 1,2) = -0.53 p = 0.47; variant, r(pulses 2,3, Table 1 ramp) = -0.97 p = 0.03
Correlation of the pulse 3 population rate with the mean speed of two impulses, by how the impulse speed is taken from S1 Fig:
speeds 0.2-mm span Table 1 ramp own excursion per kind
set choice baseline pulses
this attempt left 10 1,2 0.335 0.290 0.331 0.289
2,3 0.035 0.049 0.038 0.048
25 1,2 0.547 0.497 0.543 0.495
2,3 0.173 0.144 0.177 0.142
right 10 1,2 0.683 0.744 0.689 0.746
2,3 0.616 0.420 0.614 0.419
25 1,2 0.651 0.706 0.655 0.708
2,3 0.728 0.545 0.728 0.543
variant: recomputed modulated set (a) left 10 1,2 0.471 0.418 0.466 0.417
2,3 0.061 0.033 0.062 0.032
25 1,2 0.641 0.583 0.636 0.582
2,3 0.148 0.081 0.149 0.080
right 10 1,2 0.897 0.961 0.904 0.962
2,3 0.408 0.240 0.406 0.239
25 1,2 0.870 0.929 0.874 0.931
2,3 0.519 0.365 0.520 0.363
Result: partially reproduced. L5 Slow Positive units fire little to pulses 1 and 2 (2.00 Hz on right-choice and 0.39 Hz on left-choice trials, 25-ms baseline) against 5.3 to 12.6 Hz for pulse 3 on right-choice trials, and pulse 3 does not correlate with sequence speed or with the S1 Fig speed of pulses 2 and 3 or 1 and 2 with the 25-ms baseline (all p of 0.17 or more). But pulse 3 differs across sequences on right-choice trials (ANOVA p = 0.016; SMF 5.32 Hz against 11.8 to 12.6), and with the 0 to 10 ms baseline the ANOVA is not significant but the left-choice correlation with pulses 2 and 3 is (r = -0.96, p = 0.035). That correlation is below 0.05 however the impulse speed is taken from S1 Fig: p = 0.035 with the 0.2-mm span, 0.038 with a span above 20% of each impulse's own excursion, 0.048 with one speed per impulse kind, and 0.049 with the Table 1 ramp. The spans differ between impulses of one kind (M 123.7 mm/s in FMS, 103.3 in SMF) under both span rules, so the difference is in the recorded profiles, not only in the rule. So no baseline meets the criterion. On the recomputed set the 25-ms baseline meets it (right-choice ANOVA p = 0.052).
s6-head-position-choice (S2 Data, S6 Fig)¶
In high-speed video of 43 trials, head angle and whisker tip trajectories did not differ between right- and left-choice trials, while head position differed modestly from 100 ms, by 0.6 mm at 125 ms.
S2 Data gives the mean and SEM per frame for 22 left- and 21 right-choice trials, so the t tests are computed from those summaries.
s6 = S2["Fig S6"]
cols = s6.iloc[3, :].tolist()
left = pd.DataFrame(s6.iloc[4:23].values.astype(float), columns=cols)
right = pd.DataFrame(s6.iloc[26:45].values.astype(float), columns=cols)
nL, nR = 22, 21
out = {"time": left["Time (ms)"].values}
for v in ["Head Angle", "W Lat", "W RC", "Head dx", "Head dy"]:
mL, sL = left[[c for c in cols if c.startswith(v) and "mean" in c][0]], left[[c for c in cols if c.startswith(v) and "sem" in c.replace(" ", " ")][0]]
mR, sR = right[[c for c in cols if c.startswith(v) and "mean" in c][0]], right[[c for c in cols if c.startswith(v) and "sem" in c.replace(" ", " ")][0]]
sdL, sdR = sL * np.sqrt(nL), sR * np.sqrt(nR)
w = stats.ttest_ind_from_stats(mR, sdR, nR, mL, sdL, nL, equal_var=False)
s = stats.ttest_ind_from_stats(mR, sdR, nR, mL, sdL, nL, equal_var=True)
out[v + " R-L"] = (mR - mL).values
out[v + " p_welch"] = w.pvalue
out[v + " p_student"] = s.pvalue
S6 = pd.DataFrame(out)
print(S6.round(3).to_string())
for v in ["Head Angle", "W Lat", "W RC", "Head dx", "Head dy"]:
for k in ["p_welch", "p_student"]:
sigt = S6.time[S6[v + " " + k] < 0.05].tolist()
print("%s %s: frames with p < 0.05: %s" % (v, k, sigt))
i = int(np.argmin(np.abs(S6.time - 125)))
print("at %.1f ms: head dx right minus left %.3f mm, head dy %.3f mm" % (S6.time[i], S6["Head dx R-L"][i], S6["Head dy R-L"][i]))
time Head Angle R-L Head Angle p_welch Head Angle p_student W Lat R-L W Lat p_welch W Lat p_student W RC R-L W RC p_welch W RC p_student Head dx R-L Head dx p_welch Head dx p_student Head dy R-L Head dy p_welch Head dy p_student 0 0.0 -0.177 0.959 0.959 -0.198 0.910 0.910 1.116 0.170 0.172 -0.008 0.894 0.894 -0.048 0.478 0.475 1 8.4 0.224 0.950 0.950 -0.097 0.957 0.957 0.781 0.343 0.346 -0.019 0.463 0.461 0.025 0.220 0.214 2 16.8 0.328 0.928 0.928 0.011 0.995 0.995 0.626 0.441 0.443 0.026 0.603 0.602 0.023 0.732 0.730 3 25.2 0.527 0.881 0.881 0.285 0.873 0.873 0.455 0.576 0.578 -0.019 0.823 0.824 0.055 0.631 0.630 4 33.6 -0.351 0.922 0.922 -0.085 0.962 0.962 0.704 0.392 0.395 0.022 0.845 0.845 0.075 0.575 0.574 5 42.0 -0.134 0.971 0.971 0.170 0.926 0.926 0.588 0.473 0.476 -0.100 0.421 0.423 0.168 0.288 0.289 6 50.4 0.368 0.919 0.919 0.411 0.820 0.820 0.269 0.742 0.744 -0.107 0.429 0.432 0.236 0.204 0.203 7 58.8 0.047 0.990 0.990 0.260 0.887 0.887 0.301 0.720 0.721 -0.141 0.393 0.395 0.236 0.252 0.253 8 67.2 0.287 0.936 0.936 0.485 0.785 0.785 0.326 0.702 0.703 -0.192 0.242 0.244 0.235 0.280 0.279 9 75.6 0.089 0.980 0.981 0.477 0.793 0.794 0.481 0.567 0.569 -0.255 0.198 0.199 0.236 0.299 0.297 10 84.0 0.489 0.891 0.891 0.660 0.713 0.714 0.329 0.688 0.690 -0.328 0.097 0.097 0.203 0.387 0.386 11 92.4 -0.068 0.985 0.985 0.583 0.750 0.750 0.475 0.562 0.564 -0.326 0.100 0.101 0.276 0.261 0.262 12 100.8 -0.034 0.993 0.993 1.000 0.587 0.587 0.476 0.566 0.567 -0.442 0.037 0.037 0.238 0.363 0.365 13 109.2 0.426 0.904 0.904 0.959 0.596 0.597 0.359 0.675 0.676 -0.518 0.019 0.019 0.287 0.304 0.306 14 117.6 -0.158 0.964 0.964 0.653 0.715 0.715 0.338 0.711 0.713 -0.504 0.027 0.027 0.324 0.268 0.269 15 126.0 -0.821 0.816 0.817 0.427 0.814 0.814 0.694 0.459 0.461 -0.595 0.019 0.019 0.313 0.329 0.330 16 134.4 0.123 0.973 0.973 0.781 0.674 0.674 0.520 0.593 0.594 -0.722 0.006 0.006 0.332 0.328 0.329 17 142.8 -0.418 0.907 0.907 1.205 0.518 0.518 0.754 0.420 0.422 -0.754 0.006 0.006 0.353 0.337 0.337 18 151.2 -1.149 0.748 0.749 1.104 0.548 0.548 1.007 0.306 0.309 -0.871 0.003 0.003 0.342 0.397 0.398 Head Angle p_welch: frames with p < 0.05: [] Head Angle p_student: frames with p < 0.05: [] W Lat p_welch: frames with p < 0.05: [] W Lat p_student: frames with p < 0.05: [] W RC p_welch: frames with p < 0.05: [] W RC p_student: frames with p < 0.05: [] Head dx p_welch: frames with p < 0.05: [100.8, 109.2, 117.6, 126.0, 134.4, 142.8, 151.2] Head dx p_student: frames with p < 0.05: [100.8, 109.2, 117.6, 126.0, 134.4, 142.8, 151.2] Head dy p_welch: frames with p < 0.05: [] Head dy p_student: frames with p < 0.05: [] at 126.0 ms: head dx right minus left -0.595 mm, head dy 0.313 mm
Result: reproduced. From S2 Data, head position along x differs between right- and left-choice trials at every frame from 100.8 ms (p = 0.037) on, by 0.595 mm at 126 ms. Head angle, both whisker tip coordinates and head y differ at no frame.
s7-no-fs-l5-slow-positive¶
All four response classes (Fast, Medium, Slow Positive, Slow Negative) included RS single units, FS single units and multi-unit clusters; few FS units were in the Slow classes and none among L5 Slow Positive units.
for nm, c in [("this attempt", "cls"), ("variant: recomputed modulated set (a)", "cls_a")]:
ct = pd.crosstab(U[c], U.type).drop("none")
ct["FS_frac"] = ct.SU_FS / ct[["MU", "SU_FS", "SU_RS"]].sum(axis=1)
print(nm); print(ct.round(3))
l5sp = U[(U[c] == "SlowPos") & U.layer.isin(["L5a", "L5b"])].type.value_counts().to_dict()
print(" L5 Slow Positive by type:", l5sp)
print(" every class holds all three types:", bool((ct[["MU", "SU_FS", "SU_RS"]] > 0).all().all()),
"| FS fraction of each Slow class below Fast:", bool((ct.loc[["SlowPos", "SlowNeg"], "FS_frac"] < ct.loc["Fast", "FS_frac"]).all()))
this attempt
type MU SU_FS SU_RS FS_frac
cls
Fast 67 31 62 0.194
Medium 20 7 26 0.132
SlowNeg 21 2 23 0.043
SlowPos 12 7 32 0.137
L5 Slow Positive by type: {'SU_RS': 14, 'MU': 7}
every class holds all three types: True | FS fraction of each Slow class below Fast: True
variant: recomputed modulated set (a)
type MU SU_FS SU_RS FS_frac
cls_a
Fast 71 26 63 0.162
Medium 18 8 24 0.160
SlowNeg 24 2 24 0.040
SlowPos 13 7 30 0.140
L5 Slow Positive by type: {'SU_RS': 15, 'MU': 6}
every class holds all three types: True | FS fraction of each Slow class below Fast: True
Result: reproduced. Every class holds RS, FS and multi-units; the FS fraction is 0.137 in Slow Positive and 0.043 in Slow Negative against 0.194 in Fast; the 21 L5 Slow Positive units are 14 RS and 7 multi-units, with no FS unit.
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 |
|---|---|
| fig2ab-fms-smf-not-discriminated | partially reproduced (5 of 8 rats; 62SC not in the data) |
| training-days | partially reproduced (minimum 11 or 12 days, not 8) |
| fig2c-choice-follows-mean-speed | reproduced |
| fig2d-fixed-panel-impairs | reproduced (S2 Data) |
| dprime-fff-sss-range | partially reproduced (highest 1.09, not 1.5) |
| fig3-fsfs-sffs-intensity-only | reproduced (S1 Data) |
| units-recorded | reproduced (but 506 units against 473) |
| baseline-rates | partially reproduced (RS maximum 11.4 Hz) |
| temporal-modulation-count | reproduced |
| modulated-higher-baseline | reproduced |
| fig4d-evoked-modulation-by-layer | partially reproduced (4 of 5 layers) |
| latency-by-layer | partially reproduced (ordering only, two-sided test) |
| fig4d-gradual-decrease | not reproduced (L5a also decreases) |
| fig6-regression-significant | reproduced |
| fig6e-unit-classes | reproduced |
| fig6fg-laminar-classes | reproduced |
| fig7c-fast-impulse-velocity | reproduced |
| fig7c-fast-sequence-rate | reproduced |
| fig7-fff-adaptation | reproduced (on all 62 Fast RS units, an assumption) |
| fig7-sss-no-adaptation | reproduced |
| s4-fms-middle-pulse | reproduced |
| fig7de-medium-suppressed | reproduced (on the deposited set, an assumption; suppression not significant) |
| fig8a-slow-positive-no-sequence-difference | partially reproduced (S response too) |
| fig8b-slow-negative-no-impulse-response | reproduced |
| fig8d-slow-positive-right-choice-l5 | reproduced (reading a, on the deposited set, an assumption) |
| fig8d-fast-medium-no-choice-bias | reproduced |
| fig8e-choice-divergence-125ms | reproduced |
| s5-slow-positive-no-integration | partially reproduced (pulse 3 differs across sequences) |
| s6-head-position-choice | reproduced (S2 Data) |
| s7-no-fs-l5-slow-positive | reproduced |
The decoder claims of Figure 9 are in decoders.ipynb.
How the analysis differs from the paper's: behaviour rests on the five recorded rats, not eight; units are all 506 deposited, not the paper's 473, since the columns to drop cannot be identified; the temporally modulated units are those the data set marks (its stored p-values, which the descriptor names as the paper's units), as the Methods' test recomputed here gives the same count but a different set (73% agreement); the classes are recomputed from the regression and equal the data set's labels; the impulse t test selects about half of the Fast RS units, so the adaptation claims rest on all 62 Fast RS units, close to the paper's 61; impulse speeds for s5 come from the S1 Fig profiles in S2 Data.
What was found about the data set: the column map (MapPosition) the descriptor documents is
missing, so 33 units beyond the paper's 473 cannot be removed (by S1 Table they are in L2/3 to
L5b, none in L6); the stored temporal-modulation p-values use a -50 to 300 ms window, not the
Methods' window, and neither that window nor a bin-shuffle null reproduces them; the fixed-panel
sessions and three behaviour-only rats are not deposited; the stored regression inputs show that
completed trials were analysed; no recording is deposited twice; spikes and trials share one
clock.