Scherrer, Lynch et al. (2023), dandiset 000691: more (n2) null decoders for fig2-quadrant-direction-decoding¶

Paper. Scherrer JR, Lynch GF, Zhang JJ, Fee MS (2023). An optical design enabling lightweight and large field-of-view head-mounted microscopes. Nature Methods 20, 546-549. doi:10.1038/s41592-023-01806-1.

Claims. claims/000691/10.1038-s41592-023-01806-1.yaml, written from the full text of the version of record and the paper's code (GitHub FeeLab/Feescope-Paper-Code, commit d596646). It decides what is tested and how.

Dandiset. DANDI:000691, version 0.260827.1358, the only published version (the paper cites none); see the main notebook, reproduce_scherrer_2023.ipynb, for the reasons and the full data check.

Why this notebook. The criterion of fig2-quadrant-direction-decoding judges p under two readings of a null decoder: (n1) one fit per shuffle and (n2) the average matrix of 200 fits per shuffle. The 1,000 (n2) decoders it asks for need 200,000 fits, more than a day on four cores (measured in the decoding notebook), and are not run. The first verification asked for more of them, to show where they lie; this notebook runs 8, a number chosen here to keep the notebook well within the time limit, beside the one in decoding_quadrant_direction.ipynb. They cannot give p < 0.001 and decide no outcome alone.

Claim Data Status
fig2-quadrant-direction-decoding dandiset 8 more (n2) null decoders
In [1]:
import time
import warnings

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

import kiloscope as ks

pd.set_option("display.width", 200)
warnings.filterwarnings("ignore", category=RuntimeWarning)
started = time.time()
urls = ks.asset_urls()
f = ks.open_nwb(urls)
S = ks.load_session(f)
POS = ks.mask_positions(ks.read_masks(urls[ks.NWB_PATH], f))
track, B = ks.load_behaviour(urls, S)
run = B["running"]
X_run = ks.moving_max(S["traces"][B["sel"]])[run]
X_F = np.asfortranarray(X_run)         # columns contiguous, for fast shuffles
print(f"loaded and tracked in {time.time() - started:.0f} s")
loaded and tracked in 187 s

Data check¶

The full check of the data is in the main notebook. Here: what this notebook decodes.

In [2]:
LABELS_QD = ks.quad_dir_labels(B)[run]
LABELS_OCT = B["octant"][run]
print(f"imaging frames within the tracked video: {len(B['sel'])}; running (speed above its median): {run.sum()}")
print(f"activity: moving maximum over 30 frames of {X_run.shape[1]} footprints; values {X_run.min():.3f} to {X_run.max():.3f}")
print("frames per quadrant and direction class:", np.bincount(LABELS_QD, minlength=8).tolist())
print("frames per octant:", np.bincount(LABELS_OCT, minlength=8).tolist())
print(f"footprints with a position (the code's peak pixel): {(~np.isnan(POS['peak']).any(1)).sum()} of {len(POS['peak'])}")
imaging frames within the tracked video: 32056; running (speed above its median): 16028
activity: moving maximum over 30 frames of 2948 footprints; values 0.000 to 0.348
frames per quadrant and direction class: [2845, 2458, 1758, 2025, 1617, 2263, 1474, 1588]
frames per octant: [2557, 2746, 1858, 1925, 2044, 1836, 1372, 1690]
footprints with a position (the code's peak pixel): 2948 of 2948

fig2-quadrant-direction-decoding¶

Linear SVM decoders trained on half of the data decode the mouse's combined quadrant and movement direction on the other half at an accuracy at least three times chance, above that of decoders trained on shuffled data.

Criterion (part): eight classes, lambda 3.2e-7, the average matrix of 200 fits; the null is 1,000 decoders on their own shuffles, p the fraction at or above the real median accuracy, judged under (n1) and (n2); when they disagree on p < 0.001 the claim is methods_underspecified.

The real decoder is computed again here with the seed of the decoding notebook, so that its value is printed beside the null decoders.

In [3]:
LABELS = LABELS_QD
LAMBDA = ks.LAMBDA_QUAD_DIR
t0 = time.time()
real = ks.decoding_matrix(X_run, LABELS, 8, LAMBDA, 200, np.random.default_rng(69120), n_jobs=4)
print(f"real decoder, 200 fits, in {time.time() - t0:.0f} s: median accuracy {real['median']:.3f} (chance 0.125)")
t0 = time.time()
null2 = []
for s_ in np.random.SeedSequence(69123).spawn(8):
    rng_s = np.random.default_rng(s_)
    null2.append(ks.decoding_matrix(ks.shuffle_columns(X_F, rng_s), LABELS, 8, LAMBDA, 200, rng_s, n_jobs=4)["median"])
null2 = np.array(null2)
print(f"8 (n2) null decoders, 200 fits each, in {time.time() - t0:.0f} s")
print("their median accuracies:", np.round(null2, 3).tolist())
print(f"range {null2.min():.3f} to {null2.max():.3f}, mean {null2.mean():.3f}, standard deviation {null2.std(ddof=1):.4f}; "
      f"at or above the real {real['median']:.3f}: {(null2 >= real['median']).sum()}")
print(f"the real value lies {(real['median'] - null2.mean()) / null2.std(ddof=1):.0f} standard deviations of these null values above their mean "
      f"(descriptive only; no distribution is assumed for an outcome)")
real decoder, 200 fits, in 135 s: median accuracy 0.437 (chance 0.125)
8 (n2) null decoders, 200 fits each, in 1107 s
their median accuracies: [0.109, 0.11, 0.119, 0.141, 0.12, 0.089, 0.145, 0.105]
range 0.089 to 0.145, mean 0.117, standard deviation 0.0185; at or above the real 0.437: 0
the real value lies 17 standard deviations of these null values above their mean (descriptive only; no distribution is assumed for an outcome)

Result: blocked (not_runnable). The real decoder, computed again with the decoding notebook's seed, has a median accuracy of 0.437. The eight (n2) null decoders run here give 0.089 to 0.145 (mean 0.117), none at or above it. Eight decoders cannot show p < 0.001, which needs the 1,000 of the criterion, so the claim stays blocked; these values show where the (n2) null lies.

In [4]:
print(f"total run time {(time.time() - started) / 60:.1f} min")
total run time 23.8 min

Summary¶

Claim Outcome (this attempt)
fig2-quadrant-direction-decoding blocked: not runnable (see the decoding notebook)

How the analysis differs from the paper's. As in the decoding notebook: all 2948 footprints, the position tracked from the video, scikit-learn's SGD in place of MATLAB's solver. Only 8 of the 1,000 (n2) null decoders the criterion asks for are run.