Reproducing Mannion (2015) from CRCNS vim-3¶

Paper. Mannion DJ (2015). Sensitivity to the visual field origin of natural image patches in human low-level visual cortex. PeerJ 3:e1038. doi:10.7717/peerj.1038. The claims file (claims/crcns-vim-3/10.7717-peerj.1038.yaml) was written from the version of record (PMC4485252); the supplementary files themselves were not available, only their legends.

Data set. CRCNS vim-3, doi:10.6080/K0JS9NC2, read from the public bucket at https://crcnsarchive.s3-us-west-2.amazonaws.com/vim-3/. CRCNS data sets are not versioned (docs/archives.md), so the version is recorded as unversioned, and the paper cites the data set by its DOI only. The data set has one data file, crcns_vim-3.tar.gz (2,349,486,063 bytes), with md5 005760a76158d4f16f54b41ee24cd1f2 in the data set's checksums.md5; the notebook streams the whole file once, computes its md5 as it reads and compares it with that list below, so a later change of the file is detected. The data descriptor is version 0.5 of 12 June 2015. There is no other version to choose. A tar.gz has no index, so it cannot be opened in place as a zip can; it is streamed member by member and nothing is written to disk.

What the data set holds. For each of the seven participants, the ten functional runs (NIfTI, not preprocessed), the event sequence of each run, the digit stream of the central task and the button presses; and screenshots of the 120 stimuli. It does not hold the anatomical images, the cortical surfaces, the retinotopic mapping or the V1, V2 and V3 definitions; the descriptor says so ("You may need additional data (anatomical images, visual area definitions, etc.) that are not part of the current archive"). Every response claim of the paper is measured in V1, V2 and V3.

Claim Tested Outcome
localiser-masks-ventral-dorsal no blocked, data missing (V1 to V3 and surfaces)
presentation-source-interaction no blocked, data missing (V1 to V3)
interaction-not-area-dependent no blocked, data missing (V1 to V3)
lower-field-below-greater no blocked, data missing (V1 to V3)
upper-field-no-source-difference no blocked, data missing (V1 to V3)
fig4-top-five-matching-source no blocked, data missing (V1 to V3)
fig4-qualitative-content no blocked, data missing (depends on fig4-top-five-matching-source)
fig5a-mean-luminance no blocked, data missing (responses; monitor calibration)
fig5-no-other-pixel-relations no blocked, data missing (as fig5a)
fig5bc-spatial-frequency no blocked, data missing (as fig5a)
fig5def-orientation no blocked, data missing (as fig5a)
fig5-no-other-filter-relations no blocked, data missing (as fig5a)
no-radial-bias-in-patches no (variant shown) blocked, metadata insufficient (monitor calibration); a variant under assumed calibrations is shown
figs2-task-no-condition-difference yes see its section
figs3-residual-no-condition-difference no blocked, data missing (V1 to V3)
figs3-residual-upper-larger no blocked, data missing (V1 to V3)

The blocked response claims are not tested. To describe the data set, the data check fits the paper's GLM in the volume, and a last section repeats the response analysis on a volume localiser region that is not V1 to V3. No outcome rests on that section. The radial-bias test needs only the stimulus screenshots and the monitor calibration; it is run under two assumed calibrations, as a variant on which no outcome rests.

Paper's code. The notebook fetches files of the paper's analysis code (github.com/mannion-lab/ul_sens_fmri_analysis at commit 571e9312, the Bitbucket repository the paper links) and of its experiment code (github.com/mannion-lab/ul_sens_fmri at commit 5e98dd81), and prints the lines it follows, so that each method detail can be checked against them.

In [1]:
import time
import resource
import urllib.request
from collections import Counter

import numpy as np
import pandas as pd
from scipy import stats

import vim3

CODE = "https://raw.githubusercontent.com/mannion-lab/ul_sens_fmri_analysis/571e9312c251ff2166be91a57201112036e5e80d/ul_sens_analysis/"
EXP_CODE = "https://raw.githubusercontent.com/mannion-lab/ul_sens_fmri/5e98dd81512fa3d226a971a6217426535b682d85/ul_sens_fmri/"


def show_lines(url, patterns, context=0):
    """Print the numbered lines of a code file that match any of the patterns."""
    lines = urllib.request.urlopen(url, timeout=60).read().decode().splitlines()
    keep = sorted({j for i, l in enumerate(lines) if any(p in l for p in patterns)
                   for j in range(max(0, i - context), min(len(lines), i + context + 1))})
    print(url.rsplit("/", 1)[1], f"({len(lines)} lines)")
    for j in keep:
        print(f"  {j + 1:4d}  {lines[j]}")

pd.set_option("display.width", 200)
started = time.time()
participants, stim = [], None
for p in vim3.stream_participants():
    if p["id"] == "stim":
        stim = p
        continue
    r = vim3.process_participant(p)
    for reading in ("a", "b", "c", "d", "e"):
        r["perf_" + reading] = vim3.task_performance(p, reading)
    for k in ("md5", "series", "seq", "lut", "task", "affine", "scale"):
        r[k] = p[k]
    participants.append(r)
    del p
print(f"data set {vim3.DATASET}, version {vim3.VERSION}, file md5 expected {vim3.TAR_MD5}")
print(f"streamed and processed {len(participants)} participants in {time.time() - started:.0f} s; "
      f"peak memory {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1e6:.1f} GB; "
      f"{stim['reconnects']} reconnections")
data set vim-3, version unversioned, file md5 expected 005760a76158d4f16f54b41ee24cd1f2
streamed and processed 7 participants in 477 s; peak memory 4.2 GB; 0 reconnections

Data check¶

In [2]:
listed = dict(line.split()[::-1] for line in urllib.request.urlopen(
    "https://crcnsarchive.s3-us-west-2.amazonaws.com/vim-3/checksums.md5").read().decode().splitlines() if line.strip())
print("crcns_vim-3.tar.gz: md5 as streamed", stim["tar_md5"], "| in checksums.md5", listed["crcns_vim-3.tar.gz"],
      "| match:", stim["tar_md5"] == listed["crcns_vim-3.tar.gz"], "| bytes read", stim["tar_bytes"])

rows = []
for r in participants:
    kinds = Counter("nii" if n.endswith(".nii") else n.split("_")[-1].replace(".npy", "").replace("lut", "task_lut")
                    if not n.endswith("task_lut.npy") else "task_lut" for n in r["md5"])
    rows.append({"participant": r["id"], "nifti": kinds["nii"], "seq": kinds["seq"], "task": kinds["task"],
                 "task_lut": kinds["task_lut"], "series": " ".join(map(str, r["series"])),
                 "shape": "x".join(map(str, r["shape"])), "dtype": r["dtype"],
                 "raw range": f"{r['raw_range'][0]} to {r['raw_range'][1]}", "slope": round(r["scale"][0], 3),
                 "voxel mm": tuple(np.sqrt((r["affine"][:3, :3] ** 2).sum(0)).round(2)),
                 "presses": sum(len(v) for v in r["task"].values())})
info = pd.DataFrame(rows)
print(info.to_string(index=False))
md5s = Counter(h for r in participants for h in r["md5"].values())
print("\nfiles", sum(len(r["md5"]) for r in participants), "| distinct md5", len(md5s),
      "| files with the same content as another:", sum(c for c in md5s.values() if c > 1))
seq_keys = Counter(r["seq"][k].tobytes() for r in participants for k in r["seq"])
print("run sequences", sum(seq_keys.values()), "| distinct", len(seq_keys))
print("\nevery member of the tar archive, by kind and parent directory:")
for (kind, parent), n in sorted(stim["members"].items(), key=lambda x: x[0][1]):
    print(f"  {n:4d} {kind:9s} {parent or '(top)'}")
print("files outside the participant and stimulus directories:", stim.get("other_files", []))
crcns_vim-3.tar.gz: md5 as streamed 005760a76158d4f16f54b41ee24cd1f2 | in checksums.md5 005760a76158d4f16f54b41ee24cd1f2 | match: True | bytes read 2349486063
participant  nifti  seq  task  task_lut                  series        shape dtype raw range  slope        voxel mm  presses
      p1008     10   10    10        10  3 4 5 6 7 8 9 10 11 12 96x96x35x166 int16  0 to 610  5.903 (2.0, 2.0, 2.0)      811
      p1006     10   10    10        10  3 4 5 6 7 8 9 10 11 12 96x96x35x166 int16  0 to 788  3.965 (2.0, 2.0, 2.0)      983
      p1011     10   10    10        10  3 4 5 6 7 8 9 10 11 12 96x96x35x166 int16  0 to 741  4.162 (2.0, 2.0, 2.0)      660
      p1004     10   10    10        10  3 4 5 6 7 8 9 10 11 12 96x96x35x166 int16  0 to 707  4.183 (2.0, 2.0, 2.0)      954
      p1001     10   10    10        10  3 4 5 6 7 8 9 10 11 12 96x96x35x166 int16  0 to 438  6.848 (2.0, 2.0, 2.0)      955
      p1003     10   10    10        10 3 4 6 7 8 9 10 11 12 13 96x96x35x166 int16  0 to 773  4.704 (2.0, 2.0, 2.0)      735
      p1010     10   10    10        10 4 5 6 7 8 9 10 11 12 13 96x96x35x166 int16  0 to 630  5.575 (2.0, 2.0, 2.0)      750

files 280 | distinct md5 280 | files with the same content as another: 0
run sequences 70 | distinct 70

every member of the tar archive, by kind and parent directory:
     1 directory (top)
     1 file      crcns_vim-3
     2 directory crcns_vim-3
     7 directory crcns_vim-3/data
    40 file      crcns_vim-3/data/p1001
    40 file      crcns_vim-3/data/p1003
    40 file      crcns_vim-3/data/p1004
    40 file      crcns_vim-3/data/p1006
    40 file      crcns_vim-3/data/p1008
    40 file      crcns_vim-3/data/p1010
    40 file      crcns_vim-3/data/p1011
   120 file      crcns_vim-3/stim
files outside the participant and stimulus directories: [('crcns_vim-3/README.txt', 402)]

The archive holds 280 files under the seven participant directories, 120 under stim/ and one README.txt at the top (the listing above counts every member, so nothing is skipped unseen); there are no anatomical, surface or area files. The descriptor says each participant directory holds the 10 fMRI recordings with the sequence and task files; every directory holds 10 NIfTI files, 10 sequence, 10 task and 10 task lookup files. Each NIfTI is 96 x 96 x 35 voxels by 166 volumes, 2 mm voxels, int16 with a scale factor, which matches the Methods (matrix 96 x 96, 35 slices, 2 mm isotropic, 332 s at TR 2 s). No two files share their content, and no run sequence is repeated, so no recording was deposited twice. The NIfTI files are named by scanner series number, not run number; for p1003 and p1010 the series run 3, 4, 6 to 13 and 4 to 13. Run n is taken to be the n-th series in order, which is what the participant configurations of the paper's code list (for example p1003 [3, 4] + range(6, 14)); the check of the run order below tests this against the data.

In [3]:
r0 = participants[0]
seq = r0["seq"][1]
print("run sequence array", seq.shape, "(descriptor: 2 x 83 x 5)")
rows = []
for r in participants:
    for run in range(1, 11):
        s = r["seq"][run]
        for f, name in ((0, "upper"), (1, "lower")):
            e = s[f]
            img = e[e[:, 1] > 0]
            main = e[e[:, 3] == 0]
            rows.append({"participant": r["id"], "run": run, "field": name, "events": len(e),
                         "main events": len(main), "main null": int((main[:, 1] == 0).sum()),
                         "main above": int((main[:, 1] == 1).sum()), "main below": int((main[:, 1] == 2).sum()),
                         "main pairs": len({(int(a), int(b)) for a, b in main[main[:, 1] > 0][:, 1:3]}),
                         "null": int((e[:, 1] == 0).sum()), "above": int((e[:, 1] == 1).sum()),
                         "below": int((e[:, 1] == 2).sum()), "pre": int(e[:, 3].sum()),
                         "images": len(set(img[:, 2].astype(int))),
                         "first onset": e[0, 0], "last onset": e[-1, 0],
                         "step": float(np.unique(np.diff(e[:, 0]))[0]) if len(np.unique(np.diff(e[:, 0]))) == 1 else np.nan})
ev = pd.DataFrame(rows)
print(ev.groupby("field")[["events", "main events", "main null", "main above", "main below", "main pairs", "pre",
                          "images", "first onset", "last onset", "step"]]
      .agg(["min", "max"]).to_string())
adv = ev.pivot_table(index=["participant", "run"], columns="field", values="first onset")
print("\nruns where the lower field starts 2 s after the upper:", int((adv.lower - adv.upper == 2).sum()),
      "| upper 2 s after lower:", int((adv.upper - adv.lower == 2).sum()), "of", len(adv))
ids_seq = sorted({int(i) for r in participants for s in r["seq"].values() for i in s[..., 2].ravel() if i > 0})
ids_stim = sorted({int(n.split("_img_id_")[1][:3]) for n in stim["names"]})
print("image ids in sequences", len(ids_seq), "| in stimulus screenshots", len(ids_stim), "| same:", ids_seq == ids_stim,
      "| screenshots", len(stim["names"]))
col = pd.DataFrame(stim["colour"]).T
print("screenshot sizes", col.groupby(["width", "height"]).size().to_dict(), "| largest R-G difference", col.max_rg.max(),
      "| largest R-B difference", col.max_rb.max(), "| screenshots with R, G and B not all equal", int(((col.max_rg > 0) | (col.max_rb > 0)).sum()))
lut = pd.DataFrame([{"participant": r["id"], "run": k, "rows": len(v), "t0": v[0, 0], "t_end": v[-1, 0],
                     "rate_hz": 1 / np.median(np.diff(v[:, 0])), "digits": f"{int(v[:, 1].min())}-{int(v[:, 1].max())}",
                     "polarities": " ".join(map(str, sorted(set(v[:, 2].astype(int))))), "targets": int(v[:, 3].sum())}
                    for r in participants for k, v in r["lut"].items()])
print("\ntask lookup:", lut[["rows", "t0", "t_end", "rate_hz", "targets"]].agg(["min", "max"]).round(3).to_string())
print("digits", lut.digits.unique(), "polarities", lut.polarities.unique())
press = pd.DataFrame([{"participant": r["id"], "key": k.decode(), "time": t} for r in participants
                      for v in r["task"].values() for (k, t) in v])
print("\nbutton presses: keys", press.key.value_counts().to_dict(), "| time range", press.time.min().round(2),
      "to", press.time.max().round(2), "s")
run sequence array (2, 83, 5) (descriptor: 2 x 83 x 5)
      events     main events     main null     main above     main below     main pairs     pre     images     first onset      last onset        step     
         min max         min max       min max        min max        min max        min max min max    min max         min  max        min    max  min  max
field                                                                                                                                                      
lower     83  83          75  75        15  15         30  30         30  30         60  60   8   8     30  30         0.0  2.0      328.0  330.0  4.0  4.0
upper     83  83          75  75        15  15         30  30         30  30         60  60   8   8     30  30         0.0  2.0      328.0  330.0  4.0  4.0

runs where the lower field starts 2 s after the upper: 34 | upper 2 s after lower: 36 of 70
image ids in sequences 30 | in stimulus screenshots 30 | same: True | screenshots 120
screenshot sizes {(1920, 1200): 120} | largest R-G difference 176 | largest R-B difference 192 | screenshots with R, G and B not all equal 120

task lookup:      rows   t0    t_end  rate_hz  targets
min   996  0.0  331.667      3.0       79
max   996  0.0  331.667      3.0      118
digits <StringArray>
['0-9']
Length: 1, dtype: str polarities <StringArray>
['-1 1']
Length: 1, dtype: str

button presses: keys {'2': 3131, '1': 1967, '4': 728, '3': 22} | time range 0.78 to 331.94 s

Each field's sequence has 83 events at 4 s steps, of which 8 are marked 'pre' (the Design: 83 events, 4 s inter-event interval, the final 8 events replicated and prepended). In every run and field the other 75 hold 15 null events and 60 image events, 30 above and 30 below, each of the 60 image and source pairs once, as the Design says; the 30 image ids are those of the 120 screenshots (30 images by 2 sources by 2 presentation locations). The screenshots are 1920 by 1200 pixels, the display resolution of the Methods. Every screenshot holds pixels whose R, G and B values differ (by up to 192 levels); this count covers the whole screen, overlay lines included. The colour of the patches themselves is shown in the radial-bias section below, inside the patch masks. In every run one field's sequence starts 2 s after the other's, as the Design says, and which one varies by run. The task lookup has 996 digits at 3 Hz over 332 s, as the descriptor says and the Methods' 3 Hz stream. Button times lie within the run; four different keys were used, and task.py counts any key as a response, as is done here.

The next checks fit the paper's GLM in the volume, without the paper's preprocessing (no slice timing or motion correction, no projection to the surface) and with ordinary least squares in place of 3dREMLfit. They test that the image sequences share the clock of the fMRI volumes and that the NIfTI order is the run order. For each run, a localiser mask (voxels with t > 2.58 for one regressor for all image events of a field, as in the Methods, Localiser) is made from the other nine runs, and the mean over that mask of the held-out run is fitted with: each run's sequence (run order); its own sequence shifted by -12 to +12 s (clock); and the other field's sequence (contrast between conditions: the two fields' events alternate every 2 s, so a voxel set chosen for one field should follow that field's timing better than the other's).

In [4]:
rows = []
for r in participants:
    for f, name in ((0, "upper"), (1, "lower")):
        q = r["fields"][f]
        prof = q["shift_t"].mean(0)
        rows.append({"participant": r["id"], "field": name, "mask voxels (all runs)": q["n_mask"],
                     "held-out mask voxels (min-max)": f"{q['n_mask_cv'].min()}-{q['n_mask_cv'].max()}",
                     "runs whose best sequence is their own": int((q["order_t"].argmax(1) == np.arange(10)).sum()),
                     "t own seq (mean)": q["order_t"].diagonal().mean().round(2),
                     "t other runs' seq (mean)": q["order_t"][~np.eye(10, dtype=bool)].mean().round(2),
                     "t other field (mean)": q["other_field_t"].mean().round(2),
                     "best shift s": int(q["shifts"][prof.argmax()]),
                     "t at shift 0": prof[list(q["shifts"]).index(0)].round(2),
                     "t at +-12 s": f"{prof[0]:.2f} / {prof[-1]:.2f}"})
chk = pd.DataFrame(rows)
print(chk.to_string(index=False))
print("\nmean t over participants by shift (s):")
shifts = participants[0]["fields"][0]["shifts"]
prof = pd.DataFrame({f"{r['id']} {n}": r["fields"][f]["shift_t"].mean(0) for r in participants for f, n in ((0, "U"), (1, "L"))},
                    index=shifts).T
print(prof.round(1).to_string())
print("\nhead motion index, largest centre-of-mass displacement from the first volume of run 1, mm, per run:")
print(pd.DataFrame({r["id"]: r["motion_mm"] for r in participants}, index=range(1, 11)).T.round(1).to_string())
participant field  mask voxels (all runs) held-out mask voxels (min-max)  runs whose best sequence is their own  t own seq (mean)  t other runs' seq (mean)  t other field (mean)  best shift s  t at shift 0   t at +-12 s
      p1008 upper                     721                        550-925                                      5              2.61                     -0.29                  0.50            -2          2.61  0.29 / -0.50
      p1008 lower                    1438                      1050-1808                                      6              2.96                      0.12                  0.33            -2          2.96 -1.77 / -0.60
      p1006 upper                    1672                      1460-1801                                      9              4.34                      0.26                  3.14             0          4.34 -0.60 / -0.38
      p1006 lower                    3182                      2638-3463                                      7              4.67                      0.37                  1.69             0          4.67 -1.23 / -0.70
      p1011 upper                    5713                      4032-8076                                      2              0.68                     -0.17                 -0.10            -4          0.68 -0.33 / -0.22
      p1011 lower                    1918                      1052-2221                                      1              1.07                      0.00                  0.03             0          1.07  -0.20 / 0.06
      p1004 upper                    1549                      1297-1673                                      8              3.83                     -0.13                  1.51             0          3.83 -0.72 / -1.67
      p1004 lower                    1378                      1113-1542                                      7              3.34                      0.17                  1.88             0          3.34 -0.93 / -1.42
      p1001 upper                    1406                      1185-1479                                      7              3.67                      0.05                  1.45            -2          3.67 -0.74 / -0.39
      p1001 lower                    2081                      1785-2384                                      8              4.11                      0.45                  0.88            -2          4.11 -0.91 / -0.54
      p1003 upper                    1271                      1040-1480                                      5              3.47                      0.12                 -0.16             0          3.47 -0.53 / -0.53
      p1003 lower                     804                        725-861                                      7              4.90                     -0.15                  1.21             0          4.90  0.00 / -1.09
      p1010 upper                     844                        750-860                                     10              4.38                     -0.09                  0.78            -2          4.38 -0.40 / -0.11
      p1010 lower                     832                        747-874                                     10              4.31                     -0.30                  0.86            -2          4.31 -0.19 / -1.01

mean t over participants by shift (s):
         -12  -10  -8   -6   -4   -2    0    2    4    6    8    10   12
p1008 U  0.3 -0.1 -0.2  0.4  1.5  2.6  2.6  1.2 -0.1 -0.4 -0.3 -0.5 -0.5
p1008 L -1.8 -1.1 -0.2  0.9  2.0  3.1  3.0  1.8  1.0  0.8  0.4 -0.1 -0.6
p1006 U -0.6 -0.3  0.2  1.0  2.2  3.8  4.3  2.4  0.1 -0.8 -0.7 -0.6 -0.4
p1006 L -1.2 -0.9 -0.4  0.6  2.2  4.2  4.7  2.9  0.8 -0.3 -0.6 -0.7 -0.7
p1011 U -0.3  0.1  0.5  0.8  0.9  0.9  0.7  0.4  0.0 -0.5 -0.9 -0.7 -0.2
p1011 L -0.2 -0.1 -0.0  0.2  0.6  1.1  1.1  0.7  0.5  0.5  0.4  0.2  0.1
p1004 U -0.7 -0.3  0.2  0.9  2.2  3.6  3.8  2.2  0.6 -0.1 -0.6 -1.1 -1.7
p1004 L -0.9 -0.9 -0.6  0.4  1.7  3.3  3.3  1.8  0.4 -0.3 -0.8 -1.1 -1.4
p1001 U -0.7 -0.6 -0.1  0.8  2.3  3.8  3.7  1.1 -0.8 -1.0 -0.5 -0.4 -0.4
p1001 L -0.9 -0.4  0.2  1.0  2.3  4.2  4.1  1.6 -0.4 -0.8 -0.7 -0.7 -0.5
p1003 U -0.5 -0.3  0.0  0.5  1.4  2.8  3.5  2.3  0.5 -0.6 -0.9 -0.7 -0.5
p1003 L  0.0 -0.2 -0.3  0.3  2.1  4.3  4.9  2.8  0.6 -0.5 -0.7 -0.8 -1.1
p1010 U -0.4 -0.3  0.1  1.2  2.9  5.0  4.4  1.4 -0.3 -0.3 -0.3 -0.3 -0.1
p1010 L -0.2 -0.1  0.4  1.8  4.0  5.9  4.3  0.3 -2.1 -1.9 -1.4 -1.2 -1.0

head motion index, largest centre-of-mass displacement from the first volume of run 1, mm, per run:
        1    2    3    4    5    6    7    8    9    10
p1008  0.4  0.4  0.6  0.8  0.8  0.8  1.0  1.3  1.1  1.0
p1006  0.7  1.0  1.0  1.0  1.0  1.1  1.1  1.1  1.1  1.2
p1011  0.4  0.4  1.1  1.2  1.3  2.8  3.0  3.4  3.2  3.6
p1004  0.2  0.7  1.0  1.1  1.5  1.4  1.4  0.9  0.6  0.5
p1001  0.8  0.6  0.6  1.0  1.2  1.4  1.4  1.3  1.5  1.5
p1003  0.2  0.3  0.6  0.9  0.8  1.1  1.0  1.1  1.6  1.8
p1010  0.2  0.3  0.3  0.8  0.7  0.9  0.7  1.2  1.2  1.5

For six of the seven participants the held-out runs follow their own sequence: the mean t for the own sequence (2.6 to 4.9) is above the mean for the other runs' sequences, most runs fit their own sequence best (5 to 10 of 10 per field), the fit is best at a shift of -2 or 0 s and falls to near zero or below at 8 to 12 s, and the mask of each field follows its own field's timing better than the other field's. This is consistent with the sequences sharing the clock of the volumes, with the first volume at time 0 of the sequence, and with the n-th series being run n. A best shift of -2 s, half the 4 s event spacing, is within what the HRF model and the unshifted slice times allow; it is not a measured offset. For p1011 none of this could be established: the own-sequence t is near 1, its runs do not pick their own sequence (1 and 2 of 10), and the motion index grows to 3.6 mm by run 10, against at most 1.8 mm in the others. Without motion correction the volume analysis cannot separate a timing or ordering problem in p1011 from motion; the paper motion-corrected the data. The p1011 clock and run order are therefore not shown, and this bears only on the volume variant at the end, not on the tested claim, which uses the sequence and task files alone.

In [5]:
rows = []
for r in participants:
    ju, jl = r["fields"][0]["mask_j"], r["fields"][1]["mask_j"]
    ku, kl = r["fields"][0]["mask_k"], r["fields"][1]["mask_k"]
    rows.append({"participant": r["id"], "upper mask voxels": len(ju), "lower mask voxels": len(jl),
                 "upper mean S-I index": ju.mean().round(1), "lower mean S-I index": jl.mean().round(1),
                 "upper below lower (mm)": round(2 * (ju.mean() - jl.mean()), 1),
                 "Mann-Whitney p": stats.mannwhitneyu(ju, jl).pvalue})
loc = pd.DataFrame(rows)
print("Axis codes of the image axes:", "".join(__import__("nibabel").aff2axcodes(participants[0]["affine"])),
      "(second axis increases toward inferior)")
print(loc.to_string(index=False, float_format=lambda x: f"{x:.3g}"))
print("participants whose upper-field mask lies below the lower-field mask:", int((loc["upper below lower (mm)"] > 0).sum()), "of 7")
Axis codes of the image axes: LIP (second axis increases toward inferior)
participant  upper mask voxels  lower mask voxels  upper mean S-I index  lower mean S-I index  upper below lower (mm)  Mann-Whitney p
      p1008                721               1438                  53.9                  47.1                    13.7        2.46e-47
      p1006               1672               3182                  47.9                  43.4                       9        1.16e-36
      p1011               5713               1918                  49.5                    54                    -8.9        9.61e-13
      p1004               1549               1378                  50.8                  47.8                     6.1        1.22e-24
      p1001               1406               2081                  46.6                  41.6                      10         9.5e-47
      p1003               1271                804                  47.2                  46.4                     1.6        1.85e-08
      p1010                844                832                  51.2                  46.6                     9.2        3.68e-21
participants whose upper-field mask lies below the lower-field mask: 6 of 7

The affine puts the second image axis from superior to inferior. In six of seven participants the voxels that respond to upper-field presentation lie on average below (inferior to) those that respond to lower-field presentation, by 1.6 to 13.7 mm, which is the retinotopic expectation (upper field on the ventral bank) and a second contrast between conditions; p1011 is again the exception. This is a volume check over the whole slab, not the paper's test of the localiser claim, which needs V1 to V3 on the cortical surface.

figs2-task-no-condition-difference¶

Performance on the central fixation task does not differ across the presentation and source location conditions. (Results and Discussion, paragraph 7; Figure S2 legend)

Criterion (claims file): performance as in the Figure S2 legend and task.py, the correlation of target presence assigned to a condition with button responses at lags 0 to 1.9 s in 0.1 s bins, averaged over lags 0.4 to 0.9 s (bins 4 to 9), and a two-way repeated measures ANOVA (presentation by source), as group.py tasks(). Reproduced when no effect has p < 0.05. Reading (a) is task.py as written, reading (b) assigns targets by absolute run time; both keep the p1004 rule. Variant (c), added here for information, bins the whole of 32 to 332 s (task.py puts every press and target after 300 s into its last bin). With two levels per factor each ANOVA effect is a paired contrast over the seven participants, F(1, 6) = t². Two more variants of this attempt change only the assignment window, on the timing of reading (b): (d) keeps targets that fall exactly on an event onset (0 <= difference < 2 s; task.py uses strict inequalities, so targets on an even second are dropped), and (e) assigns each target to the event in progress, the one starting up to 2 s before it (-2 < difference <= 0 s). The next cell prints the lines of task.py that fix the bin edges, the p1004 rule, the assignment and the treatment of keys.

In [6]:
show_lines(CODE + "task.py", ["bin_left_edges = ", "resp_time > bin_left_edges", "onset >= bin_left_edges",
                              "for (_, resp_time)", "<= 32.0", "continue", "subj_id == \"p1004\"", "== 9 and", "== 5 and",
                              "run_task[i_task, 2] ==", "is_target = run_task", "time_diff", "trial_ok",
                              "if task_src == -1", "np.roll(responses"])
show_lines(EXP_CODE + "config.py", ["trial_len_s =", "task_polarity", "task_rate_hz", "run_len_s ="])
task.py (184 lines)
    35      bin_left_edges = np.arange(0.0, conf.exp.run_len_s - 32.0, bin_res)
    51          for (_, resp_time) in run_resp:
    53              if resp_time <= 32.0:
    54                  continue
    56              i_bin = np.where(resp_time > bin_left_edges)[0][-1]
    78              if subj_id == "p1004" and i_run < 5:
    82                          run_task[i_task, 1] == 9 and
    83                          run_task[i_task, 2] == 1
    86                          run_task[i_task, 1] == 5 and
    87                          run_task[i_task, 2] == -1
    95                  is_target = run_task[i_task, -1]
    99              if onset <= 32.0:
   100                  continue
   104                  i_bin = np.where(onset >= bin_left_edges)[0][-1]
   138                  continue
   141              time_diff = run_seq[..., 0] - (bin_left_edges[i_bin] + 32.0)
   143              trial_ok = np.logical_and(
   144                  time_diff > 0,
   145                  time_diff < (conf.exp.trial_len_s / 2.0)
   148              if np.sum(trial_ok) == 0:
   149                  continue
   151              if np.sum(trial_ok) > 1:
   154              (task_vf, i_task) = np.where(trial_ok)
   158              if task_src == -1:
   159                  continue
   174                      np.roll(responses, -i_roll, axis=1).flat
config.py (192 lines)
   140      exp_conf.trial_len_s = 4.0
   142      exp_conf.run_len_s = exp_conf.n_run_trials * exp_conf.trial_len_s
   189      exp_conf.task_polarity = [-1, +1]
   190      exp_conf.task_rate_hz = 3.0
In [7]:
names = {(0, 0): "upper/above", (0, 1): "upper/below", (1, 0): "lower/above", (1, 1): "lower/below"}
results = {}
for reading in ("a", "b", "c", "d", "e"):
    perf = np.array([r["perf_" + reading][0] for r in participants])  # (7, pres, src, lag)
    win = perf[..., 4:10].mean(-1)
    results[reading] = (perf, win, vim3.rm_anova_2x2(win))
    print(f"Reading ({reading}): window 0.4-0.9 s, correlation per participant and condition")
    print(pd.DataFrame({names[k]: win[:, k[0], k[1]] for k in names}, index=[r["id"] for r in participants]).round(4).to_string())
    print("  mean", {names[k]: round(float(win[:, k[0], k[1]].mean()), 4) for k in names})
    for eff, (F, d1, d2, p) in results[reading][2].items():
        print(f"  {eff:9s} F({d1},{d2}) = {F:.3f}, p = {p:.3f}")
    counts = pd.DataFrame([{k: v for k, v in r["perf_" + reading][1].items() if k != "by_condition"} for r in participants],
                          index=[r["id"] for r in participants]).fillna(0).astype(int)
    print("  targets after 32 s, and how they were assigned (totals):", counts.sum().to_dict())
    byc = pd.DataFrame({names[k]: [int(r["perf_" + reading][1]["by_condition"][k]) for r in participants] for k in names},
                       index=[r["id"] for r in participants])
    print("  targets assigned to each condition, per participant (10 runs):")
    print(byc.to_string())
    print()
Reading (a): window 0.4-0.9 s, correlation per participant and condition
       upper/above  upper/below  lower/above  lower/below
p1008       0.0468       0.0355       0.0420       0.0394
p1006       0.0428       0.0512       0.0438       0.0467
p1011       0.0391       0.0357       0.0377       0.0344
p1004       0.0244       0.0320       0.0269       0.0255
p1001       0.0460       0.0454       0.0427       0.0493
p1003       0.0302       0.0317       0.0345       0.0305
p1010       0.0340       0.0379       0.0341       0.0290
  mean {'upper/above': 0.0376, 'upper/below': 0.0385, 'lower/above': 0.0374, 'lower/below': 0.0364}
  pres      F(1,6) = 2.598, p = 0.158
  src       F(1,6) = 0.001, p = 0.979
  pres:src  F(1,6) = 0.446, p = 0.529
  targets after 32 s, and how they were assigned (totals): {'presses': 5227, 'targets': 6214, 'null_event': 959, 'assigned': 3642, 'unassigned': 1023}
  targets assigned to each condition, per participant (10 runs):
       upper/above  upper/below  lower/above  lower/below
p1008          143          117          118          131
p1006          136          141          126          135
p1011          136          128          125          125
p1004          120          137          151          123
p1001          138          134          130          139
p1003          111          122          135          131
p1010          119          149          139          103

Reading (b): window 0.4-0.9 s, correlation per participant and condition
       upper/above  upper/below  lower/above  lower/below
p1008       0.0430       0.0368       0.0403       0.0456
p1006       0.0464       0.0444       0.0470       0.0448
p1011       0.0400       0.0382       0.0369       0.0336
p1004       0.0304       0.0248       0.0192       0.0297
p1001       0.0389       0.0473       0.0499       0.0486
p1003       0.0327       0.0294       0.0318       0.0345
p1010       0.0363       0.0347       0.0312       0.0306
  mean {'upper/above': 0.0383, 'upper/below': 0.0365, 'lower/above': 0.0366, 'lower/below': 0.0382}
  pres      F(1,6) = 0.000, p = 0.987
  src       F(1,6) = 0.005, p = 0.947
  pres:src  F(1,6) = 1.042, p = 0.347
  targets after 32 s, and how they were assigned (totals): {'presses': 5227, 'targets': 6214, 'assigned': 3821, 'null_event': 885, 'unassigned': 918}
  targets assigned to each condition, per participant (10 runs):
       upper/above  upper/below  lower/above  lower/below
p1008          145          130          140          136
p1006          140          142          126          147
p1011          138          150          141          116
p1004          148          115          135          135
p1001          133          139          157          148
p1003          132          137          143          135
p1010          131          142          117          123

Reading (c): window 0.4-0.9 s, correlation per participant and condition
       upper/above  upper/below  lower/above  lower/below
p1008       0.0441       0.0383       0.0403       0.0454
p1006       0.0500       0.0461       0.0496       0.0489
p1011       0.0399       0.0397       0.0372       0.0328
p1004       0.0336       0.0258       0.0237       0.0288
p1001       0.0428       0.0488       0.0527       0.0513
p1003       0.0334       0.0341       0.0341       0.0356
p1010       0.0404       0.0349       0.0369       0.0338
  mean {'upper/above': 0.0406, 'upper/below': 0.0383, 'lower/above': 0.0392, 'lower/below': 0.0395}
  pres      F(1,6) = 0.002, p = 0.965
  src       F(1,6) = 1.447, p = 0.274
  pres:src  F(1,6) = 0.901, p = 0.379
  targets after 32 s, and how they were assigned (totals): {'presses': 5227, 'targets': 6214, 'assigned': 4979, 'null_event': 1197, 'unassigned': 38}
  targets assigned to each condition, per participant (10 runs):
       upper/above  upper/below  lower/above  lower/below
p1008          185          170          183          173
p1006          172          178          168          187
p1011          190          182          188          156
p1004          200          155          184          170
p1001          169          176          196          189
p1003          167          184          187          166
p1010          198          176          159          171

Reading (d): window 0.4-0.9 s, correlation per participant and condition
       upper/above  upper/below  lower/above  lower/below
p1008       0.0472       0.0424       0.0428       0.0499
p1006       0.0504       0.0473       0.0511       0.0509
p1011       0.0398       0.0413       0.0405       0.0366
p1004       0.0360       0.0290       0.0247       0.0324
p1001       0.0436       0.0528       0.0534       0.0521
p1003       0.0349       0.0316       0.0368       0.0375
p1010       0.0416       0.0379       0.0385       0.0342
  mean {'upper/above': 0.0419, 'upper/below': 0.0403, 'lower/above': 0.0411, 'lower/below': 0.042}
  pres      F(1,6) = 0.095, p = 0.768
  src       F(1,6) = 0.156, p = 0.707
  pres:src  F(1,6) = 0.520, p = 0.498
  targets after 32 s, and how they were assigned (totals): {'presses': 5227, 'targets': 6214, 'assigned': 4544, 'null_event': 1080}
  targets assigned to each condition, per participant (10 runs):
       upper/above  upper/below  lower/above  lower/below
p1008          170          158          169          155
p1006          162          161          151          174
p1011          163          177          175          139
p1004          182          142          162          159
p1001          155          165          185          172
p1003          157          157          171          155
p1010          170          164          146          148

Reading (e): window 0.4-0.9 s, correlation per participant and condition
       upper/above  upper/below  lower/above  lower/below
p1008       0.0439       0.0516       0.0428       0.0452
p1006       0.0454       0.0480       0.0552       0.0476
p1011       0.0330       0.0395       0.0374       0.0444
p1004       0.0319       0.0306       0.0315       0.0313
p1001       0.0474       0.0579       0.0490       0.0495
p1003       0.0376       0.0364       0.0360       0.0310
p1010       0.0359       0.0351       0.0423       0.0400
  mean {'upper/above': 0.0393, 'upper/below': 0.0427, 'lower/above': 0.042, 'lower/below': 0.0413}
  pres      F(1,6) = 0.166, p = 0.698
  src       F(1,6) = 0.703, p = 0.434
  pres:src  F(1,6) = 5.767, p = 0.053
  targets after 32 s, and how they were assigned (totals): {'presses': 5227, 'targets': 6214, 'null_event': 1149, 'assigned': 4475}
  targets assigned to each condition, per participant (10 runs):
       upper/above  upper/below  lower/above  lower/below
p1008          156          168          151          167
p1006          155          150          173          166
p1011          163          143          167          169
p1004          165          170          153          160
p1001          151          173          165          165
p1003          166          155          154          151
p1010          163          137          172          147

In [8]:
perf = results["a"][0]
lag_mean = perf.mean(0)  # (pres, src, lag)
print("Reading (a): mean correlation over participants by lag (s); rows are conditions")
print(pd.DataFrame({names[k]: lag_mean[k[0], k[1]] for k in names}, index=np.arange(20) / 10).T.round(3).to_string())
print("peak lag per condition (s):", {names[k]: float(lag_mean[k[0], k[1]].argmax() / 10) for k in names})
print("range over all participants, conditions and lags:", perf.min().round(3), "to", perf.max().round(3))
for reading in ("b", "c", "d", "e"):
    lm = results[reading][0].mean(0)
    print(f"reading ({reading}): peak lag per condition (s):", {names[k]: float(lm[k[0], k[1]].argmax() / 10) for k in names})
# the window is a choice of group.py: show other windows
for lo, hi in ((3, 8), (4, 10), (5, 11), (6, 10)):
    for reading in ("a", "b"):
        w = results[reading][0][..., lo:hi].mean(-1)
        st = vim3.rm_anova_2x2(w)
        print(f"window {lo/10:.1f}-{(hi-1)/10:.1f} s, reading ({reading}):",
              ", ".join(f"{e} F = {v[0]:.2f}, p = {v[3]:.3f}" for e, v in st.items()))
# the effect sizes: largest condition difference in the window, as a fraction of the mean
for reading in ("a", "b", "c", "d", "e"):
    w = results[reading][1].mean(0)
    print(f"reading ({reading}): condition means {w.ravel().round(4)}, range / mean = {(w.max() - w.min()) / w.mean():.3f}")
Reading (a): mean correlation over participants by lag (s); rows are conditions
               0.0    0.1    0.2    0.3    0.4    0.5    0.6    0.7    0.8    0.9    1.0    1.1    1.2    1.3    1.4    1.5    1.6    1.7    1.8    1.9
upper/above -0.001 -0.001 -0.001 -0.001  0.008  0.043  0.068  0.055  0.034  0.017  0.004  0.001  0.003  0.004 -0.003  0.006  0.002 -0.001  0.000 -0.001
upper/below -0.000  0.000 -0.001 -0.000  0.003  0.047  0.070  0.056  0.039  0.016  0.004  0.001  0.003  0.001 -0.005  0.003  0.003 -0.001  0.001  0.005
lower/above -0.001 -0.001  0.001 -0.003  0.005  0.053  0.066  0.050  0.038  0.013  0.004 -0.000  0.010 -0.000  0.002  0.003  0.001 -0.005  0.003  0.002
lower/below -0.002  0.001 -0.000 -0.002  0.006  0.049  0.061  0.052  0.038  0.013  0.009  0.007  0.005 -0.000 -0.003 -0.000  0.004 -0.004 -0.003  0.003
peak lag per condition (s): {'upper/above': 0.6, 'upper/below': 0.6, 'lower/above': 0.6, 'lower/below': 0.6}
range over all participants, conditions and lags: -0.011 to 0.115
reading (b): peak lag per condition (s): {'upper/above': 0.6, 'upper/below': 0.6, 'lower/above': 0.7, 'lower/below': 0.6}
reading (c): peak lag per condition (s): {'upper/above': 0.6, 'upper/below': 0.6, 'lower/above': 0.6, 'lower/below': 0.6}
reading (d): peak lag per condition (s): {'upper/above': 0.6, 'upper/below': 0.6, 'lower/above': 0.7, 'lower/below': 0.6}
reading (e): peak lag per condition (s): {'upper/above': 0.6, 'upper/below': 0.6, 'lower/above': 0.6, 'lower/below': 0.6}
window 0.3-0.7 s, reading (a): pres F = 0.64, p = 0.456, src F = 0.01, p = 0.938, pres:src F = 0.31, p = 0.600
window 0.3-0.7 s, reading (b): pres F = 0.01, p = 0.945, src F = 0.00, p = 0.970, pres:src F = 0.22, p = 0.654
window 0.4-0.9 s, reading (a): pres F = 2.60, p = 0.158, src F = 0.00, p = 0.979, pres:src F = 0.45, p = 0.529
window 0.4-0.9 s, reading (b): pres F = 0.00, p = 0.987, src F = 0.00, p = 0.947, pres:src F = 1.04, p = 0.347
window 0.5-1.0 s, reading (a): pres F = 0.39, p = 0.557, src F = 0.28, p = 0.614, pres:src F = 0.41, p = 0.548
window 0.5-1.0 s, reading (b): pres F = 0.04, p = 0.844, src F = 0.52, p = 0.497, pres:src F = 2.35, p = 0.176
window 0.6-0.9 s, reading (a): pres F = 7.51, p = 0.034, src F = 0.02, p = 0.897, pres:src F = 0.29, p = 0.612
window 0.6-0.9 s, reading (b): pres F = 0.04, p = 0.843, src F = 0.18, p = 0.685, pres:src F = 0.50, p = 0.506
reading (a): condition means [0.0376 0.0385 0.0374 0.0364], range / mean = 0.056
reading (b): condition means [0.0383 0.0365 0.0366 0.0382], range / mean = 0.046
reading (c): condition means [0.0406 0.0383 0.0392 0.0395], range / mean = 0.060
reading (d): condition means [0.0419 0.0403 0.0411 0.042 ], range / mean = 0.039
reading (e): condition means [0.0393 0.0427 0.042  0.0413], range / mean = 0.083

Result: reproduced. No effect of presentation, source or their interaction reaches p < 0.05 under either reading the criterion names (smallest p 0.158 in reading (a) and 0.347 in reading (b)), or under variants (c), (d) and (e). The mean response peaks at 0.6 s in all four conditions under readings (a), (c) and (e), and under (b) and (d) at 0.6 s in three conditions and 0.7 s in the fourth (lower/above). The condition means in the window differ by less than a tenth of their mean (range over mean 0.039 to 0.083). The lines of task.py printed above confirm the bin edges (presses by >, targets by >=), the p1004 rule, any key counting as a response, the skipping of presses and targets at or before 32 s (lines 53 to 54 and 99 to 100), and the assignment to the event starting strictly between 0 and 2 s after the bin. That strict window drops targets that fall exactly on an event onset (1023 unassigned targets in reading (a), 918 in (b)); variant (d) keeps them (none unassigned) and gives no effect below p = 0.49. Assigning each target to the event in progress, variant (e), gives the smallest p of any variant, 0.053 for the interaction, still above 0.05. Each participant has 103 to 200 assigned targets per condition in every reading, so no condition is under-sampled. The null depends to some degree on the window under reading (a): of the other windows shown, 0.6 to 0.9 s gives a presentation effect (F = 7.51, p = 0.034); none does under reading (b), and the claim's window is that of group.py. Under reading (a) a target at time t is binned at t and compared with events starting between t + 32 and t + 34 s (line 141), so its condition label is that of an event about 32 s after the target. From this code we infer that these labels are unrelated to the event during which the target appeared; no output here measures that. Reading (b) is the one the legend describes, and it gives the same outcome.

no-radial-bias-in-patches (blocked; variant under assumed calibrations)¶

The output of Gabor filters oriented at 45 and 135 degrees does not differ significantly, so the patches show no reliable radial bias. (Results and Discussion, paragraph 6)

Criterion (claims file): filter outputs as in fig5bc-spatial-frequency, averaged over spatial frequency; for each DKL channel, source location and side, a paired t-test over the 30 images of 45 against 135 degree output, 12 tests, uncorrected, reproduced when none has p < 0.05; the luminance channel alone (4 tests) as a variant. The test needs no responses, only the stimulus screenshots, which are in the data set, and the DKL transform, which needs the CIE coordinates of the monitor's primaries (Methods, Image patch analysis: "the CIE coordinates of the red, green, and blue channels of the monitor (as measured with a colorimeter) were used"). These are not in the paper, its code or the data set, so the claim is blocked. To show what the data set supports, the test is run here as imstats.py runs it, under two assumed calibrations (sRGB and Adobe RGB primaries, two common LCD gamuts) and at 78.7 pixels per degree, with 78.2 as the other value the claims file names. Pixel values are taken as linear, as the Methods (the display was linearised) and imstats.py (pixel value / 255 converted directly) do. The first cell prints the lines of the paper's code followed, checks the patch geometry and shows the colour inside the patches.

In [9]:
show_lines(CODE + "imstats.py", ["ap_pos_pix =", "ap_size_pix =", "cap_size_pix =", "pres_str =", "i_row_start =",
                                 "i_col_start =", "cap_centre_pix[", "ap_pos_pix[horiz]", "frag.astype", "rgb_image_to_dkl",
                                 "radius=0.9", "sfs = [", "thetas =", "gamma =", "psi =", "sigma = (", "wl * 1.0", "((2 ** 1)",
                                 "k_size = int", "filt_ori =", "cv2.getGaborKernel", "cv2.filter2D", "np.sum(out ** 2",
                                 "np.mean(filt_out, axis=-2)", "ttest_rel", "data[:, 1], data[:, 3]"])
show_lines(EXP_CODE + "config.py", ["ap_size_deg =", "ap_ecc_deg =", "ap_offset_deg =", '"al":', '"ar":', "monitor_name"])

rb_rng = np.random.default_rng(13)  # this section's generator (nothing here is random; kept for the rule)
screens = {(int(n.split("_img_id_")[1][:3]), n.split("src_loc_")[1][0]): vim3.read_png(b)
           for n, b in stim["png"].items() if n.endswith("pres_loc_u.png")}
screens_low = {(int(n.split("_img_id_")[1][:3]), n.split("src_loc_")[1][0]): vim3.read_png(b)
               for n, b in stim["png"].items() if n.endswith("pres_loc_l.png")}
img_ids = sorted({k[0] for k in screens})
print("\nupper presentation screenshots", len(screens), "| lower", len(screens_low), "| images", len(img_ids),
      "| sources", sorted({k[1] for k in screens}))
off = vim3.AP_ECC_DEG / np.sqrt(2) * vim3.PIX_PER_DEG
print(f"pixels per degree {vim3.PIX_PER_DEG:.2f}; aperture centre offset {off:.1f} px; square {vim3.PATCH_PIX} px "
      f"(4.5 degrees = {4.5 * vim3.PIX_PER_DEG:.1f} px)")
r = np.hypot(*np.meshgrid(np.linspace(-1, 1, vim3.PATCH_PIX), np.linspace(-1, 1, vim3.PATCH_PIX)))
inner, outer = r <= 0.8, r >= 1.05
rows = []
for (img_id, src_), img in screens.items():
    crops = vim3.patch_crops(img) * 255
    # the lower presentation screenshot should hold the same patches, translated; the row of a square is
    # rounded down, so the best of shifts up to 3 px is taken
    big = vim3.patch_crops(screens_low[(img_id, src_)], size=vim3.PATCH_PIX + 6, field="lower") * 255
    for side, name in ((0, "left"), (1, "right")):
        c = crops[side]
        rows.append({"image": img_id, "source": src_, "side": name,
                     "median |px - 128| inside r 0.8": np.median(np.abs(c[inner] - 128).max(-1)),
                     "median |px - 128| corners r >= 1.05": np.median(np.abs(c[outer] - 128).max(-1)),
                     "fraction of pixels R, G, B not all equal (inside)": np.mean((c[inner][:, 0] != c[inner][:, 1]) | (c[inner][:, 1] != c[inner][:, 2])),
                     "largest |R - B| inside": np.abs(c[inner][:, 0] - c[inner][:, 2]).max(),
                     **dict(zip(["mean |upper - lower patch| inside, best shift", "row shift", "column shift"],
                                min((np.abs(c[inner] - big[side][3 + dr:3 + dr + vim3.PATCH_PIX, 3 + dc:3 + dc + vim3.PATCH_PIX][inner]).mean(), dr, dc)
                                    for dr in range(-3, 4) for dc in range(-3, 4))))})
geo = pd.DataFrame(rows)
print(geo.drop(columns=["image", "source", "side"]).describe().loc[["min", "50%", "max"]].round(3).T.to_string())
print("patches with R, G, B not all equal in more than half the pixels inside:", int((geo["fraction of pixels R, G, B not all equal (inside)"] > 0.5).sum()), "of", len(geo))

import matplotlib.pyplot as plt
fig, axes = plt.subplots(1, 4, figsize=(12, 3.3))
k0 = (img_ids[0], "a"), (img_ids[0], "b")
for ax, (key, side) in zip(axes, [(k0[0], 0), (k0[0], 1), (k0[1], 0), (k0[1], 1)]):
    ax.imshow(vim3.patch_crops(screens[key])[side])
    t = np.linspace(0, 2 * np.pi, 200)
    h = (vim3.PATCH_PIX - 1) / 2
    ax.plot(h + 0.9 * h * np.cos(t), h + 0.9 * h * np.sin(t), lw=0.8, color="white")
    ax.set_title(f"image {key[0]:03d}, source {'above' if key[1] == 'a' else 'below'}, {'left' if side == 0 else 'right'}", fontsize=9)
    ax.set_xticks([]); ax.set_yticks([])
fig.suptitle("Patch squares cut from the upper presentation screenshot; white circle: filter mask radius 0.9", fontsize=10)
plt.show()
imstats.py
 (538 lines)
    25      ap_pos_pix = {
    33      ap_size_pix = psychopy.misc.deg2pix(
    39      cap_size_pix = np.array([1200, 1920])
    79                  pres_str = "pres_loc_a"
    99                      i_row_start = int(
   100                          cap_centre_pix[0] -
   101                          ap_pos_pix[horiz][1] -
   105                      i_col_start = int(
   106                          cap_centre_pix[1] +
   107                          ap_pos_pix[horiz][0] -
   117                      frag = frag.astype("float") / 255.0
   119                      frag_in_dkl = monitors.conversions.rgb_image_to_dkl(
   168          radius=0.9,
   210                              np.sum(np.sum(out ** 2, axis=-1), axis=-1)
   245          out = cv2.filter2D(
   263      sfs = [1.0, 2.0, 4.0, 8.0, 16.0]
   273      thetas = np.radians([0, 45, 90, 135])
   275      gamma = 1
   277      psi = np.pi / 2
   284          sigma = (
   285              wl * 1.0 / np.pi * np.sqrt(np.log(2) / 2.0) *
   287                  ((2 ** 1) + 1) / ((2 ** 1) - 1)
   291          k_size = int(sigma * 6)
   304              filt_ori = np.mod(-ori - np.pi / 2.0, 2 * np.pi)
   306              filt = cv2.getGaborKernel(
   339      filt_out = np.mean(filt_out, axis=-2)
   356                  test_meth = scipy.stats.ttest_rel
   359                  (t, p) = test_meth(data[:, 1], data[:, 3])
config.py (192 lines)
    72      stim_conf.ap_size_deg = 4.5
    73      stim_conf.ap_ecc_deg = 5.37
    75      ap_offset_deg = stim_conf.ap_ecc_deg / np.sqrt(2.0)
    78          "al": [-ap_offset_deg, +ap_offset_deg],
    79          "ar": [+ap_offset_deg, +ap_offset_deg],
   103      exp_conf.monitor_name = "BOLDscreen"
upper presentation screenshots 60 | lower 60 | images 30 | sources ['a', 'b']
pixels per degree 78.69; aperture centre offset 298.8 px; square 353 px (4.5 degrees = 354.1 px)
                                                      min     50%      max
median |px - 128| inside r 0.8                     33.000  97.500  127.000
median |px - 128| corners r >= 1.05                 0.000   0.000    0.000
fraction of pixels R, G, B not all equal (inside)   0.027   1.000    1.000
largest |R - B| inside                             22.000  60.000  187.000
mean |upper - lower patch| inside, best shift       0.051   0.536    3.896
row shift                                          -2.000  -1.000   -1.000
column shift                                        0.000   0.000    0.000
patches with R, G, B not all equal in more than half the pixels inside: 118 of 120
No description has been provided for this image
In [10]:
import cv2
# the numpy Gabor kernel and filter of vim3 against OpenCV, which imstats.py uses
bank = vim3.filter_bank()
dk = []
for sf, b in zip((1.0, 2.0, 4.0, 8.0, 16.0), bank):
    wl = vim3.PIX_PER_DEG / sf
    sigma = wl / np.pi * np.sqrt(np.log(2) / 2.0) * 3.0
    for i_o, o in enumerate((0, 45, 90, 135)):
        kc = cv2.getGaborKernel((b.shape[-1], b.shape[-1]), sigma, np.mod(-np.radians(o) - np.pi / 2, 2 * np.pi), wl, 1.0, np.pi / 2, ktype=cv2.CV_64F)
        dk.append(np.abs(kc - b[i_o]).max())
test_patch = (vim3.patch_crops(screens[(img_ids[0], "a")])[0] - 0.5) @ vim3.rgb_to_dkl_matrix(vim3.CALIBRATIONS["sRGB"]).T
test_patch = test_patch[..., 0] * vim3.circle_mask(vim3.PATCH_PIX, 0.9)
mine = vim3.filter_output(test_patch, bank)
ocv = np.array([[np.sqrt((cv2.filter2D(test_patch, cv2.CV_64F, b[i]) ** 2).sum()) for i in range(4)] for b in bank])
print(f"kernel size per spatial frequency {[b.shape[-1] for b in bank]}; largest kernel difference from cv2 {max(dk):.1e}; "
      f"largest relative filter output difference from cv2.filter2D {np.abs(mine / ocv - 1).max():.1e}")

chan = ["luminance", "L-M", "S-(L+M)"]
filt = {}
for cal, ppd in (("sRGB", vim3.PIX_PER_DEG), ("Adobe RGB", vim3.PIX_PER_DEG), ("sRGB", 78.2)):
    t0 = time.time()
    f = vim3.patch_filter_outputs(screens, vim3.CALIBRATIONS[cal], ppd, img_ids)
    filt[(cal, round(ppd, 1))] = f
    print(f"\n{cal} primaries, {ppd:.1f} px per degree ({time.time() - t0:.0f} s); RGB to DKL rows (unit length):")
    print(np.round(vim3.rgb_to_dkl_matrix(vim3.CALIBRATIONS[cal]), 4))
    sd = f.mean(-1).mean(-1)  # mean over sf and ori
    print("  filter output, mean over sf and orientation, range per channel:",
          {chan[c]: f"{sd[..., c].min():.3g} to {sd[..., c].max():.3g}" for c in range(3)})
    tab = pd.DataFrame(vim3.radial_bias_tests(f), columns=["channel", "source", "side", "t(29)", "p", "mean 45-135", "median 45-135"])
    tab["channel"] = [chan[c] for c in tab.channel]
    tab["source"] = np.where(tab.source == 0, "above", "below")
    tab["side"] = np.where(tab.side == 0, "left", "right")
    tab["mean 45-135 / mean output"] = [row["mean 45-135"] / f.mean(-2)[:, 0 if row.source == "above" else 1,
                                        0 if row.side == "left" else 1, chan.index(row.channel)][:, [1, 3]].mean()
                                        for _, row in tab.iterrows()]
    print(tab.to_string(index=False, float_format=lambda x: f"{x:.3g}"))
    print(f"  tests with p < 0.05: {int((tab.p < 0.05).sum())} of 12; luminance channel: {int((tab[tab.channel == 'luminance'].p < 0.05).sum())} of 4;"
          f" smallest p {tab.p.min():.3f}")
kernel size per spatial frequency [265, 133, 67, 33, 17]; largest kernel difference from cv2 2.2e-16; largest relative filter output difference from cv2.filter2D 8.9e-16
sRGB primaries, 78.7 px per degree (64 s); RGB to DKL rows (unit length):
[[ 0.1503  0.5057  0.0511]
 [ 0.0535 -0.0382 -0.0153]
 [-0.0017 -0.0053  0.007 ]]
  filter output, mean over sf and orientation, range per channel: {'luminance': '2.45e+03 to 1.34e+04', 'L-M': '29.5 to 715', 'S-(L+M)': '5.05 to 72'}
  channel source  side  t(29)      p  mean 45-135  median 45-135  mean 45-135 / mean output
luminance  above  left -0.281  0.781        -65.8           -169                   -0.00856
luminance  above right  0.552  0.585          213           29.5                     0.0275
luminance  below  left  0.272  0.788         73.1          -42.9                      0.012
luminance  below right  -1.93  0.063         -392           -162                    -0.0663
      L-M  above  left -0.391  0.699        -3.62           4.82                    -0.0301
      L-M  above right -0.934  0.358        -4.77           -6.6                    -0.0437
      L-M  below  left -0.836   0.41        -3.11          -1.33                    -0.0303
      L-M  below right -0.932  0.359        -4.26          -1.34                     -0.045
  S-(L+M)  above  left  0.264  0.794        0.221          0.663                    0.00989
  S-(L+M)  above right  -1.74 0.0919        -1.37          -1.13                    -0.0607
  S-(L+M)  below  left  0.226  0.822        0.138         -0.362                    0.00796
  S-(L+M)  below right -0.131  0.896      -0.0754         0.0899                   -0.00473
  tests with p < 0.05: 0 of 12; luminance channel: 0 of 4; smallest p 0.063
Adobe RGB primaries, 78.7 px per degree (62 s); RGB to DKL rows (unit length):
[[ 0.2103  0.4436  0.0532]
 [ 0.0748 -0.0589 -0.0159]
 [-0.0024 -0.0049  0.0073]]
  filter output, mean over sf and orientation, range per channel: {'luminance': '2.4e+03 to 1.34e+04', 'L-M': '30.8 to 963', 'S-(L+M)': '5.49 to 81.4'}
  channel source  side  t(29)      p  mean 45-135  median 45-135  mean 45-135 / mean output
luminance  above  left -0.293  0.772        -68.6           -162                   -0.00892
luminance  above right  0.541  0.593          208           11.5                     0.0268
luminance  below  left   0.28  0.782         75.4            -45                     0.0124
luminance  below right  -1.92 0.0646         -395           -164                    -0.0669
      L-M  above  left  -0.46  0.649        -5.77           5.15                    -0.0371
      L-M  above right -0.886  0.383        -5.97          -8.59                    -0.0428
      L-M  below  left -0.887  0.382        -4.31          -1.32                    -0.0321
      L-M  below right -0.986  0.332        -6.02           -2.1                    -0.0487
  S-(L+M)  above  left  0.226  0.823        0.216          0.909                    0.00901
  S-(L+M)  above right  -1.69  0.102        -1.44          -1.26                    -0.0594
  S-(L+M)  below  left  0.136  0.893       0.0905         -0.374                    0.00481
  S-(L+M)  below right -0.182  0.857       -0.115           0.17                    -0.0067
  tests with p < 0.05: 0 of 12; luminance channel: 0 of 4; smallest p 0.065
sRGB primaries, 78.2 px per degree (61 s); RGB to DKL rows (unit length):
[[ 0.1503  0.5057  0.0511]
 [ 0.0535 -0.0382 -0.0153]
 [-0.0017 -0.0053  0.007 ]]
  filter output, mean over sf and orientation, range per channel: {'luminance': '2.38e+03 to 1.32e+04', 'L-M': '28.8 to 706', 'S-(L+M)': '4.98 to 70.9'}
  channel source  side   t(29)      p  mean 45-135  median 45-135  mean 45-135 / mean output
luminance  above  left  -0.149  0.883        -34.7           -134                   -0.00457
luminance  above right   0.438  0.664          165          -15.3                     0.0216
luminance  below  left   0.297  0.768         80.4          -38.9                     0.0134
luminance  below right   -1.92 0.0642         -385           -154                    -0.0662
      L-M  above  left  -0.453  0.654        -4.14           4.17                     -0.035
      L-M  above right  -0.875  0.389         -4.4          -6.11                    -0.0409
      L-M  below  left  -0.865  0.394         -3.1          -1.04                    -0.0306
      L-M  below right  -0.912  0.369        -4.12          -2.89                    -0.0442
  S-(L+M)  above  left   0.191   0.85        0.156          0.497                    0.00709
  S-(L+M)  above right   -1.65   0.11        -1.33          -1.01                    -0.0595
  S-(L+M)  below  left   0.228  0.821        0.134         -0.317                    0.00785
  S-(L+M)  below right -0.0918  0.927      -0.0527          0.154                   -0.00336
  tests with p < 0.05: 0 of 12; luminance channel: 0 of 4; smallest p 0.064

Result: blocked, metadata insufficient. The test needs the CIE coordinates of the monitor's primaries, which are not public, so it decides nothing. Under the two assumed calibrations and both pixel-per-degree values shown, none of the 12 paired t-tests of 45 against 135 degree output has p < 0.05 (smallest p 0.063, 0.065 and 0.064, each the luminance channel for patches from below on the right, t(29) = -1.93 to -1.92), and none of the 4 luminance tests does. The mean 45 minus 135 degree difference is at most 7% of the mean output in any test, and the t values change by at most 0.1 between the calibrations. The squares sit where imstats.py cuts them: the median pixel differs from the background grey by 33 to 127 levels inside radius 0.8 and by 0 in the corners, and the figure shows the patch inside each square. 118 of the 120 patches have R, G and B not all equal in more than half their pixels inside the mask, so they are in colour and the chromatic channels need the calibration. The lower presentation screenshots hold the same patches translated (mean difference 0.05 to 3.9 levels at a shift of 1 or 2 rows). The vim3 Gabor kernels and filter match OpenCV's to rounding (largest kernel difference 2.2e-16, largest relative filter output difference 8.9e-16).

Volume variant of the response claims (no outcome rests on it)¶

The response claims need V1, V2 and V3, which are not in the data set, and they are blocked. To show what the data set can support, the paper's response analysis (Methods, Response amplitude) is repeated here on the volume localiser masks of the data check: for each participant and field, the mean time course over all voxels with t > 2.58, a GLM with one regressor per image and source (60 per field), and psc from the polynomial baseline. These masks are not V1 to V3: they include any responsive voxel in the 35-slice occipital slab, the data are not motion corrected and OLS replaces 3dREMLfit, and there is no area factor. The numbers below describe the data set and are not compared with the claims' tolerances.

In [11]:
labels = participants[0]["fields"][0]["labels"]
assert all(r["fields"][f]["labels"] == labels for r in participants for f in (0, 1))
A = np.array([[r["fields"][f]["psc_image"] for f in (0, 1)] for r in participants]).reshape(7, 2, 30, 2)
m = A.mean(2)  # participant, pres (upper, lower), src (above, below)
print("psc per participant (mean over 30 images):")
print(pd.DataFrame({names[k]: m[:, k[0], k[1]] for k in names}, index=[r["id"] for r in participants]).round(3).to_string())
print("mean over participants:", {names[k]: round(float(m[:, k[0], k[1]].mean()), 3) for k in names})
print("range of all per-image psc values:", A.min().round(2), "to", A.max().round(2))
for label, sub in (("all 7", slice(None)), ("without p1011", [i for i, r in enumerate(participants) if r["id"] != "p1011"])):
    mm = m[sub]
    an = vim3.rm_anova_2x2(mm)
    tl = stats.ttest_rel(mm[:, 1, 1], mm[:, 1, 0])
    tu = stats.ttest_rel(mm[:, 0, 1], mm[:, 0, 0])
    print(f"\n{label}: presentation x source F(1,{an['pres:src'][2]}) = {an['pres:src'][0]:.2f}, p = {an['pres:src'][3]:.3f}"
          f" | source F = {an['src'][0]:.2f}, p = {an['src'][3]:.3f} | presentation F = {an['pres'][0]:.2f}, p = {an['pres'][3]:.3f}")
    print(f"  lower field, below vs above: {mm[:, 1, 1].mean():.3f} vs {mm[:, 1, 0].mean():.3f} psc, t = {tl.statistic:.2f}, p = {tl.pvalue:.3f}")
    print(f"  upper field, below vs above: {mm[:, 0, 1].mean():.3f} vs {mm[:, 0, 0].mean():.3f} psc, t = {tu.statistic:.2f}, p = {tu.pvalue:.3f}")
d = (A[:, 0] - A[:, 1]).mean(0).reshape(60)  # upper minus lower, mean over participants
order = np.argsort(d)
lab = np.array([f"{i:03d} {s}" for i, s in labels])
print("\nfive most upper-preferred:", list(zip(lab[order[::-1][:5]], d[order[::-1][:5]].round(3))))
print("five most lower-preferred:", list(zip(lab[order[:5]], d[order[:5]].round(3))))
src = np.array([s for _, s in labels])
print("above among top five upper-preferred:", int((src[order[::-1][:5]] == "above").sum()),
      "| below among top five lower-preferred:", int((src[order[:5]] == "below").sum()))
rm = np.array([[r["fields"][f]["resid_ms"] for f in (0, 1)] for r in participants])
print("\nmean squared residual of the ROI GLM, psc^2, upper and lower:", rm.round(3).tolist())
print("upper larger in", int((rm[:, 0] > rm[:, 1]).sum()), "of 7; paired t =", round(stats.ttest_rel(rm[:, 0], rm[:, 1]).statistic, 2),
      "p =", round(stats.ttest_rel(rm[:, 0], rm[:, 1]).pvalue, 3))
psc per participant (mean over 30 images):
       upper/above  upper/below  lower/above  lower/below
p1008        1.046        0.926        0.851        0.904
p1006        0.940        0.929        0.829        0.904
p1011        1.375        1.224        1.249        1.631
p1004        0.888        0.906        0.762        0.785
p1001        0.879        1.013        0.866        0.932
p1003        0.836        0.849        0.791        0.960
p1010        0.790        0.890        0.745        0.860
mean over participants: {'upper/above': 0.965, 'upper/below': 0.963, 'lower/above': 0.87, 'lower/below': 0.997}
range of all per-image psc values: -0.83 to 4.63

all 7: presentation x source F(1,6) = 2.94, p = 0.137 | source F = 8.51, p = 0.027 | presentation F = 0.78, p = 0.412
  lower field, below vs above: 0.997 vs 0.870 psc, t = 2.73, p = 0.034
  upper field, below vs above: 0.963 vs 0.965 psc, t = -0.06, p = 0.957

without p1011: presentation x source F(1,5) = 2.53, p = 0.172 | source F = 5.41, p = 0.068 | presentation F = 6.57, p = 0.050
  lower field, below vs above: 0.891 vs 0.807 psc, t = 3.99, p = 0.010
  upper field, below vs above: 0.919 vs 0.897 psc, t = 0.62, p = 0.562

five most upper-preferred: [(np.str_('971 above'), np.float64(0.54)), (np.str_('042 above'), np.float64(0.508)), (np.str_('856 below'), np.float64(0.434)), (np.str_('352 above'), np.float64(0.422)), (np.str_('314 above'), np.float64(0.311))]
five most lower-preferred: [(np.str_('042 below'), np.float64(-0.569)), (np.str_('376 below'), np.float64(-0.498)), (np.str_('224 below'), np.float64(-0.399)), (np.str_('338 below'), np.float64(-0.284)), (np.str_('600 below'), np.float64(-0.284))]
above among top five upper-preferred: 4 | below among top five lower-preferred: 5

mean squared residual of the ROI GLM, psc^2, upper and lower: [[0.489, 0.594], [0.384, 0.359], [4.404, 6.696], [0.355, 0.262], [0.487, 0.434], [0.783, 0.217], [0.259, 0.238]]
upper larger in 5 of 7; paired t = -0.66 p = 0.531

In this volume substitute, lower-field responses are larger for patches from below fixation than from above, the upper-field responses do not differ by source, and the most lower-preferred patch pairs are mostly from below fixation (5 of 5, and 4 of 5 upper-preferred from above), the pattern the paper reports; the presentation by source interaction is weaker than the paper's (p = 0.137). The residual of the region's GLM is larger for upper presentation in 5 of 7 participants, but not on average, because of p1011, whose region is large and whose residuals are an order of magnitude larger than the others'. The printed numbers are the record of this; none of them is an outcome, since the region is not the paper's.

Summary¶

Claim Data Outcome
localiser-masks-ventral-dorsal dataset blocked: data missing
presentation-source-interaction dataset blocked: data missing
interaction-not-area-dependent dataset blocked: data missing
lower-field-below-greater dataset blocked: data missing
upper-field-no-source-difference dataset blocked: data missing
fig4-top-five-matching-source dataset blocked: data missing
fig4-qualitative-content with inputs blocked: data missing
fig5a-mean-luminance with inputs blocked: data missing
fig5-no-other-pixel-relations with inputs blocked: data missing
fig5bc-spatial-frequency with inputs blocked: data missing
fig5def-orientation with inputs blocked: data missing
fig5-no-other-filter-relations with inputs blocked: data missing
no-radial-bias-in-patches with inputs blocked: metadata insufficient
figs2-task-no-condition-difference dataset reproduced
figs3-residual-no-condition-difference dataset blocked: data missing
figs3-residual-upper-larger dataset blocked: data missing

How the analysis differs from the paper's. The tested claim follows task.py and group.py, with the ANOVA computed as paired contrasts (exact for a 2 x 2 design) in place of the code's fmri_tools routine. The radial-bias variant follows imstats.py with assumed monitor calibrations in place of the measured one, and OpenCV's Gabor kernel and filter written out in numpy and scipy (checked against OpenCV above). The volume checks and variant use OLS without slice timing or motion correction, in the volume, without the V1 to V3 restriction.

What was found about the data set. The archive holds the functional runs, event sequences and task files of all seven participants, with no duplicated recording, and its file matches its listed md5. It lacks the V1, V2 and V3 definitions, the cortical surfaces and anatomical images, which 14 of the 16 claims need directly or through the claims they depend on; it holds the stimulus screenshots but not the monitor calibration needed to put them in DKL space, so the radial-bias test, which needs nothing else, is blocked too, and 15 claims are blocked in all. The NIfTI files are named by scanner series, not run, and the descriptor does not give the mapping; the paper's code does, and the data support it for six participants. For p1011 the clock and run order could not be confirmed in uncorrected volume data, and that participant moves more than the others.