Reproducing Xia et al. (2021) from SPARC:108 and SPARC:75¶

Paper. Xia J, Yang H, Mu M, Micovic N, Poskanzer KE, Monaghan JR, Clark HA (2021). Imaging in vivo acetylcholine release in the peripheral nervous system with a fluorescent nanosensor. PNAS 118:e2023807118. doi:10.1073/pnas.2023807118. The claims file (claims/xia-2021.yaml) was written from the version of record and its SI Appendix (Figures S1 to S16, Table S1); Movies S1 to S4 were not available.

Datasets. Both are read anonymously from the public SPARC bucket at a pinned published version, through the version's manifest.json and each file's S3 object version (xia2021.py). The cell after the imports lists every file read, with its SHA-256 from the manifest.

  • SPARC:108, version 1 (doi:10.26275/w027-cisv), "Imaging in vivo acetylcholine release in the peripheral nervous system with a fluorescent nanosensor in mice": HPLC chromatograms, UV-Vis spectra and native PAGE images; ex vivo calibration recordings (sub-1); in vivo recordings at 3 V (sub-2), 8 V (sub-3) and 10 V (sub-4); a confocal stack of a nanosensor-stained ChAT(BAC)-eGFP ganglion (sub-5); and the vesamicol pair (sub-6).
  • SPARC:75, version 1 (doi:10.26275/prjd-jhoc), "Submandibular ganglion stained by bungarotoxin and nanosensors developed by the Clark lab": confocal LSM images of one ChAT(BAC)-eGFP ganglion stained with BTX-AF647 or the nanosensor.

Why these versions. The paper's Data Availability cites the DOI of version 1 of SPARC:108 (10.26275/w027-cisv), so that version is pinned. The paper cites no version of SPARC:75; version 1 is its only published version (Pennsieve Discover lists one version of each dataset), so it is pinned. No version comparison is needed.

Claims. 29 claims; 12 are analysed here, 11 of them with an outcome and figs12-3v-propagation blocked as the deposit holds one of its three mice, and 18 blocked in all.

Claim Tested?
fig2d-hplc-yield tested
fig2g-conjugation-ratios blocked: the spectra of pure AChE and BTX are not deposited (data_missing)
fig2e-page-bands tested
figs3-size blocked: no AFM images (data_missing)
figs5-btx-staining tested (SPARC:75)
fig3d-sensor-on-soma tested (SPARC:108 sub-5, and SPARC:75)
fig3bc-retention blocked: no images of the bare DNA structures (data_missing)
figs4-stability blocked: no 0 h and 5 h images (data_missing)
figs6a-response-time blocked: the time of ACh addition is not recorded (metadata_insufficient)
fig4b-michaelis-menten tested (one mouse of three)
fig4b-lod tested (one mouse of three)
figs6b-unit-calibration blocked: no AF647 channel or AF647 calibration in the ex vivo data (data_missing)
fig4c-control-ph blocked: no control nanosensor or pH data (data_missing)
fig5b-in-vivo-response tested (two 3 V recordings; the paper's three mice are not identified)
fig5b-control-minimal blocked: no control nanosensor recordings (data_missing)
figs8-control-10v blocked: no control nanosensor recordings (data_missing)
fig5c-voltage-dose blocked: no 5 V recording, and 3 V and 10 V come from different mice (data_missing)
fig5c-ach-concentration blocked: depends on fig5c-voltage-dose and figs6b-unit-calibration
fig5d-pulse-dose blocked: no recordings with 10 or 50 pulses (data_missing)
fig5e-reversibility blocked: no recording with three repeated stimulations (data_missing)
figs7b-in-vitro-reversibility blocked: no dialysis-fiber recording (data_missing)
fig6-vesamicol tested (one experiment of four)
figs9-aqua-vs-roi blocked: AQuA (MATLAB) cannot run in this environment (not_runnable)
figs10-control-8v blocked: no control nanosensor recordings (data_missing)
fig7-rostral-caudal tested (sub-3; block onsets in place of AQuA, which cannot run here)
fig7-peak-timing tested (sub-3; block onsets in place of AQuA)
figs12-3v-propagation blocked: one mouse of three deposited (data_missing); analysed on sub-2 and sub-3, that one mouse, with block onsets in place of AQuA
figs16-af647-stable tested
figs13-two-photon blocked: no two-photon images (data_missing)

Method details the claims file leaves open are taken from the paper where it gives them, and every reading the claims file names is run; each choice is cited in xia2021.py and in the section that uses it.

In [1]:
import io
import re
import resource
import time
import warnings

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from scipy import ndimage as ndi
from scipy import stats
from scipy.optimize import OptimizeWarning
from scipy.signal import find_peaks

import xia2021 as X

pd.set_option("display.width", 220)
pd.set_option("display.max_columns", 40)
pd.set_option("display.max_rows", 200)
pd.set_option("display.max_colwidth", 80)
T0 = time.time()
# Exponential fits that overflow on the way to a solution, or give no covariance, warn; the fits that fail are
# replaced by a line and counted where it matters (fig4b-michaelis-menten).
warnings.filterwarnings("ignore", category=RuntimeWarning, message="overflow")
warnings.filterwarnings("ignore", category=OptimizeWarning)


def rss_mb():
    return resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1024


print("SPARC:108 version", X.DATASETS["108"]["version"], X.DATASETS["108"]["doi"],
      "; SPARC:75 version", X.DATASETS["75"]["version"], X.DATASETS["75"]["doi"])
SPARC:108 version 1 10.26275/w027-cisv ; SPARC:75 version 1 10.26275/prjd-jhoc
In [2]:
# Every file this notebook reads, with its size and SHA-256 from the pinned version's manifest (the header's
# checksums; the last cell checks that nothing else was read).
def files_read():
    out = {"108": ["files/dataset_description.xlsx", "files/subjects.xlsx", "files/primary/manifest.xlsx"]
                  + [X.SC + f"HPLC_{c}.csv" for c in ("PHAB", "260_NM", "280_NM", "652_NM")]
                  + [X.SC + n for n in ("2019-08-09_sensor.xml", "2019-08-09_dna_scaffold.xml")]
                  + [X.SC + f"2019-08-09_SENSOR_{c}.tif" for c in ("eb", "PHAB", "AF652")]
                  + list(X.MOVIES.values()) + [X.CZI_SUB5, X.SV + "sub-5/sub-5_2019-11-01 ACh sensor staining in SMG 02 - Same Thresholds_z14.tif"]
                  + sorted(f["path"] for f in X.manifest("108")["files"] if "/sub-1/" in f["path"]),
           "75": ["files/dataset_description.xlsx", "files/subjects.xlsx"]
                 + sorted(f["path"] for f in X.manifest("75")["files"] if f["path"].endswith(".lsm"))}
    return {f"{ds}/{p}": X.entry(ds, p) for ds, ps in out.items() for p in ps}

FILES = files_read()
for key, f in FILES.items():
    print(f"SPARC:{key}  {f['size']:>11,d} B  sha256 {X.sha_hex(*key.split('/', 1))}")
SPARC:108/files/dataset_description.xlsx       24,256 B  sha256 7cbede542e56df780b6175343a201024b3f1d0b5f3844336d5d236a24efe772a
SPARC:108/files/subjects.xlsx       51,553 B  sha256 54f4769a2bb05910d5aa86e744a3e21f9223836ff355638fd6698f75198b0d40
SPARC:108/files/primary/manifest.xlsx        7,934 B  sha256 6b21c1340ad956e2376417aaffcab5aea58136f199466c1ea96b86017b931606
SPARC:108/files/primary/sensor_characterization/HPLC_PHAB.csv    1,332,598 B  sha256 68aef6dbf195853abf242aa2f257e471b60aa9b70bc745db1b975f5ad9075a76
SPARC:108/files/primary/sensor_characterization/HPLC_260_NM.csv      841,834 B  sha256 b92d9ccda0d71aa9fca532faa9134f75d2943efb2e67b7c9b3bf6b8be5a5889a
SPARC:108/files/primary/sensor_characterization/HPLC_280_NM.csv      846,016 B  sha256 dd6304a026abb368b29655facb83c4096904319a8edb2a26960105dc506d0f0a
SPARC:108/files/primary/sensor_characterization/HPLC_652_NM.csv      848,208 B  sha256 760fb7750f4597354eb8f0977ffb2e047593e6f1af1018955566df7042a90311
SPARC:108/files/primary/sensor_characterization/2019-08-09_sensor.xml    1,315,062 B  sha256 ea832625da1e8ab3db4aebf2437b8d43075006cfe5371f72f6bf58a12a41325e
SPARC:108/files/primary/sensor_characterization/2019-08-09_dna_scaffold.xml      133,046 B  sha256 67986f0010be3fab49a07d64464bcf6b7e15c9478280b9144ac041761596377c
SPARC:108/files/primary/sensor_characterization/2019-08-09_SENSOR_eb.tif    6,923,082 B  sha256 700c8042094f8113c1c7a6c8d7bf286f322b6476ecb643de4a5a6b0727ae6d76
SPARC:108/files/primary/sensor_characterization/2019-08-09_SENSOR_PHAB.tif    5,579,352 B  sha256 6129ef799e977ca93b6a65266559f7e5ee97aa769dfc0f49483bd4876b88318e
SPARC:108/files/primary/sensor_characterization/2019-08-09_SENSOR_AF652.tif    5,665,714 B  sha256 d4053b2d5d17e8d63c2de3ababa58b910bcd8a8f9729cbe1bf041c40a2d53b10
SPARC:108/files/primary/sensor_validation/sub-2/sub-2 3V.tif  252,533,666 B  sha256 d6eba7e6c691d37db7afb5f313e72fbe5d2f1e9b6568d2fdcd7b7577caba0f2a
SPARC:108/files/primary/sensor_validation/sub-3/sub-3 8V.tif  256,208,792 B  sha256 c3d5968e0efc1e92b3302b836d593cc7f142945a65e2884dfc750321c819498f
SPARC:108/files/primary/sensor_validation/sub-4/sub-4 10V.tif  133,514,977 B  sha256 be7b384b2b39b9a4462b148118c69ccbb3f5b9e6d063d21eff5ffe042854a245
SPARC:108/files/primary/sensor_validation/sub-6/sub-6_with drug 3v(00299).tif   84,616,253 B  sha256 dbd86de7bf9b9dd9a291a58e1aa8fc65a781b2bb97b6fd20afd8350397808099
SPARC:108/files/primary/sensor_validation/sub-6/sub-6_without drug 3v(00300).tif   86,007,185 B  sha256 e6d0df80bd63310593f9520af5b45c09883bf67227a01240fefd41a9afbb808b
SPARC:108/files/primary/sensor_validation/sub-5/2019-11-01 ACh sensor staining in SMG 02 - Same Thresholds.czi  599,892,448 B  sha256 f1804da1019c3f32cf26c5a944f25a3bbd1ff4ffc2e84be346e07bc344379483
SPARC:108/files/primary/sensor_validation/sub-5/sub-5_2019-11-01 ACh sensor staining in SMG 02 - Same Thresholds_z14.tif    3,493,038 B  sha256 697ea81da1596a975bfd226a22df948359f6c8f42b78677ad3860308ed886c72
SPARC:108/files/primary/sensor_validation/sub-1/sub-1_0.000714 uM    5,715,766 B  sha256 b6a6471374702b39620275054c4b1219f2c244c422dbc761e92f4ca720be570c
SPARC:108/files/primary/sensor_validation/sub-1/sub-1_0.00714 uM    8,832,790 B  sha256 47d67b960d881fb7363d9563c7130003300868a869d93b1128b88b2c71fc63df
SPARC:108/files/primary/sensor_validation/sub-1/sub-1_0.0714 uM    8,573,038 B  sha256 76d99b9989e3898e05682b87f20445a9ccef43e315e85c3f9b8244a0c1d8cb34
SPARC:108/files/primary/sensor_validation/sub-1/sub-1_0.714 uM    6,495,022 B  sha256 f904585a169b0ab2aa12707256f3efa61435f97b1aa4d8116888ce97e84f1c07
SPARC:108/files/primary/sensor_validation/sub-1/sub-1_142.85 uM    7,534,029 B  sha256 c949487332c1b573239d9494b71fee0146fcdbb5e912fc490caa5603b1f333b5
SPARC:108/files/primary/sensor_validation/sub-1/sub-1_7.14 uM    7,793,782 B  sha256 2675f0335b77b84bebad4b77513c89fb8ceba3de2ccfb4a4072a6f51bd173187
SPARC:108/files/primary/sensor_validation/sub-1/sub-1_71.4 uM    7,793,781 B  sha256 4aa6ecd60a9c1db8b478a1c0643df20373554fc4f5f15eb7ef4ead4ca3ca118f
SPARC:108/files/primary/sensor_validation/sub-1/sub-1_714 uM.tif    6,235,269 B  sha256 a913bf725d8a0aea0c01b63c1382823a14c627a837257b8c6cb16c82cbd8bc35
SPARC:75/files/dataset_description.xlsx       24,934 B  sha256 3a773503d06955889b9dafee4cf75d3f3dac1f9c6521e46c85632515b58437da
SPARC:75/files/subjects.xlsx       55,738 B  sha256 30615d8ffce225a1684421cdc9d9cebd4910a1e471bcc6c35797d7b2b8e3f3eb
SPARC:75/files/primary/Sub_01/submandibular ganglion labelled by bungarotoxin Z-stack high magnification.lsm   68,188,294 B  sha256 13819630ac40ede8552018b707d92337be4dfd62ffbbe7202a78560af036e3ac
SPARC:75/files/primary/Sub_01/submandibular ganglion labelled by bungarotoxin Z-stack low magnification.lsm  126,224,513 B  sha256 4b59a1e9008eeeed28221b6b1f592ecfdb0592caeb14af382556df40d3906555
SPARC:75/files/primary/Sub_01/submandibular ganglion labelled by nanosensor high magnification_1.lsm    1,772,768 B  sha256 33037e56b2cf00a0c84e9073c69ea842ea25f938042e45cfc7a3c4cc191a6ceb
SPARC:75/files/primary/Sub_01/submandibular ganglion labelled by nanosensor high magnification_2.lsm    1,772,769 B  sha256 3734b155301c72e6b790f017110de85d91776fe156b4c77e846b04df5ec8b223
SPARC:75/files/primary/Sub_01/submandibular ganglion labelled by nanosensor high magnification_3.lsm    1,772,772 B  sha256 463b11959a108b0e406ddf258c902b7157759448f1464f2a42569980b5289abc
SPARC:75/files/primary/Sub_01/submandibular ganglion labelled by nanosensor low magnification.lsm    2,334,817 B  sha256 6643eb47de2f877171f94066ef9b1b90831ce4bdf6675dd67701c2e0ec1d6551

Data check¶

What each dataset holds, read from its manifest, its SDS sheets and the files themselves. Each check of the metadata against the values is stated under its output.

In [3]:
for ds in ("108", "75"):
    m = X.manifest(ds)
    files = m["files"]
    print(f"SPARC:{ds} version {m['version']} ({X.DATASETS[ds]['doi']}), published {m['datePublished']}: {m['name']}")
    print(f"  {len(files)} files, {sum(f['size'] for f in files) / 1e9:.3f} GB")
    folders = pd.Series(["/".join(f["path"].split("/")[:4]) if f["path"].startswith("files/primary")
                         else "/".join(f["path"].split("/")[:2]) for f in files])
    print(folders.value_counts().sort_index().to_string(), "\n")

for ds in ("108", "75"):
    dd = pd.read_excel(io.BytesIO(X.read_bytes(ds, "files/dataset_description.xlsx")), header=None)
    dd = dd.set_index(0)
    for key in ("Originating Article DOI", "Number of subjects", "Number of samples", "Protocol URL or DOI"):
        vals = [str(v) for v in dd.loc[key].iloc[2:].tolist() if str(v) != "nan"]
        print(f"SPARC:{ds} dataset_description {key}: {vals}")
    sub = pd.read_excel(io.BytesIO(X.read_bytes(ds, "files/subjects.xlsx"))).dropna(how="all", axis=1)
    print(f"SPARC:{ds} subjects.xlsx, every column:")
    print(sub.to_string(index=False), "\n")
SPARC:108 version 1 (10.26275/w027-cisv), published 2021-03-19: Imaging in vivo acetylcholine release in the peripheral nervous system with a fluorescent nanosensor in mice
  73 files, 2.217 GB
banner.jpg                                                            1
files/README                                                          1
files/dataset_description.xlsx                                        1
files/derivative                                                      4
files/primary/manifest.xlsx                                           1
files/primary/sensor_characterization/2019-08-09_SENSOR_AF652.tif     1
files/primary/sensor_characterization/2019-08-09_SENSOR_PHAB.tif      1
files/primary/sensor_characterization/2019-08-09_SENSOR_eb.tif        1
files/primary/sensor_characterization/2019-08-09_dna_scaffold.xml     1
files/primary/sensor_characterization/2019-08-09_sensor.xml           1
files/primary/sensor_characterization/HPLC_260_NM.csv                 1
files/primary/sensor_characterization/HPLC_280_NM.csv                 1
files/primary/sensor_characterization/HPLC_652_NM.csv                 1
files/primary/sensor_characterization/HPLC_PHAB.csv                   1
files/primary/sensor_validation/sub-1                                 8
files/primary/sensor_validation/sub-2                                 1
files/primary/sensor_validation/sub-3                                 1
files/primary/sensor_validation/sub-4                                 1
files/primary/sensor_validation/sub-5                                28
files/primary/sensor_validation/sub-6                                 2
files/subjects.xlsx                                                   1
files/submission.xlsx                                                 1
manifest.json                                                         1
metadata/records                                                      8
metadata/relationships                                                2
metadata/schema.json                                                  1
readme.md                                                             1 

SPARC:75 version 1 (10.26275/prjd-jhoc), published 2020-04-22: Submandibular ganglion stained by bungarotoxin and nanosensors developed by the Clark lab
  41 files, 0.206 GB
banner.jpg                                                                                              1
files/Readme.txt                                                                                        1
files/dataset_description.xlsx                                                                          1
files/derivative                                                                                        8
files/docs                                                                                              1
files/primary/Sub_01/submandibular ganglion labelled by bungarotoxin Z-stack high magnification.lsm     1
files/primary/Sub_01/submandibular ganglion labelled by bungarotoxin Z-stack low magnification.lsm      1
files/primary/Sub_01/submandibular ganglion labelled by nanosensor high magnification_1.lsm             1
files/primary/Sub_01/submandibular ganglion labelled by nanosensor high magnification_2.lsm             1
files/primary/Sub_01/submandibular ganglion labelled by nanosensor high magnification_3.lsm             1
files/primary/Sub_01/submandibular ganglion labelled by nanosensor low magnification.lsm                1
files/samples.xlsx                                                                                      1
files/subjects.xlsx                                                                                     1
files/submission.xlsx                                                                                   1
manifest.json                                                                                           1
metadata/records                                                                                       12
metadata/relationships                                                                                  5
metadata/schema.json                                                                                    1
readme.md                                                                                               1 

SPARC:108 dataset_description Originating Article DOI: ['https://doi.org/10.1101/2020.07.06.189696']
SPARC:108 dataset_description Number of subjects: ['6']
SPARC:108 dataset_description Number of samples: ['0']
SPARC:108 dataset_description Protocol URL or DOI: ['https://www.protocols.io/private/E8556016FD0311EA96240A58A9FEAC2A']
SPARC:108 subjects.xlsx, every column:
subject_id                     experimental group     age    sex      species             strain      RRID for strain      age category age range (min) age range (max)
     sub-1                      calibration curve 5 weeks Female mus musculus C57BL/6 (wildtype) RRID:IMSR_JAX:000664 prime adult stage         4 weeks         8 weeks
     sub-2             dose_dependent stimulation 6 weeks  Male  mus musculus C57BL/6 (wildtype) RRID:IMSR_JAX:000664 prime adult stage         4 weeks         8 weeks
     sub-3             dose_dependent stimulation 6 weeks  Male  mus musculus C57BL/6 (wildtype) RRID:IMSR_JAX:000664 prime adult stage         4 weeks         8 weeks
     sub-4             dose_dependent stimulation 6 weeks Female mus musculus C57BL/6 (wildtype) RRID:IMSR_JAX:000664 prime adult stage         4 weeks         8 weeks
     sub-5                        sensor staining 5 weeks Female mus musculus       ChATBAC-eGFP RRID:IMSR_JAX:007902 prime adult stage         4 weeks         8 weeks
     sub-6 stimulation with and without inhibitor 6 weeks  Male  mus musculus C57BL/6 (wildtype) RRID:IMSR_JAX:000664 prime adult stage         4 weeks         8 weeks 

SPARC:75 dataset_description Originating Article DOI: []
SPARC:75 dataset_description Number of subjects: ['1']
SPARC:75 dataset_description Number of samples: ['1']
SPARC:75 dataset_description Protocol URL or DOI: ['https://www.protocols.io/view/staining-and-imaging-of-mouse-submandibular-gangli-wxrffm6']
SPARC:75 subjects.xlsx, every column:
subject_id     age  sex      species                           strain age category age range (min) age range (max)                 genotype                                                               reference atlas                                                                        protocol title                                                                     protocol.io location software     software version software vendor                                                              software URL
    Sub_01 unknown Male Mus musculus B6.Cg-Tg(RP23-268L19-EGFP)2Mik/J  prime adult         28 days         56 days Tg(RP23-268L19-EGFP)2Mik Purves D., Lichtman J. W., The Journal of Fluorescence, 1987, 7(5): 1492-1497 Staining and imaging of mouse submandibular ganglion by α-bungarotoxin and nanosensor https://www.protocols.io/view/staining-and-imaging-of-mouse-submandibular-gangli-wxrffm6 ZEN blue ZEN 2.6 blue edition           Zeiss https://www.zeiss.com/microscopy/us/products/microscope-software/zen.html 

SPARC:108 has six subjects in subjects.xlsx, with their experiment groups (calibration curve, dose-dependent stimulation, sensor staining, inhibitor), and states 6 subjects; SPARC:75 has one ChAT(BAC)-eGFP mouse and one sample. SPARC:108 names only the bioRxiv preprint (10.1101/2020.07.06.189696) as its originating article, not the PNAS paper; SPARC:75 names none. The next cell compares the primary folder's manifest.xlsx with the files that are there.

In [4]:
man = pd.read_excel(io.BytesIO(X.read_bytes("108", "files/primary/manifest.xlsx")))
print("manifest.xlsx columns:", list(man.columns))
listed = {"files/primary/" + str(f) for f in man["filename"] if str(f) != "manifest.xlsx"}
present = {f["path"] for f in X.manifest("108")["files"] if f["path"].startswith("files/primary/") and not f["path"].endswith("manifest.xlsx")}
print(f"rows in manifest.xlsx: {len(listed)}; files in files/primary: {len(present)}; names that match exactly: {len(listed & present)}")
print("examples listed but not present:", sorted(listed - present)[:4])
print("examples present but not listed:", sorted(present - listed)[:4])
print("files under sub-1 without the .tif extension:", sorted(p.split("/")[-1] for p in present if "/sub-1/" in p and not p.endswith(".tif")))
manifest.xlsx columns: ['filename', 'timestamp', 'description', 'file_type', 'Additional_Metadata']
rows in manifest.xlsx: 50; files in files/primary: 50; names that match exactly: 10
examples listed but not present: ['files/primary/sensor_validation/sub-1/0.000714_uM.tif', 'files/primary/sensor_validation/sub-1/0.00714_uM.tif', 'files/primary/sensor_validation/sub-1/0.0714_uM.tif', 'files/primary/sensor_validation/sub-1/0.714_uM.tif']
examples present but not listed: ['files/primary/sensor_validation/sub-1/sub-1_0.000714 uM', 'files/primary/sensor_validation/sub-1/sub-1_0.00714 uM', 'files/primary/sensor_validation/sub-1/sub-1_0.0714 uM', 'files/primary/sensor_validation/sub-1/sub-1_0.714 uM']
files under sub-1 without the .tif extension: ['sub-1_0.000714 uM', 'sub-1_0.00714 uM', 'sub-1_0.0714 uM', 'sub-1_0.714 uM', 'sub-1_142.85 uM', 'sub-1_7.14 uM', 'sub-1_71.4 uM']

The primary manifest.xlsx describes the files under names that differ from the deposited ones (for example sub-1/0.000714_uM.tif in the sheet, sub-1/sub-1_0.000714 uM in the dataset, which also lacks the .tif extension for seven of the eight calibration files), so no file is described by its own name. The sheet's descriptions of the sub-1 files say "ACh release by electrical stimulation", while the README, the subjects sheet ("calibration curve") and the paper make them the ex vivo calibration with added ACh.

In vivo recordings¶

Each recording is read once; the analyses below use only the reduced traces kept here: the mean over the stained tissue (Otsu threshold of the mean pre-stimulus image), the mean over the whole frame, and the mean of each 40 x 40 pixel block inside the tissue.

In [5]:
V = {}
rows = []
MAPS = {}   # block onset/peak maps of the pHAb half of sub-2 and sub-3 (fig7 and figs12), under each variant
for key in X.MOVIES:
    m = X.movie(key)
    rec = {"shape": m["shape"], "times": m["times"], "acquired": m["acquired"]}
    for h, a in m["halves"].items():
        mean_img = a[:X.STIM_FRAME].mean(0)
        mask = X.tissue_mask(mean_img)
        bt, org = X.blocks(a, mask)
        sat = a.max(0) >= 65534
        rec[h] = {"mean_img": mean_img, "mask": mask, "tissue": a[:, mask].mean(1),
                  "tissue_unsat": a[:, mask & ~sat].mean(1), "sat_px_frac": float((mask & sat).sum() / mask.sum()),
                  "full": a.reshape(len(a), -1).mean(1), "blocks": bt, "origins": org,
                  "dark": float(np.percentile(mean_img, 0.1))}
        if h == "right" and key in ("sub-2 3V", "sub-3 8V"):
            for size in (16, 32):
                for k in (2.0, 3.0, 5.0):
                    for fit, after in (("a", 120.0), ("c", 180.0), ("b", None)):
                        MAPS[(key, size, k, fit)] = X.block_onsets(a, mask, X.STIM_FRAME, size, k, after)
        dt = np.diff(m["times"]) if len(m["times"]) > 1 else np.array([np.nan])
        rows.append({"recording": key, "acquired": m["acquired"][:30], "frames": a.shape[0], "frame_px": f"{a.shape[1]}x{a.shape[2]}",
                     "channel": h, "timestamps": len(m["times"]), "dt_median_s": np.median(dt), "dt_min": dt.min(), "dt_max": dt.max(),
                     "min": int(a.min()), "max": int(a.max()), "dark (0.1th pct of mean image)": round(rec[h]["dark"]),
                     "tissue mean (pre-onset)": round(float(mean_img[mask].mean())), "off-tissue median": round(float(np.median(mean_img[~mask]))),
                     "saturated_px_frames_%": round(100 * (a >= 65534).mean(), 2),
                     "tissue_px_ever_saturated_%": round(100 * rec[h]["sat_px_frac"], 1),
                     "tissue_frac": round(mask.mean(), 2), "blocks": len(bt)})
    if "left" in rec and "right" in rec:
        rec["left"]["by_right_mask"] = m["halves"]["left"][:, rec["right"]["mask"]].mean(1)
    V[key] = rec
    del m, a
print(pd.DataFrame(rows).to_string(index=False))
print(f"block maps computed: {len(MAPS)}; peak memory {rss_mb():.0f} MB, {time.time() - T0:.0f} s")
         recording                       acquired  frames frame_px channel  timestamps  dt_median_s  dt_min  dt_max  min   max  dark (0.1th pct of mean image)  tissue mean (pre-onset)  off-tissue median  saturated_px_frames_%  tissue_px_ever_saturated_%  tissue_frac  blocks
          sub-2 3V Fri, 06 Dec 2019 15:50:37 East     481  512x256    left         481          0.5     0.5   0.597 1562 51688                            1643                    25211              11000                   0.00                         0.0         0.34      16
          sub-2 3V Fri, 06 Dec 2019 15:50:37 East     481  512x256   right         481          0.5     0.5   0.597 1547 65534                            1588                    37601              16899                   0.79                        11.5         0.35      21
          sub-3 8V Fri, 06 Dec 2019 16:04:29 East     488  512x256    left         488          0.5     0.5   0.598 1561 40330                            1606                    16729               6194                   0.00                         0.0         0.12       2
          sub-3 8V Fri, 06 Dec 2019 16:04:29 East     488  512x256   right         488          0.5     0.5   0.598 1523 65534                            1574                    33779              14877                   0.51                        16.4         0.34      20
         sub-4 10V Fri, 19 Jul 2019 17:22:35 East     509  512x256  single           1          NaN     NaN     NaN 1535  3299                            1589                     2105               1872                   0.00                         0.0         0.17      11
   sub-6 with drug Mon, 16 Dec 2019 15:42:29 East     365  495x234  single           1          NaN     NaN     NaN 2392 65534                            2641                    47890              18146                   3.24                        19.6         0.24      13
sub-6 without drug Mon, 16 Dec 2019 16:14:47 East     371  495x234  single           1          NaN     NaN     NaN 2672 65534                            2941                    53458              22054                   6.73                        69.0         0.26      13
block maps computed: 36; peak memory 1129 MB, 65 s

Frames are 16-bit counts from a Hamamatsu C11440-22C camera (binning 4, 50 ms exposure); the files carry no spatial scale (their calibration is in pixels). sub-2 and sub-3 keep both W-VIEW GEMINI channels side by side (512 x 512) and a timestamp per frame: the interval is 0.50 s (one 0.60 s gap after the first frame), not the 0.55 s the paper states for its sampling. sub-4 and sub-6 were saved by ImageJ, cropped to one channel, with only the first frame's timestamp, so their interval cannot be read from the files. No file labels its channels; which half is pHAb is settled below from the response. Pixels at the top of the 16-bit range (65534 and above) are saturated: in the right half of sub-2 and sub-3 and in both sub-6 files a share of the tissue pixels saturate at some frame (printed), so their responses are clipped. The analyses of sub-6 show the tissue without those pixels as a further ROI.

Dark level. No background or camera offset is subtracted in the paper's Methods, and none is subtracted here in the main readings. The darkest pixels of each mean image (0.1th percentile, printed as "dark") sit at 1,574 to 1,643 counts in sub-2, sub-3 and sub-4 and at 2,641 and 2,941 in the two sub-6 files, near the lowest pixel of each file, so they are the floor of the camera, not tissue; the pixels outside the tissue mask of sub-2 and sub-3 are far brighter (printed), as the field is all ganglion and glow. The dark level is 4 to 10% of the tissue means of sub-2, sub-3 and sub-6, so subtracting it would raise their dF/F by about that share; fig5b-in-vivo-response shows the tissue ROI with it subtracted as a variant. In sub-4 the tissue mean is close to the dark level, so its dF/F would change several-fold; sub-4 is used by no tested claim.

In [6]:
def z_from_pre(tr, n_pre=X.STIM_FRAME):
    pre = tr[:n_pre]
    return (tr - pre.mean()) / pre.std()

rows = []
for key, rec in V.items():
    for h in [k for k in ("left", "right", "single") if k in rec]:
        tr = rec[h]["tissue"]
        z = z_from_pre(tr)
        over = np.flatnonzero(np.abs(z[X.STIM_FRAME:]) > 5)
        first = int(over[0]) + X.STIM_FRAME if len(over) else None
        d = 100 * (tr / tr[:X.STIM_FRAME].mean() - 1)
        rows.append({"recording": key, "channel": h, "first frame |z|>5": first,
                     "t file clock (s)": round(first * X.FRAME_S_FILE, 2) if first else None, "t paper clock (s)": round(first * X.FRAME_S_PAPER, 2) if first else None,
                     "max dF/F after frame 19 (%)": round(d[X.STIM_FRAME:].max(), 1), "min dF/F after frame 19 (%)": round(d[X.STIM_FRAME:].min(), 1),
                     "mean |z| frames 0-18": round(np.abs(z[:X.STIM_FRAME]).mean(), 2)})
print(pd.DataFrame(rows).to_string(index=False))
print("\nTissue-mean z-scores against frames 0-18, frames 15 to 40:")
for key in ("sub-2 3V", "sub-3 8V", "sub-6 without drug", "sub-6 with drug"):
    h = "right" if "right" in V[key] else "single"
    print(f"{key:20s}", " ".join(f"{v:.0f}" for v in z_from_pre(V[key][h]["tissue"])[15:41]))

# sub-4 (10 V), the whole tissue trace: how many stimulations does it hold? (fig5c-voltage-dose, fig5e-reversibility)
d4 = 100 * (V["sub-4 10V"]["single"]["tissue"] / V["sub-4 10V"]["single"]["tissue"][:X.STIM_FRAME].mean() - 1)
z4 = z_from_pre(V["sub-4 10V"]["single"]["tissue"])
pk4, pr4 = find_peaks(ndi.uniform_filter1d(d4, 5), prominence=1.0)
print(f"\nsub-4: {len(d4)} frames; dF/F {d4.min():.1f} to {d4.max():.1f}%; peaks of the 5-frame mean with prominence above 1%: frames {pk4.tolist()} "
      f"(heights {np.round(d4[pk4], 1).tolist()}%); frames with z > 5: {int((z4 > 5).sum())}, from {int(np.flatnonzero(z4 > 5)[0])} to {int(np.flatnonzero(z4 > 5)[-1])}")
print("sub-4 dF/F every 10th frame:", " ".join(f"{v:.1f}" for v in d4[::10]))
fig, ax = plt.subplots(figsize=(8, 2.5))
ax.plot(d4, lw=1); ax.set_xlabel("frame"); ax.set_ylabel("dF/F (%)"); ax.set_title("sub-4 (10 V), tissue mean, no photobleaching correction")
plt.show()
         recording channel  first frame |z|>5  t file clock (s)  t paper clock (s)  max dF/F after frame 19 (%)  min dF/F after frame 19 (%)  mean |z| frames 0-18
          sub-2 3V    left               34.0              17.0              18.70                         -2.7                        -53.4                  0.88
          sub-2 3V   right               28.0              14.0              15.40                         27.1                          0.5                  0.83
          sub-3 8V    left               27.0              13.5              14.85                          0.0                        -46.7                  0.81
          sub-3 8V   right               23.0              11.5              12.65                         48.1                        -14.1                  0.84
         sub-4 10V  single               55.0              27.5              30.25                          8.7                         -1.5                  0.85
   sub-6 with drug  single                NaN               NaN                NaN                          3.3                         -9.5                  0.48
sub-6 without drug  single               32.0              16.0              17.60                         17.4                        -11.0                  0.47

Tissue-mean z-scores against frames 0-18, frames 15 to 40:
sub-2 3V             1 1 1 2 2 2 2 2 2 2 2 3 4 5 6 9 12 15 19 23 28 32 38 43 48 54
sub-3 8V             1 -2 -1 -1 -3 -2 -2 -4 -10 -24 -45 -54 -52 -52 -38 -18 -8 10 28 39 54 67 77 88 97 102
sub-6 without drug   0 -4 0 0 0 -0 -4 0 0 0 1 2 2 3 4 5 4 6 7 7 7 8 8 8 9 8
sub-6 with drug      0 0 0 0 0 -2 0 0 0 0 0 -3 0 0 0 0 -0 1 1 1 1 -2 1 1 1 1

sub-4: 509 frames; dF/F -1.5 to 8.7%; peaks of the 5-frame mean with prominence above 1%: frames [99] (heights [8.7]%); frames with z > 5: 133, from 78 to 210
sub-4 dF/F every 10th frame: 0.1 -0.0 -0.1 -0.2 -0.4 -0.4 -0.4 -0.4 1.1 6.3 8.6 7.3 5.8 4.5 3.5 2.8 2.1 1.6 1.2 0.9 0.6 0.4 0.2 0.0 -0.1 -0.2 -0.3 -0.4 -0.4 -0.6 -0.6 -0.7 -0.7 -0.7 -0.9 -0.9 -0.8 -0.9 -1.0 -1.0 -0.9 -1.0 -1.1 -1.1 -1.1 -1.2 -1.2 -1.3 -1.4 -1.4 -1.4
No description has been provided for this image

Clock. The files do not record when the stimulation was given. The paper puts its start at 10.45 s in Fig. 6A and Fig. 7A, frame 19 on its 0.55 s clock (STIM_FRAME). In sub-2, sub-3 and sub-6 after washout each tissue trace departs from baseline (|z| > 5 against frames 0 to 18) 4 to 13 frames after frame 19, at frame 23 to 34. In sub-3 (8 V) the first change is a drop in both channels, followed by the rise in one. With the drug, sub-6 has no frame with |z| > 5 and rises by at most 3.3%. sub-4 (10 V) first departs at frame 55, so its stimulation did not start at 10.45 s; it is used by no tested claim. Its whole trace (printed and plotted) holds one response: one peak of 8.7% at frame 99, with |z| > 5 from frame 78 to 210 and the signal near or below baseline before and after. It holds no repeated stimulations, so fig5e-reversibility cannot be tested on it, and no 3 V or 5 V recording of the same ganglion exists for fig5c-voltage-dose. That the responses start after frame 19 is consistent with the stated onset; it does not prove it.

Channels. In sub-2 and sub-3 the right half rises after stimulation (by 27.1% and 48.1% over the tissue) and the left half does not rise above its baseline; the right half is taken as pHAb and the left as AF647. The files do not label them, so this is an assumption, and figs16-af647-stable rests on it. (While preparing, outside this notebook, the time-lapse panels of Fig. 7A, the nanosensor signal of the 8 V recording, were compared with sub-3 and match its right half; this is not run here, as the entry reads no figures. It does not decide the channels, which rest on which half rises.)

Recordings deposited twice. The next cell compares the mean images.

In [7]:
from skimage.registration import phase_cross_correlation

def aligned_r(a, b):
    h, w = min(a.shape[0], b.shape[0]), min(a.shape[1], b.shape[1])
    a, b = a[:h, :w], b[:h, :w]
    shift = phase_cross_correlation(a, b, upsample_factor=1)[0]
    b2 = ndi.shift(b, shift, order=1)
    sl = (slice(20, h - 20), slice(20, w - 20))
    return shift, stats.pearsonr(a[sl].ravel(), b2[sl].ravel())[0]

pairs = [("sub-2 3V", "right", "sub-3 8V", "right"), ("sub-2 3V", "left", "sub-3 8V", "left"),
         ("sub-6 with drug", "single", "sub-6 without drug", "single"),
         ("sub-2 3V", "right", "sub-6 without drug", "single"), ("sub-2 3V", "right", "sub-4 10V", "single"),
         ("sub-3 8V", "right", "sub-4 10V", "single")]
for k1, h1, k2, h2 in pairs:
    s, r = aligned_r(V[k1][h1]["mean_img"], V[k2][h2]["mean_img"])
    print(f"{k1} {h1} vs {k2} {h2}: shift {s}, r = {r:.3f}")
print("acquired:", {k: V[k]["acquired"][:40] for k in V})
print("traces identical between any two recordings:",
      any(np.array_equal(V[a][ha]["tissue"], V[b][hb]["tissue"]) for a, ha, b, hb in pairs))
sub-2 3V right vs sub-3 8V right: shift [0. 0.], r = 0.928
sub-2 3V left vs sub-3 8V left: shift [0. 0.], r = 0.695
sub-6 with drug single vs sub-6 without drug single: shift [0. 0.], r = 0.981
sub-2 3V right vs sub-6 without drug single: shift [11. 10.], r = 0.471
sub-2 3V right vs sub-4 10V single: shift [0. 0.], r = 0.063
sub-3 8V right vs sub-4 10V single: shift [0. 0.], r = 0.080
acquired: {'sub-2 3V': 'Fri, 06 Dec 2019 15:50:37 Eastern Standa', 'sub-3 8V': 'Fri, 06 Dec 2019 16:04:29 Eastern Standa', 'sub-4 10V': 'Fri, 19 Jul 2019 17:22:35 Eastern Daylig', 'sub-6 with drug': 'Mon, 16 Dec 2019 15:42:29 Eastern Standa', 'sub-6 without drug': 'Mon, 16 Dec 2019 16:14:47 Eastern Standa'}
traces identical between any two recordings: False

sub-2 (3 V) and sub-3 (8 V) were recorded 14 minutes apart on the same day and their mean images match with no shift (r = 0.93 for the right halves), far more closely than images of different recordings do (r = 0.06 to 0.47): they are two stimulations of one ganglion. The paper says the AQuA analysis used one mouse stimulated at 3 V and 8 V (Methods, AQuA Analysis); the subjects sheet lists sub-2 and sub-3 as two subjects. Neither recording is a copy of the other (the traces differ), so each is used once. The two sub-6 files are one field before and after washout, as the paper's Fig. 6 describes.

Ex vivo calibration recordings (sub-1)¶

In [8]:
CAL = X.calibration_movies()
rows = []
for c in CAL:
    a = c["frames"].astype(float)
    mask = X.tissue_mask(a[0])
    c["tissue"] = a[:, mask].mean(1)
    c["full"] = a.reshape(len(a), -1).mean(1)
    step = np.diff(c["tissue"])
    c["onset"] = int(np.argmax(step))
    rows.append({"conc_uM": c["conc_uM"], "file": c["path"].split("/")[-1], "acquired": c["acquired"][:33], "frames": a.shape[0],
                 "size": f"{a.shape[1]}x{a.shape[2]}", "min": int(a.min()), "max": int(a.max()), "tissue_frac": round(mask.mean(), 2),
                 "largest 1-frame rise at frame": c["onset"], "rise (%)": round(100 * step.max() / c["tissue"][:c["onset"] + 1].mean(), 1),
                 "frame-to-frame SD before it (%)": round(100 * np.diff(c["tissue"][:c["onset"] + 1]).std() / c["tissue"][0], 2)})
    c["frames"] = None
print(pd.DataFrame(rows).to_string(index=False))

# Each tissue trace with the inferred onset (the frame before the largest one-frame rise) marked.
fig, axs = plt.subplots(2, 4, figsize=(14, 5), sharex=True)
for a_, c in zip(axs.ravel(), CAL):
    d = 100 * (c["tissue"] / c["tissue"][0] - 1)
    a_.plot(d, ".-", lw=1); a_.axvline(c["onset"], color="r", ls=":")
    a_.set_title(f"{c['conc_uM']} uM (onset frame {c['onset']})", fontsize=9)
for a_ in axs[1]:
    a_.set_xlabel("frame")
axs[0, 0].set_ylabel("dF/F vs frame 0 (%)"); axs[1, 0].set_ylabel("dF/F vs frame 0 (%)")
plt.tight_layout(); plt.show()
for c in CAL:
    d = 100 * (c["tissue"] / c["tissue"][0] - 1)
    print(f"{c['conc_uM']:>10} uM: dF/F per frame " + " ".join(f"{v:.1f}" for v in d))
   conc_uM              file                          acquired  frames    size  min   max  tissue_frac  largest 1-frame rise at frame  rise (%)  frame-to-frame SD before it (%)
  0.000714 sub-1_0.000714 uM Mon, 07 Oct 2019 16:36:56 Eastern      22 509x255 1554 10293         0.60                              7      23.1                             0.49
  0.007140  sub-1_0.00714 uM Mon, 07 Oct 2019 16:48:36 Eastern      34 509x255 1556 10438         0.60                             11       1.7                             0.64
  0.071400   sub-1_0.0714 uM Mon, 07 Oct 2019 16:58:27 Eastern      33 509x255 1550  8913         0.62                             11       3.0                             0.77
  0.714000    sub-1_0.714 uM Mon, 07 Oct 2019 17:13:32 Eastern      25 509x255 1554  8282         0.16                              7      19.8                             1.36
  7.140000     sub-1_7.14 uM Mon, 07 Oct 2019 17:25:48 Eastern      30 509x255 1555  8233         0.53                              7      41.9                             0.98
 71.400000     sub-1_71.4 uM Mon, 07 Oct 2019 18:05:11 Eastern      30 509x255 1544 13097         0.62                              9      58.4                             8.38
142.850000   sub-1_142.85 uM Mon, 07 Oct 2019 18:21:05 Eastern      29 509x255 1543 13577         0.49                              7      28.6                             2.37
714.000000  sub-1_714 uM.tif Mon, 07 Oct 2019 18:34:45 Eastern      24 509x255 1555 15548         0.48                              7      38.4                             0.36
No description has been provided for this image
  0.000714 uM: dF/F per frame 0.0 0.1 0.1 -0.7 -1.9 -2.8 -3.0 -3.0 19.8 17.4 17.8 21.2 21.0 20.8 20.8 20.6 20.6 20.5 20.5 20.2 20.3 20.1
   0.00714 uM: dF/F per frame 0.0 0.0 -1.7 -1.3 -1.6 -1.9 -0.8 -1.0 -1.2 -1.7 -2.3 -2.8 -1.2 -1.4 -1.4 -1.5 -1.7 -1.8 -1.7 -1.9 -1.9 -1.9 -1.9 -1.9 -1.9 -1.9 -1.9 -2.0 -2.0 -2.0 -2.0 -2.1 -2.1 -39.6
    0.0714 uM: dF/F per frame 0.0 -0.0 0.0 0.1 0.1 -1.2 -2.8 -3.2 -3.0 -2.3 -1.4 -2.5 0.5 0.5 0.5 0.2 0.1 0.0 -0.2 -0.2 -0.2 -0.3 -0.4 -0.3 -0.5 -0.4 -0.5 -0.6 -0.7 -0.7 -0.7 -0.8 -0.9
     0.714 uM: dF/F per frame 0.0 -0.0 -0.2 -0.3 -0.2 -3.5 -5.5 -8.2 11.1 14.0 16.2 25.2 25.0 24.9 24.8 24.9 24.8 23.6 21.0 21.1 20.9 20.9 20.9 20.6 20.6
      7.14 uM: dF/F per frame 0.0 -1.7 -3.6 -5.0 -6.4 -10.6 -12.5 -15.5 23.4 24.0 26.0 27.6 27.6 27.6 27.5 27.6 27.6 27.5 27.2 27.3 27.1 27.1 27.1 27.0 26.8 26.8 27.0 26.8 26.7 26.7
      71.4 uM: dF/F per frame 0.0 -0.1 -0.7 -0.8 -1.0 -1.3 -1.4 -1.4 -1.5 24.9 84.3 84.9 85.6 85.7 85.5 85.8 85.7 85.5 85.4 85.6 85.5 85.5 85.2 85.2 85.4 85.2 85.2 85.1 85.2 85.1
    142.85 uM: dF/F per frame 0.0 -0.5 -1.0 -2.2 -3.3 -4.6 -5.5 0.3 28.3 30.2 29.8 29.9 31.1 31.4 31.3 31.3 31.5 31.3 31.3 31.3 31.3 31.3 31.2 31.2 31.3 31.2 31.2 31.1 31.2
     714.0 uM: dF/F per frame 0.0 -0.1 -0.1 -0.5 -1.5 -2.2 -2.1 -2.3 35.6 46.4 50.2 54.2 56.2 56.3 55.5 54.6 53.5 52.8 52.1 51.6 51.2 50.8 50.4 50.2

Eight recordings of one mouse (sub-1), each 22 to 34 frames of one channel cropped to 509 x 255 pixels, acquired in increasing concentration over two hours on one day. The concentrations in the names (0.000714 to 714 uM) are the paper's final concentrations (stock divided by 1.4, Methods); the paper's range runs to 7.14 mM, and the deposit has 8 concentrations and one of three mice. The files keep only the first frame's timestamp, so their frame interval is not recorded; the time of ACh addition is not recorded either. Six of the eight recordings rise by 19.8 to 58.4% within one frame, at frame 7 to 9; at 0.00714 and 0.0714 uM the largest one-frame rise is 1.7 and 3.0%, with no clear step. The channel is not labelled; it is taken as pHAb, the channel the calibration measures. The traces (plotted and printed) show the shape of each: in the six recordings with a step, the signal drifts down by 1.5 to 15.5% over the frames before it, then jumps within one frame and stays high to the end; the 0.00714 uM recording ends with one frame at -39.6%.

Confocal images¶

In [9]:
P75 = "files/primary/Sub_01/"
LSM = {}
for f in X.manifest("75")["files"]:
    if f["path"].endswith(".lsm"):
        arr, dyes, vox = X.lsm(f["path"])
        name = f["path"].split("/")[-1].replace("submandibular ganglion labelled by ", "").replace(".lsm", "")
        LSM[name] = {"arr": arr, "dyes": dyes, "vox": vox}
        empty = int(sum(not arr[z].any() for z in range(arr.shape[0]))) if arr.ndim == 4 else 0
        print(f"{name}: shape {arr.shape}, dyes {dyes}, voxel x {vox['X']:.3f} um, z {vox['Z']:.3g} um, range {arr.min()} to {arr.max()}, all-zero planes {empty}")

t = time.time()
CZ_MAX, CZ_MID, CZ_NAMES, CZ_SCALE, CZ_NZ = X.czi_sub5()
print(f"\nsub-5 CZI: channels {CZ_NAMES}, {CZ_NZ} planes of {CZ_MAX.shape[1]}x{CZ_MAX.shape[2]}, pixel {CZ_SCALE['X']:.4f} um, z step {CZ_SCALE['Z']:.4f} um "
      f"(stack {CZ_SCALE['Z'] * (CZ_NZ - 1):.2f} um); read in {time.time() - t:.0f} s")
for i, n in enumerate(CZ_NAMES):
    print(f"  {n}: max projection range {CZ_MAX[i].min()} to {CZ_MAX[i].max()}, median {np.median(CZ_MAX[i]):.0f}")

# The 27 per-plane TIFFs of sub-5 against the CZI: compare the middle plane.
mid_file = X.SV + f"sub-5/sub-5_2019-11-01 ACh sensor staining in SMG 02 - Same Thresholds_z{CZ_NZ // 2 + 1:02d}.tif"
import tifffile
with tifffile.TiffFile(io.BytesIO(X.read_bytes("108", mid_file))) as tf:
    rgb = tf.asarray()
print(f"\n{mid_file.split('/')[-1]}: {rgb.shape} {rgb.dtype}")
for j, col in enumerate("RGB"):
    rs = [stats.pearsonr(rgb[::4, ::4, j].ravel().astype(float), CZ_MID[i][::4, ::4].ravel().astype(float))[0] for i in range(3)]
    print(f"  TIFF {col} against CZI middle plane " + ", ".join(f"{n} r={r:.2f}" for n, r in zip(CZ_NAMES, rs)))
print(f"peak memory {rss_mb():.0f} MB")
bungarotoxin Z-stack high magnification: shape (62, 2, 512, 512), dyes ['EGFP', 'Alexa Fluor 647'], voxel x 0.198 um, z 0.1 um, range 0 to 65535, all-zero planes 50
bungarotoxin Z-stack low magnification: shape (5, 3, 2048, 2048), dyes ['EGFP', 'Alexa Fluor 647', ''], voxel x 0.099 um, z 7.49 um, range 0 to 65535, all-zero planes 0
nanosensor high magnification_1: shape (3, 512, 512), dyes ['Alexa Fluor 488', 'Alexa Fluor 647', 'Alexa Fluor 546'], voxel x 0.142 um, z 1e-13 um, range 0 to 53666, all-zero planes 0
nanosensor high magnification_2: shape (3, 512, 512), dyes ['Alexa Fluor 488', 'Alexa Fluor 647', 'Alexa Fluor 546'], voxel x 0.180 um, z 1e-13 um, range 0 to 65535, all-zero planes 0
nanosensor high magnification_3: shape (3, 512, 512), dyes ['Alexa Fluor 488', 'Alexa Fluor 647', 'Alexa Fluor 546'], voxel x 0.153 um, z 1e-13 um, range 0 to 65535, all-zero planes 0
nanosensor low magnification: shape (4, 512, 512), dyes ['Alexa Fluor 488', 'Alexa Fluor 647', '', 'Alexa Fluor 546'], voxel x 0.893 um, z 1e-13 um, range 51 to 65535, all-zero planes 0
sub-5 CZI: channels ['Alexa Fluor 647', 'Alexa Fluor 532', 'EGFP'], 27 planes of 1924x1924, pixel 0.1105 um, z step 0.6696 um (stack 17.41 um); read in 36 s
  Alexa Fluor 647: max projection range 72 to 63071, median 868
  Alexa Fluor 532: max projection range 992 to 65535, median 10825
  EGFP: max projection range 64 to 30564, median 2032
sub-5_2019-11-01 ACh sensor staining in SMG 02 - Same Thresholds_z14.tif: (1924, 1924, 3) uint8
  TIFF R against CZI middle plane Alexa Fluor 647 r=0.89, Alexa Fluor 532 r=0.24, EGFP r=-0.05
  TIFF G against CZI middle plane Alexa Fluor 647 r=-0.07, Alexa Fluor 532 r=0.42, EGFP r=0.99
  TIFF B against CZI middle plane Alexa Fluor 647 r=0.31, Alexa Fluor 532 r=0.66, EGFP r=0.16
peak memory 1129 MB

The LSM files of SPARC:75 name their dyes: GFP and AF647 in the BTX stacks; AF488 (GFP), AF647 and AF546 (pHAb) in the nanosensor images. In the high-magnification BTX stack only the first planes hold data; the others (count printed) are all zero, so the stack is 62 planes of 0.1 um by its metadata but about 1.2 um of tissue in fact. The nanosensor images are single planes. The sub-5 CZI holds 27 planes of three channels (AF647, AF532 for pHAb, EGFP), with a 17.41 um stack, as the Methods state (27 slices, 17.41 um, lasers 488, 514 and 633 nm). The 27 per-plane TIFFs of sub-5 are 8-bit RGB renders of the same stack (the printed correlations match each colour to one CZI channel), so the stack is deposited twice (three times with the derivative OME-TIFF and JPX); the CZI is used.

In vitro files¶

In [10]:
for ch in ("PHAB", "260_NM", "280_NM", "652_NM"):
    t, y = X.hplc(ch)
    print(f"HPLC_{ch}: {len(t)} samples, first column {t.min():.4f} to {t.max():.2f} (step {np.median(np.diff(t)):.5f}), signal {y.min():.3f} to {y.max():.3f}")
for name in ("2019-08-09_sensor.xml", "2019-08-09_dna_scaffold.xml"):
    sp = X.uvvis(name)
    print(f"{name}: {len(sp)} spectra; titles {[s['title'] for s in sp]}; wavelengths {sp[0]['wavelength'].min():.0f}-{sp[0]['wavelength'].max():.0f} nm")
G = {c: X.gel(c) for c in ("eb", "PHAB", "AF652")}
for c, g in G.items():
    print(f"gel {c}: {g.shape}, {g.min():.0f} to {g.max():.0f}, saturated pixels {(g >= 65535).sum()}")
HPLC_PHAB: 24820 samples, first column 0.0001 to 44.68 (step 0.00180), signal 0.026 to 13.623
HPLC_260_NM: 13403 samples, first column 0.0033 to 44.68 (step 0.00333), signal -0.918 to 765.601
HPLC_280_NM: 13403 samples, first column 0.0033 to 44.68 (step 0.00333), signal -1.554 to 609.221
HPLC_652_NM: 13403 samples, first column 0.0033 to 44.68 (step 0.00333), signal -0.085 to 111.980
2019-08-09_sensor.xml: 10 spectra; titles ['sensor', 'sensor', 'sensor', 'sensor', 'sensor(Reblank)', 'water', 'sensor', 'sensor', 'sensor', 'sensor']; wavelengths 220-750 nm
2019-08-09_dna_scaffold.xml: 1 spectra; titles ['sensor']; wavelengths 220-750 nm
gel eb: (2048, 2048), 1294 to 65535, saturated pixels 7135
gel PHAB: (2048, 2048), 1300 to 65535, saturated pixels 1
gel AF652: (2048, 2048), 1265 to 65535, saturated pixels 2

The HPLC files have no header. The first column runs to 44.7 min at a constant step, so it is time in minutes, not volume; the paper reports volumes and does not give the flow rate. The UV-Vis workbooks hold spectra titled "sensor" (eight repeats, a reblank and water) and one of the DNA scaffold; there are no spectra of pure AChE or BTX, which fig2g-conjugation-ratios needs. The three gel images are 2048 x 2048 16-bit scans (ethidium bromide, pHAb, AF647).

fig2d-hplc-yield¶

In size-exclusion HPLC the assembled nanosensors elute first (main peak near 7.5 mL), followed by a second peak at 9.1 to 9.2 mL of unreacted material, and the nanosensors are about 77% of the reaction mixture by area under all peaks of the pHAb channel.

Criterion: the area of the first peak over the summed area of all detectable peaks of the pHAb chromatogram, (a) limits at the minima between peaks with a flat baseline at the pre-injection level, (b) the same with a linear baseline under each peak; share 69.3 to 84.7%, main peak 6.75 to 8.25 mL, second peak 8.19 to 10.12 mL.

Details not in the claims file. "Detectable" is taken as a prominence of at least 1% of the largest peak (0.5% as a variant), a choice made here. The start of the first peak is where the signal rises above the pre-injection level plus 3 SD (the first 5 min, before any peak). The end of the last peak is open, and three ends are run: (i) where the signal returns to the pre-injection level plus 3 SD; (ii) the end of the peak's own descent, the first point after it where the slope (101-sample running mean) falls below 1% of the steepest slope of the chromatogram; (iii) where the signal falls below 2% of the peak's height. Ends (ii) and (iii) leave out the low tail after about 21 min, which (i) gives to the second peak. Reading (b) is run as written (a line under each peak, from its limits) and as a common line from the start of the first peak to the end of the last, with a vertical drop at the valley, the usual way to split two overlapping peaks on a sloped baseline; a line under each peak alone cuts through the second peak, as its left limit is the valley.

The file gives time, not volume, and the paper gives no flow rate (Methods, "Superdex 200 increase 10/300 GL column ... via HPLC (Infinity 1260, Agilent)"; no rate is stated anywhere in the text or SI). The retention volumes therefore cannot be tested: any rate could be chosen to put the main peak at 7.5 mL. Only the ratio of the two retention times, which does not depend on the rate, is compared with the paper's 9.1 to 9.2 over 7.5 mL. The rate that would put the main peak at 7.5 mL is printed for information.

In [11]:
from scipy.ndimage import uniform_filter1d

t, y = X.hplc("PHAB")
pre = t < 5
base, base_sd = np.median(y[pre]), y[pre].std()
print(f"pre-injection level {base:.4f} (SD {base_sd:.4f}) over the first 5 min")
slope = np.gradient(uniform_filter1d(y, 101), t)

def peak_limits(y, peaks, level, end):
    lims = []
    i = peaks[0]
    while i > 0 and y[i] > level:
        i -= 1
    lims.append(i)
    for a, b in zip(peaks[:-1], peaks[1:]):
        lims.append(a + int(np.argmin(y[a:b])))
    i = peaks[-1]
    if end == "i return to pre-injection + 3 SD":
        while i < len(y) - 1 and y[i] > level:
            i += 1
    elif end == "ii end of descent (slope < 1% of steepest)":
        i = i + int(np.argmax((np.arange(len(y))[i:] > i + 50) & (np.abs(slope[i:]) < 0.01 * np.abs(slope).max())))
    else:
        i = i + int(np.argmax(y[i:] - base < 0.02 * (y[i] - base)))
    lims.append(i)
    return lims

rows = []
for detect in (0.01, 0.005):
    pk, pr = find_peaks(y, prominence=detect * (y.max() - base))
    # the end readings apply to the end of the second peak; with the 0.5% rule a third, late peak is counted with limits (i)
    for end in ("i return to pre-injection + 3 SD", "ii end of descent (slope < 1% of steepest)", "iii below 2% of the peak height"):
        s0, v0, e0 = peak_limits(y, pk[:2], base + 3 * base_sd, end)
        segs = [(s0, v0), (v0, e0)]
        for p in pk[2:]:   # a later, separate peak (0.5% rule): its own limits by reading (i)
            s3, e3 = peak_limits(y, [p], base + 3 * base_sd, "i return to pre-injection + 3 SD")
            segs.append((max(s3, e0), e3))
        flat = [np.trapezoid(y[a:b + 1] - base, t[a:b + 1]) for a, b in segs]
        each = [np.trapezoid(y[a:b + 1] - np.interp(t[a:b + 1], [t[a], t[b]], [y[a], y[b]]), t[a:b + 1]) for a, b in segs]
        common_line = lambda tt: np.interp(tt, [t[s0], t[e0]], [y[s0], y[e0]])
        common = [np.trapezoid(y[a:b + 1] - common_line(t[a:b + 1]), t[a:b + 1]) for a, b in segs[:2]] + \
                 [np.trapezoid(y[a:b + 1] - np.interp(t[a:b + 1], [t[a], t[b]], [y[a], y[b]]), t[a:b + 1]) for a, b in segs[2:]]
        for reading, areas in (("a flat baseline", flat), ("b line under each peak", each), ("b common line, drop at valley", common)):
            rows.append({"detectable": f"{detect:.1%}", "end of 2nd peak": end, "reading": reading, "peaks (min)": np.round(t[pk], 2).tolist(),
                         "limits (min)": [round(float(t[a]), 2) for a, b in segs] + [round(float(t[segs[-1][1]]), 2)],
                         "areas": np.round(areas, 2).tolist(), "main share (%)": round(100 * areas[0] / sum(areas), 1)})
H = pd.DataFrame(rows)
H["share_ok"] = (H["main share (%)"] - 77).abs() <= 7.7
print(H.to_string(index=False))
ok = H[H.reading != "b line under each peak"]
print(f"\nreadings with a share within 69.3-84.7%: {int(H.share_ok.sum())} of {len(H)}; share over the readings with positive areas "
      f"{ok['main share (%)'].min():.1f} to {ok['main share (%)'].max():.1f}%")
pk1, _ = find_peaks(y, prominence=0.01 * (y.max() - base))
v_i = peak_limits(y, pk1[:2], base + 3 * base_sd, "i return to pre-injection + 3 SD")[1]
print(f"valley between the two peaks: {y[v_i]:.2f} at {t[v_i]:.2f} min (main peak {y.max():.2f}, pre-injection {base:.3f})")
H1 = H[H.detectable == "1.0%"]
for end in H1["end of 2nd peak"].unique():
    fa = H1[(H1["end of 2nd peak"] == end) & (H1.reading == "a flat baseline")].areas.iloc[0]
    ba = H1[(H1["end of 2nd peak"] == end) & (H1.reading == "b line under each peak")].areas.iloc[0]
    print(f"  end {end}: the line under each peak (b) keeps {100 * ba[0] / fa[0]:.0f}% of the main peak's area above the flat "
          f"baseline and {100 * ba[1] / fa[1]:.0f}% of the second peak's")

pk, _ = find_peaks(y, prominence=0.01 * (y.max() - base))
t_main, t_second = t[pk[0]], t[pk[1]]
print(f"\nretention times: main {t_main:.2f} min, second {t_second:.2f} min; second / main {t_second / t_main:.3f} "
      f"(paper 9.1-9.2 / 7.5 = {9.1 / 7.5:.3f}-{9.2 / 7.5:.3f})")
print(f"flow rate that would put the main peak at 7.5 mL: {7.5 / t_main:.3f} mL/min (not given in the paper; not a test)")
for a, b in ((19, 20), (20, 21), (21, 23), (23, 25), (25, 27), (27, 30), (30, 35)):
    m = (t >= a) & (t < b)
    print(f"  signal {a}-{b} min: mean {y[m].mean():.3f}, min {y[m].min():.3f}, max {y[m].max():.3f} (pre-injection {base:.3f}; main peak {y.max():.2f})")
m = (t >= 21) & (t < 30)
print(f"  signal 21-30 min: {y[m].min():.3f} to {y[m].max():.3f}, {y[m].min() / base:.1f} to {y[m].max() / base:.1f} times the pre-injection level")
for ch in ("260_NM", "280_NM", "652_NM"):
    tc, yc = X.hplc(ch)
    pc, _ = find_peaks(yc, prominence=0.01 * (yc.max() - np.median(yc[tc < 5])))
    print(f"{ch}: peaks at {np.round(tc[pc], 2).tolist()} min")

fig, axs = plt.subplots(1, 2, figsize=(13, 3.5))
for a_, (lo, hi, top) in zip(axs, ((10, 32, None), (17, 32, 1.0))):
    a_.plot(t, y, lw=1)
    for end, ls in (("i return to pre-injection + 3 SD", ":"), ("ii end of descent (slope < 1% of steepest)", "--")):
        for i in peak_limits(y, pk, base + 3 * base_sd, end):
            a_.axvline(t[i], color="grey", ls=ls, lw=0.8)
    a_.set_xlim(lo, hi); a_.set_xlabel("time (min)"); a_.set_ylabel("pHAb fluorescence")
    if top:
        a_.set_ylim(0, top)
axs[0].set_title("pHAb chromatogram; limits with end (i) dotted, (ii) dashed")
axs[1].set_title("the same, 17-32 min, y axis cut at 1.0")
plt.show()
print(f"left: 10-32 min; outside it the signal is between {y[(t < 10) | (t > 32)].min():.3f} and {y[(t < 10) | (t > 32)].max():.3f}; "
      f"right: {int(((t >= 17) & (t <= 32) & (y > 1.0)).sum())} samples above the cut at 1.0")
pre-injection level 0.0425 (SD 0.0051) over the first 5 min
detectable                            end of 2nd peak                       reading           peaks (min)                 limits (min)                 areas  main share (%)  share_ok
      1.0%           i return to pre-injection + 3 SD               a flat baseline        [15.16, 18.05]        [12.38, 17.27, 29.76]        [27.25, 13.69]            66.6     False
      1.0%           i return to pre-injection + 3 SD        b line under each peak        [15.16, 18.05]        [12.38, 17.27, 29.76]       [14.61, -18.58]          -367.6     False
      1.0%           i return to pre-injection + 3 SD b common line, drop at valley        [15.16, 18.05]        [12.38, 17.27, 29.76]         [27.18, 13.5]            66.8     False
      1.0% ii end of descent (slope < 1% of steepest)               a flat baseline        [15.16, 18.05]        [12.38, 17.27, 20.53]        [27.25, 12.71]            68.2     False
      1.0% ii end of descent (slope < 1% of steepest)        b line under each peak        [15.16, 18.05]        [12.38, 17.27, 20.53]         [14.61, 3.86]            79.1      True
      1.0% ii end of descent (slope < 1% of steepest) b common line, drop at valley        [15.16, 18.05]        [12.38, 17.27, 20.53]         [26.8, 11.99]            69.1     False
      1.0%            iii below 2% of the peak height               a flat baseline        [15.16, 18.05]        [12.38, 17.27, 20.94]         [27.25, 12.8]            68.0     False
      1.0%            iii below 2% of the peak height        b line under each peak        [15.16, 18.05]        [12.38, 17.27, 20.94]         [14.61, 2.97]            83.1      True
      1.0%            iii below 2% of the peak height b common line, drop at valley        [15.16, 18.05]        [12.38, 17.27, 20.94]        [26.91, 12.18]            68.8     False
      0.5%           i return to pre-injection + 3 SD               a flat baseline [15.16, 18.05, 37.27] [12.38, 17.27, 31.93, 38.61]  [27.25, 13.69, 0.48]            65.8     False
      0.5%           i return to pre-injection + 3 SD        b line under each peak [15.16, 18.05, 37.27] [12.38, 17.27, 31.93, 38.61] [14.61, -18.58, 0.38]          -406.0     False
      0.5%           i return to pre-injection + 3 SD b common line, drop at valley [15.16, 18.05, 37.27] [12.38, 17.27, 31.93, 38.61]   [27.18, 13.5, 0.38]            66.2     False
      0.5% ii end of descent (slope < 1% of steepest)               a flat baseline [15.16, 18.05, 37.27] [12.38, 17.27, 31.93, 38.61]  [27.25, 12.71, 0.48]            67.4     False
      0.5% ii end of descent (slope < 1% of steepest)        b line under each peak [15.16, 18.05, 37.27] [12.38, 17.27, 31.93, 38.61]   [14.61, 3.86, 0.38]            77.5      True
      0.5% ii end of descent (slope < 1% of steepest) b common line, drop at valley [15.16, 18.05, 37.27] [12.38, 17.27, 31.93, 38.61]   [26.8, 11.99, 0.38]            68.4     False
      0.5%            iii below 2% of the peak height               a flat baseline [15.16, 18.05, 37.27] [12.38, 17.27, 31.93, 38.61]   [27.25, 12.8, 0.48]            67.2     False
      0.5%            iii below 2% of the peak height        b line under each peak [15.16, 18.05, 37.27] [12.38, 17.27, 31.93, 38.61]   [14.61, 2.97, 0.38]            81.4      True
      0.5%            iii below 2% of the peak height b common line, drop at valley [15.16, 18.05, 37.27] [12.38, 17.27, 31.93, 38.61]  [26.91, 12.18, 0.38]            68.2     False

readings with a share within 69.3-84.7%: 4 of 18; share over the readings with positive areas 65.8 to 69.1%
valley between the two peaks: 5.19 at 17.27 min (main peak 13.62, pre-injection 0.043)
  end i return to pre-injection + 3 SD: the line under each peak (b) keeps 54% of the main peak's area above the flat baseline and -136% of the second peak's
  end ii end of descent (slope < 1% of steepest): the line under each peak (b) keeps 54% of the main peak's area above the flat baseline and 30% of the second peak's
  end iii below 2% of the peak height: the line under each peak (b) keeps 54% of the main peak's area above the flat baseline and 23% of the second peak's

retention times: main 15.16 min, second 18.05 min; second / main 1.191 (paper 9.1-9.2 / 7.5 = 1.213-1.227)
flow rate that would put the main peak at 7.5 mL: 0.495 mL/min (not given in the paper; not a test)
  signal 19-20 min: mean 1.189, min 0.567, max 2.025 (pre-injection 0.043; main peak 13.62)
  signal 20-21 min: mean 0.349, min 0.250, max 0.566 (pre-injection 0.043; main peak 13.62)
  signal 21-23 min: mean 0.199, min 0.165, max 0.250 (pre-injection 0.043; main peak 13.62)
  signal 23-25 min: mean 0.151, min 0.101, max 0.173 (pre-injection 0.043; main peak 13.62)
  signal 25-27 min: mean 0.115, min 0.093, max 0.136 (pre-injection 0.043; main peak 13.62)
  signal 27-30 min: mean 0.111, min 0.055, max 0.150 (pre-injection 0.043; main peak 13.62)
  signal 30-35 min: mean 0.081, min 0.049, max 0.125 (pre-injection 0.043; main peak 13.62)
  signal 21-30 min: 0.055 to 0.250, 1.3 to 5.9 times the pre-injection level
260_NM: peaks at [1.01, 15.05, 18.68, 37.82, 42.81] min
280_NM: peaks at [0.99, 15.07, 18.75, 21.23, 37.79, 42.82] min
652_NM: peaks at [15.08, 18.0, 33.84, 38.69] min
No description has been provided for this image
left: 10-32 min; outside it the signal is between 0.026 and 0.172; right: 1447 samples above the cut at 1.0

Result: partially reproduced, resting on an assumption about where the second peak ends. The pHAb chromatogram has two detectable peaks, at 15.16 and 18.05 min (a third, small one at 37.27 min passes the 0.5% rule). The share of the first peak depends on the reading. With a flat baseline (reading a) it is 65.8 to 68.2% under every end of the second peak, below the tolerance of 69.3 to 84.7%; so is a common line under both peaks with a drop at the valley (66.2 to 69.1%). With a line under each peak (reading b, as the criterion writes it), the share is 77.5 to 83.1%, within tolerance, when the second peak ends where its own descent ends (end ii, 20.53 min) or where it falls below 2% of its height (end iii, 20.94 min); when it ends where the signal returns to the pre-injection level (end i, 29.76 min), the line from the valley (5.19 high, at 17.27 min) runs above the low tail and the second area is negative, which is no share. From 21 to 30 min the signal is 0.055 to 0.250, 1.3 to 5.9 times the pre-injection level, against a main peak of 13.62; end (i) counts that tail in the second peak. Ends (ii) and (iii), where a peak's own descent ends, are the usual limits of a peak, so the share holds under reading (b), 4 of 18 readings in all. That reading has a cost: as the valley is high, the line under each peak cuts through both peaks, keeping 54% of the main peak's area above the flat baseline and 30% (end ii) or 23% (end iii) of the second peak's. Every reading that splits the overlap the usual way (a flat baseline, or a common line with a drop at the valley) gives 65.8 to 69.1%, just below the tolerance. The share therefore holds by the letter of the criterion's reading (b) only. The retention volumes cannot be tested: the paper gives no flow rate, and the rate that would put the main peak at 7.5 mL (0.495 mL/min) is read from the data. The ratio of the two retention times, 1.191, is 1.8% below the paper's 1.213 to 1.227. Partially reproduced: the share holds under one reading of the criterion, a reading that cuts away part of each peak, and the volume part cannot be tested.

fig2e-page-bands¶

In native PAGE the purified nanosensor runs as several bands of lower mobility than the DNA scaffold (likely 1 to 4 AChE per scaffold), and these bands carry both pHAb and AF647 fluorescence.

Criterion: lane 3 (main peak) shows at least two bands above the scaffold band of lane 1 (ethidium bromide, Fig. 2E), with signal above the lane background in both the pHAb and AF647 images (Fig. S2C); judged by eye with lane profiles. Lanes are found as runs of columns with signal (lane_segments); bands are peaks of the lane profile with a prominence of at least 5% of its range (bands), a choice made here. The ethidium image is framed differently from the two fluorescence images, which are registered to each other (shift printed); band positions are therefore compared within the ethidium image, and within the pair of fluorescence images, where the scaffold band of lane 1 (pHAb-labelled DNA) is the reference.

In [12]:
from skimage.registration import phase_cross_correlation
shift = phase_cross_correlation(G["PHAB"][500:1400, 700:1400], G["AF652"][500:1400, 700:1400])[0]
print("pHAb vs AF647 image shift (rows, columns):", shift)

eb_y0, eb_y1, fl_y0, fl_y1 = 380, 1300, 650, 1400
eb_lanes = X.lane_segments(G["eb"], 420, 1250, 0.3)
fl_lanes = X.lane_segments(G["PHAB"], 700, 1350, 0.2)
af_lanes = X.lane_segments(G["AF652"], 700, 1350, 0.2)
print("ethidium lanes (columns):", eb_lanes)
print("pHAb lanes:", fl_lanes, "  AF647 lanes found on their own:", af_lanes)

def describe(img, seg, y0, y1, label):
    prof = X.lane_profile(img, seg, y0, y1)
    pk, prom = X.bands(prof)
    return prof, [(int(y0 + p), int(prof[p]), int(pr)) for p, pr in zip(pk, prom)]

print("\nEthidium bromide (row, signal above image median, prominence):")
eb = {}
for i, seg in enumerate(eb_lanes):
    name = "ladder" if i == 0 else f"lane {i}"
    prof, bl = describe(G["eb"], seg, eb_y0, eb_y1, name)
    eb[name] = bl
    print(f"  {name} {seg}: {len(bl)} bands {bl}")
well = 440   # rows above this are the wells (the top edge of the gel at about row 400)
scaffold_row = max([b for b in eb["lane 1"] if b[0] > well], key=lambda b: b[1])[0]
above = [b for b in eb["lane 3"] if well < b[0] < scaffold_row - 10]
print(f"lane 1 scaffold band at row {scaffold_row}; lane 3 bands between the well and it: {above}")

# empty gel between lanes, for the background of the fluorescence images
gap = lambda img: img[fl_y0:fl_y1, fl_lanes[1][0] - 12:fl_lanes[1][0] - 4]
print("\npHAb and AF647 (row, signal above image median, prominence); same lane columns in both images:")
fl = {}
for i, seg in enumerate(fl_lanes):
    for c in ("PHAB", "AF652"):
        prof, bl = describe(G[c], seg, fl_y0, fl_y1, c)
        fl[(i + 1, c)] = (prof, bl)
        print(f"  lane {i + 1} {c:5s} {seg}: {bl}")
for c in ("PHAB", "AF652"):
    g = gap(G[c]) - np.median(G[c])
    print(f"  {c} background between lanes 1 and 2: mean {g.mean():.0f}, SD {g.std():.0f}")
fl_well = 700
fl_scaffold = max([b for b in fl[(1, "PHAB")][1] if b[0] > fl_well], key=lambda b: b[1])[0]
print(f"pHAb lane 1 band (pHAb-labelled scaffold) at row {fl_scaffold}")
ph3 = [b for b in fl[(3, "PHAB")][1] if fl_well < b[0] < fl_scaffold - 10]
af3_prof = fl[(3, "AF652")][0]
af_bg = gap(G["AF652"]) - np.median(G["AF652"])
for r, v, p in ph3:
    af_v = af3_prof[r - fl_y0]
    af_near = [b for b in fl[(3, "AF652")][1] if abs(b[0] - r) <= 10]
    print(f"  lane 3 pHAb band at row {r} (signal {v}); AF647 there {af_v:.0f} = {af_v / max(af_bg.std(), 1):.0f} SD of the gap; AF647 band within 10 rows: {af_near}")

fig, ax = plt.subplots(1, 3, figsize=(14, 4))
for a_, (img, lanes, y0, y1, title) in zip(ax, [(G["eb"], eb_lanes, eb_y0, eb_y1, "ethidium"), (G["PHAB"], fl_lanes, fl_y0, fl_y1, "pHAb"), (G["AF652"], fl_lanes, fl_y0, fl_y1, "AF647")]):
    for i, seg in enumerate(lanes):
        a_.plot(np.arange(y0, y1), X.lane_profile(img, seg, y0, y1), label="ladder" if (title == "ethidium" and i == 0) else f"lane {i if title == 'ethidium' else i + 1}")
    a_.set_title(title); a_.set_xlabel("row"); a_.legend(fontsize=7)
plt.show()
pHAb vs AF647 image shift (rows, columns): [2. 1.]
ethidium lanes (columns): [(585, 649), (673, 761), (777, 860), (880, 959), (983, 1068)]
pHAb lanes: [(820, 902), (917, 993), (1017, 1086), (1115, 1186)]   AF647 lanes found on their own: [(895, 995), (1019, 1083), (1118, 1184)]

Ethidium bromide (row, signal above image median, prominence):
  ladder (585, 649): 11 bands [(394, 7051, 5298), (640, 57251, 38522), (659, 57779, 46743), (682, 57980, 46168), (706, 58742, 51250), (737, 61469, 56662), (787, 63356, 62154), (847, 60740, 58168), (918, 61519, 59090), (1019, 61903, 60094), (1189, 59561, 58011)]
  lane 1 (673, 761): 3 bands [(684, 11325, 5372), (878, 44564, 43522), (926, 25223, 2310)]
  lane 2 (777, 860): 5 bands [(408, 55795, 54771), (508, 35282, 6433), (592, 36893, 14203), (810, 23087, 18588), (863, 15701, 7807)]
  lane 3 (880, 959): 3 bands [(407, 60662, 59896), (511, 36309, 6027), (593, 37468, 16218)]
  lane 4 (983, 1068): 4 bands [(407, 9446, 5698), (593, 12369, 9010), (809, 16420, 15590), (862, 12268, 5789)]
lane 1 scaffold band at row 878; lane 3 bands between the well and it: [(511, 36309, 6027), (593, 37468, 16218)]

pHAb and AF647 (row, signal above image median, prominence); same lane columns in both images:
  lane 1 PHAB  (820, 902): [(1119, 6457, 6420)]
  lane 1 AF652 (820, 902): [(660, 201, 33), (860, 277, 45), (1024, 765, 604), (1327, 201, 59)]
  lane 2 PHAB  (917, 993): [(685, 3210, 3160), (775, 2127, 733), (856, 2295, 1238), (1061, 1255, 1040), (1111, 798, 401)]
  lane 2 AF652 (917, 993): [(684, 18620, 18264), (776, 9968, 2679), (854, 15627, 9165), (1062, 9133, 7100)]
  lane 3 PHAB  (1017, 1086): [(686, 3558, 3515), (783, 2117, 598), (861, 2095, 1078)]
  lane 3 AF652 (1017, 1086): [(685, 19209, 18942), (783, 9642, 2494), (859, 13001, 7519)]
  lane 4 PHAB  (1115, 1186): [(691, 284, 157), (791, 219, 45), (868, 462, 335), (1070, 870, 856), (1119, 581, 287)]
  lane 4 AF652 (1115, 1186): [(690, 1473, 782), (865, 3413, 2625), (1070, 5666, 5541)]
  PHAB background between lanes 1 and 2: mean 109, SD 102
  AF652 background between lanes 1 and 2: mean 1482, SD 1231
pHAb lane 1 band (pHAb-labelled scaffold) at row 1119
  lane 3 pHAb band at row 783 (signal 2117); AF647 there 9643 = 8 SD of the gap; AF647 band within 10 rows: [(783, 9642, 2494)]
  lane 3 pHAb band at row 861 (signal 2095); AF647 there 12873 = 10 SD of the gap; AF647 band within 10 rows: [(859, 13001, 7519)]
No description has been provided for this image

Result: reproduced. In the ethidium image, lane 3 (main peak) has two bands, at rows 511 and 593, between the well and the scaffold band of lane 1 (row 878), so both run slower than the scaffold. In the fluorescence images, lane 3 has two pHAb bands (rows 783 and 861) above the pHAb-labelled scaffold band of lane 1 (row 1119), and the AF647 image has bands at the same rows (783 and 859), 8 and 10 SD above the gel between lanes. Lane 1 of the fluorescence images has one pHAb band and no AF647 band above the background (its largest AF647 peak is 765 counts above the image median, against an SD of 1231 between lanes), as for a DNA scaffold without BTX: Figure 2E labels lane 1 as the scaffold, Figure S2C as unpurified nanosensor.

figs5-btx-staining¶

Ex vivo staining of freshly isolated SMG with BTX-AF647 shows a punctate pattern across the ganglion, confirming nicotinic ACh receptors on SMG neurons.

Criterion: in the confocal z-stacks of a ChAT(BAC)-eGFP SMG (Fig. S5), the AF647 channel shows discrete puncta distributed over the ganglion and lying on or next to GFP-positive cell bodies; judged by eye on maximum projections and single slices. The numbers below support the judgement: AF647 puncta (components above the background threshold, 0.1 to 25 um^2, puncta; the background rule is in xia2021.py: since round 1 of verification the median plus 3 SD of the lower half of the pixels reflected about the median, with the first rule, the mean plus 3 SD of the lower half, shown as a variant, as it passes much of the noise), their density, the share of 8 x 8 tiles over the ganglion (GFP mask) that hold one, and the share lying within 1 um of the GFP mask, against the share of the field that lies there (the value for puncta placed at random). The GFP mask is drawn two ways (soma_mask): Otsu's threshold, which in these images picks out the bright presynaptic fibres more than the dimmer somata, and the background rule, which takes in the somata. Single planes: the plane with the brightest AF647.

In [13]:
def punctum_stats(af, gfp, px, label, rule="reflected"):
    lab, keep, thr = X.puncta(af, px, rule=rule)
    cents = np.round(np.array(ndi.center_of_mass(np.ones_like(lab), lab, keep))).astype(int) if len(keep) else np.zeros((0, 2), int)
    h, w = af.shape
    out = {"image": label, "background rule": rule, "threshold": round(thr), "puncta": len(keep), "per_100um2": round(100 * len(keep) / (h * w * px ** 2), 2)}
    for rule in ("otsu", "background"):
        gm = X.soma_mask(gfp, px, rule)
        near = ndi.binary_dilation(gm, iterations=max(1, int(round(1.0 / px))))
        tiles, filled = 0, 0
        for i in range(8):
            for j in range(8):
                sl = (slice(i * h // 8, (i + 1) * h // 8), slice(j * w // 8, (j + 1) * w // 8))
                if gm[sl].mean() > 0.2:
                    tiles += 1
                    filled += int(np.any((cents[:, 0] >= sl[0].start) & (cents[:, 0] < sl[0].stop) & (cents[:, 1] >= sl[1].start) & (cents[:, 1] < sl[1].stop)))
        out[f"GFP mask ({rule}) frac"] = round(float(gm.mean()), 2)
        out[f"tiles over GFP with puncta ({rule})"] = f"{filled}/{tiles}"
        out[f"puncta within 1 um ({rule})"] = round(float(near[cents[:, 0], cents[:, 1]].mean()), 2) if len(keep) else np.nan
        out[f"field within 1 um ({rule})"] = round(float(near.mean()), 2)
    return out

rows = []
for name in ("bungarotoxin Z-stack high magnification", "bungarotoxin Z-stack low magnification"):
    d = LSM[name]
    a, dyes, px = d["arr"], d["dyes"], d["vox"]["X"]
    gi, ai = dyes.index("EGFP"), dyes.index("Alexa Fluor 647")
    mx = a.max(0)
    z = int(np.argmax([a[k, ai].mean() for k in range(a.shape[0])]))
    for rule in ("reflected", "lower_half"):
        rows.append(punctum_stats(mx[ai].astype(float), mx[gi].astype(float), px, f"{name}, max projection", rule))
        rows.append(punctum_stats(a[z, ai].astype(float), a[z, gi].astype(float), px, f"{name}, plane {z} (brightest AF647)", rule))
print(pd.DataFrame(rows).T.to_string(header=False))
print("background rule: reflected (median + 3 SD of the reflected lower half, the rule used since round 1) and lower_half (the first version)")

fig, ax = plt.subplots(1, 2, figsize=(12, 6))
for a_, name in zip(ax, ("bungarotoxin Z-stack high magnification", "bungarotoxin Z-stack low magnification")):
    d = LSM[name]; mx = d["arr"].max(0)
    g, r = mx[d["dyes"].index("EGFP")].astype(float), mx[d["dyes"].index("Alexa Fluor 647")].astype(float)
    norm = lambda im: np.clip((im - np.percentile(im, 1)) / (np.percentile(im, 99.5) - np.percentile(im, 1)), 0, 1)
    a_.imshow(np.dstack([norm(r), norm(g), np.zeros_like(r)])); a_.set_title(f"{name}\nred AF647 (BTX), green GFP"); a_.axis("off")
plt.show()
print("display: intensities scaled from the 1st to the 99.5th percentile of each channel; brighter pixels shown at full scale")
image                                    bungarotoxin Z-stack high magnification, max projection  bungarotoxin Z-stack high magnification, plane 6 (brightest AF647)  bungarotoxin Z-stack high magnification, max projection  bungarotoxin Z-stack high magnification, plane 6 (brightest AF647)  bungarotoxin Z-stack low magnification, max projection  bungarotoxin Z-stack low magnification, plane 0 (brightest AF647)  bungarotoxin Z-stack low magnification, max projection  bungarotoxin Z-stack low magnification, plane 0 (brightest AF647)
background rule                                                                        reflected                                                           reflected                                               lower_half                                                          lower_half                                               reflected                                                          reflected                                              lower_half                                                         lower_half
threshold                                                                                   5656                                                                3554                                                     3481                                                                1843                                                    6904                                                               1638                                                    3411                                                                457
puncta                                                                                      1172                                                                1188                                                     2122                                                                2412                                                    1821                                                               6513                                                    7348                                                              26603
per_100um2                                                                                 11.35                                                               11.51                                                    20.55                                                               23.36                                                    4.41                                                              15.77                                                   17.79                                                              64.41
GFP mask (otsu) frac                                                                        0.11                                                                0.08                                                     0.11                                                                0.08                                                    0.34                                                               0.03                                                    0.34                                                               0.03
tiles over GFP with puncta (otsu)                                                          13/13                                                               10/10                                                    13/13                                                               10/10                                                   29/29                                                                5/5                                                   29/29                                                                5/5
puncta within 1 um (otsu)                                                                   0.18                                                                 0.1                                                      0.1                                                                0.07                                                    0.82                                                               0.03                                                    0.53                                                                0.0
field within 1 um (otsu)                                                                    0.15                                                                0.11                                                     0.15                                                                0.11                                                    0.37                                                               0.04                                                    0.37                                                               0.04
GFP mask (background) frac                                                                  0.06                                                                 0.1                                                     0.06                                                                 0.1                                                    0.08                                                               0.22                                                    0.08                                                               0.22
tiles over GFP with puncta (background)                                                      9/9                                                               12/12                                                      9/9                                                               12/12                                                   14/14                                                              17/17                                                   14/14                                                              17/17
puncta within 1 um (background)                                                             0.12                                                                0.12                                                     0.07                                                                0.08                                                    0.29                                                               0.61                                                    0.12                                                               0.05
field within 1 um (background)                                                              0.09                                                                0.13                                                     0.09                                                                0.13                                                    0.11                                                               0.24                                                    0.11                                                               0.24
background rule: reflected (median + 3 SD of the reflected lower half, the rule used since round 1) and lower_half (the first version)
No description has been provided for this image
display: intensities scaled from the 1st to the 99.5th percentile of each channel; brighter pixels shown at full scale

Result: reproduced. By eye, on the maximum projections above and on single planes, the AF647 (BTX) signal is punctate, with puncta over the whole ganglion and along the borders of the GFP-positive somata. In numbers, with the background rule used since round 1 (reflected), every 8 x 8 tile over the GFP mask holds puncta in all four images (5/5 to 29/29 tiles with the Otsu mask), at 4.4 to 15.8 puncta per 100 um^2 (17.8 to 64.4 with the first rule, which passed much of the noise). Nearness to GFP beyond chance holds in three of the four images by at least one mask: in the low-magnification projection 0.82 of puncta lie within 1 um of the Otsu GFP mask, against 0.37 of the field (0.29 against 0.11 with the background-rule mask); in its brightest plane 0.61 against 0.24 (background-rule mask); in the high-magnification projection 0.18 against 0.15 and 0.12 against 0.09. The high-magnification stack holds data in 12 of its 62 planes (50 are all zero). The judgement by eye decides the outcome; the numbers support it.

fig3d-sensor-on-soma¶

Confocal imaging of a nanosensor-stained SMG shows punctate AF647 and pHAb staining that overlaps and lies mainly on the neuronal cell soma, consistent with the BTX staining.

Criterion: in the confocal stacks of a nanosensor-injected, fixed ChAT(BAC)-eGFP SMG, puncta in the AF647 and pHAb channels coincide and most lie on GFP-positive somata; (a) judged by eye, as the paper does; (b) as a check, more than half of the AF647 puncta (threshold at mean plus 3 SD of the background) overlap pHAb puncta and lie within the GFP soma mask. Reproduced when (a) holds; (b) is shown. The background of the threshold is not defined in the paper; the rule used since round 1 of verification is the median plus 3 SD of the lower half of the pixels reflected about the median (X.background_threshold), and the first rule (mean plus 3 SD of the lower half), which marked a third or more of the field and so made overlap near certain, is shown as a variant. The images: the sub-5 stack of SPARC:108 (maximum projection and middle plane), and the three high-magnification nanosensor images of SPARC:75. A punctum overlaps pHAb when one of its pixels is above the pHAb threshold. As the pHAb channel also shows the GFP of the somata (see the correlation printed), a variant uses the pHAb channel after a white top-hat of radius 1 um, which keeps spots and removes the broad soma signal. As a reference for chance, the overlap is also computed with the pHAb mask shifted by 5 um (a deterministic shift, about a third of a soma; the larger of two diagonal shifts is printed), for the plain and the top-hat pHAb masks. A full-resolution crop shows each channel alone. "Within the soma mask" is shown with the Otsu mask, the same grown by 1 um (BTX binds the soma membrane at its edge), and the background-rule mask; each is compared with the share of the field the mask covers.

In [14]:
from skimage.morphology import disk, white_tophat

def overlap_stats(af, ph, gfp, px, label, rule="reflected"):
    lab, keep, thr = X.puncta(af, px, rule=rule)
    r1 = max(1, int(round(1.0 / px)))
    ph_th = white_tophat(ph, disk(r1))
    pm = ph > X.background_threshold(ph, rule=rule)
    pm_th = ph_th > X.background_threshold(ph_th, rule=rule)
    gm = X.soma_mask(gfp, px)
    gm1 = ndi.binary_dilation(gm, iterations=r1)
    gmb = X.soma_mask(gfp, px, "background")
    idx = ndi.labeled_comprehension
    sh = int(round(5.0 / px))
    ov = lambda m: idx(m, lab, keep, np.any, bool, False) if len(keep) else np.array([], bool)
    o, o_th = ov(pm), ov(pm_th)
    null = lambda m: max(ov(np.roll(m, (sh, sh), (0, 1))).mean(), ov(np.roll(m, (-sh, sh), (0, 1))).mean())
    cents = np.round(np.array(ndi.center_of_mass(np.ones_like(lab), lab, keep))).astype(int) if len(keep) else np.zeros((0, 2), int)
    ins, ins1, insb = (g_[cents[:, 0], cents[:, 1]] for g_ in (gm, gm1, gmb))
    return {"image": label, "background rule": rule, "AF647 puncta": len(keep), "AF647>thr area": round(float((af > thr).mean()), 3),
            "pHAb>thr area": round(float(pm.mean()), 3), "overlap pHAb": round(o.mean(), 2), "overlap, pHAb shifted 5 um (larger of 2)": round(null(pm), 2),
            "pHAb top-hat>thr area": round(float(pm_th.mean()), 3), "overlap pHAb top-hat": round(o_th.mean(), 2),
            "overlap top-hat, shifted 5 um (larger of 2)": round(null(pm_th), 2),
            "in soma mask (Otsu)": round(ins.mean(), 2), "soma mask frac": round(gm.mean(), 2),
            "within 1 um of soma": round(ins1.mean(), 2), "soma+1um frac": round(gm1.mean(), 2),
            "in soma (background rule)": round(insb.mean(), 2), "soma (background rule) frac": round(float(gmb.mean()), 2),
            "coinciding puncta within 1 um of soma": round(ins1[o].mean(), 2) if o.any() else np.nan,
            "(b) both, mask": round((o & ins).mean(), 2), "(b) both, top-hat, +1um": round((o_th & ins1).mean(), 2),
            "(b) both, background-rule mask": round((o & insb).mean(), 2),
            "r pHAb vs GFP": round(stats.pearsonr(ph[::3, ::3].ravel(), gfp[::3, ::3].ravel())[0], 2)}

rows = []
names = CZ_NAMES
iA, iP, iG = names.index("Alexa Fluor 647"), names.index("Alexa Fluor 532"), names.index("EGFP")
IMGS3D = [(CZ_MAX[iA], CZ_MAX[iP], CZ_MAX[iG], CZ_SCALE["X"], "SPARC:108 sub-5, max projection"),
          (CZ_MID[iA], CZ_MID[iP], CZ_MID[iG], CZ_SCALE["X"], f"SPARC:108 sub-5, plane {CZ_NZ // 2}")]
for k in (1, 2, 3):
    d = LSM[f"nanosensor high magnification_{k}"]
    a = d["arr"]
    IMGS3D.append((a[d["dyes"].index("Alexa Fluor 647")], a[d["dyes"].index("Alexa Fluor 546")], a[d["dyes"].index("Alexa Fluor 488")],
                   d["vox"]["X"], f"SPARC:75 nanosensor high magnification_{k}"))
for rule in ("reflected", "lower_half"):
    for af, ph, g, px, lab_ in IMGS3D:
        rows.append(overlap_stats(af.astype(float), ph.astype(float), g.astype(float), px, lab_, rule))
R3 = pd.DataFrame(rows)
print(R3.T.to_string(header=False))
print("background rule: reflected (the rule used since round 1) and lower_half (the first version)")
for af, ph, g, px, lab_ in IMGS3D:
    print(f"{lab_}: zero pixels AF647 {100 * (af == 0).mean():.1f}%, pHAb {100 * (ph == 0).mean():.1f}%; median AF647 {np.median(af):.0f}, pHAb {np.median(ph):.0f}")

fig, ax = plt.subplots(1, 2, figsize=(13, 6.5))
norm = lambda im: np.clip((im - np.percentile(im, 1)) / (np.percentile(im, 99.7) - np.percentile(im, 1)), 0, 1)
for a_, (arr, title) in zip(ax, ((CZ_MAX, "sub-5 max projection"), (CZ_MID, "sub-5 middle plane"))):
    a_.imshow(np.dstack([norm(arr[iA].astype(float)), norm(arr[iP].astype(float)), 0.5 * norm(arr[iG].astype(float))]))
    a_.set_title(f"{title}: red AF647, green pHAb, blue GFP"); a_.axis("off")
plt.show()
print("display: each channel scaled from its 1st to 99.7th percentile")

# Full-resolution crop of the sub-5 max projection, each channel alone and the merge, with the masks drawn by the reflected rule.
cy, cx, hw = CZ_MAX.shape[1] // 2, CZ_MAX.shape[2] // 2, 300
sl = (slice(cy - hw, cy + hw), slice(cx - hw, cx + hw))
A_, P_, G_ = (CZ_MAX[i][sl].astype(float) for i in (iA, iP, iG))
fig, ax = plt.subplots(1, 4, figsize=(18, 4.8))
for a_, (im, title) in zip(ax, ((A_, "AF647"), (P_, "pHAb (AF532)"), (G_, "GFP"))):
    a_.imshow(norm(im), cmap="gray"); a_.set_title(title); a_.axis("off")
pm_c = P_ > X.background_threshold(P_); am_c = A_ > X.background_threshold(A_)
ax[3].imshow(np.dstack([am_c, pm_c, 0.5 * norm(G_)]).astype(float)); ax[3].set_title("above threshold: red AF647, green pHAb,\nyellow both, blue GFP", fontsize=9); ax[3].axis("off")
plt.show()
print(f"rows {cy - hw}-{cy + hw}, columns {cx - hw}-{cx + hw}: crop {2 * hw} x {2 * hw} px = {2 * hw * CZ_SCALE['X']:.1f} um square at full resolution; in the crop {100 * am_c.mean():.1f}% of pixels are above the AF647 threshold, "
      f"{100 * pm_c.mean():.1f}% above the pHAb threshold, {100 * (am_c & pm_c).mean():.1f}% above both")
image                                        SPARC:108 sub-5, max projection  SPARC:108 sub-5, plane 13  SPARC:75 nanosensor high magnification_1  SPARC:75 nanosensor high magnification_2  SPARC:75 nanosensor high magnification_3  SPARC:108 sub-5, max projection  SPARC:108 sub-5, plane 13  SPARC:75 nanosensor high magnification_1  SPARC:75 nanosensor high magnification_2  SPARC:75 nanosensor high magnification_3
background rule                                                    reflected                  reflected                                 reflected                                 reflected                                 reflected                       lower_half                 lower_half                                lower_half                                lower_half                                lower_half
AF647 puncta                                                            2228                       3937                                       438                                       933                                       455                             5415                      10729                                      1625                                      1488                                       946
AF647>thr area                                                         0.082                      0.168                                     0.087                                     0.109                                     0.112                            0.329                      0.345                                     0.331                                     0.363                                     0.335
pHAb>thr area                                                          0.072                      0.348                                     0.106                                     0.116                                     0.125                            0.321                      0.475                                     0.339                                     0.368                                     0.345
overlap pHAb                                                            0.59                       0.98                                      0.77                                      0.85                                      0.66                             0.84                       0.98                                      0.85                                      0.86                                      0.88
overlap, pHAb shifted 5 um (larger of 2)                                0.41                       0.95                                       0.4                                      0.53                                      0.39                             0.82                       0.98                                      0.81                                      0.78                                      0.79
pHAb top-hat>thr area                                                  0.093                      0.349                                     0.093                                       0.1                                     0.105                            0.311                      0.472                                     0.332                                     0.357                                     0.338
overlap pHAb top-hat                                                    0.78                       0.98                                      0.75                                      0.79                                      0.68                             0.96                       0.98                                       0.9                                      0.89                                      0.91
overlap top-hat, shifted 5 um (larger of 2)                             0.64                       0.95                                      0.42                                      0.52                                       0.4                             0.95                       0.98                                      0.87                                      0.83                                      0.86
in soma mask (Otsu)                                                     0.29                       0.09                                      0.47                                      0.13                                      0.37                             0.37                        0.2                                      0.32                                      0.17                                      0.42
soma mask frac                                                          0.35                       0.23                                      0.42                                      0.28                                      0.39                             0.35                       0.23                                      0.42                                      0.28                                      0.39
within 1 um of soma                                                     0.34                       0.15                                      0.55                                      0.14                                      0.44                             0.41                       0.26                                      0.39                                      0.22                                      0.52
soma+1um frac                                                           0.38                       0.27                                      0.48                                      0.33                                      0.47                             0.38                       0.27                                      0.48                                      0.33                                      0.47
in soma (background rule)                                               0.05                       0.22                                       0.0                                      0.11                                      0.03                             0.06                       0.34                                       0.0                                      0.14                                      0.02
soma (background rule) frac                                             0.08                       0.34                                       0.0                                      0.25                                      0.03                             0.08                       0.34                                       0.0                                      0.25                                      0.03
coinciding puncta within 1 um of soma                                   0.42                       0.16                                      0.52                                      0.15                                      0.41                             0.48                       0.26                                      0.39                                      0.22                                      0.52
(b) both, mask                                                          0.22                       0.09                                      0.35                                      0.11                                      0.24                             0.36                        0.2                                      0.27                                      0.16                                      0.38
(b) both, top-hat, +1um                                                 0.29                       0.15                                       0.4                                      0.13                                      0.31                              0.4                       0.26                                      0.35                                       0.2                                      0.47
(b) both, background-rule mask                                          0.04                       0.22                                       0.0                                      0.09                                      0.02                             0.06                       0.34                                       0.0                                      0.12                                      0.02
r pHAb vs GFP                                                           0.53                       0.43                                     -0.04                                     -0.02                                     -0.01                             0.53                       0.43                                     -0.04                                     -0.02                                     -0.01
background rule: reflected (the rule used since round 1) and lower_half (the first version)
SPARC:108 sub-5, max projection: zero pixels AF647 0.0%, pHAb 0.0%; median AF647 868, pHAb 10825
SPARC:108 sub-5, plane 13: zero pixels AF647 7.5%, pHAb 0.0%; median AF647 80, pHAb 1397
SPARC:75 nanosensor high magnification_1: zero pixels AF647 0.6%, pHAb 0.8%; median AF647 323, pHAb 406
SPARC:75 nanosensor high magnification_2: zero pixels AF647 1.0%, pHAb 2.1%; median AF647 331, pHAb 310
SPARC:75 nanosensor high magnification_3: zero pixels AF647 0.0%, pHAb 0.7%; median AF647 359, pHAb 258
No description has been provided for this image
display: each channel scaled from its 1st to 99.7th percentile
No description has been provided for this image
rows 662-1262, columns 662-1262: crop 600 x 600 px = 66.3 um square at full resolution; in the crop 8.9% of pixels are above the AF647 threshold, 8.5% above the pHAb threshold, 2.4% above both

Result: partially reproduced. By eye (merges above, and the full-resolution crop with each channel shown alone), the sub-5 stack shows puncta in both channels and yellow spots where they coincide, as in Fig. 3D; but much of the AF647 signal lines the borders of the cells and the capsule of the ganglion, and the coinciding spots lie mostly between or at the edges of the somata. With the background rule used since round 1 (reflected), which marks 7 to 12% of the field as pHAb in four of the five images (35% in sub-5 plane 13), the coincidence is above chance: 59 to 85% of AF647 puncta overlap pHAb in those four, against 39 to 53% with the pHAb mask shifted by 5 um (top-hat pHAb: 68 to 79% against 40 to 64%); in plane 13 it is 98% against 95%. The first rule marked 32 to 48% of the field and gave 84 to 98% against 78 to 98%. The soma localisation is not shown: 9 to 47% of AF647 puncta lie in the Otsu soma mask, which covers 23 to 42% of the field, and 15 to 52% of the coinciding puncta lie within 1 um of it, against 27 to 48% of the field. Reading (b) fails: the share of AF647 puncta that overlap pHAb and lie in the soma mask is 0.09 to 0.35 (0.13 to 0.40 with the top-hat and the 1 um margin), below one half in every image. In the sub-5 stack the pHAb channel correlates with GFP (r 0.43 and 0.53), so part of its signal inside somata may be GFP excited at 514 nm. Partially reproduced: the puncta coincide beyond chance, but their place on the somata is not shown.

fig4b-michaelis-menten¶

The initial rate of the ex vivo nanosensor response follows a Michaelis-Menten curve in ACh concentration with EC50 (Km) 49.24 ± 5.84 uM and Vmax 281.00 ± 7.14 %/s (R2 0.9811); the upper limit of detection is 358.01 uM.

Criterion: initial rates of pHAb dF/F per concentration, fit by V = Vmax [ACh] / (Km + [ACh]); reproduced when Km (43.40 to 55.08 uM) and Vmax (273.86 to 288.14 %/s) are within tolerance under one reading. Readings run here, all crossed: frame interval 0.55 s (paper) or 0.50 s (the in vivo files); photobleaching curve fit to (a) the frames before onset (there is no recovery within these recordings) or (b) the whole trace; baseline (a) mean of the frames before onset or (b) the first frame; initial rate (a) a linear fit from onset to the peak or (b) over the first k = 2 to 5 frames; ROI the stained tissue or the whole frame (the paper's ROI is not given). Onset is the last frame before the largest one-frame rise, as the addition time is not recorded (an assumption; at 0.00714 and 0.0714 uM there is no clear step); a variant puts it at one frame for every recording. Means over mice and all points are the same here (one mouse). Upper limit of detection: (a) the concentration at 88% of Vmax, (b) the upper end of the region where the tangent at EC50 (on log concentration) stays within 5% of the curve (Methods, "within 5% deviation").

In [15]:
conc = np.array([c["conc_uM"] for c in CAL])
combos, fits = [], []
fallback = 0
for roi in ("tissue", "full"):
    for dt in (X.FRAME_S_PAPER, X.FRAME_S_FILE):
        for bl in ("a", "b"):
            for base in ("mean", "first"):
                for rd in ("peak", "k2", "k3", "k4", "k5"):
                    v = []
                    for c in CAL:
                        tr, on = c[roi], c["onset"]
                        idx = np.arange(on + 1) if bl == "a" else np.arange(len(tr))
                        corr, _, how = X.bleach_correct(tr, idx, with_method=True)
                        fallback += how == "line"
                        v.append(X.initial_rate(X.dff(corr, on, base), on, dt, rd))
                    v = np.array(v)
                    try:
                        vmax, km, se_v, se_k, r2 = X.fit_mm(conc, v)
                    except Exception:
                        vmax = km = se_v = se_k = r2 = np.nan
                    fits.append({"roi": roi, "dt_s": dt, "bleach": bl, "baseline": base, "rate": rd, "Vmax": vmax, "se_Vmax": se_v,
                                 "Km_uM": km, "se_Km": se_k, "R2": r2, "rates": np.round(v, 1).tolist()})
F = pd.DataFrame(fits)
F["Km_ok"] = (F.Km_uM - 49.24).abs() <= 5.84
F["Vmax_ok"] = (F.Vmax - 281.00).abs() <= 7.14
print(f"{len(F)} readings; photobleaching fits that fell back to a line: {fallback} of {len(F) * len(CAL)}")
print(F.drop(columns="rates").round(4).to_string(index=False))
print(f"\nreadings with Km within tolerance: {int(F.Km_ok.sum())}; with Vmax within: {int(F.Vmax_ok.sum())}; both: {int((F.Km_ok & F.Vmax_ok).sum())}")
print(f"Km over all readings {F.Km_uM.min():.3g} to {F.Km_uM.max():.3g} uM (median {F.Km_uM.median():.3g}); Vmax {F.Vmax.min():.1f} to {F.Vmax.max():.1f} %/s; R2 {F.R2.min():.2f} to {F.R2.max():.2f}")

main = F[(F.roi == "tissue") & (F.dt_s == X.FRAME_S_PAPER) & (F.bleach == "a") & (F.baseline == "mean") & (F.rate == "peak")].iloc[0]
print(f"\nfirst reading (tissue, 0.55 s, bleach a, mean baseline, rate to peak): rates {main.rates} %/s at {conc.tolist()} uM")
print(f"  Vmax {main.Vmax:.2f} ± {main.se_Vmax:.2f} %/s, Km {main.Km_uM:.4g} ± {main.se_Km:.3g} uM, R2 {main.R2:.3f}")
rho = stats.spearmanr(conc, main.rates)
print(f"  Spearman correlation of rate with concentration: rho {rho.statistic:.2f}, p {rho.pvalue:.3f}")

# Variant: one onset for every recording, the most common frame of the largest one-frame rise (the
# addition time is not recorded, so this tests only whether the per-recording onset drives the result).
common_on = int(pd.Series([c["onset"] for c in CAL]).mode().iloc[0])
vc = []
for c in CAL:
    corr, _ = X.bleach_correct(c["tissue"], np.arange(common_on + 1))
    vc.append(X.initial_rate(X.dff(corr, common_on, "mean"), common_on, X.FRAME_S_PAPER, "peak"))
vmc, kmc, _, _, r2c = X.fit_mm(conc, np.array(vc))
print(f"\nvariant, onset at frame {common_on} in every recording (first reading otherwise): rates {np.round(vc, 1).tolist()} %/s; "
      f"Vmax {vmc:.2f} %/s, Km {kmc:.4g} uM, R2 {r2c:.3f}")

def ulod(vmax, km):
    a = km * 0.88 / (1 - 0.88)
    cs = np.logspace(np.log10(km), np.log10(km) + 4, 4000)
    tang = vmax / 2 + vmax / 4 * np.log(cs / km)
    mm = X.michaelis_menten(cs, vmax, km)
    ok = np.abs(tang - mm) / mm <= 0.05
    b = cs[np.argmin(ok)] if not ok.all() else np.nan
    return a, b
for label, (vm, k) in (("paper's fit", (281.0, 49.24)), ("first reading", (main.Vmax, main.Km_uM))):
    a, b = ulod(vm, k)
    print(f"upper limit of detection, {label}: (a) 88% of Vmax at {a:.4g} uM; (b) tangent within 5% up to {b:.4g} uM")

fig, ax = plt.subplots(figsize=(6, 4))
cs = np.logspace(-4, 3.2, 200)
ax.semilogx(conc, main.rates, "o", label="sub-1 rates (first reading)")
ax.semilogx(cs, X.michaelis_menten(cs, main.Vmax, main.Km_uM), label="fit")
ax.semilogx(cs, X.michaelis_menten(cs, 281.0, 49.24), "--", label="paper's curve")
ax.set_xlabel("[ACh] (uM)"); ax.set_ylabel("initial rate (%/s)"); ax.legend(fontsize=8)
plt.show()
print(f"plotted rates {min(main.rates):.1f} to {max(main.rates):.1f} %/s; paper's curve up to 281 %/s")
80 readings; photobleaching fits that fell back to a line: 0 of 640
   roi  dt_s bleach baseline rate    Vmax  se_Vmax  Km_uM  se_Km     R2  Km_ok  Vmax_ok
tissue  0.55      a     mean peak  8.6523   2.4345 0.2617 0.5959 0.3727  False    False
tissue  0.55      a     mean   k2 45.2046   6.4505 0.5543 0.5878 0.6987  False    False
tissue  0.55      a     mean   k3 29.5273   4.2426 0.4541 0.4959 0.6991  False    False
tissue  0.55      a     mean   k4 21.6723   3.4155 0.2822 0.3575 0.6354  False    False
tissue  0.55      a     mean   k5 16.9747   2.8695 0.2352 0.3240 0.5938  False    False
tissue  0.55      a    first peak  8.6128   2.4289 0.2495 0.5714 0.3692  False    False
tissue  0.55      a    first   k2 44.9222   6.3871 0.5261 0.5589 0.6974  False    False
tissue  0.55      a    first   k3 29.3800   4.2382 0.4320 0.4765 0.6951  False    False
tissue  0.55      a    first   k4 21.6142   3.4422 0.2703 0.3474 0.6279  False    False
tissue  0.55      a    first   k5 16.9535   2.9065 0.2266 0.3173 0.5845  False    False
tissue  0.55      b     mean peak 10.8686   2.3069 0.0516 0.0913 0.1663  False    False
tissue  0.55      b     mean   k2 40.5565   5.6783 0.7247 0.7386 0.7100  False    False
tissue  0.55      b     mean   k3 25.7868   3.5092 0.6489 0.6473 0.7276  False    False
tissue  0.55      b     mean   k4 18.1504   2.6457 0.3803 0.4307 0.6759  False    False
tissue  0.55      b     mean   k5 13.6447   2.0604 0.3153 0.3783 0.6531  False    False
tissue  0.55      b    first peak  8.5063   1.9343 0.0307 0.0616 0.0113  False    False
tissue  0.55      b    first   k2 30.3234   4.1424 0.5003 0.5134 0.6758  False    False
tissue  0.55      b    first   k3 19.3305   2.5866 0.4455 0.4541 0.6965  False    False
tissue  0.55      b    first   k4 13.7589   2.0490 0.2686 0.3229 0.6205  False    False
tissue  0.55      b    first   k5 10.4089   1.6389 0.2304 0.2960 0.5863  False    False
tissue  0.50      a     mean peak  9.5175   2.6780 0.2617 0.5959 0.3727  False    False
tissue  0.50      a     mean   k2 49.7250   7.0956 0.5543 0.5878 0.6987  False    False
tissue  0.50      a     mean   k3 32.4800   4.6669 0.4541 0.4959 0.6991  False    False
tissue  0.50      a     mean   k4 23.8395   3.7570 0.2822 0.3575 0.6354  False    False
tissue  0.50      a     mean   k5 18.6722   3.1565 0.2352 0.3240 0.5938  False    False
tissue  0.50      a    first peak  9.4741   2.6718 0.2495 0.5714 0.3692  False    False
tissue  0.50      a    first   k2 49.4144   7.0258 0.5261 0.5589 0.6974  False    False
tissue  0.50      a    first   k3 32.3180   4.6620 0.4320 0.4765 0.6951  False    False
tissue  0.50      a    first   k4 23.7757   3.7864 0.2703 0.3474 0.6279  False    False
tissue  0.50      a    first   k5 18.6488   3.1971 0.2266 0.3173 0.5845  False    False
tissue  0.50      b     mean peak 11.9554   2.5375 0.0516 0.0913 0.1663  False    False
tissue  0.50      b     mean   k2 44.6122   6.2462 0.7247 0.7386 0.7100  False    False
tissue  0.50      b     mean   k3 28.3655   3.8602 0.6489 0.6473 0.7276  False    False
tissue  0.50      b     mean   k4 19.9655   2.9103 0.3803 0.4307 0.6759  False    False
tissue  0.50      b     mean   k5 15.0092   2.2664 0.3153 0.3783 0.6531  False    False
tissue  0.50      b    first peak  9.3569   2.1278 0.0307 0.0616 0.0113  False    False
tissue  0.50      b    first   k2 33.3558   4.5566 0.5003 0.5134 0.6758  False    False
tissue  0.50      b    first   k3 21.2635   2.8453 0.4455 0.4541 0.6965  False    False
tissue  0.50      b    first   k4 15.1348   2.2539 0.2686 0.3229 0.6205  False    False
tissue  0.50      b    first   k5 11.4498   1.8028 0.2304 0.2960 0.5863  False    False
  full  0.55      a     mean peak  8.3176   1.9927 0.5762 1.0220 0.3713  False    False
  full  0.55      a     mean   k2 43.4534   7.0165 0.1671 0.2214 0.5999  False    False
  full  0.55      a     mean   k3 28.3353   4.4788 0.1714 0.2225 0.6231  False    False
  full  0.55      a     mean   k4 20.5928   3.4515 0.1734 0.2386 0.5882  False    False
  full  0.55      a     mean   k5 16.0312   2.7591 0.1832 0.2589 0.5793  False    False
  full  0.55      a    first peak  8.2593   1.9769 0.5608 0.9964 0.3679  False    False
  full  0.55      a    first   k2 43.2926   7.0043 0.1643 0.2182 0.5968  False    False
  full  0.55      a    first   k3 28.2441   4.4907 0.1687 0.2202 0.6185  False    False
  full  0.55      a    first   k4 20.5386   3.4740 0.1709 0.2373 0.5820  False    False
  full  0.55      a    first   k5 15.9953   2.7840 0.1806 0.2581 0.5721  False    False
  full  0.55      b     mean peak 12.2348   2.6605 0.0564 0.1014 0.2518  False    False
  full  0.55      b     mean   k2 38.9962   6.2453 0.1638 0.2153 0.5952  False    False
  full  0.55      b     mean   k3 24.8262   3.8201 0.1669 0.2108 0.6277  False    False
  full  0.55      b     mean   k4 17.5440   2.8103 0.1673 0.2200 0.5993  False    False
  full  0.55      b     mean   k5 13.2429   2.1223 0.1757 0.2312 0.6016  False    False
  full  0.55      b    first peak  9.4656   2.1249 0.0433 0.0826 0.1369  False    False
  full  0.55      b    first   k2 29.8525   4.7104 0.1542 0.1994 0.5601  False    False
  full  0.55      b    first   k3 19.0355   2.9033 0.1580 0.1976 0.5963  False    False
  full  0.55      b    first   k4 13.4735   2.1908 0.1596 0.2129 0.5527  False    False
  full  0.55      b    first   k5 10.1860   1.6780 0.1687 0.2281 0.5500  False    False
  full  0.50      a     mean peak  9.1493   2.1920 0.5762 1.0220 0.3713  False    False
  full  0.50      a     mean   k2 47.7980   7.7181 0.1671 0.2214 0.5999  False    False
  full  0.50      a     mean   k3 31.1685   4.9267 0.1714 0.2225 0.6231  False    False
  full  0.50      a     mean   k4 22.6521   3.7967 0.1734 0.2386 0.5882  False    False
  full  0.50      a     mean   k5 17.6344   3.0350 0.1832 0.2589 0.5793  False    False
  full  0.50      a    first peak  9.0853   2.1746 0.5608 0.9964 0.3679  False    False
  full  0.50      a    first   k2 47.6209   7.7047 0.1643 0.2182 0.5968  False    False
  full  0.50      a    first   k3 31.0684   4.9397 0.1687 0.2202 0.6185  False    False
  full  0.50      a    first   k4 22.5924   3.8214 0.1709 0.2373 0.5820  False    False
  full  0.50      a    first   k5 17.5945   3.0625 0.1806 0.2581 0.5721  False    False
  full  0.50      b     mean peak 13.4582   2.9265 0.0564 0.1014 0.2518  False    False
  full  0.50      b     mean   k2 42.8955   6.8697 0.1638 0.2152 0.5952  False    False
  full  0.50      b     mean   k3 27.3088   4.2021 0.1669 0.2108 0.6277  False    False
  full  0.50      b     mean   k4 19.2984   3.0913 0.1673 0.2200 0.5993  False    False
  full  0.50      b     mean   k5 14.5671   2.3345 0.1757 0.2312 0.6016  False    False
  full  0.50      b    first peak 10.4121   2.3374 0.0433 0.0826 0.1369  False    False
  full  0.50      b    first   k2 32.8379   5.1813 0.1541 0.1994 0.5601  False    False
  full  0.50      b    first   k3 20.9389   3.1936 0.1580 0.1976 0.5963  False    False
  full  0.50      b    first   k4 14.8208   2.4099 0.1596 0.2129 0.5527  False    False
  full  0.50      b    first   k5 11.2045   1.8458 0.1686 0.2281 0.5500  False    False

readings with Km within tolerance: 0; with Vmax within: 0; both: 0
Km over all readings 0.0307 to 0.725 uM (median 0.205); Vmax 8.3 to 49.7 %/s; R2 0.01 to 0.73

first reading (tissue, 0.55 s, bleach a, mean baseline, rate to peak): rates [2.7, 0.3, 1.9, 4.9, 16.3, 12.2, 3.6, 3.6] %/s at [0.000714, 0.00714, 0.0714, 0.714, 7.14, 71.4, 142.85, 714.0] uM
  Vmax 8.65 ± 2.43 %/s, Km 0.2617 ± 0.596 uM, R2 0.373
  Spearman correlation of rate with concentration: rho 0.54, p 0.168

variant, onset at frame 7 in every recording (first reading otherwise): rates [2.7, -0.3, 1.1, 4.9, 16.3, 22.7, 3.6, 3.6] %/s; Vmax 11.43 %/s, Km 0.5451 uM, R2 0.373
upper limit of detection, paper's fit: (a) 88% of Vmax at 361.1 uM; (b) tangent within 5% up to 181.3 uM
upper limit of detection, first reading: (a) 88% of Vmax at 1.919 uM; (b) tangent within 5% up to 0.9638 uM
No description has been provided for this image
plotted rates 0.3 to 16.3 %/s; paper's curve up to 281 %/s

Result: not reproduced. No reading gives Km or Vmax within tolerance (0 of 80). Over all readings Km is 0.031 to 0.73 uM, against 49.24 ± 5.84 uM, Vmax 8.3 to 49.7 %/s, against 281.00 ± 7.14 %/s, and R2 0.01 to 0.73, against 0.9811. In the first reading the rates are 0.3 to 16.3 %/s and do not rise steadily with concentration (Spearman rho 0.54, p 0.168); in the data check the one-frame step is 23.1% at 0.000714 uM and 19.8% at 0.714 uM, 41.9% at 7.14 uM and 38.4% at 714 uM, and there is no clear step at 0.00714 and 0.0714 uM. The onset rests on an assumption (the frame before the largest one-frame rise), and the traces printed in the data check show why it is weak: in the six recordings with a step the signal falls by 1.5 to 15.5% over the frames before it (most at 7.14 uM), then jumps within one frame to a plateau, and the 0.000714 uM recording steps by more than the 0.714 uM one. Dips and steps of this kind may come from adding the solution as much as from the sensor, which the files cannot tell. With one onset for every recording (frame 7, the most common), Km is 0.545 uM and Vmax 11.4 %/s, still far from the paper. The upper limit of detection of the first reading's fit is 1.92 uM by (a) and 0.96 uM by (b); the paper's own constants give 361.1 uM by (a), close to its 358.01 uM, and 181.3 uM by (b). The deposit holds one of the three mice and 8 concentrations, so this is not the paper's fit; the rates of this mouse do not follow the paper's curve under any reading run here.

fig4b-lod¶

The lower limit of detection is 228 nM, where two regression lines through the low-concentration data (0.71 nM to 14.28 uM) cross; the theoretical response there from the Michaelis-Menten equation (1.3 %/s, 0.72% per 0.55 s frame) is 8.18 times the background noise of 0.088 ± 0.039%.

Criterion: readings (a) the split of the points into two runs that minimises the summed squared residuals of two lines, on linear concentration, (b) the same on log10 concentration, (c) the split of Fig. 4B(ii) as read from its lines. Reading (c) is not run: it needs the figure, which the entry does not read. The rates are those of fig4b-michaelis-menten, under each of its readings; the deposit has five concentrations up to 14.28 uM (0.000714 to 7.14 uM). Reproduced when the crossing is within 205.2 to 250.8 nM under one reading. Noise: (a) SD of the photobleaching-corrected dF/F of the baseline frames, (b) mean absolute frame-to-frame change of that dF/F; the signal-to-noise ratio is the theoretical response at the crossing (the first reading's fit, times 0.55 s) over the noise.

In [16]:
low = conc <= 14.28
rows = []
for _, f in F.iterrows():
    v = np.array(f.rates)[low]
    for space, xv in (("a linear", conc[low]), ("b log10", np.log10(conc[low]))):
        best = X.two_line_crossing(xv, v)
        if best is None:
            continue
        xc = best[0] if space == "a linear" else 10 ** best[0]
        rows.append({"roi": f.roi, "dt_s": f.dt_s, "bleach": f.bleach, "baseline": f.baseline, "rate": f.rate, "space": space,
                     "split after point": best[1], "crossing_nM": 1000 * xc})
L = pd.DataFrame(rows)
L["ok"] = (L.crossing_nM - 228).abs() <= 22.8
print(f"{len(L)} crossings; within 205.2-250.8 nM: {int(L.ok.sum())}")
print(L.groupby("space").crossing_nM.describe().round(2).to_string())
print(L[(L.roi == "tissue") & (L.dt_s == X.FRAME_S_PAPER)].round(3).to_string(index=False))
first = L[(L.roi == "tissue") & (L.dt_s == X.FRAME_S_PAPER) & (L.bleach == "a") & (L.baseline == "mean") & (L.rate == "peak") & (L.space == "a linear")]
print("\nfirst reading crossing:", first.crossing_nM.round(3).tolist(), "nM")

noise_sd, noise_step = [], []
for c in CAL:
    tr, on = c["tissue"], c["onset"]
    corr, _ = X.bleach_correct(tr, np.arange(on + 1))
    d = X.dff(corr, on, "mean")[:on + 1]
    noise_sd.append(d.std()); noise_step.append(np.abs(np.diff(d)).mean())
noise_sd, noise_step = np.array(noise_sd), np.array(noise_step)
print(f"\nbaseline noise (a) SD of dF/F: mean {noise_sd.mean():.3f} ± {noise_sd.std():.3f}% over 8 recordings ({np.round(noise_sd, 3).tolist()})")
print(f"baseline noise (b) mean |frame-to-frame change|: mean {noise_step.mean():.3f} ± {noise_step.std():.3f}%")
xc = float(first.crossing_nM.iloc[0]) / 1000 if len(first) else np.nan
for label, (vm, k, at) in (("paper's fit at 228 nM", (281.0, 49.24, 0.228)), ("first reading's fit at its crossing", (main.Vmax, main.Km_uM, xc))):
    resp = X.michaelis_menten(at, vm, k) * 0.55
    print(f"{label}: theoretical response {resp:.3f}% per 0.55 s; SNR (a) {resp / noise_sd.mean():.2f}, (b) {resp / noise_step.mean():.2f}")
160 crossings; within 205.2-250.8 nM: 0
          count      mean        std      min     25%     50%    75%         max
space                                                                           
a linear   80.0   1185.70   10890.73 -2603.78 -227.14 -140.10  -4.18    96333.92
b log10    80.0  93163.73  415122.63     0.00    0.01    3.11  23.63  2295855.70
   roi  dt_s bleach baseline rate    space  split after point  crossing_nM    ok
tissue  0.55      a     mean peak a linear                  2        0.977 False
tissue  0.55      a     mean peak  b log10                  3      322.898 False
tissue  0.55      a     mean   k2 a linear                  2        3.923 False
tissue  0.55      a     mean   k2  b log10                  2       24.193 False
tissue  0.55      a     mean   k3 a linear                  3      -93.796 False
tissue  0.55      a     mean   k3  b log10                  2       25.947 False
tissue  0.55      a     mean   k4 a linear                  3     -133.575 False
tissue  0.55      a     mean   k4  b log10                  2       23.399 False
tissue  0.55      a     mean   k5 a linear                  3     -155.696 False
tissue  0.55      a     mean   k5  b log10                  2       23.263 False
tissue  0.55      a    first peak a linear                  2        0.858 False
tissue  0.55      a    first peak  b log10                  3      316.658 False
tissue  0.55      a    first   k2 a linear                  2        3.865 False
tissue  0.55      a    first   k2  b log10                  2       24.168 False
tissue  0.55      a    first   k3 a linear                  3      -98.510 False
tissue  0.55      a    first   k3  b log10                  2       25.909 False
tissue  0.55      a    first   k4 a linear                  3     -137.636 False
tissue  0.55      a    first   k4  b log10                  2       23.454 False
tissue  0.55      a    first   k5 a linear                  3     -157.820 False
tissue  0.55      a    first   k5  b log10                  2       23.060 False
tissue  0.55      b     mean peak a linear                  2        0.335 False
tissue  0.55      b     mean peak  b log10                  2        3.843 False
tissue  0.55      b     mean   k2 a linear                  2        4.171 False
tissue  0.55      b     mean   k2  b log10                  2       21.278 False
tissue  0.55      b     mean   k3 a linear                  3      -81.325 False
tissue  0.55      b     mean   k3  b log10                  2       22.223 False
tissue  0.55      b     mean   k4 a linear                  3     -118.155 False
tissue  0.55      b     mean   k4  b log10                  3        3.617 False
tissue  0.55      b     mean   k5 a linear                  3     -138.449 False
tissue  0.55      b     mean   k5  b log10                  3        0.369 False
tissue  0.55      b    first peak a linear                  2        0.136 False
tissue  0.55      b    first peak  b log10                  2        2.783 False
tissue  0.55      b    first   k2 a linear                  2        4.131 False
tissue  0.55      b    first   k2  b log10                  2       19.428 False
tissue  0.55      b    first   k3 a linear                  3      -81.106 False
tissue  0.55      b    first   k3  b log10                  2       20.253 False
tissue  0.55      b    first   k4 a linear                  3     -117.953 False
tissue  0.55      b    first   k4  b log10                  3        1.395 False
tissue  0.55      b    first   k5 a linear                  3     -138.988 False
tissue  0.55      b    first   k5  b log10                  3        0.063 False

first reading crossing: [0.977] nM

baseline noise (a) SD of dF/F: mean 1.772 ± 2.338% over 8 recordings ([0.433, 0.559, 0.816, 1.476, 0.857, 7.807, 1.932, 0.3])
baseline noise (b) mean |frame-to-frame change|: mean 1.173 ± 0.948%
paper's fit at 228 nM: theoretical response 0.712% per 0.55 s; SNR (a) 0.40, (b) 0.61
first reading's fit at its crossing: theoretical response 0.018% per 0.55 s; SNR (a) 0.01, (b) 0.02

Result: not reproduced. None of the 160 crossings (80 rate readings, on linear and on log concentration) falls within 205.2 to 250.8 nM; their medians are -140 nM on linear concentration (a crossing outside the data) and 3.11 nM on log concentration, and the first reading gives 0.977 nM. The baseline noise is 1.77 ± 2.34% by its SD (a) and 1.17 ± 0.95% by the frame-to-frame change (b), 20 and 13 times the paper's 0.088%; at these levels the paper's own theoretical response at 228 nM (0.712% per 0.55 s) would have a signal-to-noise ratio of 0.40 or 0.61, not 8.18. The fit of this mouse gives 0.018% per frame at its crossing (signal-to-noise 0.01 to 0.02). Reading (c), the split of Fig. 4B(ii), is not run, as the entry reads no figures; with rates that do not rise with concentration below 14.28 uM (fig4b-michaelis-menten) a crossing near 228 nM under it is not expected, but that is not shown here.

fig5b-in-vivo-response¶

In vivo, lingual nerve stimulation (3 V, 10 Hz, 10 ms, 100 pulses) raises nanosensor fluorescence by 3.7% by 15 s with initial rate 0.294 ± 0.116 %/s, recovering to baseline within 2 min (three mice).

Criterion: pHAb dF/F of one ganglion-cell ROI per mouse, photobleaching corrected, averaged over three mice; 3.7% read (a) as the mean dF/F at 15 s after onset, (b) as the peak within 15 s; within tolerance (3.33 to 4.07%, rate 0.178 to 0.410 %/s) under one reading, and back within the pre-stimulus mean plus 2 SD by 120 s.

The deposit does not say which recordings are the three mice of Fig. 5B. It holds two 3 V, 100-pulse recordings of the ACh nanosensor: sub-2 (the 3 V recording of the AQuA mouse) and sub-6 after washout (the untreated recording of the vesamicol pair). Both are used, alone and averaged. Onset is frame 19 (10.45 s, Fig. 6A and 7A). The ROI is open: (i) the stained tissue, (ii) the whole frame, (iii) the tissue without the pixels that saturate at some frame, (iv) each 40 x 40 pixel block (about one cell) inside the tissue, as the distribution the hand-drawn ROI was drawn from. A further ROI subtracts the camera's dark level (data check) from the tissue mean. Photobleaching curve fit to (a) the frames before onset and from 120 s after it, (c) the frames before onset and from 180 s after it, as sub-2 is not back at 120 s (for sub-6 at 0.50 s there are too few frames after 180 s, and the whole trace is used), (b) the whole trace; baseline mean of pre-onset frames or the first frame; frame interval 0.50 s (the files) or 0.55 s (the paper). Rates: (a) a line from onset to the peak within 15 s; (b) the slope over k = 2 to 5 frames, counted from the last frame before the trace leaves baseline (|z| > 5 against frames 0 to 18), since the responses start 6 to 10 frames after frame 19. The k-frame slopes from frame 19 are printed too; they cover baseline frames and are not counted as a match.

In [17]:
ON = X.STIM_FRAME

def response(tr, dt, bl, base):
    n = len(tr)
    after = {"a": 120, "c": 180}.get(bl)
    rec = ON + int(round(after / dt)) if after else n
    idx = np.r_[0:ON, rec:n] if (after and rec < n - 5) else np.arange(n)
    corr, _ = X.bleach_correct(tr, idx)
    d = X.dff(corr, ON, base)
    f15 = ON + int(round(15 / dt))
    pre = d[:ON]
    z = (d - pre.mean()) / pre.std()
    dep = ON + int(np.argmax(np.abs(z[ON:]) > 5)) - 1     # last frame before the trace leaves baseline (|z| > 5)
    out = {"at15": d[f15], "peak15": d[ON + 1:f15 + 1].max(), "rate_peak": X.initial_rate(d, ON, dt, "peak", f15 + 1), "departure": dep}
    for k in (2, 3, 4, 5):
        out[f"rate_k{k}"] = X.initial_rate(d, ON, dt, f"k{k}")
        out[f"rate_dep_k{k}"] = X.initial_rate(d, dep, dt, f"k{k}")
    i120 = min(ON + int(round(120 / dt)), n - 1)
    out["d120"] = d[i120]
    out["thr120"] = pre.mean() + 2 * pre.std()
    return out, d

REC5B = {"sub-2 3V": "right", "sub-6 without drug": "single"}
TR = lambda k, h, roi: V[k][h]["tissue"] - V[k][h]["dark"] if roi == "tissue_minus_dark" else V[k][h][roi]
rows = []
for dt in (X.FRAME_S_FILE, X.FRAME_S_PAPER):
    for bl in ("a", "c", "b"):
        for base in ("mean", "first"):
            for roi in ("tissue", "full", "tissue_unsat", "tissue_minus_dark"):
                per = {k: response(TR(k, h, roi), dt, bl, base)[0] for k, h in REC5B.items()}
                for which in ("sub-2 3V", "sub-6 without drug", "mean of both"):
                    r = per[which] if which != "mean of both" else {q: np.mean([per[k][q] for k in per]) for q in per["sub-2 3V"]}
                    rows.append({"dt": dt, "bleach": bl, "baseline": base, "roi": roi, "recording": which, **{k: round(v, 3) for k, v in r.items()}})
R5 = pd.DataFrame(rows)
rate_cols = ["rate_peak", "rate_dep_k2", "rate_dep_k3", "rate_dep_k4", "rate_dep_k5"]
stim_k = ["rate_k2", "rate_k3", "rate_k4", "rate_k5"]
R5["dff_ok"] = R5[["at15", "peak15"]].apply(lambda s: ((s - 3.7).abs() <= 0.37).any(), axis=1)
R5["rate_ok"] = R5[rate_cols].apply(lambda s: ((s - 0.294).abs() <= 0.116).any(), axis=1)
R5["rate_ok_stim_k"] = R5[stim_k].apply(lambda s: ((s - 0.294).abs() <= 0.116).any(), axis=1)
R5["back_by_120s"] = R5.d120 <= R5.thr120
print(R5.drop(columns=stim_k).to_string(index=False))
print(f"\nbleach readings: a = curve fit to the frames before onset and from 120 s after it; c = from 180 s after it; b = whole trace")
print(f"readings with dF/F within tolerance: {int(R5.dff_ok.sum())} of {len(R5)}; with the rate to the peak or a rate from the departure within: "
      f"{int(R5.rate_ok.sum())}; both: {int((R5.dff_ok & R5.rate_ok).sum())}")
print(f"dF/F at 15 s over all readings: {R5.at15.min():.1f} to {R5.at15.max():.1f}%; peak within 15 s {R5.peak15.min():.1f} to {R5.peak15.max():.1f}%; "
      f"rate to the peak {R5.rate_peak.min():.2f} to {R5.rate_peak.max():.2f} %/s; rates over k frames from the departure "
      f"{R5[rate_cols[1:]].min().min():.2f} to {R5[rate_cols[1:]].max().max():.2f} %/s")
print(f"departure frames (last frame before |z| > 5): sub-2 {sorted(set(R5[R5.recording == 'sub-2 3V'].departure.astype(int)))}, "
      f"sub-6 {sorted(set(R5[R5.recording == 'sub-6 without drug'].departure.astype(int)))}")
print(f"rates over k frames from frame 19 (stimulation onset), which cover baseline frames before the departure: {R5[stim_k].min().min():.2f} to "
      f"{R5[stim_k].max().max():.2f} %/s; readings where one is within 0.178-0.410 %/s: {int(R5.rate_ok_stim_k.sum())} (not counted as a match)")
for which in ("sub-2 3V", "sub-6 without drug"):
    s_ = R5[R5.recording == which]
    print(f"{which}: dF/F at 120 s {s_.d120.min():.1f} to {s_.d120.max():.1f}%; back within pre-stimulus mean + 2 SD in {int(s_.back_by_120s.sum())} of {len(s_)} readings")
for roi in ("tissue", "tissue_minus_dark"):
    s_ = R5[(R5.roi == roi) & (R5.recording == "mean of both")]
    print(f"ROI {roi}, mean of both: dF/F at 15 s {s_.at15.min():.1f} to {s_.at15.max():.1f}%")

print("\nPer 40 x 40 block (dt 0.50 s, bleach a, mean baseline):")
for k, h in REC5B.items():
    B = pd.DataFrame([response(b, X.FRAME_S_FILE, "a", "mean")[0] for b in V[k][h]["blocks"]])
    ok = ((B.at15 - 3.7).abs() <= 0.37) | ((B.peak15 - 3.7).abs() <= 0.37)
    okr = B[rate_cols].apply(lambda s: ((s - 0.294).abs() <= 0.116).any(), axis=1)
    print(f"  {k}: {len(B)} blocks; dF/F at 15 s {B.at15.min():.1f} to {B.at15.max():.1f}% (median {B.at15.median():.1f}); "
          f"rate to peak {B.rate_peak.min():.2f} to {B.rate_peak.max():.2f} %/s; blocks with dF/F within tolerance {int(ok.sum())}, "
          f"with a rate within {int(okr.sum())}, both {int((ok & okr).sum())}")

fig, ax = plt.subplots(figsize=(8, 3.5))
for k, h in REC5B.items():
    _, d = response(V[k][h]["tissue"], X.FRAME_S_FILE, "a", "mean")
    ax.plot((np.arange(len(d)) - ON) * X.FRAME_S_FILE, d, label=f"{k} (tissue)")
ax.axvline(0, color="k", lw=0.8); ax.axhline(3.7, color="grey", ls="--", lw=0.8, label="3.7%")
ax.set_xlabel("time from onset (s, 0.50 s frames)"); ax.set_ylabel("dF/F (%)"); ax.legend(fontsize=8)
plt.show()
  dt bleach baseline               roi          recording   at15  peak15  rate_peak  departure  rate_dep_k2  rate_dep_k3  rate_dep_k4  rate_dep_k5   d120  thr120  dff_ok  rate_ok  rate_ok_stim_k  back_by_120s
0.50      a     mean            tissue           sub-2 3V 25.924  25.924      1.885       27.0        0.774        0.897        1.092        1.196 11.428   0.534   False    False           False         False
0.50      a     mean            tissue sub-6 without drug 17.896  18.449      1.702       29.0       -0.766        1.817        2.390        2.432  1.489   3.472   False    False           False          True
0.50      a     mean            tissue       mean of both 21.910  22.186      1.794       28.0        0.004        1.357        1.741        1.814  6.458   2.003   False    False            True         False
0.50      a     mean              full           sub-2 3V 28.678  28.678      2.159       26.0        0.960        1.011        1.159        1.326 11.955   0.505   False    False           False         False
0.50      a     mean              full sub-6 without drug 21.782  22.259      1.950       27.0        2.838        2.833        2.091        2.460  2.021   2.204   False    False           False          True
0.50      a     mean              full       mean of both 25.230  25.469      2.054       26.5        1.899        1.922        1.625        1.893  6.988   1.355   False    False            True         False
0.50      a     mean      tissue_unsat           sub-2 3V 26.689  26.689      1.895       27.0        0.683        0.833        0.992        1.094 11.790   0.543   False    False           False         False
0.50      a     mean      tissue_unsat sub-6 without drug 33.166  35.320      3.211       26.0        3.703        4.014        4.201        3.628  1.059   1.935   False    False            True          True
0.50      a     mean      tissue_unsat       mean of both 29.927  31.004      2.553       26.5        2.193        2.423        2.596        2.361  6.424   1.239   False    False            True         False
0.50      a     mean tissue_minus_dark           sub-2 3V 27.067  27.067      1.968       27.0        0.808        0.937        1.140        1.249 11.932   0.558   False    False           False         False
0.50      a     mean tissue_minus_dark sub-6 without drug 18.948  19.534      1.802       29.0       -0.811        1.923        2.530        2.575  1.581   3.674   False    False           False          True
0.50      a     mean tissue_minus_dark       mean of both 23.008  23.300      1.885       28.0       -0.001        1.430        1.835        1.912  6.756   2.116   False    False            True         False
0.50      a    first            tissue           sub-2 3V 26.566  26.566      1.895       27.0        0.778        0.902        1.097        1.202 11.996   1.047   False    False           False         False
0.50      a    first            tissue sub-6 without drug 17.083  17.632      1.690       29.0       -0.761        1.804        2.373        2.415  0.789   2.758   False    False           False          True
0.50      a    first            tissue       mean of both 21.824  22.099      1.793       28.0        0.009        1.353        1.735        1.809  6.393   1.903   False    False            True         False
0.50      a    first              full           sub-2 3V 29.297  29.297      2.169       26.0        0.964        1.016        1.165        1.333 12.494   0.989   False    False           False         False
0.50      a    first              full sub-6 without drug 20.966  21.440      1.936       27.0        2.819        2.814        2.077        2.443  1.338   1.520   False    False           False          True
0.50      a    first              full       mean of both 25.131  25.369      2.053       26.5        1.892        1.915        1.621        1.888  6.916   1.254   False    False            True         False
0.50      a    first      tissue_unsat           sub-2 3V 27.307  27.307      1.905       27.0        0.686        0.837        0.996        1.099 12.335   1.033   False    False           False         False
0.50      a    first      tissue_unsat sub-6 without drug 32.606  34.751      3.197       26.0        3.687        3.997        4.184        3.612  0.634   1.506   False    False            True          True
0.50      a    first      tissue_unsat       mean of both 29.956  31.029      2.551       26.5        2.187        2.417        2.590        2.356  6.484   1.270   False    False            True         False
0.50      a    first tissue_minus_dark           sub-2 3V 27.744  27.744      1.979       27.0        0.813        0.942        1.146        1.255 12.529   1.094   False    False           False         False
0.50      a    first tissue_minus_dark sub-6 without drug 18.081  18.662      1.789       29.0       -0.805        1.909        2.512        2.556  0.840   2.918   False    False           False          True
0.50      a    first tissue_minus_dark       mean of both 22.912  23.203      1.884       28.0        0.004        1.425        1.829        1.906  6.684   2.006   False    False            True         False
0.50      c     mean            tissue           sub-2 3V 25.589  25.589      1.867       27.0        0.760        0.882        1.077        1.181  9.439   0.466   False    False           False         False
0.50      c     mean            tissue sub-6 without drug 19.001  19.475      1.762       29.0       -0.719        1.877        2.454        2.497  8.105   3.388   False    False           False         False
0.50      c     mean            tissue       mean of both 22.295  22.532      1.815       28.0        0.020        1.380        1.765        1.839  8.772   1.927   False    False            True         False
0.50      c     mean              full           sub-2 3V 28.237  28.237      2.135       26.0        0.941        0.992        1.140        1.306  9.475   0.418   False    False           False         False
0.50      c     mean              full sub-6 without drug 23.168  23.580      2.026       27.0        2.914        2.909        2.164        2.535 10.177   2.097   False    False           False         False
0.50      c     mean              full       mean of both 25.702  25.908      2.080       26.5        1.927        1.951        1.652        1.921  9.826   1.257   False    False            True         False
0.50      c     mean      tissue_unsat           sub-2 3V 26.315  26.315      1.876       27.0        0.667        0.816        0.975        1.077  9.607   0.467   False    False           False         False
0.50      c     mean      tissue_unsat sub-6 without drug 35.233  37.259      3.331       25.0        3.545        3.766        3.991        4.165 12.191   1.716   False    False           False         False
0.50      c     mean      tissue_unsat       mean of both 30.774  31.787      2.603       26.0        2.106        2.291        2.483        2.621 10.899   1.091   False    False            True         False
0.50      c     mean tissue_minus_dark           sub-2 3V 26.715  26.715      1.949       27.0        0.793        0.921        1.124        1.233  9.849   0.486   False    False           False         False
0.50      c     mean tissue_minus_dark sub-6 without drug 20.119  20.620      1.866       29.0       -0.762        1.987        2.598        2.644  8.574   3.586   False    False           False         False
0.50      c     mean tissue_minus_dark       mean of both 23.417  23.668      1.908       28.0        0.016        1.454        1.861        1.938  9.211   2.036   False    False            True         False
0.50      c    first            tissue           sub-2 3V 26.155  26.155      1.876       27.0        0.763        0.886        1.082        1.186  9.932   0.918   False    False           False         False
0.50      c    first            tissue sub-6 without drug 18.424  18.896      1.754       29.0       -0.716        1.868        2.442        2.485  7.580   2.886   False    False           False         False
0.50      c    first            tissue       mean of both 22.289  22.525      1.815       28.0        0.024        1.377        1.762        1.835  8.756   1.902   False    False            True         False
0.50      c    first              full           sub-2 3V 28.754  28.754      2.143       26.0        0.944        0.996        1.144        1.312  9.917   0.823   False    False           False         False
0.50      c    first              full sub-6 without drug 22.649  23.059      2.017       27.0        2.901        2.897        2.154        2.524  9.713   1.667   False    False           False         False
0.50      c    first              full       mean of both 25.701  25.907      2.080       26.5        1.923        1.947        1.649        1.918  9.815   1.245   False    False            True         False
0.50      c    first      tissue_unsat           sub-2 3V 26.846  26.846      1.883       27.0        0.670        0.820        0.979        1.082 10.068   0.890   False    False           False         False
0.50      c    first      tissue_unsat sub-6 without drug 35.122  37.147      3.328       25.0        3.542        3.763        3.987        4.162 12.099   1.633   False    False           False         False
0.50      c    first      tissue_unsat       mean of both 30.984  31.997      2.606       26.0        2.106        2.291        2.483        2.622 11.084   1.261   False    False            True         False
0.50      c    first tissue_minus_dark           sub-2 3V 27.311  27.311      1.959       27.0        0.797        0.926        1.130        1.238 10.366   0.959   False    False           False         False
0.50      c    first tissue_minus_dark sub-6 without drug 19.500  19.999      1.857       29.0       -0.758        1.977        2.585        2.630  8.015   3.053   False    False           False         False
0.50      c    first tissue_minus_dark       mean of both 23.406  23.655      1.908       28.0        0.020        1.451        1.857        1.934  9.190   2.006   False    False            True         False
0.50      b     mean            tissue           sub-2 3V 26.178  26.178      1.899       27.0        0.785        0.908        1.103        1.207 14.262   0.581   False    False           False         False
0.50      b     mean            tissue sub-6 without drug 19.001  19.475      1.762       29.0       -0.719        1.877        2.454        2.497  8.105   3.388   False    False           False         False
0.50      b     mean            tissue       mean of both 22.589  22.826      1.831       28.0        0.033        1.393        1.779        1.852 11.183   1.984   False    False            True         False
0.50      b     mean              full           sub-2 3V 28.919  28.919      2.172       26.0        0.970        1.022        1.170        1.337 14.668   0.548   False    False           False         False
0.50      b     mean              full sub-6 without drug 23.168  23.580      2.026       27.0        2.914        2.909        2.164        2.535 10.177   2.097   False    False           False         False
0.50      b     mean              full       mean of both 26.044  26.250      2.099       26.5        1.942        1.965        1.667        1.936 12.423   1.323   False    False            True         False
0.50      b     mean      tissue_unsat           sub-2 3V 26.930  26.930      1.909       28.0        0.873        1.097        1.203        1.378 14.536   0.587   False    False           False         False
0.50      b     mean      tissue_unsat sub-6 without drug 35.233  37.259      3.331       25.0        3.545        3.766        3.991        4.165 12.191   1.716   False    False           False         False
0.50      b     mean      tissue_unsat       mean of both 31.081  32.095      2.620       26.5        2.209        2.431        2.597        2.771 13.364   1.151   False    False            True         False
0.50      b     mean tissue_minus_dark           sub-2 3V 27.334  27.334      1.983       27.0        0.820        0.948        1.152        1.261 14.893   0.606   False    False           False         False
0.50      b     mean tissue_minus_dark sub-6 without drug 20.119  20.620      1.866       29.0       -0.762        1.987        2.598        2.644  8.574   3.586   False    False           False         False
0.50      b     mean tissue_minus_dark       mean of both 23.726  23.977      1.925       28.0        0.029        1.468        1.875        1.952 11.734   2.096   False    False            True         False
0.50      b    first            tissue           sub-2 3V 26.872  26.872      1.910       27.0        0.789        0.913        1.109        1.214 14.891   1.134   False    False           False         False
0.50      b    first            tissue sub-6 without drug 18.424  18.896      1.754       29.0       -0.716        1.868        2.442        2.485  7.580   2.886   False    False           False         False
0.50      b    first            tissue       mean of both 22.648  22.884      1.832       28.0        0.037        1.390        1.776        1.849 11.236   2.010   False    False            True         False
0.50      b    first              full           sub-2 3V 29.586  29.586      2.183       26.0        0.975        1.027        1.176        1.344 15.262   1.069   False    False           False         False
0.50      b    first              full sub-6 without drug 22.649  23.059      2.017       27.0        2.901        2.897        2.154        2.524  9.713   1.667   False    False           False         False
0.50      b    first              full       mean of both 26.118  26.323      2.100       26.5        1.938        1.962        1.665        1.934 12.488   1.368   False    False            True         False
0.50      b    first      tissue_unsat           sub-2 3V 27.596  27.596      1.919       28.0        0.877        1.103        1.209        1.385 15.137   1.115   False    False           False         False
0.50      b    first      tissue_unsat sub-6 without drug 35.122  37.147      3.328       25.0        3.542        3.763        3.987        4.162 12.099   1.633   False    False           False         False
0.50      b    first      tissue_unsat       mean of both 31.359  32.372      2.623       26.5        2.210        2.433        2.598        2.773 13.618   1.374   False    False            True         False
0.50      b    first tissue_minus_dark           sub-2 3V 28.065  28.065      1.994       27.0        0.824        0.954        1.159        1.268 15.553   1.184   False    False           False         False
0.50      b    first tissue_minus_dark sub-6 without drug 19.500  19.999      1.857       29.0       -0.758        1.977        2.585        2.630  8.015   3.053   False    False           False         False
0.50      b    first tissue_minus_dark       mean of both 23.783  24.032      1.926       28.0        0.033        1.465        1.872        1.949 11.784   2.118   False    False            True         False
0.55      a     mean            tissue           sub-2 3V 23.349  23.349      1.591       27.0        0.704        0.816        0.993        1.087 12.804   0.535   False    False           False         False
0.55      a     mean            tissue sub-6 without drug 18.460  18.460      1.548       29.0       -0.696        1.652        2.173        2.212  1.843   3.471   False    False           False          True
0.55      a     mean            tissue       mean of both 20.905  20.905      1.569       28.0        0.004        1.234        1.583        1.650  7.323   2.003   False    False            True         False
0.55      a     mean              full           sub-2 3V 26.740  26.740      1.868       26.0        0.873        0.920        1.054        1.206 13.357   0.506   False    False           False         False
0.55      a     mean              full sub-6 without drug 22.274  22.274      1.808       27.0        2.581        2.577        1.902        2.237  2.510   2.203   False    False           False         False
0.55      a     mean              full       mean of both 24.507  24.507      1.838       26.5        1.727        1.748        1.478        1.721  7.933   1.355   False    False            True         False
0.55      a     mean      tissue_unsat           sub-2 3V 23.676  23.676      1.569       27.0        0.621        0.757        0.902        0.995 13.155   0.544   False    False           False         False
0.55      a     mean      tissue_unsat sub-6 without drug 35.329  35.329      2.919       26.0        3.367        3.649        3.820        3.298  1.869   1.934   False    False            True          True
0.55      a     mean      tissue_unsat       mean of both 29.503  29.503      2.244       26.5        1.994        2.203        2.361        2.147  7.512   1.239   False    False           False         False
0.55      a     mean tissue_minus_dark           sub-2 3V 24.379  24.379      1.661       27.0        0.735        0.852        1.037        1.135 13.369   0.559   False    False           False         False
0.55      a     mean tissue_minus_dark sub-6 without drug 19.545  19.545      1.639       29.0       -0.736        1.749        2.301        2.341  1.956   3.673   False    False           False          True
0.55      a     mean tissue_minus_dark       mean of both 21.962  21.962      1.650       28.0       -0.001        1.300        1.669        1.738  7.662   2.116   False    False            True         False
0.55      a    first            tissue           sub-2 3V 23.980  23.980      1.599       27.0        0.708        0.820        0.998        1.093 13.381   1.050   False    False           False         False
0.55      a    first            tissue sub-6 without drug 17.646  17.646      1.537       29.0       -0.691        1.641        2.158        2.196  1.143   2.760   False    False           False          True
0.55      a    first            tissue       mean of both 20.813  20.813      1.568       28.0        0.008        1.230        1.578        1.645  7.262   1.905   False    False            True         False
0.55      a    first              full           sub-2 3V 27.351  27.351      1.877       26.0        0.877        0.924        1.059        1.212 13.903   0.990   False    False           False         False
0.55      a    first              full sub-6 without drug 21.459  21.459      1.796       27.0        2.564        2.559        1.889        2.222  1.826   1.522   False    False           False         False
0.55      a    first              full       mean of both 24.405  24.405      1.836       26.5        1.720        1.742        1.474        1.717  7.865   1.256   False    False            True         False
0.55      a    first      tissue_unsat           sub-2 3V 24.280  24.280      1.576       27.0        0.624        0.761        0.906        1.000 13.708   1.035   False    False           False         False
0.55      a    first      tissue_unsat sub-6 without drug 34.763  34.763      2.907       26.0        3.353        3.634        3.804        3.285  1.442   1.507   False    False            True          True
0.55      a    first      tissue_unsat       mean of both 29.521  29.521      2.242       26.5        1.988        2.197        2.355        2.142  7.575   1.271   False    False           False         False
0.55      a    first tissue_minus_dark           sub-2 3V 25.044  25.044      1.670       27.0        0.739        0.856        1.042        1.141 13.974   1.096   False    False           False         False
0.55      a    first tissue_minus_dark sub-6 without drug 18.676  18.676      1.627       29.0       -0.731        1.736        2.284        2.324  1.214   2.920   False    False           False          True
0.55      a    first tissue_minus_dark       mean of both 21.860  21.860      1.648       28.0        0.004        1.296        1.663        1.733  7.594   2.008   False    False            True         False
0.55      c     mean            tissue           sub-2 3V 23.044  23.044      1.575       27.0        0.691        0.802        0.979        1.073 10.873   0.467   False    False           False         False
0.55      c     mean            tissue sub-6 without drug 22.253  22.253      1.734       27.0        2.872        2.812        1.478        2.104  5.075   3.234   False    False            True         False
0.55      c     mean            tissue       mean of both 22.649  22.649      1.655       27.0        1.782        1.807        1.229        1.589  7.974   1.851   False    False           False         False
0.55      c     mean              full           sub-2 3V 26.338  26.338      1.847       26.0        0.855        0.902        1.036        1.188 10.993   0.419   False    False           False         False
0.55      c     mean              full sub-6 without drug 25.083  25.083      1.950       26.0        2.087        2.324        2.458        2.046  5.457   2.010   False    False            True         False
0.55      c     mean              full       mean of both 25.711  25.711      1.898       26.0        1.471        1.613        1.747        1.617  8.225   1.215   False    False            True         False
0.55      c     mean      tissue_unsat           sub-2 3V 23.337  23.337      1.551       27.0        0.607        0.742        0.887        0.980 11.053   0.468   False    False           False         False
0.55      c     mean      tissue_unsat sub-6 without drug 39.378  39.378      3.136       25.0        3.333        3.536        3.743        3.903  5.741   1.544   False    False           False         False
0.55      c     mean      tissue_unsat       mean of both 31.358  31.358      2.344       26.0        1.970        2.139        2.315        2.441  8.397   1.006   False    False            True         False
0.55      c     mean tissue_minus_dark           sub-2 3V 24.058  24.058      1.645       27.0        0.721        0.838        1.022        1.121 11.346   0.487   False    False           False         False
0.55      c     mean tissue_minus_dark sub-6 without drug 23.606  23.606      1.840       27.0        3.045        2.981        1.568        2.231  5.400   3.424   False    False            True         False
0.55      c     mean tissue_minus_dark       mean of both 23.832  23.832      1.742       27.0        1.883        1.909        1.295        1.676  8.373   1.956   False    False           False         False
0.55      c    first            tissue           sub-2 3V 23.599  23.599      1.582       27.0        0.694        0.806        0.984        1.078 11.374   0.920   False    False           False         False
0.55      c    first            tissue sub-6 without drug 22.776  22.776      1.742       27.0        2.884        2.824        1.485        2.113  5.524   3.676   False    False            True         False
0.55      c    first            tissue       mean of both 23.188  23.188      1.662       27.0        1.789        1.815        1.234        1.596  8.449   2.298   False    False           False         False
0.55      c    first              full           sub-2 3V 26.849  26.849      1.854       26.0        0.859        0.906        1.040        1.193 11.441   0.825   False    False           False         False
0.55      c    first              full sub-6 without drug 25.180  25.180      1.951       26.0        2.088        2.326        2.460        2.048  5.538   2.088   False    False            True         False
0.55      c    first              full       mean of both 26.014  26.014      1.903       26.0        1.474        1.616        1.750        1.620  8.490   1.457   False    False            True         False
0.55      c    first      tissue_unsat           sub-2 3V 23.857  23.857      1.558       27.0        0.609        0.746        0.890        0.984 11.521   0.892   False    False           False         False
0.55      c    first      tissue_unsat sub-6 without drug 40.130  40.130      3.153       25.0        3.351        3.555        3.763        3.924  6.311   2.092   False    False           False         False
0.55      c    first      tissue_unsat       mean of both 31.993  31.993      2.355       26.0        1.980        2.150        2.327        2.454  8.916   1.492   False    False            True         False
0.55      c    first tissue_minus_dark           sub-2 3V 24.643  24.643      1.652       27.0        0.725        0.842        1.027        1.126 11.871   0.961   False    False           False         False
0.55      c    first tissue_minus_dark sub-6 without drug 24.165  24.165      1.848       27.0        3.058        2.994        1.575        2.241  5.877   3.892   False    False            True         False
0.55      c    first tissue_minus_dark       mean of both 24.404  24.404      1.750       27.0        1.892        1.918        1.301        1.684  8.874   2.427   False    False           False         False
0.55      b     mean            tissue           sub-2 3V 23.570  23.570      1.603       27.0        0.714        0.826        1.003        1.098 15.068   0.581   False    False           False         False
0.55      b     mean            tissue sub-6 without drug 19.475  19.475      1.602       29.0       -0.654        1.706        2.231        2.270  7.764   3.388   False    False           False         False
0.55      b     mean            tissue       mean of both 21.523  21.523      1.603       28.0        0.030        1.266        1.617        1.684 11.416   1.984   False    False            True         False
0.55      b     mean              full           sub-2 3V 26.952  26.952      1.879       26.0        0.882        0.929        1.063        1.215 15.536   0.548   False    False           False         False
0.55      b     mean              full sub-6 without drug 23.544  23.544      1.876       27.0        2.649        2.645        1.967        2.304  9.796   2.097   False    False           False         False
0.55      b     mean              full       mean of both 25.248  25.248      1.878       26.5        1.765        1.787        1.515        1.760 12.666   1.323   False    False            True         False
0.55      b     mean      tissue_unsat           sub-2 3V 23.885  23.885      1.580       28.0        0.793        0.997        1.093        1.252 15.346   0.587   False    False           False         False
0.55      b     mean      tissue_unsat sub-6 without drug 37.259  37.259      3.028       25.0        3.222        3.424        3.628        3.786 11.905   1.716   False    False            True         False
0.55      b     mean      tissue_unsat       mean of both 30.572  30.572      2.304       26.5        2.008        2.210        2.360        2.519 13.625   1.151   False    False            True         False
0.55      b     mean tissue_minus_dark           sub-2 3V 24.611  24.611      1.674       27.0        0.745        0.862        1.047        1.146 15.735   0.606   False    False           False         False
0.55      b     mean tissue_minus_dark sub-6 without drug 20.620  20.620      1.697       29.0       -0.692        1.807        2.362        2.404  8.211   3.586   False    False           False         False
0.55      b     mean tissue_minus_dark       mean of both 22.615  22.615      1.685       28.0        0.026        1.334        1.705        1.775 11.973   2.096   False    False            True         False
0.55      b    first            tissue           sub-2 3V 24.250  24.250      1.612       27.0        0.718        0.830        1.008        1.104 15.701   1.134   False    False           False         False
0.55      b    first            tissue sub-6 without drug 18.896  18.896      1.594       29.0       -0.651        1.698        2.220        2.259  7.241   2.886   False    False           False         False
0.55      b    first            tissue       mean of both 21.573  21.573      1.603       28.0        0.033        1.264        1.614        1.681 11.471   2.010   False    False            True         False
0.55      b    first              full           sub-2 3V 27.610  27.610      1.889       26.0        0.886        0.934        1.069        1.222 16.135   1.069   False    False           False         False
0.55      b    first              full sub-6 without drug 23.023  23.023      1.868       27.0        2.638        2.634        1.959        2.295  9.333   1.667   False    False           False         False
0.55      b    first              full       mean of both 25.316  25.316      1.879       26.5        1.762        1.784        1.514        1.758 12.734   1.368   False    False            True         False
0.55      b    first      tissue_unsat           sub-2 3V 24.535  24.535      1.588       28.0        0.798        1.002        1.099        1.259 15.951   1.115   False    False           False         False
0.55      b    first      tissue_unsat sub-6 without drug 37.147  37.147      3.025       25.0        3.220        3.421        3.625        3.783 11.814   1.633   False    False            True         False
0.55      b    first      tissue_unsat       mean of both 30.841  30.841      2.307       26.5        2.009        2.212        2.362        2.521 13.883   1.374   False    False            True         False
0.55      b    first tissue_minus_dark           sub-2 3V 25.326  25.326      1.683       27.0        0.749        0.867        1.053        1.153 16.400   1.184   False    False           False         False
0.55      b    first tissue_minus_dark sub-6 without drug 19.999  19.999      1.688       29.0       -0.689        1.797        2.350        2.391  7.654   3.053   False    False           False         False
0.55      b    first tissue_minus_dark       mean of both 22.663  22.663      1.686       28.0        0.030        1.332        1.702        1.772 12.027   2.118   False    False            True         False

bleach readings: a = curve fit to the frames before onset and from 120 s after it; c = from 180 s after it; b = whole trace
readings with dF/F within tolerance: 0 of 144; with the rate to the peak or a rate from the departure within: 0; both: 0
dF/F at 15 s over all readings: 17.1 to 40.1%; peak within 15 s 17.6 to 40.1%; rate to the peak 1.54 to 3.33 %/s; rates over k frames from the departure -0.81 to 4.20 %/s
departure frames (last frame before |z| > 5): sub-2 [26, 27, 28], sub-6 [25, 26, 27, 29]
rates over k frames from frame 19 (stimulation onset), which cover baseline frames before the departure: -7.46 to 0.83 %/s; readings where one is within 0.178-0.410 %/s: 54 (not counted as a match)
sub-2 3V: dF/F at 120 s 9.4 to 16.4%; back within pre-stimulus mean + 2 SD in 0 of 48 readings
sub-6 without drug: dF/F at 120 s 0.6 to 12.2%; back within pre-stimulus mean + 2 SD in 14 of 48 readings
ROI tissue, mean of both: dF/F at 15 s 20.8 to 23.2%
ROI tissue_minus_dark, mean of both: dF/F at 15 s 21.9 to 24.4%

Per 40 x 40 block (dt 0.50 s, bleach a, mean baseline):
  sub-2 3V: 21 blocks; dF/F at 15 s 11.3 to 53.6% (median 25.9); rate to peak 0.65 to 4.32 %/s; blocks with dF/F within tolerance 0, with a rate within 0, both 0
  sub-6 without drug: 13 blocks; dF/F at 15 s 0.3 to 28.4% (median 17.6); rate to peak 0.03 to 2.82 %/s; blocks with dF/F within tolerance 1, with a rate within 1, both 1
No description has been provided for this image

Result: not reproduced. Under every reading the pHAb dF/F 15 s after onset is far above 3.7%: 17.1 to 40.1% (0 of 144 readings within 3.33 to 4.07%), 23.0 to 29.6% in sub-2 and 17.1 to 40.1% in sub-6 after washout. Subtracting the camera's dark level raises it slightly (mean of both, tissue: 20.8 to 23.2% without, 21.9 to 24.4% with). Single 40 x 40 pixel blocks, about one cell each, give 11.3 to 53.6% in sub-2 and 0.3 to 28.4% in sub-6; one block of sub-6 is within tolerance in both dF/F and rate. The rate to the peak is 1.54 to 3.33 %/s, and the rates over 2 to 5 frames from the frame where each trace leaves baseline (frames 25 to 29) are -0.81 to 4.20 %/s; none of the readings has a rate within 0.178 to 0.410 %/s by these measures. Rates over 2 to 5 frames from frame 19 fall within it in 54 readings, but those frames lie before the response, so they measure baseline and are not counted. At 120 s after onset sub-2 is still 9.4 to 16.4% above baseline under every bleaching fit, including the fit from 180 s; sub-6 is back within the pre-stimulus mean plus 2 SD in 14 of 48 readings, all with the fit from 120 s. The deposit does not say which recordings are the three mice of Fig. 5B; on the two 3 V recordings it holds, the response is about 5 to 10 times the paper's.

fig6-vesamicol¶

Vesamicol cuts the nanosensor response to 3 V stimulation; in the example the response with the drug is 17% of that after washout, and over four experiments the reduction averages 76.59 ± 11.34%, significant in each by a paired t test (P < 0.01).

Criterion: peak pHAb dF/F with vesamicol and after washout, same ROI and stimulation, normalised to the maximum; reduction is 1 minus the ratio, averaged over four experiments; tests (a) one paired t test over the four experiments' peaks, (b) a paired t test within each experiment over matched time points from onset to the end of the response. The deposit holds one experiment (sub-6), taken as the example of Fig. 6A-B. Peak: the maximum dF/F from onset (frame 19, Fig. 6A "Sti starts 10.45 s") to 120 s after it. End of the response for (b): 120 s after onset (the paper's "within 2 min"). ROI open: stained tissue, whole frame, the tissue without pixels that saturate at some frame, and the same 40 x 40 blocks in both files (the two files are one field; their shift is printed). Photobleaching and baseline readings as in fig5b. sub-6 has single frames that drop below their neighbours (counted below); a 3-frame median filter is shown as a variant. The frames of test (b) are not independent (each follows the last), so the test is also run on the means of non-overlapping 10 s bins, as a variant.

In [18]:
from skimage.registration import phase_cross_correlation
print("shift between the mean images of the two sub-6 files:", phase_cross_correlation(V["sub-6 with drug"]["single"]["mean_img"], V["sub-6 without drug"]["single"]["mean_img"])[0])
for k in ("sub-6 with drug", "sub-6 without drug"):
    tr = V[k]["single"]["tissue"]
    dev = tr - ndi.median_filter(tr, 5)
    print(f"{k}: frames more than 5 SD below their 5-frame median: {int((dev < -5 * np.std(dev)).sum())} of {len(tr)}")

def peak_and_trace(tr, dt, bl, base, med=False):
    if med:
        tr = ndi.median_filter(tr, 3)
    n = len(tr); rec = ON + int(round(120 / dt))
    idx = np.r_[0:ON, rec:n] if (bl == "a" and rec < n - 5) else np.arange(n)
    corr, _ = X.bleach_correct(tr, idx)
    d = X.dff(corr, ON, base)
    end = min(rec, n - 1)
    return d[ON:end + 1].max(), d[ON:end + 1]

rows = []
for dt in (X.FRAME_S_FILE, X.FRAME_S_PAPER):
    for bl in ("a", "b"):
        for base in ("mean", "first"):
            for roi in ("tissue", "full", "tissue_unsat"):
                for med in (False, True):
                    pw, dw = peak_and_trace(V["sub-6 with drug"]["single"][roi], dt, bl, base, med)
                    po, do = peak_and_trace(V["sub-6 without drug"]["single"][roi], dt, bl, base, med)
                    m = min(len(dw), len(do))
                    tt = stats.ttest_rel(dw[:m], do[:m])
                    nb_ = int(round(10 / dt)); nbins = m // nb_   # variant: means of non-overlapping 10 s bins, fewer and less dependent samples
                    tb = stats.ttest_rel(dw[:nbins * nb_].reshape(nbins, nb_).mean(1), do[:nbins * nb_].reshape(nbins, nb_).mean(1))
                    rows.append({"dt": dt, "bleach": bl, "baseline": base, "roi": roi, "median3": med, "peak_with": round(pw, 2), "peak_without": round(po, 2),
                                 "ratio_%": round(100 * pw / po, 1), "reduction_%": round(100 * (1 - pw / po), 1), "paired_t": round(tt.statistic, 2), "p": tt.pvalue, "n_frames": m,
                                 "t_10s_bins": round(tb.statistic, 2), "p_10s_bins": tb.pvalue, "n_bins": nbins})
R6 = pd.DataFrame(rows)
R6["ratio_ok"] = (R6["ratio_%"] - 17).abs() <= 1.7
R6["reduction_ok"] = (R6["reduction_%"] - 76.59).abs() <= 11.34
print(R6.to_string(index=False))
print(f"\nratio within 15.3-18.7%: {int(R6.ratio_ok.sum())} of {len(R6)}; reduction within 65.25-87.93%: {int(R6.reduction_ok.sum())}; "
      f"ratio range {R6['ratio_%'].min():.1f} to {R6['ratio_%'].max():.1f}%; largest p of the within-experiment t test {R6.p.max():.2g}")
print(f"paired t over the means of 10 s bins ({R6.n_bins.min()} to {R6.n_bins.max()} bins): p {R6.p_10s_bins.min():.2g} to {R6.p_10s_bins.max():.2g}; "
      f"below 0.01 in {int((R6.p_10s_bins < 0.01).sum())} of {len(R6)} readings")

print("\nPer 40 x 40 block at the same positions (dt 0.50 s, bleach a, mean baseline):")
ow = V["sub-6 with drug"]["single"]["origins"]; oo = V["sub-6 without drug"]["single"]["origins"]
common = [o for o in ow if o in oo]
br = []
for o in common:
    pw, _ = peak_and_trace(V["sub-6 with drug"]["single"]["blocks"][ow.index(o)], X.FRAME_S_FILE, "a", "mean")
    po, _ = peak_and_trace(V["sub-6 without drug"]["single"]["blocks"][oo.index(o)], X.FRAME_S_FILE, "a", "mean")
    br.append({"block": o, "peak_with": round(pw, 2), "peak_without": round(po, 2), "ratio_%": round(100 * pw / po, 1)})
B6 = pd.DataFrame(br)
print(B6.to_string(index=False))
print(f"{len(B6)} blocks; ratio {B6['ratio_%'].min():.1f} to {B6['ratio_%'].max():.1f}% (median {B6['ratio_%'].median():.1f}); within 15.3-18.7%: {int(((B6['ratio_%'] - 17).abs() <= 1.7).sum())}")
print("Test (a), a paired t test over four experiments, cannot be computed: the deposit holds one experiment.")

fig, ax = plt.subplots(figsize=(8, 3.5))
for k in ("sub-6 without drug", "sub-6 with drug"):
    _, d = response(V[k]["single"]["tissue"], X.FRAME_S_FILE, "a", "mean")
    po = peak_and_trace(V["sub-6 without drug"]["single"]["tissue"], X.FRAME_S_FILE, "a", "mean")[0]
    ax.plot((np.arange(len(d)) - ON) * X.FRAME_S_FILE, 100 * d / po, label=k)
ax.axvline(0, color="k", lw=0.8); ax.set_xlabel("time from onset (s)"); ax.set_ylabel("dF/F, % of the washout peak"); ax.legend(fontsize=8)
plt.show()
shift between the mean images of the two sub-6 files: [0. 0.]
sub-6 with drug: frames more than 5 SD below their 5-frame median: 2 of 365
sub-6 without drug: frames more than 5 SD below their 5-frame median: 2 of 371
  dt bleach baseline          roi  median3  peak_with  peak_without  ratio_%  reduction_%  paired_t             p  n_frames  t_10s_bins  p_10s_bins  n_bins  ratio_ok  reduction_ok
0.50      a     mean       tissue    False       4.09         18.45     22.2         77.8    -12.78  7.060507e-29       241       -3.09    0.010334      12     False          True
0.50      a     mean       tissue     True       3.15         17.95     17.5         82.5    -13.83  2.262853e-32       241       -3.15    0.009196      12      True          True
0.50      a     mean         full    False       3.46         22.26     15.6         84.4    -16.73  3.760998e-42       241       -3.84    0.002732      12      True          True
0.50      a     mean         full     True       2.84         21.93     13.0         87.0    -17.16  1.350835e-43       241       -3.88    0.002568      12     False          True
0.50      a     mean tissue_unsat    False       4.96         35.32     14.0         86.0    -12.41  1.177281e-27       241       -2.87    0.015229      12     False          True
0.50      a     mean tissue_unsat     True       3.96         35.09     11.3         88.7    -12.85  4.308407e-29       241       -2.93    0.013812      12     False         False
0.50      a    first       tissue    False       5.25         17.63     29.8         70.2     -7.15  1.042714e-11       241       -1.73    0.110859      12     False          True
0.50      a    first       tissue     True       4.94         17.63     28.0         72.0     -6.89  4.885428e-11       241       -1.58    0.143322      12     False          True
0.50      a    first         full    False       3.63         21.44     16.9         83.1    -14.39  2.847917e-34       241       -3.31    0.006974      12      True          True
0.50      a    first         full     True       3.37         21.43     15.7         84.3    -14.46  1.721111e-34       241       -3.27    0.007465      12      True          True
0.50      a    first tissue_unsat    False       6.11         34.75     17.6         82.4     -9.64  8.319087e-19       241       -2.23    0.047278      12      True          True
0.50      a    first tissue_unsat     True       5.72         34.75     16.5         83.5     -9.18  2.127446e-17       241       -2.09    0.060435      12      True          True
0.50      b     mean       tissue    False       4.31         19.48     22.1         77.9    -28.76  1.035365e-79       241       -7.62    0.000010      12     False          True
0.50      b     mean       tissue     True       3.47         18.95     18.3         81.7    -32.07  9.470542e-89       241       -7.68    0.000010      12      True          True
0.50      b     mean         full    False       3.66         23.58     15.5         84.5    -36.71 1.924416e-100       241       -8.94    0.000002      12      True          True
0.50      b     mean         full     True       3.09         23.24     13.3         86.7    -37.95 2.158834e-103       241       -8.96    0.000002      12     False          True
0.50      b     mean tissue_unsat    False       5.25         37.26     14.1         85.9    -28.10  7.500080e-78       241       -6.82    0.000029      12     False          True
0.50      b     mean tissue_unsat     True       4.37         37.04     11.8         88.2    -29.12  9.966864e-81       241       -6.89    0.000026      12     False         False
0.50      b    first       tissue    False       5.47         18.90     29.0         71.0    -22.31  1.892816e-60       241       -5.92    0.000101      12     False          True
0.50      b    first       tissue     True       5.29         18.87     28.0         72.0    -23.72  7.503079e-65       241       -5.68    0.000143      12     False          True
0.50      b    first         full    False       3.83         23.06     16.6         83.4    -34.50  5.243019e-95       241       -8.40    0.000004      12      True          True
0.50      b    first         full     True       3.64         23.03     15.8         84.2    -35.25  7.324011e-97       241       -8.32    0.000004      12      True          True
0.50      b    first tissue_unsat    False       6.42         37.15     17.3         82.7    -25.33  9.233599e-70       241       -6.15    0.000072      12      True          True
0.50      b    first tissue_unsat     True       6.16         37.16     16.6         83.4    -25.21  2.117671e-69       241       -5.96    0.000094      12      True          True
0.55      a     mean       tissue    False       4.12         18.46     22.3         77.7    -13.25  8.589065e-30       219       -3.40    0.005976      12     False          True
0.55      a     mean       tissue     True       3.17         17.95     17.6         82.4    -14.29  3.846790e-33       219       -3.43    0.005597      12      True          True
0.55      a     mean         full    False       3.49         22.28     15.6         84.4    -17.31  8.435378e-43       219       -4.20    0.001474      12      True          True
0.55      a     mean         full     True       2.86         21.95     13.0         87.0    -17.74  3.531617e-44       219       -4.23    0.001415      12     False          True
0.55      a     mean tissue_unsat    False       4.98         35.33     14.1         85.9    -12.90  1.122633e-28       219       -3.15    0.009233      12     False          True
0.55      a     mean tissue_unsat     True       3.98         35.10     11.4         88.6    -13.28  6.844391e-30       219       -3.17    0.008840      12     False         False
0.55      a    first       tissue    False       5.27         17.65     29.9         70.1     -7.94  1.075571e-13       219       -2.05    0.065119      12     False          True
0.55      a    first       tissue     True       4.96         17.64     28.1         71.9     -7.75  3.524861e-13       219       -1.88    0.087086      12     False          True
0.55      a    first         full    False       3.65         21.46     17.0         83.0    -15.09  1.064931e-35       219       -3.67    0.003683      12      True          True
0.55      a    first         full     True       3.39         21.45     15.8         84.2    -15.17  5.643090e-36       219       -3.62    0.004006      12      True          True
0.55      a    first tissue_unsat    False       6.13         34.76     17.6         82.4    -10.29  1.682810e-20       219       -2.52    0.028424      12      True          True
0.55      a    first tissue_unsat     True       5.74         34.77     16.5         83.5     -9.83  4.216636e-19       219       -2.36    0.037904      12      True          True
0.55      b     mean       tissue    False       4.31         19.48     22.1         77.9    -26.84  4.917370e-71       219       -7.40    0.000014      12     False          True
0.55      b     mean       tissue     True       3.47         18.95     18.3         81.7    -29.79  8.404516e-79       219       -7.36    0.000014      12      True          True
0.55      b     mean         full    False       3.66         23.58     15.5         84.5    -34.19  1.491132e-89       219       -8.65    0.000003      12      True          True
0.55      b     mean         full     True       3.09         23.24     13.3         86.7    -35.30  4.082104e-92       219       -8.62    0.000003      12     False          True
0.55      b     mean tissue_unsat    False       5.25         37.26     14.1         85.9    -26.23  2.274648e-69       219       -6.61    0.000038      12     False          True
0.55      b     mean tissue_unsat     True       4.37         37.04     11.8         88.2    -27.09  1.028879e-71       219       -6.59    0.000039      12     False         False
0.55      b    first       tissue    False       5.47         18.90     29.0         71.0    -20.92  5.047790e-54       219       -5.78    0.000123      12     False          True
0.55      b    first       tissue     True       5.29         18.87     28.0         72.0    -22.15  1.019064e-57       219       -5.47    0.000194      12     False          True
0.55      b    first         full    False       3.83         23.06     16.6         83.4    -32.17  9.975356e-85       219       -8.14    0.000006      12      True          True
0.55      b    first         full     True       3.64         23.03     15.8         84.2    -32.83  2.557016e-86       219       -8.01    0.000006      12      True          True
0.55      b    first tissue_unsat    False       6.42         37.15     17.3         82.7    -23.69  3.088855e-62       219       -5.98    0.000092      12      True          True
0.55      b    first tissue_unsat     True       6.16         37.16     16.6         83.4    -23.52  1.002260e-61       219       -5.72    0.000133      12      True          True

ratio within 15.3-18.7%: 24 of 48; reduction within 65.25-87.93%: 44; ratio range 11.3 to 29.9%; largest p of the within-experiment t test 4.9e-11
paired t over the means of 10 s bins (12 to 12 bins): p 2.2e-06 to 0.14; below 0.01 in 37 of 48 readings

Per 40 x 40 block at the same positions (dt 0.50 s, bleach a, mean baseline):
     block  peak_with  peak_without  ratio_%
 (120, 80)       5.87         29.47     19.9
(120, 120)       5.11          3.54    144.6
(120, 160)       9.40         21.03     44.7
 (160, 40)       3.77         25.77     14.6
 (160, 80)       2.53          0.68    369.2
(160, 120)       1.68          0.38    437.3
(160, 160)       6.51         17.69     36.8
 (200, 80)       3.63          7.73     47.0
(200, 120)       2.13          1.45    147.5
(200, 160)       4.75         23.36     20.3
 (240, 80)       3.15         23.77     13.3
(240, 120)       4.94         19.87     24.8
(240, 160)       3.87         25.41     15.2
13 blocks; ratio 13.3 to 437.3% (median 36.8); within 15.3-18.7%: 0
Test (a), a paired t test over four experiments, cannot be computed: the deposit holds one experiment.
No description has been provided for this image

Result: partially reproduced. The deposit holds one of the four experiments. In it vesamicol cuts the response: over 48 readings the peak with the drug is 11.3 to 29.9% of the peak after washout, a reduction of 70.1 to 88.7%, within the paper's 76.59 ± 11.34% in 44 readings. The paired t test over matched frames of the two traces gives p of 4.9e-11 or smaller in every reading, but its frames are not independent; over the means of twelve 10 s bins it gives p of 2.2e-06 to 0.14, below 0.01 in 37 of 48 readings; under the first reading (0.50 s, fit a, mean baseline, tissue) it is 0.0103, not below 0.01. The example's 17% is matched in 24 of 48 readings and depends on the ROI: the stained tissue gives 17.5 to 22.3% with the mean baseline and 28.0 to 29.9% with the first frame, the whole frame 13.0 to 17.0%, and the tissue without saturating pixels 11.3 to 17.6%. 69% of the tissue pixels of the washout recording saturate at some frame (data check), which clips its peak and raises the ratio when they are kept. Cell-sized blocks give ratios of 13.3 to 437.3% (median 36.8%), none within 15.3 to 18.7%, as blocks with little response after washout give large ratios. The mean over four experiments and the paired test over them (reading a) cannot be computed. Partially reproduced: the suppression holds in the one deposited experiment, three of four are not deposited, and the example ratio depends on the ROI.

figs16-af647-stable¶

The AF647 channel recorded with the pHAb signal of Figure 7 shows no visible fluorescence increase during stimulation, so the internal standard does not respond.

Criterion: whole-SMG mean AF647 intensity, photobleaching corrected, over the 8 V recording; reproduced when its largest rise after stimulation onset is below the largest rise of the pHAb channel by at least a factor of five and within the pre-stimulus noise (mean plus 3 SD). The 8 V recording is sub-3 (Methods: one mouse stimulated at 3 and 8 V for Fig. 7). The left half is taken as AF647 and the right as pHAb (data check; an assumption). The whole SMG is read as (i) the tissue mask of each channel, (ii) the whole half-frame, (iii) the pHAb tissue mask applied to the AF647 half. Photobleaching curve fit to (a) the frames before onset and from 120 s after it, (b) the whole trace. Rises are dF/F against the pre-onset mean. The drop of both channels right after stimulation is shown, with the AF647 rise measured from its lowest point as a variant.

In [19]:
s3 = V["sub-3 8V"]
rows = []
for bl in ("a", "b"):
    for roi in ("own tissue mask", "whole half", "pHAb mask on AF647"):
        if roi == "own tissue mask":
            af, ph = s3["left"]["tissue"], s3["right"]["tissue"]
        elif roi == "whole half":
            af, ph = s3["left"]["full"], s3["right"]["full"]
        else:
            af, ph = s3["left"]["by_right_mask"], s3["right"]["tissue"]
        res = {}
        for name, tr in (("AF647", af), ("pHAb", ph)):
            n = len(tr); rec = ON + int(round(120 / X.FRAME_S_FILE))
            idx = np.r_[0:ON, rec:n] if bl == "a" else np.arange(n)
            corr, _ = X.bleach_correct(tr, idx)
            d = X.dff(corr, ON, "mean")
            res[name] = d
        a, p = res["AF647"], res["pHAb"]
        noise = a[:ON].mean() + 3 * a[:ON].std()
        rows.append({"bleach": bl, "roi": roi, "AF647 max rise (%)": round(a[ON + 1:].max(), 2), "AF647 pre-onset mean+3SD (%)": round(noise, 2),
                     "AF647 min after onset (%)": round(a[ON + 1:].min(), 2), "AF647 rise from its minimum (%)": round(a[ON + 1 + np.argmin(a[ON + 1:]):].max() - a[ON + 1:].min(), 2),
                     "AF647 highest after its minimum (%)": round(a[ON + 1 + np.argmin(a[ON + 1:]):].max(), 2),
                     "pHAb max rise (%)": round(p[ON + 1:].max(), 2), "pHAb/AF647 rise": round(p[ON + 1:].max() / a[ON + 1:].max(), 1) if a[ON + 1:].max() > 0 else np.inf,
                     "AF647 within noise": bool(a[ON + 1:].max() <= noise)})
R16 = pd.DataFrame(rows)
print(R16.to_string(index=False))
print(f"after its minimum the AF647 trace passes its pre-stimulus mean (0%) in {int((R16['AF647 highest after its minimum (%)'] > 0).sum())} of {len(R16)} "
      f"readings and its pre-stimulus mean + 3 SD in {int((R16['AF647 highest after its minimum (%)'] > R16['AF647 pre-onset mean+3SD (%)']).sum())}")

fig, ax = plt.subplots(figsize=(8, 3.5))
for name, tr in (("AF647 (left)", s3["left"]["tissue"]), ("pHAb (right)", s3["right"]["tissue"])):
    corr, _ = X.bleach_correct(tr, np.r_[0:ON, ON + 240:len(tr)])
    ax.plot((np.arange(len(tr)) - ON) * X.FRAME_S_FILE, X.dff(corr, ON, "mean"), label=name)
ax.axvline(0, color="k", lw=0.8); ax.set_xlabel("time from onset (s)"); ax.set_ylabel("dF/F (%)"); ax.legend(fontsize=8)
plt.show()
print(f"run time so far {time.time() - T0:.0f} s, peak memory {rss_mb():.0f} MB")
bleach                roi  AF647 max rise (%)  AF647 pre-onset mean+3SD (%)  AF647 min after onset (%)  AF647 rise from its minimum (%)  AF647 highest after its minimum (%)  pHAb max rise (%)  pHAb/AF647 rise  AF647 within noise
     a    own tissue mask                3.54                          4.11                     -13.00                            15.76                                 2.77              50.07             14.1                True
     a         whole half                1.35                          1.97                     -15.16                            16.50                                 1.35              46.90             34.8                True
     a pHAb mask on AF647                1.53                          1.94                     -13.27                            14.80                                 1.53              50.07             32.7                True
     b    own tissue mask                3.70                          4.14                     -12.77                            11.68                                -1.09              54.01             14.6                True
     b         whole half                0.38                          1.92                     -15.36                            11.13                                -4.23              50.85            135.0                True
     b pHAb mask on AF647                1.18                          1.89                     -13.42                            11.63                                -1.79              54.01             45.7                True
after its minimum the AF647 trace passes its pre-stimulus mean (0%) in 3 of 6 readings and its pre-stimulus mean + 3 SD in 0
No description has been provided for this image
run time so far 150 s, peak memory 1305 MB

Result: reproduced, resting on the channel assignment. Over the 8 V recording the AF647 channel's largest rise after onset is 0.4 to 3.7%, within its pre-stimulus mean plus 3 SD (1.9 to 4.1%) under all six readings, while the pHAb channel rises by 46.9 to 54.0%, 14 to 135 times more. The AF647 channel drops by 13 to 15% after stimulation, as the pHAb channel does at first (data check), and rises by 11.1 to 16.5% from that minimum. After the minimum it passes its pre-stimulus mean in 3 of 6 readings (by 1.35 to 2.77%, all with the bleaching curve fit outside the response), and its pre-stimulus mean plus 3 SD in none. The files do not label the channels; the left half is taken as AF647 because it does not rise, so the test shows that one channel stays flat while the other rises, which is what the claim needs if the assignment is right.

fig7-rostral-caudal¶

At 8 V, AQuA shows the nanosensor signal spreading from rostral to caudal across the SMG. The rostral-most region rises at 13.20 s (2.75 s after stimulation onset) and peaks at 22.0 s; the signal reaches caudal regions by 13.75 and 15.40 s and lateral at 15.95 s; the most caudal region peaks at 44.55 s.

Criterion: AQuA on the 8 V recording of Figure 7 (stimulation 10.45 to 20.35 s), the whole SMG; reproduced when the event onsets are ordered rostral before caudal before lateral and the times are within tolerance (onsets within 0.55 s, the rostral peak within 0.55 s, the caudal peak within 4.455 s); partially reproduced when the order holds but the times do not.

AQuA is not run, and a substitute is. AQuA (Wang et al. 2019, the paper's ref. 32) is MATLAB software; it cannot be installed in the entry's locked Python environment, and the paper names its parameters (intensity threshold scaling factor, Gaussian smoothing, temporal cut threshold, super-event grouping; Methods, AQuA Analysis) without values. In its place each 16 x 16 pixel block of the pHAb tissue mask gets an onset and a peak frame (X.block_onsets: photobleaching-corrected dF/F; onset the first frame from frame 19 that begins 3 frames above the block's pre-onset mean + 3 SD; peak the largest 3-frame mean). The bleaching curve is fit to the frames before onset and from 120 s after it (a); variants fit it from 180 s after onset (c) or to the whole trace (b), and use blocks of 32 pixels and thresholds of 2 and 5 SD. This is an assumption: it measures where and when the signal rises, as AQuA's events do, but it is not AQuA, and AQuA's events and their times may differ from block onsets.

Regions and axis. The anatomical axis is read from Figure 7B, as the criterion says: rostral up (the stimulating electrode), caudal down, lateral to the left. The files carry no orientation; the frame is taken as shown in Figure 7A. (While preparing, outside this notebook, the panels of Fig. 7A were compared with the frames of sub-3: they show the right half of the frame, not flipped. That comparison is not run here, as the entry reads no figures.) The orientation decides the direction: the cell below runs the frame turned each way. That the deposited frames are oriented as Figure 7A shows them, with rostral up, is an assumption: the files are the camera's frames, the paper shows no sign of a flip, and the criterion reads the axis from Figure 7B. The paper's four AQuA areas cannot be located from the text, so four regions are drawn from the axis: the rostral, middle and caudal thirds of the tissue's extent along the rows (region 1, rostral-most; regions 2 and 3, the caudal regions the text reaches "by 13.75 and 15.40 s"; "most caudal" is the caudal third), and the lateral region 4, the blocks of the lower two thirds in the quarter of columns furthest to the left. A region's onset is the median onset of its blocks (the earliest is also printed), and its peak the median peak frame. Times are frame x 0.55 s, the paper's clock, on which stimulation starts at 10.45 s (frame 19); the files' 0.50 s clock is printed too. The 8 V recording is sub-3.

In [20]:
def regions(a, mask):
    rows_ = np.flatnonzero(mask.any(1)); top, bot = rows_.min(), rows_.max()
    rc = (a[:, 0] - top) / (bot - top)
    lower = a[rc >= 1 / 3]
    left_cut = np.percentile(lower[:, 1], 25)
    return {"1 rostral third": a[rc < 1 / 3], "2 middle third": a[(rc >= 1 / 3) & (rc < 2 / 3)], "3 caudal third": a[rc >= 2 / 3],
            "4 lateral (left quarter of lower 2/3)": lower[lower[:, 1] <= left_cut]}

def flipped(a, mask, rows_flip, cols_flip):
    a = a.copy()
    r_, c_ = np.flatnonzero(mask.any(1)), np.flatnonzero(mask.any(0))
    if rows_flip:
        a[:, 0] = r_.min() + r_.max() - a[:, 0]
    if cols_flip:
        a[:, 1] = c_.min() + c_.max() - a[:, 1]
    return a

ORIENT = (((False, False), "as deposited (rostral up, lateral left)"), ((True, False), "flipped top to bottom"),
          ((False, True), "flipped left to right"), ((True, True), "turned 180 degrees"))

def region_table(key, flip=(False, False)):
    mask = V[key]["right"]["mask"]
    out = []
    for (k_, size, k, fit), a in MAPS.items():
        if k_ != key:
            continue
        a = flipped(a[a[:, 2] >= 0], mask, *flip)
        rg = regions(a, mask)
        row = {"block px": size, "k SD": k, "bleach fit": fit, "blocks with onset": len(a),
               "rho(onset, row)": round(stats.spearmanr(a[:, 0], a[:, 2])[0], 2), "p(rho row)": stats.spearmanr(a[:, 0], a[:, 2])[1],
               "rho(onset, column)": round(stats.spearmanr(a[:, 1], a[:, 2])[0], 2)}
        for name, r in rg.items():
            n_ = name.split()[0]
            row[f"R{n_} n"] = len(r)
            row[f"R{n_} onset"] = float(np.median(r[:, 2])); row[f"R{n_} first"] = float(r[:, 2].min())
            row[f"R{n_} peak"] = float(np.median(r[:, 3])); row[f"R{n_} amp %"] = round(float(np.median(r[:, 4])), 1)
        row["order 1<2,3<4"] = bool(row["R1 onset"] < min(row["R2 onset"], row["R3 onset"]) and max(row["R2 onset"], row["R3 onset"]) < row["R4 onset"])
        row["order 1<2<=3<4"] = bool(row["R1 onset"] < row["R2 onset"] <= row["R3 onset"] < row["R4 onset"])
        out.append(row)
    return pd.DataFrame(out)

T3 = region_table("sub-3 8V")
print("sub-3 (8 V), pHAb half: region onsets and peaks in frames (median over the region's blocks; 'first' the earliest block)")
print(T3.to_string(index=False))

exp = {"R1 onset": 13.20, "R2 onset": 13.75, "R3 onset": 15.40, "R4 onset": 15.95, "R1 peak": 22.0, "R3 peak": 44.55}
tol = {"R1 onset": 0.55, "R2 onset": 0.55, "R3 onset": 0.55, "R4 onset": 0.55, "R1 peak": 0.55, "R3 peak": 4.455}
rows = []
for _, r in T3.iterrows():
    for clock, dt in (("paper 0.55 s", X.FRAME_S_PAPER), ("file 0.50 s", X.FRAME_S_FILE)):
        tt = {q: r[q] * dt for q in exp}
        rows.append({"block px": r["block px"], "k SD": r["k SD"], "bleach fit": r["bleach fit"], "clock": clock,
                     **{f"{q} (s)": round(v, 2) for q, v in tt.items()},
                     "times within tolerance": int(sum(abs(tt[q] - exp[q]) <= tol[q] for q in exp)), "order": r["order 1<2,3<4"]})
T3t = pd.DataFrame(rows)
print("\nThe same in seconds (frame x clock); the paper: onsets 13.20, 13.75, 15.40, 15.95 s, rostral peak 22.0 s, caudal peak 44.55 s")
print(T3t.to_string(index=False))
print(f"\nvariants with the order rostral < caudal regions < lateral: {int(T3['order 1<2,3<4'].sum())} of {len(T3)}; "
      f"with all 6 times within tolerance: {int((T3t['times within tolerance'] == 6).sum())} of {len(T3t)}; "
      f"most times within tolerance in any variant: {T3t['times within tolerance'].max()} of 6")
print(f"Spearman rho of block onset with the row (rostral to caudal) over the variants: {T3['rho(onset, row)'].min()} to {T3['rho(onset, row)'].max()}, "
      f"largest p {T3['p(rho row)'].max():.2g}; with the column (left is lateral): {T3['rho(onset, column)'].min()} to {T3['rho(onset, column)'].max()}")
print("\nThe files carry no orientation. The order under each way the frame could be turned (regions redrawn on the turned frame):")
for flip, name in ORIENT:
    Tf = region_table("sub-3 8V", flip)
    print(f"  {name}: rostral < caudal regions < lateral in {int(Tf['order 1<2,3<4'].sum())} of {len(Tf)} variants; "
          f"rostral region first in {int((Tf['R1 onset'] < Tf[['R2 onset', 'R3 onset', 'R4 onset']].min(axis=1)).sum())}")

fig, axs = plt.subplots(1, 4, figsize=(15, 7))
for a_, key in zip((axs[:2], axs[2:]), ("sub-3 8V", "sub-2 3V")):
    a = MAPS[(key, 16, 3.0, "a")]
    for ax_, col, title in ((a_[0], 2, "onset frame"), (a_[1], 3, "peak frame")):
        img = np.full(V[key]["right"]["mask"].shape, np.nan)
        for yc, xc, on, pk, amp in a:
            img[int(yc) - 8:int(yc) + 8, int(xc) - 8:int(xc) + 8] = (on if col == 2 else pk) if on >= 0 else np.nan
        im = ax_.imshow(img, cmap="viridis"); ax_.set_title(f"{key}: {title}\n(16 px blocks, 3 SD, bleach a)", fontsize=9); ax_.axis("off")
        plt.colorbar(im, ax=ax_, fraction=0.046)
plt.show()
for key in ("sub-3 8V", "sub-2 3V"):
    a = MAPS[(key, 16, 3.0, "a")]
    print(f"{key} maps: {len(a)} blocks, {int((a[:, 2] < 0).sum())} without an onset; onset frames {a[a[:, 2] >= 0, 2].min():.0f} to {a[:, 2].max():.0f}, "
          f"peak frames {a[:, 3].min():.0f} to {a[:, 3].max():.0f}; rostral is up")
sub-3 (8 V), pHAb half: region onsets and peaks in frames (median over the region's blocks; 'first' the earliest block)
 block px  k SD bleach fit  blocks with onset  rho(onset, row)   p(rho row)  rho(onset, column)  R1 n  R1 onset  R1 first  R1 peak  R1 amp %  R2 n  R2 onset  R2 first  R2 peak  R2 amp %  R3 n  R3 onset  R3 first  R3 peak  R3 amp %  R4 n  R4 onset  R4 first  R4 peak  R4 amp %  order 1<2,3<4  order 1<2<=3<4
       16   2.0          a                157             0.65 2.319350e-20               -0.46    27      30.0      28.0     56.0      69.9    69      34.0      27.0     61.0      53.9    61      37.0      32.0     65.0      39.5    34      42.0      34.0     66.5      38.0           True            True
       16   2.0          c                157             0.65 1.737219e-20               -0.46    27      30.0      28.0     56.0      69.9    69      34.0      27.0     61.0      53.9    61      37.0      32.0     65.0      39.0    34      42.0      34.0     66.5      38.0           True            True
       16   2.0          b                157             0.65 6.834996e-20               -0.46    27      29.0      27.0     62.0      78.3    69      33.0      27.0     62.0      58.8    61      36.0      32.0     66.0      42.4    34      41.0      33.0     67.0      40.7           True            True
       16   3.0          a                157             0.67 1.269468e-21               -0.46    27      30.0      28.0     56.0      69.9    69      34.0      27.0     61.0      53.9    61      37.0      33.0     65.0      39.5    34      42.0      34.0     66.5      38.0           True            True
       16   3.0          c                157             0.67 5.623201e-22               -0.46    27      30.0      28.0     56.0      69.9    69      34.0      27.0     61.0      53.9    61      37.0      33.0     65.0      39.0    34      42.0      34.0     66.5      38.0           True            True
       16   3.0          b                157             0.66 1.031085e-20               -0.46    27      30.0      28.0     62.0      78.3    69      33.0      27.0     62.0      58.8    61      37.0      32.0     66.0      42.4    34      42.0      34.0     67.0      40.7           True            True
       16   5.0          a                157             0.68 2.093729e-22               -0.44    27      30.0      29.0     56.0      69.9    69      35.0      27.0     61.0      53.9    61      38.0      33.0     65.0      39.5    34      43.0      36.0     66.5      38.0           True            True
       16   5.0          c                157             0.68 1.724124e-22               -0.44    27      30.0      29.0     56.0      69.9    69      35.0      27.0     61.0      53.9    61      38.0      33.0     65.0      39.0    34      43.0      36.0     66.5      38.0           True            True
       16   5.0          b                157             0.68 1.023439e-22               -0.44    27      30.0      29.0     62.0      78.3    69      35.0      27.0     62.0      58.8    61      38.0      33.0     66.0      42.4    34      42.0      34.0     67.0      40.7           True            True
       32   2.0          a                 33             0.62 1.084184e-04               -0.62     5      29.0      29.0     55.0      63.5    13      32.0      28.0     59.0      56.0    15      37.0      34.0     65.0      38.2    12      41.0      32.0     66.0      37.8           True            True
       32   2.0          c                 33             0.62 1.084184e-04               -0.62     5      29.0      29.0     55.0      63.4    13      32.0      28.0     59.0      55.8    15      37.0      34.0     65.0      38.3    12      41.0      32.0     66.0      37.8           True            True
       32   2.0          b                 33             0.64 6.334921e-05               -0.62     5      29.0      28.0     61.0      71.1    13      32.0      28.0     65.0      61.5    15      36.0      33.0     65.0      40.8    12      40.0      32.0     66.0      40.2           True            True
       32   3.0          a                 33             0.67 2.121506e-05               -0.61     5      29.0      29.0     55.0      63.5    13      33.0      29.0     59.0      56.0    15      37.0      34.0     65.0      38.2    12      41.5      32.0     66.0      37.8           True            True
       32   3.0          c                 33             0.67 2.121506e-05               -0.61     5      29.0      29.0     55.0      63.4    13      33.0      29.0     59.0      55.8    15      37.0      34.0     65.0      38.3    12      41.5      32.0     66.0      37.8           True            True
       32   3.0          b                 33             0.63 7.642105e-05               -0.60     5      29.0      29.0     61.0      71.1    13      32.0      28.0     65.0      61.5    15      37.0      34.0     65.0      40.8    12      40.5      32.0     66.0      40.2           True            True
       32   5.0          a                 33             0.66 3.441560e-05               -0.63     5      30.0      29.0     55.0      63.5    13      33.0      29.0     59.0      56.0    15      38.0      35.0     65.0      38.2    12      42.0      33.0     66.0      37.8           True            True
       32   5.0          c                 33             0.66 2.434955e-05               -0.63     5      30.0      29.0     55.0      63.4    13      33.0      29.0     59.0      55.8    15      38.0      35.0     65.0      38.3    12      42.0      33.0     66.0      37.8           True            True
       32   5.0          b                 33             0.67 1.845388e-05               -0.62     5      29.0      29.0     61.0      71.1    13      33.0      29.0     65.0      61.5    15      38.0      34.0     65.0      40.8    12      41.5      32.0     66.0      40.2           True            True

The same in seconds (frame x clock); the paper: onsets 13.20, 13.75, 15.40, 15.95 s, rostral peak 22.0 s, caudal peak 44.55 s
 block px  k SD bleach fit        clock  R1 onset (s)  R2 onset (s)  R3 onset (s)  R4 onset (s)  R1 peak (s)  R3 peak (s)  times within tolerance  order
       16   2.0          a paper 0.55 s         16.50         18.70         20.35         23.10        30.80        35.75                       0   True
       16   2.0          a  file 0.50 s         15.00         17.00         18.50         21.00        28.00        32.50                       0   True
       16   2.0          c paper 0.55 s         16.50         18.70         20.35         23.10        30.80        35.75                       0   True
       16   2.0          c  file 0.50 s         15.00         17.00         18.50         21.00        28.00        32.50                       0   True
       16   2.0          b paper 0.55 s         15.95         18.15         19.80         22.55        34.10        36.30                       0   True
       16   2.0          b  file 0.50 s         14.50         16.50         18.00         20.50        31.00        33.00                       0   True
       16   3.0          a paper 0.55 s         16.50         18.70         20.35         23.10        30.80        35.75                       0   True
       16   3.0          a  file 0.50 s         15.00         17.00         18.50         21.00        28.00        32.50                       0   True
       16   3.0          c paper 0.55 s         16.50         18.70         20.35         23.10        30.80        35.75                       0   True
       16   3.0          c  file 0.50 s         15.00         17.00         18.50         21.00        28.00        32.50                       0   True
       16   3.0          b paper 0.55 s         16.50         18.15         20.35         23.10        34.10        36.30                       0   True
       16   3.0          b  file 0.50 s         15.00         16.50         18.50         21.00        31.00        33.00                       0   True
       16   5.0          a paper 0.55 s         16.50         19.25         20.90         23.65        30.80        35.75                       0   True
       16   5.0          a  file 0.50 s         15.00         17.50         19.00         21.50        28.00        32.50                       0   True
       16   5.0          c paper 0.55 s         16.50         19.25         20.90         23.65        30.80        35.75                       0   True
       16   5.0          c  file 0.50 s         15.00         17.50         19.00         21.50        28.00        32.50                       0   True
       16   5.0          b paper 0.55 s         16.50         19.25         20.90         23.10        34.10        36.30                       0   True
       16   5.0          b  file 0.50 s         15.00         17.50         19.00         21.00        31.00        33.00                       0   True
       32   2.0          a paper 0.55 s         15.95         17.60         20.35         22.55        30.25        35.75                       0   True
       32   2.0          a  file 0.50 s         14.50         16.00         18.50         20.50        27.50        32.50                       0   True
       32   2.0          c paper 0.55 s         15.95         17.60         20.35         22.55        30.25        35.75                       0   True
       32   2.0          c  file 0.50 s         14.50         16.00         18.50         20.50        27.50        32.50                       0   True
       32   2.0          b paper 0.55 s         15.95         17.60         19.80         22.00        33.55        35.75                       0   True
       32   2.0          b  file 0.50 s         14.50         16.00         18.00         20.00        30.50        32.50                       0   True
       32   3.0          a paper 0.55 s         15.95         18.15         20.35         22.83        30.25        35.75                       0   True
       32   3.0          a  file 0.50 s         14.50         16.50         18.50         20.75        27.50        32.50                       0   True
       32   3.0          c paper 0.55 s         15.95         18.15         20.35         22.83        30.25        35.75                       0   True
       32   3.0          c  file 0.50 s         14.50         16.50         18.50         20.75        27.50        32.50                       0   True
       32   3.0          b paper 0.55 s         15.95         17.60         20.35         22.28        33.55        35.75                       0   True
       32   3.0          b  file 0.50 s         14.50         16.00         18.50         20.25        30.50        32.50                       0   True
       32   5.0          a paper 0.55 s         16.50         18.15         20.90         23.10        30.25        35.75                       0   True
       32   5.0          a  file 0.50 s         15.00         16.50         19.00         21.00        27.50        32.50                       0   True
       32   5.0          c paper 0.55 s         16.50         18.15         20.90         23.10        30.25        35.75                       0   True
       32   5.0          c  file 0.50 s         15.00         16.50         19.00         21.00        27.50        32.50                       0   True
       32   5.0          b paper 0.55 s         15.95         18.15         20.90         22.83        33.55        35.75                       0   True
       32   5.0          b  file 0.50 s         14.50         16.50         19.00         20.75        30.50        32.50                       0   True

variants with the order rostral < caudal regions < lateral: 18 of 18; with all 6 times within tolerance: 0 of 36; most times within tolerance in any variant: 0 of 6
Spearman rho of block onset with the row (rostral to caudal) over the variants: 0.62 to 0.68, largest p 0.00011; with the column (left is lateral): -0.63 to -0.44

The files carry no orientation. The order under each way the frame could be turned (regions redrawn on the turned frame):
  as deposited (rostral up, lateral left): rostral < caudal regions < lateral in 18 of 18 variants; rostral region first in 18
  flipped top to bottom: rostral < caudal regions < lateral in 0 of 18 variants; rostral region first in 0
  flipped left to right: rostral < caudal regions < lateral in 0 of 18 variants; rostral region first in 18
  turned 180 degrees: rostral < caudal regions < lateral in 0 of 18 variants; rostral region first in 0
No description has been provided for this image
sub-3 8V maps: 157 blocks, 0 without an onset; onset frames 27 to 45, peak frames 51 to 129; rostral is up
sub-2 3V maps: 154 blocks, 0 without an onset; onset frames 25 to 46, peak frames 43 to 77; rostral is up

Result: partially reproduced, resting on the substitute for AQuA and on the orientation. In sub-3 the signal starts rostrally and spreads caudally and then laterally: in all 18 variants the median onset of the rostral third precedes those of the middle and caudal thirds, which precede the lateral region (for 16 px blocks, 3 SD, fit a: frames 30, 34, 37 and 42), and block onset rises with the rostro-caudal position (Spearman rho 0.62 to 0.68, p 0.00011 or less) and falls with the column (rho -0.63 to -0.44, later to the left, the lateral side). The times do not match: on the paper's clock the region onsets are 15.95 to 16.50 s (rostral), 17.60 to 19.25 s, 19.80 to 20.90 s and 22.00 to 23.65 s (lateral), against 13.20, 13.75, 15.40 and 15.95 s; the rostral peak is 30.25 to 34.10 s against 22.0 s and the caudal peak 35.75 to 36.30 s against 44.55 s; none of the 36 variant-clock pairs has any of the six times within tolerance. Part of the onset delay may come from the drop of both channels in the first frames after stimulation (data check), which a threshold on dF/F has to clear, and AQuA's events need not match blocks. The direction rests on the orientation: with the frame flipped top to bottom, or turned 180 degrees, the order holds in 0 of 18 variants, and flipped left to right also in 0 of 18 (the rostral region still starts first in all 18, but the lateral region no longer comes last). The frame is taken as deposited, rostral up, an assumption (see above). Partially reproduced, as the criterion says when the order holds but the times do not, on the frame as deposited.

fig7-peak-timing¶

All evoked nanosensor responses in Figure 7A climb to their peak around 10 to 15 s after stimulation onset, as in Figure 5B to E.

Criterion: for the AQuA events of Figure 7A, the time to each event's peak, from (i) stimulation onset (10.45 s) or (ii) the event's onset; reproduced when, under one reading, all four numbered events peak within 9 to 16.5 s; partially reproduced when all but the most caudal do. As for fig7-rostral-caudal, the four regions and the block onsets and peaks stand in for AQuA's events (an assumption), on sub-3. The per-block times are shown too.

In [21]:
rows = []
for _, r in T3.iterrows():
    for clock, dt in (("paper 0.55 s", X.FRAME_S_PAPER), ("file 0.50 s", X.FRAME_S_FILE)):
        for reading in ("i from stimulation onset", "ii from region onset"):
            ts = {f"R{n}": (r[f"R{n} peak"] - (X.STIM_FRAME if reading == "i from stimulation onset" else r[f"R{n} onset"])) * dt for n in (1, 2, 3, 4)}
            inside = {q: 9 <= v <= 16.5 for q, v in ts.items()}
            rows.append({"block px": r["block px"], "k SD": r["k SD"], "bleach fit": r["bleach fit"], "clock": clock, "reading": reading,
                         **{f"{q} (s)": round(v, 2) for q, v in ts.items()}, "all 4 within 9-16.5 s": all(inside.values()),
                         "all but caudal (R3) within": all(v for q, v in inside.items() if q != "R3")})
P7 = pd.DataFrame(rows)
print(P7.to_string(index=False))
for reading in ("i from stimulation onset", "ii from region onset"):
    s_ = P7[P7.reading == reading]
    print(f"{reading}: all four within 9-16.5 s in {int(s_['all 4 within 9-16.5 s'].sum())} of {len(s_)} variants; all but the caudal region in "
          f"{int(s_['all but caudal (R3) within'].sum())}; times {s_[[f'R{n} (s)' for n in (1, 2, 3, 4)]].min().min():.1f} to "
          f"{s_[[f'R{n} (s)' for n in (1, 2, 3, 4)]].max().max():.1f} s")
stim_s = X.STIM_FRAME * X.FRAME_S_PAPER
print(f"the paper's own times (claim fig7-rostral-caudal): reading (i) rostral {exp['R1 peak'] - stim_s:.2f} s, most caudal {exp['R3 peak'] - stim_s:.2f} s; "
      f"reading (ii) rostral {exp['R1 peak'] - exp['R1 onset']:.2f} s, most caudal {exp['R3 peak'] - exp['R3 onset']:.2f} s (9-16.5 s to pass)")
a = MAPS[("sub-3 8V", 16, 3.0, "a")]; a = a[a[:, 2] >= 0]
for reading, ref in (("from stimulation onset", np.full(len(a), X.STIM_FRAME)), ("from block onset", a[:, 2])):
    t_ = (a[:, 3] - ref) * X.FRAME_S_PAPER
    print(f"per block (16 px, 3 SD, bleach a, 0.55 s), time to peak {reading}: {t_.min():.1f} to {t_.max():.1f} s, median {np.median(t_):.1f}; "
          f"within 9-16.5 s: {int(((t_ >= 9) & (t_ <= 16.5)).sum())} of {len(t_)}")
 block px  k SD bleach fit        clock                  reading  R1 (s)  R2 (s)  R3 (s)  R4 (s)  all 4 within 9-16.5 s  all but caudal (R3) within
       16   2.0          a paper 0.55 s i from stimulation onset   20.35   23.10   25.30   26.13                  False                       False
       16   2.0          a paper 0.55 s     ii from region onset   14.30   14.85   15.40   13.48                   True                        True
       16   2.0          a  file 0.50 s i from stimulation onset   18.50   21.00   23.00   23.75                  False                       False
       16   2.0          a  file 0.50 s     ii from region onset   13.00   13.50   14.00   12.25                   True                        True
       16   2.0          c paper 0.55 s i from stimulation onset   20.35   23.10   25.30   26.13                  False                       False
       16   2.0          c paper 0.55 s     ii from region onset   14.30   14.85   15.40   13.48                   True                        True
       16   2.0          c  file 0.50 s i from stimulation onset   18.50   21.00   23.00   23.75                  False                       False
       16   2.0          c  file 0.50 s     ii from region onset   13.00   13.50   14.00   12.25                   True                        True
       16   2.0          b paper 0.55 s i from stimulation onset   23.65   23.65   25.85   26.40                  False                       False
       16   2.0          b paper 0.55 s     ii from region onset   18.15   15.95   16.50   14.30                  False                       False
       16   2.0          b  file 0.50 s i from stimulation onset   21.50   21.50   23.50   24.00                  False                       False
       16   2.0          b  file 0.50 s     ii from region onset   16.50   14.50   15.00   13.00                   True                        True
       16   3.0          a paper 0.55 s i from stimulation onset   20.35   23.10   25.30   26.13                  False                       False
       16   3.0          a paper 0.55 s     ii from region onset   14.30   14.85   15.40   13.48                   True                        True
       16   3.0          a  file 0.50 s i from stimulation onset   18.50   21.00   23.00   23.75                  False                       False
       16   3.0          a  file 0.50 s     ii from region onset   13.00   13.50   14.00   12.25                   True                        True
       16   3.0          c paper 0.55 s i from stimulation onset   20.35   23.10   25.30   26.13                  False                       False
       16   3.0          c paper 0.55 s     ii from region onset   14.30   14.85   15.40   13.48                   True                        True
       16   3.0          c  file 0.50 s i from stimulation onset   18.50   21.00   23.00   23.75                  False                       False
       16   3.0          c  file 0.50 s     ii from region onset   13.00   13.50   14.00   12.25                   True                        True
       16   3.0          b paper 0.55 s i from stimulation onset   23.65   23.65   25.85   26.40                  False                       False
       16   3.0          b paper 0.55 s     ii from region onset   17.60   15.95   15.95   13.75                  False                       False
       16   3.0          b  file 0.50 s i from stimulation onset   21.50   21.50   23.50   24.00                  False                       False
       16   3.0          b  file 0.50 s     ii from region onset   16.00   14.50   14.50   12.50                   True                        True
       16   5.0          a paper 0.55 s i from stimulation onset   20.35   23.10   25.30   26.13                  False                       False
       16   5.0          a paper 0.55 s     ii from region onset   14.30   14.30   14.85   12.93                   True                        True
       16   5.0          a  file 0.50 s i from stimulation onset   18.50   21.00   23.00   23.75                  False                       False
       16   5.0          a  file 0.50 s     ii from region onset   13.00   13.00   13.50   11.75                   True                        True
       16   5.0          c paper 0.55 s i from stimulation onset   20.35   23.10   25.30   26.13                  False                       False
       16   5.0          c paper 0.55 s     ii from region onset   14.30   14.30   14.85   12.93                   True                        True
       16   5.0          c  file 0.50 s i from stimulation onset   18.50   21.00   23.00   23.75                  False                       False
       16   5.0          c  file 0.50 s     ii from region onset   13.00   13.00   13.50   11.75                   True                        True
       16   5.0          b paper 0.55 s i from stimulation onset   23.65   23.65   25.85   26.40                  False                       False
       16   5.0          b paper 0.55 s     ii from region onset   17.60   14.85   15.40   13.75                  False                       False
       16   5.0          b  file 0.50 s i from stimulation onset   21.50   21.50   23.50   24.00                  False                       False
       16   5.0          b  file 0.50 s     ii from region onset   16.00   13.50   14.00   12.50                   True                        True
       32   2.0          a paper 0.55 s i from stimulation onset   19.80   22.00   25.30   25.85                  False                       False
       32   2.0          a paper 0.55 s     ii from region onset   14.30   14.85   15.40   13.75                   True                        True
       32   2.0          a  file 0.50 s i from stimulation onset   18.00   20.00   23.00   23.50                  False                       False
       32   2.0          a  file 0.50 s     ii from region onset   13.00   13.50   14.00   12.50                   True                        True
       32   2.0          c paper 0.55 s i from stimulation onset   19.80   22.00   25.30   25.85                  False                       False
       32   2.0          c paper 0.55 s     ii from region onset   14.30   14.85   15.40   13.75                   True                        True
       32   2.0          c  file 0.50 s i from stimulation onset   18.00   20.00   23.00   23.50                  False                       False
       32   2.0          c  file 0.50 s     ii from region onset   13.00   13.50   14.00   12.50                   True                        True
       32   2.0          b paper 0.55 s i from stimulation onset   23.10   25.30   25.30   25.85                  False                       False
       32   2.0          b paper 0.55 s     ii from region onset   17.60   18.15   15.95   14.30                  False                       False
       32   2.0          b  file 0.50 s i from stimulation onset   21.00   23.00   23.00   23.50                  False                       False
       32   2.0          b  file 0.50 s     ii from region onset   16.00   16.50   14.50   13.00                   True                        True
       32   3.0          a paper 0.55 s i from stimulation onset   19.80   22.00   25.30   25.85                  False                       False
       32   3.0          a paper 0.55 s     ii from region onset   14.30   14.30   15.40   13.48                   True                        True
       32   3.0          a  file 0.50 s i from stimulation onset   18.00   20.00   23.00   23.50                  False                       False
       32   3.0          a  file 0.50 s     ii from region onset   13.00   13.00   14.00   12.25                   True                        True
       32   3.0          c paper 0.55 s i from stimulation onset   19.80   22.00   25.30   25.85                  False                       False
       32   3.0          c paper 0.55 s     ii from region onset   14.30   14.30   15.40   13.48                   True                        True
       32   3.0          c  file 0.50 s i from stimulation onset   18.00   20.00   23.00   23.50                  False                       False
       32   3.0          c  file 0.50 s     ii from region onset   13.00   13.00   14.00   12.25                   True                        True
       32   3.0          b paper 0.55 s i from stimulation onset   23.10   25.30   25.30   25.85                  False                       False
       32   3.0          b paper 0.55 s     ii from region onset   17.60   18.15   15.40   14.03                  False                       False
       32   3.0          b  file 0.50 s i from stimulation onset   21.00   23.00   23.00   23.50                  False                       False
       32   3.0          b  file 0.50 s     ii from region onset   16.00   16.50   14.00   12.75                   True                        True
       32   5.0          a paper 0.55 s i from stimulation onset   19.80   22.00   25.30   25.85                  False                       False
       32   5.0          a paper 0.55 s     ii from region onset   13.75   14.30   14.85   13.20                   True                        True
       32   5.0          a  file 0.50 s i from stimulation onset   18.00   20.00   23.00   23.50                  False                       False
       32   5.0          a  file 0.50 s     ii from region onset   12.50   13.00   13.50   12.00                   True                        True
       32   5.0          c paper 0.55 s i from stimulation onset   19.80   22.00   25.30   25.85                  False                       False
       32   5.0          c paper 0.55 s     ii from region onset   13.75   14.30   14.85   13.20                   True                        True
       32   5.0          c  file 0.50 s i from stimulation onset   18.00   20.00   23.00   23.50                  False                       False
       32   5.0          c  file 0.50 s     ii from region onset   12.50   13.00   13.50   12.00                   True                        True
       32   5.0          b paper 0.55 s i from stimulation onset   23.10   25.30   25.30   25.85                  False                       False
       32   5.0          b paper 0.55 s     ii from region onset   17.60   17.60   14.85   13.48                  False                       False
       32   5.0          b  file 0.50 s i from stimulation onset   21.00   23.00   23.00   23.50                  False                       False
       32   5.0          b  file 0.50 s     ii from region onset   16.00   16.00   13.50   12.25                   True                        True
i from stimulation onset: all four within 9-16.5 s in 0 of 36 variants; all but the caudal region in 0; times 18.0 to 26.4 s
ii from region onset: all four within 9-16.5 s in 30 of 36 variants; all but the caudal region in 30; times 11.8 to 18.1 s
the paper's own times (claim fig7-rostral-caudal): reading (i) rostral 11.55 s, most caudal 34.10 s; reading (ii) rostral 8.80 s, most caudal 29.15 s (9-16.5 s to pass)
per block (16 px, 3 SD, bleach a, 0.55 s), time to peak from stimulation onset: 17.6 to 60.5 s, median 23.7; within 9-16.5 s: 0 of 157
per block (16 px, 3 SD, bleach a, 0.55 s), time to peak from block onset: 9.4 to 55.6 s, median 13.8; within 9-16.5 s: 126 of 157

Result: reproduced under reading (ii), resting on the substitute for AQuA and on the orientation; asked of a reader. Counted from each region's onset (reading ii), the four regions of sub-3 reach their peak in 11.8 to 18.1 s; all four are within 9 to 16.5 s in 30 of 36 variants, every variant with the bleaching curve fit outside the response (a and c) on both clocks, and at the 0.50 s clock with the whole-trace fit. For the main variant (16 px blocks, 3 SD, fit a, paper's clock) the times are 14.30, 14.85, 15.40 and 13.48 s, and 126 of the 157 blocks peak 9 to 16.5 s after their own onset (median 13.8 s). Counted from stimulation onset (reading i), no variant fits: the regions peak 18.0 to 26.4 s after it, and no block peaks within 16.5 s of it. The pass is weak. It rests on the region onsets, which come 2.75 to 3.3 s after the paper's for the rostral region (none of the six times of fig7-rostral-caudal matches); both the onsets and the peaks are late, and their difference falls in the window. And reading (ii) does not fit the paper's own times: from Figure 7B and the text, the rostral region peaks 8.80 s after its onset and the most caudal 29.15 s after its own, both outside 9 to 16.5 s, while reading (i) gives 11.55 s for the rostral region. The claims file flags the paper's contradiction only for the most caudal region; whether reading (ii) should stand is now asked of a reader (questions/xia-2021.yaml). The outcome follows the claims file as written, which counts a pass under either reading: reproduced under reading (ii).

figs12-3v-propagation¶

At 3 V, in three independent experiments, AQuA shows the same rostral-to-caudal direction of propagation, with lower amplitude than at 8 V.

Criterion: AQuA as in fig7-rostral-caudal on the 3 V recordings of three mice (one also used at 8 V, two at 3 V only); reproduced when in each the earliest event lies rostral of the later ones, and in the mouse stimulated at both voltages the peak dF/F at 3 V is below that at 8 V; partially reproduced when two of three show the order. Only the mouse stimulated at both voltages is deposited: sub-2 (3 V) and sub-3 (8 V) are one ganglion (data check). The two mice stimulated at 3 V only are not. The block maps stand in for AQuA, as above (an assumption). Order: the rostral region's onset precedes those of the other regions, and the earliest block lies in the rostral third. Amplitude: the peak of the photobleaching-corrected tissue dF/F after onset, at 3 V and 8 V.

In [22]:
T2 = region_table("sub-2 3V")
print("sub-2 (3 V), pHAb half: region onsets and peaks in frames")
print(T2.to_string(index=False))
first_rostral = []
for (k_, size, k, fit), a in MAPS.items():
    if k_ == "sub-2 3V":
        a = a[a[:, 2] >= 0]
        rows_ = np.flatnonzero(V[k_]["right"]["mask"].any(1))
        first = a[a[:, 2] == a[:, 2].min()]
        first_rostral.append(bool(np.all((first[:, 0] - rows_.min()) / (rows_.max() - rows_.min()) < 1 / 3)))
T2["earliest blocks all in rostral third"] = first_rostral
T2["rostral first"] = T2["R1 onset"] < T2[["R2 onset", "R3 onset", "R4 onset"]].min(axis=1)
print(f"\nvariants where the rostral region's onset precedes the other three: {int(T2['rostral first'].sum())} of {len(T2)}; "
      f"where every earliest block lies in the rostral third: {int(T2['earliest blocks all in rostral third'].sum())} of {len(T2)}")
print(f"Spearman rho of block onset with the row: {T2['rho(onset, row)'].min()} to {T2['rho(onset, row)'].max()}, largest p {T2['p(rho row)'].max():.2g}")
for flip, name in ORIENT:
    Tf = region_table("sub-2 3V", flip)
    print(f"  frame {name}: rostral region first in {int((Tf['R1 onset'] < Tf[['R2 onset', 'R3 onset', 'R4 onset']].min(axis=1)).sum())} of {len(Tf)} variants")

rows = []
for bl in ("a", "b"):
    for roi in ("tissue", "full", "tissue_unsat"):
        pk = {}
        for key in ("sub-2 3V", "sub-3 8V"):
            tr = V[key]["right"][roi]; n = len(tr); rec = X.STIM_FRAME + int(round(120 / X.FRAME_S_FILE))
            idx = np.r_[0:X.STIM_FRAME, rec:n] if bl == "a" else np.arange(n)
            d = X.dff(X.bleach_correct(tr, idx)[0], X.STIM_FRAME)
            pk[key] = d[X.STIM_FRAME:].max()
        rows.append({"bleach": bl, "roi": roi, "peak dF/F 3 V (%)": round(pk["sub-2 3V"], 1), "peak dF/F 8 V (%)": round(pk["sub-3 8V"], 1),
                     "3 V below 8 V": bool(pk["sub-2 3V"] < pk["sub-3 8V"])})
A12 = pd.DataFrame(rows)
print("\n" + A12.to_string(index=False))
print(f"3 V below 8 V in {int(A12['3 V below 8 V'].sum())} of {len(A12)} readings; block-median amplitude by region at 3 V and 8 V (16 px, 3 SD, bleach a): "
      + "; ".join(f"R{n} {T2[(T2['block px'] == 16) & (T2['k SD'] == 3.0) & (T2['bleach fit'] == 'a')][f'R{n} amp %'].iloc[0]} vs "
                  f"{T3[(T3['block px'] == 16) & (T3['k SD'] == 3.0) & (T3['bleach fit'] == 'a')][f'R{n} amp %'].iloc[0]}" for n in (1, 2, 3, 4)))
sub-2 (3 V), pHAb half: region onsets and peaks in frames
 block px  k SD bleach fit  blocks with onset  rho(onset, row)   p(rho row)  rho(onset, column)  R1 n  R1 onset  R1 first  R1 peak  R1 amp %  R2 n  R2 onset  R2 first  R2 peak  R2 amp %  R3 n  R3 onset  R3 first  R3 peak  R3 amp %  R4 n  R4 onset  R4 first  R4 peak  R4 amp %  order 1<2,3<4  order 1<2<=3<4
       16   2.0          a                154             0.61 3.660119e-17                0.18    24      27.0      24.0     49.0      43.6    74      29.0      26.0     53.0      28.1    56      32.0      21.0     62.0      21.5    35      30.0      21.0     60.0      21.1          False           False
       16   2.0          c                154             0.70 1.080749e-23                0.18    24      27.0      24.0     49.0      43.6    74      29.0      26.0     53.0      28.7    56      34.0      27.0     61.5      19.9    35      31.0      27.0     60.0      20.5          False           False
       16   2.0          b                152             0.45 8.148841e-09                0.14    24      29.0      22.0     49.0      44.2    74      29.0      21.0     54.0      29.6    54      35.0      21.0     61.5      20.2    35      32.0      21.0     60.0      21.7          False           False
       16   3.0          a                154             0.65 1.198043e-19                0.16    24      27.0      25.0     49.0      43.6    74      30.0      27.0     53.0      28.1    56      34.5      27.0     62.0      21.5    35      32.0      27.0     60.0      21.1          False           False
       16   3.0          c                154             0.71 5.059993e-25                0.19    24      27.0      25.0     49.0      43.6    74      30.0      26.0     53.0      28.7    56      35.5      27.0     61.5      19.9    35      32.0      27.0     60.0      20.5          False           False
       16   3.0          b                146             0.45 1.055011e-08                0.01    24      31.0      26.0     49.0      44.2    73      30.0      26.0     54.0      29.6    49      36.0      27.0     62.0      21.5    35      33.0      27.0     60.0      21.7          False           False
       16   5.0          a                154             0.65 3.256389e-20                0.15    24      28.0      26.0     49.0      43.6    74      31.0      28.0     53.0      28.1    56      36.5      29.0     62.0      21.5    35      34.0      29.0     60.0      21.1          False           False
       16   5.0          c                154             0.74 3.486265e-28                0.18    24      28.0      26.0     49.0      43.6    74      31.0      28.0     53.0      28.7    56      37.0      29.0     61.5      19.9    35      34.0      29.0     60.0      20.5          False           False
       16   5.0          b                137             0.38 3.717540e-06                0.05    23      33.0      27.0     49.0      44.6    73      32.0      28.0     54.0      29.6    41      36.0      29.0     62.0      22.0    31      35.0      29.0     60.0      23.2          False           False
       32   2.0          a                 31             0.42 1.924413e-02               -0.08     6      26.0      24.0     49.5      40.7    14      28.0      26.0     52.5      28.8    11      29.0      21.0     61.0      21.0    11      29.0      22.0     60.0      22.7          False           False
       32   2.0          c                 31             0.65 7.670119e-05               -0.06     6      26.0      25.0     49.0      39.8    14      28.5      26.0     52.5      28.6    11      31.0      21.0     61.0      19.3    11      31.0      26.0     60.0      22.3          False           False
       32   2.0          b                 31             0.08 6.659209e-01               -0.05     6      31.0      21.0     49.0      40.3    14      27.5      27.0     54.0      29.4    11      29.0      21.0     61.0      18.6    11      30.0      24.0     60.0      23.7          False           False
       32   3.0          a                 31             0.56 9.754462e-04               -0.08     6      27.0      26.0     49.5      40.7    14      29.0      27.0     52.5      28.8    11      30.0      27.0     61.0      21.0    11      31.0      28.0     60.0      22.7           True            True
       32   3.0          c                 31             0.71 7.906150e-06                0.02     6      26.5      26.0     49.0      39.8    14      29.0      27.0     52.5      28.6    11      31.0      27.0     61.0      19.3    11      31.0      28.0     60.0      22.3          False           False
       32   3.0          b                 30             0.17 3.614358e-01               -0.18     6      32.0      26.0     49.0      40.3    14      29.0      27.0     54.0      29.4    10      30.5      27.0     61.0      19.8    11      33.0      27.0     60.0      23.7          False           False
       32   5.0          a                 31             0.65 6.407150e-05               -0.16     6      28.5      26.0     49.5      40.7    14      30.0      29.0     52.5      28.8    11      32.0      28.0     61.0      21.0    11      33.0      29.0     60.0      22.7           True            True
       32   5.0          c                 31             0.74 2.166419e-06               -0.02     6      28.0      26.0     49.0      39.8    14      30.0      29.0     52.5      28.6    11      33.0      28.0     61.0      19.3    11      33.0      29.0     60.0      22.3          False           False
       32   5.0          b                 28             0.07 7.225697e-01               -0.06     6      33.5      28.0     49.0      40.3    14      30.5      29.0     54.0      29.4     8      32.0      28.0     61.5      22.5     9      33.0      29.0     60.0      23.9          False           False

variants where the rostral region's onset precedes the other three: 12 of 18; where every earliest block lies in the rostral third: 11 of 18
Spearman rho of block onset with the row: 0.07 to 0.74, largest p 0.72
  frame as deposited (rostral up, lateral left): rostral region first in 12 of 18 variants
  frame flipped top to bottom: rostral region first in 0 of 18 variants
  frame flipped left to right: rostral region first in 12 of 18 variants
  frame turned 180 degrees: rostral region first in 0 of 18 variants
bleach          roi  peak dF/F 3 V (%)  peak dF/F 8 V (%)  3 V below 8 V
     a       tissue               27.1               50.1           True
     a         full               28.8               46.9           True
     a tissue_unsat               28.0               49.3           True
     b       tissue               27.4               54.0           True
     b         full               29.0               50.8           True
     b tissue_unsat               28.3               52.9           True
3 V below 8 V in 6 of 6 readings; block-median amplitude by region at 3 V and 8 V (16 px, 3 SD, bleach a): R1 43.6 vs 69.9; R2 28.1 vs 53.9; R3 21.5 vs 39.5; R4 21.1 vs 38.0

Result: blocked, data missing (one deposited mouse of three). The results in that one mouse rest on the substitute for AQuA and on the orientation. In the mouse stimulated at both voltages the 3 V response is lower than the 8 V one in all 6 readings (tissue peak 27.1 to 29.0% against 46.9 to 54.0%), and in each of the four regions (block medians 21.1 to 43.6% against 38.0 to 69.9%). At 3 V the rostral region's onset precedes the other three in 12 of 18 variants, all those with the bleaching curve fit outside the response (a and c); with the curve fit to the whole trace (b), which takes in part of a response still 9 to 16% above baseline at 120 s (fig5b-in-vivo-response), it does not. Every earliest block lies in the rostral third in 11 of 18 variants, and block onset rises with the rostro-caudal position in the fits outside the response (rho 0.42 to 0.74). With the frame flipped top to bottom or turned 180 degrees, the rostral region starts first in 0 of 18 variants, so the direction rests on the orientation, as for fig7-rostral-caudal. The two mice stimulated at 3 V only are not deposited. The criterion's partial outcome needs the order in two of three mice, which one mouse cannot give, and its full outcome needs all three, so the criterion cannot be applied. The outcome verified in round 1 was partially reproduced; the round-2 verifier found that the threshold cannot be reached, and the round-3 verifier agreed with the change to blocked, for missing data, with the results in this one mouse reported as above. If the two missing mice are deposited, rostral is to be read from the electrode side, as the criterion says, not from the orientation assumed here.

In [23]:
extra = sorted(set(X.READ) - set(FILES))
print(f"files read: {len(X.READ)}; listed in the header: {len(FILES)}; read but not listed: {extra}; listed but not read: {sorted(set(FILES) - set(X.READ))}")
print(f"total run time {time.time() - T0:.0f} s, peak memory {rss_mb():.0f} MB")
files read: 35; listed in the header: 35; read but not listed: []; listed but not read: []
total run time 151 s, peak memory 1305 MB

Summary¶

Claim Outcome
fig2d-hplc-yield partially reproduced (main peak 77.5 to 83.1% of the pHAb area with a line under each peak, which cuts away 46% of the main peak and 70 to 77% of the second; 65.8 to 69.1% otherwise; volumes not testable without the flow rate)
fig2g-conjugation-ratios blocked: data missing (no spectra of pure AChE or BTX)
fig2e-page-bands reproduced
figs3-size blocked: data missing (no AFM images)
figs5-btx-staining reproduced (by eye; SPARC:75)
fig3d-sensor-on-soma partially reproduced (puncta coincide beyond chance; their place on the somata is not shown)
fig3bc-retention blocked: data missing
figs4-stability blocked: data missing
figs6a-response-time blocked: metadata insufficient (ACh addition time not recorded)
fig4b-michaelis-menten not reproduced (one mouse of three; Km 0.03 to 0.73 uM against 49.24 uM)
fig4b-lod not reproduced (one mouse of three)
figs6b-unit-calibration blocked: data missing
fig4c-control-ph blocked: data missing
fig5b-in-vivo-response not reproduced (dF/F 17 to 40% against 3.7%, on two 3 V recordings)
fig5b-control-minimal blocked: data missing
figs8-control-10v blocked: data missing
fig5c-voltage-dose blocked: data missing
fig5c-ach-concentration blocked: data missing (depends on two blocked claims)
fig5d-pulse-dose blocked: data missing
fig5e-reversibility blocked: data missing
figs7b-in-vitro-reversibility blocked: data missing
fig6-vesamicol partially reproduced (one experiment of four; reduction 70 to 89%)
figs9-aqua-vs-roi blocked: not runnable (AQuA)
figs10-control-8v blocked: data missing
fig7-rostral-caudal partially reproduced (rostral to caudal to lateral order holds; times do not; block onsets in place of AQuA)
fig7-peak-timing reproduced (11.8 to 18.1 s from region onset, within 9 to 16.5 s in 30 of 36 variants; none from stimulation onset; block onsets in place of AQuA; whether reading (ii) stands is asked of a reader)
figs12-3v-propagation blocked: data missing (one mouse of three, so the criterion's count cannot be made; in that mouse 3 V is lower than 8 V and, with the frame rostral up, rostral starts first in 12 of 18 variants; block onsets in place of AQuA)
figs16-af647-stable reproduced (resting on the channel assignment)
figs13-two-photon blocked: data missing

A failure to reproduce here may be a failure of this attempt, not of the paper: see the reasoning and the differences from the paper's method.

How the analysis differs from the paper's. The ROIs of Figs. 5 and 6 are drawn by hand in the paper and not given; whole-tissue, whole-frame, saturation-free and cell-sized block ROIs are used instead. The stimulation onset is taken from Fig. 6A and 7A (10.45 s, frame 19) for every in vivo recording, as the files do not record it; the ACh addition in the ex vivo recordings is taken as the largest one-frame rise. The frame interval is run at the paper's 0.55 s and at the 0.50 s the files record. Fig. 4B is fit on one mouse of three and 8 concentrations; Fig. 5B on two 3 V recordings whose identity with the paper's three mice is not known; Fig. 6 on one experiment of four. Colocalisation is judged by eye with a threshold rule from the claims file, a background and masks chosen here. AQuA (MATLAB, with parameters the paper does not give) was not run; for Fig. 7 and S12 the onset and peak of 16 x 16 pixel blocks, grouped into rostral, middle, caudal and lateral regions, stand in for its events, on the frame as deposited (rostral up), an assumption on which the direction of propagation rests. The HPLC flow rate is not given, so the retention volumes are not tested; the end of the second peak is taken where its descent ends.

What was found about the datasets. SPARC:108 holds a part of the paper's data: one of three calibration mice, one of four vesamicol experiments, the 3 V and 8 V recordings of the AQuA mouse (as two subjects, sub-2 and sub-3, of one ganglion), one 10 V recording with a single stimulation, and none of the control nanosensor, pH, 5 V, pulse-number, repeated-stimulation, AFM, stability, two-photon or fiber data. The primary manifest.xlsx names 40 of its 50 files under names that are not in the dataset, seven of the eight calibration files lack an extension, and the sheet describes the calibration recordings as electrical stimulation. The recordings carry no channel labels, no spatial scale, no stimulation or addition times, and, for the files resaved in ImageJ, no frame times; the files that keep frame times show 0.50 s, where the paper uses 0.55 s. Many tissue pixels saturate in the sub-6 recordings (69% at some frame after washout). In SPARC:75 the high-magnification BTX stack has 50 empty planes out of 62. SPARC:108 names the bioRxiv preprint, not the PNAS paper, as its originating article; SPARC:75 names none.