Niknam et al. (2019) on CRCNS mt-3¶

Paper: Niknam, Akbarian, Clark, Zamani, Noudoost and Nategh (2019), "Characterizing and dissociating multiple time-varying modulatory computations influencing neuronal activity", PLoS Comput Biol, doi:10.1371/journal.pcbi.1007275. The claims (claims/niknam-2019.yaml) were written from the version of record (PMC6759185), its figure legends and the legends of its supplement.

Dataset: CRCNS mt-3 (doi:10.6080/K0FB514J), mt-3/live/data.zip in the public bucket crcnsarchive, streamed and opened in place. CRCNS data sets are not versioned, so the version is recorded as unversioned (docs/archives.md). The bucket holds one copy of the data (live/, no old/), so there is no other version to choose; the data descriptor is version 0.6 of 2019-08-06, the only one, and describes these files. MD5 sums from the data set's checksums.md5: data.zip a5f225a0b73d64b5e2d2f881e345752a (checked below against the bytes read), docs/crcns_mt-3_data_description.pdf 0a3515c7d3a4a8aae3b0aded6daa3d7a.

Outside input (with_labels): assets/data/main_lists.mat of the paper's code, https://github.com/nnategh/SFA-Models at commit 1438dde9dd3207348ec0df1e5c4dd2a7b014e68e, for each neuron's RF, FF and ST probe (probe_list). Its other tables are shown for reference only.

Claim Tested here
probe-locations-link tested
methods-neuron-counts tested
fig1b-saccadic-suppression, fig1c-ff-remapping, fig1d-st-remapping, fig1e-ff-and-st-remapping tested
fig1-remapping-longer-latency, fig1-example-neurons tested
fig3, fig5a to fig5c, fig6, fig7, fig8, figs4, figs5 (25 claims) blocked: they need the S-, F-, A- or N-model. The S-model's parameter selection as ported here, timed below, needs hundreds of hours on the runner's 4 CPUs, and the full fits, the ten S-model fits of the A-model and the simulations come on top (too_large); fig5a-n-model-no-perisaccadic-gain is blocked because the N-model (ref [48]) was not identified when it was tested (O8); ref [48] has since been identified, but this attempt did not implement the N-model
figs1-rf-centres blocked: no grid geometry in the data set
In [1]:
import hashlib, io, time, resource, collections
import numpy as np
import pandas as pd
import fsspec
import matplotlib.pyplot as plt
from scipy import stats
import mt3

T0 = time.time()
zf = mt3.open_zip()
names = mt3.neuron_names(zf)
N = [mt3.load_neuron(zf, n) for n in names]
lists = mt3.load_probe_list()
probe_list = lists["probe_list"]
row_of = {(int(r[0]), int(r[1])): r for r in probe_list}
print(f"loaded {len(N)} neurons in {time.time() - T0:.1f} s, "
      f"peak memory {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1e6:.2f} GB")
loaded 41 neurons in 5.7 s, peak memory 0.72 GB

Data check¶

What was loaded, by session, and every variable the analysis uses, against the data descriptor (paper/mt-3.data-description.txt, version 0.6) and the paper's Methods.

In [2]:
# MD5 of data.zip against the archive's checksums.md5 (the zip is read into memory, not to disk)
with fsspec.open(mt3.CHECKSUMS_URL, "r") as f:
    md5s = dict(line.split()[::-1] for line in f.read().strip().splitlines())
with fsspec.open(mt3.DATA_URL, "rb", block_size=2**20) as f:
    zip_md5 = hashlib.md5(f.read()).hexdigest()
print("data.zip md5", zip_md5, "checksums.md5:", md5s["data.zip"], "match:", zip_md5 == md5s["data.zip"])

rows = []
for d in N:
    sc, r = d["stimcode"], d["resp"]
    rows.append(dict(neuron=d["name"], session=d["session"], channel=d["channel"],
                     trials=sc.shape[0], ms_per_trial=sc.shape[1], conditions=len(np.unique(d["conds"])),
                     spikes=int(r.sum()), rate_spk_s=r.sum() / r.size * 1000,
                     tsaccade_min=d["tsaccade"].min(), tsaccade_max=d["tsaccade"].max(),
                     stim_min=int(sc.min()), stim_max=int(sc.max()), resp_values=str(np.unique(r).tolist())))
inv = pd.DataFrame(rows)
pd.set_option("display.width", 200, "display.max_columns", 30)
print(inv.to_string(index=False))
by_session = inv.groupby("session").agg(neurons=("neuron", "size"), trials=("trials", "first"))
print(by_session.to_string())
print("neurons", len(inv), "sessions", inv.session.nunique())
# descriptor: 41 neurons as 1,3,2,1,0,6,1,2,8,3,7,7 over sessions 1-12
print("neurons per session in date order:", by_session.neurons.tolist(),
      "descriptor (session 5 has 0):", [1, 3, 2, 1, 6, 1, 2, 8, 3, 7, 7])
# do neurons of a session share stimuli, conditions and saccade times?
for s, g in inv.groupby("session"):
    ds = [d for d in N if d["session"] == s]
    same = all((x["stimcode"] == ds[0]["stimcode"]).all() and (x["tsaccade"] == ds[0]["tsaccade"]).all()
               and (x["conds"] == ds[0]["conds"]).all() for x in ds)
    print(s, "stimcode, conds and tsaccade identical across its neurons:", same)
data.zip md5 a5f225a0b73d64b5e2d2f881e345752a checksums.md5: a5f225a0b73d64b5e2d2f881e345752a match: True
    neuron  session  channel  trials  ms_per_trial  conditions  spikes  rate_spk_s  tsaccade_min  tsaccade_max  stim_min  stim_max resp_values
2015051115 20150511       15     641          3000          75   19862   10.328653           845          1271         0        81      [0, 1]
2015071702 20150717        2     305          3000          81    6684    7.304918           927          1275         0        81      [0, 1]
2015071703 20150717        3     305          3000          81    3591    3.924590           927          1275         0        81      [0, 1]
2015071704 20150717        4     305          3000          81    9871   10.787978           927          1275         0        81      [0, 1]
2015072013 20150720       13     675          3000          81    4805    2.372840           909          1269         0        81      [0, 1]
2015072016 20150720       16     675          3000          81    8021    3.960988           909          1269         0        81      [0, 1]
2015072903 20150729        3     290          3000          81    4598    5.285057           909          1269         0        81      [0, 1]
2015082005 20150820        5     784          3000          81   10780    4.583333           932          1285         0        81      [0, 1]
2015082009 20150820        9     784          3000          81   30566   12.995748           932          1285         0        81      [0, 1]
2015082010 20150820       10     784          3000          81   28464   12.102041           932          1285         0        81      [0, 1]
2015082011 20150820       11     784          3000          81   30863   13.122024           932          1285         0        81      [0, 1]
2015082015 20150820       15     784          3000          81   11079    4.710459           932          1285         0        81      [0, 1]
2015082016 20150820       16     784          3000          81   45018   19.140306           932          1285         0        81      [0, 1]
2015083106 20150831        6     493          3000          81   41555   28.096687           914          1276         0        81      [0, 1]
2015090504 20150905        4     547          3000          81   18422   11.226082           891          1271         0        81      [0, 1]
2015090508 20150905        8     547          3000          81   58546   35.677026           891          1271         0        81      [0, 1]
2015092704 20150927        4     437          3000          80   30910   23.577422           913          1274         0        81      [0, 1]
2015092706 20150927        6     437          3000          80   16320   12.448513           913          1274         0        81      [0, 1]
2015092707 20150927        7     437          3000          80   30600   23.340961           913          1274         0        81      [0, 1]
2015092708 20150927        8     437          3000          80    5975    4.557590           913          1274         0        81      [0, 1]
2015092709 20150927        9     437          3000          80    8069    6.154844           913          1274         0        81      [0, 1]
2015092710 20150927       10     437          3000          80    9807    7.480549           913          1274         0        81      [0, 1]
2015092711 20150927       11     437          3000          80    4769    3.637681           913          1274         0        81      [0, 1]
2015092716 20150927       16     437          3000          80    5464    4.167811           913          1274         0        81      [0, 1]
2015092905 20150929        5     197          3000          80    2382    4.030457           868          1277         0        81      [0, 1]
2015092909 20150929        9     197          3000          80    4158    7.035533           868          1277         0        81      [0, 1]
2015092910 20150929       10     197          3000          80    9203   15.571912           868          1277         0        81      [0, 1]
2015121404 20151214        4     646          3000          81   17902    9.237358           928          1276         0        81      [0, 1]
2015121405 20151214        5     646          3000          81    8152    4.206398           928          1276         0        81      [0, 1]
2015121406 20151214        6     646          3000          81    8480    4.375645           928          1276         0        81      [0, 1]
2015121408 20151214        8     646          3000          81   23021   11.878741           928          1276         0        81      [0, 1]
2015121410 20151214       10     646          3000          81   10418    5.375645           928          1276         0        81      [0, 1]
2015121411 20151214       11     646          3000          81   28850   14.886481           928          1276         0        81      [0, 1]
2015121413 20151214       13     646          3000          81   16375    8.449432           928          1276         0        81      [0, 1]
2015121510 20151215       10     918          3000          81   44685   16.225490           928          1277         0        81      [0, 1]
2015121511 20151215       11     918          3000          81   60643   22.019971           928          1277         0        81      [0, 1]
2015121512 20151215       12     918          3000          81   11510    4.179375           928          1277         0        81      [0, 1]
2015121513 20151215       13     918          3000          81   27608   10.024691           928          1277         0        81      [0, 1]
2015121514 20151215       14     918          3000          81   39829   14.462237           928          1277         0        81      [0, 1]
2015121515 20151215       15     918          3000          81   11844    4.300654           928          1277         0        81      [0, 1]
2015121516 20151215       16     918          3000          81   34780   12.628903           928          1277         0        81      [0, 1]
          neurons  trials
session                  
20150511        1     641
20150717        3     305
20150720        2     675
20150729        1     290
20150820        6     784
20150831        1     493
20150905        2     547
20150927        8     437
20150929        3     197
20151214        7     646
20151215        7     918
neurons 41 sessions 11
neurons per session in date order: [1, 3, 2, 1, 6, 1, 2, 8, 3, 7, 7] descriptor (session 5 has 0): [1, 3, 2, 1, 6, 1, 2, 8, 3, 7, 7]
20150511 stimcode, conds and tsaccade identical across its neurons: True
20150717 stimcode, conds and tsaccade identical across its neurons: False
20150720 stimcode, conds and tsaccade identical across its neurons: False
20150729 stimcode, conds and tsaccade identical across its neurons: True
20150820 stimcode, conds and tsaccade identical across its neurons: False
20150831 stimcode, conds and tsaccade identical across its neurons: True
20150905 stimcode, conds and tsaccade identical across its neurons: False
20150927 stimcode, conds and tsaccade identical across its neurons: False
20150929 stimcode, conds and tsaccade identical across its neurons: False
20151214 stimcode, conds and tsaccade identical across its neurons: False
20151215 stimcode, conds and tsaccade identical across its neurons: False
In [3]:
# Probe timing: runs of one code (probe durations) and gaps with no probe, over all trials of one
# neuron per session; the paper says each probe lasted 7 ms with exactly one probe on screen at a time.
run_len, gap_len, first_on, last_on, cycle_ok = collections.Counter(), collections.Counter(), [], [], []
for s in inv.session.unique():
    d = next(x for x in N if x["session"] == s)
    for row in d["stimcode"]:
        ch = np.flatnonzero(np.diff(row) != 0) + 1
        starts = np.r_[0, ch]; lens = np.diff(np.r_[starts, row.size]); vals = row[starts]
        on = np.flatnonzero(vals > 0)
        run_len.update(lens[on].tolist())
        inner = np.arange(on[0], on[-1] + 1)
        gap_len.update(lens[inner][vals[inner] == 0].tolist())
        first_on.append(starts[on[0]]); last_on.append(starts[on[-1]] + lens[on[-1]])
        seq = vals[on]
        # is the probe order a repeating 81-long cycle (each code once per 81 consecutive onsets)?
        cycle_ok.append(all(len(set(seq[i:i + 81])) == min(81, len(seq[i:i + 81])) for i in range(0, len(seq) - 81, 81)))
tot = sum(run_len.values())
print("probe run lengths (ms: share of runs):", {k: round(v / tot, 4) for k, v in sorted(run_len.items())})
print("gaps between probes inside the sequence (ms: count):", dict(sorted(gap_len.items())))
print(f"first probe at {np.min(first_on)}-{np.max(first_on)} ms, last probe ends at "
      f"{np.min(last_on)}-{np.max(last_on)} ms of the 3000 ms arrays")
print("trials whose onsets run in blocks of 81 distinct codes:", np.mean(cycle_ok).round(3))

# Order of probes within a trial (bears on which pairings of O1 exist). Per session: onsets per
# trial, distinct codes per trial, presentations of each shown probe per trial, ms between repeats
# of a probe, trials where one probe falls in both the fixation (-500 to -100 ms) and the
# perisaccadic (-50 to 0 ms) window, and where the order restarts from its first probe.
seq_rows = []
for s in inv.session.unique():
    d = next(x for x in N if x["session"] == s)
    tr, t, c = mt3.all_onsets(d)
    rel = t - d["sacc"][tr]
    fixw, periw = mt3.in_window(d, tr, t, mt3.FIX), mt3.in_window(d, tr, t, mt3.PERI_LATE)
    n_on, n_codes, reps, rep_ms, both, restart = [], [], collections.Counter(), [], 0, []
    for i in range(d["stimcode"].shape[0]):
        m = tr == i
        q, ti = c[m], t[m]
        n_on.append(len(q)); n_codes.append(len(set(q)))
        reps.update(np.bincount(q)[np.unique(q)].tolist())
        for code in np.unique(q):
            rep_ms.extend(np.diff(np.sort(ti[q == code])).tolist())
        both += len(np.intersect1d(q[fixw[m]], q[periw[m]]))
        K = len(set(q))
        r = [j for j in range(1, len(q) - 3) if j % K and (q[j:j + 3] == q[:3]).all()]
        if r:
            restart.append(ti[r[0]] - d["sacc"][i])
    restart = np.array(restart)
    seq_rows.append(dict(session=s, onsets_per_trial=f"{min(n_on)}-{max(n_on)}",
                         codes_per_trial=sorted(set(n_codes)), presentations_per_probe_per_trial=dict(sorted(reps.items())),
                         ms_between_repeats_median=float(np.median(rep_ms)), ms_between_repeats_5pct=float(np.percentile(rep_ms, 5)),
                         probe_in_both_windows=both, trials_restarting=f"{len(restart)}/{len(n_on)}",
                         restart_ms_from_saccade=f"{restart.min()}-{restart.max()}" if len(restart) else "-"))
print(pd.DataFrame(seq_rows).to_string(index=False))
# Runs longer than 7 ms: in session 20150717, whose order never restarts, the onset sequence repeats
# exactly every 81 onsets, so a 14 or 21 ms run takes one place in the order (one probe held longer).
d = next(x for x in N if x["session"] == 20150717)
tr, t, c = mt3.all_onsets(d)
exact = all((c[tr == i][81:] == c[tr == i][:-81]).all() for i in range(d["stimcode"].shape[0]))
long_runs = sum(((np.diff(np.r_[0, np.flatnonzero(np.diff(row) != 0) + 1, row.size]) >= 13)
                 & (row[np.r_[0, np.flatnonzero(np.diff(row) != 0) + 1]] > 0)).sum() for row in d["stimcode"])
print(f"session 20150717: onset order repeats every 81 onsets in every trial: {exact}; runs of 13 ms or more: {long_runs}")
probe run lengths (ms: share of runs): {6: 0.0555, 7: 0.9151, 8: 0.0015, 9: 0.0002, 10: 0.0033, 11: 0.0005, 12: 0.0, 13: 0.0021, 14: 0.0172, 15: 0.0, 18: 0.0, 20: 0.0008, 21: 0.0037, 22: 0.0, 27: 0.0, 28: 0.0001}
gaps between probes inside the sequence (ms: count): {7: 3, 8: 1, 9: 5, 10: 1458, 11: 4434, 12: 29, 13: 16, 14: 155, 17: 1, 18: 3, 20: 1225, 21: 4525, 27: 2, 28: 9}
first probe at 9-17 ms, last probe ends at 1468-2371 ms of the 3000 ms arrays
trials whose onsets run in blocks of 81 distinct codes: 0.076
 session onsets_per_trial codes_per_trial presentations_per_probe_per_trial  ms_between_repeats_median  ms_between_repeats_5pct  probe_in_both_windows trials_restarting restart_ms_from_saccade
20150511          198-259            [75]      {2: 2599, 3: 41126, 4: 4350}                      562.0                   389.00                      0           631/641                  40-247
20150717          324-324            [81]                        {4: 24705}                      584.0                   563.00                      0             0/305                       -
20150720          212-282            [81]      {2: 2003, 3: 43999, 4: 8673}                      604.0                   229.00                      0           649/675                  42-292
20150729          213-282            [81]       {2: 825, 3: 18933, 4: 3732}                      604.0                   236.00                      0           278/290                  45-288
20150820          212-282            [81]     {2: 1233, 3: 51066, 4: 11205}                      604.0                   222.00                      0           753/784                  35-273
20150831          212-282            [81]      {2: 3076, 3: 33117, 4: 3740}                      597.0                   389.00                      0           482/493                  37-295
20150905          212-281            [81]      {2: 3990, 3: 37063, 4: 3254}                      591.0                   403.00                      0           531/547                  40-295
20150927          211-279            [80]      {2: 2002, 3: 28423, 4: 4535}                      597.0                   256.00                      0           421/437                  38-296
20150929          211-279            [80]       {2: 727, 3: 12909, 4: 2124}                      597.0                   236.00                      0           191/197                  35-264
20151214          213-282            [81]      {2: 1676, 3: 42012, 4: 8638}                      604.0                   222.65                      0           632/646                  37-294
20151215          213-282            [81]     {2: 2490, 3: 60394, 4: 11474}                      604.0                   229.00                      0           881/918                  40-275
session 20150717: onset order repeats every 81 onsets in every trial: True; runs of 13 ms or more: 2158
In [4]:
# Recordings deposited more than once: identical or near-identical spike trains within a session.
pairs = []
for s in inv.session.unique():
    ds = [d for d in N if d["session"] == s]
    for i in range(len(ds)):
        for j in range(i + 1, len(ds)):
            a, b = ds[i]["resp"].ravel().astype(float), ds[j]["resp"].ravel().astype(float)
            pairs.append((ds[i]["name"], ds[j]["name"], bool((a == b).all()), np.corrcoef(a, b)[0, 1],
                          (a * b).sum() / min(a.sum(), b.sum())))
pairs = pd.DataFrame(pairs, columns=["a", "b", "identical", "r_1ms", "coincident_share"])
print(len(pairs), "pairs within sessions; identical:", int(pairs.identical.sum()))
print(pairs.sort_values("r_1ms", ascending=False).head(5).to_string(index=False))
93 pairs within sessions; identical: 0
         a          b  identical    r_1ms  coincident_share
2015092704 2015092707      False 0.013836          0.037157
2015082010 2015082011      False 0.009653          0.023047
2015090504 2015090508      False 0.009285          0.051840
2015092706 2015092707      False 0.009116          0.035600
2015092707 2015092709      False 0.008698          0.040030
In [5]:
# The paper's code repository holds copies of the neuron files (assets/data); compare them with CRCNS.
diff = []
for d in N:
    raw = mt3.load_code_file(f"assets/data/{d['name']}.mat")
    import h5py
    with h5py.File(io.BytesIO(raw), "r") as h:
        same = all(np.array_equal(h[k][()].T.ravel() if k in ("conds", "tsaccade") else h[k][()].T,
                                  (d[k].ravel() if k in ("conds", "tsaccade") else d[k]).astype(h[k].dtype))
                   for k in ("stimcode", "resp", "conds", "tsaccade"))
    diff.append(same)
print("code-repository copies identical to the CRCNS files in all four variables:", sum(diff), "of", len(diff))
code-repository copies identical to the CRCNS files in all four variables: 41 of 41
In [6]:
# Clocks. Stimulus clock: the response to the listed RF probe against all other probes, by latency,
# with the true stimulus codes and with codes shifted by 300 ms. Saccade clock: the population rate
# around tsaccade, against tsaccade taken from another trial of the same session.
lags = np.arange(0, 151)
contrast_true, contrast_shift = [], []
for d in N:
    r = row_of[(d["session"], d["channel"])]
    rf = mt3.sub2ind(r[2], r[3])
    tr, t, c = mt3.all_onsets(d)
    keep = t + 300 + 151 < d["resp"].shape[1]
    tr, t, c = tr[keep], t[keep], c[keep]
    tr_ = d["resp"][tr[:, None], t[:, None] + lags]
    sh = d["resp"][tr[:, None], t[:, None] + 300 + lags]
    for out, x in ((contrast_true, tr_), (contrast_shift, sh)):
        out.append((x[c == rf].mean(0) - x[c != rf].mean(0)) * 1000)
ct, cs = np.array(contrast_true), np.array(contrast_shift)
pk = ct.mean(0).argmax()
print(f"RF minus other probes, mean over neurons: peak {ct.mean(0).max():.1f} spk/s at {pk} ms latency; "
      f"mean over 50-75 ms {ct[:, 50:76].mean():.1f} spk/s, positive in {(ct[:, 50:76].mean(1) > 0).sum()} of 41 neurons")
print(f"with codes shifted by 300 ms: mean over 50-75 ms {cs[:, 50:76].mean():.1f} spk/s, "
      f"positive in {(cs[:, 50:76].mean(1) > 0).sum()} of 41")

rng = np.random.default_rng(1)
win = np.arange(-300, 301)
mod_true, mod_shuf = [], []
for d in N:
    s = d["sacc"]
    sp = rng.permutation(len(s))
    for out, ss in ((mod_true, s), (mod_shuf, s[sp])):
        x = d["resp"][np.arange(len(ss))[:, None], ss[:, None] + win].mean(0) * 1000
        x = mt3.gauss_smooth(x, 13)
        out.append(x / x.mean())
mt, ms = np.array(mod_true).mean(0), np.array(mod_shuf).mean(0)
print(f"normalized population rate -300..300 ms around saccade: range {mt.min():.2f}-{mt.max():.2f} "
      f"(minimum at {win[mt.argmin()]} ms) with true times; {ms.min():.2f}-{ms.max():.2f} with shuffled times")
fig, ax = plt.subplots(1, 2, figsize=(10, 3))
ax[0].plot(lags, ct.mean(0), label="true codes"); ax[0].plot(lags, cs.mean(0), label="codes shifted 300 ms")
ax[0].set_xlabel("ms after probe onset"); ax[0].set_ylabel("RF minus others (spk/s)"); ax[0].legend()
ax[1].plot(win, mt, label="true tsaccade"); ax[1].plot(win, ms, label="shuffled tsaccade")
ax[1].set_xlabel("ms from saccade"); ax[1].set_ylabel("rate / mean"); ax[1].legend(); plt.show()
RF minus other probes, mean over neurons: peak 19.1 spk/s at 58 ms latency; mean over 50-75 ms 14.3 spk/s, positive in 41 of 41 neurons
with codes shifted by 300 ms: mean over 50-75 ms -0.9 spk/s, positive in 7 of 41
normalized population rate -300..300 ms around saccade: range 0.84-1.25 (minimum at -300 ms) with true times; 0.90-1.10 with shuffled times
No description has been provided for this image

probe-locations-link¶

The RF, FF and ST probe of each neuron listed in the code repository's main_lists.mat correspond to the dataset's neurons, and the RF probe recomputed from the dataset by the Methods' definition matches the listed one.

Neurons are matched by session and channel (file name, probe_list columns 1 and 2). The RF is recomputed by D1 (highest mean count 50-75 ms after onsets in -500 to -100 ms), onsets by O2 i.

In [7]:
link = []
for d in N:
    key = (d["session"], d["channel"])
    r = row_of.get(key)
    rf, m = mt3.rf_from_data(d, "onset")
    rf2, _ = mt3.rf_from_data(d, "every")
    x, y = mt3.ind2sub(rf)
    x2, y2 = mt3.ind2sub(rf2)
    link.append(dict(neuron=d["name"], listed=r is not None, RF_listed=(int(r[2]), int(r[3])), RF_data=(x, y),
                     cheb=max(abs(x - r[2]), abs(y - r[3])), cheb_every=max(abs(x2 - r[2]), abs(y2 - r[3])),
                     FF_minus_RF=(int(r[4] - r[2]), int(r[5] - r[3])), ST=(int(r[6]), int(r[7])),
                     direction="left" if r[4] < r[2] else ("right" if r[4] > r[2] else "none")))
link = pd.DataFrame(link)
print(link.to_string(index=False))
print("files matched to a probe_list row:", link.listed.sum(), "of", len(N), "; probe_list rows:", len(probe_list),
      "; rows without a file:", len(set(row_of) - {(d['session'], d['channel']) for d in N}))
n_ok = int((link.cheb <= 1).sum())
print(f"recomputed RF equal to the listed RF: {(link.cheb == 0).sum()}; equal or a neighbour: {n_ok} of 41 "
      f"(every-ms reading: {(link.cheb_every <= 1).sum()})")
print("FF minus RF offsets (x, y):", collections.Counter(link.FF_minus_RF))
print("saccade direction from the sign of FF minus RF x:", link.direction.value_counts().to_dict())
    neuron  listed RF_listed RF_data  cheb  cheb_every FF_minus_RF     ST direction
2015051115    True    (7, 6)  (7, 6)     0           0     (-3, 0) (2, 6)      left
2015071702    True    (7, 4)  (7, 4)     0           0     (-3, 0) (3, 7)      left
2015071703    True    (7, 6)  (7, 6)     0           0     (-3, 0) (3, 8)      left
2015071704    True    (6, 5)  (6, 5)     0           0     (-3, 0) (3, 9)      left
2015072013    True    (5, 6)  (5, 6)     0           0     (-3, 0) (3, 8)      left
2015072016    True    (5, 6)  (5, 6)     0           0     (-3, 0) (2, 8)      left
2015072903    True    (7, 4)  (7, 4)     0           0     (-2, 0) (2, 8)      left
2015082005    True    (8, 5)  (8, 5)     0           1     (-3, 0) (4, 7)      left
2015082009    True    (8, 5)  (8, 5)     0           0     (-3, 0) (4, 7)      left
2015082010    True    (8, 6)  (8, 6)     0           1     (-3, 0) (3, 7)      left
2015082011    True    (8, 5)  (8, 5)     0           0     (-3, 0) (3, 8)      left
2015082015    True    (9, 6)  (9, 7)     1           1     (-3, 0) (2, 7)      left
2015082016    True    (9, 7)  (9, 7)     0           0     (-3, 0) (3, 8)      left
2015083106    True    (8, 8)  (8, 7)     1           1     (-3, 0) (3, 7)      left
2015090504    True    (7, 6)  (7, 6)     0           0     (-3, 0) (1, 6)      left
2015090508    True    (7, 6)  (7, 6)     0           0     (-3, 0) (1, 6)      left
2015092704    True    (6, 5)  (6, 5)     0           0     (-3, 0) (1, 7)      left
2015092706    True    (6, 5)  (6, 5)     0           0     (-3, 0) (2, 9)      left
2015092707    True    (6, 5)  (6, 5)     0           0     (-3, 0) (1, 7)      left
2015092708    True    (6, 4)  (6, 4)     0           0     (-3, 0) (1, 8)      left
2015092709    True    (6, 5)  (6, 5)     0           0     (-3, 0) (3, 7)      left
2015092710    True    (6, 5)  (6, 5)     0           0     (-3, 0) (1, 7)      left
2015092711    True    (6, 4)  (6, 4)     0           0     (-3, 0) (1, 6)      left
2015092716    True    (6, 4)  (6, 4)     0           0     (-3, 0) (4, 6)      left
2015092905    True    (6, 5)  (6, 5)     0           0     (-3, 0) (1, 7)      left
2015092909    True    (6, 7)  (6, 7)     0           0     (-3, 0) (1, 7)      left
2015092910    True    (6, 7)  (6, 7)     0           0     (-3, 0) (1, 7)      left
2015121404    True    (3, 4)  (3, 4)     0           0      (2, 0) (7, 6)     right
2015121405    True    (4, 5)  (4, 5)     0           0      (2, 0) (8, 6)     right
2015121406    True    (4, 5)  (3, 6)     1           0      (2, 0) (9, 6)     right
2015121408    True    (3, 4)  (3, 4)     0           0      (2, 0) (6, 6)     right
2015121410    True    (4, 4)  (4, 4)     0           0      (2, 0) (7, 9)     right
2015121411    True    (4, 5)  (4, 5)     0           0      (2, 0) (9, 9)     right
2015121413    True    (4, 6)  (4, 6)     0           0      (2, 0) (7, 8)     right
2015121510    True    (3, 4)  (3, 4)     0           1      (2, 0) (7, 8)     right
2015121511    True    (4, 5)  (4, 5)     0           0      (2, 0) (9, 8)     right
2015121512    True    (4, 5)  (4, 5)     0           0      (2, 0) (9, 8)     right
2015121513    True    (4, 5)  (4, 5)     0           0      (2, 0) (9, 8)     right
2015121514    True    (4, 5)  (4, 5)     0           0      (2, 0) (6, 8)     right
2015121515    True    (4, 5)  (4, 5)     0           0      (2, 0) (9, 8)     right
2015121516    True    (4, 5)  (4, 5)     0           0      (2, 0) (7, 8)     right
files matched to a probe_list row: 41 of 41 ; probe_list rows: 41 ; rows without a file: 0
recomputed RF equal to the listed RF: 38; equal or a neighbour: 41 of 41 (every-ms reading: 41)
FF minus RF offsets (x, y): Counter({(-3, 0): 26, (2, 0): 14, (-2, 0): 1})
saccade direction from the sign of FF minus RF x: {'left': 27, 'right': 14}

Result: reproduced. All 41 files match a row of probe_list by session and channel, and the RF recomputed from the data is the listed RF or one of its neighbours for all 41 neurons (see the counts printed above). The FF minus RF offsets are horizontal only, and their signs give 27 leftward and 14 rightward neurons.

methods-neuron-counts¶

Of 49 well-isolated MT neurons, 41 responded to the probes and were analysed; they come from 11 sessions, 27 neurons from 9 sessions with leftward saccades and 14 from 2 sessions with rightward saccades.

In [8]:
sess_dir = link.assign(session=link.neuron.str[:8]).groupby("session").direction.agg(lambda s: s.unique().tolist())
print(sess_dir.to_string())
left = link.direction == "left"
print("neurons", len(link), "sessions", link.neuron.str[:8].nunique())
print("leftward: neurons", int(left.sum()), "sessions", link[left].neuron.str[:8].nunique())
print("rightward: neurons", int((~left).sum()), "sessions", link[~left].neuron.str[:8].nunique())
session
20150511     [left]
20150717     [left]
20150720     [left]
20150729     [left]
20150820     [left]
20150831     [left]
20150905     [left]
20150927     [left]
20150929     [left]
20151214    [right]
20151215    [right]
neurons 41 sessions 11
leftward: neurons 27 sessions 9
rightward: neurons 14 sessions 2

Result: reproduced. 41 neurons from 11 sessions; by the sign of the listed FF minus RF offset, 27 neurons from 9 sessions are leftward and 14 from 2 sessions rightward, and every session has a single direction. The 49 isolated units cannot be counted: the 8 that were discarded are not in the data set.

Recorded perisaccadic effects (Figure 1)¶

Each neuron is classified by D2 under every reading of O1 (pairs: (a) trial, (b) condition, (c) unpaired rank-sum, a variant) and O2 (presentations: (i) onset, (ii) every ms, a variant). Two pairings outside O1, raised by the verifier, are shown as variants: a one-sided signed-rank test over the 1 ms bins of the response window, on the mean count per bin (timebin) and on the curves smoothed as for plots (timebin_smoothed). The Methods allow the first ("comparing the perisaccadic and fixation spike counts (during the same stimulus-aligned window)") and exclude the second ("all statistical analyses were performed on spike counts ... (not estimates of firing rate)"). Only (a) and (b) with onsets decide (column decides). Reading (a) cannot be tested: in no session does any trial show a probe in both the fixation and the perisaccadic window (data check, probe_in_both_windows), as a probe returns only after a pass through the whole order, 562 to 604 ms (median per session). The outcomes therefore rest on (b).

The normalized responses follow D3; O4 (a) is the mean over the effect window of the normalized response, averaged over neurons with SE across neurons, and O4 (b) the peak inside the window of the neuron-averaged curve smoothed with a Gaussian of FWHM 13 ms.

In [9]:
SPECS = {"supp": ("RF", mt3.PERI_RF, mt3.EARLY, "less"),
         "ff": ("FF", mt3.PERI_LATE, mt3.LATE, "greater"),
         "st": ("ST", mt3.PERI_LATE, mt3.LATE, "greater")}
PROBES = {}
for d in N:
    r = row_of[(d["session"], d["channel"])]
    PROBES[d["name"]] = {"RF": mt3.sub2ind(r[2], r[3]), "FF": mt3.sub2ind(r[4], r[5]), "ST": mt3.sub2ind(r[6], r[7])}
# O1 a (trial) and b (condition) decide, with O2 i (onset); the rest are variants: O1 c (unpaired),
# and two pairings outside O1, over the 1 ms bins of the response window, of mean counts (timebin)
# and of the smoothed curves (timebin_smoothed), which the Methods exclude ("not estimates of firing rate").
PAIRINGS = ("trial", "condition", "unpaired", "timebin", "timebin_smoothed")
READINGS = [(p, m) for m in ("onset", "every") for p in PAIRINGS]
DECIDES = {("trial", "onset"), ("condition", "onset")}


def run_test(d, eff, p, m):
    loc, peri, win, di = SPECS[eff]
    if p.startswith("timebin"):
        return mt3.timebin_test(d, PROBES[d["name"]][loc], peri, win, di, m, smooth=p == "timebin_smoothed")
    return mt3.effect_test(d, PROBES[d["name"]][loc], peri, win, di, p, m)


TESTS = {(d["name"], eff, p, m): run_test(d, eff, p, m) for d in N for eff in SPECS for p, m in READINGS}
sig, TESTABLE = {}, {}
rows = []
for p, m in READINGS:
    TESTABLE[(p, m)] = any(not np.isnan(TESTS[(d["name"], "ff", p, m)]["p"]) for d in N)
    for eff in SPECS:
        ps = np.array([TESTS[(d["name"], eff, p, m)]["p"] for d in N])
        sig[(eff, p, m)] = np.nan_to_num(ps, nan=1.0) < 0.05
    row = dict(pairing=p, presentations=m, decides=(p, m) in DECIDES,
               pairs_median=np.median([TESTS[(d["name"], "ff", p, m)]["n"] if p != "unpaired" else 0 for d in N]),
               neurons_testable=sum(not np.isnan(TESTS[(d["name"], "ff", p, m)]["p"]) for d in N))
    for eff, lab in (("supp", "suppression"), ("ff", "ff"), ("st", "st")):
        row[lab] = int(sig[(eff, p, m)].sum()) if TESTABLE[(p, m)] else "not testable"
    row["ff_and_st"] = int((sig[("ff", p, m)] & sig[("st", p, m)]).sum()) if TESTABLE[(p, m)] else "not testable"
    rows.append(row)
counts_tab = pd.DataFrame(rows)
print("Neurons significant by D2 under each reading (paper: 8, 23, 37, 22)")
print(counts_tab.to_string(index=False))
# number of presentations per neuron in each window, onset reading
npres = pd.DataFrame([{**{"neuron": d["name"]}, **{f"{e}_{k}": TESTS[(d["name"], e, "condition", "onset")][k]
                       for e in SPECS for k in ("n_fix", "n_peri")}} for d in N])
print(npres.describe().loc[["min", "50%", "max"]].round(1).to_string())
Neurons significant by D2 under each reading (paper: 8, 23, 37, 22)
         pairing presentations  decides  pairs_median  neurons_testable  suppression           ff           st    ff_and_st
           trial         onset     True           0.0                 0 not testable not testable not testable not testable
       condition         onset     True          30.0                41            8            8           11            6
        unpaired         onset    False           0.0                41            9           10           24           10
         timebin         onset    False          71.0                41           13           10           16            9
timebin_smoothed         onset    False          71.0                41           15           19           34           19
           trial         every    False           0.0                 0 not testable not testable not testable not testable
       condition         every    False          34.0                41            4            9            9            6
        unpaired         every    False           0.0                41           12           17           31           17
         timebin         every    False          71.0                41           13           17           29           17
timebin_smoothed         every    False          71.0                41           16           17           32           17
     supp_n_fix  supp_n_peri  ff_n_fix  ff_n_peri  st_n_fix  st_n_peri
min       117.0          8.0     130.0       17.0     137.0       10.0
50%       425.0         30.0     420.0       60.0     420.0       50.0
max       592.0         51.0     601.0       80.0     597.0       92.0
In [10]:
def population(names_sel, loc, peri, win, mode="onset"):
    """D3 normalized responses of the selected neurons; O4 a and b."""
    fs, ps = [], []
    for d in N:
        if d["name"] not in names_sel:
            continue
        F, P = mt3.mean_trains(d, PROBES[d["name"]][loc], peri, mode)
        f, p = mt3.normalized(F, P)
        fs.append(f); ps.append(p)
    fs, ps = np.array(fs), np.array(ps)
    if len(fs) == 0:
        return dict(n=0)
    wf = fs[:, win[0]:win[1] + 1].mean(1); wp = ps[:, win[0]:win[1] + 1].mean(1)
    sf, sp = mt3.gauss_smooth(fs.mean(0)), mt3.gauss_smooth(ps.mean(0))
    return dict(n=len(fs), fix_a=wf.mean(), fix_a_se=wf.std(ddof=1) / np.sqrt(len(wf)) if len(wf) > 1 else np.nan,
                peri_a=wp.mean(), peri_a_se=wp.std(ddof=1) / np.sqrt(len(wp)) if len(wp) > 1 else np.nan,
                fix_b=sf[win[0]:win[1] + 1].max(), peri_b=sp[win[0]:win[1] + 1].max(), curves=(fs, ps))


def within(v, e, tol):
    return abs(v - e) <= tol + 1e-9


def fig1_table(eff, loc, peri, win, expected, selector=None):
    rows = []
    for p, m in READINGS:
        row = dict(pairing=p, presentations=m, decides=(p, m) in DECIDES)
        if not TESTABLE[(p, m)]:
            row["count"] = "not testable"
            rows.append(row)
            continue
        sel = sig[(eff, p, m)] if selector is None else selector(p, m)
        names_sel = {d["name"] for d, s in zip(N, sel) if s}
        pop = population(names_sel, loc, peri, win, m)
        row["count"] = int(sel.sum())
        if pop["n"]:
            row.update(fix_a=pop["fix_a"], fix_a_se=pop["fix_a_se"], peri_a=pop["peri_a"], peri_a_se=pop["peri_a_se"],
                       fix_b=pop["fix_b"], peri_b=pop["peri_b"])
            row["in_tol_a"] = [within(row["count"], expected[0][0], expected[0][1]), within(row["fix_a"], *expected[1]),
                               within(row["peri_a"], *expected[2])]
        rows.append(row)
    return pd.DataFrame(rows)

fig1b-saccadic-suppression¶

Eight neurons show significant saccadic suppression; for them the average normalized response to an RF probe drops from 2.53 to 1.51 when the probe appears just before the saccade.

In [11]:
t1b = fig1_table("supp", "RF", mt3.PERI_RF, mt3.EARLY, [(8, 0.8), (2.53, 0.37), (1.51, 0.29)])
print("expected: count 8 (tol 0.8), fixation 2.53 (0.37), perisaccadic 1.51 (0.29)")
print(t1b.round(3).to_string(index=False))
sel = sig[("supp", "condition", "onset")]
print("suppressed neurons under (b, i):", [d["name"] for d, s in zip(N, sel) if s])
print("by session:", collections.Counter(d["name"][:8] for d, s in zip(N, sel) if s))
for d, s in zip(N, sel):
    if s:
        t = TESTS[(d["name"], "supp", "condition", "onset")]
        print(f"  {d['name']}: conditions {t['n']}, mean count fixation {t['mean_fix']:.3f}, perisaccadic {t['mean_peri']:.3f}, p {t['p']:.4f}")
pop = population({d["name"] for d, s in zip(N, sel) if s}, "RF", mt3.PERI_RF, mt3.EARLY)
fs, ps = pop["curves"]
fig, ax = plt.subplots(figsize=(5, 3))
ax.plot(mt3.gauss_smooth(fs.mean(0)), label="fixation"); ax.plot(mt3.gauss_smooth(ps.mean(0)), label="perisaccadic")
ax.axvspan(50, 75, alpha=.1); ax.set_xlabel("ms after RF probe onset"); ax.set_ylabel("normalized response"); ax.legend(); plt.show()
print(f"plotted range: fixation {mt3.gauss_smooth(fs.mean(0)).min():.2f}-{mt3.gauss_smooth(fs.mean(0)).max():.2f}, "
      f"perisaccadic {mt3.gauss_smooth(ps.mean(0)).min():.2f}-{mt3.gauss_smooth(ps.mean(0)).max():.2f}")
expected: count 8 (tol 0.8), fixation 2.53 (0.37), perisaccadic 1.51 (0.29)
         pairing presentations  decides        count  fix_a  fix_a_se  peri_a  peri_a_se  fix_b  peri_b              in_tol_a
           trial         onset     True not testable    NaN       NaN     NaN        NaN    NaN     NaN                   NaN
       condition         onset     True            8  2.235     0.291   1.239      0.183  2.541   1.530    [True, True, True]
        unpaired         onset    False            9  2.291     0.327   1.297      0.222  2.898   1.884   [False, True, True]
         timebin         onset    False           13  2.212     0.233   1.297      0.161  2.431   1.545   [False, True, True]
timebin_smoothed         onset    False           15  2.180     0.220   1.350      0.159  2.370   1.511   [False, True, True]
           trial         every    False not testable    NaN       NaN     NaN        NaN    NaN     NaN                   NaN
       condition         every    False            4  1.714     0.269   1.063      0.303  1.869   1.338 [False, False, False]
        unpaired         every    False           12  1.887     0.193   1.215      0.157  2.130   1.533 [False, False, False]
         timebin         every    False           13  1.913     0.177   1.262      0.153  2.074   1.452  [False, False, True]
timebin_smoothed         every    False           16  1.849     0.158   1.292      0.134  2.134   1.656  [False, False, True]
suppressed neurons under (b, i): ['2015082009', '2015082011', '2015082016', '2015083106', '2015090504', '2015092708', '2015121513', '2015121516']
by session: Counter({'20150820': 3, '20151215': 2, '20150831': 1, '20150905': 1, '20150927': 1})
  2015082009: conditions 27, mean count fixation 1.397, perisaccadic 0.691, p 0.0429
  2015082011: conditions 27, mean count fixation 0.920, perisaccadic 0.716, p 0.0422
  2015082016: conditions 24, mean count fixation 1.265, perisaccadic 0.681, p 0.0033
  2015083106: conditions 22, mean count fixation 1.879, perisaccadic 1.341, p 0.0264
  2015090504: conditions 19, mean count fixation 1.163, perisaccadic 0.211, p 0.0002
  2015092708: conditions 12, mean count fixation 0.681, perisaccadic 0.292, p 0.0156
  2015121513: conditions 29, mean count fixation 1.328, perisaccadic 1.006, p 0.0185
  2015121516: conditions 29, mean count fixation 1.417, perisaccadic 1.053, p 0.0225
No description has been provided for this image
plotted range: fixation 0.74-2.54, perisaccadic 0.29-1.53

Result: reproduced under O1 (b), pairing by condition, with onsets (O2 i). Eight neurons are significant (paper 8), and their normalized RF response falls from 2.235 to 1.239 by O4 (a) (paper 2.53 ± 0.37 to 1.51 ± 0.29; both within tolerance, near its lower edge); by O4 (b) the peaks are 2.541 and 1.530. Reading (a), pairing by trial, cannot be tested, because no trial shows the same probe in both windows. The 8 neurons are only partly the paper's: the classification agrees with the code's nuron_list on 35 of 41 neurons (reference section), so 5 of the 8 are in that list and 3 are not. The variants give 4 to 16 neurons; the unpaired test with onsets gives 9 with both values within tolerance, the time-bin tests 13 and 15.

fig1c-ff-remapping¶

Twenty-three neurons show significant FF-remapping; for them the average normalized response to an FF probe rises from 0.90 during fixation to 1.30 just before the saccade.

In [12]:
t1c = fig1_table("ff", "FF", mt3.PERI_LATE, mt3.LATE, [(23, 2.3), (0.90, 0.03), (1.30, 0.08)])
print("expected: count 23 (tol 2.3), fixation 0.90 (0.03), perisaccadic 1.30 (0.08)")
print(t1c.round(3).to_string(index=False))
sel = sig[("ff", "condition", "onset")]
print("FF-remapping neurons under (b, i):", [d["name"] for d, s in zip(N, sel) if s])
print("by direction:", collections.Counter(link.direction[sel]))
expected: count 23 (tol 2.3), fixation 0.90 (0.03), perisaccadic 1.30 (0.08)
         pairing presentations  decides        count  fix_a  fix_a_se  peri_a  peri_a_se  fix_b  peri_b              in_tol_a
           trial         onset     True not testable    NaN       NaN     NaN        NaN    NaN     NaN                   NaN
       condition         onset     True            8  0.792     0.037   1.609      0.111  0.927   2.211 [False, False, False]
        unpaired         onset    False           10  0.825     0.038   1.637      0.088  0.915   2.134 [False, False, False]
         timebin         onset    False           10  0.817     0.035   1.587      0.101  0.920   2.030 [False, False, False]
timebin_smoothed         onset    False           19  0.885     0.026   1.411      0.078  0.962   1.779  [False, True, False]
           trial         every    False not testable    NaN       NaN     NaN        NaN    NaN     NaN                   NaN
       condition         every    False            9  0.820     0.042   1.586      0.087  0.917   2.079 [False, False, False]
        unpaired         every    False           17  0.888     0.029   1.427      0.077  0.980   1.780  [False, True, False]
         timebin         every    False           17  0.889     0.030   1.430      0.076  0.980   1.755  [False, True, False]
timebin_smoothed         every    False           17  0.889     0.030   1.430      0.076  0.980   1.755  [False, True, False]
FF-remapping neurons under (b, i): ['2015051115', '2015071702', '2015082005', '2015092704', '2015092707', '2015092708', '2015092910', '2015121410']
by direction: Counter({'left': 7, 'right': 1})

Result: not reproduced. Under O1 (b) with onsets only 8 neurons show FF-remapping (paper 23, tolerance 2.3), and their normalized FF response rises from 0.792 to 1.609 (paper 0.90 to 1.30); the rise is present but none of the three numbers is within tolerance. Reading (a) cannot be tested. No variant reaches the count: they give 9 to 19 neurons. The closest, the time-bin test on smoothed curves with onsets (19 neurons, 0.885 to 1.411) and the unpaired, time-bin and smoothed time-bin tests with every-ms presentations (17 neurons, 0.888 or 0.889 to 1.427 or 1.430), have only the fixation value within tolerance. The time-bin test on mean counts with onsets gives 10 neurons. 7 of the 8 neurons under (b) are from leftward sessions.

fig1d-st-remapping¶

Thirty-seven neurons show significant ST-remapping; for them the average normalized late response to a probe near the saccade target rises from 0.83 during fixation to 1.35 just before the saccade.

In [13]:
t1d = fig1_table("st", "ST", mt3.PERI_LATE, mt3.LATE, [(37, 3.7), (0.83, 0.03), (1.35, 0.06)])
print("expected: count 37 (tol 3.7), fixation 0.83 (0.03), perisaccadic 1.35 (0.06)")
print(t1d.round(3).to_string(index=False))
sel = sig[("st", "condition", "onset")]
print("ST-remapping neurons under (b, i):", [d["name"] for d, s in zip(N, sel) if s])
print("by direction:", collections.Counter(link.direction[sel]))
expected: count 37 (tol 3.7), fixation 0.83 (0.03), perisaccadic 1.35 (0.06)
         pairing presentations  decides        count  fix_a  fix_a_se  peri_a  peri_a_se  fix_b  peri_b              in_tol_a
           trial         onset     True not testable    NaN       NaN     NaN        NaN    NaN     NaN                   NaN
       condition         onset     True           11  0.749     0.046   1.629      0.112  0.793   1.915 [False, False, False]
        unpaired         onset    False           24  0.781     0.029   1.439      0.071  0.815   1.587 [False, False, False]
         timebin         onset    False           16  0.793     0.039   1.509      0.087  0.824   1.702 [False, False, False]
timebin_smoothed         onset    False           34  0.815     0.024   1.365      0.057  0.847   1.470    [True, True, True]
           trial         every    False not testable    NaN       NaN     NaN        NaN    NaN     NaN                   NaN
       condition         every    False            9  0.731     0.051   1.622      0.113  0.770   1.942 [False, False, False]
        unpaired         every    False           31  0.823     0.026   1.369      0.056  0.870   1.536   [False, True, True]
         timebin         every    False           29  0.819     0.027   1.383      0.058  0.870   1.502   [False, True, True]
timebin_smoothed         every    False           32  0.816     0.024   1.340      0.058  0.869   1.465   [False, True, True]
ST-remapping neurons under (b, i): ['2015051115', '2015082005', '2015082015', '2015092707', '2015092708', '2015092711', '2015092716', '2015092910', '2015121410', '2015121411', '2015121510']
by direction: Counter({'left': 8, 'right': 3})

Result: not reproduced. Under O1 (b) with onsets 11 neurons show ST-remapping (paper 37, tolerance 3.7), and their normalized ST response rises from 0.749 to 1.629 (paper 0.83 to 1.35); none of the three numbers is within tolerance. Reading (a) cannot be tested. The outcome depends on the pairing. The time-bin test on smoothed curves with onsets gives 34 neurons, 0.815 to 1.365, all three numbers within tolerance, and agrees with the code's nuron_list on ST for 36 of 41 neurons, against 15 for (b) (reference section). The Methods exclude that test, as it compares firing-rate estimates, and the claims file does not list it, so it decides nothing here; whether O1 should hold a pairing over time bins is asked of a reader (questions/niknam-2019.yaml). On mean counts per bin, the time-bin test gives 16 neurons with onsets (no number within tolerance) and 29 with every-ms presentations (0.819 to 1.383, both values within tolerance); the unpaired test with every-ms presentations gives 31 (0.823 to 1.369).

fig1e-ff-and-st-remapping¶

Twenty-two neurons show both FF- and ST-remapping; for them the normalized FF response rises from 0.90 to 1.32 and the normalized ST response from 0.80 to 1.46.

In [14]:
rows = []
for p, m in READINGS:
    row = dict(pairing=p, presentations=m, decides=(p, m) in DECIDES)
    if not TESTABLE[(p, m)]:
        row["count"] = "not testable"
        rows.append(row)
        continue
    sel = sig[("ff", p, m)] & sig[("st", p, m)]
    names_sel = {d["name"] for d, s in zip(N, sel) if s}
    row["count"] = int(sel.sum())
    if names_sel:
        a = population(names_sel, "FF", mt3.PERI_LATE, mt3.LATE, m)
        b = population(names_sel, "ST", mt3.PERI_LATE, mt3.LATE, m)
        row.update(ff_fix=a["fix_a"], ff_peri=a["peri_a"], st_fix=b["fix_a"], st_peri=b["peri_a"],
                   ff_fix_b=a["fix_b"], ff_peri_b=a["peri_b"], st_fix_b=b["fix_b"], st_peri_b=b["peri_b"])
        exp = [(22, 2.2), (0.90, 0.03), (1.32, 0.08), (0.80, 0.03), (1.46, 0.08)]
        vals = [row["count"], row["ff_fix"], row["ff_peri"], row["st_fix"], row["st_peri"]]
        row["n_in_tol"] = sum(within(v, *e) for v, e in zip(vals, exp))
        row["both_increase"] = bool(row["ff_peri"] > row["ff_fix"] and row["st_peri"] > row["st_fix"])
    rows.append(row)
t1e = pd.DataFrame(rows)
print("expected: count 22 (2.2); FF 0.90 (0.03) to 1.32 (0.08); ST 0.80 (0.03) to 1.46 (0.08)")
print(t1e.round(3).to_string(index=False))
expected: count 22 (2.2); FF 0.90 (0.03) to 1.32 (0.08); ST 0.80 (0.03) to 1.46 (0.08)
         pairing presentations  decides        count  ff_fix  ff_peri  st_fix  st_peri  ff_fix_b  ff_peri_b  st_fix_b  st_peri_b  n_in_tol both_increase
           trial         onset     True not testable     NaN      NaN     NaN      NaN       NaN        NaN       NaN        NaN       NaN           NaN
       condition         onset     True            6   0.777    1.680   0.750    1.789     0.879      2.205     0.810      2.201       0.0          True
        unpaired         onset    False           10   0.825    1.637   0.749    1.718     0.915      2.134     0.814      2.115       0.0          True
         timebin         onset    False            9   0.826    1.586   0.727    1.691     0.930      2.097     0.761      2.117       0.0          True
timebin_smoothed         onset    False           19   0.885    1.411   0.791    1.492     0.962      1.779     0.838      1.723       3.0          True
           trial         every    False not testable     NaN      NaN     NaN      NaN       NaN        NaN       NaN        NaN       NaN           NaN
       condition         every    False            6   0.818    1.609   0.760    1.669     0.907      2.088     0.821      2.000       0.0          True
        unpaired         every    False           17   0.888    1.427   0.779    1.496     0.980      1.780     0.838      1.725       3.0          True
         timebin         every    False           17   0.889    1.430   0.786    1.503     0.980      1.755     0.860      1.716       3.0          True
timebin_smoothed         every    False           17   0.889    1.430   0.786    1.503     0.980      1.755     0.860      1.716       3.0          True

Result: not reproduced. Under O1 (b) with onsets 6 neurons show both effects (paper 22), and none of the five numbers is within tolerance (FF 0.777 to 1.680, ST 0.750 to 1.789), though both responses rise. Reading (a) cannot be tested. The variants give 6 to 19 neurons, none within tolerance of 22. The time-bin test on smoothed curves with onsets (19 neurons) and the unpaired, time-bin and smoothed time-bin tests with every-ms presentations (17 neurons) each have 3 of 5 numbers within tolerance, which would meet the partial rule; the others have none.

fig1-remapping-longer-latency¶

Perisaccadic FF and ST responses come at a longer latency (80-150 ms after the probe) than RF responses (50-75 ms).

Peak latency of the neuron-averaged normalized response 0-150 ms after onset, smoothed with a Gaussian of FWHM 13 ms: fixation RF response over all 41 neurons; perisaccadic FF response of the FF-remapping neurons and perisaccadic ST response of the ST-remapping neurons, under each reading.

In [15]:
allnames = {d["name"] for d in N}
rf_pop = population(allnames, "RF", mt3.PERI_RF, mt3.EARLY, "onset")
rf_curve = mt3.gauss_smooth(rf_pop["curves"][0].mean(0))
print(f"RF fixation peak (41 neurons, onset reading): {rf_curve.argmax()} ms")
rf_every = int(mt3.gauss_smooth(population(allnames, "RF", mt3.PERI_RF, mt3.EARLY, "every")["curves"][0].mean(0)).argmax())
rows = []
for p, m in READINGS:
    row = dict(pairing=p, presentations=m, decides=(p, m) in DECIDES)
    row["rf_peak"] = int(rf_curve.argmax()) if m == "onset" else rf_every
    if not TESTABLE[(p, m)]:
        row["n_ff"] = row["n_st"] = "not testable"
        rows.append(row)
        continue
    for eff, loc in (("ff", "FF"), ("st", "ST")):
        names_sel = {d["name"] for d, s in zip(N, sig[(eff, p, m)]) if s}
        row[f"n_{eff}"] = len(names_sel)
        if names_sel:
            c = mt3.gauss_smooth(population(names_sel, loc, mt3.PERI_LATE, mt3.LATE, m)["curves"][1].mean(0))
            row[f"{eff}_peri_peak"] = int(c.argmax())
    rows.append(row)
tlat = pd.DataFrame(rows)
print(tlat.to_string(index=False))
# per-neuron variant: peak of each remapping neuron's smoothed perisaccadic response (onset, condition)
for eff, loc in (("ff", "FF"), ("st", "ST")):
    pk = []
    for d, s in zip(N, sig[(eff, "condition", "onset")]):
        if s:
            F, P = mt3.mean_trains(d, PROBES[d["name"]][loc], mt3.PERI_LATE)
            pk.append(int(mt3.gauss_smooth(P.mean(0)).argmax()))
    print(f"{eff}: per-neuron perisaccadic peaks {sorted(pk)}")
RF fixation peak (41 neurons, onset reading): 62 ms
         pairing presentations  decides  rf_peak         n_ff         n_st  ff_peri_peak  st_peri_peak
           trial         onset     True       62 not testable not testable           NaN           NaN
       condition         onset     True       62            8           11         108.0          99.0
        unpaired         onset    False       62           10           24         106.0          98.0
         timebin         onset    False       62           10           16         105.0         116.0
timebin_smoothed         onset    False       62           19           34         105.0         100.0
           trial         every    False       59 not testable not testable           NaN           NaN
       condition         every    False       59            9            9         106.0          96.0
        unpaired         every    False       59           17           31         103.0         128.0
         timebin         every    False       59           17           29         103.0         125.0
timebin_smoothed         every    False       59           17           32         103.0         125.0
ff: per-neuron perisaccadic peaks [12, 74, 98, 106, 108, 110, 130, 150]
st: per-neuron perisaccadic peaks [0, 26, 97, 99, 112, 113, 124, 128, 132, 136, 150]

Result: reproduced. The neuron-averaged fixation RF response of the 41 neurons peaks at 62 ms after onset, inside 50-75 ms, and the perisaccadic FF and ST responses of the remapping neurons peak at 108 and 99 ms under O1 (b) with onsets, inside 80-150 ms. Every testable reading gives the same order (RF 59-62 ms, FF 103-108 ms, ST 96-128 ms). The remapped peaks are not an independent test: the neurons are selected for an increase 80-150 ms after onset, which pulls the averaged perisaccadic peak into that window, and the peaks of single neurons are spread (FF 12 to 150 ms, ST 0 to 150 ms). The RF peak, over all 41 neurons with no selection, is the part of the result that does not depend on the selection.

fig1-example-neurons¶

In example neurons the RF response falls from 60.89 to 40.49 spk/s before the saccade; the late FF response rises from 7.90 to 18.42 spk/s; the late ST response rises from 23.80 to 64.64 spk/s; and in a neuron with both effects FF rises from 15.83 to 39.10 and ST from 16.15 to 36.17 spk/s, each with p < 0.001.

Rates are mean rates over the effect window after presentations in the D2 windows, SE across presentations. Every neuron is searched for each example.

In [16]:
EX = {"RF example": [("supp", "RF", 60.89, 2.82, 40.49, 12.64)],
      "FF example": [("ff", "FF", 7.90, 1.02, 18.42, 3.56)],
      "ST example": [("st", "ST", 23.80, 1.77, 64.64, 7.91)],
      "FF and ST example": [("ff", "FF", 15.83, 0.91, 39.10, 5.14), ("st", "ST", 16.15, 0.94, 36.17, 4.49)]}
ex_rows = []
for mode in ("onset", "every"):
    for d in N:
        for ex, parts in EX.items():
            ok_all, desc = True, []
            for eff, loc, ef, tf, ep, tp in parts:
                _, peri, win, di = SPECS[eff]
                F, P = mt3.mean_trains(d, PROBES[d["name"]][loc], peri, mode)
                rf_, rp_ = mt3.window_rate(F, win), mt3.window_rate(P, win)
                pa = TESTS[(d["name"], eff, "condition", mode)]["p"]
                pt = TESTS[(d["name"], eff, "trial", mode)]["p"]
                okv = within(rf_.mean(), ef, tf) and within(rp_.mean(), ep, tp)
                oks = (pa < 0.05) or (pt < 0.05)
                ok_all &= okv and oks
                desc.append(f"{loc} {rf_.mean():.2f}±{rf_.std(ddof=1)/np.sqrt(len(rf_)):.2f} -> {rp_.mean():.2f}±"
                            f"{rp_.std(ddof=1)/np.sqrt(max(len(rp_),2)):.2f} (p_cond {pa:.4f}, values {'in' if okv else 'out'})")
            ex_rows.append(dict(mode=mode, example=ex, neuron=d["name"], match=ok_all, detail="; ".join(desc)))
ex_tab = pd.DataFrame(ex_rows)
for (mode, ex), g in ex_tab.groupby(["mode", "example"], sort=False):
    print(f"{mode} / {ex}: matching neurons {g[g.match].neuron.tolist()}")
# closest neurons by values only (onset reading), for each example
closest = {}
for ex, parts in EX.items():
    dist = []
    for d in N:
        tot = 0
        for eff, loc, ef, tf, ep, tp in parts:
            _, peri, win, di = SPECS[eff]
            F, P = mt3.mean_trains(d, PROBES[d["name"]][loc], peri)
            tot += abs(mt3.window_rate(F, win).mean() - ef) / tf + abs(mt3.window_rate(P, win).mean() - ep) / tp
        dist.append((tot, d["name"]))
    best = sorted(dist)[:3]
    closest[ex] = best[0][1]
    print(f"{ex}: closest (sum of |difference| / tolerance) {[(n, round(t, 2)) for t, n in best]}")
    for t, n in best[:1]:
        print("   ", ex_tab[(ex_tab["mode"] == "onset") & (ex_tab.example == ex) & (ex_tab.neuron == n)].detail.iloc[0])
# p of the D2 test under every pairing (onset presentations) for the matched neurons and the
# closest neuron of each example; the paper gives p < 0.001 for each example.
byname = {d["name"]: d for d in N}
shown = sorted(set(ex_tab[ex_tab.match].neuron) | set(closest.values()))
prow = []
for n in shown:
    for eff in SPECS:
        prow.append(dict(neuron=n, effect=eff, **{p: TESTS[(n, eff, p, "onset")]["p"] for p in PAIRINGS}))
with pd.option_context("display.float_format", "{:.2g}".format):
    print("closest neuron of each example:", closest)
    print(pd.DataFrame(prow).to_string(index=False))

# Fixation set: the fixation rate of the closest neuron of each example as the fixation window moves,
# start -560 to -440 ms and end -160 to -40 ms (1 ms steps), with the SE across presentations.
scan = []
for ex, parts in EX.items():
    n = closest[ex]; d = byname[n]
    for eff, loc, ef, tf, ep, tp in parts:
        _, peri, win, _ = SPECS[eff]
        tr, t = mt3.presentations(d, PROBES[n][loc])
        cr = mt3.counts(d, tr, t, win) * 1000.0 / (win[1] - win[0] + 1)
        rel = t - d["sacc"][tr]
        vals = {(a, b): cr[(rel >= a) & (rel <= b)].mean() for a in range(-560, -439) for b in range(-160, -39)}
        fx = (rel >= -500) & (rel <= -100)
        scan.append(dict(example=ex, neuron=n, probe=loc, paper=ef, paper_se=tf, here=cr[fx].mean(),
                         here_se=cr[fx].std(ddof=1) / np.sqrt(fx.sum()), n_fix=int(fx.sum()),
                         scan_min=min(vals.values()), scan_max=max(vals.values()), vals=vals))
scan = pd.DataFrame(scan)
print(scan.drop(columns="vals").round(2).to_string(index=False))
# one window for the three matched examples (four comparisons) at once
keys = list(scan.vals.iloc[0])
matched = scan[scan.example != "RF example"]
err = {k: max(abs(v[k] - e) for v, e in zip(matched.vals, matched.paper)) for k in keys}
best_win = sorted(err, key=err.get)[:3]
print("windows that bring the three matched examples closest to the paper (max |difference| spk/s):",
      [(k, round(err[k], 3)) for k in best_win], "; at -500 to -100:", round(err[(-500, -100)], 3))
# Saccade index one ms either way (tsaccade - 2, - 1 as used, and tsaccade): fixation and
# perisaccadic rates of the closest neurons.
off_rows = []
for ex, parts in EX.items():
    n = closest[ex]; d = byname[n]
    for eff, loc, ef, tf, ep, tp in parts:
        _, peri, win, _ = SPECS[eff]
        tr, t = mt3.presentations(d, PROBES[n][loc])
        cr = mt3.counts(d, tr, t, win) * 1000.0 / (win[1] - win[0] + 1)
        for off in (-1, 0, 1):
            rel = t - (d["sacc"][tr] + off)
            off_rows.append(dict(example=ex, probe=loc, shift_ms=off, fix=cr[(rel >= -500) & (rel <= -100)].mean(),
                                 peri=cr[(rel >= peri[0]) & (rel <= peri[1])].mean(), paper_fix=ef, paper_peri=ep))
print(pd.DataFrame(off_rows).round(2).to_string(index=False))
onset / RF example: matching neurons []
onset / FF example: matching neurons ['2015071702']
onset / ST example: matching neurons ['2015092707']
onset / FF and ST example: matching neurons ['2015051115']
every / RF example: matching neurons ['2015083106']
every / FF example: matching neurons ['2015071702']
every / ST example: matching neurons ['2015092707']
every / FF and ST example: matching neurons ['2015051115']
RF example: closest (sum of |difference| / tolerance) [('2015092709', np.float64(1.4)), ('2015121516', np.float64(2.73)), ('2015121513', np.float64(3.36))]
    RF 56.94±2.71 -> 40.49±12.64 (p_cond 0.4860, values out)
FF example: closest (sum of |difference| / tolerance) [('2015071702', np.float64(0.22)), ('2015071704', np.float64(2.77)), ('2015092711', np.float64(3.19))]
    FF 7.83±1.01 -> 18.96±3.49 (p_cond 0.0166, values in)
ST example: closest (sum of |difference| / tolerance) [('2015092707', np.float64(0.11)), ('2015082016', np.float64(5.33)), ('2015121511', np.float64(5.89))]
    ST 23.61±1.78 -> 64.64±7.93 (p_cond 0.0059, values in)
FF and ST example: closest (sum of |difference| / tolerance) [('2015051115', np.float64(0.18)), ('2015092910', np.float64(3.49)), ('2015090504', np.float64(9.13))]
    FF 15.76±0.91 -> 39.10±5.16 (p_cond 0.0006, values in); ST 16.05±0.94 -> 36.17±4.45 (p_cond 0.0004, values in)
closest neuron of each example: {'RF example': '2015092709', 'FF example': '2015071702', 'ST example': '2015092707', 'FF and ST example': '2015051115'}
    neuron effect  trial  condition  unpaired  timebin  timebin_smoothed
2015051115   supp    NaN       0.96      0.98        1                 1
2015051115     ff    NaN    0.00063     2e-06  1.1e-09           1.2e-13
2015051115     st    NaN    0.00037   7.2e-06  1.4e-10           1.2e-13
2015071702   supp    NaN        0.8         1     0.95                 1
2015071702     ff    NaN      0.017   0.00011    0.023           8.7e-11
2015071702     st    NaN      0.092   4.5e-05   0.0014           4.6e-11
2015083106   supp    NaN      0.026    0.0052   0.0071           4.5e-08
2015083106     ff    NaN          1         1        1                 1
2015083106     st    NaN          1         1        1                 1
2015092707   supp    NaN       0.98         1        1                 1
2015092707     ff    NaN     0.0073   4.7e-07  1.9e-10           1.2e-13
2015092707     st    NaN     0.0059   2.7e-08  2.3e-10           1.2e-13
2015092709   supp    NaN       0.49      0.02    0.015           9.5e-06
2015092709     ff    NaN       0.91      0.99        1                 1
2015092709     st    NaN       0.47      0.72     0.85                 1
          example     neuron probe  paper  paper_se  here  here_se  n_fix  scan_min  scan_max
       RF example 2015092709    RF  60.89      2.82 56.94     2.71    283     53.87     59.68
       FF example 2015071702    FF   7.90      1.02  7.83     1.01    196      6.28      8.58
       ST example 2015092707    ST  23.80      1.77 23.61     1.78    284     20.97     29.96
FF and ST example 2015051115    FF  15.83      0.91 15.76     0.91    436     14.65     17.71
FF and ST example 2015051115    ST  16.15      0.94 16.05     0.94    437     14.67     18.28
windows that bring the three matched examples closest to the paper (max |difference| spk/s): [((-495, -100), np.float64(0.054)), ((-497, -99), np.float64(0.062)), ((-498, -99), np.float64(0.066))] ; at -500 to -100: 0.194
          example probe  shift_ms   fix  peri  paper_fix  paper_peri
       RF example    RF        -1 56.88 44.87      60.89       40.49
       RF example    RF         0 56.94 40.49      60.89       40.49
       RF example    RF         1 56.94 33.94      60.89       40.49
       FF example    FF        -1  7.83 18.78       7.90       18.42
       FF example    FF         0  7.83 18.96       7.90       18.42
       FF example    FF         1  7.83 19.50       7.90       18.42
       ST example    ST        -1 23.61 64.58      23.80       64.64
       ST example    ST         0 23.61 64.64      23.80       64.64
       ST example    ST         1 23.62 63.90      23.80       64.64
FF and ST example    FF        -1 15.65 38.94      15.83       39.10
FF and ST example    FF         0 15.76 39.10      15.83       39.10
FF and ST example    FF         1 15.76 38.63      15.83       39.10
FF and ST example    ST        -1 16.05 36.37      16.15       36.17
FF and ST example    ST         0 16.05 36.17      16.15       36.17
FF and ST example    ST         1 16.11 36.82      16.15       36.17

Result: partially reproduced. With onsets (O2 i), neurons match three of the four examples on both values and on a significant D2 test under O1 (b): 2015071702 for the FF example (7.83 to 18.96 spk/s, p 0.017), 2015092707 for the ST example (23.61 to 64.64, p 0.0059) and 2015051115 for the example with both effects (FF 15.76 to 39.10, p 0.00063; ST 16.05 to 36.17, p 0.00037). Their perisaccadic means equal the paper's to the second decimal in three of the five comparisons. No neuron matches the RF example. The closest, 2015092709, has the paper's perisaccadic value (40.49 ± 12.64) but a fixation rate of 56.94 ± 2.71 against 60.89 ± 2.82, and p 0.49 under (b) (0.02 unpaired, 0.015 on time bins); moving the fixation window (start -560 to -440 ms, end -160 to -40 ms) gives it 53.87 to 59.68, never 60.89. With every-ms presentations (a variant) 2015083106 matches the RF example.

The paper's p < 0.001 holds under (b) only for the example with both effects. Under the unpaired test the three matched examples give p 0.00011 or less, and under the time-bin test on mean counts 1.1e-09 or less except the FF example (0.023). The fixation values of the three matched examples differ from the paper's by 0.07 to 0.19 spk/s while their SEs agree within 0.01 (for example 1.01 against 1.02), so the paper's fixation sets are about the same size as ours. No window in the scan matches all three at once: the closest, -495 to -100 ms, is within 0.054 spk/s, against 0.194 at -500 to -100 ms. Shifting the saccade index by 1 ms either way moves the perisaccadic rates away from the paper's (40.49 becomes 44.87 or 33.94) and the fixation rates by 0.11 spk/s at most. The paper's fixation set is not identified.

Model claims: the cost of the S-model¶

Every claim from Figure 3 on needs the S-model fitted per neuron (D4), and most need the F-model, the A-model (ten S- and F-model fits per neuron) and 1000 simulated stimulus sequences per model. The S-model's parameter selection (Methods, S-model framework; select_bases.m) fits, for every probe (81), time basis and delay basis, a single-parameter model on 100 random 65% subsets and on 100 subsets with shuffled responses. Below, that fit, ported from select_bases.m, is timed on one neuron and one probe for a few time bases, and the time for the whole selection is estimated.

In [17]:
rng_bench = np.random.default_rng(7)
d = N[0]
Bd = mt3.bspline_bases(150)
Bt = mt3.bspline_bases(1081)
print("delay bases", Bd.shape[0], "time bases", Bt.shape[0], "-> parameters per probe", Bd.shape[0] * Bt.shape[0],
      "and per neuron", 81 * Bd.shape[0] * Bt.shape[0])
times = np.arange(-540, 541)
probe = PROBES[d["name"]]["RF"]
stim = (d["stimcode"] == probe).astype(float)
nt = stim.shape[0]
BS = np.zeros((Bd.shape[0], nt, len(times)))
for j in range(Bd.shape[0]):
    for i in range(nt):
        cv = np.convolve(Bd[j], stim[i])
        BS[j, i] = cv[d["sacc"][i] + times]
rsp = np.array([d["resp"][i, d["sacc"][i] + times] for i in range(nt)], float)
b0 = -np.log(1000.0 / (d["resp"][d["stimcode"] > 0].mean() * 1000) - 1)
conds = d["conds"]; uc = np.unique(conds)
n_fit, t_fit = 0, 0.0
for tb in (40, 78, 120):
    idx = Bt[tb] > 0
    for j in range(Bd.shape[0]):
        for shuffle in (False, True):
            tr_c = rng_bench.permutation(uc)
            ntr = int(len(uc) * 0.35); nval = int((len(uc) - ntr) * 0.30 / 0.65)
            trn = np.flatnonzero(np.isin(conds, tr_c[:ntr])); val = np.flatnonzero(np.isin(conds, tr_c[ntr:ntr + nval]))
            t0 = time.time()
            mt3.select_fit(BS[j][:, idx], rsp[:, idx], b0, trn, val, rng_bench, shuffle)
            t_fit += time.time() - t0; n_fit += 1
per_fit = t_fit / n_fit
fits_neuron = 81 * Bd.shape[0] * Bt.shape[0] * 200
trials_all = sum(x["resp"].shape[0] for x in N)
est_h = per_fit * fits_neuron / 3600 * trials_all / nt
print(f"{n_fit} fits in {t_fit:.1f} s ({per_fit * 1000:.1f} ms per fit, {nt} trials)")
# Lower bound for a fully batched port: only samples where the regressor is nonzero change with the
# parameter, and each gradient step of select_bases.m evaluates the likelihood at least 4 times
# (train and validation, before and after), at least 2 steps per fit. Per-element cost measured on
# one large vectorized evaluation.
nz = []
for tb in range(0, Bt.shape[0], 5):
    idx = Bt[tb] > 0
    nz.extend((BS[j][:, idx] != 0).sum() * 0.65 for j in range(Bd.shape[0]))
nz_mean = float(np.mean(nz))
xx = rng_bench.random(10_000_000); rr = (rng_bench.random(10_000_000) < 0.01).astype(float)
t0 = time.time()
lam = 1000.0 / (1.0 + np.exp(-(0.3 * xx - 4.0))); _ = np.sum(rr * np.log(lam * 1e-3) - lam * 1e-3)
per_elem = (time.time() - t0) / 1e7
lb_h = fits_neuron * nz_mean * 8 * per_elem / 3600 * trials_all / nt
print(f"nonzero samples per fit (65% of trials): mean {nz_mean:.0f}; per-element likelihood cost {per_elem * 1e9:.1f} ns")
print(f"lower bound for the selection of all 41 neurons, fully batched: {lb_h:.1f} CPU hours, {lb_h / 4:.1f} hours on 4 CPUs")
# The A-model fits the S-model ten times on 65% subsets (Methods, A-model), selection included.
print(f"with the ten S-model fits of the A-model, fully batched: {10 * lb_h:.0f} CPU hours, {10 * lb_h / 4:.0f} hours on 4 CPUs")
print(f"selection alone: {fits_neuron:,} fits per neuron; all 41 neurons ({trials_all} trials), scaled by trials: "
      f"{est_h:,.0f} CPU hours, {est_h / 4:,.0f} hours on 4 CPUs")
delay bases 23 time bases 156 -> parameters per probe 3588 and per neuron 290628
138 fits in 0.9 s (6.8 ms per fit, 641 trials)
nonzero samples per fit (65% of trials): mean 357; per-element likelihood cost 16.6 ns
lower bound for the selection of all 41 neurons, fully batched: 29.4 CPU hours, 7.4 hours on 4 CPUs
with the ten S-model fits of the A-model, fully batched: 294 CPU hours, 74 hours on 4 CPUs
selection alone: 58,125,600 fits per neuron; all 41 neurons (24522 trials), scaled by trials: 4,211 CPU hours, 1,053 hours on 4 CPUs

Result: not tested; the model claims are blocked as too large. The S-model has 290,628 stimulus-basis parameters per neuron, and its selection step runs 58,125,600 single-parameter fits per neuron. This port of select_bases.m took 2.2 to 6.7 ms per fit in the runs of this attempt (the value printed above is this run's), that is 345 to 1,040 hours on 4 CPUs for the selection step of the 41 neurons. That port is what this attempt has, and it is far over the notebook's 60 minutes (CI fails a notebook over sixty) and the five hours of an author run. A fully batched port, not written here, would evaluate only the nonzero samples; its lower bound printed above was 11.5 to 27.5 CPU hours (2.9 to 6.9 hours on 4 CPUs) across runs, for one selection per neuron. It is a lower bound for the selection step only. The full S-model fit, the F-model fits and the 1000 simulated sequences come on top, and the A-model fits the S-model ten times per neuron (Methods, A-model: "fitting the S-model ten times as explained earlier"), which multiplies the selection bound by ten, 29 to 69 hours on 4 CPUs. Five claims also need the N-model. The paper defines it only through ref [48], which this revision identified as Akbarian et al. (2018), IEEE Trans Biomed Eng 65(2):241-253, doi:10.1109/TBME.2017.2762687 (open as PMC5796416). No code for it is published, and this attempt did not implement it.

figs1-rf-centres¶

The RF centres in dva need each session's grid position and probe spacing. The files hold probe codes on the 9 x 9 grid only (data check above); the descriptor gives no geometry, and the paper gives only ranges (Methods, paragraph 1). The claim is blocked (metadata_insufficient).

Reference: the paper's own classification lists¶

main_lists.mat in the code repository holds, besides probe_list, five undocumented 41 x 6 tables (session, channel, four 0/1 columns): nuron_list, nsglm_list, twobm_list, gauss_list and aggat_list. No code reads them. Their counts are compared with the paper and with the classification of this notebook; they decide no outcome.

In [18]:
for k in ("nuron_list", "nsglm_list", "twobm_list", "gauss_list", "aggat_list"):
    v = lists[k]
    assert all((int(a), int(b)) in row_of for a, b in v[:, :2])
    print(f"{k}: column sums {v[:, 2:].sum(0).tolist()}, columns 4 and 6 both {(v[:, 3] & v[:, 5]).sum()}, "
          f"columns 5 and 6 both {(v[:, 4] & v[:, 5]).sum()}")
nl = lists["nuron_list"]
key = {(d["session"], d["channel"]): i for i, d in enumerate(N)}
order = [key[(int(a), int(b))] for a, b in nl[:, :2]]
for p, m in READINGS:
    if not TESTABLE[(p, m)]:
        print(f"agreement with nuron_list ({p}, {m}): not testable")
        continue
    s_ = [sig[(e, p, m)][order] for e in SPECS]
    print(f"agreement with nuron_list ({p}, {m}): suppression {(s_[0] == nl[:, 2]).sum()}/41, "
          f"FF (column 4) {(s_[1] == nl[:, 3]).sum()}/41, ST (column 6) {(s_[2] == nl[:, 5]).sum()}/41; "
          f"listed ST neurons found {(s_[2] & (nl[:, 5] == 1)).sum()}/{nl[:, 5].sum()}")
for k in ("aggat_list", "gauss_list", "twobm_list", "nsglm_list"):
    v = lists[k]
    print(f"{k}: neurons with the effect in nuron_list and in the list, columns 3-6: "
          f"{[(int((nl[:, j] & v[:, j]).sum())) for j in range(2, 6)]}")
# Per neuron, by name: nuron_list columns 3 (suppression), 4 (FF) and 6 (ST), and the one-sided p of
# D2 under each pairing with onset presentations (cond = O1 b, unp = O1 c, tb = time bins of mean
# counts, tbs = time bins of smoothed curves).
nl_row = {(int(r[0]), int(r[1])): r for r in nl}
pn = []
for d in N:
    r = nl_row[(d["session"], d["channel"])]
    row = dict(neuron=d["name"], list_supp=int(r[2]), list_ff=int(r[3]), list_st=int(r[5]))
    for e in SPECS:
        for p, lab in (("condition", "cond"), ("unpaired", "unp"), ("timebin", "tb"), ("timebin_smoothed", "tbs")):
            row[f"{e}_{lab}"] = TESTS[(d["name"], e, p, "onset")]["p"]
    pn.append(row)
pn = pd.DataFrame(pn)
with pd.option_context("display.float_format", "{:.2g}".format, "display.width", 250):
    print(pn.to_string(index=False))
nuron_list: column sums [8, 23, 23, 37], columns 4 and 6 both 22, columns 5 and 6 both 22
nsglm_list: column sums [18, 10, 10, 14], columns 4 and 6 both 7, columns 5 and 6 both 6
twobm_list: column sums [15, 23, 24, 21], columns 4 and 6 both 20, columns 5 and 6 both 21
gauss_list: column sums [15, 22, 24, 24], columns 4 and 6 both 20, columns 5 and 6 both 22
aggat_list: column sums [13, 21, 25, 25], columns 4 and 6 both 20, columns 5 and 6 both 22
agreement with nuron_list (trial, onset): not testable
agreement with nuron_list (condition, onset): suppression 35/41, FF (column 4) 26/41, ST (column 6) 15/41; listed ST neurons found 11/37
agreement with nuron_list (unpaired, onset): suppression 38/41, FF (column 4) 28/41, ST (column 6) 28/41; listed ST neurons found 24/37
agreement with nuron_list (timebin, onset): suppression 34/41, FF (column 4) 26/41, ST (column 6) 20/41; listed ST neurons found 16/37
agreement with nuron_list (timebin_smoothed, onset): suppression 34/41, FF (column 4) 29/41, ST (column 6) 36/41; listed ST neurons found 33/37
agreement with nuron_list (trial, every): not testable
agreement with nuron_list (condition, every): suppression 35/41, FF (column 4) 27/41, ST (column 6) 13/41; listed ST neurons found 9/37
agreement with nuron_list (unpaired, every): suppression 33/41, FF (column 4) 29/41, ST (column 6) 35/41; listed ST neurons found 31/37
agreement with nuron_list (timebin, every): suppression 32/41, FF (column 4) 31/41, ST (column 6) 33/41; listed ST neurons found 29/37
agreement with nuron_list (timebin_smoothed, every): suppression 31/41, FF (column 4) 31/41, ST (column 6) 36/41; listed ST neurons found 32/37
aggat_list: neurons with the effect in nuron_list and in the list, columns 3-6: [7, 18, 20, 24]
gauss_list: neurons with the effect in nuron_list and in the list, columns 3-6: [7, 19, 19, 23]
twobm_list: neurons with the effect in nuron_list and in the list, columns 3-6: [6, 20, 18, 21]
nsglm_list: neurons with the effect in nuron_list and in the list, columns 3-6: [7, 9, 9, 14]
    neuron  list_supp  list_ff  list_st  supp_cond  supp_unp  supp_tb  supp_tbs  ff_cond  ff_unp   ff_tb  ff_tbs  st_cond  st_unp   st_tb  st_tbs
2015051115          0        1        1       0.96      0.98        1         1  0.00063   2e-06 1.1e-09 1.2e-13  0.00037 7.2e-06 1.4e-10 1.2e-13
2015071702          0        1        1        0.8         1     0.95         1    0.017 0.00011   0.023 8.7e-11    0.092 4.5e-05  0.0014 4.6e-11
2015071703          0        1        1        0.9      0.82     0.55         1     0.75    0.93       1       1     0.28   0.036    0.97 5.8e-12
2015071704          0        0        1       0.63      0.99        1         1     0.33    0.06   0.011 1.5e-11    0.065   0.009  0.0095 1.3e-13
2015072013          0        1        1       0.83      0.75     0.55         1     0.52     0.2    0.78    0.23     0.83    0.16    0.92 6.4e-08
2015072016          0        0        1       0.51      0.29    0.039   1.5e-08     0.93    0.93    0.97       1    0.079    0.16    0.11 9.9e-10
2015072903          0        0        1       0.88      0.76     0.65      0.98     0.77    0.87       1       1      0.2   0.046    0.87   0.059
2015082005          0        1        1       0.85      0.99     0.99         1    0.012 1.4e-07 4.7e-05 4.6e-11   0.0012 6.3e-13 2.8e-08   4e-13
2015082009          1        0        1      0.043   0.00042  8.3e-06   1.5e-08     0.95       1       1       1     0.97    0.88       1       1
2015082010          0        0        0        0.9       0.9     0.82      0.99     0.94       1       1       1     0.89    0.66    0.85       1
2015082011          0        0        0      0.042    0.0059   0.0027   1.5e-08        1       1       1       1     0.93    0.97       1       1
2015082015          0        1        1       0.67      0.62     0.43      0.47     0.08   0.037   0.065 4.4e-09   0.0035  0.0023   0.017 3.5e-13
2015082016          1        0        1     0.0033   0.00034  0.00029   1.5e-08     0.82    0.75    0.95       1     0.57    0.76    0.32   0.013
2015083106          1        0        0      0.026    0.0052   0.0071   4.5e-08        1       1       1       1        1       1       1       1
2015090504          1        0        1    0.00021    0.0019    2e-05   1.5e-08     0.58    0.55    0.47   0.024     0.18    0.19   0.034 1.8e-07
2015090508          1        0        1      0.051     0.018   0.0034   1.5e-08     0.97    0.98       1       1     0.22    0.23    0.41    0.46
2015092704          0        1        1       0.27      0.52     0.56      0.11    0.036    0.17    0.31 4.5e-09     0.12    0.02    0.17 1.4e-07
2015092706          0        0        1        0.6      0.47     0.35      0.29     0.63    0.94       1       1     0.54    0.17    0.49 0.00058
2015092707          0        1        1       0.98         1        1         1   0.0073 4.7e-07 1.9e-10 1.2e-13   0.0059 2.7e-08 2.3e-10 1.2e-13
2015092708          1        1        1      0.016    0.0071  0.00038   1.5e-08    0.024   0.004     0.1 1.3e-11    0.011   0.049    0.93 8.1e-11
2015092709          1        0        1       0.49      0.02    0.015   9.5e-06     0.91    0.99       1       1     0.47    0.72    0.85       1
2015092710          0        0        1      0.069      0.21     0.25      0.51      0.3   0.095    0.83   0.018     0.82   0.031     0.4  0.0043
2015092711          0        1        1       0.43      0.46     0.75         1     0.17   0.061    0.29 0.00053   0.0052  0.0034   0.058 1.3e-13
2015092716          0        1        1       0.62      0.38    0.041     0.087    0.093   0.024   0.028 7.4e-13  0.00079 1.6e-08 0.00019 4.3e-13
2015092905          0        1        1       0.75      0.18   0.0015   0.00021        1    0.86       1    0.96      0.5   0.022    0.99 0.00044
2015092909          0        1        1          1      0.49     0.87         1     0.91    0.68       1       1     0.38   0.079    0.46 8.4e-13
2015092910          0        1        1       0.62      0.75     0.86      0.93    0.035  0.0065  0.0043 2.4e-13    0.031 0.00057   0.059 4.3e-13
2015121404          0        0        1       0.91      0.92     0.57         1     0.88    0.48    0.83    0.93    0.078   0.047   0.035 1.2e-13
2015121405          0        1        0       0.93       0.9     0.54         1     0.61     0.8    0.88    0.45     0.47    0.18    0.54  0.0034
2015121406          0        0        1       0.22      0.42     0.16   0.00012     0.23    0.58    0.56    0.94    0.057    0.14    0.35 2.7e-06
2015121408          0        1        1      0.088      0.48     0.45      0.28     0.76    0.23    0.15   9e-08     0.13    0.02    0.24 2.2e-07
2015121410          0        1        1       0.33       0.9     0.66         1   0.0035  0.0058  0.0035 3.1e-13   0.0081 0.00071 0.00014   3e-13
2015121411          0        1        1       0.72      0.32     0.26      0.38     0.34    0.11    0.29 0.00037    0.017  0.0022  0.0016 1.6e-13
2015121413          0        0        1       0.82      0.68     0.67         1     0.26   0.065    0.32 3.1e-05     0.56   0.025   0.039 1.8e-12
2015121510          0        1        1       0.37      0.49     0.32   0.00042    0.072  0.0081   0.041 7.4e-13     0.04   0.005   0.027 5.8e-09
2015121511          0        1        1        0.8      0.86     0.83         1    0.052   0.097   0.032 1.6e-05     0.28   0.033 0.00034 1.2e-13
2015121512          1        1        1       0.24      0.25     0.16    0.0013     0.79    0.81    0.87       1     0.34     0.2    0.33 5.2e-05
2015121513          0        0        1      0.019       0.1   0.0057     1e-07     0.97    0.96       1       1     0.27   0.075    0.11 1.2e-13
2015121514          0        0        1       0.81      0.84     0.76         1     0.94    0.68       1       1     0.31   0.048   0.012 3.1e-05
2015121515          0        1        1        0.2      0.42     0.18      0.22     0.88     0.9    0.95       1     0.18 0.00058  0.0075 2.5e-10
2015121516          0        1        1      0.022     0.043    0.026   1.5e-08      0.9    0.97    0.95       1     0.11   0.056    0.16 1.4e-06

Summary¶

Claim Outcome
probe-locations-link reproduced
methods-neuron-counts reproduced
fig1b-saccadic-suppression reproduced
fig1c-ff-remapping not reproduced
fig1d-st-remapping not reproduced
fig1e-ff-and-st-remapping not reproduced
fig1-remapping-longer-latency reproduced
fig1-example-neurons partially reproduced
fig5a-n-model-no-perisaccadic-gain blocked (methods underspecified: the N-model)
24 other claims on the S-, F- and A-models (Figures 3, 5 to 8, S4, S5) blocked (too large)
figs1-rf-centres blocked (metadata insufficient)

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.

How the analysis differs from the paper's. The Methods name a one-sided signed-rank test without saying what is paired. Pairing by trial (O1 a) is impossible in these data, because no trial shows the same probe in both windows, so the outcomes rest on pairing by condition (O1 b). Under that reading saccadic suppression matches the paper (8 neurons, 5 of them in the code's nuron_list) but FF- and ST-remapping are found in far fewer neurons (8 and 11 against 23 and 37). Variants the claims file does not let decide come closer: the unpaired test on every millisecond a probe is on gives 12, 17 and 31, and a signed-rank test over the 1 ms bins of the smoothed response curves, which the Methods exclude, gives 15, 19 and 34, agreeing with nuron_list on ST for 36 of 41 neurons. Whether the claims file should include a pairing over time bins is asked of a reader. The example neurons' fixation rates differ slightly from the paper's while their perisaccadic rates match, so the paper's fixation set also differs from -500 to -100 ms in a way not identified here. No model was fitted. The N-model's reference [48] is Akbarian et al. (2018), IEEE Trans Biomed Eng 65(2):241-253, identified after the N-model claim was verified as blocked; a later attempt can implement it from that paper.

What was found about the dataset. The 41 files match the paper's 41 neurons and 11 sessions and the descriptor's per-session counts, and they are identical to the copies in the paper's code repository. Each recording appears once. The stimulus and saccade clocks hold: the RF response peaks at 58 ms after probe onset and disappears with codes shifted by 300 ms. The files do not give the saccade direction, the RF, FF or ST probes, the grid's position and spacing, or which monkey each session comes from; the probes are only in the code repository. Probes do not tile time as the paper says: about 91.5% of probe runs last 7 ms and 5.6% last 6 ms; most others last 14 or 21 ms, and a few 8 to 28 ms. Between probes there are gaps of 7 to 28 ms with no probe on screen, nearly all of 10, 11, 20 or 21 ms. A 14 or 21 ms run takes one place in the probe order. The order does not hold all 81 probes in three sessions (75 in 20150511, 80 in 20150927 and 20150929), and in every session but 20150717 it restarts from its first probe 35 to 296 ms after saccade onset in most trials, so each probe is shown 2 to 4 times per trial. The arrays are 3000 ms long, while the paper gives trials of 2100 to 2300 ms.

In [19]:
print(f"total run time {time.time() - T0:.0f} s, peak memory {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1e6:.2f} GB")
total run time 68 s, peak memory 1.38 GB