Reproducing Powell et al. (2021) from Zenodo record 3924718¶

Paper. Powell D, Haddad SA, Gorur-Shandilya S, Marder E (2021). Coupling between fast and slow oscillator circuits in Cancer borealis is temperature-compensated. eLife 10:e60454. doi:10.7554/elife.60454. The claims file (claims/powell-2021.yaml) was written from the version of record (Europe PMC, PMC7889077) with its figure supplements, and from the paper's code, https://github.com/marderlab/gastric at commit fa07d36a7e57fc7787a9a8e2fed72300b1a8e6e2.

Dataset. ZENODO:3924718, DOI 10.5281/zenodo.3924718, record 3924718. The paper's data statement cites https://zenodo.org/record/3924718, this record, and the deposit has no other version (concept 3924717 has the one version 3924718), so it is pinned. Files read: evoked_data.mat whole (72,856,015 bytes, MD5 7b4062371133a07e373900cde8c42b15, checked on loading), the zip directories of the eleven zip files (their central directories only, not their contents), and the first 200 kB of the first ABF file of 941_003.zip and 941_006.zip and of 901_046_0006.abf in 901_046.zip, for their headers. Those partial reads have no MD5 to check.

What the record holds. evoked_data.mat holds the sorted PD, LG and DG spike times, the saline temperature and a stimulation mask (1 kHz) of the ten evoked preparations of the paper's second set (Methods, N = 10, 2017). The zip files hold the raw ABF recordings of nine of those ten (no zip for 901_005) and of two preparations recorded in June 2019 (941_003, 941_006) that are in no set the paper describes, with no spike annotations. The spontaneous set (nine preparations of Haddad and Marder 2018) and the set with the pyloric pacemaker hyperpolarized (nine preparations, 2020) are not in the record. The record has no README; its description is the paper's abstract.

Burst rule. The Methods keep bursts of at least 5 spikes (LG, DG) or 2 (PD); the paper's code (crabsort.computePeriods) compares the count with the number of ISIs in the burst, so it keeps bursts of at least 6 or 3 spikes. Every claim is tested under the Methods rule, as the claims file states it, and the code's rule is shown as a variant.

Claim Tested
fig2-spontaneous-11-to-30 Blocked: data missing (spontaneous set not in the record)
fig2a-less-regular-at-high-temperature Blocked: data missing (spontaneous set not in the record)
fig3-evoked-7-to-21-in-9-of-10 Tested
fig3s1-spontaneous-and-evoked-similar Tested on three of its four preparations (no spike times of 941_006)
fig4b-periods-decrease-all-preps Tested
fig4c-q10-about-2 Tested
fig4c-q10-pd-lg-not-different Tested
fig4s1-slowdown-after-stimulation Tested
fig4s2-gastric-without-pyloric-pacemaker Blocked: data missing (PD-hyperpolarized set not in the record)
fig4s2-rhythm-counts Blocked: data missing (PD-hyperpolarized set not in the record)
fig5a-example-ratios Tested
fig5d-lg-pd-integer-coupled Tested
fig5d-dg-pd-not-coupled Tested
fig5e-lg-area-exceeds-dg Tested
fig5f-ratio-independent-of-temperature Tested
fig5f-ratio-range Tested
fig6b-lg-phase-locked Tested
fig6b-lg-start-counts Tested
fig6b-lg-phase-constant Tested
fig6c-lg-spiking-drops-near-pd-end Tested
fig6e-dg-not-phase-locked Tested
fig6f-dg-spiking-no-drop Tested
In [1]:
import time
import zipfile
import zlib
import re
import resource

import fsspec
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from scipy import stats

import stg

pd.set_option("display.width", 200)
pd.set_option("display.max_columns", 40)
np.seterr(all="ignore")

started = time.time()
raw = stg.fetch()      # whole file into memory, MD5 checked against the record's list
preps = stg.load(raw)
del raw
names = [p["name"] for p in preps]
print(f"evoked_data.mat read and MD5 checked ({stg.FILE_MD5}); {len(preps)} preparations, "
      f"{time.time() - started:.0f} s")

# Bursts under the Methods rule (main) and the code's rule (variant), module stg.
B = stg.all_bursts(preps, "spikes")
BC = stg.all_bursts(preps, "isis")


def seed(claim, k=0):
    return zlib.crc32(f"powell-2021/{claim}".encode()) + k
evoked_data.mat read and MD5 checked (7b4062371133a07e373900cde8c42b15); 10 preparations, 75 s

Data check¶

The record's file list, then what evoked_data.mat holds. Each check of the description against the values is stated under its output.

In [2]:
import requests
rec = requests.get(f"https://zenodo.org/api/records/{stg.RECORD}", timeout=60).json()
files = pd.DataFrame([{"key": f["key"], "size_GB": f["size"] / 1e9, "md5": f["checksum"]} for f in rec["files"]])
print("Record", rec["id"], "| version:", rec["metadata"].get("version"), "| published:", rec["metadata"]["publication_date"],
      "| resource type:", rec["metadata"]["resource_type"], "| access:", rec["metadata"]["access_right"])
print(files.sort_values("key").to_string(index=False))
print("Total size: %.1f GB" % files.size_GB.sum())

zip_rows = []
for key in sorted(files.key):
    if not key.endswith(".zip"):
        continue
    z, fh = stg.zip_listing(key)
    with fh:
        info = z.infolist()
        rawf = sorted(i.filename for i in info if i.filename.endswith((".abf", ".crab")))
        other = sorted(i.filename.rsplit("/", 1)[-1].rsplit(".", 1)[-1] for i in info
                       if not i.filename.endswith("/") and not i.filename.endswith((".abf", ".crab")))
        zip_rows.append({"zip": key, "abf": sum(f.endswith(".abf") for f in rawf), "crab": sum(f.endswith(".crab") for f in rawf),
                         "first": rawf[0].rsplit("/", 1)[-1], "last": rawf[-1].rsplit("/", 1)[-1],
                         "other_files": dict(pd.Series(other).value_counts()),
                         "first_file_date": str(z.getinfo(rawf[0]).date_time[:3])})
zips = pd.DataFrame(zip_rows)
print(zips.to_string(index=False))
Record 3924718 | version: None | published: 2020-07-01 | resource type: {'title': 'Journal article', 'type': 'publication', 'subtype': 'article'} | access: open
            key  size_GB                                  md5
    901_046.zip 3.815190 md5:bc3662739ff94c69beb3e03f313df180
    901_049.zip 2.452115 md5:d1a80a9bce6350ad219effb472ad8284
    901_052.zip 2.423325 md5:03be00c3b0f82efccbb231faccea9265
    901_062.zip 3.194388 md5:6b1b82f4616d0c797787c02829e1f9ee
    901_080.zip 2.459582 md5:84e159261a781c8c561373247b047e73
    901_086.zip 2.857877 md5:0fe35dd0585614ea103098daac9fccff
    901_095.zip 3.099507 md5:3efd4f995699351511fd630a0fddf6c5
    901_098.zip 1.698692 md5:383bce9766063ea995b72f0a8e821894
    932_151.zip 1.349871 md5:8f59bdcaa1a08c446548573e4d91242f
    941_003.zip 2.568056 md5:f9a31a4a613b224e5866f3256511a7f7
    941_006.zip 1.331234 md5:4b5aafe76daa9919e43facce3b0bee52
evoked_data.mat 0.072856 md5:7b4062371133a07e373900cde8c42b15
Total size: 27.3 GB
        zip  abf  crab             first              last                                                other_files first_file_date
901_046.zip  127     0  901_046_0000.abf  901_046_0126.abf           {'mat': 6, 'DS_Store': 4, 'snr': 2, 'common': 1}   (2017, 9, 29)
901_049.zip    0    55 901_049_0000.crab 901_049_0054.crab {'mat': 5, 'DS_Store': 4, 'common': 1, 'job': 1, 'snr': 1}   (2019, 3, 13)
901_052.zip    0    51 901_052_0000.crab 901_052_0050.crab           {'mat': 4, 'DS_Store': 2, 'common': 1, 'snr': 1}   (2019, 3, 14)
901_062.zip    0   101 901_062_0000.crab 901_062_0100.crab           {'DS_Store': 4, 'mat': 4, 'common': 1, 'snr': 1}   (2019, 3, 20)
901_080.zip    0    67 901_080_0000.crab 901_080_0066.crab           {'mat': 4, 'DS_Store': 2, 'common': 1, 'snr': 1}   (2019, 3, 20)
901_086.zip    0    77 901_086_0000.crab 901_086_0076.crab           {'mat': 3, 'DS_Store': 2, 'snr': 2, 'common': 1}   (2019, 3, 21)
901_095.zip    0    78 901_095_0000.crab 901_095_0077.crab           {'mat': 4, 'DS_Store': 2, 'common': 1, 'snr': 1}   (2019, 3, 26)
901_098.zip   45     0  901_098_0000.abf  901_098_0044.abf           {'mat': 4, 'DS_Store': 2, 'common': 1, 'snr': 1}  (2017, 12, 18)
932_151.zip   63     0  932_151_0000.abf  932_151_0062.abf           {'mat': 3, 'DS_Store': 2, 'common': 1, 'snr': 1}    (2019, 5, 2)
941_003.zip  124     0  941_003_0000.abf  941_003_0123.abf                        {'mat': 3, 'DS_Store': 2, 'snr': 1}   (2019, 6, 11)
941_006.zip   63     0  941_006_0000.abf  941_006_0062.abf                        {'mat': 4, 'DS_Store': 2, 'snr': 1}   (2019, 6, 12)

The record has 12 files: evoked_data.mat and eleven zips of raw recordings. Zenodo types the record as a journal article, not a dataset. The zips hold raw recordings, as ABF files or as crabsort .crab files, and the crabsort network files (network/<nerve>/*.mat, the trained spike classifiers). Whether the .crab files carry spike annotations was not examined; the ABF-only zips (901_046, 901_098, 932_151, 941_003, 941_006) carry none. The number of raw files per preparation differs from the number of files stacked in evoked_data.mat in some zips (printed above and in the next table). There is no 901_005.zip, so one of the ten preparations has spike times but no raw data. 941_003 and 941_006 are not among the ten preparations of getEvokedData.m and their files date from June 2019 (the zip dates, and the ABF headers below), while the paper's evoked preparations are from 2017 and the hyperpolarization set from 2020.

In [3]:
import struct
# Recording date in the ABF header: ABF2 uFileStartDate (offset 16), ABF1 lFileStartDate (offset 20), YYYYMMDD.
for key, member in [("941_003.zip", "941_003/941_003_0000.abf"), ("941_006.zip", "941_006/941_006_0000.abf"),
                    ("901_046.zip", "901_046/901_046_0006.abf"), ("901_098.zip", "901_098/901_098_0000.abf"),
                    ("932_151.zip", "932_151/932_151_0000.abf")]:
    z, fh = stg.zip_listing(key)
    with fh:
        head = z.open(member).read(200_000)
    abf2 = head[:4] == b"ABF2"
    date = struct.unpack("<I", head[16:20])[0] if abf2 else struct.unpack("<i", head[20:24])[0]
    strings = [x.decode() for x in re.findall(rb"[ -~]{4,}", head) if len(x) < 40]
    print(member, "| format:", head[:4], "| recording date in header:", date,
          "| channel-like names:", sorted(set(x for x in strings if re.fullmatch(r"(IN \d+|Temp|Vm_\w+|Iout_\w+)", x))))
941_003/941_003_0000.abf | format: b'ABF2' | recording date in header: 20190611 | channel-like names: ['IN 10', 'IN 12', 'IN 13', 'IN 14', 'IN 5', 'IN 6', 'IN 7', 'IN 8', 'IN 9', 'Iout_A', 'Temp', 'Vm_A1', 'Vm_A2', 'Vm_B1', 'Vm_B2']
941_006/941_006_0000.abf | format: b'ABF2' | recording date in header: 20190612 | channel-like names: ['IN 10', 'IN 11', 'IN 12', 'IN 13', 'IN 14', 'IN 5', 'IN 6', 'IN 7', 'IN 8', 'IN 9', 'Iout_A', 'Temp', 'Vm_A1', 'Vm_A2', 'Vm_B1', 'Vm_B2']
901_046/901_046_0006.abf | format: b'ABF ' | recording date in header: 20170828 | channel-like names: []
901_098/901_098_0000.abf | format: b'ABF ' | recording date in header: 20171214 | channel-like names: []
932_151/932_151_0000.abf | format: b'ABF ' | recording date in header: 20190502 | channel-like names: []

941_003 and 941_006 were recorded on 11 and 12 June 2019 (header dates), as ABF2 files with intracellular channels (Vm_A1 to Vm_B2, Iout_A) and analog inputs named only IN 5 to IN 14 and Temp, so the nerves are not named in the files. 901_046 and 901_098 were recorded in August and December 2017, as the Methods say of the evoked set. 932_151, one of the ten evoked preparations, was recorded on 2 May 2019 by its header, while the Methods say the evoked preparations came from crabs caught in 2017. The ABF1 files carry no channel names in the header read here.

In [4]:
rows = []
for p, b, bc in zip(preps, B, BC):
    m = p["mask"]
    z = np.flatnonzero(~m)
    runs = np.split(z, np.flatnonzero(np.diff(z) > 1) + 1) if len(z) else []
    run_s = np.array([len(r) / 1e3 for r in runs])
    rows.append({
        "prep": p["name"], "objects": f'{p["experiment_object"]}/{p["filename_object"]}',
        "files": len(p["file_names"]), "first_file": p["file_names"][0], "last_file": p["file_names"][-1],
        "duration_s": len(p["temperature"]) / 1e3,
        "T_min": p["temperature"].min(), "T_max": p["temperature"].max(),
        "PD_spikes": len(p["PD"]), "LG_spikes": len(p["LG"]), "DG_spikes": len(p["DG"]),
        "last_spike_s": max(np.max(p[k]) if len(p[k]) else 0 for k in ("PD", "LG", "DG")),
        "PD_bursts": len(b["PD"]["starts"]), "LG_bursts": len(b["LG"]["starts"]), "DG_bursts": len(b["DG"]["starts"]),
        "LG_bursts_code": len(bc["LG"]["starts"]), "DG_bursts_code": len(bc["DG"]["starts"]),
        "mask0_runs": len(runs), "mask0_run_s_median": np.median(run_s) if len(runs) else np.nan,
        "mask0_frac": 1 - m.mean(), "empty_fields": ",".join(p["empty_fields"]),
    })
check = pd.DataFrame(rows)
print(check.round(2).to_string(index=False))
print("\nPreparation names, in order:", names)
print("getEvokedData.m lists (sorted):", stg.PREPS, "| same:", names == stg.PREPS)
print("Every 1 kHz sample has a file code:", all((p["file_codes"] > 0).all() for p in preps),
      "| file codes run in order:", all((np.diff(p["file_codes"].astype(int)) >= 0).all() for p in preps))
print("Samples per file (s):", sorted({round(np.bincount(p["file_codes"])[1:].mean() / 1e3, 1) for p in preps}))
print("Spike times smaller than the one before, in the file's order (all three are sorted on loading here):")
print(pd.DataFrame({p["name"]: {**{k: 0 for k in ("PD", "LG", "DG")}, **p["unsorted"]} for p in preps}).T.to_string())
# getEvokedData.m sorts PD and LG but not DG: DG bursts (code's rule) in the file's order against sorted.
for p, bc in zip(preps, BC):
    if "DG" in p["file_order"]:
        try:
            n_file = len(stg.bursts(p["file_order"]["DG"], stg.IBI["DG"], stg.MIN_N["DG"], "isis")["starts"])
        except ValueError as e:
            n_file = f"error: {e}"
        print(f"  {p['name']}: DG bursts, code rule, sorted {len(bc['DG']['starts'])}, file order {n_file}")
print("Peak memory so far: %.1f GB" % (resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1e6))
   prep objects  files   first_file    last_file  duration_s  T_min  T_max  PD_spikes  LG_spikes  DG_spikes  last_spike_s  PD_bursts  LG_bursts  DG_bursts  LG_bursts_code  DG_bursts_code  mask0_runs  mask0_run_s_median  mask0_frac  empty_fields
901_005    1/11     66 901_005_0000 901_005_0065     7899.94   6.91  23.25     166742      36069          0       7899.33      13513        344          0             344               0         143                 7.0        0.13 T,time_offset
901_046    2/12    127 901_046_0000 901_046_0126    15203.92   6.70  23.19     130391      73842      28483      15203.38      25134       1041        808            1027             782         119                 7.0        0.05 T,time_offset
901_049    3/13     55 901_049_0000 901_049_0054     6600.00   6.87  21.15     131533      20606      19798       6599.40      10242        269        408             268             404          50                 7.0        0.05 T,time_offset
901_052    4/14     51 901_052_0000 901_052_0050     6120.00   6.18  21.34      73526      41793      21621       6119.51      10710        578        597             577             576          54                 7.0        0.06 T,time_offset
901_062    5/15     58 901_062_0000 901_062_0057     6960.00   6.58  19.30      59889      14664      40697       6959.91       9369        539        484             529             481          65                 7.0        0.06 T,time_offset
901_080    6/16     67 901_080_0000 901_080_0066     8040.00   6.49  21.20      89090      24798      22053       8039.82      11043        266        235             263             235          89                 7.0        0.08 T,time_offset
901_086    7/17     77 901_086_0000 901_086_0076     9240.00   5.88  21.30     104641      29777      39380       9239.21       7645        272        152             268             149          53                 7.0        0.04 T,time_offset
901_095    8/18     78 901_095_0000 901_095_0077     9360.00   6.09  21.23      98994      18145      23411       9359.66      11126        296        447             287             399          93                 7.0        0.07 T,time_offset
901_098    9/19     45 901_098_0000 901_098_0044     5400.00   6.24  21.22      65850      13595      11496       5399.98       5820        243        298             243             273          86                 7.0        0.11 T,time_offset
932_151   10/20     63 932_151_0000 932_151_0062     7560.00   6.98  21.24     106472      16226      21573       7559.99      10202        300        380             296             368          77                 7.0        0.07 T,time_offset

Preparation names, in order: ['901_005', '901_046', '901_049', '901_052', '901_062', '901_080', '901_086', '901_095', '901_098', '932_151']
getEvokedData.m lists (sorted): ['901_005', '901_046', '901_049', '901_052', '901_062', '901_080', '901_086', '901_095', '901_098', '932_151'] | same: True
Every 1 kHz sample has a file code: True | file codes run in order: True
Samples per file (s): [np.float64(119.7), np.float64(120.0)]
Spike times smaller than the one before, in the file's order (all three are sorted on loading here):
         PD  LG  DG
901_005   0   0   0
901_046   0   0  23
901_049   0   0  39
901_052   0   0   1
901_062   0   0   1
901_080   0   0  50
901_086   0   0   2
901_095   0   0   2
901_098   0   0   1
932_151   0   0  10
  901_046: DG bursts, code rule, sorted 782, file order 784
  901_049: DG bursts, code rule, sorted 404, file order 405
  901_052: DG bursts, code rule, sorted 576, file order 576
  901_062: DG bursts, code rule, sorted 481, file order 481
  901_080: DG bursts, code rule, sorted 235, file order 241
  901_086: DG bursts, code rule, sorted 149, file order 149
  901_095: DG bursts, code rule, sorted 399, file order 400
  901_098: DG bursts, code rule, sorted 273, file order 273
  932_151: DG bursts, code rule, sorted 368, file order 366
Peak memory so far: 1.4 GB

The ten preparations are the ten of getEvokedData.m, in its sorted order, and each filename category list runs from file 0000 without gaps. The zips hold as many raw files as are stacked, except the .crab zip of 901_062, which holds 101 files against 58 stacked. Spike times run to the end of each recording. The PD and LG spike times are sorted in the file, but the DG spike times of nine preparations are not (1 to 50 times smaller than the time before, 129 in all; printed above). This notebook sorts all three on loading. getEvokedData.m sorts PD and LG only, so the paper's code took DG in the file's order; with the code's burst rule that order gives -2 to +6 DG bursts per preparation, 8 more in all (3675 against 3667). Temperatures range from about 6 to 23 C, as the Methods describe (steps from 7 C, typically to 21 or 23 C). 901_005 has no DG spikes at all (its DG field is empty), so DG analyses have nine preparations. The fields T and time_offset are empty in every preparation. The mask is 0 in runs of about 7 s, which fits the stimulus trains the Methods describe and the code's findStimulationTimes (samples where a channel exceeds 9, the stimulus artefact); the record does not say what the mask is.

In [5]:
held = pd.DataFrame({p["name"]: stg.held_seconds(p) for p in preps}).T
print("Seconds of recording in each temperature bin (centre +- 1 C):")
print(held.round(0).astype(int).to_string())
Seconds of recording in each temperature bin (centre +- 1 C):
           7     9     11    13    15   17    19    21    23
901_005   493   698  2066   680   769  580   614   948  1052
901_046   938  1592  6717  1723   943  881  1100   657   653
901_049   935    78  2789    31   927   21  1024   795     0
901_052   720    69  2272   105  1055   27  1029   844     0
901_062  1473   795  2592    31  1375   35   659     0     0
901_080  1175    58  4340    85  1041   37   661   644     0
901_086  1791    82  5198   267  1065   26   481   330     0
901_095   612    74  5644   164  1433   33   894   505     0
901_098   919    38  2487    29   737   20   675   494     0
932_151  1713   501  2326    26  1240   20   712  1022     0

Most preparations were held at 7, 11, 15, 19 and 21 C (4 C steps, each held 8 to 90 minutes) and pass through 9, 13 and 17 C only on the way, for 20 to 270 s; 901_005 and 901_046 were stepped by 2 C, as the Methods allow, and only they reach 23 C. 901_062 never reaches 21 C.

In [6]:
# Clocks. (1) Stimulation mask against LG spikes: LG bursting should follow each stimulation.
# LG burst starts in the 300 s after the end of each stimulation block (mask 0, blocks separated
# by > 120 s) against the 300 s before its first train, and with the mask shifted by +-1000 s.
def lg_after_before(p, b, shift_s=0.0):
    stim = np.flatnonzero(~p["mask"]) / 1e3 + shift_s
    if len(stim) == 0:
        return np.nan, np.nan
    gaps = np.flatnonzero(np.diff(stim) > 120)
    firsts = np.r_[stim[0], stim[gaps + 1]]
    lasts = np.r_[stim[gaps], stim[-1]]
    s = b["LG"]["starts"]
    after = np.mean([np.sum((s > l) & (s < l + 300)) for l in lasts])
    before = np.mean([np.sum((s > f - 300) & (s < f)) for f in firsts])
    return after, before

rows = []
for p, b in zip(preps, B):
    r = {"prep": p["name"]}
    for sh in (0, 1000, -1000):
        a, bf = lg_after_before(p, b, sh)
        r[f"after_{sh}"], r[f"before_{sh}"] = a, bf
    rows.append(r)
clock = pd.DataFrame(rows)
print("Mean LG bursts in 300 s after the end / before the start of a stimulation block, mask shifted by 0, +1000, -1000 s:")
print(clock.round(1).to_string(index=False))

# (2) Temperature against PD spikes: Spearman correlation of PD burst frequency with temperature at
# the burst start, with the temperature trace as recorded and shifted by 1000 s.
rows = []
for p, b in zip(preps, B):
    per = b["PD"]["periods"]
    ok = np.isfinite(per) & (per < 5)
    st = b["PD"]["starts"][ok]
    r0 = stats.spearmanr(stg.temp_at(p, st), 1 / per[ok])[0]
    sh = np.clip(st + 1000, 0, len(p["temperature"]) / 1e3 - 0.001)
    r1 = stats.spearmanr(stg.temp_at(p, sh), 1 / per[ok])[0]
    rows.append({"prep": p["name"], "rho_aligned": r0, "rho_shift_1000s": r1})
print("\nPD burst frequency against temperature (Spearman rho):")
print(pd.DataFrame(rows).round(3).to_string(index=False))
Mean LG bursts in 300 s after the end / before the start of a stimulation block, mask shifted by 0, +1000, -1000 s:
   prep  after_0  before_0  after_1000  before_1000  after_-1000  before_-1000
901_005     17.1      11.0        10.4         11.6         11.6           9.6
901_046     40.4      15.0        21.8         26.1         22.4          24.5
901_049     37.0       0.6        25.0          3.2         22.8           4.0
901_052     36.8      18.0        29.5         24.7         21.3          15.7
901_062     27.8      21.2        21.2         23.4         17.2          18.0
901_080     24.0       2.8        12.1         10.5          9.1           8.9
901_086     16.4       6.8         3.2          7.2         15.4          13.6
901_095     22.6       6.5        11.6         10.4         10.4           7.4
901_098     27.0       5.7        13.7         13.3          8.2          12.3
932_151     19.6       3.6        10.0         12.9         13.2           7.5

PD burst frequency against temperature (Spearman rho):
   prep  rho_aligned  rho_shift_1000s
901_005        0.961            0.169
901_046        0.940            0.783
901_049        0.830            0.141
901_052        0.830            0.159
901_062        0.943            0.243
901_080        0.919            0.285
901_086        0.916            0.298
901_095        0.870            0.042
901_098        0.952            0.070
932_151        0.889            0.366

In every preparation LG bursts more in the 300 s after a stimulation block than in the 300 s before it (16 to 40 bursts against 0.6 to 21), and the contrast shrinks or reverses when the mask is shifted by 1000 s in either direction (printed above); the mask and the LG spike times share a clock. PD burst frequency follows the temperature trace (rho 0.83 to 0.96) and much less closely when the trace is shifted by 1000 s (0.04 to 0.37, and 0.78 in 901_046, whose temperature changes slowly), so the temperature and the PD spike times share a clock. DG and LG spike times come from the same stacked recordings as PD (one crabsort.consolidate call per preparation in getEvokedData.m); their clock is consistent with the data (DG and LG bursts both follow stimulation, see the LG check) but not separately shown.

In [7]:
# Recordings deposited twice: shared spike times between preparations (PD, to the millisecond),
# and identical durations or spike counts.
dup = []
keys = [np.unique(np.round(p["PD"] * 1e3).astype(np.int64)) for p in preps]
for i in range(len(preps)):
    for j in range(i + 1, len(preps)):
        shared = len(np.intersect1d(keys[i], keys[j])) / min(len(keys[i]), len(keys[j]))
        same_len = len(preps[i]["temperature"]) == len(preps[j]["temperature"])
        same_counts = all(len(preps[i][k]) == len(preps[j][k]) for k in ("PD", "LG"))
        if shared > 0.5 or same_len or same_counts:
            dup.append((names[i], names[j], round(shared, 3), same_len, same_counts))
print("Pairs with > 50% shared PD spike times, equal duration or equal PD and LG counts:", dup if dup else "none")
print("Largest fraction of shared PD spike times (ms) between two preparations: %.3f" % max(
    len(np.intersect1d(keys[i], keys[j])) / min(len(keys[i]), len(keys[j]))
    for i in range(len(preps)) for j in range(i + 1, len(preps))))
Pairs with > 50% shared PD spike times, equal duration or equal PD and LG counts: none
Largest fraction of shared PD spike times (ms) between two preparations: 0.025

No two preparations share their spike trains, durations or spike counts beyond chance coincidences at 1 ms, so no recording is deposited twice in evoked_data.mat.

fig3-evoked-7-to-21-in-9-of-10¶

Gastric mill rhythms could be evoked by dpon stimulation across 7 to 21 C in 9 of 10 preparations.

A rhythm is present in a bin under reading (a) when the preparation has at least one LG burst period there, under (b) when it has at least 30 LG significands (Figure 5's ratios). "Every bin the preparation was held at": the claims file leaves the meaning of "held" to the author; a bin is taken as held when the recording spends at least 120 s in it, the minimum duration of a step in the Methods ("a given temperature step was held for at least 2 minutes" for the spontaneous set; BurstPeriodsVsTime.m uses the same 120 s for the evoked set). Counts under any held bin (more than 0 s) are shown too.

Two readings of which preparations pass are run. (i) As the criterion is worded: a rhythm in every bin from 7 to 21 C that the preparation was held at, so a preparation whose warmest step is 19 C passes if it has a rhythm at every step it had. The Methods allow this ("In some preparations, 19 C was the warmest temperature that a gastric mill rhythm could be evoked"). (ii) As the statement's "across 7 to 21 C" can also be read: the 21 C bin must also be held and have a rhythm.

In [8]:
def rhythm_table(Bx):
    rows = []
    for p, b in zip(preps, Bx):
        lgT = stg.temp_at(p, b["LG"]["starts"])
        ic = stg.integer_coupling(p, b, "LG")
        h = stg.held_seconds(p)
        for c in stg.BIN_CENTRES:
            rows.append({"prep": p["name"], "bin": int(c), "held_s": h[int(c)],
                         "lg_periods": int(np.sum(stg.in_bin(lgT, c) & np.isfinite(b["LG"]["periods"]))),
                         "significands": int(np.sum(stg.in_bin(ic["temp"], c) & np.isfinite(ic["rem"])))})
    return pd.DataFrame(rows)


def evoked_7_21(tab, min_held, reading, need_21):
    out = {}
    for prep, g in tab.groupby("prep", sort=False):
        g = g[(g.bin >= 7) & (g.bin <= 21)]
        held_bins = g[g.held_s >= min_held] if min_held > 0 else g[g.held_s > 0]
        present = held_bins.lg_periods >= 1 if reading == "a" else held_bins.significands >= 30
        need = {7, 21} if need_21 else {7}
        out[prep] = bool(set(held_bins.bin[present]) >= need and present.all())
    return out

for label, Bx in (("Methods rule", B), ("code rule", BC)):
    tab = rhythm_table(Bx)
    if label == "Methods rule":
        tab_main = tab
    print(f"--- {label}: LG burst periods per bin")
    print(tab.pivot(index="prep", columns="bin", values="lg_periods").to_string())
    print("significands per bin")
    print(tab.pivot(index="prep", columns="bin", values="significands").to_string())
    for min_held in (120, 0):
        for reading in ("a", "b"):
            for need_21, rname in ((False, "i, every held bin"), (True, "ii, 21 C required")):
                r = evoked_7_21(tab, min_held, reading, need_21)
                print(f"held >= {min_held} s, reading ({reading}), ({rname}): {sum(r.values())} of 10 with a rhythm "
                      f"at every held bin from 7 to 21 C; without: {[k for k, v in r.items() if not v]}")
--- Methods rule: LG burst periods per bin
bin      7    9    11   13   15  17   19   21  23
prep                                             
901_005  14   29   83   47   69  40   35   26   0
901_046  57  121  248  179  110  84  124   64  53
901_049  15    0   60    0   63   0   73   57   0
901_052  31    1  119   14  135   3  150  124   0
901_062  90   60  206    4  155   0   23    0   0
901_080  44    2   84    0   44   0   47   44   0
901_086  35    1  151    2   57   0   25    0   0
901_095  12    0  110    6   87   0   47   33   0
901_098  28    1   69    0   54   0   52   38   0
932_151  47   17   69    0   53   0   59   54   0
significands per bin
bin      7    9    11   13   15  17   19   21  23
prep                                             
901_005  12   27   78   45   61  38   32   23   0
901_046  55  117  239  175  109  81  119   62  51
901_049   6    0   53    0   61   0   71   57   0
901_052  29    1  116   14  134   3  146  123   0
901_062  86   60  201    4  152   0   18    0   0
901_080  34    2   77    0   42   0   45   42   0
901_086   2    0  137    2   46   0   24    0   0
901_095   1    0   82    5   84   0   44   32   0
901_098  17    0   52    0   51   0   50   36   0
932_151  41   15   69    0   51   0   56   52   0
held >= 120 s, reading (a), (i, every held bin): 9 of 10 with a rhythm at every held bin from 7 to 21 C; without: ['901_086']
held >= 120 s, reading (a), (ii, 21 C required): 8 of 10 with a rhythm at every held bin from 7 to 21 C; without: ['901_062', '901_086']
held >= 120 s, reading (b), (i, every held bin): 2 of 10 with a rhythm at every held bin from 7 to 21 C; without: ['901_005', '901_049', '901_052', '901_062', '901_086', '901_095', '901_098', '932_151']
held >= 120 s, reading (b), (ii, 21 C required): 2 of 10 with a rhythm at every held bin from 7 to 21 C; without: ['901_005', '901_049', '901_052', '901_062', '901_086', '901_095', '901_098', '932_151']
held >= 0 s, reading (a), (i, every held bin): 3 of 10 with a rhythm at every held bin from 7 to 21 C; without: ['901_049', '901_062', '901_080', '901_086', '901_095', '901_098', '932_151']
held >= 0 s, reading (a), (ii, 21 C required): 3 of 10 with a rhythm at every held bin from 7 to 21 C; without: ['901_049', '901_062', '901_080', '901_086', '901_095', '901_098', '932_151']
held >= 0 s, reading (b), (i, every held bin): 1 of 10 with a rhythm at every held bin from 7 to 21 C; without: ['901_005', '901_049', '901_052', '901_062', '901_080', '901_086', '901_095', '901_098', '932_151']
held >= 0 s, reading (b), (ii, 21 C required): 1 of 10 with a rhythm at every held bin from 7 to 21 C; without: ['901_005', '901_049', '901_052', '901_062', '901_080', '901_086', '901_095', '901_098', '932_151']
--- code rule: LG burst periods per bin
bin      7    9    11   13   15  17   19   21  23
prep                                             
901_005  14   29   83   47   69  40   35   26   0
901_046  57  121  246  179  109  84  117   64  49
901_049  15    0   60    0   63   0   73   56   0
901_052  31    1  118   14  135   3  150  124   0
901_062  89   60  205    4  147   0   23    0   0
901_080  44    2   82    0   43   0   47   44   0
901_086  35    1  149    2   56   0   24    0   0
901_095  11    0  108    4   85   0   46   32   0
901_098  28    1   69    0   54   0   52   38   0
932_151  47   17   68    0   53   0   58   52   0
significands per bin
bin      7    9    11   13   15  17   19   21  23
prep                                             
901_005  12   27   78   45   61  38   32   23   0
901_046  55  117  235  175  108  81  112   62  46
901_049   6    0   53    0   61   0   71   56   0
901_052  29    1  115   14  134   3  146  123   0
901_062  86   60  199    4  144   0   18    0   0
901_080  34    2   75    0   41   0   45   42   0
901_086   2    0  134    2   45   0   23    0   0
901_095   0    0   80    3   81   0   43   31   0
901_098  17    0   52    0   51   0   50   36   0
932_151  41   15   68    0   51   0   55   50   0
held >= 120 s, reading (a), (i, every held bin): 9 of 10 with a rhythm at every held bin from 7 to 21 C; without: ['901_086']
held >= 120 s, reading (a), (ii, 21 C required): 8 of 10 with a rhythm at every held bin from 7 to 21 C; without: ['901_062', '901_086']
held >= 120 s, reading (b), (i, every held bin): 2 of 10 with a rhythm at every held bin from 7 to 21 C; without: ['901_005', '901_049', '901_052', '901_062', '901_086', '901_095', '901_098', '932_151']
held >= 120 s, reading (b), (ii, 21 C required): 2 of 10 with a rhythm at every held bin from 7 to 21 C; without: ['901_005', '901_049', '901_052', '901_062', '901_086', '901_095', '901_098', '932_151']
held >= 0 s, reading (a), (i, every held bin): 3 of 10 with a rhythm at every held bin from 7 to 21 C; without: ['901_049', '901_062', '901_080', '901_086', '901_095', '901_098', '932_151']
held >= 0 s, reading (a), (ii, 21 C required): 3 of 10 with a rhythm at every held bin from 7 to 21 C; without: ['901_049', '901_062', '901_080', '901_086', '901_095', '901_098', '932_151']
held >= 0 s, reading (b), (i, every held bin): 1 of 10 with a rhythm at every held bin from 7 to 21 C; without: ['901_005', '901_049', '901_052', '901_062', '901_080', '901_086', '901_095', '901_098', '932_151']
held >= 0 s, reading (b), (ii, 21 C required): 1 of 10 with a rhythm at every held bin from 7 to 21 C; without: ['901_005', '901_049', '901_052', '901_062', '901_080', '901_086', '901_095', '901_098', '932_151']
In [9]:
# The two preparations without a rhythm at 21 C: LG spikes and seconds in the 21 C bin, and the
# warmest bin with an LG burst.
for name in ("901_062", "901_086"):
    p = preps[names.index(name)]
    in21 = stg.in_bin(p["temperature"], 21)
    lg_t = stg.temp_at(p, p["LG"])
    b = B[names.index(name)]
    lgT = stg.temp_at(p, b["LG"]["starts"])
    print(name, "| seconds in 21 C bin: %.0f" % (in21.sum() / 1e3), "| LG spikes there:", int(np.sum(stg.in_bin(lg_t, 21))),
          "| stimulation samples there:", int(np.sum(in21 & ~p["mask"])),
          "| warmest LG burst start at %.1f C" % np.nanmax(lgT))
# 901_062: its stimulation blocks, the temperature during each, and the LG bursts until the next
# block or the end of the recording.
p, b = preps[names.index("901_062")], B[names.index("901_062")]
stim = np.flatnonzero(~p["mask"]) / 1e3
gaps = np.flatnonzero(np.diff(stim) > 120)
firsts, lasts = np.r_[stim[0], stim[gaps + 1]], np.r_[stim[gaps], stim[-1]]
dur = len(p["temperature"]) / 1e3
s_ = b["LG"]["starts"]
for f, l in zip(firsts, lasts):
    nxt = firsts[firsts > l][0] if np.any(firsts > l) else dur
    u = (s_ > l) & (s_ < nxt)
    print(f"901_062 stimulation {f:.0f} to {l:.0f} s at {p['temperature'][int(f * 1e3)]:.2f} to {p['temperature'][int(l * 1e3)]:.2f} C; "
          f"until {nxt:.0f} s: {int(u.sum())} LG bursts, the last at {s_[u].max():.0f} s ({stg.temp_at(p, s_[u].max())[()]:.2f} C)")
print(f"901_062 recording ends at {dur:.0f} s; temperature over the last 600 s {p['temperature'][-600000:].min():.2f} to "
      f"{p['temperature'][-600000:].max():.2f} C, at the end {p['temperature'][-1]:.2f} C; T max {p['temperature'].max():.2f} C")
901_062 | seconds in 21 C bin: 0 | LG spikes there: 0 | stimulation samples there: 0 | warmest LG burst start at 19.1 C
901_086 | seconds in 21 C bin: 330 | LG spikes there: 0 | stimulation samples there: 70001 | warmest LG burst start at 19.1 C
901_062 stimulation 229 to 633 s at 10.36 to 10.47 C; until 840 s: 18 LG bursts, the last at 833 s (6.81 C)
901_062 stimulation 840 to 955 s at 6.85 to 7.06 C; until 2280 s: 94 LG bursts, the last at 2276 s (11.01 C)
901_062 stimulation 2280 to 2395 s at 10.98 to 11.11 C; until 3720 s: 130 LG bursts, the last at 3718 s (14.99 C)
901_062 stimulation 3720 to 3834 s at 14.99 to 15.04 C; until 5069 s: 125 LG bursts, the last at 4865 s (15.41 C)
901_062 stimulation 5069 to 5183 s at 18.99 to 19.02 C; until 6960 s: 113 LG bursts, the last at 6946 s (7.24 C)
901_062 recording ends at 6960 s; temperature over the last 600 s 6.58 to 10.15 C, at the end 7.19 C; T max 19.30 C

Result: reproduced, resting on the reading of "held". Under reading (a), with either burst rule, 9 of the 10 preparations have an evoked LG rhythm at every held bin from 7 to 21 C under reading (i), the criterion's wording, and 8 of 10 under reading (ii), which also requires 21 C. The one that fails under both is 901_086, which was held at 21 C for 330 s, was stimulated there, and has no LG spike there; its warmest LG burst is near 19 C. 901_062 never reaches 21 C: its last stimulation is at 19 C, followed by LG bursting at 19 C and cooling back to about 7 C, so 21 C was never tried (printed above). That fits the Methods' "in some preparations, 19 C was the warmest", and counting it as a success gives the paper's 9. Under reading (b) (at least 30 significands) 2 of 10 pass under either. Counting every bin the temperature passed through, not only bins held at least 120 s, gives fewer (3 and 1 of 10), because the 9, 13 and 17 C bins crossed on ramps have few or no LG bursts; the outcome therefore rests on the 120 s reading of "held", which is stated as an assumption.

fig3s1-spontaneous-and-evoked-similar¶

In 4 of 10 evoked preparations a spontaneous gastric mill rhythm was seen at 11 C before stimulation; in three of these four the spontaneous and evoked rhythms were similar in LG spike and burst timing and in cycle period.

The stretches are those of fig_within_prep_spont_evoked_comparison.m (commit fa07d36): for each of 941_006, 901_086, 901_080 and 901_062, file 0000 as the spontaneous stretch, and files 0029, 0032, 0012 and 0020 as the evoked ones. 941_006 has no spike times in the record (its zip holds raw ABF files only), so three of the four can be tested; their LG spikes in a file are those within the file's samples in evoked_data.mat (filename). LG burst periods under the Methods rule (the criterion), with the code's rule and the script's own call (computePeriods with its default minimum of 1 ISI, bursts of at least 2 spikes) as variants; mean and SD (N - 1, MATLAB's nanstd) per stretch. Similar under reading (a) when each mean lies within one SD of the other, (b) when the mean plus or minus SD intervals overlap. The criterion needs three similar of four and one not; with k similar of the three tested, the four give k or k + 1, so it can hold only if k is 2 or 3.

The first count (4 of 10 with a spontaneous rhythm) is checked on the ten evoked preparations: LG burst periods ending before the first stimulation, in the 11 C bin.

In [10]:
def file_window(p, fname):
    k = p["file_names"].index(fname) + 1
    idx = np.flatnonzero(p["file_codes"] == k)
    return idx[0] / 1e3, (idx[-1] + 1) / 1e3

rows = []
for p, b in zip(preps, B):
    t0 = np.flatnonzero(~p["mask"])[0] / 1e3
    s, per = b["LG"]["starts"], b["LG"]["periods"]
    pre = np.isfinite(per) & (s + np.nan_to_num(per) <= t0)
    T = stg.temp_at(p, s)
    rows.append({"prep": p["name"], "first_stim_s": round(t0), "T_at_first_stim": round(float(p["temperature"][int(t0 * 1e3)]), 2),
                 "LG_spikes_before": int(np.sum(p["LG"] < t0)), "LG_periods_before": int(pre.sum()),
                 "LG_periods_before_in_11C_bin": int(np.sum(pre & stg.in_bin(T, 11))),
                 "T_of_those_starts": f"{np.min(T[pre]):.2f}-{np.max(T[pre]):.2f}" if pre.any() else ""})
pre_tab = pd.DataFrame(rows)
print(pre_tab.to_string(index=False))
print("Evoked preparations with LG burst periods before the first stimulation in the 11 C bin:",
      int((pre_tab.LG_periods_before_in_11C_bin > 0).sum()), "of 10;",
      pre_tab.prep[pre_tab.LG_periods_before_in_11C_bin > 0].tolist(),
      "| with any before the first stimulation:", int((pre_tab.LG_periods_before > 0).sum()))

SPONT = {"941_006": "0029", "901_086": "0032", "901_080": "0012", "901_062": "0020"}
rules = {"Methods (5 spikes)": dict(min_n=5, count="spikes"), "code (5 ISIs)": dict(min_n=5, count="isis"),
         "script (1 ISI)": dict(min_n=1, count="isis")}
rows = []
for name, ev in SPONT.items():
    if name not in names:
        print(name, "has no spike times in the record; not tested")
        continue
    p = preps[names.index(name)]
    for stretch, fn in (("spontaneous", "0000"), ("evoked", ev)):
        a, z = file_window(p, f"{name}_{fn}")
        sp = p["LG"][(p["LG"] >= a) & (p["LG"] < z)]
        isi = np.diff(sp)
        r = {"prep": name, "stretch": stretch, "file": fn, "T_mean": round(float(p["temperature"][int(a * 1e3):int(z * 1e3)].mean()), 2),
             "stim_samples": int((~p["mask"][int(a * 1e3):int(z * 1e3)]).sum()), "LG_spikes": len(sp),
             "ISI_median_s": round(float(np.median(isi)), 3), "ISI_over_1s": int(np.sum(isi > 1))}
        for rn, kw in rules.items():
            per = stg.bursts(sp, stg.IBI["LG"], **kw)["periods"]
            r[f"{rn} n"] = int(np.isfinite(per).sum())
            r[f"{rn} mean"] = np.nanmean(per)
            r[f"{rn} sd"] = np.nanstd(per, ddof=1)
        rows.append(r)
s1 = pd.DataFrame(rows)
print(s1.round(2).to_string(index=False))

for rn in rules:
    sim = {"a": [], "b": []}
    for name in s1.prep.unique():
        g = s1[s1.prep == name].set_index("stretch")
        m1, s1d, m2, s2d = g.loc["spontaneous", f"{rn} mean"], g.loc["spontaneous", f"{rn} sd"], g.loc["evoked", f"{rn} mean"], g.loc["evoked", f"{rn} sd"]
        if abs(m1 - m2) <= min(s1d, s2d):
            sim["a"].append(name)
        if (m1 - s1d <= m2 + s2d) and (m2 - s2d <= m1 + s1d):
            sim["b"].append(name)
    for rd in ("a", "b"):
        k = len(sim[rd])
        print(f"{rn}, reading ({rd}): similar {k} of 3 tested {sim[rd]}; with 941_006 the four give {k} or {k + 1}; "
              f"3 of 4 possible: {k in (2, 3)}")

# Variant: the spontaneous stretch as every LG burst before the first stimulation in the 11 C bin.
for name in s1.prep.unique():
    p, b = preps[names.index(name)], B[names.index(name)]
    t0 = np.flatnonzero(~p["mask"])[0] / 1e3
    s, per = b["LG"]["starts"], b["LG"]["periods"]
    pre = np.isfinite(per) & (s + np.nan_to_num(per) <= t0) & stg.in_bin(stg.temp_at(p, s), 11)
    print(f"{name}, all pre-stimulation LG periods at 11 C (Methods rule): n = {int(pre.sum())}, "
          f"{np.mean(per[pre]):.2f} +- {np.std(per[pre], ddof=1):.2f} s")
   prep  first_stim_s  T_at_first_stim  LG_spikes_before  LG_periods_before  LG_periods_before_in_11C_bin T_of_those_starts
901_005           246            10.91                 1                  0                             0                  
901_046           600             6.92                 0                  0                             0                  
901_049           360             7.15                39                  0                             0                  
901_052           288            10.53                13                  0                             0                  
901_062           229            10.36               169                 13                            13       10.41-10.77
901_080           950            10.73              1293                 18                            18       10.69-10.92
901_086          1203             6.88              6492                 48                            43        6.95-11.25
901_095          1201            11.04                54                  0                             0                  
901_098            62            10.53                 0                  0                             0                  
932_151           868             7.16               953                 16                             0         9.83-9.93
Evoked preparations with LG burst periods before the first stimulation in the 11 C bin: 3 of 10; ['901_062', '901_080', '901_086'] | with any before the first stimulation: 4
941_006 has no spike times in the record; not tested
   prep     stretch file  T_mean  stim_samples  LG_spikes  ISI_median_s  ISI_over_1s  Methods (5 spikes) n  Methods (5 spikes) mean  Methods (5 spikes) sd  code (5 ISIs) n  code (5 ISIs) mean  code (5 ISIs) sd  script (1 ISI) n  script (1 ISI) mean  script (1 ISI) sd
901_086 spontaneous 0000   11.16             0       1107          0.04            4                     2                    23.99                   0.73                2               23.99              0.73                 2                23.99               0.73
901_086      evoked 0032   10.92             0       1118          0.04            9                     7                    11.21                   2.91                7               11.21              2.91                 7                11.21               2.91
901_080 spontaneous 0000   10.86             0        548          0.06            8                     5                    16.10                   6.89                5               16.10              6.89                 5                16.10               6.89
901_080      evoked 0012    7.25             0        655          0.08           10                     6                    15.57                   2.91                6               15.57              2.91                 6                15.57               2.91
901_062 spontaneous 0000   10.56             0         90          0.73           15                     6                    16.57                   5.67                6               16.57              5.67                10                 9.94               3.54
901_062      evoked 0020   11.11             0        563          0.08           15                    13                     7.47                   0.83               13                7.47              0.83                13                 7.47               0.83
Methods (5 spikes), reading (a): similar 1 of 3 tested ['901_080']; with 941_006 the four give 1 or 2; 3 of 4 possible: False
Methods (5 spikes), reading (b): similar 1 of 3 tested ['901_080']; with 941_006 the four give 1 or 2; 3 of 4 possible: False
code (5 ISIs), reading (a): similar 1 of 3 tested ['901_080']; with 941_006 the four give 1 or 2; 3 of 4 possible: False
code (5 ISIs), reading (b): similar 1 of 3 tested ['901_080']; with 941_006 the four give 1 or 2; 3 of 4 possible: False
script (1 ISI), reading (a): similar 1 of 3 tested ['901_080']; with 941_006 the four give 1 or 2; 3 of 4 possible: False
script (1 ISI), reading (b): similar 2 of 3 tested ['901_080', '901_062']; with 941_006 the four give 2 or 3; 3 of 4 possible: True
901_086, all pre-stimulation LG periods at 11 C (Methods rule): n = 43, 21.72 +- 5.32 s
901_080, all pre-stimulation LG periods at 11 C (Methods rule): n = 18, 17.52 +- 7.75 s
901_062, all pre-stimulation LG periods at 11 C (Methods rule): n = 13, 16.16 +- 4.90 s

Result: not reproduced. Of the three preparations with spike times, under the Methods burst rule only 901_080 has similar spontaneous and evoked LG periods (16.1 +- 6.9 s against 15.6 +- 2.9 s), under both readings. 901_086 (24.0 +- 0.7 s spontaneous, from two periods, against 11.2 +- 2.9 s) and 901_062 (16.6 +- 5.7 s against 7.5 +- 0.8 s) are not similar under either. With one similar of three, the four preparations can give at most two similar, whatever 941_006 shows, so the criterion fails. The script's own burst call (bursts of at least 2 spikes) makes 901_062 similar under reading (b) (9.9 +- 3.5 s against 7.5 +- 0.8 s), which would leave three of four possible if 941_006 were also similar; that is a variant. The evoked stretch the script selects for 901_080 (file 0012) is at 7.25 C, against 10.86 C for its spontaneous stretch (printed above); the comparison follows the script, so the two stretches of this preparation are not at the same temperature. Among the ten evoked preparations, 3 (901_062, 901_080, 901_086) have LG burst periods before their first stimulation in the 11 C bin, not 4. A fourth, 932_151, has 16 LG periods before stimulation at 9.83 to 9.93 C, just outside the bin, so with it 4 of 10 have pre-stimulation bursting. The fourth preparation of the paper's script is 941_006, which is not one of the ten. The ISIs are shown and not judged, as the criterion sets.

fig4b-periods-decrease-all-preps¶

Both LG (gastric mill) and PD (pyloric) burst periods decrease with increasing temperature, a coordinated decrease seen in all 10 preparations.

Per preparation and bin, the mean period of bursts starting in the bin (PD periods above 5 s and LG above 50 s removed, fig_burst_period.m). Reading (a): the warmest bin's mean is below the coldest's; (b): Spearman rho of bin mean against bin temperature is negative.

In [11]:
def period_means(p, b, neuron, limit):
    per = b[neuron]["periods"].copy()
    per[per > limit] = np.nan
    T = stg.temp_at(p, b[neuron]["starts"])
    out = {}
    for c in stg.BIN_CENTRES:
        v = per[stg.in_bin(T, c) & np.isfinite(per)]
        if len(v):
            out[int(c)] = float(np.mean(v))
    return out

for label, Bx in (("Methods rule", B), ("code rule", BC)):
    rows = []
    for p, b in zip(preps, Bx):
        r = {"prep": p["name"]}
        for neuron, limit in (("PD", 5), ("LG", 50)):
            m = period_means(p, b, neuron, limit)
            cs = sorted(m)
            r[f"{neuron}_coldest"] = f"{cs[0]}C {m[cs[0]]:.2f}"
            r[f"{neuron}_warmest"] = f"{cs[-1]}C {m[cs[-1]]:.2f}"
            r[f"{neuron}_a"] = m[cs[-1]] < m[cs[0]]
            r[f"{neuron}_rho"] = stats.spearmanr(cs, [m[c] for c in cs])[0]
            r[f"{neuron}_b"] = r[f"{neuron}_rho"] < 0
        rows.append(r)
    dec = pd.DataFrame(rows)
    print(f"--- {label} (bin means of burst period, s)")
    print(dec.round(3).to_string(index=False))
    for rd in ("a", "b"):
        print(f"reading ({rd}): {int((dec[f'PD_{rd}'] & dec[f'LG_{rd}']).sum())} of 10 decrease for both PD and LG")
    if label == "Methods rule":
        dec_main = dec
--- Methods rule (bin means of burst period, s)
   prep PD_coldest PD_warmest  PD_a  PD_rho  PD_b LG_coldest LG_warmest  LG_a  LG_rho  LG_b
901_005    7C 1.44   23C 0.28  True  -1.000  True   7C 16.90  21C 12.02  True  -0.643  True
901_046    7C 0.85   23C 0.33  True  -1.000  True   7C 12.47   23C 5.71  True  -0.933  True
901_049    7C 0.87   21C 0.36  True  -0.976  True   7C 33.06   21C 6.75  True  -0.900  True
901_052    7C 0.77   21C 0.39  True  -1.000  True   7C 16.84   21C 4.98  True  -0.952  True
901_062    7C 1.18   19C 0.40  True  -1.000  True   7C 15.57  19C 12.64  True  -0.657  True
901_080    7C 1.57   21C 0.33  True  -1.000  True   7C 21.14   21C 6.19  True  -1.000  True
901_086    7C 2.00   21C 0.56  True  -1.000  True   7C 40.16   19C 8.14  True  -0.943  True
901_095    7C 1.51   21C 0.42  True  -0.976  True   7C 20.83   21C 9.50  True  -0.943  True
901_098    7C 1.57   21C 0.46  True  -1.000  True   7C 20.27   21C 6.79  True  -1.000  True
932_151    7C 1.23   21C 0.41  True  -1.000  True   7C 19.56   21C 7.55  True  -0.829  True
reading (a): 10 of 10 decrease for both PD and LG
reading (b): 10 of 10 decrease for both PD and LG
--- code rule (bin means of burst period, s)
   prep PD_coldest PD_warmest  PD_a  PD_rho  PD_b LG_coldest LG_warmest  LG_a  LG_rho  LG_b
901_005    7C 1.44   23C 0.28  True  -1.000  True   7C 16.90  21C 12.02  True  -0.643  True
901_046    7C 0.85   23C 0.34  True  -1.000  True   7C 12.47   23C 5.76  True  -0.933  True
901_049    7C 0.94   21C 0.36  True  -0.976  True   7C 33.06   21C 6.87  True  -0.900  True
901_052    7C 0.77   21C 0.39  True  -1.000  True   7C 16.84   21C 4.98  True  -0.952  True
901_062    7C 1.18   19C 0.40  True  -1.000  True   7C 15.75  19C 12.64  True  -0.657  True
901_080    7C 1.57   21C 0.33  True  -1.000  True   7C 21.14   21C 6.19  True  -1.000  True
901_086    7C 2.00   21C 0.56  True  -1.000  True   7C 40.16   19C 8.48  True  -0.943  True
901_095    7C 1.51   21C 0.42  True  -0.976  True   7C 20.06   21C 9.80  True  -0.771  True
901_098    7C 1.57   21C 0.46  True  -1.000  True   7C 20.27   21C 6.79  True  -1.000  True
932_151    7C 1.23   21C 0.41  True  -1.000  True   7C 19.56   21C 7.64  True  -0.829  True
reading (a): 10 of 10 decrease for both PD and LG
reading (b): 10 of 10 decrease for both PD and LG
In [12]:
fig, ax = plt.subplots(1, 2, figsize=(10, 4))
for k, (neuron, limit) in enumerate((("PD", 5), ("LG", 50))):
    allv = []
    for p, b in zip(preps, B):
        m = period_means(p, b, neuron, limit)
        ax[k].plot(list(m), list(m.values()), "o-", alpha=.6)
        allv += list(m.values())
    ax[k].set_yscale("log"); ax[k].set_xlabel("Temperature bin (C)"); ax[k].set_ylabel(f"{neuron} mean burst period (s)")
    print(f"{neuron} bin means range {min(allv):.3f} to {max(allv):.3f} s, all plotted")
plt.tight_layout(); plt.show()
PD bin means range 0.279 to 2.003 s, all plotted
LG bin means range 4.981 to 48.409 s, all plotted
No description has been provided for this image

Result: reproduced. In all 10 preparations the mean PD and LG burst periods in the warmest bin are below those in the coldest bin, and the Spearman correlation of bin mean with temperature is negative for both (PD rho -0.98 to -1, LG rho -0.64 to -1), under both burst rules.

fig4c-q10-about-2¶

Most preparations (8 of 10) had a cycle period Q10 of about 2 for both the pyloric and the gastric mill rhythm.

The Methods' Q10 (one per temperature, from the mean frequency at T against 11 C, averaged per preparation) is the main analysis; the code's per-burst Q10 is a variant. Which temperatures enter the Methods' Q10 is not fixed by the claims file. The Methods compute it "at every temperature", the temperatures being the steps of the protocol, held "for the duration of evoked gastric mill activity" (Methods, "Spontaneous and evoked gastric mill rhythm temperature ranges"). Most preparations pass through 9, 13 and 17 C only on the way between 4 C steps (data check), with 1 to 17 LG bursts there; a Q10 from such a bin next to 11 C is raised to the power 5. Two readings are run: (i) every bin with bursts, (ii) only bins held at least 120 s (the temperature steps). T is the bin centre; as a variant, T and T_11 are the mean measured temperatures at the starts of the bursts in each bin (suffix _mT), since a bin centre can be far from the temperatures a pass-through bin was crossed at.

In [13]:
def q10_table(Bx):
    rows = []
    for p, b in zip(preps, Bx):
        steps = [c for c, s in stg.held_seconds(p).items() if s >= 120]
        r = {"prep": p["name"]}
        for neuron, limit in (("PD", 5), ("LG", 50)):
            r[f"{neuron}_all_bins"], q_all = stg.q10_methods(p, b, neuron, limit)
            r[f"{neuron}_steps"], _ = stg.q10_methods(p, b, neuron, limit, bins=steps)
            r[f"{neuron}_all_bins_mT"], _ = stg.q10_methods(p, b, neuron, limit, temperature="measured")
            r[f"{neuron}_steps_mT"], _ = stg.q10_methods(p, b, neuron, limit, bins=steps, temperature="measured")
            r[f"{neuron}_code"] = stg.q10_code(p, b, neuron, limit)
            r[f"{neuron}_per_bin"] = {c: round(v, 2) for c, v in q_all.items()}
            _, q_mT = stg.q10_methods(p, b, neuron, limit, temperature="measured")
            per = b[neuron]["periods"].copy()
            per[per > limit] = np.nan
            T = stg.temp_at(p, b[neuron]["starts"])
            r[f"{neuron}_per_bin_mT"] = {c: (round(float(np.mean(T[stg.in_bin(T, c) & np.isfinite(per)])), 2),
                                             int(np.sum(stg.in_bin(T, c) & np.isfinite(per))), round(v, 2))
                                         for c, v in q_mT.items()}
        rows.append(r)
    return pd.DataFrame(rows)

ranges = {"a (1.8-2.2)": (1.8, 2.2), "b (1.5-2.5)": (1.5, 2.5)}
q10s = {}
for label, Bx in (("Methods rule", B), ("code rule", BC)):
    q = q10_table(Bx)
    q10s[label] = q
    print(f"--- {label}")
    print(q[["prep", "PD_all_bins", "LG_all_bins", "PD_steps", "LG_steps", "PD_all_bins_mT", "LG_all_bins_mT",
             "PD_steps_mT", "LG_steps_mT", "PD_code", "LG_code"]].round(3).to_string(index=False))
    for version in ("all_bins", "steps", "all_bins_mT", "steps_mT", "code"):
        for rname, (lo, hi) in ranges.items():
            n = int((q[f"PD_{version}"].between(lo, hi) & q[f"LG_{version}"].between(lo, hi)).sum())
            print(f"  Q10 {version:9s} range {rname}: {n} of 10 with both PD and LG in range")
print("\nPer-bin LG Q10s, Methods rule, every bin (the outliers come from the 9, 13 and 17 C bins):")
print(q10s["Methods rule"][["prep", "LG_per_bin"]].to_string(index=False))
print("\nPer-bin LG Q10s, Methods rule, every bin, with T the mean measured temperature of the bursts in the bin;")
print("(mean T of the bin's bursts, bursts, Q10) per bin; the 11 C bin's mean T is given first:")
for p, b, (_, r) in zip(preps, B, q10s["Methods rule"].iterrows()):
    per = b["LG"]["periods"].copy()
    per[per > 50] = np.nan
    T = stg.temp_at(p, b["LG"]["starts"])
    u = stg.in_bin(T, 11) & np.isfinite(per)
    print(f"{r.prep}: 11 C bin mean T {np.mean(T[u]):.2f} ({int(u.sum())} bursts) |", r.LG_per_bin_mT)
--- Methods rule
   prep  PD_all_bins  LG_all_bins  PD_steps  LG_steps  PD_all_bins_mT  LG_all_bins_mT  PD_steps_mT  LG_steps_mT  PD_code  LG_code
901_005        3.250        1.511     3.250     1.511           3.228           1.523        3.228        1.523    2.645    1.120
901_046        2.014        1.941     2.014     1.941           1.998           1.934        1.998        1.934    2.107    1.801
901_049        2.354        4.651     1.967     4.651           2.314           4.564        1.927        4.564    2.061    2.448
901_052        1.664       16.639     1.596     2.590           1.643         705.065        1.584        2.560    1.532    2.106
901_062        2.404        3.065     2.316     2.177           2.530           3.288        2.605        2.785    2.278    2.052
901_080        3.383        3.170     3.321     2.529           3.306           3.859        3.338        2.564    2.370    2.369
901_086        2.520       39.016     2.592     3.572           2.503          69.906        2.582        3.545    2.733    1.340
901_095        2.431        4.017     2.577     4.017           2.437           4.451        2.555        4.451    1.933    1.879
901_098        2.527        2.555     2.514     2.555           2.505           2.495        2.492        2.495    2.339    2.198
932_151        2.187        1.676     2.132     1.676           2.204           1.717        2.166        1.717    1.925    2.000
  Q10 all_bins  range a (1.8-2.2): 1 of 10 with both PD and LG in range
  Q10 all_bins  range b (1.5-2.5): 2 of 10 with both PD and LG in range
  Q10 steps     range a (1.8-2.2): 1 of 10 with both PD and LG in range
  Q10 steps     range b (1.5-2.5): 3 of 10 with both PD and LG in range
  Q10 all_bins_mT range a (1.8-2.2): 1 of 10 with both PD and LG in range
  Q10 all_bins_mT range b (1.5-2.5): 2 of 10 with both PD and LG in range
  Q10 steps_mT  range a (1.8-2.2): 1 of 10 with both PD and LG in range
  Q10 steps_mT  range b (1.5-2.5): 3 of 10 with both PD and LG in range
  Q10 code      range a (1.8-2.2): 3 of 10 with both PD and LG in range
  Q10 code      range b (1.5-2.5): 8 of 10 with both PD and LG in range
--- code rule
   prep  PD_all_bins  LG_all_bins  PD_steps  LG_steps  PD_all_bins_mT  LG_all_bins_mT  PD_steps_mT  LG_steps_mT  PD_code  LG_code
901_005        3.251        1.511     3.251     1.511           3.228           1.523        3.228        1.523    2.648    1.120
901_046        1.992        1.924     1.992     1.924           1.977           1.917        1.977        1.917    2.089    1.797
901_049        2.470        4.653     2.023     4.653           2.431           4.565        1.984        4.565    2.084    2.452
901_052        1.663       16.764     1.595     2.587           1.642         717.610        1.583        2.557    1.530    2.106
901_062        2.405        3.028     2.316     2.126           2.529           3.248        2.603        2.730    2.276    2.014
901_080        3.385        3.068     3.323     2.511           3.308           3.658        3.340        2.540    2.371    2.372
901_086        2.519       37.566     2.590     3.522           2.502          67.042        2.580        3.502    2.731    1.324
901_095        2.431        1.544     2.579     1.544           2.438           1.518        2.556        1.518    1.933    1.796
901_098        2.530        2.555     2.518     2.555           2.508           2.495        2.497        2.495    2.339    2.198
932_151        2.191        1.664     2.137     1.664           2.209           1.707        2.171        1.707    1.924    1.993
  Q10 all_bins  range a (1.8-2.2): 1 of 10 with both PD and LG in range
  Q10 all_bins  range b (1.5-2.5): 3 of 10 with both PD and LG in range
  Q10 steps     range a (1.8-2.2): 1 of 10 with both PD and LG in range
  Q10 steps     range b (1.5-2.5): 3 of 10 with both PD and LG in range
  Q10 all_bins_mT range a (1.8-2.2): 1 of 10 with both PD and LG in range
  Q10 all_bins_mT range b (1.5-2.5): 3 of 10 with both PD and LG in range
  Q10 steps_mT  range a (1.8-2.2): 1 of 10 with both PD and LG in range
  Q10 steps_mT  range b (1.5-2.5): 3 of 10 with both PD and LG in range
  Q10 code      range a (1.8-2.2): 1 of 10 with both PD and LG in range
  Q10 code      range b (1.5-2.5): 8 of 10 with both PD and LG in range

Per-bin LG Q10s, Methods rule, every bin (the outliers come from the 9, 13 and 17 C bins):
   prep                                                                    LG_per_bin
901_005          {7: 2.58, 9: 2.49, 13: 1.07, 15: 0.99, 17: 1.09, 19: 1.13, 21: 1.23}
901_046 {7: 1.86, 9: 1.69, 13: 2.55, 15: 2.14, 17: 2.0, 19: 1.86, 21: 1.72, 23: 1.72}
901_049                                       {7: 9.77, 15: 3.82, 19: 2.94, 21: 2.07}
901_052          {7: 2.63, 9: 98.74, 13: 5.56, 15: 2.93, 17: 1.8, 19: 2.32, 21: 2.48}
901_062                              {7: 1.98, 9: 2.18, 13: 6.62, 15: 3.06, 19: 1.49}
901_080                               {7: 3.91, 9: 5.73, 15: 2.4, 19: 1.91, 21: 1.89}
901_086                             {7: 6.69, 9: 180.79, 13: 0.93, 15: 3.66, 19: 3.0}
901_095                            {7: 1.41, 13: 12.09, 15: 2.87, 19: 1.94, 21: 1.77}
901_098                                       {7: 2.31, 15: 3.55, 19: 2.29, 21: 2.07}
932_151                              {7: 2.31, 9: 1.15, 15: 0.93, 19: 2.01, 21: 1.98}

Per-bin LG Q10s, Methods rule, every bin, with T the mean measured temperature of the bursts in the bin;
(mean T of the bin's bursts, bursts, Q10) per bin; the 11 C bin's mean T is given first:
901_005: 11 C bin mean T 10.95 (81 bursts) | {7: (7.11, 13, 2.69), 9: (8.93, 28, 2.48), 13: (12.93, 46, 1.07), 15: (14.97, 69, 0.99), 17: (17.07, 38, 1.08), 19: (19.02, 32, 1.13), 21: (21.0, 25, 1.23)}
901_046: 11 C bin mean T 11.01 (244 bursts) | {7: (6.92, 56, 1.83), 9: (9.08, 120, 1.72), 13: (13.05, 176, 2.5), 15: (14.92, 109, 2.17), 17: (17.15, 81, 1.96), 19: (19.04, 122, 1.85), 21: (21.19, 63, 1.71), 23: (23.07, 52, 1.72)}
901_049: 11 C bin mean T 11.10 (56 bursts) | {7: (7.04, 11, 9.46), 15: (15.13, 62, 3.78), 19: (19.11, 71, 2.94), 21: (21.09, 57, 2.07)}
901_052: 11 C bin mean T 10.89 (117 bursts) | {7: (7.0, 30, 2.7), 9: (9.81, 1, 4919.24), 13: (13.26, 14, 4.26), 15: (15.03, 134, 2.83), 17: (17.42, 3, 1.72), 19: (19.1, 148, 2.27), 21: (21.08, 123, 2.44)}
901_062: 11 C bin mean T 10.84 (205 bursts) | {7: (7.01, 89, 2.04), 9: (9.83, 60, 4.72), 13: (13.1, 4, 5.3), 15: (15.04, 153, 2.9), 19: (19.03, 21, 1.47)}
901_080: 11 C bin mean T 10.86 (79 bursts) | {7: (7.05, 41, 4.19), 9: (9.27, 2, 9.04), 15: (15.01, 42, 2.33), 19: (19.1, 45, 1.87), 21: (21.07, 42, 1.87)}
901_086: 11 C bin mean T 11.03 (149 bursts) | {7: (7.01, 20, 6.66), 9: (9.24, 1, 335.35), 13: (12.08, 2, 0.87), 15: (15.02, 53, 3.66), 19: (19.08, 25, 2.98)}
901_095: 11 C bin mean T 10.97 (105 bursts) | {7: (6.86, 10, 1.4), 13: (12.84, 5, 14.41), 15: (15.11, 85, 2.77), 19: (19.1, 45, 1.92), 21: (21.14, 33, 1.75)}
901_098: 11 C bin mean T 10.89 (67 bursts) | {7: (6.96, 26, 2.35), 15: (15.05, 53, 3.38), 19: (19.24, 51, 2.21), 21: (21.1, 37, 2.04)}
932_151: 11 C bin mean T 10.86 (69 bursts) | {7: (7.13, 45, 2.45), 9: (9.88, 15, 1.32), 15: (15.19, 52, 0.93), 19: (19.35, 57, 1.93), 21: (21.16, 52, 1.94)}

Result: not reproduced. Under the Methods' Q10, the main analysis, 1 of 10 (range 1.8 to 2.2) or 2 of 10 (1.5 to 2.5) preparations have both Q10s near 2 when every bin is used, and 1 or 3 of 10 when only the held steps are used (Methods burst rule; 1 and 3 with the code's); none reaches 8. LG Q10s from every bin reach 16.6 and 39.0 in two preparations, from bins next to 11 C crossed during a ramp. The code's per-burst Q10, a variant, gives 8 of 10 in the wider range (1.5 to 2.5) under both burst rules and 3 (Methods rule) or 1 (code rule) of 10 in the narrower one, so the paper's count matches the code's computation under the wider reading of "~2", not the Methods' formula. With T and T_11 the mean measured temperatures of the bursts in each bin, in place of the bin centres, the counts are the same (1 and 2 of 10 over every bin, 1 and 3 over the held steps). The per-preparation LG Q10s from every bin grow larger (705 in 901_052, 70 in 901_086), because the per-bin Q10 of their 9 C bin does: one LG burst each, at 9.81 C against 10.89 C at 11 C in 901_052 (per-bin Q10 4919) and at 9.24 C against 11.03 C in 901_086 (335), printed above. The exponent 10 / (T - T_11) is then larger in size than with the bin centres (-9.3 and -5.6 against -5).

fig4c-q10-pd-lg-not-different¶

The apparent Q10s of the pyloric (PD) and gastric mill (LG) burst frequencies do not differ (paired t-test, p = 0.235, N = 10, t = 1.27).

A claim of absence: two-sided paired t-test of the per-preparation Methods Q10s, reproduced when p >= 0.05. The code's per-burst Q10 and the held-steps reading are shown as variants.

In [14]:
for label in ("Methods rule", "code rule"):
    q = q10s[label]
    for version in ("all_bins", "steps", "code"):
        ok = q[f"PD_{version}"].notna() & q[f"LG_{version}"].notna()
        t, pval = stats.ttest_rel(q[f"PD_{version}"][ok], q[f"LG_{version}"][ok])
        d = q[f"PD_{version}"][ok] - q[f"LG_{version}"][ok]
        print(f"{label:12s} Q10 {version:9s}: n = {ok.sum()}, mean PD - LG = {d.mean():+.3f}, t = {t:.3f}, p = {pval:.3f}")
Methods rule Q10 all_bins : n = 10, mean PD - LG = -5.351, t = -1.418, p = 0.190
Methods rule Q10 steps    : n = 10, mean PD - LG = -0.294, t = -0.739, p = 0.479
Methods rule Q10 code     : n = 10, mean PD - LG = +0.261, t = 1.204, p = 0.259
code rule    Q10 all_bins : n = 10, mean PD - LG = -4.944, t = -1.342, p = 0.212
code rule    Q10 steps    : n = 10, mean PD - LG = -0.027, t = -0.070, p = 0.946
code rule    Q10 code     : n = 10, mean PD - LG = +0.275, t = 1.272, p = 0.235

Result: reproduced. The paired t-test on the Methods' Q10s (every bin) finds no difference (t = -1.42, p = 0.19, n = 10, Methods burst rule; printed above). The code's per-burst Q10 with the code's burst rule gives t = 1.272, p = 0.235, the paper's values exactly; with the Methods burst rule t = 1.20, p = 0.26. No version tested reaches p < 0.05 (printed above).

fig4s1-slowdown-after-stimulation¶

The evoked gastric mill rhythm slows down (LG burst period lengthens) with time since stimulation.

As gastric.BurstPeriodsVsTime and fig_evoked_slowdown.m: stretches after each stimulation held at one rounded temperature for at least 120 s, LG periods above 30 s removed, time from the first LG burst, each stretch interpolated at 1 s over 0 to 600 s, mean over stretches per temperature, least-squares line of the mean on time. LG bursts with the code's rule of this script (7 ISIs) and the Methods' (5 spikes).

In [15]:
tt = np.arange(0, 601)
slow_res = {}
for label, kw in (("code, 7 ISIs", dict(min_n=7, count="isis")), ("Methods, 5 spikes", dict(min_n=5, count="spikes"))):
    rows, temps, per_prep = [], [], []
    for p in preps:
        lg = stg.bursts(p["LG"], stg.IBI["LG"], **kw)
        for s in stg.stretches_after_stimulation(p, lg):
            ok = np.isfinite(s["periods"])
            if ok.sum() >= 2:
                rows.append(np.interp(tt, s["time"][ok], s["periods"][ok], left=np.nan, right=np.nan))
            else:
                rows.append(np.full(len(tt), np.nan))
            temps.append(s["temperature"])
            per_prep.append(p["name"])
    A, temps = np.array(rows), np.array(temps)
    fits = []
    for c in stg.BIN_CENTRES:
        sel = temps == c
        if not sel.any():
            continue
        M = np.nanmean(A[sel], 0)
        ok = np.isfinite(M)
        if ok.sum() < 2:
            continue
        slope, icpt = np.polyfit(tt[ok], M[ok], 1)
        r = np.corrcoef(M[ok], slope * tt[ok] + icpt)[0, 1]
        fits.append({"T": int(c), "stretches": int(sel.sum()), "preps": len(set(np.array(per_prep)[sel])),
                     "seconds_with_data": int(ok.sum()), "mean_period_0_60s": np.nanmean(M[:61]),
                     "mean_period_540_600s": np.nanmean(M[540:]), "slope_s_per_s": slope, "r": r})
    fits = pd.DataFrame(fits)
    slow_res[label] = fits
    print(f"--- LG bursts: {label}; {len(temps)} stretches from {len(set(per_prep))} preparations")
    print(fits.round(4).to_string(index=False))
    print(f"positive slope at {int((fits.slope_s_per_s > 0).sum())} of {len(fits)} temperatures")
    even = ~np.isin(temps, stg.BIN_CENTRES)
    print(f"stretches at an even rounded temperature (not in any odd bin, dropped): {int(even.sum())} of {len(temps)}, at {sorted(set(temps[even].tolist()))}")
--- LG bursts: code, 7 ISIs; 64 stretches from 10 preparations
 T  stretches  preps  seconds_with_data  mean_period_0_60s  mean_period_540_600s  slope_s_per_s      r
 7         10      9                601            15.3992               19.6416         0.0060 0.6511
 9          2      2                601             8.7769               10.3877         0.0008 0.1692
11         17     10                601            11.1177               15.0117         0.0059 0.8031
13          2      2                601             6.8318                8.1445        -0.0006 0.1221
15         11     10                601             7.5635               11.4662         0.0059 0.8178
17          2      2                450             7.6063                   NaN         0.0031 0.3398
19         11     10                601             6.6657               10.1239         0.0058 0.6714
21          8      8                601             6.9069               15.7133         0.0171 0.8668
23          1      1                160             4.0949                   NaN         0.0267 0.7733
positive slope at 8 of 9 temperatures
stretches at an even rounded temperature (not in any odd bin, dropped): 0 of 64, at []
--- LG bursts: Methods, 5 spikes; 64 stretches from 10 preparations
 T  stretches  preps  seconds_with_data  mean_period_0_60s  mean_period_540_600s  slope_s_per_s      r
 7         10      9                601            15.3992               19.4066         0.0058 0.6290
 9          2      2                601             8.7769               10.3877         0.0008 0.1692
11         17     10                601            11.0951               15.8418         0.0070 0.8441
13          2      2                601             6.8318                8.1445        -0.0006 0.1221
15         11     10                601             7.5635               11.7020         0.0064 0.8721
17          2      2                450             7.6063                   NaN         0.0031 0.3398
19         11     10                601             6.6657               10.1239         0.0055 0.6623
21          8      8                601             6.9069               12.4558         0.0091 0.6845
23          1      1                180             4.0949                   NaN         0.0276 0.7195
positive slope at 8 of 9 temperatures
stretches at an even rounded temperature (not in any odd bin, dropped): 0 of 64, at []
/tmp/ipykernel_2372/4190143301.py:21: RuntimeWarning: Mean of empty slice
  M = np.nanmean(A[sel], 0)
/tmp/ipykernel_2372/4190143301.py:29: RuntimeWarning: Mean of empty slice
  "mean_period_540_600s": np.nanmean(M[540:]), "slope_s_per_s": slope, "r": r})
/tmp/ipykernel_2372/4190143301.py:21: RuntimeWarning: Mean of empty slice
  M = np.nanmean(A[sel], 0)
/tmp/ipykernel_2372/4190143301.py:29: RuntimeWarning: Mean of empty slice
  "mean_period_540_600s": np.nanmean(M[540:]), "slope_s_per_s": slope, "r": r})

Result: reproduced. The fitted slope of mean LG period on time since stimulation is positive at 8 of the 9 temperatures with data under both burst rules, all but 13 C (slope -0.0006 s per s, two stretches). At the five temperatures with 8 or more stretches (7, 11, 15, 19 and 21 C) the slopes are 0.0055 to 0.0171 s per s with r from 0.63 to 0.87, and the mean period rises from 6.7 to 15.4 s in the first minute to 10.1 to 19.6 s at 9 to 10 minutes. The 9, 13, 17 and 23 C means rest on one or two stretches. No stretch has an even rounded temperature, so the odd-bin filter drops none (printed above).

fig5a-example-ratios¶

In the example preparation the ratio of LG to PD period is close to an integer at both temperatures, about 10 at 7 C and about 11 at 23 C, and PD bursts end shortly before LG bursts start.

Preparation 901_046, files 0006 and 0079 (fig_integer_coupling.m), selected through the per-sample filename codes. Each LG cycle starting in the file, with its mean PD period (gastric.integerCoupling). Reading (a): the cycle whose LG period is closest to the labelled T_LG; (b): the median ratio of the file.

In [16]:
p, b = preps[names.index("901_046")], B[names.index("901_046")]
ic = stg.integer_coupling(p, b, "LG")
ex = {}
for fname, T_LG, label in (("901_046_0006", 9.17, 10.06), ("901_046_0079", 3.44, 10.98)):
    codeval = p["file_names"].index(fname) + 1
    idx = np.flatnonzero(p["file_codes"] == codeval)
    t0, t1 = idx[0] / 1e3, (idx[-1] + 1) / 1e3
    u = (b["LG"]["starts"] >= t0) & (b["LG"]["starts"] < t1)
    starts = b["LG"]["starts"][u]
    pd_end_before = [t - b["PD"]["ends"][b["PD"]["ends"] < t].max() for t in starts]
    df = pd.DataFrame({"LG_start_s": starts - t0, "T_LG": ic["y"][u], "mean_T_PD": ic["x"][u], "ratio": ic["ratio"][u],
                       "PD_end_to_LG_start_s": pd_end_before})
    print(f"{fname}: {t0:.0f}-{t1:.0f} s, mean temperature {p['temperature'][idx].mean():.2f} C, {u.sum()} LG bursts")
    print(df.round(3).to_string(index=False))
    j = np.nanargmin(np.abs(df.T_LG.values - T_LG))
    near = df[np.abs(df.T_LG - df.T_LG.iloc[j]) < 0.01]
    ra, rb = df.ratio.iloc[j], np.nanmedian(df.ratio)
    ex[fname] = (ra, rb)
    for name, r in (("(a) closest cycle", ra), ("(b) median", rb)):
        print(f"  {name}: ratio {r:.3f}; label {label}, within 10%: {abs(r - label) <= 0.1 * label}; "
              f"distance to integer {abs(r - round(r)):.3f}, within 0.2: {abs(r - round(r)) <= 0.2}")
    if len(near) > 1:
        print("  cycles within 0.01 s of the closest T_LG:", near[["T_LG", "mean_T_PD", "ratio"]].round(3).values.tolist())
    print(f"  PD burst end to LG burst start: median {np.median(pd_end_before):.3f} s, range {np.min(pd_end_before):.3f} to {np.max(pd_end_before):.3f} s")
901_046_0006: 720-840 s, mean temperature 6.92 C, 13 LG bursts
 LG_start_s   T_LG  mean_T_PD  ratio  PD_end_to_LG_start_s
      0.468  9.244      0.843 10.961                 0.167
      9.712  8.177      0.890  9.189                 0.139
     17.889  9.989      0.928 10.761                 0.316
     27.878  9.245      0.923 10.016                 0.088
     37.123  9.088      0.908 10.004                 0.099
     46.211  8.140      0.897  9.074                 0.113
     54.351  8.712      0.873  9.979                 0.184
     63.063  8.682      0.859 10.107                 0.165
     71.745  9.284      0.840 11.052                 0.259
     81.029  9.029      0.825 10.942                 0.289
     90.058 10.096      0.843 11.973                 0.245
    100.154 10.609      0.876 12.108                 0.172
    110.763 11.330      0.811 13.977                 0.280
  (a) closest cycle: ratio 10.961; label 10.06, within 10%: True; distance to integer 0.039, within 0.2: True
  (b) median: ratio 10.761; label 10.06, within 10%: True; distance to integer 0.239, within 0.2: False
  cycles within 0.01 s of the closest T_LG: [[9.244, 0.843, 10.961], [9.245, 0.923, 10.016]]
  PD burst end to LG burst start: median 0.172 s, range 0.088 to 0.316 s
901_046_0079: 9444-9564 s, mean temperature 23.07 C, 27 LG bursts
 LG_start_s  T_LG  mean_T_PD  ratio  PD_end_to_LG_start_s
      1.762 3.459      0.316 10.962                 0.094
      5.221 3.424      0.312 10.971                 0.086
      8.645 3.743      0.314 11.911                 0.077
     12.388 3.438      0.316 10.873                 0.048
     15.826 3.768      0.315 11.949                 0.315
     19.594 4.190      0.312 13.414                 0.302
     23.784 3.991      0.316 12.630                 0.130
     27.775 4.393      0.313 14.016                 0.310
     32.168 3.832      0.310 12.370                 0.001
     36.000 4.880      0.314 15.535                 0.119
     40.880 4.407      0.314 14.051                 0.276
     45.287 4.665      0.312 14.958                 0.003
     49.952 4.320      0.309 13.974                 0.287
     54.272 5.090      0.311 16.344                 0.263
     59.362 3.593      0.309 11.634                 0.080
     62.955 4.432      0.314 14.137                 0.268
     67.387 3.946      0.318 12.403                 0.011
     71.333 4.922      0.318 15.501                 0.129
     76.255 5.738      0.311 18.466                 0.285
     81.993 5.180      0.313 16.543                 0.116
     87.173 3.815      0.316 12.073                 0.292
     90.988 6.050      0.312 19.407                 0.004
     97.038 5.049      0.315 16.010                 0.127
    102.087 4.061      0.323 12.563                 0.145
    106.148 8.245      0.318 25.959                 0.313
    114.393 5.167      0.324 15.972                 0.295
    119.560 7.052      0.321 21.991                 0.304
  (a) closest cycle: ratio 10.873; label 10.98, within 10%: True; distance to integer 0.127, within 0.2: True
  (b) median: ratio 14.016; label 10.98, within 10%: False; distance to integer 0.016, within 0.2: True
  PD burst end to LG burst start: median 0.130 s, range 0.001 to 0.315 s

Result: reproduced. Under reading (a), the LG cycle closest to the labelled T_LG gives a ratio of 10.96 at 7 C (label 10.06, distance to an integer 0.04) and 10.87 at 23 C (label 10.98, distance 0.13), both within 10% of the labels and within 0.2 of an integer. Another 7 C cycle with nearly the same T_LG (9.245 against 9.244 s) has ratio 10.02 and mean PD period 0.923 s, close to the label's 0.911 s. Under reading (b) the median ratios are 10.76 and 14.02, which miss. LG bursts start a median 0.17 s (7 C) and 0.13 s (23 C) after the last PD burst end (ranges 0.09 to 0.32 s and 0.001 to 0.32 s); this part is shown, not judged.

fig5d-lg-pd-integer-coupled¶

LG and PD burst periods are significantly integer-coupled at every temperature from 7 to 21 C (two-sample Kolmogorov-Smirnov test against shuffled periods, p < 1e-5, D > 0.24).

Significands pooled over preparations per bin, against shuffled significands: (a) the code's 100 independent draws of LG and mean PD periods; (b) a permutation of the bin's mean PD periods. Each repeated 1000 times; median D and p (asymptotic p, as MATLAB's kstest2). Seeds from the claim id, and four more (+1000 to +4000).

In [17]:
def pooled_coupling(Bx, slow):
    ics = [stg.integer_coupling(p, b, slow) for p, b in zip(preps, Bx)]
    cat = {k: np.concatenate([i[k] for i in ics]) for k in ("x", "y", "temp", "rem", "ratio")}
    cat["prep"] = np.concatenate([np.full(len(i["y"]), k) for k, i in enumerate(ics)])
    return cat


def ks_by_bin(cat, claim, reading, k_seed=0, n_rep=1000):
    rng = np.random.default_rng(seed(claim, k_seed))
    rows = []
    for c in stg.BIN_CENTRES:
        u = stg.in_bin(cat["temp"], c)
        obs = cat["rem"][u]
        obs = obs[np.isfinite(obs)]
        ok = u & np.isfinite(cat["x"]) & np.isfinite(cat["y"])
        if len(obs) < 2:
            continue
        res = stg.ks_shuffled(obs, cat["x"][ok], cat["y"][ok], rng, reading, n_rep)
        rows.append({"T_C": int(c), "n": len(obs), "D": np.median(res[:, 0]), "p": np.median(res[:, 1]),
                     "D_2.5pct": np.percentile(res[:, 0], 2.5), "p_97.5pct": np.percentile(res[:, 1], 97.5)})
    return pd.DataFrame(rows)


ALPHA = 0.05 / 9
claim = "fig5d-lg-pd-integer-coupled"
cat_lg = {"Methods rule": pooled_coupling(B, "LG"), "code rule": pooled_coupling(BC, "LG")}
ks_lg = {}
for label, cat in cat_lg.items():
    for reading in ("draw", "perm"):
        df = ks_by_bin(cat, claim, reading)
        ks_lg[(label, reading)] = df
        sel = df[(df.T_C >= 7) & (df.T_C <= 21)]
        print(f"--- {label}, shuffle {reading}")
        print(df.to_string(index=False, float_format=lambda v: f"{v:.3g}"))
        print(f"7-21 C: all p < 0.05/9: {bool((sel.p < ALPHA).all())}; all D > 0.216: {bool((sel.D > 0.216).all())}; "
              f"all p < 1e-5: {bool((sel.p < 1e-5).all())}; smallest D {sel.D.min():.3f} at {int(sel.T_C[sel.D.idxmin()])} C; largest p {sel.p.max():.2g}")
--- Methods rule, shuffle draw
 T_C    n     D        p  D_2.5pct  p_97.5pct
   7  283 0.351 1.47e-08     0.304   1.53e-06
   9  222 0.346 7.57e-08     0.292   1.07e-05
  11 1104 0.306 4.46e-08     0.251   1.35e-05
  13  245 0.351 2.82e-08     0.291      8e-06
  15  791 0.306  7.7e-08     0.256   1.23e-05
  17  122 0.314 2.56e-05     0.248    0.00181
  19  605 0.281 1.69e-06     0.232   0.000153
  21  427 0.223 0.000487     0.173     0.0138
  23   51 0.162     0.31     0.116      0.723
7-21 C: all p < 0.05/9: True; all D > 0.216: True; all p < 1e-5: False; smallest D 0.223 at 21 C; largest p 0.00049
--- Methods rule, shuffle perm
 T_C    n     D        p  D_2.5pct  p_97.5pct
   7  283 0.336 1.41e-14     0.311   1.44e-12
   9  222 0.342 5.25e-12     0.302      2e-09
  11 1104 0.279 3.86e-38     0.264   4.31e-34
  13  245 0.347 1.55e-13     0.302   2.32e-10
  15  791 0.287 4.48e-29     0.268   2.05e-25
  17  122 0.311 9.61e-06     0.254   0.000578
  19  605  0.26 2.23e-18     0.238   1.58e-15
  21  427 0.199 6.66e-08     0.173    4.3e-06
  23   51 0.176    0.371     0.118       0.85
7-21 C: all p < 0.05/9: True; all D > 0.216: False; all p < 1e-5: True; smallest D 0.199 at 21 C; largest p 9.6e-06
--- code rule, shuffle draw
 T_C    n     D        p  D_2.5pct  p_97.5pct
   7  282  0.35 1.64e-08     0.306   1.27e-06
   9  222 0.346 7.57e-08     0.292   1.07e-05
  11 1089 0.304 5.29e-08     0.258   7.23e-06
  13  243 0.351 3.04e-08     0.291   8.46e-06
  15  777 0.304 9.73e-08     0.252   1.85e-05
  17  122 0.305 4.84e-05     0.235    0.00362
  19  595 0.273 3.81e-06     0.223   0.000309
  21  423 0.222 0.000528     0.171     0.0151
  23   46 0.164    0.335     0.121      0.719
7-21 C: all p < 0.05/9: True; all D > 0.216: True; all p < 1e-5: False; smallest D 0.222 at 21 C; largest p 0.00053
--- code rule, shuffle perm
 T_C    n     D        p  D_2.5pct  p_97.5pct
   7  282 0.337 1.25e-14     0.312    1.3e-12
   9  222 0.347 2.59e-12     0.302      2e-09
  11 1089 0.279 1.12e-37     0.263   2.14e-33
  13  243 0.346 2.46e-13     0.305   1.91e-10
  15  777 0.284  4.5e-28     0.264   3.25e-24
  17  122 0.303 1.82e-05     0.238     0.0016
  19  595  0.25 7.21e-17     0.229      4e-14
  21  423 0.199 8.49e-08     0.175    3.8e-06
  23   46 0.174    0.452      0.13      0.801
7-21 C: all p < 0.05/9: True; all D > 0.216: False; all p < 1e-5: False; smallest D 0.199 at 21 C; largest p 1.8e-05
In [18]:
# Seeds: the claim's own and +1000 to +4000, main reading (Methods rule, the code's draws).
rows = []
for k in (0, 1000, 2000, 3000, 4000):
    df = ks_by_bin(cat_lg["Methods rule"], claim, "draw", k)
    sel = df[(df.T_C >= 7) & (df.T_C <= 21)]
    rows.append({"seed_offset": k, "D_21C": float(sel.D[sel.T_C == 21].iloc[0]), "min_D_7_21": sel.D.min(),
                 "max_p_7_21": sel.p.max(), "holds": bool((sel.p < ALPHA).all() and (sel.D > 0.216).all())})
print(pd.DataFrame(rows).to_string(index=False, float_format=lambda v: f"{v:.4g}"))
 seed_offset  D_21C  min_D_7_21  max_p_7_21  holds
           0 0.2233      0.2233    0.000487   True
        1000 0.2239      0.2239   0.0004666   True
        2000 0.2207      0.2207    0.000593   True
        3000 0.2221      0.2221   0.0005327   True
        4000 0.2214      0.2214   0.0005621   True

Result: reproduced. With the code's shuffle (reading a), every bin from 7 to 21 C is significant at 0.05/9, with median D from 0.223 (21 C) to 0.351 and median p from 1.5e-8 to 4.9e-4 (Methods burst rule); D at 21 C is 0.221 to 0.224 under the five seeds, above the 0.216 bound in each (printed above). The reported p < 1e-5 is not met at 17 and 21 C with the code's 100 draws (median p 2.6e-5 and 4.9e-4); with the permutation shuffle (reading b) p is below 1e-5 at every bin from 7 to 21 C but D at 21 C is 0.199, under the bound. The 23 C bin is not significant (D 0.162, p 0.31), as the paper's range 7 to 21 C implies.

fig5d-dg-pd-not-coupled¶

DG and PD burst periods are not significantly integer-coupled at any temperature (p > 0.02, D < 0.16).

A claim of absence, the same test with DG (the code's shuffle, median over repetitions), at 0.05/9. The permutation shuffle is a variant.

In [19]:
claim = "fig5d-dg-pd-not-coupled"
cat_dg = {"Methods rule": pooled_coupling(B, "DG"), "code rule": pooled_coupling(BC, "DG")}
for label, cat in cat_dg.items():
    for reading in ("draw", "perm"):
        df = ks_by_bin(cat, claim, reading)
        print(f"--- {label}, shuffle {reading}")
        print(df.to_string(index=False, float_format=lambda v: f"{v:.3g}"))
        print(f"bins with p < 0.05/9: {df.T_C[df.p < ALPHA].tolist()}; D range {df.D.min():.3f}-{df.D.max():.3f}; p range {df.p.min():.2g}-{df.p.max():.2g}")
rows = []
for k in (0, 1000, 2000, 3000, 4000):
    df = ks_by_bin(cat_dg["Methods rule"], claim, "draw", k)
    rows.append({"seed_offset": k, "bins_significant": df.T_C[df.p < ALPHA].tolist(), "min_p": df.p.min(), "max_D": df.D.max()})
print(pd.DataFrame(rows).to_string(index=False, float_format=lambda v: f"{v:.3g}"))
--- Methods rule, shuffle draw
 T_C    n     D     p  D_2.5pct  p_97.5pct
   7  331  0.12 0.207      0.07      0.833
   9  154 0.123 0.298    0.0715      0.905
  11 1173 0.115 0.162    0.0651      0.816
  13   54 0.129 0.579    0.0837      0.959
  15  737 0.133 0.082    0.0863       0.51
  17   59 0.125 0.578    0.0798      0.966
  19  536 0.126 0.125    0.0773      0.678
  21  319 0.123 0.187    0.0726      0.803
  23   12  0.16 0.925      0.12      0.996
bins with p < 0.05/9: []; D range 0.115-0.160; p range 0.082-0.92
--- Methods rule, shuffle perm
 T_C    n      D        p  D_2.5pct  p_97.5pct
   7  331  0.103   0.0567    0.0695      0.389
   9  154  0.117    0.228    0.0714      0.813
  11 1173 0.0835 0.000511    0.0614     0.0231
  13   54  0.148    0.559    0.0926      0.968
  15  737  0.104 0.000577    0.0841     0.0102
  17   59  0.136    0.618    0.0847      0.979
  19  536  0.097   0.0119    0.0746     0.0965
  21  319  0.103   0.0614    0.0721      0.366
  23   12   0.25    0.786     0.167      0.991
bins with p < 0.05/9: [11, 15]; D range 0.084-0.250; p range 0.00051-0.79
--- code rule, shuffle draw
 T_C    n     D     p  D_2.5pct  p_97.5pct
   7  324 0.118 0.225    0.0699      0.837
   9  154 0.134 0.212    0.0786      0.834
  11 1111 0.119 0.141    0.0671      0.789
  13   47 0.148 0.455    0.0891      0.952
  15  712 0.129 0.098    0.0834      0.558
  17   58 0.134 0.494    0.0855      0.942
  19  515 0.126 0.129    0.0758      0.705
  21  296 0.121 0.212    0.0721      0.817
  23   12  0.19  0.79      0.14      0.975
bins with p < 0.05/9: []; D range 0.118-0.190; p range 0.098-0.79
--- code rule, shuffle perm
 T_C    n      D        p  D_2.5pct  p_97.5pct
   7  324 0.0988   0.0795    0.0679      0.431
   9  154   0.13    0.138    0.0779      0.721
  11 1111 0.0837 0.000766    0.0648     0.0179
  13   47   0.17    0.466    0.0851      0.994
  15  712 0.0997  0.00153    0.0801     0.0196
  17   58  0.155    0.454    0.0862      0.977
  19  515 0.0932   0.0212    0.0718      0.134
  21  296  0.098     0.11    0.0676      0.495
  23   12   0.25    0.786     0.167      0.991
bins with p < 0.05/9: [11, 15]; D range 0.084-0.250; p range 0.00077-0.79
 seed_offset bins_significant  min_p  max_D
           0               []  0.082   0.16
        1000               [] 0.0844   0.16
        2000               []  0.079   0.16
        3000               [] 0.0839   0.16
        4000               [] 0.0783   0.16

Result: reproduced. With the code's shuffle no temperature bin reaches p < 0.05/9 (median p 0.082 to 0.925, D 0.115 to 0.160, Methods burst rule), under all five seeds (smallest p 0.078 to 0.084). p > 0.02 holds everywhere and D < 0.16 everywhere but the 23 C bin (12 DG cycles, D 0.160, or 0.19 with the code's burst rule). With the permutation shuffle (variant) the 11 and 15 C bins are significant (p 5e-4 and 6e-4), so the absence depends on the shuffle.

fig5e-lg-area-exceeds-dg¶

The area between the significand c.d.f. and the diagonal is larger for LG/PD than for DG/PD at every temperature, and the DG/PD areas overlap those of shuffled periods.

As plotIntegerCoupling.m: per preparation and bin with at least 30 significands, the mean over 100 bootstrap resamples of the area; the shuffled area from as many significands drawn from one shuffle of all gastric against all mean PD periods; mean and SEM over preparations. A bin with one preparation has no SEM; its interval is its value. That makes overlap there a point test, so the count is also given over the bins with more than one preparation. The code's shuffle for the area (one permutation of all periods, or independent draws as in its KS shuffle) cannot be told from the figure; both are run.

In [20]:
def areas(cat, rng, shuffle="perm"):
    ok = np.isfinite(cat["x"]) & np.isfinite(cat["y"])
    if shuffle == "perm":
        rand_rem = np.mod(cat["y"] / cat["x"][rng.permutation(len(cat["x"]))], 1)
    else:   # independent draws with replacement, as the KS shuffle of plotIntegerCoupling.m
        xo, yo = cat["x"][ok], cat["y"][ok]
        rand_rem = np.mod(yo[rng.integers(0, len(yo), len(yo))] / xo[rng.integers(0, len(xo), len(xo))], 1)
    rand_rem = rand_rem[np.isfinite(rand_rem)]
    A = np.full((len(stg.BIN_CENTRES), 10), np.nan)
    R = A.copy()
    for i, c in enumerate(stg.BIN_CENTRES):
        for j in range(10):
            v = cat["rem"][stg.in_bin(cat["temp"], c) & (cat["prep"] == j)]
            v = v[np.isfinite(v)]
            if len(v) < 30:
                continue
            rr = rand_rem[rng.integers(0, len(rand_rem), len(v))]
            A[i, j] = stg.integerness(v, rng)
            R[i, j] = stg.integerness(rr, rng)
    def ms(X):
        n = np.sum(np.isfinite(X), 1)
        sem = np.where(n > 1, np.nanstd(X, 1, ddof=1) / np.sqrt(n), 0.0)
        return np.nanmean(X, 1), sem, n
    return ms(A), ms(R)


def area_test(k_seed=0, Bcat=None, shuffle="perm"):
    rng = np.random.default_rng(seed("fig5e-lg-area-exceeds-dg", k_seed))
    Bcat = Bcat or (cat_lg["Methods rule"], cat_dg["Methods rule"])
    (lm, ls, ln), (lrm, lrs, _) = areas(Bcat[0], rng, shuffle)
    (dm, dsem, dn), (drm, drs, _) = areas(Bcat[1], rng, shuffle)
    t = pd.DataFrame({"T": stg.BIN_CENTRES, "LG_n": ln, "LG_area": lm, "LG_sem": ls, "DG_n": dn, "DG_area": dm, "DG_sem": dsem,
                      "shufDG_area": drm, "shufDG_sem": drs, "shufLG_area": lrm, "shufLG_sem": lrs})
    both = t.LG_area.notna() & t.DG_area.notna()
    t["LG_gt_DG"] = np.where(both, t.LG_area > t.DG_area, None)
    t["DG_overlaps_shufDG"] = np.where(t.DG_area.notna(),
        (t.DG_area - t.DG_sem <= t.shufDG_area + t.shufDG_sem) & (t.DG_area + t.DG_sem >= t.shufDG_area - t.shufDG_sem), None)
    t["DG_overlaps_shufLG"] = np.where(t.DG_area.notna(),
        (t.DG_area - t.DG_sem <= t.shufLG_area + t.shufLG_sem) & (t.DG_area + t.DG_sem >= t.shufLG_area - t.shufLG_sem), None)
    return t

t = area_test()
print(t.to_string(index=False, float_format=lambda v: f"{v:.4f}"))
dgb = t[t.DG_area.notna()]
print(f"LG > DG in {int((t.LG_gt_DG == True).sum())} of {int(t.LG_gt_DG.notna().sum())} bins with both; "
      f"DG overlaps its shuffle in {int((dgb.DG_overlaps_shufDG == True).sum())} of {len(dgb)} bins "
      f"(LG's shuffle: {int((dgb.DG_overlaps_shufLG == True).sum())})")
rows = []
for k in (0, 1000, 2000, 3000, 4000):
    tk = area_test(k)
    d = tk[tk.DG_area.notna()]
    rows.append({"seed_offset": k, "LG_gt_DG_all": bool((tk.LG_gt_DG.dropna() == True).all()),
                 "DG_overlap_bins": int((d.DG_overlaps_shufDG == True).sum()), "of": len(d)})
print(pd.DataFrame(rows).to_string(index=False))
tc = area_test(0, (cat_lg["code rule"], cat_dg["code rule"]))
dc = tc[tc.DG_area.notna()]
print(f"code burst rule: LG > DG in all bins with both: {bool((tc.LG_gt_DG.dropna() == True).all())}; "
      f"DG overlaps its shuffle in {int((dc.DG_overlaps_shufDG == True).sum())} of {len(dc)} bins")
# Bins with more than one DG preparation only (a single preparation has no SEM), and the shuffle by
# independent draws in place of one permutation, under the five seeds.
rows = []
for shuffle in ("perm", "draw"):
    for k in (0, 1000, 2000, 3000, 4000):
        tk = area_test(k, shuffle=shuffle)
        d = tk[tk.DG_area.notna()]
        d2 = d[d.DG_n > 1]
        rows.append({"shuffle": shuffle, "seed_offset": k, "LG_gt_DG_all": bool((tk.LG_gt_DG.dropna() == True).all()),
                     "DG_overlap_bins": int((d.DG_overlaps_shufDG == True).sum()), "of": len(d),
                     "overlap_bins_n_gt_1": int((d2.DG_overlaps_shufDG == True).sum()), "of_n_gt_1": len(d2)})
print(pd.DataFrame(rows).to_string(index=False))
/home/runner/work/encore-registry/encore-registry/executed/powell-2021/.venv/lib/python3.13/site-packages/numpy/lib/_nanfunctions_impl.py:1998: RuntimeWarning: Degrees of freedom <= 0 for slice.
  var = nanvar(a, axis=axis, dtype=dtype, out=out, ddof=ddof,
/tmp/ipykernel_2372/1286705825.py:23: RuntimeWarning: Mean of empty slice
  return np.nanmean(X, 1), sem, n
 T  LG_n  LG_area  LG_sem  DG_n  DG_area  DG_sem  shufDG_area  shufDG_sem  shufLG_area  shufLG_sem LG_gt_DG DG_overlaps_shufDG DG_overlaps_shufLG
 7     4   0.1929  0.0032     6   0.0668  0.0063       0.0724      0.0088       0.0536      0.0046     True               True              False
 9     2   0.1825  0.0190     2   0.0563  0.0004       0.0483      0.0075       0.0374      0.0062     True              False              False
11    10   0.1641  0.0064     8   0.0595  0.0075       0.0409      0.0068       0.0428      0.0037     True              False              False
13     2   0.1768  0.0021     1   0.0794  0.0000       0.0593      0.0000       0.0506      0.0215     True              False              False
15    10   0.1556  0.0090     8   0.0718  0.0112       0.0446      0.0041       0.0498      0.0049     True              False              False
17     2   0.1472  0.0005     1   0.0495  0.0000       0.0480      0.0000       0.0610      0.0227     True              False               True
19     8   0.1516  0.0061     7   0.0742  0.0066       0.0551      0.0073       0.0657      0.0059     True              False               True
21     7   0.1266  0.0135     6   0.0695  0.0087       0.0553      0.0041       0.0646      0.0065     True              False               True
23     1   0.0769  0.0000     0      NaN  0.0000          NaN      0.0000       0.0612      0.0000     None               None               None
LG > DG in 8 of 8 bins with both; DG overlaps its shuffle in 1 of 8 bins (LG's shuffle: 3)
/home/runner/work/encore-registry/encore-registry/executed/powell-2021/.venv/lib/python3.13/site-packages/numpy/lib/_nanfunctions_impl.py:1998: RuntimeWarning: Degrees of freedom <= 0 for slice.
  var = nanvar(a, axis=axis, dtype=dtype, out=out, ddof=ddof,
/tmp/ipykernel_2372/1286705825.py:23: RuntimeWarning: Mean of empty slice
  return np.nanmean(X, 1), sem, n
 seed_offset  LG_gt_DG_all  DG_overlap_bins  of
           0          True                1   8
        1000          True                4   8
        2000          True                2   8
        3000          True                2   8
        4000          True                1   8
/home/runner/work/encore-registry/encore-registry/executed/powell-2021/.venv/lib/python3.13/site-packages/numpy/lib/_nanfunctions_impl.py:1998: RuntimeWarning: Degrees of freedom <= 0 for slice.
  var = nanvar(a, axis=axis, dtype=dtype, out=out, ddof=ddof,
/tmp/ipykernel_2372/1286705825.py:23: RuntimeWarning: Mean of empty slice
  return np.nanmean(X, 1), sem, n
code burst rule: LG > DG in all bins with both: True; DG overlaps its shuffle in 2 of 7 bins
shuffle  seed_offset  LG_gt_DG_all  DG_overlap_bins  of  overlap_bins_n_gt_1  of_n_gt_1
   perm            0          True                1   8                    1          6
   perm         1000          True                4   8                    4          6
   perm         2000          True                2   8                    2          6
   perm         3000          True                2   8                    2          6
   perm         4000          True                1   8                    1          6
   draw            0          True                3   8                    3          6
   draw         1000          True                2   8                    2          6
   draw         2000          True                3   8                    3          6
   draw         3000          True                3   8                    3          6
   draw         4000          True                3   8                    3          6

Result: partially reproduced. The LG area exceeds the DG area in every bin where both exist (8 of 8, 0.127 to 0.193 against 0.050 to 0.079), under all five seeds. The DG area (mean plus or minus SEM) overlaps the shuffled area in 1 of 8 bins under the claim's seed and 1 to 4 of 8 under the five seeds, never in most; in every bin but 7 C the DG area lies above the shuffled one. Against the LG call's shuffle, the other gray line of the figure, DG overlaps in 3 of 8. Over the six bins with more than one DG preparation, where the SEM is defined, DG overlaps in 1 of 6 under the claim's seed and 1 to 4 of 6 under the five seeds (4 of 6, a majority, under one seed only). With the shuffled pool built from independent draws in place of one permutation, DG overlaps in 2 or 3 of 8 bins under the five seeds. The overlap is in a minority of bins under every variant but one seed of the six-bin count.

fig5f-ratio-independent-of-temperature¶

The ratio of LG to PD cycle period does not change with temperature (Spearman test, p = 0.88, n = 3799).

A claim of absence: Spearman correlation of every LG/mean PD ratio with the temperature at the LG burst start, pooled over preparations; reproduced when p >= 0.05. The code's prep-by-prep means per bin are a variant.

In [21]:
for label, cat in cat_lg.items():
    ok = np.isfinite(cat["ratio"])
    rho, pval = stats.spearmanr(cat["temp"][ok], cat["ratio"][ok])
    print(f"{label}: n = {ok.sum()} cycles, rho = {rho:.4f}, p = {pval:.3f}")
    rows = []
    for c in stg.BIN_CENTRES:
        for j in range(10):
            v = cat["ratio"][ok & (cat["prep"] == j) & stg.in_bin(cat["temp"], c)]
            if len(v):
                rows.append((c, v.mean()))
    rows = np.array(rows)
    r2, p2 = stats.spearmanr(rows[:, 0], rows[:, 1])
    print(f"   prep-by-prep means per bin: n = {len(rows)}, rho = {r2:.3f}, p = {p2:.3f}")
cat = cat_lg["Methods rule"]
ok = np.isfinite(cat["ratio"])
fig, ax = plt.subplots(figsize=(5, 4))
ax.plot(cat["temp"][ok], cat["ratio"][ok], ".", ms=2)
ax.set_ylim(0, 30); ax.set_xlabel("Temperature (C)"); ax.set_ylabel("T_LG / mean T_PD")
print("ratios above 30, outside the axes:", int(np.sum(cat["ratio"][ok] > 30)), "of", int(ok.sum()))
plt.show()
Methods rule: n = 3850 cycles, rho = 0.0163, p = 0.311
   prep-by-prep means per bin: n = 64, rho = 0.206, p = 0.103
code rule: n = 3799 cycles, rho = 0.0024, p = 0.880
   prep-by-prep means per bin: n = 63, rho = 0.187, p = 0.143
ratios above 30, outside the axes: 90 of 3850
No description has been provided for this image

Result: reproduced. Pooled over all cycles the ratio does not correlate with temperature: rho = 0.016, p = 0.31, n = 3850 (Methods burst rule). With the code's burst rule n = 3799 and p = 0.880, the paper's numbers exactly. The prep-by-prep means per bin do not correlate either (rho 0.21, p = 0.10, 64 means).

fig5f-ratio-range¶

At low temperatures the ratios of LG to PD cycle period range widely, from about 5 to 25.

Reading (a) the 7 C bin, (b) bins 7 to 11 C. Reproduced when the 2.5th to 97.5th percentiles lie within 4.5 to 27.5 and span at least 5.5 to 22.5.

In [22]:
for label, cat in cat_lg.items():
    ok = np.isfinite(cat["ratio"])
    for rd, bins in (("a", (7,)), ("b", (7, 9, 11))):
        u = ok & np.any([stg.in_bin(cat["temp"], c) for c in bins], 0)
        v = cat["ratio"][u]
        lo, hi = np.percentile(v, [2.5, 97.5])
        inside = lo >= 4.5 and hi <= 27.5
        spans = lo <= 5.5 and hi >= 22.5
        print(f"{label}, reading ({rd}) bins {bins}: n = {u.sum()}, min {v.min():.2f}, 2.5% {lo:.2f}, 97.5% {hi:.2f}, max {v.max():.2f}; "
              f"within 4.5-27.5: {inside}; spans 5.5-22.5: {spans}; percentiles 1/99: {np.percentile(v, [1, 99]).round(2).tolist()}")
Methods rule, reading (a) bins (7,): n = 283, min 5.76, 2.5% 7.04, 97.5% 26.03, max 39.91; within 4.5-27.5: True; spans 5.5-22.5: False; percentiles 1/99: [6.81, 30.47]
Methods rule, reading (b) bins (7, 9, 11): n = 1609, min 2.55, 2.5% 7.03, 97.5% 25.99, max 57.12; within 4.5-27.5: True; spans 5.5-22.5: False; percentiles 1/99: [6.07, 30.94]
code rule, reading (a) bins (7,): n = 282, min 5.76, 2.5% 7.04, 97.5% 26.06, max 37.86; within 4.5-27.5: True; spans 5.5-22.5: False; percentiles 1/99: [6.08, 29.2]
code rule, reading (b) bins (7, 9, 11): n = 1593, min 2.55, 2.5% 7.03, 97.5% 25.97, max 57.12; within 4.5-27.5: True; spans 5.5-22.5: False; percentiles 1/99: [6.07, 30.06]

Result: not reproduced. At 7 C the central 95% of ratios runs from 7.0 to 26.0 (7 to 11 C: 7.0 to 26.0), inside 4.5 to 27.5 but not reaching down to 5.5; the lowest ratio at 7 C is 5.8 and the highest 39.9. The upper end matches the paper's 25; the lower end of the bulk is 7, not 5.

fig6b-lg-phase-locked¶

LG burst starts are phase-locked to the PD cycle, their distribution in PD phase sharply peaked and significantly non-uniform (Rayleigh test, p < 4e-4, 7.5 < z < 45).

PD phase of each LG burst start (gastric.measurePhase), temperature at the PD burst start rounded to a whole degree, the bins 7 to 23 C. Sample (a), the Methods: the first 40 starts of each preparation and temperature, combinations with fewer excluded; (b) the later code, first 50; (c) the archived code, all starts of a temperature pooled, temperatures with fewer than 100 excluded. The Rayleigh test is circ_rtest.

In [23]:
def phase_tables(Bx, slow):
    rows, pooled = [], []
    for j, (p, b) in enumerate(zip(preps, Bx)):
        ph, T = stg.measure_phase(p, b, b[slow]["starts"])
        Tr = np.round(T)
        for c in stg.BIN_CENTRES:
            v = ph[(Tr == c) & np.isfinite(ph)]
            r = {"prep": p["name"], "T": int(c), "n": len(v), "cmean_all": stg.circ_mean01(v)}
            for N in (40, 50):
                if len(v) >= N:
                    r[f"p{N}"], r[f"z{N}"] = stg.rayleigh(v[:N])
                    r[f"cmean{N}"] = stg.circ_mean01(v[:N])
            rows.append(r)
        pooled.append(pd.DataFrame({"prep": j, "T": Tr, "phase": ph}))
    P = pd.concat(pooled)
    P = P[np.isfinite(P.phase)]
    pool = []
    for c in range(5, 26, 2):
        v = P.phase[P["T"] == c].values
        if len(v) >= 100:
            pv, z = stg.rayleigh(v)
            pool.append({"T": c, "n": len(v), "p": pv, "z": z})
    return pd.DataFrame(rows), pd.DataFrame(pool)


def summarise(tab, pool, label):
    out = {}
    for N in (40, 50):
        s = tab.dropna(subset=[f"p{N}"])
        out[N] = s
        print(f"  {label} first {N}: {len(s)} combinations; p {s[f'p{N}'].min():.2g} to {s[f'p{N}'].max():.2g}; "
              f"z {s[f'z{N}'].min():.2f} to {s[f'z{N}'].max():.2f} (median {s[f'z{N}'].median():.1f}); "
              f"p >= 0.05 in {int((s[f'p{N}'] >= 0.05).sum())}")
    print(f"  {label} pooled (>= 100 per temperature):", pool.round(3).to_dict("records"))
    return out

ph_lg = {lab: phase_tables(Bx, "LG") for lab, Bx in (("Methods rule", B), ("code rule", BC))}
for lab, (tab, pool) in ph_lg.items():
    print(f"--- LG, {lab}")
    s = summarise(tab, pool, lab)
    a = s[40]
    print(f"  sample (a): all p < 4.4e-4: {bool((a.p40 < 4.4e-4).all())}; all z in 6.75-49.5: {bool(a.z40.between(6.75, 49.5).all())}; "
          f"all p < 0.05: {bool((a.p40 < 0.05).all())}; combinations failing p < 4.4e-4: {int((a.p40 >= 4.4e-4).sum())}")
    b50 = s[50]
    print(f"  sample (b): all p < 4.4e-4: {bool((b50.p50 < 4.4e-4).all())}; all z in 6.75-49.5: {bool(b50.z50.between(6.75, 49.5).all())}")
tab, _ = ph_lg["Methods rule"]
print("\nSample (a), Methods rule, per combination:")
print(tab.dropna(subset=["p40"])[["prep", "T", "n", "p40", "z40"]].to_string(index=False, float_format=lambda v: f"{v:.3g}"))

def dropped_even(Bx, slow):
    n_all = n_even = 0
    for p, b in zip(preps, Bx):
        ph, T = stg.measure_phase(p, b, b[slow]["starts"])
        ok = np.isfinite(ph)
        n_all += int(ok.sum())
        n_even += int(np.sum(ok & ~np.isin(np.round(T), np.arange(5, 26, 2))))
    return n_even, n_all

for lab, Bx in (("Methods rule", B), ("code rule", BC)):
    for slow in ("LG", "DG"):
        e, a = dropped_even(Bx, slow)
        print(f"{lab}, {slow}: burst starts with a PD phase at an even rounded temperature (dropped): {e} of {a}")
--- LG, Methods rule
  Methods rule first 40: 41 combinations; p 2.5e-23 to 0.008; z 4.74 to 35.77 (median 22.6); p >= 0.05 in 0
  Methods rule first 50: 34 combinations; p 6.1e-30 to 0.00021; z 8.20 to 45.31 (median 26.2); p >= 0.05 in 0
  Methods rule pooled (>= 100 per temperature): [{'T': 7, 'n': 353, 'p': 0.0, 'z': 172.852}, {'T': 9, 'n': 148, 'p': 0.0, 'z': 107.582}, {'T': 11, 'n': 1116, 'p': 0.0, 'z': 576.827}, {'T': 13, 'n': 227, 'p': 0.0, 'z': 152.109}, {'T': 15, 'n': 819, 'p': 0.0, 'z': 417.168}, {'T': 17, 'n': 124, 'p': 0.0, 'z': 73.521}, {'T': 19, 'n': 631, 'p': 0.0, 'z': 319.583}, {'T': 21, 'n': 437, 'p': 0.0, 'z': 103.672}]
  sample (a): all p < 4.4e-4: False; all z in 6.75-49.5: False; all p < 0.05: True; combinations failing p < 4.4e-4: 4
  sample (b): all p < 4.4e-4: True; all z in 6.75-49.5: True
--- LG, code rule
  code rule first 40: 41 combinations; p 1.6e-23 to 0.082; z 2.49 to 35.92 (median 22.6); p >= 0.05 in 1
  code rule first 50: 33 combinations; p 4.2e-30 to 0.00045; z 7.49 to 45.44 (median 28.3); p >= 0.05 in 0
  code rule pooled (>= 100 per temperature): [{'T': 7, 'n': 352, 'p': 0.0, 'z': 172.282}, {'T': 9, 'n': 148, 'p': 0.0, 'z': 108.806}, {'T': 11, 'n': 1106, 'p': 0.0, 'z': 570.917}, {'T': 13, 'n': 225, 'p': 0.0, 'z': 154.038}, {'T': 15, 'n': 806, 'p': 0.0, 'z': 408.201}, {'T': 17, 'n': 124, 'p': 0.0, 'z': 67.342}, {'T': 19, 'n': 622, 'p': 0.0, 'z': 299.187}, {'T': 21, 'n': 433, 'p': 0.0, 'z': 100.78}]
  sample (a): all p < 4.4e-4: False; all z in 6.75-49.5: False; all p < 0.05: False; combinations failing p < 4.4e-4: 4
  sample (b): all p < 4.4e-4: False; all z in 6.75-49.5: True

Sample (a), Methods rule, per combination:
   prep  T   n      p40  z40
901_005 11  80  6.1e-19 31.5
901_005 13  41  8.7e-19 31.3
901_005 15  67 1.66e-09 17.9
901_046  7  56 2.61e-11   21
901_046  9 118  5.7e-15 26.5
901_046 11 239 4.15e-21 33.8
901_046 13 168 2.82e-17 29.5
901_046 15 110 2.97e-14 25.5
901_046 17  83 2.86e-12 22.5
901_046 19 123 2.64e-10 19.3
901_046 21  63 5.98e-06 11.3
901_046 23  53  0.00513 5.16
901_049 11  59 1.95e-05 10.2
901_049 15  63 3.68e-06 11.7
901_049 19  73 1.39e-11 21.4
901_049 21  57  1.9e-05 10.3
901_052 11 115 1.02e-15 27.5
901_052 15 132 6.05e-17 29.1
901_052 19 147 7.32e-09 16.8
901_052 21 122 3.51e-06 11.7
901_062  7  87 2.46e-23 35.8
901_062 11 151 2.45e-18 30.8
901_062 15 154 1.05e-21 34.3
901_080  7  41 6.81e-10 18.6
901_080 11  83 1.77e-12 22.8
901_080 15  44 9.51e-16 27.5
901_080 19  47 6.97e-16 27.7
901_080 21  44 2.68e-13 24.1
901_086 11 146 2.49e-12 22.6
901_086 15  55 0.000123 8.61
901_095 11 109  0.00183 6.13
901_095 15  87  0.00361  5.5
901_095 19  47  1.8e-11 21.2
901_098 11  65  0.00802 4.74
901_098 15  54 4.74e-11 20.5
901_098 19  52 1.46e-12   23
932_151  7  47 8.54e-21 33.4
932_151 11  69  1.6e-14 25.9
932_151 15  53 5.81e-16 27.8
932_151 19  59 2.59e-13 24.1
932_151 21  54 9.37e-06 10.9
Methods rule, LG: burst starts with a PD phase at an even rounded temperature (dropped): 220 of 4128
Methods rule, DG: burst starts with a PD phase at an even rounded temperature (dropped): 218 of 3791
code rule, LG: burst starts with a PD phase at an even rounded temperature (dropped): 217 of 4082
code rule, DG: burst starts with a PD phase at an even rounded temperature (dropped): 201 of 3649

Result: partially reproduced. Under the Methods' sample (first 40 starts), every one of the 41 preparation and temperature combinations is significantly non-uniform (p < 0.05; largest p 0.008), but not every one reaches p < 4.4e-4, and z runs from 4.7 to 35.8, below the reported 7.5 at the low end (Methods burst rule). With the code's burst rule one combination has p = 0.08. The later code's sample (first 50) with the code's burst rule gives p up to 4.5e-4 and z 7.5 to 45.4, which are the reported bounds within rounding; with the Methods burst rule and the first 50, p up to 2.1e-4 and z 8.2 to 45.3, within them. The archived code's pooled sample gives z of 67 to 577, far above them. The odd-temperature filter drops the 220 of 4128 LG burst starts with a PD phase whose rounded temperature is even (Methods rule; printed above); they belong to none of the nine temperature points.

fig6b-lg-start-counts¶

A total of 3816 LG burst starts and 3228 DG burst starts across nine temperature points and 10 preparations enter the phase distributions, and about 35% of preparation and temperature combinations have fewer than 40 burst starts.

All LG and DG burst starts with a defined PD phase in the bins 7 to 23 C. The fraction, reading (a): of preparation and temperature combinations; the claims file does not say over which combinations, so both those with at least one start and all 90 (10 preparations by 9 temperatures) are shown; reading (b): of burst starts. The claims file leaves the denominator of reading (a) open; the combinations with at least one start are taken as the main one (a combination with no start has no data to exclude), and all 90 are shown. The outcome is decided by the DG total under either.

In [24]:
ph_dg = {lab: phase_tables(Bx, "DG") for lab, Bx in (("Methods rule", B), ("code rule", BC))}
for lab in ("Methods rule", "code rule"):
    lt, lp = ph_lg[lab]
    dt, dp = ph_dg[lab]
    both = pd.concat([lt.assign(neuron="LG"), dt.assign(neuron="DG")])
    nz = both[both.n > 0]
    print(f"--- {lab}: LG starts {lt.n.sum()} (expected 3816 +- 381.6, within: {abs(lt.n.sum() - 3816) <= 381.6}); "
          f"DG starts {dt.n.sum()} (expected 3228 +- 322.8, within: {abs(dt.n.sum() - 3228) <= 322.8})")
    print(f"  pooled over temperatures with >= 100 (code's figure): LG {lp.n.sum()}, DG {dp.n.sum()}")
    for name, t in (("LG", lt), ("DG", dt), ("LG and DG", both)):
        z = t[t.n > 0]
        print(f"  {name}: combinations < 40 of those with any start: {(z.n < 40).mean():.3f} ({int((z.n < 40).sum())}/{len(z)}); "
              f"of all {len(t)}: {(t.n < 40).mean():.3f}; fraction of starts in combinations < 40: {t.n[t.n < 40].sum() / t.n.sum():.3f}")
--- Methods rule: LG starts 3908 (expected 3816 +- 381.6, within: True); DG starts 3573 (expected 3228 +- 322.8, within: False)
  pooled over temperatures with >= 100 (code's figure): LG 3855, DG 3341
  LG: combinations < 40 of those with any start: 0.339 (21/62); of all 90: 0.544; fraction of starts in combinations < 40: 0.100
  DG: combinations < 40 of those with any start: 0.386 (22/57); of all 90: 0.611; fraction of starts in combinations < 40: 0.086
  LG and DG: combinations < 40 of those with any start: 0.361 (43/119); of all 180: 0.578; fraction of starts in combinations < 40: 0.093
--- code rule: LG starts 3865 (expected 3816 +- 381.6, within: True); DG starts 3448 (expected 3228 +- 322.8, within: True)
  pooled over temperatures with >= 100 (code's figure): LG 3816, DG 3220
  LG: combinations < 40 of those with any start: 0.339 (21/62); of all 90: 0.544; fraction of starts in combinations < 40: 0.100
  DG: combinations < 40 of those with any start: 0.439 (25/57); of all 90: 0.644; fraction of starts in combinations < 40: 0.118
  LG and DG: combinations < 40 of those with any start: 0.387 (46/119); of all 180: 0.594; fraction of starts in combinations < 40: 0.109

Result: partially reproduced. Two of the three quantities are within tolerance. Under the Methods burst rule there are 3908 LG burst starts (within 3816 plus or minus 381.6) and 3573 DG starts, above the tolerance of 3228 plus or minus 322.8 by 22. The fraction of combinations with fewer than 40 starts, over combinations with any start, is 0.339 for LG, within the reported ~35% plus or minus 0.035 (the criterion's quantity), 0.386 for DG, just outside it, and 0.361 for both together; 0.09 to 0.10 of the starts are in such combinations. With the code's burst rule the counts are 3865 LG and 3448 DG, both within tolerance, so the claim holds in full under the code's rule and in part under the Methods' one, which the claims file sets. With the code's burst rule and the archived code's sample (temperatures with at least 100 pooled starts), the totals are 3816 LG, the paper's number exactly, and 3220 DG against 3228. Counting the starts at even rounded temperatures, which belong to none of the nine temperature points the paper names, would add 220 LG and 218 DG starts (Methods rule).

fig6b-lg-phase-constant¶

From 7 to 21 C, LG bursts start at a phase of about 0.5 in the PD cycle, and this phase does not trend with temperature (Spearman test, p = 0.46, rho = -0.31).

Circular mean phase per preparation and bin, then circular mean over preparations (groupAndPlotErrorBars with circular means); Spearman correlation of the eight bin means 7 to 21 C with temperature (absence, reproduced when p >= 0.05); the phase holds when every bin mean is within 0.45 to 0.55. All starts and the first 40 per combination are both run.

In [25]:
for lab in ("Methods rule", "code rule"):
    tab, _ = ph_lg[lab]
    for col, name in (("cmean_all", "all starts"), ("cmean40", "first 40")):
        M = np.array([stg.circ_mean01(tab[tab["T"] == c][col].dropna().values) for c in stg.BIN_CENTRES])
        sel = (stg.BIN_CENTRES >= 7) & (stg.BIN_CENTRES <= 21) & np.isfinite(M)
        rho, pval = stats.spearmanr(stg.BIN_CENTRES[sel], M[sel])
        print(f"{lab}, {name}: bin means {dict(zip(stg.BIN_CENTRES.tolist(), M.round(3).tolist()))}")
        print(f"   7-21 C: Spearman rho = {rho:.3f}, p = {pval:.3f}; range {M[sel].min():.3f}-{M[sel].max():.3f}; "
              f"all within 0.45-0.55: {bool(((M[sel] >= 0.45) & (M[sel] <= 0.55)).all())}; bins outside: {stg.BIN_CENTRES[sel][(M[sel] < 0.45) | (M[sel] > 0.55)].tolist()}")
Methods rule, all starts: bin means {7: 0.435, 9: 0.446, 11: 0.494, 13: 0.454, 15: 0.466, 17: 0.436, 19: 0.45, 21: 0.416, 23: 0.188}
   7-21 C: Spearman rho = -0.190, p = 0.651; range 0.416-0.494; all within 0.45-0.55: False; bins outside: [7, 9, 17, 21]
Methods rule, first 40: bin means {7: 0.413, 9: 0.447, 11: 0.504, 13: 0.384, 15: 0.46, 17: 0.337, 19: 0.421, 21: 0.351, 23: 0.188}
   7-21 C: Spearman rho = -0.429, p = 0.289; range 0.337-0.504; all within 0.45-0.55: False; bins outside: [7, 9, 13, 17, 19, 21]
code rule, all starts: bin means {7: 0.436, 9: 0.447, 11: 0.494, 13: 0.45, 15: 0.465, 17: 0.432, 19: 0.449, 21: 0.415, 23: 0.124}
   7-21 C: Spearman rho = -0.310, p = 0.456; range 0.415-0.494; all within 0.45-0.55: False; bins outside: [7, 9, 17, 19, 21]
code rule, first 40: bin means {7: 0.413, 9: 0.456, 11: 0.504, 13: 0.384, 15: 0.457, 17: 0.337, 19: 0.417, 21: 0.347, 23: 0.103}
   7-21 C: Spearman rho = -0.429, p = 0.289; range 0.337-0.504; all within 0.45-0.55: False; bins outside: [7, 13, 17, 19, 21]

Result: partially reproduced. The phase does not trend with temperature from 7 to 21 C (all starts: rho = -0.19, p = 0.65; first 40: rho = -0.43, p = 0.29; Methods burst rule). With the code's burst rule and all starts, rho = -0.310 and p = 0.456, the paper's values. The mean phase is near but mostly below 0.5: 0.42 to 0.49 with all starts, 0.34 to 0.50 with the first 40, so not every bin lies within 0.45 to 0.55 under either sample.

fig6c-lg-spiking-drops-near-pd-end¶

LG spike probability in the PD cycle shows a pronounced decrease at higher temperatures, occurring close to PD burst termination.

PD phase of every LG spike, rounded temperature, temperatures with at least 1000 spikes, 30-bin p.d.f. on 0 to 1; mean PD burst-end phase per temperature. The value is the p.d.f. in the bin holding the mean PD end (a), or the lowest bin within 0.1 phase of it (b).

In [26]:
def spike_pdf_table(Bx, neuron):
    stops, sT, ph, T = [], [], [], []
    for p, b in zip(preps, Bx):
        s, t = stg.measure_phase(p, b, b["PD"]["ends"])
        stops.append(s); sT.append(t)
        a, t2 = stg.measure_phase(p, b, p[neuron])
        ph.append(a); T.append(t2)
    stops, sT = np.concatenate(stops), np.round(np.concatenate(sT))
    ph, T = np.concatenate(ph), np.round(np.concatenate(T))
    edges = np.linspace(0, 1, 31)
    centres = (edges[:-1] + edges[1:]) / 2
    rows = []
    for c in range(5, 26, 2):
        u = (T == c) & np.isfinite(ph)
        if u.sum() < 1000:
            continue
        h, _ = np.histogram(ph[u], edges, density=True)
        M = np.nanmean(stops[sT == c])
        k = min(int(M * 30), 29)
        near = np.abs(centres - M) <= 0.1
        rows.append({"T": c, "spikes": int(u.sum()), "PD_end_phase": M, "pdf_a": h[k], "pdf_b": h[near].min(),
                     "pdf_min": h.min(), "pdf_max": h.max()})
    return pd.DataFrame(rows)

pdf_lg = {lab: spike_pdf_table(Bx, "LG") for lab, Bx in (("Methods rule", B), ("code rule", BC))}
for lab, t in pdf_lg.items():
    print(f"--- LG, {lab}")
    print(t.round(3).to_string(index=False))
    for rd in ("a", "b"):
        rho, pval = stats.spearmanr(t["T"], t[f"pdf_{rd}"])
        print(f"  reading ({rd}): value at warmest ({t['T'].iloc[-1]} C) {t[f'pdf_{rd}'].iloc[-1]:.3f} < 1: {t[f'pdf_{rd}'].iloc[-1] < 1}; "
              f"Spearman with temperature rho = {rho:.3f}, p = {pval:.3f}")
    print("  without the 23 C bin (one or two preparations):",
          {rd: round(stats.spearmanr(t["T"][t["T"] < 23], t[f"pdf_{rd}"][t["T"] < 23])[0], 3) for rd in ("a", "b")})
for lab, Bx in (("Methods rule", B), ("code rule", BC)):
    for neuron in ("LG", "DG"):
        T_all = np.concatenate([np.round(stg.measure_phase(p, b, p[neuron])[1]) for p, b in zip(preps, Bx)])
        ph_all = np.concatenate([stg.measure_phase(p, b, p[neuron])[0] for p, b in zip(preps, Bx)])
        ok = np.isfinite(ph_all)
        even = ok & ~np.isin(T_all, np.arange(5, 26, 2))
        print(f"{lab}, {neuron}: spikes with a PD phase at an even rounded temperature (not in any odd bin, dropped): "
              f"{int(even.sum())} of {int(ok.sum())} ({even.sum() / ok.sum():.3f})")
--- LG, Methods rule
 T  spikes  PD_end_phase  pdf_a  pdf_b  pdf_min  pdf_max
 7   29398         0.201  0.741  0.702    0.702    1.189
 9   11653         0.215  0.451  0.391    0.391    1.382
11   80462         0.191  0.624  0.624    0.624    1.257
13   19916         0.198  0.697  0.600    0.600    1.241
15   53427         0.204  0.727  0.727    0.727    1.248
17   11515         0.195  0.740  0.636    0.636    1.266
19   40895         0.195  0.789  0.730    0.730    1.220
21   28910         0.197  0.811  0.730    0.730    1.189
23    2892         0.189  0.228  0.197    0.197    1.504
  reading (a): value at warmest (23 C) 0.228 < 1: True; Spearman with temperature rho = 0.150, p = 0.700
  reading (b): value at warmest (23 C) 0.197 < 1: True; Spearman with temperature rho = 0.167, p = 0.668
  without the 23 C bin (one or two preparations): {'a': np.float64(0.643), 'b': np.float64(0.667)}
--- LG, code rule
 T  spikes  PD_end_phase  pdf_a  pdf_b  pdf_min  pdf_max
 7   29398         0.201  0.741  0.704    0.704    1.190
 9   11653         0.215  0.451  0.389    0.389    1.380
11   80462         0.191  0.625  0.625    0.625    1.256
13   19916         0.198  0.696  0.601    0.601    1.241
15   53427         0.204  0.727  0.727    0.727    1.248
17   11515         0.196  0.748  0.685    0.685    1.227
19   40895         0.196  0.800  0.754    0.754    1.218
21   28910         0.197  0.820  0.741    0.741    1.179
23    2892         0.189  0.270  0.187    0.187    1.691
  reading (a): value at warmest (23 C) 0.270 < 1: True; Spearman with temperature rho = 0.233, p = 0.546
  reading (b): value at warmest (23 C) 0.187 < 1: True; Spearman with temperature rho = 0.167, p = 0.668
  without the 23 C bin (one or two preparations): {'a': np.float64(0.762), 'b': np.float64(0.667)}
Methods rule, LG: spikes with a PD phase at an even rounded temperature (not in any odd bin, dropped): 10419 of 289487 (0.036)
Methods rule, DG: spikes with a PD phase at an even rounded temperature (not in any odd bin, dropped): 20917 of 228412 (0.092)
code rule, LG: spikes with a PD phase at an even rounded temperature (not in any odd bin, dropped): 10419 of 289487 (0.036)
code rule, DG: spikes with a PD phase at an even rounded temperature (not in any odd bin, dropped): 20916 of 228412 (0.092)

Result: not reproduced. LG spike density at the PD burst end is below the uniform level at every temperature (0.45 to 0.81 from 7 to 21 C), and lowest at 23 C (0.23, reading a), but it does not decrease with temperature: the Spearman correlation with temperature is not negative under either reading (printed above), as the density rises from 11 to 21 C. The drop at 23 C rests on the two preparations that reach it. The odd-temperature filter drops 3.6% of LG spikes and 9.2% of DG spikes with a PD phase (even rounded temperatures; printed above).

fig6e-dg-not-phase-locked¶

DG bursts are not phase-locked to PD; DG burst starts are not sharply peaked in PD phase, not significantly non-uniform in every preparation and temperature, and the effect is much smaller than for LG (p from 0.001 to 0.85, 0.15 < z < 13).

The same test with DG burst starts; reproduced when at least one combination has p >= 0.05 and the median DG z is below the median LG z under the same sample.

In [27]:
for lab in ("Methods rule", "code rule"):
    dt, dp = ph_dg[lab]
    lt, _ = ph_lg[lab]
    print(f"--- DG, {lab}")
    s = summarise(dt, dp, lab)
    for N in (40, 50):
        d = s[N]
        l = lt.dropna(subset=[f"z{N}"])
        print(f"  first {N}: p >= 0.05 in {int((d[f'p{N}'] >= 0.05).sum())} of {len(d)}; median z DG {d[f'z{N}'].median():.2f} "
              f"against LG {l[f'z{N}'].median():.2f}; DG z within 0.15-13: {bool(d[f'z{N}'].between(0.15, 13).all())}; "
              f"DG p within 0.001-0.85: {bool(d[f'p{N}'].between(0.001, 0.85).all())}")
--- DG, Methods rule
  Methods rule first 40: 35 combinations; p 1.4e-08 to 0.82; z 0.21 to 16.25 (median 3.4); p >= 0.05 in 16
  Methods rule first 50: 27 combinations; p 2.3e-06 to 0.85; z 0.16 to 12.27 (median 2.6); p >= 0.05 in 15
  Methods rule pooled (>= 100 per temperature): [{'T': 7, 'n': 384, 'p': 0.0, 'z': 23.196}, {'T': 11, 'n': 1305, 'p': 0.0, 'z': 49.235}, {'T': 15, 'n': 764, 'p': 0.0, 'z': 58.272}, {'T': 19, 'n': 556, 'p': 0.0, 'z': 12.654}, {'T': 21, 'n': 332, 'p': 0.0, 'z': 18.185}]
  first 40: p >= 0.05 in 16 of 35; median z DG 3.38 against LG 22.59; DG z within 0.15-13: False; DG p within 0.001-0.85: False
  first 50: p >= 0.05 in 15 of 27; median z DG 2.57 against LG 26.21; DG z within 0.15-13: True; DG p within 0.001-0.85: False
--- DG, code rule
  code rule first 40: 32 combinations; p 2.7e-08 to 0.82; z 0.21 to 15.74 (median 3.2); p >= 0.05 in 16
  code rule first 50: 27 combinations; p 4.8e-07 to 0.85; z 0.16 to 13.65 (median 2.5); p >= 0.05 in 15
  code rule pooled (>= 100 per temperature): [{'T': 7, 'n': 378, 'p': 0.0, 'z': 22.048}, {'T': 11, 'n': 1256, 'p': 0.0, 'z': 50.823}, {'T': 15, 'n': 741, 'p': 0.0, 'z': 55.214}, {'T': 19, 'n': 537, 'p': 0.0, 'z': 11.384}, {'T': 21, 'n': 308, 'p': 0.0, 'z': 14.042}]
  first 40: p >= 0.05 in 16 of 32; median z DG 3.24 against LG 22.59; DG z within 0.15-13: False; DG p within 0.001-0.85: False
  first 50: p >= 0.05 in 15 of 27; median z DG 2.50 against LG 28.30; DG z within 0.15-13: False; DG p within 0.001-0.85: False

Result: reproduced. Under the Methods' sample (first 40), 16 of 35 DG combinations are not significantly non-uniform (p >= 0.05), and the median DG z, 3.4, is far below the median LG z, 22.6 (Methods burst rule). DG p ranges from 1.4e-8 to 0.82 and z from 0.21 to 16.25, beyond the reported 0.001 to 0.85 and 0.15 to 13 at the significant end; with the later code's sample of 50, z runs 0.16 to 12.3 (Methods burst rule) or 13.7 (code's), and p from 2e-6 to 0.85.

fig6f-dg-spiking-no-drop¶

DG spike probability does not show a noticeable decrease close to the end of PD bursting.

The measure of fig6c applied to DG spikes; reproduced when, under the reading used for LG (a), the DG value is not below 1 by more than half of the LG drop at the same temperature, at every included temperature.

In [28]:
for lab, Bx in (("Methods rule", B), ("code rule", BC)):
    d = spike_pdf_table(Bx, "DG")
    l = pdf_lg[lab].set_index("T")
    d["LG_pdf_a"] = d["T"].map(l["pdf_a"])
    d["threshold"] = 1 - 0.5 * (1 - d["LG_pdf_a"])
    d["holds"] = d["pdf_a"] >= d["threshold"]
    print(f"--- DG, {lab}")
    print(d.round(3).to_string(index=False))
    print(f"  holds at {int(d.holds.sum())} of {len(d)} temperatures; DG value range {d.pdf_a.min():.2f}-{d.pdf_a.max():.2f}")

print(f"Run time of the notebook up to here: {(time.time() - started) / 60:.1f} min")
--- DG, Methods rule
 T  spikes  PD_end_phase  pdf_a  pdf_b  pdf_min  pdf_max  LG_pdf_a  threshold  holds
 7   33562         0.201  1.058  1.019    0.855    1.084     0.741      0.870   True
 9    3985         0.215  0.986  0.851    0.775    1.265     0.451      0.725   True
11   80097         0.191  0.954  0.935    0.887    1.176     0.624      0.812   True
13    1763         0.198  1.089  0.902    0.664    1.395     0.697      0.849   True
15   42570         0.204  1.010  0.932    0.784    1.300     0.727      0.864   True
17    2466         0.195  0.888  0.864    0.791    1.387     0.740      0.870   True
19   25624         0.195  0.947  0.911    0.848    1.215     0.789      0.895   True
21   16874         0.197  0.965  0.930    0.857    1.179     0.811      0.906   True
  holds at 8 of 8 temperatures; DG value range 0.89-1.09
--- DG, code rule
 T  spikes  PD_end_phase  pdf_a  pdf_b  pdf_min  pdf_max  LG_pdf_a  threshold  holds
 7   33562         0.201  1.061  1.020    0.856    1.084     0.741      0.870   True
 9    3985         0.215  0.986  0.851    0.775    1.265     0.451      0.725   True
11   80098         0.191  0.954  0.935    0.887    1.174     0.625      0.812   True
13    1763         0.198  1.089  0.885    0.664    1.395     0.696      0.848   True
15   42570         0.204  1.010  0.932    0.784    1.300     0.727      0.864   True
17    2466         0.196  0.912  0.852    0.803    1.375     0.748      0.874   True
19   25624         0.196  0.950  0.914    0.843    1.222     0.800      0.900   True
21   16874         0.197  0.965  0.932    0.860    1.177     0.820      0.910   True
  holds at 8 of 8 temperatures; DG value range 0.91-1.09
Run time of the notebook up to here: 2.1 min

Result: reproduced. DG spike density at the PD burst-end bin is 0.89 to 1.09 at the eight temperatures with at least 1000 DG spikes (7 to 21 C), and at each it is above the threshold of 1 minus half of the LG drop (printed above).

Summary¶

Claim Outcome
fig2-spontaneous-11-to-30 Blocked: data missing
fig2a-less-regular-at-high-temperature Blocked: data missing
fig3-evoked-7-to-21-in-9-of-10 Reproduced (9 of 10 under the criterion's wording, 8 if 21 C is required; rests on the reading of "held")
fig3s1-spontaneous-and-evoked-similar Not reproduced (1 of the 3 testable preparations similar; 941_006 has no spike times)
fig4b-periods-decrease-all-preps Reproduced
fig4c-q10-about-2 Not reproduced (Methods' Q10; the code's Q10 gives 8 of 10)
fig4c-q10-pd-lg-not-different Reproduced
fig4s1-slowdown-after-stimulation Reproduced
fig4s2-gastric-without-pyloric-pacemaker Blocked: data missing
fig4s2-rhythm-counts Blocked: data missing
fig5a-example-ratios Reproduced
fig5d-lg-pd-integer-coupled Reproduced
fig5d-dg-pd-not-coupled Reproduced
fig5e-lg-area-exceeds-dg Partially reproduced
fig5f-ratio-independent-of-temperature Reproduced
fig5f-ratio-range Not reproduced
fig6b-lg-phase-locked Partially reproduced
fig6b-lg-start-counts Partially reproduced (DG count 22 over tolerance; holds under the code's burst rule)
fig6b-lg-phase-constant Partially reproduced
fig6c-lg-spiking-drops-near-pd-end Not reproduced
fig6e-dg-not-phase-locked Reproduced
fig6f-dg-spiking-no-drop Reproduced

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. Bursts follow the Methods (at least 5 or 2 spikes); the paper's code keeps bursts with at least that many ISIs, one spike more, and is shown as a variant throughout. With the code's rule and the code's computations, several reported numbers are matched exactly (paired t-test t = 1.27, p = 0.235; n = 3799 cycles and Spearman p = 0.88; phase Spearman rho = -0.31, p = 0.46), so the record holds the data the paper analysed. The Methods' phase sample (first 40 starts) does not give the reported Rayleigh ranges; the later code's (first 50) does, and the archived code's pooled sample with the code's burst rule gives the reported 3816 LG burst starts. The Methods' Q10 does not give the reported count of 8 of 10 near 2; the code's per-burst Q10 does. Random draws (KS shuffles, bootstraps) use seeds from the claim ids, not the paper's.

What was found about the dataset. evoked_data.mat holds the spike times, temperature and stimulation mask of the ten evoked preparations, consistent with the paper. The spontaneous recordings and the recordings with the pyloric pacemaker hyperpolarized, behind Figure 2 and Figure 4, figure supplement 2, are not in the record, although the data statement points only to it. There is no raw data for 901_005. 932_151, one of the ten evoked preparations, was recorded in May 2019 by its ABF header, not in 2017 as the Methods say. Two zips (941_003, 941_006, recorded June 2019) belong to no set the paper describes and have no spike annotations; 941_006 is one of the four preparations of Figure 3, figure supplement 1, so that claim is tested on the other three. The record has no README, and the fields of evoked_data.mat (the mask in particular) are not described. Its experiment_idx and filename fields are MATLAB categorical objects, readable outside MATLAB only by decoding the MCOS subsystem. The fields T and time_offset are empty. The DG spike times of nine preparations are not sorted in the file.