Reproducing Shi, Apker and Buneo (2013) on CRCNS ppc-1¶
Paper. Shi Y, Apker G, Buneo CA (2013). Multimodal representation of limb endpoint position in the posterior parietal cortex. J Neurophysiol 109: 2097-2107. doi:10.1152/jn.00223.2012
Dataset. CRCNS ppc-1, Buneo, Shi, Apker and VanGilder (2016),
doi:10.6080/K0CZ353K, identified here as
crcns:ppc-1/unversioned. It is read from the public bucket
(https://crcnsarchive.s3-us-west-2.amazonaws.com/ppc-1/live/data.tar.gz, streamed, not
downloaded).
Version. CRCNS data sets are not versioned, and ppc-1 has one published copy, under live/
(no old/ copy exists in the bucket), so that copy is the one pinned. The paper cites no version.
To detect a later change: data.tar.gz has MD5 bbb341b8947a6314b2618f0caa0b64f8 in the data
set's checksums.md5 (printed below as read), size 4,394,813,551 bytes; data descriptor version 0.8
(Dec 7, 2016).
Claims. claims/shi-2013.yaml, written from the version of record (Methods, Results,
Discussion, Table 1, legends of Figures 1 to 6; the paper has no supplement and links no code), and
checked by a second reader.
What the data set holds, in short. Spike times of sorted units and strobed event codes for each session, in MATLAB and Plexon files; each trial's events end with a text record that gives the target, a two-valued condition code and the hand position. All sessions have monkey X's target layout; monkey B is not in the data set. Which condition code is Vision is not documented and is inferred from the data (see "Which code is Vision"). Outcomes that depend on it are marked as resting on that assumption.
| Claim | Status |
|---|---|
| behavior-mean-position-sessions | tested |
| behavior-variability-sessions | tested |
| table1-endpoint-means | tested |
| table1-endpoint-sd | tested |
| fig3-example-neuron | tested |
| movement-epoch-tuning | tested |
| hold-position-main-effect | tested |
| hold-vision-main-effect | tested |
| hold-interaction | tested |
| hold-subepochs | tested |
| hold-overall-effects | tested |
| correlation-endpoint-datasets | tested |
| fig4-indx1-negative | tested |
| fig4-indx1-means | tested |
| indx1-tuning-shift | tested |
| indx2-means | tested |
| rate-variance-nv-higher | tested |
| fig5-fano-factor | tested |
| cv2-larger-nv | tested |
| fig6-decoding-vv | tested |
| fig6-decoding-nvnv | tested |
| decoding-v-better-than-nv | tested |
| fig6-decoding-cross | tested |
| decoding-subepochs | tested |
| decoding-nonsignificant-cells | tested |
| eye-position-no-difference | blocked |
| aborted-trials-nv | blocked |
| longer-hold-no-difference | blocked |
import time
import warnings
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import yaml
from scipy import stats
import ppc
warnings.filterwarnings("ignore", category=RuntimeWarning)
pd.set_option("display.width", 220)
pd.set_option("display.max_columns", 40)
pd.set_option("display.max_rows", 200)
CLAIMS = {c["id"]: c for c in yaml.safe_load(Path("../../claims/shi-2013.yaml").read_text())["claims"]}
def expected(cid):
return [(e["quantity"], e["value"], e.get("tolerance")) for e in CLAIMS[cid].get("expected", [])]
Loading¶
The data set is one 4.4 GB data.tar.gz. It is streamed once from the CRCNS bucket and each
session's MATLAB file is reduced to its trial table and spike times as it passes (ppc.load_all);
nothing is written to disk. The .plx file of the first session is parsed too, to check the
MATLAB extraction against Plexon's own file.
t_start = time.time()
D = ppc.load_all()
print(f"streamed in {(time.time() - t_start) / 60:.1f} min")
import resource
print(f"peak memory {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1e6:.2f} GB")
import fsspec
with fsspec.open("https://crcnsarchive.s3-us-west-2.amazonaws.com/ppc-1/live/checksums.md5", "rt") as f:
print(f.read())
streamed in 4.0 min peak memory 0.51 GB fad2fd4c900133461b4a7c95a27d3b18 data_filelist.txt bbb341b8947a6314b2618f0caa0b64f8 data.tar.gz 7a45ce3b236aa4ee83390283964bcca6 docs/crcns_ppc-1_data_description.docx 1cbab60cd05d2928ec86aa5716983c75 docs/crcns_ppc-1_data_description.pdf 4a54fc39336c010f5c971af54b3a7973 filelist.txt
Data check¶
mem = pd.DataFrame(D["members"], columns=["name", "size"])
mem["kind"] = mem.name.str.extract(r"(\.plxAnaAD\.dat|\.plxAnaAD\.mat|\.plxSpk\.dat|\.[A-Za-z0-9]+)$")[0]
print("members of data.tar.gz by kind:")
print(mem.kind.value_counts(dropna=False).to_string())
print("folders (recording days):", mem.name.str.extract(r"^data/(\d{6})/")[0].nunique())
print("session .mat files read:", len(D["sessions"]), " unreadable:", D["errors"])
names = pd.Series(sorted(D["sessions"]))
print("session file names: <mmddyy>_<n>", names.str.contains(r"/\d{6}_\d+\.mat$").sum(),
" d<n>", names.str.contains(r"/d\d+\.mat$").sum(), " File<n>", names.str.contains(r"/File\d+\.mat$").sum())
members of data.tar.gz by kind:
kind
.plx 685
.mat 608
.plxSpk.dat 608
.plxAnaAD.dat 607
.plxAnaAD.mat 607
NaN 117
.txt 110
.jpg 2
.db 2
.doc 1
.bmp 1
.fig 1
folders (recording days): 113
session .mat files read: 415 unreadable: {}
session file names: <mmddyy>_<n> 404 d<n> 9 File<n> 2
The data descriptor lists <session>.mat with strobed (time stamps, event codes), data
(spike time stamps) and waveforms. It does not give units. The check below compares the first
session's .mat with its .plx file, read with Plexon's published layout.
first = "data/010609/010609_1.mat"
s0 = D["sessions"][first]
plx = D["plx"]
st = s0["strobed_head"]
n = min(len(st), len(plx["strobed"]))
print("plx ADFrequency (Hz):", plx["adfreq"])
print("strobed events, .mat vs .plx: n", s0["n_strobes"], "; first", n, "codes identical:",
bool(np.all(st[:n, 1] == plx["strobed"][:n, 1])),
"; max time difference (s):", float(np.max(np.abs(st[:n, 0] - plx["strobed"][:n, 0]))))
u = s0["units"]["chan1a"]
for key, sp in plx["spikes"].items():
m = min(len(sp), len(u))
same = len(sp) == len(u) and np.allclose(sp, u, atol=1e-4)
print(f"plx unit {key}: {len(sp)} spikes; equals .mat chan1a (ms / 1000): {same}")
print(".mat chan1a spikes span", round(u.min(), 2), "to", round(u.max(), 2), "s; strobes span",
round(st[0, 0], 2), "to", round(s0["trials"].t0.max(), 2), "s")
plx ADFrequency (Hz): 40000 strobed events, .mat vs .plx: n 28173 ; first 2000 codes identical: True ; max time difference (s): 0.0 plx unit (1, 0): 682 spikes; equals .mat chan1a (ms / 1000): False plx unit (1, 1): 1968 spikes; equals .mat chan1a (ms / 1000): True .mat chan1a spikes span 0.64 to 636.9 s; strobes span 4.42 to 628.2 s
The trial record and the event codes¶
Each trial's events end with code 255 and an ASCII record (see ppc.py). EventCodes.txt in
the data set is a generic code list (names such as TAPE = 1, DISPLAY = 10) that does not
describe the codes used here, so their meaning is read from the timing below.
allt = pd.concat([s["trials"].assign(session=k) for k, s in D["sessions"].items()], ignore_index=True)
print("trials:", len(allt), " completed (code 12):", int(allt.completed.sum()), " aborted (code 14):",
int(allt.aborted.sum()))
print("record length (fields) per trial:")
print(allt.nrec.value_counts().to_string())
c = allt[allt.completed & allt.target.notna()]
print("completed trials by target code and field 14:")
print(pd.crosstab(c.target, c.cond).to_string())
iv = pd.DataFrame({
"3 - t0 (start held, target on?)": c.t3 - c.t0,
"8 - 3 (reaction time?)": c.t8 - c.t3,
"target code - 8 (movement time?)": c.t_target - c.t8,
"10 - target code": c.t10 - c.t_target,
"12 - 10": c.t12 - c.t10,
"13 - 12": c.t13 - c.t12,
})
print("intervals between events on completed trials (s):")
print(iv.describe(percentiles=[0.05, 0.5, 0.95]).T.round(3).to_string())
trials: 54116 completed (code 12): 31330 aborted (code 14): 22756
record length (fields) per trial:
nrec
24 33438
22 19509
19 1132
0 37
completed trials by target code and field 14:
cond 2.0 4.0 7.0
target
44.0 0 1948 1930
45.0 0 1934 1915
46.0 0 1933 1916
54.0 0 1932 1910
56.0 0 1929 1910
64.0 1 1933 1914
65.0 0 1932 1911
66.0 0 1932 1909
intervals between events on completed trials (s):
count mean std min 5% 50% 95% max
3 - t0 (start held, target on?) 30789.0 0.650 0.167 0.543 0.544 0.576 0.960 1.920
8 - 3 (reaction time?) 30789.0 0.433 0.120 0.080 0.224 0.448 0.576 1.120
target code - 8 (movement time?) 30789.0 0.163 0.119 0.016 0.032 0.128 0.384 1.248
10 - target code 30789.0 0.317 0.013 0.224 0.304 0.320 0.320 0.416
12 - 10 30789.0 1.184 0.118 0.832 0.960 1.184 1.376 1.856
13 - 12 30789.0 0.029 0.006 0.016 0.016 0.032 0.032 0.032
Reading of the codes, from the timing and the paper's paradigm (Methods, Experimental paradigm). Ranges below are the 5th to 95th percentiles of the table above, with the minimum and maximum in brackets. Code 3 comes 0.54 to 0.96 s (0.54 to 1.92 s) after the trial starts (the start position is shown, then held for 500 ms): it fits target onset, the go signal. Code 8 follows 0.22 to 0.58 s (0.08 to 1.12 s) later (a reaction time), and the target code 0.03 to 0.38 s (0.02 to 1.25 s) after 8 (median 0.13 s): 8 fits the cursor leaving the start window and the target code the cursor entering the target window. Code 10 follows the target code by a median of 320 ms (5th to 95th percentile 0.30 to 0.32 s, range 0.22 to 0.42 s), the 300 ms after which the target is extinguished (on a 32 ms strobe clock). From 10 to 12 is 0.83 to 1.86 s, the saccade to the central fixation point and the 800 to 1,200 ms hold. Code 12 is taken as the end of the static holding period, and 13, 32 ms later, as reward. These are readings of the data, not documented; the clock check below tests the alignment.
geo = []
for k, s in D["sessions"].items():
t = s["trials"]
if "target" not in t or t.target.isna().all():
continue
t = t[t.completed & t.target.isin(ppc.TARGETS)]
row = t.target // 10
col = t.target % 10
geo.append(dict(session=k, n=len(t),
x_right_minus_left=t[col == 6].x.mean() - t[col == 4].x.mean(),
y_top_minus_bottom=t[row == 6].y.mean() - t[row == 4].y.mean(),
y_middle_row=t[row == 5].y.mean(), z=t.z.mean()))
geo = pd.DataFrame(geo)
print("target geometry per session, from the record's x, y, z (cm):")
print(geo.describe().round(2).to_string())
print("sessions with mean z > 12 cm:", (geo.z > 12).sum(), "; with y_top_minus_bottom > 9 cm:",
(geo.y_top_minus_bottom > 9).sum())
target geometry per session, from the record's x, y, z (cm):
n x_right_minus_left y_top_minus_bottom y_middle_row z
count 406.00 404.00 405.00 404.00 406.00
mean 75.83 9.19 7.39 -4.10 10.06
std 14.80 0.63 0.54 0.45 0.50
min 5.00 7.31 5.65 -5.61 6.34
25% 80.00 8.78 7.08 -4.37 9.83
50% 80.00 9.25 7.38 -4.07 10.02
75% 80.00 9.62 7.68 -3.82 10.25
max 122.00 10.79 8.99 -2.30 14.04
sessions with mean z > 12 cm: 3 ; with y_top_minus_bottom > 9 cm: 0
The paper's targets are 5 cm apart horizontally and 4 cm vertically for monkey X (a rectangle), 5 cm along both axes for monkey B (a square), and Table 1 places monkey X's hand at depth z of about 9.5 to 10.2 cm and monkey B's at 14.2 to 14.9 cm, with the middle row at y of about -4 cm (X) and -0.8 cm (B). In every session with a record the targets are about 9.2 cm apart horizontally and 7.4 cm vertically (twice 4.6 and 3.7 cm), the middle row is at y near -4 cm, and depth is near 10 cm: the geometry of monkey X. No session has monkey B's geometry. The data set descriptor says it holds 343 cells, 219 from X and 124 from B; the data are consistent with monkey X only. A few sessions have z near 14 cm but monkey X's x and y layout.
kept, sel = ppc.select_sessions(D["sessions"])
print(sel.status.value_counts().to_string())
print("sessions without a usable record:", sel[sel.status.str.startswith("no")].session.tolist())
ks = sel[sel.status.str.startswith("kept")]
print("kept sessions:", len(ks), "; sorted units in them:", int(ks.n_units.sum()),
"; units per session:", ks.n_units.value_counts().sort_index().to_dict())
par = pd.Series([kept[k].params.iloc[0] for k in kept])
print("record fields 0 to 12 (task parameters) in kept sessions:")
print(par.value_counts().to_string())
early = [k for k in D["sessions"] if "/d" in k]
print("early d<n> files: record fields per trial",
sorted({int(x) for k in early for x in D["sessions"][k]["trials"].nrec.unique()}))
for k in early:
st_ = D["sessions"][k]["strobed_head"]
c_ = st_[:, 1].astype(int)
j = int(np.flatnonzero(c_ == 255)[0])
nxt = np.flatnonzero(c_[j + 1:] == 0)
rec = ppc.parse_record(c_[j + 1:j + 1 + (nxt[0] if len(nxt) else len(c_))])
print(f" {k}: {len(rec)} fields; fields 11 and 12 = {rec[11]:.0f}, {rec[12]:.0f}")
status
kept 355
incomplete design 47
no trial record with target and position 9
kept, first five per cell 4
sessions without a usable record: ['data/041408/d1.mat', 'data/041408/d2.mat', 'data/042808/d4.mat', 'data/042808/d5.mat', 'data/050608/d10.mat', 'data/050608/d11.mat', 'data/050608/d9.mat', 'data/050908/d13.mat', 'data/050908/d14.mat']
kept sessions: 359 ; sorted units in them: 485 ; units per session: {1: 255, 2: 83, 3: 20, 4: 1}
record fields 0 to 12 (task parameters) in kept sessions:
(0.0, 10.0, 300.0, 600.0, 1400.0, 0.0, 500.0, 10.0, 300.0, 600.0, 1400.0, 900.0, 300.0) 226
(0.0, 8.0, 300.0, 600.0, 1400.0, 0.0, 500.0, 10.0, 300.0, 600.0, 1400.0, 900.0, 300.0) 65
(0.0, 10.0, 300.0, 600.0, 1400.0, 0.0, 500.0, 10.0, 300.0, 600.0, 1400.0, 1000.0, 300.0) 33
(0.0, 10.0, 300.0, 600.0, 1400.0, 0.0, 500.0, 6.0, 300.0, 600.0, 1400.0, 900.0, 300.0) 7
(0.0, 10.0, 300.0, 600.0, 1400.0, 0.0, 500.0, 8.0, 300.0, 600.0, 1400.0, 900.0, 300.0) 6
(0.0, 12.0, 300.0, 600.0, 1400.0, 0.0, 500.0, 10.0, 300.0, 600.0, 1400.0, 1000.0, 300.0) 6
(0.0, 12.0, 300.0, 600.0, 1400.0, 0.0, 500.0, 12.0, 300.0, 600.0, 1400.0, 1000.0, 300.0) 4
(0.0, 10.0, 300.0, 600.0, 1400.0, 0.0, 500.0, 13.0, 300.0, 600.0, 1400.0, 900.0, 300.0) 2
(0.0, 10.0, 300.0, 600.0, 1400.0, 0.0, 500.0, 4.0, 300.0, 600.0, 1400.0, 900.0, 300.0) 2
(0.0, 8.0, 300.0, 600.0, 1400.0, 0.0, 500.0, 8.0, 300.0, 600.0, 1400.0, 900.0, 300.0) 2
(0.0, 10.0, 300.0, 600.0, 1400.0, 0.0, 500.0, 10.0, 300.0, 600.0, 1400.0, 1100.0, 200.0) 2
(0.0, 10.0, 300.0, 600.0, 1400.0, 0.0, 500.0, 12.0, 300.0, 600.0, 1400.0, 900.0, 300.0) 1
(0.0, 10.0, 300.0, 600.0, 1400.0, 0.0, 500.0, 5.0, 300.0, 600.0, 1400.0, 900.0, 300.0) 1
(0.0, 10.0, 300.0, 600.0, 1400.0, 0.0, 500.0, 10.0, 300.0, 600.0, 1400.0, 800.0, 400.0) 1
(0.0, 10.0, 300.0, 600.0, 1400.0, 0.0, 500.0, 11.0, 300.0, 600.0, 1400.0, 900.0, 300.0) 1
early d<n> files: record fields per trial [0, 19]
data/041408/d1.mat: 19 fields; fields 11 and 12 = 500, 500
data/041408/d2.mat: 19 fields; fields 11 and 12 = 500, 500
data/042808/d4.mat: 19 fields; fields 11 and 12 = 600, 400
data/042808/d5.mat: 19 fields; fields 11 and 12 = 600, 400
data/050608/d10.mat: 19 fields; fields 11 and 12 = 500, 500
data/050608/d11.mat: 19 fields; fields 11 and 12 = 500, 500
data/050608/d9.mat: 19 fields; fields 11 and 12 = 500, 500
data/050908/d13.mat: 19 fields; fields 11 and 12 = 500, 500
data/050908/d14.mat: 19 fields; fields 11 and 12 = 500, 500
Kept are the sessions whose completed trials cover the 8 targets in both codes of field 14 with
at least five trials each, the paper's design ("Five trials were performed for each target",
Methods); where a cell has more, the first five in time are used. The early d<n> files have a
19 field record without positions, and field 11 (read as the minimum hold, 900 ms in most
sessions, with field 12, 300 ms, as its random part; see longer-hold-no-difference) is 500 or 600
ms there, below the paper's 800 ms hold; they are not used. Fields 1 and 7 vary between sessions (4
to 15) and may be window sizes; no file says.
c10 = allt[allt.completed & allt.params.notna()].copy()
c10["field11_s"] = c10.params.apply(lambda p: p[11]) / 1000
c10["d10_12"] = c10.t12 - c10.t10
c10["excess"] = c10.d10_12 - c10.field11_s
c10["kept"] = c10.session.isin(kept)
print("completed trials with a record: code 10 to code 12 interval against the trial's own field 11 (s):")
print(c10.groupby("field11_s").agg(trials=("d10_12", "size"), min_10_to_12=("d10_12", "min"),
median_10_to_12=("d10_12", "median"), max_10_to_12=("d10_12", "max"),
min_excess=("excess", "min")).round(3).to_string())
print("trials where code 10 to code 12 is shorter than field 11:", int((c10.excess < 0).sum()), "of", len(c10))
print("excess of code 10 to code 12 over field 11 (s), quantiles:",
c10.excess.quantile([0, 0.01, 0.05, 0.25, 0.5, 0.75, 0.95, 1]).round(3).to_dict())
for lim in (0.25, 0.30):
for lab, sub in (("all", c10), ("kept sessions", c10[c10.kept])):
print(f"{lab}: trials whose 800 ms window (code 12 - 0.8 s) starts less than {lim} s after code 10: "
f"{100 * np.mean(sub.d10_12 - 0.8 < lim):.1f}% of {len(sub)}")
completed trials with a record: code 10 to code 12 interval against the trial's own field 11 (s):
trials min_10_to_12 median_10_to_12 max_10_to_12 min_excess
field11_s
0.8 266 0.832 0.992 1.248 0.032
0.9 26942 0.928 1.184 1.792 0.028
1.0 3386 1.056 1.312 1.856 0.056
1.1 195 1.152 1.152 1.152 0.052
trials where code 10 to code 12 is shorter than field 11: 0 of 30789
excess of code 10 to code 12 over field 11 (s), quantiles: {0.0: 0.028, 0.01: 0.028, 0.05: 0.056, 0.25: 0.22, 0.5: 0.284, 0.75: 0.348, 0.95: 0.44, 1.0: 0.892}
all: trials whose 800 ms window (code 12 - 0.8 s) starts less than 0.25 s after code 10: 11.9% of 30789
kept sessions: trials whose 800 ms window (code 12 - 0.8 s) starts less than 0.25 s after code 10: 11.6% of 28790
all: trials whose 800 ms window (code 12 - 0.8 s) starts less than 0.3 s after code 10: 21.2% of 30789
kept sessions: trials whose 800 ms window (code 12 - 0.8 s) starts less than 0.3 s after code 10: 21.0% of 28790
On every completed trial the time from code 10 to code 12 is at least the trial's own record field 11 plus 28 ms (the table above): the shortest intervals, 0.83 s, are on trials with field 11 = 800, and with 900 and 1,000 the shortest are 0.93 and 1.06 s. Field 11 is therefore read as the minimum hold, timed from a point at least 28 ms after code 10 (target offset, the cue to saccade to the centre), and code 12 as its end, so the 800 ms before code 12 lie inside the hold as the task timed it. A start 28 ms after the cue is too early for a saccade; the fixation window is 6.5 degrees in radius (Methods, Experimental paradigm), so the eyes may already have been inside it. Where the window starts soon after code 10 it may still include the end of a saccade, and this bears most on the first 400 ms. The share of such trials is printed above. A variant that starts the window at least 250 ms after code 10 is run for hold-subepochs and decoding-subepochs.
Which code is Vision¶
Field 14 splits each session's completed trials into two halves, five per target, as V and NV should. No file says which is which. The conditions differ only from the end of the reach, when the cursor is blanked on NV trials. The table counts aborted trials by whether they ended before or after code 10.
a = allt[allt.cond.isin([4, 7])].copy()
a["phase"] = np.where(a.completed, "completed", np.where(a.t10.notna(), "aborted after code 10", "aborted before code 10"))
tab = pd.crosstab(a.phase, a.cond)
print(tab.to_string())
pre = tab.loc["aborted before code 10"]; post = tab.loc["aborted after code 10"]
print("chi-square, aborts after code 10 against completed, by code:",
stats.chi2_contingency(tab.loc[["aborted after code 10", "completed"]].values)[:2])
per = a[a.phase == "aborted after code 10"].groupby(["session", "cond"]).size().unstack(fill_value=0)
print("sessions with more aborts after code 10 on code 7 / on code 4 / equal:",
int((per[7] > per[4]).sum()), int((per[4] > per[7]).sum()), int((per[4] == per[7]).sum()))
print("binomial test over sessions:", stats.binomtest(int((per[7] > per[4]).sum()),
int((per[7] != per[4]).sum())).pvalue)
cond 4.0 7.0 phase aborted after code 10 4423 5688 aborted before code 10 6006 6040 completed 15473 15315 chi-square, aborts after code 10 against completed, by code: (np.float64(128.94788771406652), np.float64(6.962253719773221e-30)) sessions with more aborts after code 10 on code 7 / on code 4 / equal: 210 165 28 binomial test over sessions: 0.02295027298522436
Aborts before code 10, when the two kinds of trial do not yet differ, are equal in number; aborts
after it are about 29% more frequent on code 7 trials. The paper reports more aborted trials
without vision of the cursor (Discussion, Additional factors influencing neural responses,
paragraph 1). Code 7 is therefore taken as No Vision and code 4 as Vision. This is an assumption
(ppc.V_CODE, ppc.NV_CODE). Outcomes that depend on the direction are marked as resting on it;
the other mapping is shown for the indexes and for the V against NV decoding, and for the
variances, FF and CV2 it would reverse the direction of the difference. Claims whose test is
symmetric in V and NV (the counts of ANOVA effects, the MANOVA and Levene tests, correlations)
do not depend on it. The neural results were not used to choose the mapping.
The clock of spikes and events¶
If the spike times and the event times share a clock, the target should be decodable from spikes after the reach and not before the target is shown. For each kept session's units, the fraction with a significant target effect (one-way ANOVA on counts over the 80 trials, P < 0.05) is computed in 800 ms windows ending at code 12, and in windows shifted in time.
def units_of(kept, all_units=False):
out = []
for k, t in kept.items():
us = D["sessions"][k]["units"]
names_ = list(us)[:None if all_units else 1]
for u_ in names_:
out.append((k, u_, us[u_]))
return out
UNITS_ALL = units_of(kept, all_units=True)
shifts = [-6.0, -4.0, -3.0, -2.5, -2.0, -1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 3.0]
frac = []
for sh in shifts:
sig = []
for k, u_, sp in UNITS_ALL:
t = kept[k]
cnt = ppc.unit_counts(t, sp, (sh - 0.8, sh))
groups = [cnt[t.target.values == tg] for tg in ppc.TARGETS]
if np.all(cnt == cnt[0]):
sig.append(False)
continue
sig.append(stats.f_oneway(*groups).pvalue < 0.05)
frac.append(np.mean(sig))
print(pd.DataFrame({"window end relative to code 12 (s)": shifts, "fraction of units with a target effect": np.round(frac, 3)}).to_string(index=False))
pre_t = []
for k, u_, sp in UNITS_ALL:
t = kept[k]
cnt = ppc.unit_counts(t, sp, (-0.8, 0.0), align="t0")
groups = [cnt[t.target.values == tg] for tg in ppc.TARGETS]
pre_t.append(False if np.all(cnt == cnt[0]) else stats.f_oneway(*groups).pvalue < 0.05)
print("window of 800 ms before the trial's first event:", round(float(np.mean(pre_t)), 3), "(chance 0.05)")
print("units:", len(UNITS_ALL))
window end relative to code 12 (s) fraction of units with a target effect
-6.0 0.035
-4.0 0.023
-3.0 0.039
-2.5 0.045
-2.0 0.049
-1.5 0.359
-1.0 0.602
-0.5 0.482
0.0 0.361
0.5 0.336
1.0 0.311
3.0 0.045
window of 800 ms before the trial's first event: 0.021 (chance 0.05) units: 485
The target is decoded in about a third or more of the units in the windows ending at or before code 12 back to the reach, and in about 5% (chance) before the trial starts, when the target is not yet known. Spike times and event times share a clock in the data as a whole; this check does not establish it for each session separately.
rows = []
for k in kept:
t = kept[k]
ph, pp = [], []
for u_, sp in D["sessions"][k]["units"].items():
for align, lst in (("t12", ph), ("t0", pp)):
cnt = ppc.unit_counts(t, sp, (-0.8, 0.0), align=align)
g_ = [cnt[t.target.values == tg] for tg in ppc.TARGETS]
lst.append(1.0 if np.all(cnt == cnt[0]) else stats.f_oneway(*g_).pvalue)
rows.append(dict(session=k, n_units=len(ph), p_hold=min(ph), p_pre=min(pp)))
CK = pd.DataFrame(rows)
print("per session, smallest one-way ANOVA P of the target effect over its units:")
print(f" last 800 ms before code 12: P < 0.05 in {int((CK.p_hold < 0.05).sum())} of {len(CK)} sessions")
print(f" 800 ms before the trial's first event: P < 0.05 in {int((CK.p_pre < 0.05).sum())} of {len(CK)} sessions"
f" (expected if no unit were tuned: {np.sum(1 - 0.95 ** CK.n_units):.0f})")
print("sessions where this check does not support the clock (no unit with a hold target effect):",
int((CK.p_hold >= 0.05).sum()))
per session, smallest one-way ANOVA P of the target effect over its units: last 800 ms before code 12: P < 0.05 in 153 of 359 sessions 800 ms before the trial's first event: P < 0.05 in 10 of 359 sessions (expected if no unit were tuned: 24) sessions where this check does not support the clock (no unit with a hold target effect): 206
Per session the check has one to four units, so it supports the shared clock only where a unit is tuned to the target in the hold: 153 of the 359 sessions. Before the trial starts, 10 sessions have a unit with a target effect, fewer than the 24 expected if no unit were tuned. In the other 206 sessions no unit carries a target effect in the hold, so the clock is not established for them by this check. They are kept, as the paper kept cells without a position effect.
Per-trial measures¶
For each kept unit and trial: spike counts in the last 800 ms of the hold, its first and last 400 ms, and the 500 ms centred on code 8; the smoothed rate of the paper's PSTH averaged over the hold window; and the spike times in the hold window (for CV2). Two populations are used. The paper has one neuron per session (Table 1 counts sessions; the Results give "N = 343 sessions" and 343 neurons), so the main population takes the first sorted unit of each kept session; every sorted unit is shown as a variant. Units without a spike in any hold window are left out.
def measures(unit_list, v_code=ppc.V_CODE, nv_code=ppc.NV_CODE):
rows = []
for k, u_, sp in unit_list:
t = kept[k]
r = dict(session=k, unit=u_)
for w, win in ppc.WINDOWS.items():
cnt = ppc.unit_counts(t, sp, win)
r[w] = ppc.cell_array(t, cnt / (win[1] - win[0]), v_code, nv_code)
r[w + "_count"] = ppc.cell_array(t, cnt, v_code, nv_code)
mv = ppc.unit_counts(t, sp, (-ppc.MOVE_HALF, ppc.MOVE_HALF), align="t8")
r["move"] = ppc.cell_array(t, mv / (2 * ppc.MOVE_HALF), v_code, nv_code)
r["psth"] = ppc.cell_array(t, ppc.psth_rate(t, sp, ppc.WINDOWS["hold"]), v_code, nv_code)
hold_sp = np.empty(len(t), dtype=object)
for i, t12 in enumerate(t.t12.values):
hold_sp[i] = ppc.spikes_in(sp, t12 - 0.8, t12)
arr = np.empty((2, 8, ppc.N_PER_CELL), dtype=object)
for ci, code in enumerate((v_code, nv_code)):
for ti, tg in enumerate(ppc.TARGETS):
idx = np.flatnonzero((t.cond.values == code) & (t.target.values == tg))
for j, i in enumerate(idx[:ppc.N_PER_CELL]):
arr[ci, ti, j] = hold_sp[i]
r["hold_spikes"] = arr
rows.append(r)
M = pd.DataFrame(rows)
active = M.hold_count.apply(lambda a: a.sum() > 0)
return M[active].reset_index(drop=True), M[~active][["session", "unit"]]
def add_anova(M, key="hold", prefix=""):
p = np.array([ppc.anova2(y) for y in M[key]])
M[prefix + "p_pos"], M[prefix + "p_vis"], M[prefix + "p_int"] = p[:, 0], p[:, 1], p[:, 2]
return M
M1, drop1 = measures(units_of(kept))
MA, dropA = measures(UNITS_ALL)
for M in (M1, MA):
add_anova(M)
print("main population (first unit per session):", len(M1), "units; left out, no hold spikes:", len(drop1))
print("all sorted units:", len(MA), "units; left out, no hold spikes:", len(dropA))
r = np.stack(M1.hold.values)
print("hold rate (spikes/s) of main population: range", r.min(), "to", r.max(), "; median of unit means",
round(float(np.median(r.mean(axis=(1, 2, 3)))), 2))
print("ANOVA left undefined (zero error variance):", int(M1.p_pos.isna().sum()), "main;", int(MA.p_pos.isna().sum()), "all")
main population (first unit per session): 359 units; left out, no hold spikes: 0 all sorted units: 483 units; left out, no hold spikes: 2 hold rate (spikes/s) of main population: range 0.0 to 135.0 ; median of unit means 5.75 ANOVA left undefined (zero error variance): 0 main; 0 all
Which sessions and neurons¶
The paper has 219 monkey X neurons, one per session; the data set has 359 usable monkey X sessions. The recording dates, the target geometry by month, and whether one neuron was recorded in several sessions of a day:
SUBMITTED = pd.Timestamp("2012-03-14") # paper, header: "Submitted 14 March 2012"
ks_ = sel[sel.status.str.startswith("kept")].copy()
ks_["date"] = pd.to_datetime(ks_.session.str.split("/").str[1], format="%m%d%y")
print("kept sessions by quarter of the recording date (folder name):")
print(ks_.groupby(ks_.date.dt.to_period("Q")).agg(sessions=("session", "size"), units=("n_units", "sum")).to_string())
print("kept sessions recorded on or after 14 March 2012 (paper submitted):", int((ks_.date >= SUBMITTED).sum()),
"; recording days:", ks_.date.nunique(), "; first", ks_.date.min().date(), "; last", ks_.date.max().date())
gk = geo.merge(ks_[["session", "date"]], on="session")
gm = gk.groupby(gk.date.dt.to_period("M"))
print("target geometry by month of recording, kept sessions (cm, means over sessions):")
print(gm[["x_right_minus_left", "y_top_minus_bottom", "y_middle_row", "z"]].mean().round(2)
.assign(sessions=gm.size()).to_string())
# Is one neuron recorded in several sessions of a day? Compare the hold tuning (mean rate per
# target, both conditions) of the first unit of consecutive sessions on a day with that of
# sessions on different days.
T_ = pd.DataFrame({"session": M1.session, "tuning": [r.mean(axis=(0, 2)) for r in M1.hold],
"rate": [r.mean() for r in M1.hold]})
T_["day"] = T_.session.str.split("/").str[1]
T_["num"] = T_.session.str.extract(r"_(\d+)\.mat$")[0].astype(float)
T_ = T_.sort_values(["day", "num"]).reset_index(drop=True)
def tuning_r(i, j):
return np.corrcoef(T_.tuning[i], T_.tuning[j])[0, 1]
same_day = [(i, i + 1) for i in range(len(T_) - 1) if T_.day[i] == T_.day[i + 1]]
rng_pop = np.random.default_rng(11)
other = []
while len(other) < 2000:
i, j = rng_pop.choice(len(T_), 2, replace=False)
if T_.day[i] != T_.day[j]:
other.append((i, j))
for lab, pairs in (("consecutive sessions, same day", same_day), ("sessions on different days", other)):
r_ = np.array([tuning_r(i, j) for i, j in pairs])
lr = np.array([abs(np.log((T_.rate[i] + 0.1) / (T_.rate[j] + 0.1))) for i, j in pairs])
print(f"{lab}: {len(pairs)} pairs; tuning correlation median {np.nanmedian(r_):.2f}, above 0.8 in "
f"{100 * np.nanmean(r_ > 0.8):.1f}%; median |log rate ratio| {np.median(lr):.2f}")
kept sessions by quarter of the recording date (folder name):
sessions units
date
2008Q4 46 50
2009Q1 163 223
2009Q2 57 72
2009Q3 73 111
2009Q4 20 29
kept sessions recorded on or after 14 March 2012 (paper submitted): 0 ; recording days: 92 ; first 2008-10-21 ; last 2009-11-16
target geometry by month of recording, kept sessions (cm, means over sessions):
x_right_minus_left y_top_minus_bottom y_middle_row z sessions
date
2008-10 8.82 6.96 -4.23 9.71 10
2008-11 9.41 7.43 -4.57 10.30 2
2008-12 8.63 8.17 -3.91 9.99 34
2009-01 8.76 7.38 -4.27 10.05 73
2009-02 9.03 7.30 -4.84 9.93 16
2009-03 9.10 7.08 -3.99 9.83 74
2009-04 9.52 7.27 -3.86 10.02 39
2009-05 9.70 7.35 -3.91 10.24 18
2009-07 9.44 7.73 -4.05 10.03 25
2009-08 9.40 7.14 -3.98 10.37 40
2009-09 10.10 7.75 -4.16 9.99 8
2009-10 10.22 7.28 -4.23 10.22 19
2009-11 9.77 7.76 -4.22 9.94 1
consecutive sessions, same day: 267 pairs; tuning correlation median 0.04, above 0.8 in 3.4%; median |log rate ratio| 0.80
sessions on different days: 2000 pairs; tuning correlation median -0.01, above 0.8 in 1.1%; median |log rate ratio| 1.03
The kept sessions were all recorded between October 2008 and November 2009, on 92 days, before the paper was submitted (14 March 2012). Their target geometry is the same in every month: monkey X's layout throughout, with no block of sessions in monkey B's square layout or at a depth near 14.5 cm. The paper has one neuron per session (Table 1 legend, "means +/- SD over 219 sessions for monkey X"; Results, Behavior, "both animals (N = 343 sessions)" against 343 neurons). Consecutive sessions on one day do not look like one neuron recorded again: their tuning correlation has a median of 0.04, against -0.01 for sessions on different days, and 3.4% of the same-day pairs correlate above 0.8, against 1.1%, so at most a handful could be repeats. The data set therefore holds about 140 more monkey X sessions than the paper's 219, the descriptor's 124 monkey B cells are not identifiable in it, and which sessions the paper used is not documented. All 359 are used. One unit is taken from each, as the paper has one neuron per session; which unit is an assumption (the first sorted, "a"), and all 483 sorted units are shown as a variant throughout.
behavior-mean-position-sessions¶
behavior-mean-position-sessions: Few sessions showed a significant difference in mean arm endpoint position between V and NV at a target; the average percentage across animals and targets was 6.9 +/- 1.5% (one-factor MANOVA, P < 0.05).
beh = []
for k, t in kept.items():
for tg in ppc.TARGETS:
xv = t[(t.target == tg) & (t.cond == ppc.V_CODE)][["x", "y", "z"]].values
xn = t[(t.target == tg) & (t.cond == ppc.NV_CODE)][["x", "y", "z"]].values
F, p = ppc.hotelling2(xv, xn)
row = dict(session=k, target=ppc.TARGET_DEG[tg], p_manova=p)
for ax, i in zip("xyz", range(3)):
row["p_levene_mean_" + ax] = stats.levene(xv[:, i], xn[:, i], center="mean").pvalue
row["p_levene_median_" + ax] = stats.levene(xv[:, i], xn[:, i], center="median").pvalue
beh.append(row)
beh = pd.DataFrame(beh)
print("session x target pairs:", len(beh), "; MANOVA undefined:", int(beh.p_manova.isna().sum()))
pt = beh.groupby("target").p_manova.apply(lambda p: 100 * np.mean(p < 0.05))
print("percentage of sessions with a significant V against NV difference, by target (monkey X):")
print(pt.round(1).to_string())
print(f"(a) mean of the 8 target percentages: {pt.mean():.2f} +/- {pt.std(ddof=1):.2f} (SD)")
print(f"(b) pooled over session and target pairs: {100 * np.mean(beh.p_manova < 0.05):.2f}")
print("expected:", expected("behavior-mean-position-sessions"))
session x target pairs: 2872 ; MANOVA undefined: 0
percentage of sessions with a significant V against NV difference, by target (monkey X):
target
0 20.3
45 17.3
90 15.0
135 22.8
180 14.5
225 9.2
270 12.8
315 17.0
(a) mean of the 8 target percentages: 16.12 +/- 4.27 (SD)
(b) pooled over session and target pairs: 16.12
expected: [('percentage of sessions with a significant V against NV difference in mean endpoint position, averaged across animals and targets', 6.9, 1.5)]
# Checks of the record's hand position (fields 19 to 21) asked for in verification.
K_ = pd.concat([t.assign(session=k) for k, t in kept.items()])
w_sd = K_.groupby(["session", "target", "cond"])[["x", "y", "z"]].std()
print("SD over a session's five trials at a target and condition (cm), median and IQR over",
len(w_sd), "session, target and condition cells:")
print(w_sd.quantile([0.25, 0.5, 0.75]).round(3).to_string())
sm_sd = K_.groupby(["session", "target", "cond"])[["x", "y", "z"]].mean().groupby(["target", "cond"]).std()
print("SD over sessions of the session means (cm), range over targets and conditions:",
{ax: (round(sm_sd[ax].min(), 2), round(sm_sd[ax].max(), 2)) for ax in "xyz"},
"; Table 1 (monkey X) runs from 0.50 to 1.28")
# Order of conditions within a session: interleaved or in blocks?
rows = []
for k in kept:
c_ = D["sessions"][k]["trials"]
c_ = c_[c_.completed & c_.cond.isin([4, 7])].sort_values("t0")
s_ = c_.cond.values
n1, n2 = int((s_ == 4).sum()), int((s_ == 7).sum())
rows.append(dict(session=k, runs=1 + int(np.sum(s_[1:] != s_[:-1])), expected=1 + 2 * n1 * n2 / (n1 + n2)))
RU = pd.DataFrame(rows)
print(f"runs of one condition among a session's completed trials: median {RU.runs.median():.0f} "
f"(expected under random order {RU.expected.median():.0f}); fewest {RU.runs.min()}, most {RU.runs.max()}")
for k in list(kept)[:3]:
c_ = D["sessions"][k]["trials"]
c_ = c_[c_.completed & c_.cond.isin([4, 7])].sort_values("t0")
print(" ", k, "first 40 completed trials:", "".join("V" if x == ppc.V_CODE else "N" for x in c_.cond.values[:40]))
# The MANOVA on these data with V and NV labels shuffled within each session and target.
rng_beh = np.random.default_rng(21)
p_null = []
for k, t in kept.items():
for tg in ppc.TARGETS:
X_ = t[t.target == tg][["x", "y", "z"]].values
lab_ = rng_beh.permutation(np.r_[np.zeros(5), np.ones(5)])
p_null.append(ppc.hotelling2(X_[lab_ == 0], X_[lab_ == 1])[1])
print(f"MANOVA with shuffled V/NV labels: {100 * np.nanmean(np.array(p_null) < 0.05):.1f}% of {len(p_null)} pairs significant (nominal 5%)")
dd = K_.groupby(["session", "target", "cond"])[["x", "y", "z"]].mean().unstack("cond")
diff_ = pd.DataFrame({ax: dd[(ax, ppc.NV_CODE)] - dd[(ax, ppc.V_CODE)] for ax in "xyz"})
print("NV minus V session mean position (cm), mean and SD over session and target pairs:",
diff_.mean().round(3).to_dict(), diff_.std().round(3).to_dict())
SD over a session's five trials at a target and condition (cm), median and IQR over 5744 session, target and condition cells:
x y z
0.25 0.213 0.207 0.139
0.50 0.294 0.288 0.190
0.75 0.387 0.381 0.252
SD over sessions of the session means (cm), range over targets and conditions: {'x': (np.float64(0.32), np.float64(0.67)), 'y': (np.float64(0.44), np.float64(0.6)), 'z': (np.float64(0.43), np.float64(0.52))} ; Table 1 (monkey X) runs from 0.50 to 1.28
runs of one condition among a session's completed trials: median 39 (expected under random order 41); fewest 23, most 74
data/010609/010609_1.mat first 40 completed trials: NNNNNVVNNNVVVNVVVVNVNNNNNVVNVVVVNVNVNNVN
data/010609/010609_2.mat first 40 completed trials: NVNVVVNVNNVNNNVNNVNVVNVNVNNNVNVVVVVNNNVN
data/010809/010809_1.mat first 40 completed trials: VVNNVNNVNVVNNVNNVNVNVNVVNNVVNVVVVVVNNVVV
MANOVA with shuffled V/NV labels: 5.7% of 2872 pairs significant (nominal 5%)
NV minus V session mean position (cm), mean and SD over session and target pairs: {'x': -0.048, 'y': -0.057, 'z': -0.008} {'x': 0.282, 'y': 0.306, 'z': 0.161}
The conditions are interleaved within each session (a median of 39 runs, against 41 for a random order), so slow drift cannot make V and NV differ. The MANOVA is calibrated on these data: with the labels shuffled it rejects in 5.7% of pairs. The 16% is therefore a property of the positions recorded under the real labels. Whether the record's position is the mean over the hold, as the paper's Fig. 2 legend describes, or one sample, the data do not say. Within a session the five trials at a target spread by about 0.2 to 0.4 cm (median SD 0.29, 0.29 and 0.19 cm in x, y, z), and the session means spread over sessions by 0.32 to 0.67 cm, about half of Table 1's SDs. No analog channel follows the hand (see eye-position-no-difference), so there is no position trace to check the record against.
Result: not reproduced. In monkey X, 16.1% of session and target pairs (2,872 pairs, 359 sessions) show a significant V against NV difference in endpoint position by the two-group MANOVA, both as the mean of the 8 target percentages (16.12 +/- 4.27) and pooled (16.12), against 6.9 +/- 1.5%. The test is calibrated on these data (5.7% with shuffled labels), and the conditions are interleaved within sessions, so neither the test nor drift explains the excess. Each trial has one endpoint in the data (the record's x, y, z), and whether it is the mean over the 800 ms hold, as in the paper, is not documented; monkey B is not in the data set.
behavior-variability-sessions¶
behavior-variability-sessions: Few sessions showed a significant difference in endpoint variability between V and NV; along the horizontal, vertical and depth axes the average percentages were 5 +/- 1.9%, 4.7 +/- 1.6% and 6 +/- 0.9% (Levene's test, P < 0.05).
rows = []
for centre in ("mean", "median"):
for ax in "xyz":
col = f"p_levene_{centre}_{ax}"
pt_ = beh.groupby("target")[col].apply(lambda p: 100 * np.mean(p < 0.05))
rows.append(dict(centre=centre, axis=ax, mean_of_targets=pt_.mean(), sd_of_targets=pt_.std(ddof=1),
pooled=100 * np.mean(beh[col] < 0.05)))
lev = pd.DataFrame(rows)
print(lev.round(2).to_string(index=False))
exp_ = {e[0].split(", ")[-1].split(" ")[0]: e for e in expected("behavior-variability-sessions")}
for centre in ("mean", "median"):
for avg in ("mean_of_targets", "pooled"):
ok = []
for ax, (q, v, tol) in zip("xyz", expected("behavior-variability-sessions")):
m = lev[(lev.centre == centre) & (lev.axis == ax)][avg].item()
ok.append(abs(m - v) <= tol)
print(f"centre {centre}, {avg}: within tolerance x, y, z = {ok}")
centre axis mean_of_targets sd_of_targets pooled mean x 8.08 1.51 8.08 mean y 8.08 1.09 8.08 mean z 7.00 1.58 7.00 median x 0.45 0.47 0.45 median y 0.66 0.45 0.66 median z 0.42 0.30 0.42 centre mean, mean_of_targets: within tolerance x, y, z = [False, False, False] centre mean, pooled: within tolerance x, y, z = [False, False, False] centre median, mean_of_targets: within tolerance x, y, z = [False, False, False] centre median, pooled: within tolerance x, y, z = [False, False, False]
Result: not reproduced. With Levene's test centred on the mean, 8.1%, 8.1% and 7.0% of pairs differ in x, y and z (paper 5 +/- 1.9, 4.7 +/- 1.6, 6 +/- 0.9): z is within tolerance, x and y are not. Centred on the median (Brown-Forsythe), 0.4 to 0.7%, none within. No reading puts all three axes within tolerance.
table1-endpoint-means and table1-endpoint-sd¶
table1-endpoint-means: Mean endpoint positions per target in the V and NV conditions are those of Table 1, and differ between conditions by at most 0.11 cm at every target, coordinate and animal.
table1-endpoint-sd: The across-session SDs of endpoint position per target are those of Table 1, about 0.5 to 1.3 cm for monkey X and 0.4 to 0.6 cm for monkey B.
Only monkey X's 48 values can be compared; the data set holds no monkey B session.
sm_ = pd.concat([t.assign(session=k) for k, t in kept.items()]).groupby(["session", "target", "cond"])[["x", "y", "z"]].mean().reset_index()
print("sessions:", sm_.session.nunique())
rows = []
exp_m = expected("table1-endpoint-means")[:48]
exp_s = expected("table1-endpoint-sd")[:48]
i = 0
for tg in ppc.TARGETS:
for ax in "xyz":
for code, lab in ((ppc.NV_CODE, "NV"), (ppc.V_CODE, "V")):
vals = sm_[(sm_.target == tg) & (sm_.cond == code)][ax]
q, v, tol = exp_m[i]
qs, vs, tols = exp_s[i]
assert f"{ppc.TARGET_DEG[tg]} degrees, {ax}, {lab}" in q
rows.append(dict(target=ppc.TARGET_DEG[tg], axis=ax, cond=lab, mean=vals.mean(), paper_mean=v, tol=tol,
sd=vals.std(ddof=1), paper_sd=vs, tol_sd=tols))
i += 1
T1 = pd.DataFrame(rows)
T1["in_tol"] = (T1["mean"] - T1.paper_mean).abs() <= T1.tol
off = T1.assign(d=T1["mean"] - T1.paper_mean).groupby("axis").d.mean()
T1["mean_offset_removed"] = T1["mean"] - T1.axis.map(off)
T1["in_tol_offset_removed"] = (T1.mean_offset_removed - T1.paper_mean).abs() <= T1.tol
print(T1[["target", "axis", "cond", "mean", "paper_mean", "tol", "in_tol", "mean_offset_removed", "in_tol_offset_removed"]].round(2).to_string(index=False))
print("mean offset per axis (data minus Table 1, cm):", off.round(3).to_dict())
print(f"within tolerance: {T1.in_tol.mean() * 100:.1f}% of 48; after removing the offset: {T1.in_tol_offset_removed.mean() * 100:.1f}%")
dv = T1.pivot_table(index=["target", "axis"], columns="cond", values="mean")
d = (dv["V"] - dv["NV"]).abs()
print(f"largest |V - NV| difference of the means: {d.max():.3f} cm (bound 0.11 + 10% = 0.121); at {d.idxmax()}")
dvf = T1.pivot_table(index=["target", "axis"], columns="cond", values="mean")
print("under the other code mapping the |V - NV| differences are the same (absolute values).")
sessions: 359
target axis cond mean paper_mean tol in_tol mean_offset_removed in_tol_offset_removed
0 x NV 4.72 4.84 0.89 True 4.82 True
0 x V 4.87 4.95 0.92 True 4.97 True
0 y NV -4.08 -3.81 0.73 True -3.91 True
0 y V -3.99 -3.81 0.68 True -3.81 True
0 z NV 9.79 9.49 1.19 True 9.53 True
0 z V 9.77 9.52 1.19 True 9.52 True
45 x NV 4.63 4.64 0.81 True 4.73 True
45 x V 4.64 4.64 0.83 True 4.74 True
45 y NV -0.47 -0.24 0.59 True -0.30 True
45 y V -0.39 -0.24 0.53 True -0.22 True
45 z NV 9.81 9.54 1.19 True 9.56 True
45 z V 9.82 9.56 1.19 True 9.56 True
90 x NV 0.06 0.09 0.52 True 0.16 True
90 x V 0.14 0.08 0.50 True 0.24 True
90 y NV -0.58 -0.48 0.55 True -0.41 True
90 y V -0.46 -0.45 0.53 True -0.28 True
90 z NV 9.82 9.52 1.18 True 9.57 True
90 z V 9.84 9.55 1.18 True 9.58 True
135 x NV -4.47 -4.37 0.75 True -4.37 True
135 x V -4.39 -4.38 0.75 True -4.29 True
135 y NV -0.49 -0.36 0.60 True -0.31 True
135 y V -0.34 -0.34 0.59 True -0.16 True
135 z NV 10.16 9.92 1.23 True 9.91 True
135 z V 10.16 9.96 1.24 True 9.90 True
180 x NV -4.63 -4.42 0.98 True -4.53 True
180 x V -4.66 -4.51 1.01 True -4.56 True
180 y NV -4.18 -4.00 0.76 True -4.01 True
180 y V -4.12 -4.03 0.73 True -3.94 True
180 z NV 10.20 9.94 1.24 True 9.95 True
180 z V 10.23 10.03 1.25 True 9.97 True
225 x NV -4.41 -4.19 0.70 True -4.31 True
225 x V -4.44 -4.26 0.73 True -4.34 True
225 y NV -7.71 -7.51 1.04 True -7.54 True
225 y V -7.73 -7.52 1.04 True -7.56 True
225 z NV 10.36 10.11 1.27 True 10.10 True
225 z V 10.39 10.19 1.28 True 10.14 True
270 x NV -0.04 0.12 0.54 True 0.06 True
270 x V -0.02 0.07 0.51 True 0.08 True
270 y NV -7.93 -7.69 1.06 True -7.76 True
270 y V -7.96 -7.74 1.06 True -7.79 True
270 z NV 10.02 9.77 1.22 True 9.77 True
270 z V 10.05 9.83 1.22 True 9.79 True
315 x NV 4.58 4.76 0.94 True 4.68 True
315 x V 4.71 4.83 0.95 True 4.81 True
315 y NV -7.80 -7.52 1.06 True -7.63 True
315 y V -7.79 -7.51 1.06 True -7.62 True
315 z NV 10.05 9.72 1.22 True 9.80 True
315 z V 10.03 9.77 1.22 True 9.78 True
mean offset per axis (data minus Table 1, cm): {'x': -0.1, 'y': -0.172, 'z': 0.255}
within tolerance: 100.0% of 48; after removing the offset: 100.0%
largest |V - NV| difference of the means: 0.150 cm (bound 0.11 + 10% = 0.121); at (np.int64(135), 'y')
under the other code mapping the |V - NV| differences are the same (absolute values).
Result: partially reproduced. All 48 of monkey X's means are within the Table 1 SDs (100%, also after removing the mean offsets of -0.10, -0.17 and +0.26 cm), but the largest V minus NV difference of the means is 0.150 cm (135 degrees, y), above the 0.121 cm bound. Monkey B's 48 values cannot be tested; the data set holds 359 usable monkey X sessions against the paper's 219.
table1-endpoint-sd: The across-session SDs of endpoint position per target are those of Table 1, about 0.5 to 1.3 cm for monkey X and 0.4 to 0.6 cm for monkey B.
T1["sd_in_tol"] = (T1.sd - T1.paper_sd).abs() <= T1.tol_sd
print(T1[["target", "axis", "cond", "sd", "paper_sd", "tol_sd", "sd_in_tol"]].round(3).to_string(index=False))
tr_sd = pd.concat([t.assign(session=k) for k, t in kept.items()]).groupby(["target", "cond"])[["x", "y", "z"]].std()
T1["sd_trials"] = [tr_sd.loc[(tg, {"V": ppc.V_CODE, "NV": ppc.NV_CODE}[c_]), ax] for tg, c_, ax in
zip([{v: k for k, v in ppc.TARGET_DEG.items()}[d_] for d_ in T1.target], T1.cond, T1.axis)]
print(f"variant, SD over all trials pooled across sessions: {T1.sd_trials.min():.2f} to {T1.sd_trials.max():.2f} cm; "
f"within 10% of Table 1: {100 * np.mean((T1.sd_trials - T1.paper_sd).abs() <= T1.tol_sd):.1f}%")
print(f"SDs within 10%: {T1.sd_in_tol.mean() * 100:.1f}% of 48; range of SDs {T1.sd.min():.2f} to {T1.sd.max():.2f} cm "
f"(Table 1, monkey X: {T1.paper_sd.min():.2f} to {T1.paper_sd.max():.2f}); median ratio data / paper {np.median(T1.sd / T1.paper_sd):.2f}")
target axis cond sd paper_sd tol_sd sd_in_tol
0 x NV 0.525 0.89 0.089 False
0 x V 0.515 0.92 0.092 False
0 y NV 0.552 0.73 0.073 False
0 y V 0.460 0.68 0.068 False
0 z NV 0.514 1.19 0.119 False
0 z V 0.475 1.19 0.119 False
45 x NV 0.443 0.81 0.081 False
45 x V 0.414 0.83 0.083 False
45 y NV 0.604 0.59 0.059 True
45 y V 0.501 0.53 0.053 True
45 z NV 0.485 1.19 0.119 False
45 z V 0.444 1.19 0.119 False
90 x NV 0.316 0.52 0.052 False
90 x V 0.335 0.50 0.050 False
90 y NV 0.527 0.55 0.055 True
90 y V 0.440 0.53 0.053 False
90 z NV 0.523 1.18 0.118 False
90 z V 0.492 1.18 0.118 False
135 x NV 0.476 0.75 0.075 False
135 x V 0.520 0.75 0.075 False
135 y NV 0.557 0.60 0.060 True
135 y V 0.491 0.59 0.059 False
135 z NV 0.443 1.23 0.123 False
135 z V 0.431 1.24 0.124 False
180 x NV 0.494 0.98 0.098 False
180 x V 0.510 1.01 0.101 False
180 y NV 0.576 0.76 0.076 False
180 y V 0.535 0.73 0.073 False
180 z NV 0.458 1.24 0.124 False
180 z V 0.449 1.25 0.125 False
225 x NV 0.464 0.70 0.070 False
225 x V 0.480 0.73 0.073 False
225 y NV 0.573 1.04 0.104 False
225 y V 0.532 1.04 0.104 False
225 z NV 0.485 1.27 0.127 False
225 z V 0.468 1.28 0.128 False
270 x NV 0.423 0.54 0.054 False
270 x V 0.415 0.51 0.051 False
270 y NV 0.569 1.06 0.106 False
270 y V 0.524 1.06 0.106 False
270 z NV 0.478 1.22 0.122 False
270 z V 0.458 1.22 0.122 False
315 x NV 0.630 0.94 0.094 False
315 x V 0.666 0.95 0.095 False
315 y NV 0.599 1.06 0.106 False
315 y V 0.581 1.06 0.106 False
315 z NV 0.525 1.22 0.122 False
315 z V 0.484 1.22 0.122 False
variant, SD over all trials pooled across sessions: 0.41 to 0.73 cm; within 10% of Table 1: 14.6%
SDs within 10%: 8.3% of 48; range of SDs 0.32 to 0.67 cm (Table 1, monkey X: 0.50 to 1.28); median ratio data / paper 0.55
Result: not reproduced. 8.3% of monkey X's 48 SDs over sessions are within 10% of Table 1; the SDs run from 0.32 to 0.67 cm against 0.50 to 1.28 cm, a median of 0.55 times the paper's. The SD over all trials (a variant) runs from 0.41 to 0.73 cm, 14.6% within.
fig3-example-neuron¶
fig3-example-neuron: An example neuron fired most when the hand was held at the lower left target (225 degrees) in both V and NV; its hold-period rate showed a main effect of position (P < 0.05) but no effect of vision (P = 0.52) and no interaction (P = 0.64).
def example_search(M):
rows = []
for _, r in M.iterrows():
m = r.hold.mean(axis=2)
rows.append(dict(session=r.session, unit=r.unit, peak_V=ppc.TARGETS[int(np.argmax(m[0]))],
peak_NV=ppc.TARGETS[int(np.argmax(m[1]))], p_pos=r.p_pos, p_vis=r.p_vis, p_int=r.p_int))
E = pd.DataFrame(rows)
E["peak225_both"] = (E.peak_V == 44) & (E.peak_NV == 44)
E["dist"] = np.hypot((E.p_vis - 0.52) / 0.052, (E.p_int - 0.64) / 0.064)
E["match"] = E.peak225_both & (E.p_pos < 0.05) & ((E.p_vis - 0.52).abs() <= 0.052) & ((E.p_int - 0.64).abs() <= 0.064)
return E
for lab, M in (("main", M1), ("all units", MA)):
E = example_search(M)
print(f"{lab}: units with the peak at 225 deg in V and NV and a position effect:",
int((E.peak225_both & (E.p_pos < 0.05)).sum()), "; candidates matching all:", int(E.match.sum()))
print(E[E.match].round(3).to_string(index=False) if E.match.any() else
E[E.peak225_both & (E.p_pos < 0.05)].sort_values("dist").head(3).round(3).to_string(index=False))
main: units with the peak at 225 deg in V and NV and a position effect: 8 ; candidates matching all: 0
session unit peak_V peak_NV p_pos p_vis p_int peak225_both dist match
data/073009/073009_4.mat chan1a 44 44 0.000 0.364 0.537 True 3.400 False
data/031909/031909_3.mat chan1a 44 44 0.000 0.372 0.841 True 4.231 False
data/102408/102408_2.mat chan1a 44 44 0.005 0.378 0.347 True 5.338 False
all units: units with the peak at 225 deg in V and NV and a position effect: 10 ; candidates matching all: 0
session unit peak_V peak_NV p_pos p_vis p_int peak225_both dist match
data/073009/073009_4.mat chan1a 44 44 0.000 0.364 0.537 True 3.400 False
data/031909/031909_3.mat chan1a 44 44 0.000 0.372 0.841 True 4.231 False
data/102408/102408_2.mat chan1a 44 44 0.005 0.378 0.347 True 5.338 False
Result: not reproduced. Of the 359 units, 8 peak at 225 degrees in both conditions with a position effect (10 of 483 among all units), and none has vision and interaction P values within 0.52 +/- 0.052 and 0.64 +/- 0.064; the closest (073009_4, chan1a) has P = 0.364 and 0.537. The paper does not identify the neuron, which may be from monkey B, absent here.
movement-epoch-tuning¶
movement-epoch-tuning: In a 500 ms epoch centred on movement onset, 41% (139 of 343) of neurons were modulated by the movement vector (main and/or interaction effects, ANOVA, P < 0.05).
Movement onset is read as code 8 (reading (a) of the criterion, an event code; see the data check). No continuous arm position is in the data set, so reading (b) cannot be run: the record gives one position per trial.
for lab, M in (("main", M1), ("all units", MA)):
p = np.array([ppc.anova2(y) for y in M.move])
sig = (p[:, 0] < 0.05) | (p[:, 2] < 0.05)
n = len(M)
print(f"{lab}: {sig.sum()} of {n} units ({100 * sig.mean():.1f}%) with a target main effect or interaction; "
f"scaled to 343: {343 * sig.mean():.0f} (paper 139, 41%)")
# sensitivity: window centred on the target-code event (end of the reach) and on code 3
for lab, al in (("centred on target acquired", "t_target"), ("centred on code 3", "t3")):
sig = []
for k, u_, sp in units_of(kept):
t = kept[k]
cnt = ppc.unit_counts(t, sp, (-0.25, 0.25), align=al)
y = ppc.cell_array(t, cnt / 0.5)
if y.sum() == 0:
continue
p = ppc.anova2(y)
sig.append((p[0] < 0.05) | (p[2] < 0.05))
print(f"variant, 500 ms {lab}: {100 * np.mean(sig):.1f}% of {len(sig)}")
main: 187 of 359 units (52.1%) with a target main effect or interaction; scaled to 343: 179 (paper 139, 41%) all units: 241 of 483 units (49.9%) with a target main effect or interaction; scaled to 343: 171 (paper 139, 41%)
variant, 500 ms centred on target acquired: 65.5% of 359
variant, 500 ms centred on code 3: 6.1% of 358
Result: not reproduced. With movement onset read as code 8, 187 of 359 units (52.1%; 179 when scaled to 343) have a target main effect or interaction in the 500 ms around it, against 139 +/- 13.9 (41%); all units give 49.9% (171). The result rests on reading code 8 as movement onset; a window centred on the target code event gives 65.5%, one on code 3 6.1%.
hold-position-main-effect, hold-vision-main-effect, hold-interaction¶
hold-position-main-effect: In the 800 ms static holding period, 39% (135 of 343) of neurons showed a significant main effect of position.
hold-vision-main-effect: Only 13% (44 of 343) of neurons showed a main effect of the visual conditions in the holding period.
hold-interaction: Interaction effects of position and vision were found in 9% (27 of 343) of neurons.
def effect_table(M, prefix=""):
pp, pv, pi = M[prefix + "p_pos"], M[prefix + "p_vis"], M[prefix + "p_int"]
n = len(M)
return dict(n=n, position=int((pp < 0.05).sum()), vision=int((pv < 0.05).sum()), interaction=int((pi < 0.05).sum()))
for lab, M, key in (("main, spike count rate", M1, "hold"), ("main, smoothed PSTH rate", M1, "psth"),
("all units, spike count rate", MA, "hold")):
Mx = add_anova(M.copy(), key, "x_")
e = effect_table(Mx, "x_")
n = e["n"]
print(f"{lab}: n = {n}; position {e['position']} ({100 * e['position'] / n:.1f}%), vision {e['vision']} "
f"({100 * e['vision'] / n:.1f}%), interaction {e['interaction']} ({100 * e['interaction'] / n:.1f}%); "
f"scaled to 343: {343 * e['position'] / n:.0f}, {343 * e['vision'] / n:.0f}, {343 * e['interaction'] / n:.0f}")
print("paper: position 135/343 (39.4%), vision 44/343 (12.8%), interaction 27/343 (7.9%) or 9% (31)")
print("false positive rate of the ANOVA under shuffled labels (main population, 1 shuffle per unit):")
rng = np.random.default_rng(1)
fp = []
for y in M1.hold:
flat = y.reshape(-1).copy()
rng.shuffle(flat)
fp.append(ppc.anova2(flat.reshape(y.shape)))
fp = np.array(fp)
print(" position, vision, interaction:", np.round(np.nanmean(fp < 0.05, axis=0) * 100, 1), "%")
main, spike count rate: n = 359; position 141 (39.3%), vision 49 (13.6%), interaction 27 (7.5%); scaled to 343: 135, 47, 26 main, smoothed PSTH rate: n = 359; position 142 (39.6%), vision 50 (13.9%), interaction 27 (7.5%); scaled to 343: 136, 48, 26 all units, spike count rate: n = 483; position 176 (36.4%), vision 69 (14.3%), interaction 35 (7.2%); scaled to 343: 125, 49, 25 paper: position 135/343 (39.4%), vision 44/343 (12.8%), interaction 27/343 (7.9%) or 9% (31) false positive rate of the ANOVA under shuffled labels (main population, 1 shuffle per unit):
position, vision, interaction: [4.2 4.7 3.3] %
Result: reproduced. 141 of 359 units (39.3%; 135 scaled to 343) have a position main effect in the last 800 ms of the hold, against 135 of 343 (39.4%). The smoothed PSTH rate gives 142 (39.6%) and all 483 units 36.4% (125 scaled), both within tolerance. Shuffled labels give 4.2%.
Result: reproduced (resting on an assumption). 49 of 359 units (13.6%; 47 scaled to 343) have a vision main effect, against 44 +/- 4.4, and fewer than the 141 with a position effect. All 483 units give 14.3% (49 scaled), just above the bound of 48.4, so the outcome rests on taking one unit per session (the first sorted). The count does not depend on which code is V.
Result: reproduced. 27 of 359 units (7.5%; 26 scaled to 343) have an interaction, within reading (a), 27 +/- 2.7, and not reading (b), 31 +/- 3.1. All units give 7.2% (25 scaled).
hold-subepochs¶
hold-subepochs: Similar percentages were found when the first 400 ms and the last 400 ms of the hold were analyzed separately, 31%, 9% and 5% and 29%, 10% and 4% for position main effect, vision main effect and interaction.
exp_sub = [e[1:] for e in expected("hold-subepochs")]
for lab, M in (("main", M1), ("all units", MA)):
vals = []
for w in ("first400", "last400"):
Mx = add_anova(M.copy(), w, "x_")
e = effect_table(Mx, "x_")
vals += [100 * e["position"] / e["n"], 100 * e["vision"] / e["n"], 100 * e["interaction"] / e["n"]]
ok = [abs(v - ev) <= tol for v, (ev, tol) in zip(vals, exp_sub)]
print(f"{lab}: first 400 ms {np.round(vals[:3], 1)}%, last 400 ms {np.round(vals[3:], 1)}%; within tolerance: {sum(ok)} of 6 {ok}")
print("paper: 31/9/5% and 29/10/4%")
main: first 400 ms [35.7 11.4 7. ]%, last 400 ms [28.7 13.6 5. ]%; within tolerance: 1 of 6 [False, False, False, True, False, False] all units: first 400 ms [31.5 11.2 6.2]%, last 400 ms [27.1 13.3 4.3]%; within tolerance: 3 of 6 [True, False, False, True, False, True] paper: 31/9/5% and 29/10/4%
# Variant (verification round 1): hold windows starting no earlier than 250 ms after code 10
# (ppc.late_windows); rates, as the windows differ in length between trials.
def late_measures(M):
out = {"hold": [], "first": [], "last": []}
for r in M.itertuples():
t = kept[r.session]
sp = np.sort(D["sessions"][r.session]["units"][r.unit])
s0, mid, e0 = ppc.late_windows(t)
for key, (a_, b_) in (("hold", (s0, e0)), ("first", (s0, mid)), ("last", (mid, e0))):
dur = b_ - a_
cnt = np.searchsorted(sp, b_) - np.searchsorted(sp, a_)
out[key].append(ppc.cell_array(t, np.where(dur > 0, cnt / np.where(dur > 0, dur, 1), np.nan)))
return out
LATE = {lab: late_measures(M) for lab, M in (("main", M1), ("all units", MA))}
s0, mid, e0 = ppc.late_windows(pd.concat(kept.values()))
print(f"first part of the variant window: median {np.median(mid - s0):.3f} s, shortest {np.min(mid - s0):.3f} s; "
f"trials where it is shorter than 400 ms: {100 * np.mean(mid - s0 < 0.3999):.1f}%")
first part of the variant window: median 0.400 s, shortest 0.182 s; trials where it is shorter than 400 ms: 11.6%
for lab, M in (("main", M1), ("all units", MA)):
vals = []
for key in ("first", "last"):
p = np.array([ppc.anova2(y) for y in LATE[lab][key]])
ok = ~np.isnan(p[:, 0])
vals += [100 * np.mean(p[ok, i] < 0.05) for i in range(3)]
within = [abs(v - e[0]) <= e[1] for v, e in zip(vals, exp_sub)]
print(f"variant, window from 250 ms after code 10, {lab}: first part {vals[0]:.1f}/{vals[1]:.1f}/{vals[2]:.1f}%, "
f"last 400 ms {vals[3]:.1f}/{vals[4]:.1f}/{vals[5]:.1f}%; within tolerance {sum(within)} of 6")
variant, window from 250 ms after code 10, main: first part 35.7/10.9/7.5%, last 400 ms 28.8/13.7/5.0%; within tolerance 1 of 6 variant, window from 250 ms after code 10, all units: first part 31.7/10.6/6.6%, last 400 ms 27.2/13.3/4.4%; within tolerance 3 of 6
Result: not reproduced (resting on an assumption). In the first and last 400 ms, 35.7/11.4/7.0% and 28.7/13.6/5.0% of the 359 units have position, vision and interaction effects, against 31/9/5% and 29/10/4%: 1 of 6 within tolerance. All 483 units give 3 of 6 (31.5/11.2/6.2% and 27.1/13.3/4.3%), which would be partial, so the outcome rests on taking one unit per session. Starting the window at least 250 ms after code 10 (variant) gives 35.7/10.9/7.5% and 28.8/13.7/5.0% (1 of 6) and, for all units, 3 of 6: the possible inclusion of a saccade at the start of the window does not explain the difference. The last 400 ms position percentage is within tolerance and the first 400 ms one (35.7%) is above it; the vision and interaction percentages are higher than the paper's.
hold-overall-effects¶
hold-overall-effects: Over the full hold, 44% of neurons showed some effect of position (main and/or interaction), 19% some effect of vision, and 11% effects of both position and vision.
def groups(M):
pp, pv, pi = M.p_pos < 0.05, M.p_vis < 0.05, M.p_int < 0.05
return dict(any_position=pp | pi, any_vision=pv | pi, both=(pp & pv) | pi,
position_only=pp & ~pv & ~pi, position_vision=(pp & pv) | pi, vision_only=pv & ~pp & ~pi,
none=~pp & ~pv & ~pi)
for lab, M in (("main", M1), ("all units", MA)):
g = groups(M)
print(f"{lab} (n = {len(M)}): any position {100 * g['any_position'].mean():.1f}%, any vision {100 * g['any_vision'].mean():.1f}%, "
f"both {100 * g['both'].mean():.1f}%")
print("paper: 44%, 19%, 11%")
main (n = 359): any position 40.4%, any vision 18.7%, both 13.1% all units (n = 483): any position 38.3%, any vision 18.8%, both 12.2% paper: 44%, 19%, 11%
Result: partially reproduced. 40.4% of units show some position effect (44 +/- 4.4) and 18.7% some vision effect (19 +/- 1.9), both within tolerance; 13.1% show both, above 11 +/- 1.1. All units give 38.3%, 18.8% and 12.2%.
correlation-endpoint-datasets¶
correlation-endpoint-datasets: Correlations between V and NV responses were the same where mean endpoint positions differed between conditions (r = 0.9301) and where they did not (r = 0.9281), so firing rate differences did not reflect endpoint differences.
sigpair = set(map(tuple, beh[beh.p_manova < 0.05][["session", "target"]].values))
def corr_sets(M, trial_level=False):
d1, d2 = [], []
for _, r in M.iterrows():
for ti, tg in enumerate(ppc.TARGETS):
if trial_level:
pairs = list(zip(r.hold[0, ti], r.hold[1, ti]))
else:
pairs = [(r.hold[0, ti].mean(), r.hold[1, ti].mean())]
(d1 if (r.session, ppc.TARGET_DEG[tg]) in sigpair else d2).extend(pairs)
return np.array(d1), np.array(d2)
def perm_r(d1, d2, n_perm=1000, seed=0):
rng = np.random.default_rng(seed)
obs = stats.spearmanr(d1[:, 0], d1[:, 1])[0] - stats.spearmanr(d2[:, 0], d2[:, 1])[0]
pool = np.vstack([d1, d2])
diffs = np.empty(n_perm)
for i in range(n_perm):
idx = rng.permutation(len(pool))
a_, b_ = pool[idx[:len(d1)]], pool[idx[len(d1):]]
diffs[i] = stats.spearmanr(a_[:, 0], a_[:, 1])[0] - stats.spearmanr(b_[:, 0], b_[:, 1])[0]
return obs, np.mean(np.abs(diffs) >= abs(obs))
for lab, M in (("main", M1), ("all units", MA)):
for tl in (False, True):
d1, d2 = corr_sets(M, tl)
r1, r2 = stats.spearmanr(d1[:, 0], d1[:, 1])[0], stats.spearmanr(d2[:, 0], d2[:, 1])[0]
obs, p = perm_r(d1, d2)
print(f"{lab}, reading {'(b) trials' if tl else '(a) means'}: data set 1 r = {r1:.4f} (n = {len(d1)}), "
f"data set 2 r = {r2:.4f} (n = {len(d2)}); difference {obs:.4f}, permutation P = {p:.3f}")
d1, d2 = corr_sets(M1)
allr = stats.spearmanr(np.vstack([d1, d2])[:, 0], np.vstack([d1, d2])[:, 1])[0]
print(f"all responses (main, means): r = {allr:.4f}")
main, reading (a) means: data set 1 r = 0.9237 (n = 463), data set 2 r = 0.9154 (n = 2409); difference 0.0083, permutation P = 0.469
main, reading (b) trials: data set 1 r = 0.7941 (n = 2315), data set 2 r = 0.7674 (n = 12045); difference 0.0267, permutation P = 0.025
all units, reading (a) means: data set 1 r = 0.9222 (n = 676), data set 2 r = 0.9109 (n = 3188); difference 0.0113, permutation P = 0.267
all units, reading (b) trials: data set 1 r = 0.7973 (n = 3380), data set 2 r = 0.7625 (n = 15940); difference 0.0348, permutation P = 0.001 all responses (main, means): r = 0.9171
Result: reproduced (resting on an assumption). With each cell's V and NV mean rates at a target as the pair (reading (a)), r is 0.9237 where endpoints differed (463 pairs) and 0.9154 where they did not (2,409), both within 0.093 of the paper's, and the permutation test finds no difference (P = 0.469). With single trials as pairs (reading (b)), r is 0.794 and 0.767, outside tolerance, and the difference is significant (P = 0.025). Reading (a) is adopted, as its r values are of the paper's size; all units give the same pattern (P = 0.267 and 0.001).
fig4-indx1-negative and fig4-indx1-means¶
fig4-indx1-negative: For most cells INDX1 was negative (activity lower with vision than without), with 84%, 77%, 85% and 84% negative among all cells, Position Only, Position/Vision and Vision Only cells (338, 110, 38 and 27 cells after outlier removal).
fig4-indx1-means: Mean INDX1 was least negative for Position Only cells (-13%) and most negative for Position/Vision cells (-31%).
def indexes(M):
out = []
for _, r in M.iterrows():
m = r.hold.mean(axis=2)
pnv, pv = int(np.argmax(m[1])), int(np.argmax(m[0]))
nv = m[1, pnv]
out.append(dict(pnv=pnv, pv=pv,
indx1=np.nan if nv == 0 else (m[0, pnv] - nv) / nv * 100,
indx2=np.nan if nv == 0 else (m[0, pv] - nv) / nv * 100))
return pd.DataFrame(out, index=M.index)
def fences(x):
q1, q3 = np.nanpercentile(x, [25, 75])
return q1 - 1.5 * (q3 - q1), q3 + 1.5 * (q3 - q1), q3 - q1
def outliers(M, col, reading):
x = M[col]
g = groups(M)
if reading == "a":
lo, hi, _ = fences(x)
return (x < lo) | (x > hi)
if reading == "b":
o = pd.Series(False, index=M.index)
for gname in ("position_only", "position_vision", "vision_only", "none"):
sub = x[g[gname]]
lo, hi, _ = fences(sub)
o[g[gname]] = (sub < lo) | (sub > hi)
return o
if reading == "c":
_, _, iqr = fences(x)
return x > 1.5 * iqr
def fig4(M, col="indx1", reading="a", outlier_col=None):
I = indexes(M)
M = M.join(I)
o = outliers(M, outlier_col or col, reading) | M[col].isna()
g = groups(M)
res = {}
for gname, mask in (("all", pd.Series(True, index=M.index)), ("position_only", g["position_only"]),
("position_vision", g["position_vision"]), ("vision_only", g["vision_only"])):
x = M[col][mask & ~o]
res[gname] = dict(n=len(x), neg=100 * np.mean(x < 0), mean=x.mean(), removed=int((mask & o).sum()))
return pd.DataFrame(res).T, M, o
for lab, M in (("main", M1), ("all units", MA)):
for reading in ("a", "b", "c"):
R, _, o = fig4(M, "indx1", reading)
print(f"{lab}, outlier reading ({reading}): removed {int(o.sum())}")
print(R.round(1).to_string())
print("paper: negative 84/77/85/84%; n 338/110/38/27; mean INDX1 Position Only -13%, Position/Vision -31%")
print("under the other code mapping (V = 7), main, reading (a):")
M1f = M1.copy()
M1f["hold"] = [y[::-1] for y in M1.hold]
R, _, _ = fig4(M1f, "indx1", "a")
print(R.round(1).to_string())
main, outlier reading (a): removed 3
n neg mean removed
all 356.0 77.8 -24.9 3.0
position_only 98.0 68.4 -12.0 0.0
position_vision 44.0 75.0 -24.2 3.0
vision_only 20.0 75.0 -23.5 0.0
main, outlier reading (b): removed 11
n neg mean removed
all 348.0 78.4 -25.2 11.0
position_only 90.0 70.0 -12.0 8.0
position_vision 44.0 75.0 -24.2 3.0
vision_only 20.0 75.0 -23.5 0.0
main, outlier reading (c): removed 3
n neg mean removed
all 356.0 77.8 -24.9 3.0
position_only 98.0 68.4 -12.0 0.0
position_vision 44.0 75.0 -24.2 3.0
vision_only 20.0 75.0 -23.5 0.0
all units, outlier reading (a): removed 4
n neg mean removed
all 479.0 81.4 -27.3 4.0
position_only 126.0 71.4 -13.7 0.0
position_vision 56.0 76.8 -26.2 3.0
vision_only 32.0 81.2 -27.6 0.0
all units, outlier reading (b): removed 13
n neg mean removed
all 470.0 81.9 -27.4 13.0
position_only 117.0 72.6 -13.0 9.0
position_vision 56.0 76.8 -26.2 3.0
vision_only 32.0 81.2 -27.6 0.0
all units, outlier reading (c): removed 4
n neg mean removed
all 479.0 81.4 -27.3 4.0
position_only 126.0 71.4 -13.7 0.0
position_vision 56.0 76.8 -26.2 3.0
vision_only 32.0 81.2 -27.6 0.0
paper: negative 84/77/85/84%; n 338/110/38/27; mean INDX1 Position Only -13%, Position/Vision -31%
under the other code mapping (V = 7), main, reading (a):
n neg mean removed
all 348.0 80.5 -28.2 11.0
position_only 94.0 72.3 -14.2 4.0
position_vision 43.0 74.4 -27.1 4.0
vision_only 19.0 73.7 -33.5 1.0
Result: partially reproduced (resting on an assumption). After removing outliers (reading (a), 3 cells), INDX1 is negative in 77.8% of all cells, 68.4% of Position Only, 75.0% of Position/Vision and 75.0% of Vision Only cells (paper 84, 77, 85, 84%): only the first is within tolerance, and the others are 0.6 to 1.5 points below it. Reading (c) gives the same values; reading (b) gives 78.4, 70.0, 75.0 and 75.0%, again only the first within tolerance. Group sizes are 356, 98, 44 and 20 (paper 338, 110, 38, 27). Among all 483 units the four percentages (81.4, 71.4, 76.8, 81.2%) are within tolerance, so the outcome rests on taking one unit per session. INDX1 is mostly negative also under the other code mapping (80.5% of all cells).
fig4-indx1-means: Mean INDX1 was least negative for Position Only cells (-13%) and most negative for Position/Vision cells (-31%).
Result: partially reproduced. Mean INDX1 is -12.0% for Position Only cells (paper -13 +/- 1.3, within) and -24.2% for Position/Vision cells (paper -31 +/- 3.1, not within), and the most negative of the four populations is all cells (-24.9%), not Position/Vision. Position Only is the least negative, as in the paper. Outlier readings (b) and (c) and all units give the same pattern.
indx1-tuning-shift¶
indx1-tuning-shift: Among Position/Vision cells, those with their maximal response at the same or an adjacent location in the two conditions (22 of 38, 58%) had a mean INDX1 of -24%, and the others a more negative mean of -40%.
grid = {56: (1, 0), 66: (1, 1), 65: (0, 1), 64: (-1, 1), 54: (-1, 0), 44: (-1, -1), 45: (0, -1), 46: (1, -1)}
for lab, M in (("main", M1), ("all units", MA)):
for reading in ("a", "b", "c"):
_, Mi, o = fig4(M, "indx1", reading)
pvc = groups(Mi)["position_vision"] & ~o
sub = Mi[pvc]
ring = ((sub.pv - sub.pnv) % 8).isin([0, 1, 7])
gpos = lambda i: np.array(grid[ppc.TARGETS[i]])
gridadj = np.array([np.max(np.abs(gpos(a_) - gpos(b_))) <= 1 for a_, b_ in zip(sub.pv, sub.pnv)])
for adj_lab, adj in (("ring", ring.values), ("grid", gridadj)):
print(f"{lab}, outliers ({reading}), adjacency {adj_lab}: {adj.sum()} of {len(sub)} same or adjacent, "
f"mean INDX1 {sub.indx1[adj].mean():.1f}% vs others {sub.indx1[~adj].mean():.1f}% (n {int((~adj).sum())})")
print("paper: 22 of 38, -24% vs -40%")
main, outliers (a), adjacency ring: 33 of 44 same or adjacent, mean INDX1 -23.0% vs others -27.6% (n 11) main, outliers (a), adjacency grid: 34 of 44 same or adjacent, mean INDX1 -23.4% vs others -26.9% (n 10) main, outliers (b), adjacency ring: 33 of 44 same or adjacent, mean INDX1 -23.0% vs others -27.6% (n 11) main, outliers (b), adjacency grid: 34 of 44 same or adjacent, mean INDX1 -23.4% vs others -26.9% (n 10) main, outliers (c), adjacency ring: 33 of 44 same or adjacent, mean INDX1 -23.0% vs others -27.6% (n 11) main, outliers (c), adjacency grid: 34 of 44 same or adjacent, mean INDX1 -23.4% vs others -26.9% (n 10) all units, outliers (a), adjacency ring: 43 of 56 same or adjacent, mean INDX1 -26.6% vs others -24.8% (n 13) all units, outliers (a), adjacency grid: 46 of 56 same or adjacent, mean INDX1 -26.0% vs others -26.9% (n 10)
all units, outliers (b), adjacency ring: 43 of 56 same or adjacent, mean INDX1 -26.6% vs others -24.8% (n 13) all units, outliers (b), adjacency grid: 46 of 56 same or adjacent, mean INDX1 -26.0% vs others -26.9% (n 10) all units, outliers (c), adjacency ring: 43 of 56 same or adjacent, mean INDX1 -26.6% vs others -24.8% (n 13) all units, outliers (c), adjacency grid: 46 of 56 same or adjacent, mean INDX1 -26.0% vs others -26.9% (n 10) paper: 22 of 38, -24% vs -40%
Result: not reproduced. Of 44 Position/Vision cells, 33 (ring) or 34 (grid) have their V and NV peaks at the same or adjacent targets (paper 22 of 38), with mean INDX1 -23.0% (paper -24, within) against -27.6% for the others (paper -40, not within).
indx2-means¶
indx2-means: With an index based on each condition's own preferred location (INDX2), rate differences were weaker but still biased toward suppression, with means of -9%, -13% and -13% for Position Only, Vision Only and Position/Vision cells.
for lab, M in (("main", M1), ("all units", MA), ("main, other mapping", M1f)):
for oc in ("indx1", "indx2"):
for reading in ("a", "b", "c"):
R, _, o = fig4(M, "indx2", reading, outlier_col=oc)
print(f"{lab}, outliers on {oc} ({reading}): mean INDX2 Position Only {R.loc['position_only', 'mean']:.1f}, "
f"Vision Only {R.loc['vision_only', 'mean']:.1f}, Position/Vision {R.loc['position_vision', 'mean']:.1f} "
f"(n {int(R.loc['position_only', 'n'])}, {int(R.loc['vision_only', 'n'])}, {int(R.loc['position_vision', 'n'])})")
print("paper: -9, -13, -13")
main, outliers on indx1 (a): mean INDX2 Position Only -0.5, Vision Only 12.7, Position/Vision 7.5 (n 98, 20, 44) main, outliers on indx1 (b): mean INDX2 Position Only -1.3, Vision Only 12.7, Position/Vision 7.5 (n 90, 20, 44)
main, outliers on indx1 (c): mean INDX2 Position Only -0.5, Vision Only 12.7, Position/Vision 7.5 (n 98, 20, 44) main, outliers on indx2 (a): mean INDX2 Position Only -0.5, Vision Only -1.7, Position/Vision -2.6 (n 98, 16, 36) main, outliers on indx2 (b): mean INDX2 Position Only -1.2, Vision Only 12.7, Position/Vision 5.4 (n 87, 20, 44) main, outliers on indx2 (c): mean INDX2 Position Only -1.7, Vision Only -10.5, Position/Vision -9.5 (n 96, 14, 36) all units, outliers on indx1 (a): mean INDX2 Position Only 0.8, Vision Only 1.1, Position/Vision 9.1 (n 126, 32, 56) all units, outliers on indx1 (b): mean INDX2 Position Only -0.5, Vision Only 1.1, Position/Vision 9.1 (n 117, 32, 56) all units, outliers on indx1 (c): mean INDX2 Position Only 0.8, Vision Only 1.1, Position/Vision 9.1 (n 126, 32, 56) all units, outliers on indx2 (a): mean INDX2 Position Only -0.6, Vision Only -6.7, Position/Vision -1.5 (n 124, 27, 47) all units, outliers on indx2 (b): mean INDX2 Position Only -1.9, Vision Only 1.1, Position/Vision 4.9 (n 115, 32, 55)
all units, outliers on indx2 (c): mean INDX2 Position Only -2.0, Vision Only -14.1, Position/Vision -9.9 (n 121, 26, 45) main, other mapping, outliers on indx1 (a): mean INDX2 Position Only 1.6, Vision Only -2.5, Position/Vision -1.7 (n 94, 19, 43) main, other mapping, outliers on indx1 (b): mean INDX2 Position Only 1.3, Vision Only 1.0, Position/Vision 1.5 (n 88, 20, 45) main, other mapping, outliers on indx1 (c): mean INDX2 Position Only 1.6, Vision Only -2.5, Position/Vision -0.3 (n 94, 19, 44) main, other mapping, outliers on indx2 (a): mean INDX2 Position Only 0.9, Vision Only -7.1, Position/Vision -6.4 (n 93, 18, 37)
main, other mapping, outliers on indx2 (b): mean INDX2 Position Only 0.8, Vision Only 1.0, Position/Vision -3.4 (n 91, 20, 44) main, other mapping, outliers on indx2 (c): mean INDX2 Position Only 0.3, Vision Only -10.4, Position/Vision -12.6 (n 92, 17, 39) paper: -9, -13, -13
Result: not reproduced. Mean INDX2 is -0.5%, +12.7% and +7.5% for Position Only, Vision Only and Position/Vision cells (outliers on INDX1, reading (a)), against -9, -13 and -13%. No reading, population or code mapping gives three negative means within tolerance; the closest are outliers on INDX2 by reading (c), which gives -1.7, -10.5 and -9.5% for the 359 units, and -2.0, -14.1 and -9.9% for all 483 units, where only Vision Only (-14.1%) is within tolerance.
rate-variance-nv-higher¶
rate-variance-nv-higher: Spike rate variance at the NV preferred location tended to be higher in NV than in V, on average 56 against 30 (spikes/s)^2 across cells.
_, Mi1, o1 = fig4(M1, "indx1", "a")
for lab, M, keep in (("main, all cells", M1, None), ("main, after Fig. 4 outliers (a)", M1, ~o1), ("all units", MA, None)):
I = indexes(M)
for ddof in (1, 0):
vv = np.array([r.hold[0, p].var(ddof=ddof) for r, p in zip(M.itertuples(), I.pnv)])
vn = np.array([r.hold[1, p].var(ddof=ddof) for r, p in zip(M.itertuples(), I.pnv)])
if keep is not None:
vv, vn = vv[keep.values], vn[keep.values]
print(f"{lab}, ddof {ddof}: mean variance NV {vn.mean():.1f}, V {vv.mean():.1f} (spikes/s)^2; n {len(vv)}; "
f"NV > V in {100 * np.mean(vn > vv):.0f}% of cells; median NV {np.median(vn):.1f}, V {np.median(vv):.1f}")
print("paper: NV 56, V 30")
main, all cells, ddof 1: mean variance NV 46.4, V 23.1 (spikes/s)^2; n 359; NV > V in 67% of cells; median NV 14.5, V 8.9 main, all cells, ddof 0: mean variance NV 37.1, V 18.5 (spikes/s)^2; n 359; NV > V in 67% of cells; median NV 11.6, V 7.1
main, after Fig. 4 outliers (a), ddof 1: mean variance NV 46.7, V 23.0 (spikes/s)^2; n 356; NV > V in 68% of cells; median NV 14.5, V 8.9
main, after Fig. 4 outliers (a), ddof 0: mean variance NV 37.3, V 18.4 (spikes/s)^2; n 356; NV > V in 68% of cells; median NV 11.6, V 7.1 all units, ddof 1: mean variance NV 48.5, V 25.6 (spikes/s)^2; n 483; NV > V in 68% of cells; median NV 16.1, V 9.7 all units, ddof 0: mean variance NV 38.8, V 20.5 (spikes/s)^2; n 483; NV > V in 68% of cells; median NV 12.9, V 7.8 paper: NV 56, V 30
Result: partially reproduced (resting on an assumption). At the NV preferred location the mean rate variance across the 359 cells is 46.4 (spikes/s)^2 in NV and 23.1 in V, higher in NV in 67% of cells, as the paper's 56 against 30, but both below tolerance (50.4 and 27). After the Fig. 4 outliers it is 46.7 and 23.0; all units give 48.5 and 25.6. Which condition is NV rests on the code mapping.
fig5-fano-factor¶
fig5-fano-factor: The Fano factor was significantly larger in NV (1.54) than in V (1.13) (permutation test, P < 0.05).
def ff_slope(m, v):
return np.sum(m * v) / np.sum(m * m)
def ff_test(M, keep=None, seed=2, n_perm=1000):
I = indexes(M)
cm = np.array([[r.hold_count[c_, p].mean() for c_ in (0, 1)] for r, p in zip(M.itertuples(), I.pnv)])
cv = np.array([[r.hold_count[c_, p].var(ddof=1) for c_ in (0, 1)] for r, p in zip(M.itertuples(), I.pnv)])
if keep is not None:
cm, cv = cm[keep], cv[keep]
ffv, ffn = ff_slope(cm[:, 0], cv[:, 0]), ff_slope(cm[:, 1], cv[:, 1])
rng = np.random.default_rng(seed)
pm, pv_ = np.concatenate([cm[:, 0], cm[:, 1]]), np.concatenate([cv[:, 0], cv[:, 1]])
n = len(cm)
d = np.empty(n_perm)
for i in range(n_perm):
idx = rng.permutation(2 * n)
d[i] = ff_slope(pm[idx[n:]], pv_[idx[n:]]) - ff_slope(pm[idx[:n]], pv_[idx[:n]])
obs = ffn - ffv
return ffv, ffn, np.mean(np.abs(d) >= abs(obs)), np.mean(d >= obs), n, cm, cv
I1 = indexes(M1)
cm_all = np.array([[r.hold_count[c_, p].mean() for c_ in (0, 1)] for r, p in zip(M1.itertuples(), I1.pnv)])
cv_all = np.array([[r.hold_count[c_, p].var(ddof=1) for c_ in (0, 1)] for r, p in zip(M1.itertuples(), I1.pnv)])
tuk = np.zeros(len(M1), bool)
for arr in (cm_all[:, 0], cm_all[:, 1], cv_all[:, 0], cv_all[:, 1]):
lo, hi, _ = fences(arr)
tuk |= (arr < lo) | (arr > hi)
for lab, M, keep in (("main, Fig. 4 outliers (a) removed", M1, (~o1).values), ("main, Tukey outliers of count means or variances removed", M1, ~tuk),
("main, no removal", M1, None), ("all units, no removal", MA, None)):
ffv, ffn, p2, p1, n, cm, cv = ff_test(M, keep)
print(f"{lab}: n {n}; FF V {ffv:.3f}, NV {ffn:.3f}; permutation P two-sided {p2:.3f}, one-sided {p1:.3f}; "
f"count mean range {cm.min():.1f} to {cm.max():.1f}, variance range {cv.min():.1f} to {cv.max():.1f}")
ffv, ffn, p2, p1, n, cm, cv = ff_test(M1, (~o1).values)
fig, ax = plt.subplots(1, 2, figsize=(8, 3.5), sharex=True, sharey=True)
for i, (lab, f_) in enumerate((("V", ffv), ("NV", ffn))):
ax[i].scatter(cm[:, i], cv[:, i], s=6)
xx = np.linspace(0, cm.max(), 2)
ax[i].plot(xx, f_ * xx, "k")
ax[i].set_title(f"{lab}, FF {f_:.2f}")
ax[i].set_xlabel("spike count mean")
ax[0].set_ylabel("spike count variance")
plt.tight_layout()
plt.show()
print("all points are within the axes (axes span the data).")
main, Fig. 4 outliers (a) removed: n 356; FF V 1.841, NV 3.185; permutation P two-sided 0.280, one-sided 0.137; count mean range 0.0 to 50.0, variance range 0.0 to 2188.3 main, Tukey outliers of count means or variances removed: n 295; FF V 0.976, NV 1.243; permutation P two-sided 0.020, one-sided 0.010; count mean range 0.0 to 25.4, variance range 0.0 to 50.5
main, no removal: n 359; FF V 1.842, NV 3.182; permutation P two-sided 0.280, one-sided 0.147; count mean range 0.0 to 50.0, variance range 0.0 to 2188.3
all units, no removal: n 483; FF V 1.991, NV 3.155; permutation P two-sided 0.199, one-sided 0.100; count mean range 0.0 to 50.0, variance range 0.0 to 2188.3
all points are within the axes (axes span the data).
# Variant (verification round 1): the Fig. 5 axes run from 0 to 80 in count mean and variance.
# Cells whose four values (V and NV count mean and variance) all lie in that range.
in80 = (cm_all.max(axis=1) <= 80) & (cv_all.max(axis=1) <= 80)
ffv, ffn, p2, p1, n, cm, cv = ff_test(M1, in80)
print(f"main, cells within the plotted range 0 to 80: n {n} of {len(M1)}; FF V {ffv:.3f}, NV {ffn:.3f}; "
f"permutation P two-sided {p2:.3f}, one-sided {p1:.3f}")
main, cells within the plotted range 0 to 80: n 331 of 359; FF V 1.027, NV 1.205; permutation P two-sided 0.172, one-sided 0.081
Result: not reproduced (resting on an assumption). With the Fig. 4 outliers removed (reading (a), 356 cells), FF is 1.84 in V and 3.19 in NV, larger in NV but not significantly (permutation P = 0.280) and both above tolerance. With Tukey outliers of the count means or variances removed (reading (b), 295 cells), FF is 0.98 and 1.24, larger in NV with P = 0.020, but both below tolerance. Reading (a) is adopted, as the paper defines outliers only for Fig. 4. Keeping only the 331 cells within the plotted range of Fig. 5 (0 to 80, a variant) gives 1.03 and 1.21 (P = 0.172): V within tolerance, NV not, and no significant difference. Whether the criterion's outlier readings match the paper's Fig. 5 is asked of a reader (questions/shi-2013.yaml).
cv2-larger-nv¶
cv2-larger-nv: The squared coefficient of variation of interspike intervals (CV2) was also significantly larger in NV than in V (Kruskal-Wallis test, P < 0.05).
def cv2(M):
I = indexes(M)
out = []
for r, p in zip(M.itertuples(), I.pnv):
row = {}
for ci, lab in ((0, "V"), (1, "NV")):
isis = [np.diff(s) for s in r.hold_spikes[ci, p]]
pooled = np.concatenate(isis)
row[lab + "_a"] = (pooled.std() / pooled.mean()) ** 2 if len(pooled) >= 2 else np.nan
per = [(i_.std() / i_.mean()) ** 2 for i_ in isis if len(i_) >= 2]
row[lab + "_b"] = np.mean(per) if per else np.nan
out.append(row)
return pd.DataFrame(out)
for lab, M in (("main", M1), ("all units", MA)):
C = cv2(M)
for rd in ("a", "b"):
x = C[["V_" + rd, "NV_" + rd]].dropna()
h, p = stats.kruskal(x["V_" + rd], x["NV_" + rd])
print(f"{lab}, reading ({rd}): n {len(x)}; median CV2 V {x['V_' + rd].median():.3f}, NV {x['NV_' + rd].median():.3f}; "
f"mean V {x['V_' + rd].mean():.3f}, NV {x['NV_' + rd].mean():.3f}; Kruskal-Wallis H {h:.2f}, P {p:.3g}; "
f"dropped (fewer than two ISIs) {len(C) - len(x)}")
main, reading (a): n 318; median CV2 V 0.622, NV 0.737; mean V 0.780, NV 0.934; Kruskal-Wallis H 5.09, P 0.024; dropped (fewer than two ISIs) 41 main, reading (b): n 312; median CV2 V 0.456, NV 0.510; mean V 0.560, NV 0.614; Kruskal-Wallis H 2.74, P 0.0981; dropped (fewer than two ISIs) 47 all units, reading (a): n 426; median CV2 V 0.652, NV 0.770; mean V 0.803, NV 0.987; Kruskal-Wallis H 6.94, P 0.00843; dropped (fewer than two ISIs) 57 all units, reading (b): n 418; median CV2 V 0.493, NV 0.532; mean V 0.586, NV 0.670; Kruskal-Wallis H 3.36, P 0.0668; dropped (fewer than two ISIs) 65
Result: reproduced (resting on an assumption). With the ISIs of a cell's five trials pooled (reading (a)), CV2 is larger in NV (median 0.737 against 0.622; Kruskal-Wallis P = 0.024, 318 cells). Averaged over trials (reading (b)) the difference is in the same direction but not significant (0.510 against 0.456, P = 0.098). Reading (a), one CV2 "for each cell and condition" (Methods), is adopted. Which condition is NV rests on the code mapping.
Decoding: fig6-decoding-vv, fig6-decoding-nvnv, decoding-v-better-than-nv, fig6-decoding-cross¶
fig6-decoding-vv: A maximum-likelihood decoder trained and tested on V data decoded hand position with an average accuracy across targets of 91.6 +/- 9%.
fig6-decoding-nvnv: Trained and tested on NV data, the decoder's accuracy fell to 81.9 +/- 18.0%.
decoding-v-better-than-nv: Decoding accuracy was significantly higher in V than in NV (t-test, P < 0.05), a small but significant role of vision in representing limb position.
fig6-decoding-cross: Training and testing on different conditions gave lower accuracies, 60.7 +/- 22% trained on NV and tested on V and 69.1 +/- 17% trained on V and tested on NV, so decoding degraded whenever NV data were used.
All units of the population are treated as simultaneously recorded, and the trials of different units are joined by their order within target and condition (criterion reading (i)).
def counts_of(M, key="hold_count"):
return np.stack(M[key].values) # [cell, cond, target, trial]
def acc_per_target(conf):
return np.diag(conf) / conf.sum(axis=1) * 100
def run_decoder(C, tr, te, loo=True):
return acc_per_target(ppc.decode(C[:, tr], C[:, te] if te != tr else C[:, tr], loo=loo)) if te != tr else \
acc_per_target(ppc.decode(C[:, tr], C[:, tr]))
def boot(C, n_boot=200, size=None, seed=3, schemes=((0, 0), (1, 1), (1, 0), (0, 1)), loo=True):
rng = np.random.default_rng(seed)
n = C.shape[0]
out = {s: [] for s in schemes}
for b in range(n_boot):
idx = rng.integers(0, n, size or n)
Cb = C[idx]
for s in schemes:
out[s].append(run_decoder(Cb, s[0], s[1], loo))
return {s: np.array(v) for s, v in out.items()} # [boot, target]
names_s = {(0, 0): "V/V", (1, 1): "NV/NV", (1, 0): "train NV, test V", (0, 1): "train V, test NV"}
DEC = {}
for lab, M in (("main", M1), ("all units", MA)):
C = counts_of(M)
full = {s: run_decoder(C, *s) for s in names_s}
print(f"{lab}: {C.shape[0]} cells, full population, accuracy per target and mean:")
for s, a_ in full.items():
print(f" {names_s[s]:18s} {np.round(a_, 0)} mean {a_.mean():.1f}")
for bl, size in (("(a) resample n cells", None), ("(b) populations of 200 cells", 200)):
B = boot(C, size=size)
DEC[(lab, bl)] = B
for s in names_s:
acc = B[s].mean(axis=1)
print(f" bootstrap {bl}, {names_s[s]:18s}: mean {acc.mean():.1f} +/- {acc.std(ddof=1):.1f} (SD over 200); "
f"SD over targets of the mean {B[s].mean(axis=0).std(ddof=1):.1f}")
Bx = boot(C, schemes=((1, 0), (0, 1)), loo=False, seed=4)
for s in ((1, 0), (0, 1)):
print(f" cross reading (b), all five trials: {names_s[s]} {Bx[s].mean():.1f} +/- {Bx[s].mean(axis=1).std(ddof=1):.1f}")
print("paper: V/V 91.6 +/- 9, NV/NV 81.9 +/- 18.0, train NV test V 60.7 +/- 22, train V test NV 69.1 +/- 17")
main: 359 cells, full population, accuracy per target and mean: V/V [ 80. 100. 80. 100. 80. 100. 100. 60.] mean 87.5 NV/NV [ 80. 80. 80. 60. 60. 80. 100. 80.] mean 77.5 train NV, test V [ 20. 60. 20. 100. 0. 100. 100. 80.] mean 60.0 train V, test NV [40. 20. 40. 60. 60. 60. 40. 80.] mean 50.0
bootstrap (a) resample n cells, V/V : mean 77.4 +/- 6.5 (SD over 200); SD over targets of the mean 8.2 bootstrap (a) resample n cells, NV/NV : mean 63.7 +/- 7.0 (SD over 200); SD over targets of the mean 9.4 bootstrap (a) resample n cells, train NV, test V : mean 58.9 +/- 6.8 (SD over 200); SD over targets of the mean 28.3 bootstrap (a) resample n cells, train V, test NV : mean 52.7 +/- 7.2 (SD over 200); SD over targets of the mean 12.7 bootstrap (b) populations of 200 cells, V/V : mean 73.3 +/- 7.2 (SD over 200); SD over targets of the mean 6.9 bootstrap (b) populations of 200 cells, NV/NV : mean 57.2 +/- 8.3 (SD over 200); SD over targets of the mean 8.0 bootstrap (b) populations of 200 cells, train NV, test V : mean 55.1 +/- 7.4 (SD over 200); SD over targets of the mean 23.2 bootstrap (b) populations of 200 cells, train V, test NV : mean 50.6 +/- 8.2 (SD over 200); SD over targets of the mean 11.9
cross reading (b), all five trials: train NV, test V 62.1 +/- 6.4 cross reading (b), all five trials: train V, test NV 56.8 +/- 7.0 all units: 483 cells, full population, accuracy per target and mean: V/V [ 80. 100. 80. 60. 80. 100. 80. 60.] mean 80.0 NV/NV [80. 80. 20. 80. 60. 80. 80. 60.] mean 67.5 train NV, test V [ 20. 60. 0. 100. 0. 100. 80. 80.] mean 55.0 train V, test NV [ 20. 80. 20. 80. 40. 40. 40. 100.] mean 52.5
bootstrap (a) resample n cells, V/V : mean 68.4 +/- 6.8 (SD over 200); SD over targets of the mean 8.8 bootstrap (a) resample n cells, NV/NV : mean 63.0 +/- 6.4 (SD over 200); SD over targets of the mean 15.3 bootstrap (a) resample n cells, train NV, test V : mean 55.1 +/- 5.7 (SD over 200); SD over targets of the mean 29.9 bootstrap (a) resample n cells, train V, test NV : mean 49.9 +/- 7.1 (SD over 200); SD over targets of the mean 20.0 bootstrap (b) populations of 200 cells, V/V : mean 62.9 +/- 8.6 (SD over 200); SD over targets of the mean 7.8 bootstrap (b) populations of 200 cells, NV/NV : mean 55.3 +/- 8.1 (SD over 200); SD over targets of the mean 11.3 bootstrap (b) populations of 200 cells, train NV, test V : mean 49.1 +/- 7.7 (SD over 200); SD over targets of the mean 22.4 bootstrap (b) populations of 200 cells, train V, test NV : mean 45.5 +/- 8.2 (SD over 200); SD over targets of the mean 14.7
cross reading (b), all five trials: train NV, test V 61.9 +/- 6.6 cross reading (b), all five trials: train V, test NV 59.5 +/- 6.5 paper: V/V 91.6 +/- 9, NV/NV 81.9 +/- 18.0, train NV test V 60.7 +/- 22, train V test NV 69.1 +/- 17
# Chance level of this decoder: each cell's 40 trials in a condition are given shuffled target
# labels (independently per cell), and the full population is decoded leave-one-out, 20 times.
rng_ch = np.random.default_rng(31)
C0 = counts_of(M1)
null = {s: [] for s in ((0, 0), (1, 1))}
for _ in range(20):
Cs = C0.copy()
for i in range(Cs.shape[0]):
for ci in (0, 1):
flat = Cs[i, ci].reshape(-1)
Cs[i, ci] = rng_ch.permutation(flat).reshape(8, ppc.N_PER_CELL)
for s in null:
null[s].append(run_decoder(Cs, *s).mean())
for s, v in null.items():
print(f"shuffled labels, {names_s[s]}: mean accuracy {np.mean(v):.1f}% (range {np.min(v):.1f} to {np.max(v):.1f}); nominal chance 12.5%")
shuffled labels, V/V: mean accuracy 16.1% (range 5.0 to 37.5); nominal chance 12.5% shuffled labels, NV/NV: mean accuracy 11.2% (range 2.5 to 22.5); nominal chance 12.5%
for (lab, bl), B in DEC.items():
v_t, nv_t = B[(0, 0)].mean(axis=0), B[(1, 1)].mean(axis=0)
v_b, nv_b = B[(0, 0)].mean(axis=1), B[(1, 1)].mean(axis=1)
print(f"{lab}, {bl}: V {v_b.mean():.1f}, NV {nv_b.mean():.1f}; (a) paired t over 8 targets P {stats.ttest_rel(v_t, nv_t).pvalue:.3g}; "
f"(b) two-sample t over 200 bootstraps P {stats.ttest_ind(v_b, nv_b).pvalue:.3g}; (c) two-sample t over 8 targets P {stats.ttest_ind(v_t, nv_t).pvalue:.3g}")
Cf = counts_of(M1)[:, ::-1]
Bf = boot(Cf, schemes=((0, 0), (1, 1)))
print(f"other code mapping (V = 7), main, (a): V {Bf[(0, 0)].mean():.1f}, NV {Bf[(1, 1)].mean():.1f}")
main, (a) resample n cells: V 77.4, NV 63.7; (a) paired t over 8 targets P 0.00866; (b) two-sample t over 200 bootstraps P 4.05e-63; (c) two-sample t over 8 targets P 0.00806 main, (b) populations of 200 cells: V 73.3, NV 57.2; (a) paired t over 8 targets P 0.000915; (b) two-sample t over 200 bootstraps P 6.17e-65; (c) two-sample t over 8 targets P 0.000762 all units, (a) resample n cells: V 68.4, NV 63.0; (a) paired t over 8 targets P 0.294; (b) two-sample t over 200 bootstraps P 3.61e-15; (c) two-sample t over 8 targets P 0.404 all units, (b) populations of 200 cells: V 62.9, NV 55.3; (a) paired t over 8 targets P 0.0364; (b) two-sample t over 200 bootstraps P 3.45e-18; (c) two-sample t over 8 targets P 0.141
other code mapping (V = 7), main, (a): V 63.7, NV 77.4
Result: not reproduced. Trained and tested on V, the decoder's accuracy over 200 bootstrap resamples of the 359 cells is 77.4 +/- 6.5% (reading (a)) and 73.3% with populations of 200 cells (reading (b)), below 91.6 +/- 9%. The full population without resampling gives 87.5%. With shuffled target labels the decoder gives 16.1% (V) and 11.2% (NV) on average over 20 shuffles, near the nominal chance of 12.5%, so the accuracies are far above chance. The other code mapping (63.7%) and all 483 units (68.4%) are also below tolerance, so the outcome rests on neither choice.
Result: not reproduced. Trained and tested on NV, accuracy is 63.7 +/- 7.0% (reading (a)) and 57.2% (reading (b)), just below the 63.9% lower bound of 81.9 +/- 18.0%. The full population gives 77.5%.
Result: reproduced (resting on an assumption). V accuracy exceeds NV accuracy (77.4 against 63.7%) and every t-test reading finds it (paired over targets P = 0.0087, over bootstraps P < 1e-60, unpaired over targets P = 0.0081), as do populations of 200 cells. Which condition is V rests on the code mapping: under the other one NV decodes better (77.4 against 63.7%). With all 483 units and resampling n cells, only the test over bootstraps finds it (paired over targets P = 0.29, unpaired P = 0.40); with populations of 200 cells the paired test over targets also finds it (P = 0.036, unpaired P = 0.14). The test over bootstraps treats the 200 resamples as independent samples, so its P value shrinks as more resamples are drawn; the tests over targets do not have this problem.
Result: reproduced. Trained on NV and tested on V, accuracy is 58.9% (paper 60.7 +/- 22); trained on V and tested on NV, 52.7% (69.1 +/- 17); both are within tolerance and below the V/V accuracy (77.4%). Training on all five trials (reading (b)) gives 62.1 and 56.8%. Swapping the code mapping keeps both within tolerance and below the V/V accuracy (63.7%).
decoding-subepochs¶
decoding-subepochs: Decoding was less accurate with shorter windows, but did not differ between the first and the last 400 ms of the hold, in V or in NV.
for lab, M in (("main", M1), ("all units", MA)):
res = {}
for w in ("hold_count", "first400_count", "last400_count"):
res[w] = boot(counts_of(M, w), schemes=((0, 0), (1, 1)), seed=5)
for ci, cn in ((0, "V"), (1, "NV")):
s = (ci, ci)
h, f_, l_ = (res[w][s] for w in ("hold_count", "first400_count", "last400_count"))
print(f"{lab}, {cn}: 800 ms {h.mean():.1f}, first 400 {f_.mean():.1f}, last 400 {l_.mean():.1f}; first vs last: "
f"(a) paired t over targets P {stats.ttest_rel(f_.mean(0), l_.mean(0)).pvalue:.3g}, "
f"(b) two-sample t over bootstraps P {stats.ttest_ind(f_.mean(1), l_.mean(1)).pvalue:.3g}, "
f"(c) two-sample t over targets P {stats.ttest_ind(f_.mean(0), l_.mean(0)).pvalue:.3g}; "
f"difference {f_.mean() - l_.mean():.1f} points")
main, V: 800 ms 78.3, first 400 61.2, last 400 66.0; first vs last: (a) paired t over targets P 0.382, (b) two-sample t over bootstraps P 6.62e-11, (c) two-sample t over targets P 0.313; difference -4.8 points main, NV: 800 ms 64.6, first 400 59.8, last 400 42.8; first vs last: (a) paired t over targets P 0.00733, (b) two-sample t over bootstraps P 3.54e-78, (c) two-sample t over targets P 0.0168; difference 17.0 points
all units, V: 800 ms 68.3, first 400 54.1, last 400 57.2; first vs last: (a) paired t over targets P 0.6, (b) two-sample t over bootstraps P 1.49e-05, (c) two-sample t over targets P 0.554; difference -3.1 points all units, NV: 800 ms 62.2, first 400 56.3, last 400 41.7; first vs last: (a) paired t over targets P 0.0721, (b) two-sample t over bootstraps P 7.35e-74, (c) two-sample t over targets P 0.074; difference 14.6 points
# Variant: the same with the windows starting no earlier than 250 ms after code 10. The decoder is
# given counts scaled to 400 ms (rate x 0.4 s) so that the two parts are compared on one scale.
for lab in ("main", "all units"):
res = {key: boot(np.stack(LATE[lab][key]) * 0.4, schemes=((0, 0), (1, 1)), seed=5) for key in ("first", "last")}
for ci, cn in ((0, "V"), (1, "NV")):
s = (ci, ci)
f_, l_ = res["first"][s], res["last"][s]
print(f"variant, {lab}, {cn}: first part {f_.mean():.1f}, last 400 {l_.mean():.1f}; "
f"(a) paired over targets P {stats.ttest_rel(f_.mean(0), l_.mean(0)).pvalue:.3g}, "
f"(b) over bootstraps P {stats.ttest_ind(f_.mean(1), l_.mean(1)).pvalue:.3g}, "
f"(c) two-sample over targets P {stats.ttest_ind(f_.mean(0), l_.mean(0)).pvalue:.3g}; difference {f_.mean() - l_.mean():.1f}")
variant, main, V: first part 61.9, last 400 66.0; (a) paired over targets P 0.472, (b) over bootstraps P 7.95e-08, (c) two-sample over targets P 0.418; difference -4.1 variant, main, NV: first part 57.7, last 400 42.8; (a) paired over targets P 0.0191, (b) over bootstraps P 3.24e-63, (c) two-sample over targets P 0.0307; difference 14.9
variant, all units, V: first part 52.9, last 400 57.2; (a) paired over targets P 0.459, (b) over bootstraps P 2.59e-09, (c) two-sample over targets P 0.43; difference -4.3 variant, all units, NV: first part 53.2, last 400 41.7; (a) paired over targets P 0.145, (b) over bootstraps P 1.06e-53, (c) two-sample over targets P 0.173; difference 11.5
Result: not reproduced (resting on an assumption). The 400 ms windows decode less well than the 800 ms window (V 61.2 and 66.0 against 78.3%; NV 59.8 and 42.8 against 64.6%), as the paper says. In V the first and last 400 ms do not differ by the paired test (P = 0.38), but in NV the last 400 ms decode 17.0 points worse than the first (paired P = 0.0073, unpaired over targets P = 0.017), so a difference is found. With the window starting at least 250 ms after code 10 (variant) NV still differs (57.7 against 42.8%, paired P = 0.019, unpaired P = 0.031). With all 483 units the NV difference (14.6 points) is not significant by the paired (P = 0.072) or unpaired (P = 0.074) test over targets, and only the test over bootstraps finds it, so the outcome rests on taking one unit per session.
decoding-nonsignificant-cells¶
decoding-nonsignificant-cells: Neurons with no ANOVA effect of position, vision or interaction still decoded position above chance at some targets, and slightly better in V than in NV (20% against 14%), though this difference was not significant.
for lab, M in (("main", M1), ("all units", MA)):
none = groups(M)["none"].values
C = counts_of(M)[none]
B = boot(C, schemes=((0, 0), (1, 1)), seed=6)
v_t, nv_t = B[(0, 0)].mean(0), B[(1, 1)].mean(0)
print(f"{lab}: {none.sum()} cells without ANOVA effects; V {v_t.mean():.1f}, NV {nv_t.mean():.1f} (chance 12.5); "
f"per target V {np.round(v_t, 0)}, NV {np.round(nv_t, 0)}; targets above chance in both: {int(np.sum((v_t > 12.5) & (nv_t > 12.5)))}; "
f"t-tests P (a) {stats.ttest_rel(v_t, nv_t).pvalue:.3g}, (b) {stats.ttest_ind(B[(0, 0)].mean(1), B[(1, 1)].mean(1)).pvalue:.3g}, "
f"(c) {stats.ttest_ind(v_t, nv_t).pvalue:.3g}")
print("paper: V 20%, NV 14%")
main: 194 cells without ANOVA effects; V 24.7, NV 12.5 (chance 12.5); per target V [21. 38. 16. 22. 21. 44. 24. 12.], NV [16. 21. 7. 13. 3. 27. 10. 4.]; targets above chance in both: 4; t-tests P (a) 0.000162, (b) 3.56e-71, (c) 0.0242
all units: 266 cells without ANOVA effects; V 18.3, NV 17.6 (chance 12.5); per target V [17. 14. 17. 25. 9. 28. 16. 20.], NV [20. 31. 4. 30. 9. 29. 10. 9.]; targets above chance in both: 4; t-tests P (a) 0.854, (b) 0.22, (c) 0.888 paper: V 20%, NV 14%
Result: not reproduced. The 194 cells without ANOVA effects decode 24.7% in V and 12.5% in NV (paper 20 and 14%; neither within tolerance), V above NV, with 4 targets above chance in both, but the difference is significant (paired P = 0.00016), where the paper found it was not. All units (266 cells) give 18.3 and 17.6% (P = 0.85).
eye-position-no-difference¶
eye-position-no-difference: Neither mean eye position nor the variance of its horizontal or vertical component differed between V and NV for any target (MANOVA and Levene's test).
The claim is blocked (metadata_insufficient): the data set holds no documented eye position.
The analog files' channels are named only AD01 to AD16, and a summary of the channels of three
sessions is printed below. The 24 field record (in part of the sessions) ends with two numbers
near (0, -1.8) that might be an eye position averaged over the hold (the eye was to fixate the
centre), but no file names them, and their spread within a session (SD about 0.05 to 0.07) cannot
show what they are: it is below the eye tracker's resolution of 0.25 degrees (Methods,
Experimental apparatus), which a mean over about 100 samples could reach. The test is run on them
below only to show what they give; it decides nothing.
E = pd.concat([t.assign(session=k) for k, t in kept.items() if "f22" in t and t.f22.notna().all()])
print("sessions with the two fields:", E.session.nunique(), "; trials:", len(E))
print("field 22 range", E.f22.min(), "to", E.f22.max(), "; field 23 range", E.f23.min(), "to", E.f23.max())
print("within-session SD (median over sessions): field 22", round(E.groupby("session").f22.std().median(), 3),
"; field 23", round(E.groupby("session").f23.std().median(), 3))
rows = []
for tg in ppc.TARGETS:
v = E[(E.target == tg) & (E.cond == ppc.V_CODE)][["f22", "f23"]].values
nv = E[(E.target == tg) & (E.cond == ppc.NV_CODE)][["f22", "f23"]].values
F, p = ppc.hotelling2(v, nv)
rows.append(dict(target=ppc.TARGET_DEG[tg], n_V=len(v), n_NV=len(nv), mean_V=np.round(v.mean(0), 3), mean_NV=np.round(nv.mean(0), 3),
p_manova=p, p_levene_h=stats.levene(v[:, 0], nv[:, 0], center="mean").pvalue,
p_levene_v=stats.levene(v[:, 1], nv[:, 1], center="mean").pvalue,
p_levene_h_median=stats.levene(v[:, 0], nv[:, 0]).pvalue, p_levene_v_median=stats.levene(v[:, 1], nv[:, 1]).pvalue))
EY = pd.DataFrame(rows)
print("(a) per target, trials pooled over sessions:")
print(EY.to_string(index=False))
print("targets with any P < 0.05:", int(((EY.p_manova < 0.05) | (EY.p_levene_h < 0.05) | (EY.p_levene_v < 0.05)).sum()))
rows = []
for (k, tg), g in E.groupby(["session", "target"]):
v = g[g.cond == ppc.V_CODE][["f22", "f23"]].values
nv = g[g.cond == ppc.NV_CODE][["f22", "f23"]].values
rows.append(dict(p_manova=ppc.hotelling2(v, nv)[1], p_h=stats.levene(v[:, 0], nv[:, 0], center="mean").pvalue,
p_v=stats.levene(v[:, 1], nv[:, 1], center="mean").pvalue))
EP = pd.DataFrame(rows)
print("(b) per session and target, % significant: MANOVA", round(100 * np.mean(EP.p_manova < 0.05), 1),
"; Levene horizontal", round(100 * np.mean(EP.p_h < 0.05), 1), "; vertical", round(100 * np.mean(EP.p_v < 0.05), 1),
"; undefined", int(EP.p_manova.isna().sum()))
sessions with the two fields: 224 ; trials: 17920 field 22 range -1.58 to 1.43 ; field 23 range -3.19 to 0.73
within-session SD (median over sessions): field 22 0.053 ; field 23 0.073
(a) per target, trials pooled over sessions:
target n_V n_NV mean_V mean_NV p_manova p_levene_h p_levene_v p_levene_h_median p_levene_v_median
0 1120 1120 [0.076, -1.766] [0.07, -1.762] 0.907371 0.710010 0.844366 0.825764 0.599448
45 1120 1120 [0.1, -1.778] [0.09, -1.763] 0.383185 0.742611 0.827356 0.738219 0.709786
90 1120 1120 [0.032, -1.66] [0.013, -1.663] 0.504437 0.800415 0.011956 0.856390 0.282153
135 1120 1120 [-0.012, -1.766] [-0.035, -1.753] 0.219999 0.128504 0.659528 0.255449 0.469519
180 1120 1120 [-0.003, -1.814] [-0.023, -1.813] 0.460659 0.369630 0.609239 0.657098 0.535611
225 1120 1120 [-0.007, -1.834] [-0.022, -1.829] 0.626561 0.129553 0.963056 0.293188 0.920017
270 1120 1120 [0.056, -1.868] [0.045, -1.854] 0.368546 0.694729 0.814492 0.750011 0.770764
315 1120 1120 [0.065, -1.795] [0.05, -1.785] 0.554510 0.611468 0.715120 0.588751 0.557759
targets with any P < 0.05: 1
(b) per session and target, % significant: MANOVA 8.7 ; Levene horizontal 8.7 ; vertical 9.3 ; undefined 0
# The analog files of three sessions (ppc.read_anaad; layout read from the files, not documented).
for st, A in D["ana"].items():
k = st + ".mat"
t = D["sessions"][k]["trials"]
t = t[t.completed & t.target.isin(ppc.TARGETS)].copy()
X = A["X"].astype(float)
print(f"{st}: {A['n_channels']} channels, {A['n_samples']} samples at {A['fs']:.0f} Hz "
f"({A['n_samples'] / A['fs']:.0f} s; last code 12 at {t.t12.max():.0f} s); gains {A['gains'].tolist()}")
rows = []
for ch in range(A["n_channels"]):
x = X[ch]
hm = []
for t12 in t.t12.values:
i0, i1 = int(round((t12 - 0.8 - A["t0"]) * A["fs"])), int(round((t12 - A["t0"]) * A["fs"]))
hm.append(x[i0:i1].mean() if i0 >= 0 and i1 <= len(x) else np.nan)
t[f"ad{ch}"] = hm
grp = [t[f"ad{ch}"][t.target == tg].dropna() for tg in ppc.TARGETS]
rows.append(dict(channel=ch, min=x.min(), max=x.max(), sd=round(x.std(), 1),
saturated_pct=round(100 * np.mean(np.abs(x) >= 2047), 1),
r_x=round(np.corrcoef(t[f"ad{ch}"], t.x)[0, 1], 2), r_y=round(np.corrcoef(t[f"ad{ch}"], t.y)[0, 1], 2),
r_z=round(np.corrcoef(t[f"ad{ch}"], t.z)[0, 1], 2),
target_anova_p=stats.f_oneway(*grp).pvalue,
hold_sd_within_target=round(t.groupby("target")[f"ad{ch}"].std().mean(), 1)))
print(pd.DataFrame(rows).to_string(index=False))
data/010609/010609_1: 7 channels, 638372 samples at 1000 Hz (638 s; last code 12 at 632 s); gains [50, 50, 50, 50, 1, 1, 1, 1, 1, 1, 5, 5, 5, 1, 1, 1]
channel min max sd saturated_pct r_x r_y r_z target_anova_p hold_sd_within_target
0 -2048.0 2047.0 1099.0 14.2 -0.11 0.08 0.07 0.436837 180.8
1 -2048.0 2047.0 1940.0 84.8 0.22 0.05 0.12 0.299048 336.2
2 -2048.0 2047.0 1781.4 65.3 0.25 0.08 0.16 0.329474 250.7
3 -2048.0 2047.0 1534.1 42.3 0.03 -0.06 0.03 0.998218 637.3
4 -2048.0 2047.0 997.9 83.1 -0.15 -0.15 -0.04 0.506382 698.7
5 -2048.0 2047.0 1152.0 25.5 -0.12 -0.13 -0.17 0.721965 780.1
6 -32764.0 32766.0 4220.9 26.3 -0.20 -0.03 -0.17 0.354719 1531.5
data/010609/010609_2: 7 channels, 678582 samples at 1000 Hz (679 s; last code 12 at 663 s); gains [50, 50, 50, 50, 1, 1, 1, 1, 1, 1, 5, 5, 5, 1, 1, 1]
channel min max sd saturated_pct r_x r_y r_z target_anova_p hold_sd_within_target
0 -2048.0 2047.0 1004.9 6.8 0.16 0.09 -0.05 0.497863 275.7
1 -2048.0 2047.0 1391.9 29.0 -0.03 0.15 -0.16 0.553191 496.2
2 -2048.0 2047.0 1320.3 25.4 -0.01 0.15 -0.14 0.482843 451.5
3 -2048.0 2047.0 1080.0 16.5 -0.07 -0.03 0.03 0.995315 694.6
4 -2048.0 2047.0 1000.3 82.2 0.06 0.07 0.01 0.974398 576.5
5 -2048.0 2047.0 1150.4 25.5 0.06 -0.12 0.19 0.495739 620.3
6 -32762.0 32765.0 4160.2 26.7 0.11 0.02 0.01 0.333943 1026.9
data/010809/010809_2: 7 channels, 803739 samples at 1000 Hz (804 s; last code 12 at 794 s); gains [50, 50, 50, 50, 1, 1, 1, 1, 1, 1, 5, 5, 5, 1, 1, 1]
channel min max sd saturated_pct r_x r_y r_z target_anova_p hold_sd_within_target
0 -2048.0 2047.0 1110.1 9.9 -0.17 0.17 0.22 0.147898 340.8
1 -2048.0 2047.0 941.3 5.8 -0.10 0.07 0.02 0.735994 348.2
2 -2048.0 2047.0 815.8 3.3 -0.06 -0.02 0.06 0.850632 296.4
3 -2048.0 2047.0 873.8 12.9 -0.04 -0.02 0.02 0.910593 480.1
4 -2048.0 2047.0 957.3 83.8 -0.16 0.06 0.03 0.590644 572.4
5 -2048.0 2047.0 1074.9 24.7 -0.03 0.24 -0.07 0.341408 585.5
6 -32767.0 32763.0 4100.8 25.6 0.09 0.10 -0.06 0.467615 918.7
Under this reading of the analog files, no channel's hold-period mean correlates with the record's hand position beyond |r| = 0.25, and none differs between targets in the hold (one-way ANOVA P from 0.15 to 1.00), as an arm position channel would. Most channels saturate often at the 12-bit limits (+/-2047), and channel 6 spans the full 16-bit range, which a 12-bit converter cannot give, so the reading of the layout is at least partly wrong for it. A fixation trace would be nearly constant across targets in the hold, and no channel can be named as eye position on that alone. This is consistent with no usable eye or arm channel, not a proof of it: another layout of the .dat file could give other channels.
Result: blocked (metadata_insufficient). The data set holds no documented eye position. No analog channel of the three sessions summarised differs between targets in the hold or follows the hand, and the layout of the analog files is itself undocumented; record fields 22 and 23 are unnamed. The block also rests on a reading of the analog file layout that is at least partly wrong (channel 6). If fields 22 and 23 were the mean eye position, reading (a) would not reproduce the claim: Levene's test centred on the mean finds a V against NV difference at 90 degrees, vertical (P = 0.012, data check above).
aborted-trials-nv (blocked)¶
aborted-trials-nv: In one animal, as the behavioral window around the reach targets was made smaller, aborted trials increased in both conditions, and were significantly more frequent on NV trials for smaller windows (t-test, P < 0.05), so the animals used vision to hold position.
The labels of V and NV are inferred above from the aborts themselves, so this claim cannot be tested independently of that inference. The counts are shown for the record. Field 1 of the record (8, 10 or 12) is read as the target window size; no file says what it is.
a2 = a.copy()
a2["window"] = a2.params.apply(lambda p: p[1] if isinstance(p, tuple) else np.nan)
t_ = a2[a2.phase != "aborted before code 10"]
print(pd.crosstab([t_.window, t_.cond], t_.phase, margins=False).to_string())
print((t_.assign(ab=t_.phase == "aborted after code 10").groupby(["window", "cond"]).ab.mean() * 100).round(1).to_string())
phase aborted after code 10 completed
window cond
8.0 4.0 451 2783
7.0 1272 2782
10.0 4.0 3957 12290
7.0 4392 12133
12.0 4.0 15 400
7.0 24 400
window cond
8.0 4.0 13.9
7.0 31.4
10.0 4.0 24.4
7.0 26.6
12.0 4.0 3.6
7.0 5.7
Result: blocked (metadata_insufficient). Which code is NV was inferred above from the aborts themselves, so the claim's comparison of NV with V aborts would test the inference, not the paper. The window sizes are not documented either (field 1 of the record is read as one). For the record, with field 1 at 8, 10 and 12, 31.4, 26.6 and 5.7% of code 7 trials and 13.9, 24.4 and 3.6% of code 4 trials that reached code 10 were aborted. The part that does not depend on the mapping, more aborts as the window shrinks, holds for code 7 but not for code 4 (24.4% at 10 against 13.9% at 8), if field 1 is the window size.
longer-hold-no-difference (blocked)¶
longer-hold-no-difference: In a subset of sessions with the minimum hold extended to 1,200 ms, neither behavior nor neural responses differed appreciably.
rows = []
for k, s_ in D["sessions"].items():
t = s_["trials"]
if "params" not in t:
continue
c = t[t.completed & t.params.notna()]
if len(c) == 0:
continue
f11 = c.params.apply(lambda p: p[11])
d = c.t12 - c.t10
rows.append(dict(session=k, field11=f11.iloc[0], field11_values=len(set(f11)), n=len(c), min_10_to_12=d.min(),
field11_at_min=f11.loc[d.idxmin()], field11_set=sorted(set(f11))))
HP = pd.DataFrame(rows)
print("completed trials' record field 11 against the shortest code 10 to code 12 interval of each session (s):")
print(HP.groupby("field11").agg(sessions=("session", "size"), shortest_min=("min_10_to_12", "min"),
shortest_median=("min_10_to_12", "median"), shortest_max=("min_10_to_12", "max")).round(3).to_string())
print("sessions whose field 11 changes within the session:", int((HP.field11_values > 1).sum()))
below = HP[HP.min_10_to_12 < HP.field11 / 1000]
print("sessions whose shortest interval is below the field 11 of their first completed trial:")
print(below[["session", "field11", "field11_set", "min_10_to_12", "field11_at_min"]].to_string(index=False))
allp = allt[allt.params.notna()]
f11_all = allp.params.apply(lambda p: p[11])
print("trials with field 11 >= 1200, any outcome:", int((f11_all >= 1200).sum()), "; completed:", int(((f11_all >= 1200) & allp.completed).sum()))
completed trials' record field 11 against the shortest code 10 to code 12 interval of each session (s):
sessions shortest_min shortest_median shortest_max
field11
800.0 4 0.832 0.832 0.832
900.0 352 0.832 0.960 1.216
1000.0 46 0.960 1.056 1.056
1100.0 4 1.152 1.152 1.152
sessions whose field 11 changes within the session: 3
sessions whose shortest interval is below the field 11 of their first completed trial:
session field11 field11_set min_10_to_12 field11_at_min
data/012109/012109_5.mat 900.0 [800.0, 900.0] 0.832000 800.0
data/032509/032509_3.mat 1000.0 [900.0, 1000.0] 0.960025 900.0
data/033009/033009_6.mat 1000.0 [900.0, 1000.0] 0.960000 900.0
trials with field 11 >= 1200, any outcome: 4 ; completed: 0
Result: blocked (data_missing). On every completed trial the time from code 10 to code 12 is at least the trial's own field 11 plus 28 ms (data check), so field 11 is read as the minimum hold. Grouped by the field 11 of its first completed trial, a session's shortest interval is below that value in sessions grouped at 900 (0.832 s) and 1,000 ms (0.960 s); these are sessions whose field 11 changes within the session, and their shortest interval falls on a trial with a lower field 11 (data check above). No completed trial has a minimum hold of 1,200 ms or more; the data set holds no subset of sessions with the extended hold.
Summary¶
| Claim | Outcome |
|---|---|
| behavior-mean-position-sessions | not_reproduced |
| behavior-variability-sessions | not_reproduced |
| table1-endpoint-means | partially_reproduced |
| table1-endpoint-sd | not_reproduced |
| fig3-example-neuron | not_reproduced |
| movement-epoch-tuning | not_reproduced |
| hold-position-main-effect | reproduced |
| hold-vision-main-effect | reproduced |
| hold-interaction | reproduced |
| hold-subepochs | not_reproduced |
| hold-overall-effects | partially_reproduced |
| correlation-endpoint-datasets | reproduced |
| fig4-indx1-negative | partially_reproduced |
| fig4-indx1-means | partially_reproduced |
| indx1-tuning-shift | not_reproduced |
| indx2-means | not_reproduced |
| rate-variance-nv-higher | partially_reproduced |
| fig5-fano-factor | not_reproduced |
| cv2-larger-nv | reproduced |
| fig6-decoding-vv | not_reproduced |
| fig6-decoding-nvnv | not_reproduced |
| decoding-v-better-than-nv | reproduced |
| fig6-decoding-cross | reproduced |
| decoding-subepochs | not_reproduced |
| decoding-nonsignificant-cells | not_reproduced |
| eye-position-no-difference | blocked (metadata_insufficient) |
| aborted-trials-nv | blocked (metadata_insufficient) |
| longer-hold-no-difference | blocked (data_missing) |
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.
- Only monkey X: the data set holds no session with monkey B's target layout. The paper pools 219 monkey X and 124 monkey B neurons; here 359 monkey X sessions with the complete design are used, one unit from each, as the paper has one neuron per session; that it is the first sorted unit is an assumption, and all 483 sorted units are a variant. Four outcomes (hold-vision-main-effect, hold-subepochs, fig4-indx1-negative, decoding-subepochs) would differ with all units and are marked as resting on it. Counts are compared with the paper's as percentages, or scaled to 343.
- Which condition code is V is inferred from more aborts after code 10 on code 7 trials (assumed: 4 = V, 7 = NV). The directional results (rate variance, FF, CV2, V better than NV decoding) rest on this.
- The meaning of the event codes is read from their timing: 12 as the end of the hold, 8 as movement onset (cursor leaving the start window). On every completed trial code 10 to code 12 lasts at least the record's field 11 (the minimum hold) plus 28 ms, so the 800 ms window lies in the hold as the task timed it; in 11.6% of trials it starts less than 250 ms after code 10, and a variant that starts it later leaves the sub-epoch results as they are.
- Each trial has one hand position (the record's x, y, z), not a position trace, so behavioural tests use it in place of the mean over the 800 ms hold. No continuous arm or eye position is identified in the data.
- Where a cell of the design has more than five completed trials (4 sessions), the first five are used.
What was found about the data set.
- The data descriptor says 343 cells, 219 from monkey X and 124 from monkey B; every session with a trial record has monkey X's layout, in every month from October 2008 to November 2009, and there are more usable monkey X sessions (359, with 485 sorted units, all recorded before the paper was submitted, and not repeats of one neuron within a day) than the paper's 219. Which of them the paper used is not documented.
- The condition (V or NV) of a trial is coded as 4 or 7 in an undocumented text record; the event
codes are not described (
EventCodes.txtis a generic list that does not match them), nor are the record's fields (target, condition, hand position, possibly eye position, task parameters). - The analog files' channels are named AD01 to AD16 without description, and the layout of the
.plxAnaAD.datfiles is not documented. Under the layout read here no channel of three sessions follows the hand or differs between targets in the hold. - Nine early files (
d<n>.mat) have a shorter record without positions and a hold below 800 ms. - The
.matspike times are in milliseconds and the event times in seconds; the descriptor gives neither unit. They agree with the.plxfile of the session checked.