Reproducing Nishimoto et al. (2011) from CRCNS vim-2¶
Paper. Nishimoto, Vu, Naselaris, Benjamini, Yu & Gallant (2011), "Reconstructing Visual Experiences from Brain Activity Evoked by Natural Movies", Current Biology 21, 1641-1646, doi:10.1016/j.cub.2011.08.031.
Claims file. claims/nishimoto-2011-reconstructing.yaml, written from the version of record (main text, legends, Experimental Procedures) and its Supplemental Information.
Dataset. CRCNS vim-2 (Gallant Lab Natural Movie 4T fMRI Data), doi:10.6080/K00Z715X, read from the public S3 bucket crcnsarchive under vim-2/. CRCNS data sets are not versioned, so the version is recorded as unversioned (docs/archives.md); there is only one published version to pin, and it is the one the data descriptor (version 0.61, 2015-02-17) describes as holding the data of this paper. The MD5 sums of the files read, from the data set's checksums.md5, are printed in the data check below so that a later change can be detected: Stimuli.tar.gz d06069177dd2ccad303009b7003c67b9, VoxelResponses_subject1.tar.gz 0e389bfa0b2235d1763d8a0d3bebf0af, VoxelResponses_subject2.tar.gz 92f3e621677ac1c8c226c87d77977c88, VoxelResponses_subject3.tar.gz 3ea1084138f70583228ad5649c935921. The raw per-session data (raw_data/) are not used: the paper's analysis starts from the preprocessed responses these files hold.
Each file is a tar.gz holding one MATLAB 7.3 (HDF5) file. It is streamed once from the bucket into memory and opened there (vim2.py); nothing is written to disk.
| Claim | Tested here |
|---|---|
| fig2de-prediction-accuracy | tested |
| fig2e-directional-gain-small | tested |
| figs1a-motion-better-every-area | tested |
| fig2fgh-retinotopic-receptive-fields | tested (proxy test of the claims file, without the multifocal maps) |
| fig2j-speed-eccentricity | tested |
| fig3ab-identification-s1 | tested |
| fig3c-identification-large-set | blocked, data_missing (1,000,000-clip set not public) |
| fig4-reconstructions | blocked, data_missing (sampled prior not public) |
| fig4d-reconstruction-accuracy | blocked, data_missing (sampled prior not public) |
| discussion-color-no-gain | tested in the second notebook, color_no_gain.ipynb |
Main deviation. The paper fits each voxel with L1-regularized least squares by coordinate descent (Model Fitting, refs. 15 and 16). Every model here is fit by ridge regression, solved through the kernel of the training features, with the penalty chosen per voxel on held-out training data, under both readings of the claims file: (a) a held-out 10% in 50 s blocks, (b) 5-fold cross-validation over such blocks. This is an assumption: the paper gives neither its L1 penalty nor its stopping rule, and ridge with a penalty per voxel is the fit the same laboratory used for later encoding models of the same kind. An approximate L1 fit (accelerated proximal gradient, stopped after a fixed number of iterations) is run as a check on 120 voxels, 40 per subject, after fig2de-prediction-accuracy: on those voxels it predicts better than ridge, by 0.025 (static and directional) against ridge with penalty reading (a) and by 0.005 (static) and 0.011 (directional) against reading (b).
import time, resource, collections, urllib.request
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
import vim2
T0 = time.time()
SEED = 2011 # standard choice; each claim's random draws use their own generator
ALPHAS = np.logspace(0, 9, 19).astype(np.float32) # ridge penalties searched per voxel
MODELS = ["static", "nondirectional", "directional"]
SUBJECTS = [1, 2, 3]
def mem_gb():
return resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1e6
Stimuli and motion-energy features¶
Frames are downsampled to 96 x 96, converted to CIE LAB*, and the luminance passes through the 6,555-filter motion-energy bank (Supplemental, Motion-Energy Encoding Model; Gabor Wavelet Basis Set), one 600 s run (or 60 s test block) at a time. The bank is pymoten's pyramid; its default envelopes give the paper's count of 6,555 filters (see vim2.py). Four training frames are shown to check the orientation of the stored frames (rows and columns).
t = time.time()
filters = vim2.pyramid().filters
EXAMPLES = (0, 30000, 60000, 90000)
S = vim2.stimulus_motion_energy(filters, ("L",), example_frames=EXAMPLES)
me_train, me_test = S["st"]["L"], S["sv"]["L"]
stim_info = {k: S[k] for k in ("member", "member_bytes", "layout", "st_range", "sv_range", "st_L_range", "sv_L_range")}
examples = S["examples"]
del S
print(f"stimuli streamed, converted and filtered in {time.time() - t:.0f} s; peak memory {mem_gb():.1f} GB")
fig, ax = plt.subplots(1, 4, figsize=(10, 2.8))
for a, i in zip(ax, EXAMPLES):
a.imshow(examples[i])
a.set_title(f"training frame {i}", fontsize=9)
a.axis("off")
plt.show()
stimuli streamed, converted and filtered in 777 s; peak memory 6.1 GB
md5 = urllib.request.urlopen(vim2.BASE + "checksums.md5", timeout=60).read().decode()
print("MD5 sums of the files read (checksums.md5):")
for line in md5.splitlines():
if "Stimuli" in line or "VoxelResponses" in line:
print(" ", line)
print("Stimulus member:", stim_info["member"], stim_info["member_bytes"], "bytes")
print("Stored arrays:", stim_info["layout"])
print("Training frames", stim_info["layout"]["st"][0][0], "= 7200 s x 15 Hz:", stim_info["layout"]["st"][0][0] == 7200 * 15)
print("Test frames", stim_info["layout"]["sv"][0][0], "= 540 s x 15 Hz:", stim_info["layout"]["sv"][0][0] == 540 * 15)
print("Pixel range (uint8), training", stim_info["st_range"], "test", stim_info["sv_range"])
print("Luminance L* range after 96 x 96 downsampling, training %.1f to %.1f, test %.1f to %.1f (0 to 100 expected)"
% tuple(stim_info["st_L_range"] + stim_info["sv_L_range"]))
print("Filters in the bank:", len(filters), "(paper: 6,555)")
c = collections.Counter((float(f["spatial_freq"]), float(f["temporal_freq"]), float(f["direction"])) for f in filters)
print("Filters per (spatial frequency c/image, temporal frequency Hz): count, directions")
for sf in sorted({k[0] for k in c}):
for tf in sorted({k[1] for k in c}):
dirs = sorted(k[2] for k in c if k[:2] == (sf, tf))
print(f" ({sf:g}, {tf:g}): {sum(c[(sf, tf, d)] for d in dirs)} filters, {c[(sf, tf, dirs[0])]} per direction, directions {[int(d) for d in dirs]}")
z = collections.Counter(round(float(f["spatial_env"]), 4) for f in filters if f["spatial_freq"] == 0 and f["temporal_freq"] == 0)
print("Zero-spatial-frequency filters at each temporal frequency, by spatial envelope s.d. (fraction of the image):", dict(sorted(z.items())),
"- one per position of the grid of each nonzero spatial frequency, with that frequency's envelope, and no direction")
for m in MODELS:
cols = vim2.model_columns(filters, m)
g = collections.Counter((float(filters[cc[0]]["spatial_freq"]), float(filters[cc[0]]["temporal_freq"]), len(cc)) for cc in cols)
print(f"{m}: {len(cols)} features; (spatial freq, temporal freq, filters summed): count", dict(sorted(g.items())))
ktr = vim2.keep_mask(7200, vim2.TRAIN_BLOCK)
kte = vim2.keep_mask(540, vim2.TEST_BLOCK)
print("Motion energy at 1 Hz, training", me_train.shape, "test", me_test.shape,
"range %.2f to %.2f (log units)" % (me_train.min(), me_train.max()))
print("Samples kept after discarding the first 6 s of each block: training", ktr.sum(), "(paper 7,128), test", kte.sum(), "(paper 486)")
MD5 sums of the files read (checksums.md5):
d06069177dd2ccad303009b7003c67b9 Stimuli.tar.gz
0e389bfa0b2235d1763d8a0d3bebf0af VoxelResponses_subject1.tar.gz
92f3e621677ac1c8c226c87d77977c88 VoxelResponses_subject2.tar.gz
3ea1084138f70583228ad5649c935921 VoxelResponses_subject3.tar.gz
Stimulus member: Stimuli.mat 4096580159 bytes
Stored arrays: {'st': ((108000, 3, 128, 128), 'uint8'), 'sv': ((8100, 3, 128, 128), 'uint8')}
Training frames 108000 = 7200 s x 15 Hz: True
Test frames 8100 = 540 s x 15 Hz: True
Pixel range (uint8), training [0, 255] test [0, 255]
Luminance L* range after 96 x 96 downsampling, training 0.0 to 100.0, test 0.0 to 100.0 (0 to 100 expected)
Filters in the bank: 6555 (paper: 6,555)
Filters per (spatial frequency c/image, temporal frequency Hz): count, directions
(0, 0): 285 filters, 285 per direction, directions [0]
(0, 2): 285 filters, 285 per direction, directions [0]
(0, 4): 285 filters, 285 per direction, directions [0]
(2, 0): 4 filters, 1 per direction, directions [0, 45, 90, 135]
(2, 2): 8 filters, 1 per direction, directions [0, 45, 90, 135, 180, 225, 270, 315]
(2, 4): 8 filters, 1 per direction, directions [0, 45, 90, 135, 180, 225, 270, 315]
(4, 0): 4 filters, 1 per direction, directions [0, 45, 90, 135]
(4, 2): 8 filters, 1 per direction, directions [0, 45, 90, 135, 180, 225, 270, 315]
(4, 4): 8 filters, 1 per direction, directions [0, 45, 90, 135, 180, 225, 270, 315]
(8, 0): 36 filters, 9 per direction, directions [0, 45, 90, 135]
(8, 2): 72 filters, 9 per direction, directions [0, 45, 90, 135, 180, 225, 270, 315]
(8, 4): 72 filters, 9 per direction, directions [0, 45, 90, 135, 180, 225, 270, 315]
(16, 0): 196 filters, 49 per direction, directions [0, 45, 90, 135]
(16, 2): 392 filters, 49 per direction, directions [0, 45, 90, 135, 180, 225, 270, 315]
(16, 4): 392 filters, 49 per direction, directions [0, 45, 90, 135, 180, 225, 270, 315]
(32, 0): 900 filters, 225 per direction, directions [0, 45, 90, 135]
(32, 2): 1800 filters, 225 per direction, directions [0, 45, 90, 135, 180, 225, 270, 315]
(32, 4): 1800 filters, 225 per direction, directions [0, 45, 90, 135, 180, 225, 270, 315]
Zero-spatial-frequency filters at each temporal frequency, by spatial envelope s.d. (fraction of the image): {0.0187: 225, 0.0375: 49, 0.075: 9, 0.15: 1, 0.3: 1} - one per position of the grid of each nonzero spatial frequency, with that frequency's envelope, and no direction
static: 1425 features; (spatial freq, temporal freq, filters summed): count {(0.0, 0.0, 1): 285, (2.0, 0.0, 1): 4, (4.0, 0.0, 1): 4, (8.0, 0.0, 1): 36, (16.0, 0.0, 1): 196, (32.0, 0.0, 1): 900}
nondirectional: 4275 features; (spatial freq, temporal freq, filters summed): count {(0.0, 0.0, 1): 285, (0.0, 2.0, 1): 285, (0.0, 4.0, 1): 285, (2.0, 0.0, 1): 4, (2.0, 2.0, 2): 4, (2.0, 4.0, 2): 4, (4.0, 0.0, 1): 4, (4.0, 2.0, 2): 4, (4.0, 4.0, 2): 4, (8.0, 0.0, 1): 36, (8.0, 2.0, 2): 36, (8.0, 4.0, 2): 36, (16.0, 0.0, 1): 196, (16.0, 2.0, 2): 196, (16.0, 4.0, 2): 196, (32.0, 0.0, 1): 900, (32.0, 2.0, 2): 900, (32.0, 4.0, 2): 900}
directional: 6555 features; (spatial freq, temporal freq, filters summed): count {(0.0, 0.0, 1): 285, (0.0, 2.0, 1): 285, (0.0, 4.0, 1): 285, (2.0, 0.0, 1): 4, (2.0, 2.0, 1): 8, (2.0, 4.0, 1): 8, (4.0, 0.0, 1): 4, (4.0, 2.0, 1): 8, (4.0, 4.0, 1): 8, (8.0, 0.0, 1): 36, (8.0, 2.0, 1): 72, (8.0, 4.0, 1): 72, (16.0, 0.0, 1): 196, (16.0, 2.0, 1): 392, (16.0, 4.0, 1): 392, (32.0, 0.0, 1): 900, (32.0, 2.0, 1): 1800, (32.0, 4.0, 1): 1800}
Motion energy at 1 Hz, training (7200, 6555) test (540, 6555) range -11.51 to 14.81 (log units)
Samples kept after discarding the first 6 s of each block: training 7128 (paper 7,128), test 486 (paper 486)
Features, kernels and splits¶
Each model's features are summed per column, z-scored with the training statistics, clipped at 3 and delayed by 3 to 6 s within runs. The ridge fits go through the kernel X X' of the training samples, which depends only on the features, so it is computed once per model and serves the three subjects. The held-out 10% (reading a of the penalty and the voxel selection of identification) and the five folds (reading b) are drawn once and used for every subject (standard choice).
held = vim2.holdout_blocks(int(ktr.sum()), np.random.default_rng([SEED, 0]))
fold = vim2.cv_folds(int(ktr.sum()), np.random.default_rng([SEED, 1]))
KER, FEAT = {}, {}
t = time.time()
for m in MODELS + ["delay0", "delay4", "delay8"]:
base = m if m in MODELS else "directional"
dl = vim2.DELAYS if m in MODELS else (int(m[5:]),)
cols = vim2.model_columns(filters, base)
Xtr, Xte, mu, sd = vim2.build_features(me_train, me_test, cols, return_stats=True)
X = vim2.delayed(Xtr, dl, 600)[ktr]
Xe = vim2.delayed(Xte, dl, 60)[kte]
KER[m] = (X @ X.T, Xe @ X.T)
if m == "directional":
FEAT[m] = dict(X=X, Xe=Xe, cols=cols, mu=mu, sd=sd)
print(f"{m}: {len(cols)} features x {len(dl)} delays = {X.shape[1]} regressors")
del X, Xe, Xtr, Xte
print(f"held-out samples {held.sum()} of {ktr.sum()}; fold sizes {np.bincount(fold).tolist()}; kernels in {time.time() - t:.0f} s")
static: 1425 features x 4 delays = 5700 regressors
nondirectional: 4275 features x 4 delays = 17100 regressors
directional: 6555 features x 4 delays = 26220 regressors
delay0: 6555 features x 1 delays = 6555 regressors
delay4: 6555 features x 1 delays = 6555 regressors
delay8: 6555 features x 1 delays = 6555 regressors held-out samples 728 of 7128; fold sizes [1428, 1450, 1450, 1400, 1400]; kernels in 16 s
Responses, per subject¶
For each subject the V1, V2, V3, V3A and V3B voxels are taken from the data set's ROI masks. Voxels with any missing value are dropped and counted. The test responses are the ten repeats (rva); following Data Preprocessing ("signals were then normalized to mean 0.0 and standard deviation 1.0" for each run), each repeat is z-scored per voxel, and the observed test signal of reading (a) is their mean. The stored repeat mean rv is also scored, as a check.
DATA = {}
for s in SUBJECTS:
t = time.time()
d = vim2.load_subject(s)
good = ~(np.isnan(d["rt"]).any(0) | np.isnan(d["rva"]).any((0, 1)) | np.isnan(d["rv"]).any(0))
rva = d["rva"][:, :, good]
raw_std = (float(d["rt"][:, good].std()), float(d["rv"][:, good].std()), float(rva.std()))
rv_check = float(np.max(np.abs(d["rv"][:, good] - rva.mean(0))))
rva = (rva - rva.mean(1, keepdims=True)) / rva.std(1, keepdims=True)
Yrep = rva[:, kte]
DATA[s] = dict(Y=d["rt"][ktr][:, good], Yrep=Yrep, Yte=Yrep.mean(0), Yrv=d["rv"][kte][:, good],
vox=d["vox"][good], area=d["area"][good], hemi=d["hemi"][good],
info=dict(layout=d["layout"], ei=d["ei"], roi_values=d["roi_values"], roi_counts=d["roi_counts"],
roi_mean_slice=d["roi_mean_slice"], n_any=d["n_voxels_any_roi"], n_multi=d["n_multi_label"],
n_roi=len(d["vox"]), n_drop=int((~good).sum()), raw_std=raw_std, rv_check=rv_check,
first6=float(d["rt"][~ktr][:, good].mean()), rest=float(d["rt"][ktr][:, good].mean())))
del d, rva
print(f"subject {s}: loaded in {time.time() - t:.0f} s; peak memory {mem_gb():.1f} GB")
subject 1: loaded in 95 s; peak memory 6.2 GB
subject 2: loaded in 93 s; peak memory 6.4 GB
subject 3: loaded in 96 s; peak memory 6.8 GB
Fits¶
For each model and each split the training block of the kernel is decomposed once; the penalty of each voxel is the one whose fit best predicts the held-out samples (reading a: the held-out 10%, over the 19 penalties of the grid; reading b: the mean correlation over the five folds, over the whole decades of the grid, for time), and the model is refit on all training samples with it. The clock check fits the directional model at a single delay of 0, 4 or 8 s: if responses and stimuli share a clock, the 4 s delay (the hemodynamic lag the paper assumes) predicts best and 0 s worst.
FIT = {s: {} for s in SUBJECTS}
idx_all = np.arange(int(ktr.sum()))
for m in MODELS + ["delay0", "delay4", "delay8"]:
t = time.time()
K, Kte = KER[m]
tr, ev = idx_all[~held], idx_all[held]
w, U = vim2.eig_split(K, tr)
Kev = K[np.ix_(ev, tr)]
for s in SUBJECTS:
Y = DATA[s]["Y"]
rh = vim2.ridge_path_corr(w, U, Kev, Y[tr], Y[ev], ALPHAS)
FIT[s][m] = dict(ai_a=rh.argmax(0), held_acc=rh.max(0))
if m in ("directional", "delay4") and s == 1:
C90 = vim2.ridge_dual(w, U, Y[tr], FIT[s][m]["ai_a"], ALPHAS)
FIT[s][m]["Pheld"] = Kev @ C90
FIT[s][m]["R90"] = Y[tr] - K[np.ix_(tr, tr)] @ C90
del C90
if m in MODELS:
cv = {s: 0 for s in SUBJECTS}
for k in range(5):
tr_k, ev_k = idx_all[fold != k], idx_all[fold == k]
wk, Uk = vim2.eig_split(K, tr_k)
Kk = K[np.ix_(ev_k, tr_k)]
for s in SUBJECTS:
Y = DATA[s]["Y"]
cv[s] = cv[s] + vim2.ridge_path_corr(wk, Uk, Kk, Y[tr_k], Y[ev_k], ALPHAS[::2]) / 5
del wk, Uk, Kk
for s in SUBJECTS:
FIT[s][m]["ai_b"] = 2 * cv[s].argmax(0) # whole decades of the same grid, for time
if m == "directional": # S1 fit on 90% with the reading (b) penalties, for identification
Y = DATA[1]["Y"]
C90 = vim2.ridge_dual(w, U, Y[tr], FIT[1][m]["ai_b"], ALPHAS)
FIT[1][m]["Pheld_b"] = Kev @ C90
FIT[1][m]["R90_b"] = Y[tr] - K[np.ix_(tr, tr)] @ C90
del C90
w, U = vim2.eig_split(K, idx_all)
for s in SUBJECTS:
Y, f = DATA[s]["Y"], FIT[s][m]
for rd in ("a", "b") if m in MODELS else ("a",):
C = vim2.ridge_dual(w, U, Y, f["ai_" + rd], ALPHAS)
P = Kte @ C
f["acc_" + rd] = {"avg": vim2.corr_cols(P, DATA[s]["Yte"]),
"rep": np.mean([vim2.corr_cols(P, DATA[s]["Yrep"][k]) for k in range(10)], 0),
"rv": vim2.corr_cols(P, DATA[s]["Yrv"])}
if rd == "b" and m == "directional" and s == 1:
f["Pte_b"], f["R_b"] = P, Y - K @ C
if rd == "a" and m in ("directional", "delay4"):
f["Pte"] = P
if m == "directional":
f["C"] = C
if s == 1:
f["R"] = Y - K @ C
del C, P
del w, U, Kev
print(f"{m}: fitted in {time.time() - t:.0f} s; peak memory {mem_gb():.1f} GB")
static: fitted in 132 s; peak memory 6.8 GB
nondirectional: fitted in 132 s; peak memory 6.8 GB
directional: fitted in 142 s; peak memory 6.8 GB
delay0: fitted in 41 s; peak memory 6.8 GB
delay4: fitted in 46 s; peak memory 6.8 GB
delay8: fitted in 42 s; peak memory 6.8 GB
for s in SUBJECTS:
i = DATA[s]["info"]
print(f"--- subject {s}")
print(" stored arrays:", i["layout"], "ei:", i["ei"])
print(" ROI mask values:", i["roi_values"], "; voxels in any ROI:", i["n_any"], "of 73,728")
print(" every ROI mask in the file, with its voxel count:", i["roi_counts"])
print(" V1-V3B voxels per mask:", {k: v for k, v in i["roi_counts"].items() if k[:2] in ("v1", "v2", "v3")})
print(" voxels in more than one V1-V3B mask:", i["n_multi"])
print(f" V1-V3B voxels {i['n_roi']} (paper about 4,500 per subject); dropped for missing values {i['n_drop']}; kept {i['n_roi'] - i['n_drop']}")
print(" kept per area:", dict(collections.Counter(DATA[s]["area"])))
print(f" rv equals the mean of the ten rva repeats: max abs difference {i['rv_check']:.2e}")
print(f" s.d. of rt {i['raw_std'][0]:.3f}, rv {i['raw_std'][1]:.3f}, rva {i['raw_std'][2]:.3f} (training z-scored per run; test in other units, so each repeat is z-scored here)")
print(f" mean training response in the first 6 s of each run {i['first6']:.3f}, in the kept samples {i['rest']:.3f} (onset transient, discarded as in the paper)")
for m in MODELS:
for rd in ("a", "b"):
n = np.bincount(FIT[s][m]["ai_" + rd], minlength=len(ALPHAS))
print(f" {m}, penalty reading ({rd}): voxels per chosen penalty (1 to 1e9, half decades) {n.tolist()}; at the lowest {n[0]}, at the highest {n[-1]}")
print(" clock check, mean test accuracy of the directional model at one delay:",
{f"{k[5:]} s": round(float(FIT[s][k]["acc_a"]["avg"].mean()), 3) for k in ("delay0", "delay4", "delay8")})
--- subject 1
stored arrays: {'rt': ((73728, 7200), 'float32'), 'rv': ((73728, 540), 'float32'), 'rva': ((73728, 10, 540), 'float32')} ei: {'TRsec': [1.0], 'datasize': [64.0, 64.0, 18.0], 'imhz': [15.0], 'valrepnum': [10.0]}
ROI mask values: [np.float64(0.0), np.float64(1.0)] ; voxels in any ROI: 9137 of 73,728
every ROI mask in the file, with its voxel count: {'FFAlh': 0, 'FFArh': 5, 'IPlh': 967, 'IPrh': 1308, 'MTlh': 197, 'MTplh': 58, 'MTprh': 91, 'MTrh': 152, 'OBJlh': 132, 'OBJrh': 44, 'PPAlh': 0, 'PPArh': 0, 'RSCrh': 71, 'STSrh': 45, 'VOlh': 124, 'VOrh': 304, 'latocclh': 309, 'latoccrh': 413, 'v1lh': 494, 'v1rh': 514, 'v2lh': 726, 'v2rh': 781, 'v3alh': 92, 'v3arh': 160, 'v3blh': 104, 'v3brh': 152, 'v3lh': 598, 'v3rh': 562, 'v4lh': 308, 'v4rh': 426}
V1-V3B voxels per mask: {'v1lh': 494, 'v1rh': 514, 'v2lh': 726, 'v2rh': 781, 'v3alh': 92, 'v3arh': 160, 'v3blh': 104, 'v3brh': 152, 'v3lh': 598, 'v3rh': 562}
voxels in more than one V1-V3B mask: 0
V1-V3B voxels 4183 (paper about 4,500 per subject); dropped for missing values 179; kept 4004
kept per area: {'v3': 1109, 'v2': 1418, 'v1': 969, 'v3b': 256, 'v3a': 252}
rv equals the mean of the ten rva repeats: max abs difference 0.00e+00
s.d. of rt 0.994, rv 0.104, rva 0.204 (training z-scored per run; test in other units, so each repeat is z-scored here)
mean training response in the first 6 s of each run 0.416, in the kept samples 0.014 (onset transient, discarded as in the paper)
static, penalty reading (a): voxels per chosen penalty (1 to 1e9, half decades) [164, 51, 48, 47, 67, 75, 87, 204, 839, 1021, 420, 233, 149, 98, 63, 36, 9, 3, 390]; at the lowest 164, at the highest 390
static, penalty reading (b): voxels per chosen penalty (1 to 1e9, half decades) [64, 0, 48, 0, 75, 0, 61, 0, 980, 0, 2090, 0, 356, 0, 62, 0, 17, 0, 251]; at the lowest 64, at the highest 251
nondirectional, penalty reading (a): voxels per chosen penalty (1 to 1e9, half decades) [105, 1, 12, 9, 24, 32, 29, 55, 122, 536, 1115, 819, 431, 237, 115, 46, 21, 11, 284]; at the lowest 105, at the highest 284
nondirectional, penalty reading (b): voxels per chosen penalty (1 to 1e9, half decades) [55, 0, 4, 0, 26, 0, 44, 0, 55, 0, 2207, 0, 1192, 0, 198, 0, 27, 0, 196]; at the lowest 55, at the highest 196
directional, penalty reading (a): voxels per chosen penalty (1 to 1e9, half decades) [147, 1, 2, 14, 14, 40, 37, 48, 116, 315, 898, 980, 544, 301, 154, 67, 26, 13, 287]; at the lowest 147, at the highest 287
directional, penalty reading (b): voxels per chosen penalty (1 to 1e9, half decades) [50, 0, 6, 0, 22, 0, 27, 0, 30, 0, 1626, 0, 1777, 0, 232, 0, 34, 0, 200]; at the lowest 50, at the highest 200
clock check, mean test accuracy of the directional model at one delay: {'0 s': 0.059, '4 s': 0.32, '8 s': 0.142}
--- subject 2
stored arrays: {'rt': ((73728, 7200), 'float32'), 'rv': ((73728, 540), 'float32'), 'rva': ((73728, 10, 540), 'float32')} ei: {'TRsec': [1.0], 'datasize': [64.0, 64.0, 18.0], 'imhz': [15.0], 'valrepnum': [10.0]}
ROI mask values: [np.float64(0.0), np.float64(1.0)] ; voxels in any ROI: 8013 of 73,728
every ROI mask in the file, with its voxel count: {'EBAlh': 132, 'EBArh': 194, 'MTlh': 83, 'MTprh': 24, 'MTrh': 116, 'OFAlh': 81, 'OFArh': 170, 'RSClh': 0, 'RSCrh': 129, 'VOlh': 131, 'VOrh': 238, 'latocclh': 359, 'latoccrh': 255, 'v1lh': 470, 'v1rh': 573, 'v2lh': 733, 'v2rh': 928, 'v3alh': 135, 'v3arh': 202, 'v3blh': 83, 'v3brh': 140, 'v3lh': 734, 'v3rh': 670, 'v4lh': 617, 'v4rh': 417, 'v7arh': 94, 'v7brh': 56, 'v7crh': 37, 'v7lh': 60, 'v7rh': 153}
V1-V3B voxels per mask: {'v1lh': 470, 'v1rh': 573, 'v2lh': 733, 'v2rh': 928, 'v3alh': 135, 'v3arh': 202, 'v3blh': 83, 'v3brh': 140, 'v3lh': 734, 'v3rh': 670}
voxels in more than one V1-V3B mask: 0
V1-V3B voxels 4668 (paper about 4,500 per subject); dropped for missing values 46; kept 4622
kept per area: {'v3': 1360, 'v2': 1659, 'v1': 1043, 'v3a': 337, 'v3b': 223}
rv equals the mean of the ten rva repeats: max abs difference 0.00e+00
s.d. of rt 0.989, rv 0.114, rva 0.212 (training z-scored per run; test in other units, so each repeat is z-scored here)
mean training response in the first 6 s of each run 0.412, in the kept samples 0.011 (onset transient, discarded as in the paper)
static, penalty reading (a): voxels per chosen penalty (1 to 1e9, half decades) [232, 68, 71, 77, 91, 99, 217, 625, 788, 694, 533, 334, 228, 131, 61, 37, 12, 3, 321]; at the lowest 232, at the highest 321
static, penalty reading (b): voxels per chosen penalty (1 to 1e9, half decades) [74, 0, 58, 0, 65, 0, 99, 0, 1401, 0, 2166, 0, 456, 0, 75, 0, 14, 0, 214]; at the lowest 74, at the highest 214
nondirectional, penalty reading (a): voxels per chosen penalty (1 to 1e9, half decades) [88, 3, 8, 14, 22, 36, 52, 57, 112, 397, 1282, 1172, 649, 265, 147, 61, 21, 9, 227]; at the lowest 88, at the highest 227
nondirectional, penalty reading (b): voxels per chosen penalty (1 to 1e9, half decades) [30, 0, 8, 0, 14, 0, 26, 0, 67, 0, 2744, 0, 1379, 0, 179, 0, 29, 0, 146]; at the lowest 30, at the highest 146
directional, penalty reading (a): voxels per chosen penalty (1 to 1e9, half decades) [94, 3, 8, 12, 17, 26, 49, 56, 84, 195, 864, 1463, 888, 365, 177, 69, 19, 10, 223]; at the lowest 94, at the highest 223
directional, penalty reading (b): voxels per chosen penalty (1 to 1e9, half decades) [38, 0, 5, 0, 8, 0, 28, 0, 57, 0, 2156, 0, 1880, 0, 246, 0, 43, 0, 161]; at the lowest 38, at the highest 161
clock check, mean test accuracy of the directional model at one delay: {'0 s': 0.094, '4 s': 0.332, '8 s': 0.153}
--- subject 3
stored arrays: {'rt': ((73728, 7200), 'float32'), 'rv': ((73728, 540), 'float32'), 'rva': ((73728, 10, 540), 'float32')} ei: {'TRsec': [1.0], 'datasize': [64.0, 64.0, 18.0], 'imhz': [15.0], 'valrepnum': [10.0]}
ROI mask values: [np.float64(0.0), np.float64(1.0)] ; voxels in any ROI: 15122 of 73,728
every ROI mask in the file, with its voxel count: {'EBAlh': 262, 'EBArh': 32, 'FFAlh': 0, 'FFArh': 0, 'IPS1lh': 190, 'IPS1rh': 190, 'IPS2lh': 128, 'IPS2rh': 131, 'IPS3lh': 123, 'IPS3rh': 98, 'IPS4lh': 17, 'IPS4rh': 99, 'MSTlh': 49, 'MTlh': 166, 'MTrh': 64, 'OFAlh': 30, 'OFArh': 61, 'PPAlh': 0, 'PPArh': 0, 'RSClh': 20, 'RSCrh': 8, 'STSlh': 23, 'STSrh': 0, 'TOSlh': 88, 'TOSrh': 72, 'V7lh': 254, 'V7rh': 329, 'cortALL': 15122, 'cortALLlh': 8118, 'cortALLrh': 7004, 'latocclh': 186, 'latoccrh': 234, 'v1lh': 653, 'v1rh': 713, 'v2lh': 746, 'v2rh': 650, 'v3alh': 164, 'v3arh': 118, 'v3blh': 88, 'v3brh': 138, 'v3lh': 504, 'v3rh': 637, 'v4lh': 348, 'v4rh': 436}
V1-V3B voxels per mask: {'v1lh': 653, 'v1rh': 713, 'v2lh': 746, 'v2rh': 650, 'v3alh': 164, 'v3arh': 118, 'v3blh': 88, 'v3brh': 138, 'v3lh': 504, 'v3rh': 637}
voxels in more than one V1-V3B mask: 1
V1-V3B voxels 4410 (paper about 4,500 per subject); dropped for missing values 29; kept 4381
kept per area: {'v3': 1131, 'v2': 1377, 'v1': 1366, 'v3b': 226, 'v3a': 281}
rv equals the mean of the ten rva repeats: max abs difference 0.00e+00
s.d. of rt 0.991, rv 0.100, rva 0.227 (training z-scored per run; test in other units, so each repeat is z-scored here)
mean training response in the first 6 s of each run 0.276, in the kept samples 0.011 (onset transient, discarded as in the paper)
static, penalty reading (a): voxels per chosen penalty (1 to 1e9, half decades) [199, 69, 64, 51, 54, 85, 95, 210, 598, 1067, 689, 353, 203, 125, 55, 36, 5, 1, 422]; at the lowest 199, at the highest 422
static, penalty reading (b): voxels per chosen penalty (1 to 1e9, half decades) [99, 0, 49, 0, 49, 0, 107, 0, 683, 0, 2469, 0, 544, 0, 99, 0, 24, 0, 258]; at the lowest 99, at the highest 258
nondirectional, penalty reading (a): voxels per chosen penalty (1 to 1e9, half decades) [96, 5, 7, 16, 21, 40, 51, 82, 105, 334, 1049, 1115, 569, 283, 167, 56, 25, 7, 353]; at the lowest 96, at the highest 353
nondirectional, penalty reading (b): voxels per chosen penalty (1 to 1e9, half decades) [54, 0, 15, 0, 21, 0, 37, 0, 73, 0, 2296, 0, 1374, 0, 237, 0, 45, 0, 229]; at the lowest 54, at the highest 229
directional, penalty reading (a): voxels per chosen penalty (1 to 1e9, half decades) [88, 3, 7, 8, 13, 35, 35, 61, 84, 214, 782, 1215, 756, 377, 194, 92, 33, 10, 374]; at the lowest 88, at the highest 374
directional, penalty reading (b): voxels per chosen penalty (1 to 1e9, half decades) [55, 0, 7, 0, 19, 0, 41, 0, 63, 0, 1702, 0, 1936, 0, 249, 0, 53, 0, 256]; at the lowest 55, at the highest 256
clock check, mean test accuracy of the directional model at one delay: {'0 s': 0.077, '4 s': 0.298, '8 s': 0.126}
fig2de-prediction-accuracy¶
Averaged over subjects and voxels in V1, V2, V3, V3A and V3B, the prediction accuracy on the test data is 0.24 for the static model, 0.39 for the nondirectional motion-energy model and 0.40 for the directional motion-energy model, and the differences are significant (Wilcoxon signed-rank test, p < 0.0001).
Readings: accuracy on (a) the repeat-averaged test signal or (b) the mean over repeats of the single-repeat correlation; subjects combined by (i) pooling voxels or (ii) the mean of the three subject means; penalty chosen on (a) the held-out 10% or (b) five folds. Tolerances 0.024, 0.039, 0.040. The Wilcoxon tests are two-sided.
EXP = {"static": (0.24, 0.024), "nondirectional": (0.39, 0.039), "directional": (0.40, 0.040)}
def acc(s, m, rd, pen="a"):
return FIT[s][m]["acc_" + pen][rd]
def pooled(m, rd, pen="a"):
return np.concatenate([acc(s, m, rd, pen) for s in SUBJECTS])
fig2de = {}
for pen in ("a", "b"):
for rd in ("avg", "rep", "rv"):
p_ds = stats.wilcoxon(pooled("directional", rd, pen), pooled("static", rd, pen)).pvalue
p_dn = stats.wilcoxon(pooled("directional", rd, pen), pooled("nondirectional", rd, pen)).pvalue
for comb in ("pooled", "subject means"):
if comb == "pooled":
means = {m: float(pooled(m, rd, pen).mean()) for m in MODELS}
else:
means = {m: float(np.mean([acc(s, m, rd, pen).mean() for s in SUBJECTS])) for m in MODELS}
within = all(abs(means[m] - EXP[m][0]) <= EXP[m][1] for m in MODELS)
order = means["static"] < means["nondirectional"] < means["directional"]
fig2de[(pen, rd, comb)] = dict(means=means, within=within, order=order, p_ds=p_ds, p_dn=p_dn)
lab = {"avg": "(a) repeat mean", "rep": "(b) single repeats", "rv": "check: stored rv"}[rd]
print(f"penalty ({pen}), signal {lab}, ({'i' if comb == 'pooled' else 'ii'}) {comb}: "
+ ", ".join(f"{m} {means[m]:.3f}" for m in MODELS)
+ f"; within tolerance {within}; order {order}; Wilcoxon dir vs static p = {p_ds:.1e}, dir vs nondir p = {p_dn:.1e}")
print()
print("Distance of the static mean from the lower bound 0.216, reading (a) signal, (i) pooled:",
{pen: round(fig2de[(pen, "avg", "pooled")]["means"]["static"] - 0.216, 4) for pen in ("a", "b")})
print("Per subject, penalty (a), signal (a):")
for s in SUBJECTS:
ps = stats.wilcoxon(acc(s, "directional", "avg"), acc(s, "static", "avg")).pvalue
pn = stats.wilcoxon(acc(s, "directional", "avg"), acc(s, "nondirectional", "avg")).pvalue
print(f" S{s} (n = {len(acc(s, 'static', 'avg'))} voxels): " + ", ".join(f"{m} {acc(s, m, 'avg').mean():.3f}" for m in MODELS)
+ f"; p dir-static {ps:.1e}, dir-nondir {pn:.1e}")
print("Null reference: a voxel's correlation on 486 samples exceeds this by chance with p < 0.01 (two-sided):",
round(float(stats.norm.ppf(0.995) / np.sqrt(486 - 3)), 3))
print("Range of voxel accuracies (penalty a, signal a, pooled):", {m: (round(float(pooled(m, 'avg').min()), 3), round(float(pooled(m, 'avg').max()), 3)) for m in MODELS})
penalty (a), signal (a) repeat mean, (i) pooled: static 0.211, nondirectional 0.370, directional 0.373; within tolerance False; order True; Wilcoxon dir vs static p = 0.0e+00, dir vs nondir p = 0.0e+00
penalty (a), signal (a) repeat mean, (ii) subject means: static 0.212, nondirectional 0.370, directional 0.373; within tolerance False; order True; Wilcoxon dir vs static p = 0.0e+00, dir vs nondir p = 0.0e+00
penalty (a), signal (b) single repeats, (i) pooled: static 0.118, nondirectional 0.205, directional 0.207; within tolerance False; order True; Wilcoxon dir vs static p = 0.0e+00, dir vs nondir p = 0.0e+00
penalty (a), signal (b) single repeats, (ii) subject means: static 0.118, nondirectional 0.205, directional 0.207; within tolerance False; order True; Wilcoxon dir vs static p = 0.0e+00, dir vs nondir p = 0.0e+00
penalty (a), signal check: stored rv, (i) pooled: static 0.209, nondirectional 0.367, directional 0.371; within tolerance False; order True; Wilcoxon dir vs static p = 0.0e+00, dir vs nondir p = 0.0e+00
penalty (a), signal check: stored rv, (ii) subject means: static 0.210, nondirectional 0.367, directional 0.371; within tolerance False; order True; Wilcoxon dir vs static p = 0.0e+00, dir vs nondir p = 0.0e+00
penalty (b), signal (a) repeat mean, (i) pooled: static 0.233, nondirectional 0.384, directional 0.386; within tolerance True; order True; Wilcoxon dir vs static p = 0.0e+00, dir vs nondir p = 1.1e-22
penalty (b), signal (a) repeat mean, (ii) subject means: static 0.234, nondirectional 0.384, directional 0.386; within tolerance True; order True; Wilcoxon dir vs static p = 0.0e+00, dir vs nondir p = 1.1e-22
penalty (b), signal (b) single repeats, (i) pooled: static 0.128, nondirectional 0.211, directional 0.212; within tolerance False; order True; Wilcoxon dir vs static p = 0.0e+00, dir vs nondir p = 4.5e-22
penalty (b), signal (b) single repeats, (ii) subject means: static 0.128, nondirectional 0.211, directional 0.212; within tolerance False; order True; Wilcoxon dir vs static p = 0.0e+00, dir vs nondir p = 4.5e-22
penalty (b), signal check: stored rv, (i) pooled: static 0.232, nondirectional 0.381, directional 0.384; within tolerance True; order True; Wilcoxon dir vs static p = 0.0e+00, dir vs nondir p = 6.9e-24
penalty (b), signal check: stored rv, (ii) subject means: static 0.232, nondirectional 0.381, directional 0.383; within tolerance True; order True; Wilcoxon dir vs static p = 0.0e+00, dir vs nondir p = 6.9e-24
Distance of the static mean from the lower bound 0.216, reading (a) signal, (i) pooled: {'a': -0.0049, 'b': 0.0174}
Per subject, penalty (a), signal (a):
S1 (n = 4004 voxels): static 0.216, nondirectional 0.376, directional 0.376; p dir-static 0.0e+00, dir-nondir 2.5e-03
S2 (n = 4622 voxels): static 0.198, nondirectional 0.391, directional 0.398; p dir-static 0.0e+00, dir-nondir 0.0e+00
S3 (n = 4381 voxels): static 0.221, nondirectional 0.342, directional 0.345; p dir-static 0.0e+00, dir-nondir 1.0e-15
Null reference: a voxel's correlation on 486 samples exceeds this by chance with p < 0.01 (two-sided): 0.117
Range of voxel accuracies (penalty a, signal a, pooled): {'static': (-0.239, 0.667), 'nondirectional': (-0.306, 0.835), 'directional': (-0.322, 0.837)}
Result: reproduced, under penalty reading (b), resting on ridge regression in place of L1. With the penalty chosen by five-fold cross-validation (penalty reading b) and the repeat-averaged test signal (signal reading a), the pooled means are 0.233 (static), 0.384 (nondirectional) and 0.386 (directional), each within its tolerance of 0.24, 0.39 and 0.40, in the paper's order, with both paired Wilcoxon tests at p below 0.0001 (directional against nondirectional p = 1.3e-22; against static printed as 0). The mean of subject means gives 0.234, 0.384 and 0.386. With the penalty chosen on the single held-out 10% (penalty reading a) the means are 0.211, 0.370 and 0.373: order and tests hold, but the static mean is 0.005 below its lower bound of 0.216, which alone would be partially reproduced. Single repeats (signal reading b) give about half (0.118 to 0.128 static, 0.207 to 0.212 directional), outside tolerance under both penalty readings. The stored repeat mean rv gives the same values as the z-scored repeats to within 0.003. The outcome rests on two choices the paper leaves open: ridge in place of L1, and the penalty reading. The L1 check below bears on both.
Sensitivity to the fit: L1 on a voxel subsample¶
The paper fits by L1-regularized least squares (Model Fitting, refs. 15 and 16), which is too slow here for all 13,007 voxels. As a check of how far the ridge means of fig2de may move, the static and directional models are fit by L1 on 40 voxels drawn at random per subject (120 voxels). The solver is accelerated proximal gradient (FISTA, vim2.lasso_path), along a path of seven penalties from 0.5 to 0.01 times the smallest penalty that zeroes every weight, each warm-started from the last and run for 60 iterations; the paper gives no stopping rule, so this is an approximate L1 fit, stopped early, and the relative change of the objective over the last iterations is printed. The penalty of each voxel is chosen on the held-out 10% (penalty reading a) and the model refit on all training samples along the same path. The L1 accuracies are compared with the ridge accuracies of the same voxels (both penalty readings, signal reading a).
t = time.time()
D = FEAT["directional"]
rng_l1 = np.random.default_rng([SEED, 30])
FR = np.logspace(np.log10(0.5), np.log10(0.01), 7)
st_idx = np.array([i for i, f in enumerate(filters) if f["temporal_freq"] == 0])
L1_COLS = {"static": np.concatenate([j * len(filters) + st_idx for j in range(len(vim2.DELAYS))]), "directional": None}
pick = {s: np.sort(rng_l1.choice(len(DATA[s]["Y"][0]), 40, replace=False)) for s in SUBJECTS}
Ysub = np.concatenate([DATA[s]["Y"][:, pick[s]] for s in SUBJECTS], 1)
Ytes = np.concatenate([DATA[s]["Yte"][:, pick[s]] for s in SUBJECTS], 1)
L1 = {}
for m, ci in L1_COLS.items():
X = D["X"] if ci is None else D["X"][:, ci]
Xe = D["Xe"] if ci is None else D["Xe"][:, ci]
out_h, info_h = vim2.lasso_path(X[~held], Ysub[~held], [X[held]], FR, 60)
rh = np.stack([vim2.corr_cols(o[0], Ysub[held]) for o in out_h])
out_f, info_f = vim2.lasso_path(X, Ysub, [Xe], FR, 60)
rt_ = np.stack([vim2.corr_cols(o[0], Ytes) for o in out_f])
L1[m] = rt_[rh.argmax(0), np.arange(Ysub.shape[1])]
ridge = {pen: np.concatenate([acc(s, m, "avg", pen)[pick[s]] for s in SUBJECTS]) for pen in ("a", "b")}
print(f"{m} ({X.shape[1]} regressors): voxels per chosen L1 penalty (0.5 to 0.01 of the largest) {np.bincount(rh.argmax(0), minlength=len(FR)).tolist()}")
print(f" median relative change of the objective over the last 6 iterations, per penalty: 90% fit {np.round(info_h['rel_change_last_10pct'], 4).tolist()}, full fit {np.round(info_f['rel_change_last_10pct'], 4).tolist()}; "
f"nonzero weights at the smallest penalty (min, median, max) {info_f['nonzero_at_last']}")
for pen in ("a", "b"):
dd = L1[m] - ridge[pen]
print(f" mean test accuracy over the 120 voxels: L1 {L1[m].mean():.3f}, ridge penalty ({pen}) {ridge[pen].mean():.3f}; L1 - ridge {dd.mean():+.4f} "
f"(per subject {[round(float(dd[40 * k:40 * k + 40].mean()), 4) for k in range(3)]}); L1 better in {np.mean(dd > 0):.2f} of voxels; Wilcoxon p = {stats.wilcoxon(L1[m], ridge[pen]).pvalue:.1e}")
del X, Xe, out_h, out_f
for pen in ("a", "b"):
shift = L1["static"].mean() - np.concatenate([acc(s, "static", "avg", pen)[pick[s]] for s in SUBJECTS]).mean()
print(f"static mean of all voxels under ridge penalty ({pen}) {fig2de[(pen, 'avg', 'pooled')]['means']['static']:.3f}; shifted by the subsample's L1 - ridge difference {shift:+.4f}: "
f"{fig2de[(pen, 'avg', 'pooled')]['means']['static'] + shift:.3f} (tolerance 0.216 to 0.264)")
print(f"L1 check in {time.time() - t:.0f} s")
static (5700 regressors): voxels per chosen L1 penalty (0.5 to 0.01 of the largest) [30, 18, 24, 15, 9, 9, 15] median relative change of the objective over the last 6 iterations, per penalty: 90% fit [0.0001, 0.0004, 0.0015, 0.0037, 0.006, 0.0076, 0.0084], full fit [0.0001, 0.0003, 0.0012, 0.0033, 0.0054, 0.0068, 0.0075]; nonzero weights at the smallest penalty (min, median, max) (3471, 4914, 5385) mean test accuracy over the 120 voxels: L1 0.243, ridge penalty (a) 0.218; L1 - ridge +0.0244 (per subject [0.029, 0.0303, 0.014]); L1 better in 0.60 of voxels; Wilcoxon p = 3.0e-04 mean test accuracy over the 120 voxels: L1 0.243, ridge penalty (b) 0.238; L1 - ridge +0.0048 (per subject [0.0043, 0.0062, 0.0039]); L1 better in 0.50 of voxels; Wilcoxon p = 3.5e-01
directional (26220 regressors): voxels per chosen L1 penalty (0.5 to 0.01 of the largest) [19, 21, 26, 24, 20, 6, 4] median relative change of the objective over the last 6 iterations, per penalty: 90% fit [0.0002, 0.0004, 0.0007, 0.0018, 0.0046, 0.008, 0.0107], full fit [0.0002, 0.0004, 0.0006, 0.0015, 0.0039, 0.0071, 0.0094]; nonzero weights at the smallest penalty (min, median, max) (10374, 19554, 24432) mean test accuracy over the 120 voxels: L1 0.416, ridge penalty (a) 0.391; L1 - ridge +0.0253 (per subject [0.0258, 0.0325, 0.0176]); L1 better in 0.78 of voxels; Wilcoxon p = 4.1e-11 mean test accuracy over the 120 voxels: L1 0.416, ridge penalty (b) 0.405; L1 - ridge +0.0110 (per subject [0.0133, 0.0107, 0.0089]); L1 better in 0.72 of voxels; Wilcoxon p = 1.1e-04 static mean of all voxels under ridge penalty (a) 0.211; shifted by the subsample's L1 - ridge difference +0.0244: 0.236 (tolerance 0.216 to 0.264) static mean of all voxels under ridge penalty (b) 0.233; shifted by the subsample's L1 - ridge difference +0.0048: 0.238 (tolerance 0.216 to 0.264) L1 check in 316 s
Result of the check. On the 120 voxels, the approximate L1 fit predicts better than ridge. Static model: L1 0.243 against ridge 0.218 under penalty reading (a) (+0.025, Wilcoxon p = 2.9e-04, better in 60% of voxels) and 0.238 under reading (b) (+0.005, p = 0.35). Directional model: L1 0.416 against 0.391 under (a) (+0.025, p = 4.1e-11) and 0.405 under (b) (+0.011, p = 1.1e-04). The L1 gain is positive in each subject. Shifting the static mean of all voxels by the subsample's L1 minus ridge difference gives 0.236 under reading (a) and 0.238 under reading (b), both inside the tolerance of 0.216 to 0.264. The fit is approximate: at the smallest penalties the objective still changes by about 1% over the last 6 iterations, and most weights are nonzero there; few voxels chose those penalties (15 and 4 of 120). The check suggests that the ridge fit, if anything, lowers the means compared with L1, and that under L1 the static mean would lie inside its tolerance under either penalty reading. It is a subsample of 120 voxels, not a test of the claim, and no outcome rests on it.
fig2e-directional-gain-small¶
The directional model predicts better than the nondirectional model, but the difference is small, which suggests that BOLD signals carry spatially localized but mostly nondirectional motion information.
Reproduced when the directional mean exceeds the nondirectional mean, the paired Wilcoxon test gives p < 0.0001, and the difference is less than a tenth of the gain of the nondirectional model over the static model.
for (pen, rd, comb), v in fig2de.items():
mm = v["means"]
gain_dir = mm["directional"] - mm["nondirectional"]
gain_motion = mm["nondirectional"] - mm["static"]
ok = gain_dir > 0 and v["p_dn"] < 1e-4 and gain_dir < 0.1 * gain_motion
print(f"penalty ({pen}), signal {rd}, {comb}: directional - nondirectional = {gain_dir:.4f}; nondirectional - static = {gain_motion:.4f}; "
f"ratio {gain_dir / gain_motion:.3f}; Wilcoxon p = {v['p_dn']:.1e}; criterion met {ok}")
for s in SUBJECTS:
dd = acc(s, "directional", "avg") - acc(s, "nondirectional", "avg")
print(f" S{s}, penalty (a), signal (a): mean difference {dd.mean():.4f}, fraction of voxels with directional better {np.mean(dd > 0):.2f}")
penalty (a), signal avg, pooled: directional - nondirectional = 0.0034; nondirectional - static = 0.1589; ratio 0.021; Wilcoxon p = 0.0e+00; criterion met True penalty (a), signal avg, subject means: directional - nondirectional = 0.0033; nondirectional - static = 0.1583; ratio 0.021; Wilcoxon p = 0.0e+00; criterion met True penalty (a), signal rep, pooled: directional - nondirectional = 0.0016; nondirectional - static = 0.0876; ratio 0.019; Wilcoxon p = 0.0e+00; criterion met True penalty (a), signal rep, subject means: directional - nondirectional = 0.0016; nondirectional - static = 0.0872; ratio 0.018; Wilcoxon p = 0.0e+00; criterion met True penalty (a), signal rv, pooled: directional - nondirectional = 0.0034; nondirectional - static = 0.1580; ratio 0.022; Wilcoxon p = 0.0e+00; criterion met True penalty (a), signal rv, subject means: directional - nondirectional = 0.0033; nondirectional - static = 0.1574; ratio 0.021; Wilcoxon p = 0.0e+00; criterion met True penalty (b), signal avg, pooled: directional - nondirectional = 0.0024; nondirectional - static = 0.1504; ratio 0.016; Wilcoxon p = 1.1e-22; criterion met True penalty (b), signal avg, subject means: directional - nondirectional = 0.0023; nondirectional - static = 0.1499; ratio 0.015; Wilcoxon p = 1.1e-22; criterion met True penalty (b), signal rep, pooled: directional - nondirectional = 0.0011; nondirectional - static = 0.0831; ratio 0.013; Wilcoxon p = 4.5e-22; criterion met True penalty (b), signal rep, subject means: directional - nondirectional = 0.0010; nondirectional - static = 0.0828; ratio 0.012; Wilcoxon p = 4.5e-22; criterion met True penalty (b), signal rv, pooled: directional - nondirectional = 0.0024; nondirectional - static = 0.1494; ratio 0.016; Wilcoxon p = 6.9e-24; criterion met True penalty (b), signal rv, subject means: directional - nondirectional = 0.0024; nondirectional - static = 0.1490; ratio 0.016; Wilcoxon p = 6.9e-24; criterion met True S1, penalty (a), signal (a): mean difference 0.0002, fraction of voxels with directional better 0.53 S2, penalty (a), signal (a): mean difference 0.0061, fraction of voxels with directional better 0.62 S3, penalty (a), signal (a): mean difference 0.0034, fraction of voxels with directional better 0.55
Result: reproduced. Directional minus nondirectional accuracy is 0.0010 to 0.0034 against a nondirectional gain over static of 0.083 to 0.159, ratios of 0.012 to 0.022, all under the bound of 0.1, with Wilcoxon p below 0.0001 (largest 5.2e-22), under every reading of penalty, test signal and subject combination. The directional model is better in 53%, 62% and 55% of voxels of S1, S2 and S3 (penalty and signal reading a).
figs1a-motion-better-every-area¶
In each of the five visual areas and each of the three subjects, both motion models predict better than the static model, and the best predictions are in V1 for all three subjects (Wilcoxon rank-sum test, p < 0.0001).
Mean accuracy per model, area and subject (penalty reading a; signal reading a, with b shown too). Rank-sum readings: (a) V1 against each other area in turn; (b) V1 against the other four pooled. Model readings: (i) directional; (ii) each of the three models. The rank-sum p-values are given one-sided (V1 greater, as the claim is that V1 is best) and two-sided; the pass counts are given for both.
AREAS = vim2.AREAS
for rd in ("avg", "rep"):
print(f"=== test-signal reading {rd}")
n_cells = n_beat = 0
v1_best = {}
for s in SUBJECTS:
area = DATA[s]["area"]
for ar in AREAS:
sel = area == ar
mm = {m: acc(s, m, rd)[sel].mean() for m in MODELS}
beat = mm["nondirectional"] > mm["static"] and mm["directional"] > mm["static"]
n_cells += 1
n_beat += beat
print(f" S{s} {ar:4s} n={sel.sum():4d}: " + ", ".join(f"{m} {mm[m]:.3f}" for m in MODELS) + f"; both motion > static {beat}")
for m in MODELS:
a = acc(s, m, rd)
means = {ar: a[area == ar].mean() for ar in AREAS}
best = max(means, key=means.get)
v1 = a[area == "v1"]
p1 = {ar: stats.ranksums(v1, a[area == ar], alternative="greater").pvalue for ar in AREAS[1:]}
p2 = {ar: stats.ranksums(v1, a[area == ar]).pvalue for ar in AREAS[1:]}
q1 = stats.ranksums(v1, a[area != "v1"], alternative="greater").pvalue
q2 = stats.ranksums(v1, a[area != "v1"]).pvalue
v1_best[(s, m)] = (best == "v1", max(p1.values()) < 1e-4, q1 < 1e-4, max(p2.values()) < 1e-4, q2 < 1e-4)
print(f" S{s} {m}: best area {best}; rank-sum V1 > each other area, largest p one-sided {max(p1.values()):.1e}, two-sided {max(p2.values()):.1e} "
f"({ {k: f'{v:.0e}' for k, v in p1.items()} }); V1 > other four pooled p one-sided {q1:.1e}, two-sided {q2:.1e}")
print(f" cells where both motion models beat static: {n_beat} of {n_cells}")
for m in MODELS:
for k, lab in ((1, "(a) each area, one-sided"), (2, "(b) pooled, one-sided"), (3, "(a) each area, two-sided"), (4, "(b) pooled, two-sided")):
n_ok = sum(v1_best[(s, m)][0] and v1_best[(s, m)][k] for s in SUBJECTS)
print(f" {m}, rank-sum reading {lab}: subjects with V1 best and p < 0.0001: {n_ok} of 3")
=== test-signal reading avg
S1 v1 n= 969: static 0.302, nondirectional 0.472, directional 0.471; both motion > static True
S1 v2 n=1418: static 0.213, nondirectional 0.363, directional 0.361; both motion > static True
S1 v3 n=1109: static 0.180, nondirectional 0.314, directional 0.315; both motion > static True
S1 v3a n= 252: static 0.153, nondirectional 0.413, directional 0.418; both motion > static True
S1 v3b n= 256: static 0.131, nondirectional 0.320, directional 0.329; both motion > static True
S1 static: best area v1; rank-sum V1 > each other area, largest p one-sided 1.2e-28, two-sided 2.4e-28 ({'v2': '7e-29', 'v3': '2e-46', 'v3a': '1e-28', 'v3b': '5e-37'}); V1 > other four pooled p one-sided 5.8e-57, two-sided 1.2e-56
S1 nondirectional: best area v1; rank-sum V1 > each other area, largest p one-sided 3.5e-05, two-sided 7.1e-05 ({'v2': '5e-25', 'v3': '2e-43', 'v3a': '4e-05', 'v3b': '4e-20'}); V1 > other four pooled p one-sided 6.1e-42, two-sided 1.2e-41
S1 directional: best area v1; rank-sum V1 > each other area, largest p one-sided 4.1e-04, two-sided 8.2e-04 ({'v2': '9e-25', 'v3': '8e-42', 'v3a': '4e-04', 'v3b': '7e-18'}); V1 > other four pooled p one-sided 6.4e-40, two-sided 1.3e-39
S2 v1 n=1043: static 0.236, nondirectional 0.447, directional 0.451; both motion > static True
S2 v2 n=1659: static 0.211, nondirectional 0.401, directional 0.407; both motion > static True
S2 v3 n=1360: static 0.181, nondirectional 0.359, directional 0.365; both motion > static True
S2 v3a n= 337: static 0.138, nondirectional 0.368, directional 0.382; both motion > static True
S2 v3b n= 223: static 0.108, nondirectional 0.294, directional 0.297; both motion > static True
S2 static: best area v1; rank-sum V1 > each other area, largest p one-sided 3.4e-05, two-sided 6.8e-05 ({'v2': '3e-05', 'v3': '1e-18', 'v3a': '4e-26', 'v3b': '2e-30'}); V1 > other four pooled p one-sided 1.7e-20, two-sided 3.4e-20
S2 nondirectional: best area v1; rank-sum V1 > each other area, largest p one-sided 2.3e-06, two-sided 4.6e-06 ({'v2': '2e-06', 'v3': '4e-22', 'v3a': '1e-11', 'v3b': '3e-22'}); V1 > other four pooled p one-sided 8.3e-20, two-sided 1.7e-19
S2 directional: best area v1; rank-sum V1 > each other area, largest p one-sided 8.1e-06, two-sided 1.6e-05 ({'v2': '8e-06', 'v3': '1e-20', 'v3a': '1e-09', 'v3b': '2e-22'}); V1 > other four pooled p one-sided 3.3e-18, two-sided 6.6e-18
S3 v1 n=1366: static 0.283, nondirectional 0.379, directional 0.379; both motion > static True
S3 v2 n=1377: static 0.217, nondirectional 0.339, directional 0.342; both motion > static True
S3 v3 n=1131: static 0.192, nondirectional 0.323, directional 0.328; both motion > static True
S3 v3a n= 281: static 0.153, nondirectional 0.350, directional 0.357; both motion > static True
S3 v3b n= 226: static 0.093, nondirectional 0.224, directional 0.231; both motion > static True
S3 static: best area v1; rank-sum V1 > each other area, largest p one-sided 7.1e-20, two-sided 1.4e-19 ({'v2': '7e-20', 'v3': '3e-33', 'v3a': '1e-25', 'v3b': '4e-41'}); V1 > other four pooled p one-sided 3.8e-48, two-sided 7.5e-48
S3 nondirectional: best area v1; rank-sum V1 > each other area, largest p one-sided 1.2e-02, two-sided 2.4e-02 ({'v2': '7e-06', 'v3': '2e-09', 'v3a': '1e-02', 'v3b': '4e-18'}); V1 > other four pooled p one-sided 2.8e-12, two-sided 5.6e-12
S3 directional: best area v1; rank-sum V1 > each other area, largest p one-sided 3.8e-02, two-sided 7.5e-02 ({'v2': '3e-05', 'v3': '5e-08', 'v3a': '4e-02', 'v3b': '7e-17'}); V1 > other four pooled p one-sided 1.3e-10, two-sided 2.6e-10
cells where both motion models beat static: 15 of 15
static, rank-sum reading (a) each area, one-sided: subjects with V1 best and p < 0.0001: 3 of 3
static, rank-sum reading (b) pooled, one-sided: subjects with V1 best and p < 0.0001: 3 of 3
static, rank-sum reading (a) each area, two-sided: subjects with V1 best and p < 0.0001: 3 of 3
static, rank-sum reading (b) pooled, two-sided: subjects with V1 best and p < 0.0001: 3 of 3
nondirectional, rank-sum reading (a) each area, one-sided: subjects with V1 best and p < 0.0001: 2 of 3
nondirectional, rank-sum reading (b) pooled, one-sided: subjects with V1 best and p < 0.0001: 3 of 3
nondirectional, rank-sum reading (a) each area, two-sided: subjects with V1 best and p < 0.0001: 2 of 3
nondirectional, rank-sum reading (b) pooled, two-sided: subjects with V1 best and p < 0.0001: 3 of 3
directional, rank-sum reading (a) each area, one-sided: subjects with V1 best and p < 0.0001: 1 of 3
directional, rank-sum reading (b) pooled, one-sided: subjects with V1 best and p < 0.0001: 3 of 3
directional, rank-sum reading (a) each area, two-sided: subjects with V1 best and p < 0.0001: 1 of 3
directional, rank-sum reading (b) pooled, two-sided: subjects with V1 best and p < 0.0001: 3 of 3
=== test-signal reading rep
S1 v1 n= 969: static 0.182, nondirectional 0.282, directional 0.281; both motion > static True
S1 v2 n=1418: static 0.121, nondirectional 0.202, directional 0.201; both motion > static True
S1 v3 n=1109: static 0.098, nondirectional 0.169, directional 0.170; both motion > static True
S1 v3a n= 252: static 0.092, nondirectional 0.240, directional 0.244; both motion > static True
S1 v3b n= 256: static 0.069, nondirectional 0.167, directional 0.172; both motion > static True
S1 static: best area v1; rank-sum V1 > each other area, largest p one-sided 6.8e-20, two-sided 1.4e-19 ({'v2': '2e-26', 'v3': '4e-43', 'v3a': '7e-20', 'v3b': '3e-31'}); V1 > other four pooled p one-sided 3.1e-50, two-sided 6.2e-50
S1 nondirectional: best area v1; rank-sum V1 > each other area, largest p one-sided 3.0e-03, two-sided 6.0e-03 ({'v2': '9e-23', 'v3': '7e-39', 'v3a': '3e-03', 'v3b': '1e-16'}); V1 > other four pooled p one-sided 1.7e-36, two-sided 3.5e-36
S1 directional: best area v1; rank-sum V1 > each other area, largest p one-sided 7.2e-03, two-sided 1.4e-02 ({'v2': '7e-23', 'v3': '4e-38', 'v3a': '7e-03', 'v3b': '3e-15'}); V1 > other four pooled p one-sided 1.3e-35, two-sided 2.6e-35
S2 v1 n=1043: static 0.143, nondirectional 0.270, directional 0.272; both motion > static True
S2 v2 n=1659: static 0.127, nondirectional 0.239, directional 0.242; both motion > static True
S2 v3 n=1360: static 0.099, nondirectional 0.197, directional 0.200; both motion > static True
S2 v3a n= 337: static 0.073, nondirectional 0.200, directional 0.207; both motion > static True
S2 v3b n= 223: static 0.054, nondirectional 0.150, directional 0.152; both motion > static True
S2 static: best area v1; rank-sum V1 > each other area, largest p one-sided 1.1e-05, two-sided 2.3e-05 ({'v2': '1e-05', 'v3': '3e-23', 'v3a': '5e-24', 'v3b': '2e-29'}); V1 > other four pooled p one-sided 1.1e-22, two-sided 2.1e-22
S2 nondirectional: best area v1; rank-sum V1 > each other area, largest p one-sided 3.3e-06, two-sided 6.6e-06 ({'v2': '3e-06', 'v3': '3e-23', 'v3a': '1e-09', 'v3b': '2e-19'}); V1 > other four pooled p one-sided 2.7e-19, two-sided 5.5e-19
S2 directional: best area v1; rank-sum V1 > each other area, largest p one-sided 5.7e-06, two-sided 1.1e-05 ({'v2': '6e-06', 'v3': '2e-22', 'v3a': '2e-08', 'v3b': '1e-19'}); V1 > other four pooled p one-sided 2.2e-18, two-sided 4.3e-18
S3 v1 n=1366: static 0.152, nondirectional 0.205, directional 0.205; both motion > static True
S3 v2 n=1377: static 0.113, nondirectional 0.176, directional 0.178; both motion > static True
S3 v3 n=1131: static 0.095, nondirectional 0.160, directional 0.162; both motion > static True
S3 v3a n= 281: static 0.075, nondirectional 0.169, directional 0.173; both motion > static True
S3 v3b n= 226: static 0.041, nondirectional 0.094, directional 0.097; both motion > static True
S3 static: best area v1; rank-sum V1 > each other area, largest p one-sided 3.6e-15, two-sided 7.2e-15 ({'v2': '4e-15', 'v3': '4e-27', 'v3a': '6e-20', 'v3b': '3e-39'}); V1 > other four pooled p one-sided 8.1e-39, two-sided 1.6e-38
S3 nondirectional: best area v1; rank-sum V1 > each other area, largest p one-sided 1.1e-02, two-sided 2.2e-02 ({'v2': '1e-05', 'v3': '5e-09', 'v3a': '1e-02', 'v3b': '1e-18'}); V1 > other four pooled p one-sided 6.2e-12, two-sided 1.2e-11
S3 directional: best area v1; rank-sum V1 > each other area, largest p one-sided 2.8e-02, two-sided 5.6e-02 ({'v2': '3e-05', 'v3': '5e-08', 'v3a': '3e-02', 'v3b': '2e-17'}); V1 > other four pooled p one-sided 9.6e-11, two-sided 1.9e-10
cells where both motion models beat static: 15 of 15
static, rank-sum reading (a) each area, one-sided: subjects with V1 best and p < 0.0001: 3 of 3
static, rank-sum reading (b) pooled, one-sided: subjects with V1 best and p < 0.0001: 3 of 3
static, rank-sum reading (a) each area, two-sided: subjects with V1 best and p < 0.0001: 3 of 3
static, rank-sum reading (b) pooled, two-sided: subjects with V1 best and p < 0.0001: 3 of 3
nondirectional, rank-sum reading (a) each area, one-sided: subjects with V1 best and p < 0.0001: 1 of 3
nondirectional, rank-sum reading (b) pooled, one-sided: subjects with V1 best and p < 0.0001: 3 of 3
nondirectional, rank-sum reading (a) each area, two-sided: subjects with V1 best and p < 0.0001: 1 of 3
nondirectional, rank-sum reading (b) pooled, two-sided: subjects with V1 best and p < 0.0001: 3 of 3
directional, rank-sum reading (a) each area, one-sided: subjects with V1 best and p < 0.0001: 1 of 3
directional, rank-sum reading (b) pooled, one-sided: subjects with V1 best and p < 0.0001: 3 of 3
directional, rank-sum reading (a) each area, two-sided: subjects with V1 best and p < 0.0001: 1 of 3
directional, rank-sum reading (b) pooled, two-sided: subjects with V1 best and p < 0.0001: 3 of 3
Result: reproduced. Both motion models beat the static model in all 15 area and subject cells under both test-signal readings. V1 has the highest mean in every subject for every model. With V1 against the other four areas pooled (rank-sum reading b), p is below 0.0001 in all three subjects for every model, one-sided or two-sided (largest 2.8e-10, S3 directional, two-sided). With V1 against each other area in turn (reading a), this holds in all three subjects for the static model only; the nondirectional model passes in 2 of 3 subjects and the directional model in 1 of 3. Every failure is V1 against V3A: nondirectional in S3 (one-sided p = 1.2e-02), directional in S1 (4.1e-04) and S3 (3.8e-02). In S2 both motion models pass against every area (largest one-sided p 8.2e-06, V1 against V2, directional).
fig2fgh-retinotopic-receptive-fields¶
Voxel receptive fields estimated from the motion-energy model are spatially localized and retinotopically organized; their angle maps are similar to those from conventional multifocal mapping, and their eccentricity maps are similar except in the far periphery, where the multifocal mapping stimulus was coarse.
Selectivity Estimation: each voxel's directional model (penalty reading a) is driven by dynamic Gaussian white noise in each cell of a 17 x 17 grid on uniform gray, and its predicted response minus the response to uniform gray gives a spatial map, to which a 2D Gaussian is fit (vim2.gaussian_fit). The multifocal maps are not in the data set, so the claims file's proxy test is used: in each subject, more than half of the retained voxels have a fit centered inside the 20 degree display; left-hemisphere V1 centers lie over 75% in the right visual field and the reverse; and eccentricity rises along V1 from the occipital pole forward (positive correlation, p < 0.05). Voxels are retained when the prediction accuracy is positive with p <= 0.01 (two-sided t test of the correlation) on (a) the 486 test samples or (b) the 728 held-out training samples. The posterior-anterior axis is the slice axis of the 64 x 64 x 18 volume (18 coronal slices, Experimental Procedures); its direction is taken from the data, as the direction from the V1 masks to the MT masks, which lie anterior to V1.
rng_rf = np.random.default_rng([SEED, 20])
D = FEAT["directional"]
t = time.time()
noise = vim2.noise_probes(rng_rf)
F_noise = vim2.probe_features(noise, filters, D["mu"], D["sd"], D["cols"])
F_gray = vim2.probe_features([np.full_like(noise[0], vim2.GRAY)], filters, D["mu"], D["sd"], D["cols"])
movies, GLAB = vim2.grating_probes((0, 2, 4, 8, 16, 32), (0, 2, 4), range(0, 360, 45))
F_grat = vim2.probe_features(movies, filters, D["mu"], D["sd"], D["cols"])
del noise, movies
print(f"probe features in {time.time() - t:.0f} s: {len(F_noise)} noise cells, {len(F_grat)} gratings")
RF = {}
for s in SUBJECTS:
f = FIT[s]["directional"]
W = (D["X"].T @ f["C"]).reshape(len(vim2.DELAYS), len(D["cols"]), -1).sum(0) # weights summed over delays
maps = (F_noise - F_gray) @ W
tune = ((F_grat - F_gray) @ W).reshape(6, 3, 8, -1).mean(2) # (spatial freq, temporal freq, voxel)
r0, c0, sig, fit_r = vim2.gaussian_fit(maps.T)
vox = DATA[s]["vox"]
p_test = vim2.corr_pvalue(f["acc_a"]["avg"], 486)
p_held = vim2.corr_pvalue(f["held_acc"], int(held.sum()))
RF[s] = dict(r0=r0, c0=c0, sig=sig, fit_r=fit_r, tune=tune,
keep={"a": (p_test <= 0.01) & (f["acc_a"]["avg"] > 0), "b": (p_held <= 0.01) & (f["held_acc"] > 0)},
inside=(r0 >= -0.5) & (r0 <= 16.5) & (c0 >= -0.5) & (c0 <= 16.5),
ecc=np.hypot(r0 - 8, c0 - 8) * 20 / 17, right=c0 > 8, z=vim2.voxel_xyz(vox)[2])
del W, maps
print(f"receptive fields and tuning in {time.time() - t:.0f} s")
probe features in 81 s: 289 noise cells, 144 gratings
receptive fields and tuning in 96 s
DEG = 20 / 17
for s in SUBJECTS:
r = RF[s]
sl = DATA[s]["info"]["roi_mean_slice"]
v1z = np.mean([sl["v1lh"], sl["v1rh"]])
mtz = np.mean([sl[k] for k in ("MTlh", "MTrh") if k in sl])
sign = 1 if mtz > v1z else -1 # +1: slice index grows anteriorly
print(f"--- S{s}: mean slice of the V1 masks {v1z:.1f}, of the MT masks {mtz:.1f}; anterior is {'higher' if sign > 0 else 'lower'} slice index")
for rd in ("a", "b"):
k = r["keep"][rd]
hemi, area = DATA[s]["hemi"], DATA[s]["area"]
frac_in = r["inside"][k].mean()
lh = k & r["inside"] & (area == "v1") & (hemi == "lh")
rh = k & r["inside"] & (area == "v1") & (hemi == "rh")
f_lh, f_rh = r["right"][lh].mean(), 1 - r["right"][rh].mean()
v1 = k & r["inside"] & (area == "v1")
rho, p = stats.pearsonr(r["ecc"][v1], sign * r["z"][v1])
rho_s, p_s = stats.spearmanr(r["ecc"][v1], sign * r["z"][v1])
ok = frac_in > 0.5 and f_lh > 0.75 and f_rh > 0.75 and rho > 0 and p < 0.05
print(f" p-value reading ({rd}): retained {k.sum()} of {len(k)} voxels; fit inside the display {frac_in:.2f}; "
f"fit correlation median {np.median(r['fit_r'][k]):.2f}; Gaussian s.d. median {np.median(r['sig'][k]) * DEG:.1f} deg")
print(f" V1 lh centers in the right field {f_lh:.2f} (n = {lh.sum()}), V1 rh centers in the left field {f_rh:.2f} (n = {rh.sum()})")
print(f" V1 eccentricity against anterior position: Pearson r = {rho:.3f} (p = {p:.1e}), Spearman {rho_s:.3f} (p = {p_s:.1e}), n = {v1.sum()}; "
f"eccentricity range {r['ecc'][v1].min():.1f} to {r['ecc'][v1].max():.1f} deg; all three conditions met {ok}")
for ar in ("v2", "v3"):
k = r["keep"]["a"] & r["inside"] & (DATA[s]["area"] == ar)
f_lh = r["right"][k & (DATA[s]["hemi"] == "lh")].mean()
f_rh = 1 - r["right"][k & (DATA[s]["hemi"] == "rh")].mean()
print(f" {ar} (reading a, for reference): lh centers in the right field {f_lh:.2f}, rh in the left {f_rh:.2f}")
fig, ax = plt.subplots(1, 3, figsize=(12, 3.6))
for a, s in zip(ax, SUBJECTS):
r = RF[s]
k = r["keep"]["a"] & (DATA[s]["area"] == "v1")
for h, col in (("lh", "tab:blue"), ("rh", "tab:red")):
kk = k & (DATA[s]["hemi"] == h)
a.scatter((r["c0"][kk] - 8) * DEG, (8 - r["r0"][kk]) * DEG, s=3, c=col, label=f"V1 {h}")
a.add_patch(plt.Rectangle((-10, -10), 20, 20, fill=False))
a.set_xlim(-20, 20); a.set_ylim(-20, 20); a.set_aspect("equal")
a.set_title(f"S{s}: V1 receptive-field centers (deg)", fontsize=9)
n_out = int((k & ((np.abs(r["c0"] - 8) * DEG > 20) | (np.abs(8 - r["r0"]) * DEG > 20))).sum())
a.text(-19, -19, f"{n_out} outside the axes", fontsize=8)
a.legend(fontsize=7, loc="upper right")
plt.show()
--- S1: mean slice of the V1 masks 8.7, of the MT masks 3.4; anterior is lower slice index
p-value reading (a): retained 3036 of 4004 voxels; fit inside the display 0.97; fit correlation median 0.79; Gaussian s.d. median 2.4 deg
V1 lh centers in the right field 0.90 (n = 428), V1 rh centers in the left field 0.91 (n = 383)
V1 eccentricity against anterior position: Pearson r = 0.532 (p = 2.2e-60), Spearman 0.582 (p = 1.4e-74), n = 811; eccentricity range 0.0 to 11.7 deg; all three conditions met True
p-value reading (b): retained 2887 of 4004 voxels; fit inside the display 0.96; fit correlation median 0.79; Gaussian s.d. median 2.4 deg
V1 lh centers in the right field 0.91 (n = 405), V1 rh centers in the left field 0.91 (n = 365)
V1 eccentricity against anterior position: Pearson r = 0.493 (p = 2.6e-48), Spearman 0.544 (p = 1.9e-60), n = 770; eccentricity range 0.0 to 11.7 deg; all three conditions met True
v2 (reading a, for reference): lh centers in the right field 0.80, rh in the left 0.92
v3 (reading a, for reference): lh centers in the right field 0.84, rh in the left 0.90
--- S2: mean slice of the V1 masks 9.9, of the MT masks 3.5; anterior is lower slice index
p-value reading (a): retained 3866 of 4622 voxels; fit inside the display 0.95; fit correlation median 0.81; Gaussian s.d. median 2.4 deg
V1 lh centers in the right field 0.91 (n = 404), V1 rh centers in the left field 0.89 (n = 468)
V1 eccentricity against anterior position: Pearson r = 0.607 (p = 9.2e-89), Spearman 0.624 (p = 4.0e-95), n = 872; eccentricity range 0.0 to 12.1 deg; all three conditions met True
p-value reading (b): retained 3635 of 4622 voxels; fit inside the display 0.96; fit correlation median 0.82; Gaussian s.d. median 2.4 deg
V1 lh centers in the right field 0.92 (n = 384), V1 rh centers in the left field 0.89 (n = 443)
V1 eccentricity against anterior position: Pearson r = 0.607 (p = 1.7e-84), Spearman 0.624 (p = 1.4e-90), n = 827; eccentricity range 0.0 to 12.1 deg; all three conditions met True
v2 (reading a, for reference): lh centers in the right field 0.82, rh in the left 0.85
v3 (reading a, for reference): lh centers in the right field 0.80, rh in the left 0.81
--- S3: mean slice of the V1 masks 9.8, of the MT masks 4.3; anterior is lower slice index
p-value reading (a): retained 3358 of 4381 voxels; fit inside the display 0.95; fit correlation median 0.82; Gaussian s.d. median 2.4 deg
V1 lh centers in the right field 0.84 (n = 534), V1 rh centers in the left field 0.89 (n = 484)
V1 eccentricity against anterior position: Pearson r = 0.330 (p = 3.1e-27), Spearman 0.319 (p = 1.7e-25), n = 1018; eccentricity range 0.0 to 13.3 deg; all three conditions met True
p-value reading (b): retained 3248 of 4381 voxels; fit inside the display 0.95; fit correlation median 0.82; Gaussian s.d. median 2.4 deg
V1 lh centers in the right field 0.86 (n = 498), V1 rh centers in the left field 0.89 (n = 488)
V1 eccentricity against anterior position: Pearson r = 0.311 (p = 1.5e-23), Spearman 0.303 (p = 2.3e-22), n = 986; eccentricity range 0.0 to 13.7 deg; all three conditions met True
v2 (reading a, for reference): lh centers in the right field 0.81, rh in the left 0.87
v3 (reading a, for reference): lh centers in the right field 0.81, rh in the left 0.89
Result: reproduced on the claims file's proxy test, without the multifocal maps. In each subject 95% to 97% of the retained voxels (3,037, 3,867 and 3,358 under p-value reading a) have a Gaussian fit centered inside the display (bound: over half). The centers of left-hemisphere V1 voxels lie in the right visual field in 90%, 91% and 84% of cases, and those of right-hemisphere V1 voxels in the left field in 91%, 89% and 89% (bound: over 75%). V1 eccentricity rises from the occipital pole forward, Pearson r = 0.535, 0.607 and 0.330 (p = 2.6e-61, 7.3e-89 and 2.9e-27). Reading b of the p-value gives the same pass in every subject (contralateral fractions 0.86 to 0.92, r = 0.312 to 0.607). The similarity of the angle and eccentricity maps to multifocal mapping, which the statement also asserts, could not be tested: the mapping data are not in the data set and not public.
fig2j-speed-eccentricity¶
Optimal speed (peak temporal frequency over peak spatial frequency) correlates positively with eccentricity, so peripheral voxels prefer higher speeds, in V1, V2 and V3 of all three subjects (t test for correlation coefficient, p < 0.0001).
Tuning from the directional model's predicted responses to full-field drifting gratings at the basis set's spatial frequencies (0 to 32 cycles/image), temporal frequencies (0, 2, 4 Hz) and eight directions, averaged over directions, minus the response to uniform gray (Selectivity Estimation). Peaks: (a) the maximum of the joint map; (b) the maximum of each marginal curve. Speed is the peak temporal frequency over the peak spatial frequency in cycles per degree (cycles per image / 20). Voxels with prediction p > 0.01 (readings a and b as above) or optimal spatial frequency 0 are left out; eccentricity is that of the Gaussian fit, for fits centered inside the display.
SF = np.array([0, 2, 4, 8, 16, 32]) / 20.0
TF = np.array([0, 2, 4])
res_j = {}
for pk in ("a", "b"):
for prd in ("a", "b"):
n_pos = n_sig = 0
for s in SUBJECTS:
r = RF[s]
tune = r["tune"]
if pk == "a":
flat = tune.reshape(18, -1).argmax(0)
isf, itf = flat // 3, flat % 3
else:
isf, itf = tune.mean(1).argmax(0), tune.mean(0).argmax(0)
speed = np.where(isf > 0, TF[itf] / np.where(isf > 0, SF[isf], 1), np.nan)
for ar in ("v1", "v2", "v3"):
k = r["keep"][prd] & r["inside"] & (DATA[s]["area"] == ar) & (isf > 0)
rho, p = stats.pearsonr(r["ecc"][k], speed[k])
n_pos += rho > 0
n_sig += (rho > 0) and (p < 1e-4)
res_j[(pk, prd, s, ar)] = (rho, p, int(k.sum()))
print(f"peaks ({pk}), p-value ({prd}), S{s} {ar}: n = {k.sum()}, r = {rho:.3f}, p = {p:.1e}; "
f"speed range {np.nanmin(speed[k]):.2f} to {np.nanmax(speed[k]):.2f} deg/s; dropped for spatial frequency 0: {int((r['keep'][prd] & r['inside'] & (DATA[s]['area'] == ar) & (isf == 0)).sum())}")
print(f" peaks ({pk}), p-value ({prd}): positive {n_pos} of 9, positive with p < 0.0001 {n_sig} of 9")
for s in SUBJECTS:
tune = RF[s]["tune"]
flat = tune.reshape(18, -1).argmax(0)
print(f"S{s}: voxels by joint peak (spatial freq c/image, temporal freq Hz):",
dict(collections.Counter((int(SF[i // 3] * 20), int(TF[i % 3])) for i in flat[RF[s]['keep']['a']]).most_common()))
peaks (a), p-value (a), S1 v1: n = 804, r = 0.448, p = 7.3e-41; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 7
peaks (a), p-value (a), S1 v2: n = 1006, r = 0.288, p = 1.0e-20; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 9
peaks (a), p-value (a), S1 v3: n = 735, r = 0.390, p = 4.5e-28; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 6
peaks (a), p-value (a), S2 v1: n = 861, r = 0.355, p = 5.4e-27; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 11
peaks (a), p-value (a), S2 v2: n = 1268, r = 0.361, p = 2.6e-40; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 13
peaks (a), p-value (a), S2 v3: n = 1069, r = 0.216, p = 8.4e-13; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 14
peaks (a), p-value (a), S3 v1: n = 1004, r = 0.446, p = 3.5e-50; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 14
peaks (a), p-value (a), S3 v2: n = 941, r = 0.436, p = 6.3e-45; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 13
peaks (a), p-value (a), S3 v3: n = 820, r = 0.404, p = 1.6e-33; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 20
peaks (a), p-value (a): positive 9 of 9, positive with p < 0.0001 9 of 9
peaks (a), p-value (b), S1 v1: n = 765, r = 0.455, p = 2.3e-40; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 5
peaks (a), p-value (b), S1 v2: n = 908, r = 0.276, p = 2.5e-17; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 11
peaks (a), p-value (b), S1 v3: n = 681, r = 0.297, p = 2.4e-15; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 8
peaks (a), p-value (b), S2 v1: n = 816, r = 0.343, p = 5.4e-24; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 11
peaks (a), p-value (b), S2 v2: n = 1193, r = 0.314, p = 1.1e-28; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 16
peaks (a), p-value (b), S2 v3: n = 992, r = 0.217, p = 4.8e-12; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 15
peaks (a), p-value (b), S3 v1: n = 975, r = 0.457, p = 2.0e-51; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 11
peaks (a), p-value (b), S3 v2: n = 940, r = 0.416, p = 1.3e-40; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 11
peaks (a), p-value (b), S3 v3: n = 786, r = 0.407, p = 1.0e-32; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 15
peaks (a), p-value (b): positive 9 of 9, positive with p < 0.0001 9 of 9
peaks (b), p-value (a), S1 v1: n = 803, r = 0.340, p = 3.7e-23; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 8
peaks (b), p-value (a), S1 v2: n = 1008, r = 0.248, p = 1.5e-15; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 7
peaks (b), p-value (a), S1 v3: n = 737, r = 0.390, p = 3.4e-28; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 4
peaks (b), p-value (a), S2 v1: n = 862, r = 0.260, p = 7.9e-15; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 10
peaks (b), p-value (a), S2 v2: n = 1273, r = 0.290, p = 4.6e-26; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 8
peaks (b), p-value (a), S2 v3: n = 1077, r = 0.267, p = 4.9e-19; speed range 0.00 to 20.00 deg/s; dropped for spatial frequency 0: 6
peaks (b), p-value (a), S3 v1: n = 1004, r = 0.302, p = 1.3e-22; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 14
peaks (b), p-value (a), S3 v2: n = 948, r = 0.329, p = 2.7e-25; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 6
peaks (b), p-value (a), S3 v3: n = 831, r = 0.360, p = 8.1e-27; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 9
peaks (b), p-value (a): positive 9 of 9, positive with p < 0.0001 9 of 9
peaks (b), p-value (b), S1 v1: n = 766, r = 0.281, p = 2.3e-15; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 4
peaks (b), p-value (b), S1 v2: n = 910, r = 0.263, p = 6.7e-16; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 9
peaks (b), p-value (b), S1 v3: n = 684, r = 0.354, p = 1.4e-21; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 5
peaks (b), p-value (b), S2 v1: n = 816, r = 0.264, p = 1.7e-14; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 11
peaks (b), p-value (b), S2 v2: n = 1198, r = 0.280, p = 5.6e-23; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 11
peaks (b), p-value (b), S2 v3: n = 996, r = 0.209, p = 2.8e-11; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 11
peaks (b), p-value (b), S3 v1: n = 976, r = 0.344, p = 1.4e-28; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 10
peaks (b), p-value (b), S3 v2: n = 946, r = 0.315, p = 3.0e-23; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 5
peaks (b), p-value (b), S3 v3: n = 794, r = 0.340, p = 5.9e-23; speed range 0.00 to 40.00 deg/s; dropped for spatial frequency 0: 7
peaks (b), p-value (b): positive 9 of 9, positive with p < 0.0001 9 of 9
S1: voxels by joint peak (spatial freq c/image, temporal freq Hz): {(16, 2): 1113, (8, 2): 716, (32, 0): 409, (16, 4): 251, (32, 2): 216, (16, 0): 87, (8, 4): 75, (2, 0): 67, (32, 4): 25, (4, 2): 19, (0, 4): 15, (0, 2): 9, (4, 4): 7, (2, 2): 7, (0, 0): 6, (2, 4): 5, (4, 0): 5, (8, 0): 4}
S2: voxels by joint peak (spatial freq c/image, temporal freq Hz): {(16, 2): 1170, (8, 2): 1053, (16, 4): 421, (32, 0): 385, (32, 2): 341, (8, 4): 122, (2, 0): 87, (16, 0): 60, (4, 2): 56, (2, 2): 43, (0, 2): 27, (32, 4): 24, (4, 0): 19, (0, 0): 18, (0, 4): 13, (8, 0): 10, (4, 4): 10, (2, 4): 7}
S3: voxels by joint peak (spatial freq c/image, temporal freq Hz): {(16, 2): 1006, (8, 2): 676, (32, 0): 640, (16, 4): 279, (16, 0): 241, (2, 0): 136, (32, 2): 108, (8, 4): 81, (4, 2): 39, (0, 2): 26, (32, 4): 26, (0, 0): 21, (2, 2): 19, (0, 4): 18, (8, 0): 13, (4, 4): 12, (2, 4): 11, (4, 0): 6}
Result: reproduced. Under every reading of the peaks (joint map or marginal curves) and of the p-value, optimal speed correlates positively with eccentricity in all nine area and subject cells with p < 0.0001: joint peaks and p-value reading a give r = 0.216 to 0.450 (largest p 1.0e-12, S2 V3); marginal peaks give r = 0.209 to 0.390 (largest p 2.8e-11). Voxels with an optimal spatial frequency of 0 are few (4 to 20 per cell) and left out.
fig3ab-identification-s1¶
For subject S1 the motion-energy model identifies the test second that evoked an observed BOLD pattern within one volume (1 s) 95% of the time (464 of 486 volumes), far above chance (under 1%, 3 of 486).
The 2,000 V1-V3B voxels whose model fit on 90% of the training data best predicts the held-out 10% are used (Voxel Selection). The likelihood is the multivariate Gaussian of Likelihood Estimation, with the covariance of the training residuals; the Tikhonov penalty is chosen from a grid of quarter decades by identification of the held-out 10% of the training data (claims file, Common methods), using the residuals of the 90% fit. Readings of the model: (a) four delays, (b) a single 4 s delay refit. Readings of the observed signal: (i) the mean of the ten repeats, (ii) each repeat identified on its own, the count averaged over repeats. The encoding penalties are those of reading (a); the four-delay model is also run with the penalties of reading (b) (five-fold cross-validation), refit on 90% for the voxel selection and the Tikhonov choice. Expected 464, tolerance 46.4 (at least 418).
D1 = DATA[1]
Y, Yte, Yrep = D1["Y"], D1["Yte"], D1["Yrep"]
tt = np.arange(540)[kte]
th = np.arange(len(held))[held]
LAMS = np.round(np.logspace(-1, 2, 13), 3).tolist()
def within1(choice, times):
return int(np.sum(np.abs(times[choice] - times) <= 1))
chance = float(np.mean([np.sum(np.abs(tt - t0) <= 1) for t0 in tt]))
print(f"chance count within one volume: {chance:.2f} of 486 ({100 * chance / 486:.2f}%)")
ident = {}
for mdl, key, pen in (("a", "directional", "a"), ("b", "delay4", "a"), ("a", "directional", "b")):
f = FIT[1][key]
sx = "" if pen == "a" else "_b"
Pheld, R90, Pte, R = f["Pheld" + sx], f["R90" + sx], f["Pte" + sx], f["R" + sx]
held_acc = vim2.corr_cols(Pheld, Y[held])
sel = np.argsort(held_acc)[::-1][:2000]
cov90 = (R90[:, sel].T @ R90[:, sel]) / R90.shape[0]
hc = [within1(vim2.identify(Y[held][:, sel], Pheld[:, sel], cov90, l), th) for l in LAMS]
lam = LAMS[int(np.argmax(hc))]
cov = (R[:, sel].T @ R[:, sel]) / R.shape[0]
res_lam = {}
for l in LAMS:
c_avg = within1(vim2.identify(Yte[:, sel], Pte[:, sel], cov, l), tt)
c_rep = [within1(vim2.identify(Yrep[k][:, sel], Pte[:, sel], cov, l), tt) for k in range(10)]
res_lam[l] = (c_avg, float(np.mean(c_rep)), min(c_rep), max(c_rep))
ident[(mdl, pen)] = (lam, res_lam)
print(f"model reading ({mdl}), encoding penalty reading ({pen}): held-out accuracy of the 2,000th voxel {held_acc[sel[-1]]:.3f}; "
f"held-out identification within 1 s by Tikhonov penalty {dict(zip(LAMS, hc))} of {held.sum()}; chosen {lam}")
for l, (ca, cr, lo, hi) in res_lam.items():
mark = " <- chosen" if l == lam else ""
print(f" penalty {l}: (i) repeat mean {ca} of 486 ({100 * ca / 486:.1f}%); (ii) single repeats mean {cr:.1f} (range {lo} to {hi}){mark}")
chance count within one volume: 2.96 of 486 (0.61%)
model reading (a), encoding penalty reading (a): held-out accuracy of the 2,000th voxel 0.175; held-out identification within 1 s by Tikhonov penalty {0.1: 296, 0.178: 359, 0.316: 406, 0.562: 448, 1.0: 492, 1.778: 510, 3.162: 523, 5.623: 519, 10.0: 503, 17.783: 467, 31.623: 419, 56.234: 368, 100.0: 303} of 728; chosen 3.162
penalty 0.1: (i) repeat mean 318 of 486 (65.4%); (ii) single repeats mean 201.8 (range 182 to 234)
penalty 0.178: (i) repeat mean 350 of 486 (72.0%); (ii) single repeats mean 227.7 (range 201 to 262)
penalty 0.316: (i) repeat mean 367 of 486 (75.5%); (ii) single repeats mean 259.3 (range 239 to 284)
penalty 0.562: (i) repeat mean 383 of 486 (78.8%); (ii) single repeats mean 286.1 (range 267 to 310)
penalty 1.0: (i) repeat mean 396 of 486 (81.5%); (ii) single repeats mean 311.2 (range 295 to 336)
penalty 1.778: (i) repeat mean 406 of 486 (83.5%); (ii) single repeats mean 327.6 (range 314 to 349)
penalty 3.162: (i) repeat mean 409 of 486 (84.2%); (ii) single repeats mean 338.1 (range 321 to 364) <- chosen
penalty 5.623: (i) repeat mean 405 of 486 (83.3%); (ii) single repeats mean 339.8 (range 318 to 367)
penalty 10.0: (i) repeat mean 400 of 486 (82.3%); (ii) single repeats mean 330.2 (range 307 to 356)
penalty 17.783: (i) repeat mean 388 of 486 (79.8%); (ii) single repeats mean 310.7 (range 285 to 331)
penalty 31.623: (i) repeat mean 370 of 486 (76.1%); (ii) single repeats mean 288.0 (range 259 to 309)
penalty 56.234: (i) repeat mean 337 of 486 (69.3%); (ii) single repeats mean 259.1 (range 233 to 275)
penalty 100.0: (i) repeat mean 313 of 486 (64.4%); (ii) single repeats mean 232.0 (range 202 to 249)
model reading (b), encoding penalty reading (a): held-out accuracy of the 2,000th voxel 0.149; held-out identification within 1 s by Tikhonov penalty {0.1: 147, 0.178: 173, 0.316: 206, 0.562: 245, 1.0: 283, 1.778: 324, 3.162: 342, 5.623: 329, 10.0: 325, 17.783: 299, 31.623: 256, 56.234: 215, 100.0: 182} of 728; chosen 3.162
penalty 0.1: (i) repeat mean 156 of 486 (32.1%); (ii) single repeats mean 90.7 (range 75 to 102)
penalty 0.178: (i) repeat mean 178 of 486 (36.6%); (ii) single repeats mean 105.8 (range 90 to 123)
penalty 0.316: (i) repeat mean 198 of 486 (40.7%); (ii) single repeats mean 124.8 (range 109 to 137)
penalty 0.562: (i) repeat mean 222 of 486 (45.7%); (ii) single repeats mean 149.0 (range 133 to 165)
penalty 1.0: (i) repeat mean 248 of 486 (51.0%); (ii) single repeats mean 175.0 (range 155 to 197)
penalty 1.778: (i) repeat mean 281 of 486 (57.8%); (ii) single repeats mean 197.2 (range 173 to 216)
penalty 3.162: (i) repeat mean 292 of 486 (60.1%); (ii) single repeats mean 213.3 (range 199 to 226) <- chosen
penalty 5.623: (i) repeat mean 287 of 486 (59.1%); (ii) single repeats mean 217.0 (range 208 to 226)
penalty 10.0: (i) repeat mean 263 of 486 (54.1%); (ii) single repeats mean 209.5 (range 198 to 221)
penalty 17.783: (i) repeat mean 251 of 486 (51.6%); (ii) single repeats mean 196.3 (range 177 to 217)
penalty 31.623: (i) repeat mean 227 of 486 (46.7%); (ii) single repeats mean 178.8 (range 165 to 192)
penalty 56.234: (i) repeat mean 199 of 486 (40.9%); (ii) single repeats mean 158.0 (range 139 to 182)
penalty 100.0: (i) repeat mean 177 of 486 (36.4%); (ii) single repeats mean 136.9 (range 120 to 161)
model reading (a), encoding penalty reading (b): held-out accuracy of the 2,000th voxel 0.163; held-out identification within 1 s by Tikhonov penalty {0.1: 384, 0.178: 411, 0.316: 440, 0.562: 460, 1.0: 486, 1.778: 495, 3.162: 502, 5.623: 506, 10.0: 488, 17.783: 447, 31.623: 397, 56.234: 339, 100.0: 299} of 728; chosen 5.623
penalty 0.1: (i) repeat mean 395 of 486 (81.3%); (ii) single repeats mean 281.9 (range 264 to 313)
penalty 0.178: (i) repeat mean 405 of 486 (83.3%); (ii) single repeats mean 299.9 (range 287 to 328)
penalty 0.316: (i) repeat mean 409 of 486 (84.2%); (ii) single repeats mean 317.2 (range 302 to 348)
penalty 0.562: (i) repeat mean 411 of 486 (84.6%); (ii) single repeats mean 337.5 (range 323 to 367)
penalty 1.0: (i) repeat mean 424 of 486 (87.2%); (ii) single repeats mean 353.2 (range 335 to 383)
penalty 1.778: (i) repeat mean 430 of 486 (88.5%); (ii) single repeats mean 363.5 (range 345 to 387)
penalty 3.162: (i) repeat mean 432 of 486 (88.9%); (ii) single repeats mean 367.5 (range 347 to 393)
penalty 5.623: (i) repeat mean 426 of 486 (87.7%); (ii) single repeats mean 360.4 (range 344 to 390) <- chosen
penalty 10.0: (i) repeat mean 414 of 486 (85.2%); (ii) single repeats mean 346.5 (range 326 to 368)
penalty 17.783: (i) repeat mean 398 of 486 (81.9%); (ii) single repeats mean 323.4 (range 299 to 355)
penalty 31.623: (i) repeat mean 373 of 486 (76.7%); (ii) single repeats mean 296.7 (range 268 to 318)
penalty 56.234: (i) repeat mean 344 of 486 (70.8%); (ii) single repeats mean 266.8 (range 247 to 291)
penalty 100.0: (i) repeat mean 319 of 486 (65.6%); (ii) single repeats mean 242.2 (range 213 to 262)
Result: reproduced, under encoding penalty reading (b), resting on ridge regression in place of L1. With the four-delay directional model, the encoding penalties of reading (b) (five-fold cross-validation), which the claims file allows and under which fig2de-prediction-accuracy passes, the repeat-averaged test signal and the Tikhonov penalty chosen on the held-out training data (5.623 times the mean residual variance; 506 of 728 held-out samples), 426 of 486 S1 test volumes (87.7%) are identified within one volume, at least the 418 the tolerance needs and 38 short of the paper's 464; chance is 2.96 of 486 (0.61%). The grid gives 319 to 432, and 424 to 432 for Tikhonov penalties 1 to 5.623; the best penalty on the test data (3.162, 432) is not the one chosen. Single repeats give 360.4 (344 to 390). The reading (b) penalties come from cross-validation over all 7,128 training samples, so the held-out 728 samples that choose the voxels and the Tikhonov penalty also took part in choosing each voxel's encoding penalty; no test data is involved.
With encoding penalty reading (a) the same model and signal identify 408 of 486 (84.0%) at the chosen Tikhonov penalty (3.162), 10 short of the tolerance, and no Tikhonov penalty of the grid reaches 418 (313 to 408). Single repeats give 337.3 on average (320 to 364), and the single 4 s delay model 326 (repeat mean) and 231.5 (single repeats), under reading (a). The counts move by about one between runs of the same code (an earlier run gave 409 under reading a), from small floating-point differences. The verifier agreed with the change from partially reproduced to reproduced in round 3.
Blocked claims¶
- fig3c-identification-large-set, fig4-reconstructions, fig4d-reconstruction-accuracy: need the 1,000,000-clip identification set or the 18,000,000 s sampled prior of YouTube clips. The data set holds neither (the descriptor lists only the experiment's stimuli), and the paper gives no location for them (data_missing). The training movies (7,200 s) could serve as distractors for a partial test of fig3c, but not at the 1,000,000 clips the criterion names.
print(f"total run time {(time.time() - T0) / 60:.1f} min; peak memory {mem_gb():.1f} GB")
total run time 35.9 min; peak memory 6.8 GB
Summary¶
| Claim | Outcome |
|---|---|
| fig2de-prediction-accuracy | reproduced under penalty reading b (0.233, 0.384, 0.386 against 0.24, 0.39, 0.40); under reading a the static mean, 0.211, is 0.005 outside tolerance; rests on ridge in place of L1 |
| fig2e-directional-gain-small | reproduced (gain 0.0010 to 0.0034 against 0.083 to 0.159; ratios 0.012 to 0.022) |
| figs1a-motion-better-every-area | reproduced (15 of 15 cells; V1 best in 3 of 3 subjects, pooled rank-sum) |
| fig2fgh-retinotopic-receptive-fields | reproduced on the proxy test (fits inside the display 95% to 97%; contralateral 84% to 91%; eccentricity rises forward in V1, r = 0.33 to 0.61) |
| fig2j-speed-eccentricity | reproduced (9 of 9 correlations positive with p < 0.0001 under every reading) |
| fig3ab-identification-s1 | reproduced under encoding penalty reading b (426 of 486 against 464; at least 418 needed); under reading a, 408; rests on ridge in place of L1 |
| fig3c-identification-large-set | blocked, data_missing |
| fig4-reconstructions | blocked, data_missing |
| fig4d-reconstruction-accuracy | blocked, data_missing |
| discussion-color-no-gain | reproduced in color_no_gain.ipynb (color model 0.0095 lower; 0.0066 lower with a separate weight per color channel) |
How the analysis differs from the paper's. Ridge regression replaces the L1-regularized regression, with the penalty chosen per voxel on held-out training data under both readings of the claims file; an approximate L1 fit on 120 voxels predicts better than ridge (by 0.005 to 0.025), which would raise the means, not lower them. The test repeats are z-scored per voxel before averaging, since the data set's test responses are not in the units of the training responses. The filter bank is pymoten's, whose default envelopes give the paper's 6,555 filters; its 855 zero-spatial-frequency filters have no direction and are kept as single features of the nondirectional model (4,275 features). Receptive fields and tuning are estimated with simulated probes whose contrast and duration the paper does not give (standard choices), and judged on the claims file's proxy test, since the multifocal maps are not public.
What was found about the dataset. The files match the descriptor in shape (7,200 and 540 samples, 73,728 voxels, 108,000 and 8,100 frames) and rv is the mean of rva. The descriptor does not say that the responses include the first 6 s of each block that the paper discards (the mean training response there is 0.28 to 0.42, against 0.01 elsewhere), that the test responses are on a different scale from the z-scored training responses (s.d. 0.10 to 0.11 for rv, 0.20 to 0.23 for rva, against 0.99 for rt), or that 29 to 179 V1-V3B voxels per subject hold missing values. The "peak BOLD responses" it mentions are not delay-shifted: the clock check gives 0.30 to 0.33 at a 4 s delay against 0.06 to 0.09 at 0 s. The descriptor names one ROI mask by example; the files hold many more, by hemisphere, and the set differs between subjects (printed in the data check: 30 masks in S1, among them V4, MT, MTp, IP, OBJ, VO and latocc; 30 in S2, among them EBA, OFA and V7; 44 in S3, among them IPS1 to IPS4, MST, TOS and cortALL); one subject 3 voxel lies in two V1-V3B masks. The stored frames are upright once the last two stored axes are swapped (example frames above).