Gao et al. (2026) on dandiset 001683: seizure metrics from the labels¶

Paper. Gao H, Frake A, Durand DM, He B (2026). Transcranial focused ultrasound stimulation targeting white matter inhibits seizures in a rat model of epilepsy. IEEE Trans Neural Syst Rehabil Eng 34, 251-259. doi:10.1109/tnsre.2025.3644273. The claims file was written from the NIH author manuscript (PMC12848950) and the supplement.

Dandiset. DANDI:001683, version 0.260109.2104. The paper cites no version (its Data Availability statement gives the dandiset's address only). This is the only published version and so the most recent; the draft lists the same 318 assets and size.

This is the first of three notebooks. It tests the claims on seizure count, percent time in seizure, seizure duration and inter-seizure interval (Figs. 2 and 3), which use only the seizure labels the dandiset holds. eeg_blocks.ipynb tests the band power, asymmetry index and seizure PLI claims (Figs. 4, 6, S4, S5, S7); wild_type.ipynb the evoked potentials and wild-type PLI (Fig. 5).

Claim Notebook Tested here
fig2c-sham-duration-stable this yes
fig2d-seizures-under-two-minutes this yes
fig2e-sham-count-stable this yes
fig2f-sham-percent-time-post3 this yes
fig3a-count-reduction this yes
fig3a-count-sham-vs-tfus this yes
fig3b-percent-time-reduction this yes
fig3b-sham-percent-time-no-change this yes
fig3b-percent-time-sham-vs-tfus this yes
fig3c-interval-increase this yes
fig3c-interval-sham-vs-tfus this yes
fig3d-duration-decline this yes
Figs. 4, 6, S4, S5, S7 (seven claims) eeg_blocks.ipynb no
Fig. 5 (three claims) wild_type.ipynb no
In [1]:
import hashlib
import time
import warnings

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

import tfus

warnings.filterwarnings("ignore")
pd.set_option("display.width", 220)
pd.set_option("display.max_columns", 40)
pd.set_option("display.max_rows", 300)

started = time.time()
assets = tfus.list_assets()
info = tfus.version_info()
print(f"dandiset {tfus.DANDISET_ID} version {tfus.DANDISET_VERSION}: {len(assets)} assets, "
      f"{assets['size'].sum() / 1e9:.1f} GB; archive summary: {info['metadata']['assetsSummary']['numberOfSubjects']} subjects, "
      f"{info['metadata']['assetsSummary']['numberOfFiles']} files")
big = assets[assets["size"] > 2e9]
metas = tfus.read_all_meta(big.asset_id.tolist())
lab = [m for m in metas if m["kind"] == "Labeled_data"]
print(f"files over 2 GB: {len(big)}; of them labelled EEG blocks: {len(lab)}; read in {time.time() - started:.0f} s")
dandiset 001683 version 0.260109.2104: 318 assets, 355.7 GB; archive summary: 23 subjects, 318 files
files over 2 GB: 70; of them labelled EEG blocks: 70; read in 34 s

Data check¶

Each check of the metadata against the values is stated under its output.

In [2]:
blocks = tfus.assign_blocks(lab)
M = {m["asset_id"]: m for m in lab}
print("Kinds, groups and notes of the files read:")
print(pd.Series([(m["kind"], m["group"], m["notes"]) for m in lab]).value_counts().to_string())
print("\nRats per group:", blocks.groupby("group").subject.nunique().to_dict(), "(paper: 10 tFUS, 6 sham)")
print("\nBlock files per rat, and the label each file carries in general/data_collection, in time order:")
print(blocks.pivot(index="subject", columns="block", values="label").fillna("").to_string())
print("\nSampling rates:", sorted({m["rate"] for m in lab}), "Hz; channels:", sorted({m["n_channels"] for m in lab}),
      "; unit:", sorted({m["unit"] for m in lab}), "; conversion:", sorted({m["conversion"] for m in lab}))
print("Storage: chunks", sorted({str(m["chunks"]) for m in lab}), "compression", sorted({str(m["compression"]) for m in lab}))
print(f"Block length: {blocks.minutes.min():.2f} to {blocks.minutes.max():.2f} min (paper: ~62.5 min)")
gaps = blocks.assign(t=pd.to_datetime(blocks.start, utc=True)).groupby("subject").t.diff().dt.total_seconds() / 60
print(f"Start-to-start time between consecutive blocks of a rat: {gaps.min():.1f} to {gaps.max():.1f} min")
Kinds, groups and notes of the files read:
(Labeled_data, tFUS group, EEG signals with seizure labels)    40
(Labeled_data, sham group, EEG signals with seizure labels)    30

Rats per group: {'sham': 6, 'tFUS': 10} (paper: 10 tFUS, 6 sham)

Block files per rat, and the label each file carries in general/data_collection, in time order:
block          baseline     condition        post1        post2        post3
subject                                                                     
BH624    BH624_BASELINE  BH624_CC_1Hz  BH624_post1  BH624_post2             
BH626    BH626_BASELINE  BH626_CC_1Hz  BH626_post1  BH626_post2             
BH634    BH634_BASELINE  BH634_CC_1Hz  BH634_post1  BH634_post2             
BH635    BH635_BASELINE    BH635_SHAM   BH635_SHAM  BH636_post1  BH635_post2
BH638    BH638_BASELINE  BH638_CC_1Hz  BH638_post1  BH638_post2             
BH642    BH642_BASELINE  BH642_CC_1Hz  BH642_post1  BH642_post2             
BH644    BH644_BASELINE  BH644_CC_1Hz  BH644_post1  BH644_post2             
BH646    BH646_BASELINE  BH646_CC_1Hz  BH646_post1  BH646_post2             
BH649    BH649_BASELINE    BH649_SHAM  BH649_post1  BH649_post2  BH649_post3
BH650    BH650_BASELINE  BH650_CC_1Hz  BH650_post1  BH650_post2             
BH653    BH653_BASELINE  BH653_CC_1Hz  BH653_post1  BH653_post2             
BH659    BH659_BASELINE    BH659_SHAM  BH659_post1  BH659_post2  BH659_post3
BH660    BH660_BASELINE  BH660_CC_1Hz  BH660_post1  BH660_post2             
BH662    BH662_BASELINE    BH662_SHAM  BH662_post1  BH662_post2  BH662_post3
BH663    BH663_BASELINE    BH663_SHAM  BH663_post1  BH663_post2  BH663_post3
BH665    BH665_BASELINE    BH665_SHAM  BH665_post1  BH665_post2  BH665_post3

Sampling rates: [3051.7578125] Hz; channels: [32] ; unit: ['volts'] ; conversion: [1.0]
Storage: chunks ['None'] compression ['None']
Block length: 62.51 to 63.31 min (paper: ~62.5 min)
Start-to-start time between consecutive blocks of a rat: 63.0 to 68.1 min

Ten tFUS rats with four blocks each (baseline, CC_1Hz, post1, post2) and six sham rats with five (baseline, SHAM, post1, post2, post3), as in the paper. Blocks follow each other at 63 to 68 min. One rat's labels do not match its files: BH635 has two files labelled BH635_SHAM, then one labelled BH636_post1 (another rat's number) and one BH635_post2, and none post3. Its five files are taken here in time order (baseline, condition, post 1, post 2, post 3), as the other sham rats' five are; the reading that follows the labels instead (the second SHAM file left out, BH636_post1 as post 1, BH635_post2 as post 2, no post 3) is shown as a variant where it bears on a claim. The session of BH649's last block is named ses-None in its file name.

In [3]:
iv_all = pd.concat([M[a]["intervals"].assign(asset_id=a) for a in blocks.asset_id])
iv_all = iv_all.merge(blocks[["asset_id", "subject", "block", "minutes", "n_samples"]], on="asset_id")
print("Label tags:", iv_all.tag.value_counts().to_dict())
nos = iv_all[iv_all.tag == "no_seizure"]
print("Blocks with a 'no_seizure' row (start, stop):", nos[["subject", "block", "start", "stop"]].to_dict("records"))
real = iv_all[iv_all.tag != "no_seizure"]
print(f"\nLargest stop time in each file, against the block length: stop/length in minutes "
      f"{(real.groupby('asset_id').stop.max() / real.groupby('asset_id').minutes.first()).describe().round(3).to_dict()}")
print(f"Largest stop over all files: {real.stop.max():.2f}; shortest block: {blocks.minutes.min():.2f} min = {blocks.minutes.min() * 60:.0f} s")
print("So the label times are minutes: in seconds every seizure would fall in the first 63 s of a 3750 s block.")
d = (real.stop - real.start) * 60
print(f"Label durations, read as minutes: {d.min():.1f} to {d.max():.1f} s, median {d.median():.1f} s; "
      f"{(d < 10).sum()} under the 10 s minimum of Methods C")
print(f"Rows with stop before start: {(real.stop < real.start).sum()}")
first = real.groupby(["asset_id", "tag"]).start.min()
print(f"Seizures starting at the first sample (start below 2 samples): {(real.start * 60 < 2 / tfus.RATE).sum()}; "
      f"ending at the last sample: {((real.stop * 60) > (real.n_samples / tfus.RATE - 2 / tfus.RATE)).sum()}")
pairs = real.groupby(["asset_id", "tag"]).size().unstack()
print(f"Files whose ipsilateral and contralateral counts differ: {(pairs.ipsilateral != pairs.contralateral).sum()} of {len(pairs)}")
# Resolution of the labels and the distance of each hemisphere's last seizure from the block end
# (verifier, round 1: a seizure cut by the block end may not end at the last sample).
vals = real[["start", "stop"]].to_numpy().ravel()
print(f"\nLabel values (minutes) equal to their rounding to 3, 4 and 6 decimals: "
      f"{', '.join(f'{np.mean(np.isclose(vals, np.round(vals, k), rtol=0, atol=1e-9)):.1%}' for k in (3, 4, 6))}; "
      f"first starts at one sample (1/{tfus.RATE:.0f} s): {int(np.isclose(real.start * 60, 1 / tfus.RATE, atol=1e-6).sum())}")
end_gap = (real.n_samples / tfus.RATE - real.stop * 60).groupby([real.asset_id, real.tag]).min()
print(f"Seconds from each block-hemisphere's last seizure end to the block end: smallest {np.sort(end_gap.to_numpy())[:8].round(2).tolist()}; "
      f"within 2 s: {int((end_gap < 2).sum())} of {len(end_gap)}; within 10 s: {int((end_gap < 10).sum())}")
Label tags: {'ipsilateral': 970, 'contralateral': 959, 'no_seizure': 2}
Blocks with a 'no_seizure' row (start, stop): [{'subject': 'BH634', 'block': 'post2', 'start': 0.0, 'stop': 0.0}, {'subject': 'BH638', 'block': 'post2', 'start': 0.0, 'stop': 0.0}]

Largest stop time in each file, against the block length: stop/length in minutes {'count': 68.0, 'mean': 0.898, 'std': 0.11, 'min': 0.563, '25%': 0.844, '50%': 0.938, '75%': 0.986, 'max': 1.0}
Largest stop over all files: 62.71; shortest block: 62.51 min = 3750 s
So the label times are minutes: in seconds every seizure would fall in the first 63 s of a 3750 s block.
Label durations, read as minutes: 10.0 to 464.8 s, median 45.4 s; 0 under the 10 s minimum of Methods C
Rows with stop before start: 0
Seizures starting at the first sample (start below 2 samples): 6; ending at the last sample: 0
Files whose ipsilateral and contralateral counts differ: 19 of 68

Label values (minutes) equal to their rounding to 3, 4 and 6 decimals: 0.0%, 0.0%, 0.2%; first starts at one sample (1/3052 s): 6
Seconds from each block-hemisphere's last seizure end to the block end: smallest [0.97, 0.97, 1.21, 1.21, 1.28, 1.39, 3.37, 6.65]; within 2 s: 6 of 136; within 10 s: 9

The label table gives start and stop times in minutes, not in the seconds NWB prescribes. The notebook eeg_blocks.ipynb checks this against the EEG: the 30 to 80 Hz power of the labelling channels is compared inside and outside the labels, with the labels read as minutes and shifted in time. Every metric here uses the labels in seconds after multiplying by 60.

In [4]:
# Recordings deposited twice: identical label tables, sample counts, or identical samples.
sig = {}
for a in blocks.asset_id:
    m = M[a]
    x = tfus.read_rows(m, 2_000_000, 2_002_000)
    sig[a] = (hashlib.md5(x.tobytes()).hexdigest(), m["n_samples"],
              hashlib.md5(m["intervals"].round(6).to_csv().encode()).hexdigest())
s = pd.DataFrame(sig, index=["samples_md5", "n_samples", "labels_md5"]).T
print("Files sharing 2000 samples at row 2,000,000:", int(s.samples_md5.duplicated(keep=False).sum()))
dl = s[s.labels_md5.duplicated(keep=False)].join(blocks.set_index("asset_id")[["subject", "block"]])
print("Files sharing a label table:", len(dl), dl[["subject", "block"]].to_dict("records"),
      "; their tables:", [M[a]["intervals"].to_dict("records") for a in dl.index])
dup_n = s[s.n_samples.duplicated(keep=False)].join(blocks.set_index("asset_id")[["subject", "block"]])
print("Files sharing a sample count (same length is common at this rate; listed for inspection):")
print(dup_n.sort_values("n_samples")[["n_samples", "subject", "block"]].to_string())
print("read_rows agrees with h5py on a slice:", tfus.check_read(lab[0]))
Files sharing 2000 samples at row 2,000,000: 0
Files sharing a label table: 2 [{'subject': 'BH634', 'block': 'post2'}, {'subject': 'BH638', 'block': 'post2'}] ; their tables: [[{'start': 0.0, 'stop': 0.0, 'tag': 'no_seizure'}], [{'start': 0.0, 'stop': 0.0, 'tag': 'no_seizure'}]]
Files sharing a sample count (same length is common at this rate; listed for inspection):
                                     n_samples subject      block
6bea7ecf-4a97-41c5-b02b-807f4a8ee551  11445760   BH649      post3
37ffbad8-0da1-438f-88ac-1a6396189e0f  11445760   BH646      post1
da0b9f93-8f8c-4400-bf9d-7c76df5a5280  11446016   BH646      post2
dc4dd398-10e1-4f63-a7f5-c85d34897c23  11446016   BH635      post3
63f83270-187c-49f2-bd5f-a14419ecb01c  11446016   BH653      post2
89a990ab-d2d9-4456-9436-51e8eafcfb2e  11446016   BH646   baseline
50d95c00-959a-4aa1-8eed-8b6e3447c937  11446272   BH650      post1
92b03565-87c8-4b4a-b98f-f3b443d310b3  11446272   BH649   baseline
73e82f61-3f18-4728-bda8-13f0ab7ad262  11446272   BH663  condition
af84f573-f568-4a62-94a3-cf8e48380445  11446272   BH665      post2
18a8eacb-841b-4e43-8b32-280baaf299d6  11446784   BH665      post1
5c5fa29b-da36-4863-a8f8-96f62ec175cd  11446784   BH659      post3
3666f00b-65b9-4bfa-b806-655871f41c22  11446784   BH662  condition
7185bf50-0296-442d-8c7e-75d3d2e2eddf  11446784   BH634      post1
8ea6ae9f-cf33-49de-8866-5947e2856e36  11446784   BH650  condition
0d04d0b0-f232-495a-9eec-876cfdf71e62  11446784   BH649      post1
26ca6202-0372-4a47-8352-01bb9326c181  11447040   BH663   baseline
24f8a71b-75cd-4b4c-9685-920a14177c6c  11447040   BH646  condition
fdad091f-cce1-4c5c-a2e0-e72e3c7ad056  11447552   BH659   baseline
459b9525-876a-444d-ac4d-ad083beee70f  11447552   BH650   baseline
d5431724-ca5d-433f-a4c8-0ed031c2d2d4  11447552   BH626  condition
48ca9434-1d81-4ed7-8ff9-76da233b394a  11447808   BH662   baseline
a0ce9c19-7d09-42c1-8097-f7bf659497e4  11447808   BH663      post2
91a3a2c1-593a-48b5-81a1-6d8ba39e809a  11447808   BH665   baseline
493f4bc6-765b-4acf-a1b1-5b2a82b7d331  11447808   BH662      post2
aae0eda8-4402-42a3-8d44-c0d9513ba42e  11448064   BH662      post1
aed79f0d-459a-467a-9604-4038f33b6290  11448064   BH653      post1
571821e2-b4e8-47a3-8659-2ddef9e1418a  11448064   BH653   baseline
b6240577-5545-44c1-a9c9-234d5fefa866  11448320   BH644  condition
e3c38de1-fa23-4ec7-a56a-7f3f73770a31  11448320   BH638      post2
89cbadc8-a5ee-44d5-8390-cecad6c9e813  11448320   BH635   baseline
85807788-6920-4d78-b2c5-1db6076b2f2c  11448320   BH626      post2
1477f857-de0f-418f-bb58-36a06a6e2d9f  11448320   BH626      post1
d854f98d-f32a-460a-bf3a-5a20e1a1b6d1  11448320   BH653  condition
a00641ba-d152-47ec-ad0e-705b0eec94db  11448320   BH660  condition
542119da-2850-49bf-b28e-78760be55839  11448576   BH665      post3
b98a447b-e1ed-4cb5-82a0-c0ea2d34d9dc  11448576   BH659      post1
962e6ddc-5137-42c0-b572-3e48417aa97d  11448576   BH642   baseline
5c3557b7-e501-40a2-9a7b-8f45d3c000e8  11448832   BH660   baseline
b1339bd6-669d-4363-b3f0-78435bdae3fb  11448832   BH644      post1
43f03651-ddf5-49da-9dbb-97b953f50b92  11448832   BH638   baseline
5148e425-a3a4-43d6-a270-1cfd587f302a  11450112   BH642      post2
cb5ea6e6-f7f6-4598-9f84-bf22276606e2  11450112   BH663      post3
ed189a71-124b-41b5-9676-543d8b34d214  11450624   BH650      post2
53a34422-8b88-48f9-bb42-4120677941f3  11450624   BH662      post3
95e07416-b4d1-4dc9-86d3-e992aeac7a4d  11450880   BH663      post1
25b925a2-5330-4eb8-8d15-2a3e8797c3a0  11450880   BH665  condition
cf2b128b-2d1c-47f0-b92e-1e775b571418  11450880   BH624      post1
728fccd2-d993-461a-b4d2-d2be356dabb9  11450880   BH624   baseline
052b5f2e-2d75-4d06-b102-4ee19fcdb67a  11453696   BH659  condition
38087171-3b45-4eef-8870-a76f3b1c6d61  11453696   BH660      post1
read_rows agrees with h5py on a slice: True

No two block files share samples, so no recording is deposited twice. The two files that share a label table are the two blocks without seizures, whose tables hold the same single no_seizure row. Files that share a sample count differ in their samples.

Seizure metrics¶

Per rat, hemisphere and block (M2 of the claims file, Methods C): Seizure Count; Percent Time in Seizure, summed durations over the block length; Seizure Duration, the mean duration of seizures that neither start at the first sample nor end at the last; and Inter-Seizure Interval, the mean interval between neighbouring seizures, computed both as the gap from one seizure's end to the next one's start (isi_gap) and from onset to onset (isi_onset). The paper's words, "time between neighboring seizures", favour the gap. For the interval the two tFUS rats with a block without seizures are left out (Methods C, "two rats were excluded because they had conditions without seizure occurrence").

In [5]:
def metrics_table(blocks, edge=1.5 / tfus.RATE):
    rows = []
    for _, r in blocks.iterrows():
        for h in ("ipsilateral", "contralateral"):
            rows.append({"subject": r.subject, "group": r.group, "block": r.block, "hemi": h,
                         **tfus.block_metrics(M[r.asset_id], h, edge)})
    return pd.DataFrame(rows)

met = metrics_table(blocks)
no_seiz = sorted(met[(met["count"] == 0)].subject.unique())
print("Rat-blocks without seizures:", met[met["count"] == 0][["subject", "group", "block", "hemi"]].to_dict("records"))
print("Rats left out of the inter-seizure interval:", no_seiz, "(Methods C: two rats; Fig. 3C: N = 8 tFUS)")
met.loc[met.subject.isin(no_seiz), ["isi_gap", "isi_onset"]] = np.nan
print("Truncated seizures left out of the duration:", int(met.n_truncated.sum()))
print("\nGroup means per hemisphere and block:")
print(met.groupby(["group", "hemi", "block"])[["count", "percent_time", "duration", "isi_gap", "isi_onset"]].mean().round(2).to_string())
print("\nRanges over rat-blocks:", {c: (round(met[c].min(), 2), round(met[c].max(), 2)) for c in ["count", "percent_time", "duration", "isi_gap", "isi_onset"]})

# The label-following reading of BH635's blocks.
alt = blocks.copy()
b635 = alt[alt.subject == "BH635"].sort_values("start").index
alt = alt.drop(index=b635[2])
alt.loc[b635[3], "block"], alt.loc[b635[4], "block"] = "post1", "post2"
met_alt = metrics_table(alt)
met_alt.loc[met_alt.subject.isin(no_seiz), ["isi_gap", "isi_onset"]] = np.nan

# Variant for the durations: seizures within 2 s of either end of the block counted as cut off.
met_edge = metrics_table(blocks, edge=2.0)
print("\nSeizures left out of the duration with a 2 s edge:", int(met_edge.n_truncated.sum()))
Rat-blocks without seizures: [{'subject': 'BH634', 'group': 'tFUS', 'block': 'post2', 'hemi': 'ipsilateral'}, {'subject': 'BH634', 'group': 'tFUS', 'block': 'post2', 'hemi': 'contralateral'}, {'subject': 'BH638', 'group': 'tFUS', 'block': 'post2', 'hemi': 'ipsilateral'}, {'subject': 'BH638', 'group': 'tFUS', 'block': 'post2', 'hemi': 'contralateral'}]
Rats left out of the inter-seizure interval: ['BH634', 'BH638'] (Methods C: two rats; Fig. 3C: N = 8 tFUS)
Truncated seizures left out of the duration: 6

Group means per hemisphere and block:
                               count  percent_time  duration  isi_gap  isi_onset
group hemi          block                                                       
sham  contralateral baseline   18.17         25.64     56.85   158.10     214.74
                    condition  17.83         24.23     48.88   180.17     228.85
                    post1      18.17         22.24     43.29   180.82     225.74
                    post2      16.33         17.56     40.60   188.64     229.49
                    post3      16.33         15.54     35.52   225.19     260.62
      ipsilateral   baseline   18.17         24.00     53.00   161.71     214.81
                    condition  18.33         24.89     48.55   180.77     229.28
                    post1      18.00         20.60     43.85   182.82     226.21
                    post2      16.83         16.43     37.78   186.57     224.48
                    post3      16.50         15.32     34.45   226.79     261.50
tFUS  contralateral baseline   15.90         24.04     61.00   218.59     285.67
                    condition  11.60         14.80     49.15   242.23     291.44
                    post1       8.40         10.79     49.59   320.95     368.51
                    post2       7.90         10.26     49.88   266.31     317.31
      ipsilateral   baseline   15.80         23.46     59.84   220.19     286.23
                    condition  12.00         15.06     48.52   241.12     290.07
                    post1       8.50         10.58     48.00   304.71     350.17
                    post2       8.00         10.13     48.73   262.02     311.73

Ranges over rat-blocks: {'count': (np.int64(0), np.int64(35)), 'percent_time': (np.float64(0.0), np.float64(56.83)), 'duration': (np.float64(23.65), np.float64(106.74)), 'isi_gap': (np.float64(40.83), np.float64(554.16)), 'isi_onset': (np.float64(105.3), np.float64(605.04))}
Seizures left out of the duration with a 2 s edge: 14
In [6]:
# Statistics: two-way ANOVA and Bonferroni post hoc tests, under the readings of M3.
BL = ["baseline", "condition", "post1", "post2", "post3"]
NAMES = {"baseline": "baseline", "condition": "condition", "post1": "post 1", "post2": "post 2", "post3": "post 3"}

def sham_tests(df, value):
    # Fig. 2: hemisphere by block, sham rats, five blocks. Post hoc: each pair of blocks within each
    # hemisphere (family 'blocks', 20 comparisons) and the hemispheres at each block (family 'hemi', 5).
    comps = []
    for h in ("ipsilateral", "contralateral"):
        for i, b1 in enumerate(BL):
            for b2 in BL[i + 1:]:
                comps.append((f"{h[:6]} {b1}-{b2}", {"hemi": h, "block": b1}, {"hemi": h, "block": b2}, "blocks"))
    for b in BL:
        comps.append((f"ipsi-contra {b}", {"hemi": "ipsilateral", "block": b}, {"hemi": "contralateral", "block": b}, "hemi"))
    out = {}
    for rm in (False, True):
        table, post = tfus.twoway(df, value, "hemi", "block", "subject", comps, rm=rm)
        out["repeated" if rm else "ordinary"] = (table, post)
    return out

def group_tests(df, value, hemi):
    # Fig. 3 and 4: group by block per hemisphere, blocks baseline to post 2. Families (M3):
    # 'within' each block against baseline in each group (6), 'between' sham against tFUS at each block (4).
    d = df[(df.hemi == hemi) & (df.block != "post3")]
    comps = [(f"{g} baseline-{b}", {"group": g, "block": "baseline"}, {"group": g, "block": b}, "within")
             for g in ("sham", "tFUS") for b in BL[1:4]]
    comps += [(f"sham-tFUS {b}", {"group": "sham", "block": b}, {"group": "tFUS", "block": b}, "between") for b in BL[:4]]
    out = {}
    for rm in (False, True):
        table, post = tfus.twoway(d, value, "group", "block", "subject", comps, rm=rm)
        out["repeated" if rm else "ordinary"] = (table, post)
    return out

def show(out, keep=None):
    for k, (table, post) in out.items():
        print(f"  [{k}] main effects:", {i: f"F={r.F:.2f}, p={r.p:.3g}" for i, r in table.iterrows()})
        p = post if keep is None else post[post.comparison.isin(keep)]
        print(p[["comparison", "family", "diff", "stat", "p_raw", "p_family", "p_all"]].round(4).to_string(index=False))

def pct_change(df, value, group="tFUS"):
    # M4: (a) the group mean of the block over the group mean at baseline, minus 1;
    # (b) the mean over rats of each rat's change from its own baseline.
    d = df[df.group == group]
    g = d.groupby(["hemi", "block"])[value].mean().unstack()
    a = (g.div(g["baseline"], axis=0) - 1) * 100
    w = d.pivot_table(index=["hemi", "subject"], columns="block", values=value)
    b = ((w.div(w["baseline"], axis=0) - 1) * 100).groupby("hemi").mean()
    cols = [c for c in BL[1:4]]
    return a[cols], b[cols]

fig2c-sham-duration-stable¶

In the sham group, seizure durations from the ipsilateral and contralateral hemispheres do not differ significantly across time blocks or between hemispheres.

A claim of absence: two-way ANOVA (hemisphere by block) with Bonferroni post hoc tests at P < 0.05, with one value per seizure (reading a, as the Fig. 2C legend says each point is one seizure) or one mean per rat (reading b), each under the ordinary and repeated-measures readings.

In [7]:
sham = blocks[blocks.group == "sham"]
seiz = []
for _, r in sham.iterrows():
    for h in ("ipsilateral", "contralateral"):
        s = tfus.seizures(M[r.asset_id], h)
        s = s[~s.truncated]
        seiz.append(s.assign(subject=r.subject, block=r.block, hemi=h))
seiz = pd.concat(seiz, ignore_index=True)
print(f"Sham seizures: {len(seiz)} (ipsilateral {sum(seiz.hemi == 'ipsilateral')}, contralateral {sum(seiz.hemi == 'contralateral')}); "
      f"duration {seiz.duration.min():.1f} to {seiz.duration.max():.1f} s")
print(seiz.groupby(["hemi", "block"]).duration.agg(["size", "mean", "median"]).round(1).unstack(0).to_string())
res2c = {}
for reading, df in (("a, per seizure", seiz), ("b, per-rat means", met[met.group == "sham"])):
    print(f"\nReading {reading}:")
    out = sham_tests(df, "duration")
    res2c[reading] = out
    for k, (table, post) in out.items():
        sig = post[(post.p_family < 0.05) | (post.p_all < 0.05)]
        print(f"  [{k}] main effects:", {i: f"F={r.F:.2f}, p={r.p:.3g}" for i, r in table.iterrows()})
        print(f"  [{k}] post hoc significant (own family or all): {len(sig)} of {len(post)}")
        print(sig[["comparison", "diff", "p_raw", "p_family", "p_all"]].round(4).to_string(index=False) if len(sig) else "  none")
print("\nVariant, seizures within 2 s of a block end left out (per-rat means):")
for k, (table, post) in sham_tests(met_edge[met_edge.group == "sham"], "duration").items():
    print(f"  [{k}] main effects:", {i: f"F={r.F:.2f}, p={r.p:.3g}" for i, r in table.iterrows()},
          "; post hoc significant (own family):", int((post.p_family < 0.05).sum()))
Sham seizures: 1046 (ipsilateral 526, contralateral 520); duration 10.0 to 224.9 s
                   size                      mean                    median            
hemi      contralateral ipsilateral contralateral ipsilateral contralateral ipsilateral
block                                                                                  
baseline            109         109          53.0        49.6          45.6        43.4
condition           107         110          51.0        51.0          48.1        46.0
post1               108         107          42.2        43.0          44.6        43.5
post2                98         101          40.4        36.6          41.0        36.7
post3                98          99          35.7        34.8          36.3        35.6

Reading a, per seizure:
  [ordinary] main effects: {'C(hemi, Sum)': 'F=1.45, p=0.229', 'C(block, Sum)': 'F=30.45, p=5.47e-24', 'C(hemi, Sum):C(block, Sum)': 'F=0.61, p=0.658'}
  [ordinary] post hoc significant (own family or all): 12 of 25
            comparison    diff  p_raw  p_family  p_all
 ipsila baseline-post2 12.9351 0.0000    0.0000 0.0000
 ipsila baseline-post3 14.7285 0.0000    0.0000 0.0000
ipsila condition-post1  7.9538 0.0020    0.0409 0.0511
ipsila condition-post2 14.3685 0.0000    0.0000 0.0000
ipsila condition-post3 16.1619 0.0000    0.0000 0.0000
    ipsila post1-post3  8.2081 0.0019    0.0389 0.0486
 contra baseline-post1 10.7466 0.0000    0.0006 0.0008
 contra baseline-post2 12.5922 0.0000    0.0000 0.0001
 contra baseline-post3 17.2724 0.0000    0.0000 0.0000
contra condition-post1  8.8301 0.0007    0.0132 0.0165
contra condition-post2 10.6757 0.0001    0.0012 0.0015
contra condition-post3 15.3559 0.0000    0.0000 0.0000
  [repeated] main effects: {'C(hemi, Sum)': 'F=1.99, p=0.159', 'C(block, Sum)': 'F=37.48, p=2.67e-29', 'C(hemi, Sum):C(block, Sum)': 'F=0.66, p=0.621'}
  [repeated] post hoc significant (own family or all): 13 of 25
            comparison    diff  p_raw  p_family  p_all
 ipsila baseline-post1  8.1433 0.0012    0.0235 0.0294
 ipsila baseline-post2 14.4484 0.0000    0.0000 0.0000
 ipsila baseline-post3 17.2031 0.0000    0.0000 0.0000
ipsila condition-post1  7.8534 0.0016    0.0323 0.0404
ipsila condition-post2 14.1584 0.0000    0.0000 0.0000
ipsila condition-post3 16.9132 0.0000    0.0000 0.0000
    ipsila post1-post3  9.0598 0.0004    0.0081 0.0101
 contra baseline-post1 12.4317 0.0000    0.0000 0.0000
 contra baseline-post2 13.8866 0.0000    0.0000 0.0000
 contra baseline-post3 19.3898 0.0000    0.0000 0.0000
contra condition-post1  9.0857 0.0003    0.0057 0.0072
contra condition-post2 10.5406 0.0000    0.0008 0.0010
contra condition-post3 16.0438 0.0000    0.0000 0.0000

Reading b, per-rat means:
  [ordinary] main effects: {'C(hemi, Sum)': 'F=0.24, p=0.628', 'C(block, Sum)': 'F=5.17, p=0.00145', 'C(hemi, Sum):C(block, Sum)': 'F=0.07, p=0.991'}
  [ordinary] post hoc significant (own family or all): 0 of 25
  none
  [repeated] main effects: {'C(hemi, Sum)': 'F=0.29, p=0.591', 'C(block, Sum)': 'F=6.39, p=0.00037', 'C(hemi, Sum):C(block, Sum)': 'F=0.08, p=0.987'}
  [repeated] post hoc significant (own family or all): 1 of 25
           comparison    diff  p_raw  p_family  p_all
contra baseline-post3 21.3313 0.0013    0.0255 0.0318

Variant, seizures within 2 s of a block end left out (per-rat means):
  [ordinary] main effects: {'C(hemi, Sum)': 'F=0.22, p=0.64', 'C(block, Sum)': 'F=5.03, p=0.00173', 'C(hemi, Sum):C(block, Sum)': 'F=0.07, p=0.99'} ; post hoc significant (own family): 0
  [repeated] main effects: {'C(hemi, Sum)': 'F=0.28, p=0.602', 'C(block, Sum)': 'F=6.26, p=0.000431', 'C(hemi, Sum):C(block, Sum)': 'F=0.09, p=0.985'} ; post hoc significant (own family): 1
In [8]:
fig, ax = plt.subplots(figsize=(7, 3))
for k, h in enumerate(("ipsilateral", "contralateral")):
    d = seiz[seiz.hemi == h]
    x = d.block.map({b: i for i, b in enumerate(BL)}) + (k - 0.5) * 0.3
    ax.scatter(x, d.duration, s=4, alpha=0.4, label=h)
ax.set_xticks(range(5), BL); ax.set_ylabel("seizure duration (s)"); ax.legend()
ax.set_title(f"Sham seizures, all points shown ({seiz.duration.min():.0f} to {seiz.duration.max():.0f} s)")
plt.tight_layout(); plt.show()
No description has been provided for this image

Result: not reproduced. The effect of block on sham seizure duration is significant under every reading: per seizure, F = 30.45, p = 5.5e-24 (ordinary) and F = 37.48, p = 2.7e-29 (repeated), with 12 and 13 of 25 post hoc comparisons significant; per rat, p = 0.00145 (ordinary, no post hoc comparison significant) and p = 0.00037 (repeated, contralateral baseline against post 3 significant, p = 0.026). The hemisphere effect is not significant under any reading (p = 0.16 to 0.63). Mean durations fall from 49.6 to 53.0 s at baseline to 34.8 to 35.7 s at post 3. Counting the seizures within 2 s of either end of a block as cut off (14 left out, against 6) changes nothing (per rat, block p = 0.0017 ordinary and 0.00043 repeated).

fig2d-seizures-under-two-minutes¶

Pooled over blocks, most seizures in the sham group last less than 2 minutes, and the two hemispheres have similar distributions.

Seizures of the six sham rats, all five blocks pooled, per hemisphere. Reproduced when more than half last under 120 s in each hemisphere. Medians and a two-sample Kolmogorov-Smirnov test are description only.

In [9]:
allseiz = []
for _, r in sham.iterrows():
    for h in ("ipsilateral", "contralateral"):
        allseiz.append(tfus.seizures(M[r.asset_id], h).assign(subject=r.subject, block=r.block, hemi=h))
allseiz = pd.concat(allseiz, ignore_index=True)
for h in ("ipsilateral", "contralateral"):
    d = allseiz[allseiz.hemi == h].duration
    print(f"{h}: {len(d)} seizures, {100 * (d < 120).mean():.1f}% under 120 s, median {d.median():.1f} s, range {d.min():.1f} to {d.max():.1f} s")
    print("   per rat, % under 120 s:", (allseiz[allseiz.hemi == h].groupby("subject").duration.apply(lambda x: round(100 * (x < 120).mean(), 1))).to_dict())
ks = stats.ks_2samp(allseiz[allseiz.hemi == "ipsilateral"].duration, allseiz[allseiz.hemi == "contralateral"].duration)
print(f"Kolmogorov-Smirnov ipsilateral against contralateral: D = {ks.statistic:.3f}, p = {ks.pvalue:.3g}")
print(f"Excluding truncated seizures changes the counts by {int(allseiz.truncated.sum())}")
fig, ax = plt.subplots(figsize=(6, 3))
bins = np.arange(0, 241, 6)
for h in ("ipsilateral", "contralateral"):
    ax.hist(allseiz[allseiz.hemi == h].duration, bins=bins, alpha=0.5, label=h)
ax.axvline(120, color="k", lw=0.8); ax.set_xlabel("seizure duration (s)"); ax.legend()
print(f"Seizures beyond the 240 s axis: {(allseiz.duration > 240).sum()}")
plt.tight_layout(); plt.show()
ipsilateral: 527 seizures, 99.4% under 120 s, median 41.5 s, range 10.0 to 224.9 s
   per rat, % under 120 s: {'BH635': 97.9, 'BH649': 100.0, 'BH659': 100.0, 'BH662': 100.0, 'BH663': 100.0, 'BH665': 100.0}
contralateral: 521 seizures, 99.2% under 120 s, median 43.5 s, range 10.0 to 464.8 s
   per rat, % under 120 s: {'BH635': 97.0, 'BH649': 100.0, 'BH659': 100.0, 'BH662': 100.0, 'BH663': 100.0, 'BH665': 100.0}
Kolmogorov-Smirnov ipsilateral against contralateral: D = 0.082, p = 0.056
Excluding truncated seizures changes the counts by 2
Seizures beyond the 240 s axis: 1
No description has been provided for this image

Result: reproduced. 99.4% of the 527 ipsilateral and 99.2% of the 521 contralateral sham seizures last under 120 s, with medians of 41.5 and 43.5 s; every rat is at 97% or more. The KS test (D = 0.082, p = 0.056) is description and does not decide.

fig2e-sham-count-stable¶

In the sham group, seizure count does not differ significantly between time blocks or hemispheres, with a slight decrease in the last two hours.

A claim of absence: Seizure Count per rat, hemisphere and block, five blocks, two-way ANOVA (hemisphere by block) with Bonferroni post hoc tests at P < 0.05.

In [10]:
s = met[met.group == "sham"]
print("Mean count (rats) per hemisphere and block:")
print(s.groupby(["hemi", "block"])["count"].agg(["mean", "sem"]).round(2).unstack(0).to_string())
print("\nPer rat (ipsilateral):")
print(s[s.hemi == "ipsilateral"].pivot(index="subject", columns="block", values="count").to_string())
out = sham_tests(s, "count")
for k, (table, post) in out.items():
    sig = post[(post.p_family < 0.05) | (post.p_all < 0.05)]
    print(f"[{k}] main effects:", {i: f"F={r.F:.2f}, p={r.p:.3g}" for i, r in table.iterrows()},
          f"; significant post hoc: {len(sig)} of {len(post)}; smallest p (own family) {post.p_family.min():.3g}")
early = s[s.block.isin(BL[:3])]["count"].mean(); late = s[s.block.isin(BL[3:])]["count"].mean()
print(f"\nMean count, baseline to post 1: {early:.2f}; post 2 and post 3: {late:.2f}")
s_alt = met_alt[met_alt.group == "sham"]
out_alt = sham_tests(s_alt, "count")
print("Variant, BH635 blocks by their labels:", {k: f"block p={t.iloc[1].p:.3g}, smallest post hoc p {p.p_family.min():.3g}" for k, (t, p) in out_alt.items()})
Mean count (rats) per hemisphere and block:
                   mean                       sem            
hemi      contralateral ipsilateral contralateral ipsilateral
block                                                        
baseline          18.17       18.17          3.18        3.18
condition         17.83       18.33          3.33        3.88
post1             18.17       18.00          4.06        3.92
post2             16.33       16.83          3.24        3.48
post3             16.33       16.50          3.01        3.69

Per rat (ipsilateral):
block    baseline  condition  post1  post2  post3
subject                                          
BH635          14         34     34     30     33
BH649          22         14     13     10     11
BH659          32         26     25     25     18
BH662          17         14     10     11      7
BH663          13         12     10     11     17
BH665          11         10     16     14     13
[ordinary] main effects: {'C(hemi, Sum)': 'F=0.01, p=0.929', 'C(block, Sum)': 'F=0.13, p=0.972', 'C(hemi, Sum):C(block, Sum)': 'F=0.00, p=1'} ; significant post hoc: 0 of 25; smallest p (own family) 1
[repeated] main effects: {'C(hemi, Sum)': 'F=0.02, p=0.877', 'C(block, Sum)': 'F=0.38, p=0.821', 'C(hemi, Sum):C(block, Sum)': 'F=0.01, p=1'} ; significant post hoc: 0 of 25; smallest p (own family) 1

Mean count, baseline to post 1: 18.11; post 2 and post 3: 16.50
Variant, BH635 blocks by their labels: {'ordinary': 'block p=0.656, smallest post hoc p 1', 'repeated': 'block p=0.612, smallest post hoc p 1'}

Result: reproduced. No main effect is significant (block p = 0.97 ordinary and 0.82 repeated; hemisphere p = 0.93 and 0.88) and no post hoc comparison is (smallest Bonferroni p = 1). The mean count is 18.11 over baseline to post 1 and 16.50 over post 2 and post 3, the slight decrease the paper describes. With BH635's blocks taken by their labels the block effect stays non-significant (p = 0.66 and 0.61).

fig2f-sham-percent-time-post3¶

In the sham group, percent time in seizure in the contralateral hemisphere differs significantly between the sham condition block and post 3, suggesting the model is no longer stable in the fifth hour.

Percent Time in Seizure, sham rats, five blocks, hemisphere by block. "sham" read as (a) the condition block or (b) the baseline block. Reproduced when, under one reading, the contralateral comparison with post 3 is significant at P < 0.05.

In [11]:
print("Mean percent time (rats) per hemisphere and block:")
print(s.groupby(["hemi", "block"])["percent_time"].agg(["mean", "sem"]).round(2).unstack(0).to_string())
keep = ["contra condition-post3", "contra baseline-post3", "ipsila condition-post3", "ipsila baseline-post3"]
for name, df in (("blocks in time order", s), ("variant, BH635 by labels (no post 3 for BH635)", s_alt)):
    print(f"\n{name}:")
    show(sham_tests(df, "percent_time"), keep)
Mean percent time (rats) per hemisphere and block:
                   mean                       sem            
hemi      contralateral ipsilateral contralateral ipsilateral
block                                                        
baseline          25.64       24.00          3.75        3.62
condition         24.23       24.89          6.25        6.96
post1             22.24       20.60          5.73        4.28
post2             17.56       16.43          3.50        2.96
post3             15.54       15.32          3.25        3.67

blocks in time order:
  [ordinary] main effects: {'C(hemi, Sum)': 'F=0.07, p=0.786', 'C(block, Sum)': 'F=1.75, p=0.153', 'C(hemi, Sum):C(block, Sum)': 'F=0.02, p=0.999'}
            comparison family    diff   stat  p_raw  p_family  p_all
 ipsila baseline-post3 blocks  8.6809 1.3373 0.1872       1.0    1.0
ipsila condition-post3 blocks  9.5664 1.4737 0.1468       1.0    1.0
 contra baseline-post3 blocks 10.1091 1.5573 0.1257       1.0    1.0
contra condition-post3 blocks  8.6947 1.3394 0.1865       1.0    1.0
  [repeated] main effects: {'C(hemi, Sum)': 'F=0.33, p=0.568', 'C(block, Sum)': 'F=7.77, p=7.53e-05', 'C(hemi, Sum):C(block, Sum)': 'F=0.11, p=0.98'}
            comparison family    diff   stat  p_raw  p_family  p_all
 ipsila baseline-post3 blocks  8.6809 2.8146 0.0072    0.1444 0.1805
ipsila condition-post3 blocks  9.5664 3.1017 0.0033    0.0664 0.0829
 contra baseline-post3 blocks 10.1091 3.2777 0.0020    0.0404 0.0505
contra condition-post3 blocks  8.6947 2.8191 0.0071    0.1427 0.1784

variant, BH635 by labels (no post 3 for BH635):
  [ordinary] main effects: {'C(hemi, Sum)': 'F=0.03, p=0.869', 'C(block, Sum)': 'F=2.83, p=0.0346', 'C(hemi, Sum):C(block, Sum)': 'F=0.02, p=0.999'}
            comparison family    diff   stat  p_raw  p_family  p_all
 ipsila baseline-post3 blocks 11.8732 1.9212 0.0607    1.0000    1.0
ipsila condition-post3 blocks 12.7587 2.0645 0.0444    0.8880    1.0
 contra baseline-post3 blocks 12.5985 2.0385 0.0470    0.9405    1.0
contra condition-post3 blocks 11.1840 1.8097 0.0766    1.0000    1.0
  [repeated] main effects: {'C(hemi, Sum)': 'F=0.10, p=0.751', 'C(block, Sum)': 'F=6.69, p=0.00028', 'C(hemi, Sum):C(block, Sum)': 'F=0.08, p=0.988'}
            comparison family   diff   stat  p_raw  p_family  p_all
 ipsila baseline-post3 blocks 8.8340 2.6494 0.0112    0.2247 0.2808
ipsila condition-post3 blocks 9.7195 2.9149 0.0056    0.1125 0.1407
 contra baseline-post3 blocks 9.5593 2.8669 0.0064    0.1279 0.1598
contra condition-post3 blocks 8.1448 2.4427 0.0188    0.3752 0.4690

Result: reproduced, resting on assumptions. Under the repeated-measures reading the contralateral comparison of baseline (reading b of "sham") with post 3 is significant in its family (Bonferroni p = 0.040), a decrease from 25.6% to 15.5%; over all 25 comparisons it is not (p = 0.051), and condition against post 3 is not (p = 0.14). Under the ordinary reading no comparison is significant (p = 1). The result rests on the repeated-measures reading, the family reading and on taking BH635's files in time order: with BH635 by its labels the comparison is not significant (p = 0.13 repeated, 0.94 ordinary).

Figure 3: tFUS against sham¶

Each metric is tested per hemisphere with a group by block two-way ANOVA (baseline, condition, post 1, post 2; post 3 left out, Results A), with Bonferroni post hoc tests: each block against baseline within each group (family within, six comparisons) and sham against tFUS at each block (family between, four); p_all corrects over all ten. Percent changes are given under both readings of M4.

In [12]:
def fig3(value, df=met):
    a, b = pct_change(df, value)
    print(f"{value}: tFUS change from baseline, %, reading (a) ratio of group means:")
    print(a.round(1).to_string())
    print(f"reading (b) mean of each rat's change:")
    print(b.round(1).to_string())
    print("Group means and SEM:")
    print(df[df.block != "post3"].groupby(["hemi", "group", "block"])[value].agg(["mean", "sem", "count"]).round(2).unstack(1).to_string())
    res = {}
    for h in ("ipsilateral", "contralateral"):
        print(f"\n{h}:")
        res[h] = group_tests(df, value, h)
        show(res[h])
    return a, b, res

fig3a-count-reduction¶

In the tFUS group, seizure count fell from baseline by 9%, 36% and 42% in the ipsilateral S1 and by 10%, 41% and 42% in the contralateral S1 during stimulation, post 1 and post 2, with significant reductions from baseline to post 1 and to post 2 in both hemispheres.

In [13]:
a, b, res3a = fig3("count")
exp = {("ipsilateral", "condition"): 9, ("ipsilateral", "post1"): 36, ("ipsilateral", "post2"): 42,
       ("contralateral", "condition"): 10, ("contralateral", "post1"): 41, ("contralateral", "post2"): 42}
for name, t in (("a", a), ("b", b)):
    rows = [{"hemi": h, "block": k, "expected": v, "measured decrease": round(-t.loc[h, k], 1),
             "within 10%": abs(-t.loc[h, k] - v) <= 0.1 * v} for (h, k), v in exp.items()]
    print(f"\nReading ({name}) of M4:"); print(pd.DataFrame(rows).to_string(index=False))
count: tFUS change from baseline, %, reading (a) ratio of group means:
block          condition  post1  post2
hemi                                  
contralateral      -27.0  -47.2  -50.3
ipsilateral        -24.1  -46.2  -49.4
reading (b) mean of each rat's change:
block          condition  post1  post2
hemi                                  
contralateral      -10.5  -41.4  -42.4
ipsilateral         -8.7  -36.4  -41.9
Group means and SEM:
                          mean         sem       count     
group                     sham  tFUS  sham  tFUS  sham tFUS
hemi          block                                        
contralateral baseline   18.17  15.9  3.18  2.24     6   10
              condition  17.83  11.6  3.33  0.91     6   10
              post1      18.17   8.4  4.06  1.64     6   10
              post2      16.33   7.9  3.24  1.72     6   10
ipsilateral   baseline   18.17  15.8  3.18  2.11     6   10
              condition  18.33  12.0  3.88  0.91     6   10
              post1      18.00   8.5  3.92  1.64     6   10
              post2      16.83   8.0  3.48  1.73     6   10

ipsilateral:
  [ordinary] main effects: {'C(group, Sum)': 'F=14.97, p=0.000287', 'C(block, Sum)': 'F=2.07, p=0.115', 'C(group, Sum):C(block, Sum)': 'F=0.85, p=0.47'}
             comparison  family    diff    stat  p_raw  p_family  p_all
sham baseline-condition  within -0.1667 -0.0427 0.9661    1.0000 1.0000
    sham baseline-post1  within  0.1667  0.0427 0.9661    1.0000 1.0000
    sham baseline-post2  within  1.3333  0.3414 0.7341    1.0000 1.0000
tFUS baseline-condition  within  3.8000  1.2560 0.2143    1.0000 1.0000
    tFUS baseline-post1  within  7.3000  2.4128 0.0191    0.1148 0.1913
    tFUS baseline-post2  within  7.8000  2.5780 0.0126    0.0756 0.1259
     sham-tFUS baseline between  2.3667  0.6774 0.5009    1.0000 1.0000
    sham-tFUS condition between  6.3333  1.8128 0.0752    0.3009 0.7522
        sham-tFUS post1 between  9.5000  2.7193 0.0087    0.0348 0.0870
        sham-tFUS post2 between  8.8333  2.5284 0.0143    0.0572 0.1430
  [repeated] main effects: {'C(group, Sum)': 'F=6.55, p=0.0227', 'C(block, Sum)': 'F=2.39, p=0.0821', 'C(group, Sum):C(block, Sum)': 'F=1.50, p=0.23'}
             comparison  family    diff    stat  p_raw  p_family  p_all
sham baseline-condition  within -0.1667 -0.0565 0.9552    1.0000 1.0000
    sham baseline-post1  within  0.1667  0.0565 0.9552    1.0000 1.0000
    sham baseline-post2  within  1.3333  0.4516 0.6539    1.0000 1.0000
tFUS baseline-condition  within  3.8000  1.6617 0.1040    0.6242 1.0000
    tFUS baseline-post1  within  7.3000  3.1922 0.0027    0.0160 0.0267
    tFUS baseline-post2  within  7.8000  3.4108 0.0014    0.0087 0.0144
     sham-tFUS baseline between  2.3667  0.6774 0.5025    1.0000 1.0000
    sham-tFUS condition between  6.3333  1.8128 0.0782    0.3127 0.7818
        sham-tFUS post1 between  9.5000  2.7193 0.0100    0.0400 0.1000
        sham-tFUS post2 between  8.8333  2.5284 0.0160    0.0639 0.1597

contralateral:
  [ordinary] main effects: {'C(group, Sum)': 'F=15.09, p=0.000273', 'C(block, Sum)': 'F=2.26, p=0.0916', 'C(group, Sum):C(block, Sum)': 'F=0.91, p=0.442'}
             comparison  family   diff   stat  p_raw  p_family  p_all
sham baseline-condition  within 0.3333 0.0868 0.9312    1.0000 1.0000
    sham baseline-post1  within 0.0000 0.0000 1.0000    1.0000 1.0000
    sham baseline-post2  within 1.8333 0.4771 0.6351    1.0000 1.0000
tFUS baseline-condition  within 4.3000 1.4447 0.1541    0.9247 1.0000
    tFUS baseline-post1  within 7.5000 2.5199 0.0146    0.0877 0.1462
    tFUS baseline-post2  within 8.0000 2.6879 0.0095    0.0567 0.0945
     sham-tFUS baseline between 2.2667 0.6595 0.5123    1.0000 1.0000
    sham-tFUS condition between 6.2333 1.8137 0.0751    0.3003 0.7508
        sham-tFUS post1 between 9.7667 2.8418 0.0062    0.0250 0.0625
        sham-tFUS post2 between 8.4333 2.4538 0.0173    0.0691 0.1727
  [repeated] main effects: {'C(group, Sum)': 'F=6.64, p=0.022', 'C(block, Sum)': 'F=2.64, p=0.062', 'C(group, Sum):C(block, Sum)': 'F=1.58, p=0.208'}
             comparison  family    diff    stat  p_raw  p_family  p_all
sham baseline-condition  within  0.3333  0.1144 0.9095    1.0000 1.0000
    sham baseline-post1  within -0.0000 -0.0000 1.0000    1.0000 1.0000
    sham baseline-post2  within  1.8333  0.6289 0.5328    1.0000 1.0000
tFUS baseline-condition  within  4.3000  1.9044 0.0637    0.3824 0.6373
    tFUS baseline-post1  within  7.5000  3.3216 0.0019    0.0112 0.0186
    tFUS baseline-post2  within  8.0000  3.5430 0.0010    0.0059 0.0098
     sham-tFUS baseline between  2.2667  0.6595 0.5137    1.0000 1.0000
    sham-tFUS condition between  6.2333  1.8137 0.0780    0.3119 0.7799
        sham-tFUS post1 between  9.7667  2.8418 0.0073    0.0292 0.0731
        sham-tFUS post2 between  8.4333  2.4538 0.0191    0.0762 0.1905

Reading (a) of M4:
         hemi     block  expected  measured decrease  within 10%
  ipsilateral condition         9               24.1       False
  ipsilateral     post1        36               46.2       False
  ipsilateral     post2        42               49.4       False
contralateral condition        10               27.0       False
contralateral     post1        41               47.2       False
contralateral     post2        42               50.3       False

Reading (b) of M4:
         hemi     block  expected  measured decrease  within 10%
  ipsilateral condition         9                8.7        True
  ipsilateral     post1        36               36.4        True
  ipsilateral     post2        42               41.9        True
contralateral condition        10               10.5        True
contralateral     post1        41               41.4        True
contralateral     post2        42               42.4        True

Result: reproduced. Under reading (b) of M4, each rat's change from its own baseline, the six decreases are 8.7%, 36.4% and 41.9% (ipsilateral) and 10.5%, 41.4% and 42.4% (contralateral), all within tolerance of 9, 36, 42, 10, 41 and 42; reading (a) gives 24 to 50%, outside. Under the repeated-measures reading baseline against post 1 and against post 2 are significant in both hemispheres (Bonferroni p = 0.016 and 0.0087 ipsilateral, 0.011 and 0.0059 contralateral, in the within family; 0.027, 0.014, 0.019 and 0.0098 over all ten). Under the ordinary reading none of the four is significant (p = 0.057 to 0.115).

fig3a-count-sham-vs-tfus¶

Seizure count in the sham group stays steady, and the sham and tFUS groups differ significantly during post 1 and post 2.

From the same tests: sham against tFUS at post 1 and post 2 (in both hemispheres, reading a, or either, reading b), and no sham block different from sham baseline.

In [14]:
for h in ("ipsilateral", "contralateral"):
    for k, (table, post) in res3a[h].items():
        p = post[post.comparison.isin(["sham-tFUS post1", "sham-tFUS post2", "sham baseline-condition", "sham baseline-post1", "sham baseline-post2"])]
        print(h, k, {r.comparison: (round(r.diff, 2), round(r.p_family, 4), round(r.p_all, 4)) for r in p.itertuples()})
ipsilateral ordinary {'sham baseline-condition': (-0.17, 1.0, 1.0), 'sham baseline-post1': (0.17, 1.0, 1.0), 'sham baseline-post2': (1.33, 1.0, 1.0), 'sham-tFUS post1': (9.5, 0.0348, 0.087), 'sham-tFUS post2': (8.83, 0.0572, 0.143)}
ipsilateral repeated {'sham baseline-condition': (-0.17, 1.0, 1.0), 'sham baseline-post1': (0.17, 1.0, 1.0), 'sham baseline-post2': (1.33, 1.0, 1.0), 'sham-tFUS post1': (9.5, 0.04, 0.1), 'sham-tFUS post2': (8.83, 0.0639, 0.1597)}
contralateral ordinary {'sham baseline-condition': (0.33, 1.0, 1.0), 'sham baseline-post1': (0.0, 1.0, 1.0), 'sham baseline-post2': (1.83, 1.0, 1.0), 'sham-tFUS post1': (9.77, 0.025, 0.0625), 'sham-tFUS post2': (8.43, 0.0691, 0.1727)}
contralateral repeated {'sham baseline-condition': (0.33, 1.0, 1.0), 'sham baseline-post1': (-0.0, 1.0, 1.0), 'sham baseline-post2': (1.83, 1.0, 1.0), 'sham-tFUS post1': (9.77, 0.0292, 0.0731), 'sham-tFUS post2': (8.43, 0.0762, 0.1905)}

Result: partially reproduced. Sham against tFUS is significant at post 1 in both hemispheres under both ANOVA readings with the between family (ordinary p = 0.035 ipsilateral and 0.025 contralateral; repeated 0.040 and 0.029), and at post 2 in neither (ordinary 0.057 and 0.069; repeated 0.064 and 0.076). No sham block differs from sham baseline (p = 1 under both readings), so the sham count is steady. Only one of post 1 and post 2 is significant, the criterion's partial outcome. With BH635's blocks by their labels the pattern turns over (post 2 significant, 0.038 to 0.048; post 1 not, 0.055 to 0.062), still one of the two. The first version of this attempt reported ipsilateral post 2 as significant (p = 0.046) under the repeated reading; that p came from a normal reference in place of the t distribution (see the summary).

fig3b-percent-time-reduction¶

In the tFUS group, percent time in seizure decreased significantly from baseline by 33% (ipsilateral) and 35% (contralateral) during stimulation and by 55% in post 1 and post 2 in both hemispheres.

In [15]:
a, b, res3b = fig3("percent_time")
exp = {("ipsilateral", "condition"): 33, ("contralateral", "condition"): 35,
       ("ipsilateral", "post1"): 55, ("contralateral", "post1"): 55,
       ("ipsilateral", "post2"): 55, ("contralateral", "post2"): 55}
for name, t in (("a", a), ("b", b)):
    rows = [{"hemi": h, "block": k, "expected": v, "measured decrease": round(-t.loc[h, k], 1),
             "within 10%": abs(-t.loc[h, k] - v) <= 0.1 * v} for (h, k), v in exp.items()]
    print(f"\nReading ({name}) of M4:"); print(pd.DataFrame(rows).to_string(index=False))
percent_time: tFUS change from baseline, %, reading (a) ratio of group means:
block          condition  post1  post2
hemi                                  
contralateral      -38.4  -55.1  -57.3
ipsilateral        -35.8  -54.9  -56.8
reading (b) mean of each rat's change:
block          condition  post1  post2
hemi                                  
contralateral      -34.8  -55.3  -55.2
ipsilateral        -32.5  -55.5  -54.9
Group means and SEM:
                          mean          sem       count     
group                     sham   tFUS  sham  tFUS  sham tFUS
hemi          block                                         
contralateral baseline   25.64  24.04  3.75  2.63     6   10
              condition  24.23  14.80  6.25  1.46     6   10
              post1      22.24  10.79  5.73  2.22     6   10
              post2      17.56  10.26  3.50  2.32     6   10
ipsilateral   baseline   24.00  23.46  3.62  2.51     6   10
              condition  24.89  15.06  6.96  1.47     6   10
              post1      20.60  10.58  4.28  2.21     6   10
              post2      16.43  10.13  2.96  2.27     6   10

ipsilateral:
  [ordinary] main effects: {'C(group, Sum)': 'F=8.66, p=0.00474', 'C(block, Sum)': 'F=5.15, p=0.00326', 'C(group, Sum):C(block, Sum)': 'F=0.95, p=0.422'}
             comparison  family    diff    stat  p_raw  p_family  p_all
sham baseline-condition  within -0.8855 -0.1746 0.8620    1.0000 1.0000
    sham baseline-post1  within  3.4036  0.6712 0.5048    1.0000 1.0000
    sham baseline-post2  within  7.5759  1.4940 0.1408    0.8447 1.0000
tFUS baseline-condition  within  8.3905  2.1362 0.0370    0.2223 0.3705
    tFUS baseline-post1  within 12.8737  3.2776 0.0018    0.0108 0.0180
    tFUS baseline-post2  within 13.3245  3.3923 0.0013    0.0077 0.0128
     sham-tFUS baseline between  0.5481  0.1208 0.9042    1.0000 1.0000
    sham-tFUS condition between  9.8242  2.1661 0.0346    0.1383 0.3458
        sham-tFUS post1 between 10.0182  2.2089 0.0313    0.1252 0.3129
        sham-tFUS post2 between  6.2967  1.3883 0.1705    0.6821 1.0000
  [repeated] main effects: {'C(group, Sum)': 'F=2.82, p=0.115', 'C(block, Sum)': 'F=13.56, p=2.51e-06', 'C(group, Sum):C(block, Sum)': 'F=3.08, p=0.0377'}
             comparison  family    diff    stat  p_raw  p_family  p_all
sham baseline-condition  within -0.8855 -0.3139 0.7551    1.0000 1.0000
    sham baseline-post1  within  3.4036  1.2066 0.2343    1.0000 1.0000
    sham baseline-post2  within  7.5759  2.6857 0.0103    0.0619 0.1032
tFUS baseline-condition  within  8.3905  3.8401 0.0004    0.0025 0.0041
    tFUS baseline-post1  within 12.8737  5.8919 0.0000    0.0000 0.0000
    tFUS baseline-post2  within 13.3245  6.0983 0.0000    0.0000 0.0000
     sham-tFUS baseline between  0.5481  0.1208 0.9049    1.0000 1.0000
    sham-tFUS condition between  9.8242  2.1661 0.0409    0.1636 0.4090
        sham-tFUS post1 between 10.0182  2.2089 0.0374    0.1496 0.3740
        sham-tFUS post2 between  6.2967  1.3883 0.1783    0.7133 1.0000

contralateral:
  [ordinary] main effects: {'C(group, Sum)': 'F=9.92, p=0.00262', 'C(block, Sum)': 'F=4.94, p=0.00412', 'C(group, Sum):C(block, Sum)': 'F=0.81, p=0.495'}
             comparison  family    diff   stat  p_raw  p_family  p_all
sham baseline-condition  within  1.4145 0.2677 0.7899    1.0000 1.0000
    sham baseline-post1  within  3.4065 0.6447 0.5217    1.0000 1.0000
    sham baseline-post2  within  8.0811 1.5295 0.1318    0.7907 1.0000
tFUS baseline-condition  within  9.2445 2.2588 0.0278    0.1669 0.2781
    tFUS baseline-post1  within 13.2506 3.2376 0.0020    0.0122 0.0203
    tFUS baseline-post2  within 13.7799 3.3670 0.0014    0.0083 0.0138
     sham-tFUS baseline between  1.5997 0.3385 0.7363    1.0000 1.0000
    sham-tFUS condition between  9.4297 1.9954 0.0509    0.2035 0.5088
        sham-tFUS post1 between 11.4438 2.4215 0.0187    0.0749 0.1872
        sham-tFUS post2 between  7.2985 1.5444 0.1281    0.5125 1.0000
  [repeated] main effects: {'C(group, Sum)': 'F=3.13, p=0.0988', 'C(block, Sum)': 'F=14.33, p=1.43e-06', 'C(group, Sum):C(block, Sum)': 'F=2.93, p=0.0444'}
             comparison  family    diff   stat  p_raw  p_family  p_all
sham baseline-condition  within  1.4145 0.5101 0.6126    1.0000 1.0000
    sham baseline-post1  within  3.4065 1.2286 0.2261    1.0000 1.0000
    sham baseline-post2  within  8.0811 2.9145 0.0057    0.0341 0.0569
tFUS baseline-condition  within  9.2445 4.3042 0.0001    0.0006 0.0010
    tFUS baseline-post1  within 13.2506 6.1695 0.0000    0.0000 0.0000
    tFUS baseline-post2  within 13.7799 6.4159 0.0000    0.0000 0.0000
     sham-tFUS baseline between  1.5997 0.3385 0.7382    1.0000 1.0000
    sham-tFUS condition between  9.4297 1.9954 0.0587    0.2347 0.5868
        sham-tFUS post1 between 11.4438 2.4216 0.0243    0.0970 0.2426
        sham-tFUS post2 between  7.2985 1.5444 0.1369    0.5477 1.0000

Reading (a) of M4:
         hemi     block  expected  measured decrease  within 10%
  ipsilateral condition        33               35.8        True
contralateral condition        35               38.4        True
  ipsilateral     post1        55               54.9        True
contralateral     post1        55               55.1        True
  ipsilateral     post2        55               56.8        True
contralateral     post2        55               57.3        True

Reading (b) of M4:
         hemi     block  expected  measured decrease  within 10%
  ipsilateral condition        33               32.5        True
contralateral condition        35               34.8        True
  ipsilateral     post1        55               55.5        True
contralateral     post1        55               55.3        True
  ipsilateral     post2        55               54.9        True
contralateral     post2        55               55.2        True

Result: reproduced. The decreases under reading (b) of M4 are 32.5% and 34.8% (stimulation), 55.5% and 55.3% (post 1), 54.9% and 55.2% (post 2), ipsilateral and contralateral, all within tolerance; reading (a) gives 35.8% to 57.3%, also within. Under the repeated-measures reading all six comparisons with baseline are significant (Bonferroni p from 0.0025 down to below 0.0001), so reading (a) of "significantly" holds; under the ordinary reading post 1 and post 2 are (p = 0.008 to 0.012) and stimulation is not (p = 0.22 and 0.17).

fig3b-sham-percent-time-no-change¶

In the sham group, percent time in seizure decreased slightly but did not differ significantly from baseline in any block.

A claim of absence: no sham block (condition, post 1, post 2) differs from sham baseline at P < 0.05 in either hemisphere.

In [16]:
for h in ("ipsilateral", "contralateral"):
    for k, (table, post) in res3b[h].items():
        p = post[post.comparison.str.startswith("sham baseline")]
        print(h, k, {r.comparison: (round(r.diff, 2), round(r.p_family, 4), round(r.p_all, 4)) for r in p.itertuples()})
ipsilateral ordinary {'sham baseline-condition': (-0.89, 1.0, 1.0), 'sham baseline-post1': (3.4, 1.0, 1.0), 'sham baseline-post2': (7.58, 0.8447, 1.0)}
ipsilateral repeated {'sham baseline-condition': (-0.89, 1.0, 1.0), 'sham baseline-post1': (3.4, 1.0, 1.0), 'sham baseline-post2': (7.58, 0.0619, 0.1032)}
contralateral ordinary {'sham baseline-condition': (1.41, 1.0, 1.0), 'sham baseline-post1': (3.41, 1.0, 1.0), 'sham baseline-post2': (8.08, 0.7907, 1.0)}
contralateral repeated {'sham baseline-condition': (1.41, 1.0, 1.0), 'sham baseline-post1': (3.41, 1.0, 1.0), 'sham baseline-post2': (8.08, 0.0341, 0.0569)}

Result: not reproduced, resting on assumptions. The two ANOVA readings disagree, and so do the two family readings. Under the ordinary reading no sham block differs from baseline (smallest Bonferroni p = 0.79). Under the repeated-measures reading, adopted here as the paper's test with the within family (see the summary), contralateral post 2 differs from baseline (p = 0.034; ipsilateral post 2 p = 0.062); over all ten comparisons it does not (p = 0.057). The sham percent time falls from 24.0% to 16.4% (ipsilateral) and from 25.6% to 17.6% (contralateral). With BH635's blocks by their labels, contralateral post 2 is significant under the repeated reading (p = 0.024) and not under the ordinary one (p = 0.53).

In [17]:
# Variant: BH635's blocks by their labels (seizure_metrics data check). Sham comparisons and sham against
# tFUS, both ANOVA readings.
for k in ("ordinary", "repeated"):
    for value in ("count", "percent_time", "isi_gap", "duration"):
        for h in ("ipsilateral", "contralateral"):
            table, post = group_tests(met_alt, value, h)[k]
            p = post[post.comparison.str.startswith("sham baseline") | (post.family == "between")]
            print(k, value, h, {r.comparison: round(r.p_family, 4) for r in p.itertuples()})
ordinary count ipsilateral {'sham baseline-condition': 1.0, 'sham baseline-post1': 1.0, 'sham baseline-post2': 1.0, 'sham-tFUS baseline': 1.0, 'sham-tFUS condition': 0.2946, 'sham-tFUS post1': 0.0552, 'sham-tFUS post2': 0.038}
ordinary count contralateral {'sham baseline-condition': 1.0, 'sham baseline-post1': 1.0, 'sham baseline-post2': 1.0, 'sham-tFUS baseline': 1.0, 'sham-tFUS condition': 0.2617, 'sham-tFUS post1': 0.0552, 'sham-tFUS post2': 0.0425}
ordinary percent_time ipsilateral {'sham baseline-condition': 1.0, 'sham baseline-post1': 1.0, 'sham baseline-post2': 1.0, 'sham-tFUS baseline': 1.0, 'sham-tFUS condition': 0.1278, 'sham-tFUS post1': 0.2871, 'sham-tFUS post2': 0.4536}
ordinary percent_time contralateral {'sham baseline-condition': 1.0, 'sham baseline-post1': 1.0, 'sham baseline-post2': 0.5268, 'sham-tFUS baseline': 1.0, 'sham-tFUS condition': 0.1395, 'sham-tFUS post1': 0.2227, 'sham-tFUS post2': 0.4749}
ordinary isi_gap ipsilateral {'sham baseline-condition': 1.0, 'sham baseline-post1': 1.0, 'sham baseline-post2': 1.0, 'sham-tFUS baseline': 0.8762, 'sham-tFUS condition': 0.8194, 'sham-tFUS post1': 0.0612, 'sham-tFUS post2': 0.4157}
ordinary isi_gap contralateral {'sham baseline-condition': 1.0, 'sham baseline-post1': 1.0, 'sham baseline-post2': 1.0, 'sham-tFUS baseline': 0.8895, 'sham-tFUS condition': 0.8431, 'sham-tFUS post1': 0.0361, 'sham-tFUS post2': 0.4659}
ordinary duration ipsilateral {'sham baseline-condition': 1.0, 'sham baseline-post1': 1.0, 'sham baseline-post2': 0.4663, 'sham-tFUS baseline': 1.0, 'sham-tFUS condition': 1.0, 'sham-tFUS post1': 1.0, 'sham-tFUS post2': 0.713}
ordinary duration contralateral {'sham baseline-condition': 1.0, 'sham baseline-post1': 0.6481, 'sham baseline-post2': 0.2198, 'sham-tFUS baseline': 1.0, 'sham-tFUS condition': 1.0, 'sham-tFUS post1': 1.0, 'sham-tFUS post2': 0.7115}
repeated count ipsilateral {'sham baseline-condition': 1.0, 'sham baseline-post1': 1.0, 'sham baseline-post2': 1.0, 'sham-tFUS baseline': 1.0, 'sham-tFUS condition': 0.3063, 'sham-tFUS post1': 0.0617, 'sham-tFUS post2': 0.0433}
repeated count contralateral {'sham baseline-condition': 1.0, 'sham baseline-post1': 1.0, 'sham baseline-post2': 1.0, 'sham-tFUS baseline': 1.0, 'sham-tFUS condition': 0.2729, 'sham-tFUS post1': 0.0616, 'sham-tFUS post2': 0.0482}
repeated percent_time ipsilateral {'sham baseline-condition': 1.0, 'sham baseline-post1': 0.4725, 'sham baseline-post2': 0.1564, 'sham-tFUS baseline': 1.0, 'sham-tFUS condition': 0.1504, 'sham-tFUS post1': 0.3152, 'sham-tFUS post2': 0.483}
repeated percent_time contralateral {'sham baseline-condition': 1.0, 'sham baseline-post1': 0.1663, 'sham baseline-post2': 0.0236, 'sham-tFUS baseline': 1.0, 'sham-tFUS condition': 0.1637, 'sham-tFUS post1': 0.2505, 'sham-tFUS post2': 0.5055}
repeated isi_gap ipsilateral {'sham baseline-condition': 1.0, 'sham baseline-post1': 1.0, 'sham baseline-post2': 1.0, 'sham-tFUS baseline': 0.8943, 'sham-tFUS condition': 0.8379, 'sham-tFUS post1': 0.0723, 'sham-tFUS post2': 0.4353}
repeated isi_gap contralateral {'sham baseline-condition': 1.0, 'sham baseline-post1': 1.0, 'sham baseline-post2': 1.0, 'sham-tFUS baseline': 0.9133, 'sham-tFUS condition': 0.8673, 'sham-tFUS post1': 0.0476, 'sham-tFUS post2': 0.492}
repeated duration ipsilateral {'sham baseline-condition': 1.0, 'sham baseline-post1': 1.0, 'sham baseline-post2': 0.3569, 'sham-tFUS baseline': 1.0, 'sham-tFUS condition': 1.0, 'sham-tFUS post1': 1.0, 'sham-tFUS post2': 0.7715}
repeated duration contralateral {'sham baseline-condition': 1.0, 'sham baseline-post1': 0.4389, 'sham baseline-post2': 0.1229, 'sham-tFUS baseline': 1.0, 'sham-tFUS condition': 1.0, 'sham-tFUS post1': 1.0, 'sham-tFUS post2': 0.7902}

fig3b-percent-time-sham-vs-tfus¶

Percent time in seizure differs significantly between sham and tFUS during post 1 in the contralateral S1, and during stimulation and post 1 in the ipsilateral S1.

In [18]:
want = [("contralateral", "sham-tFUS post1"), ("ipsilateral", "sham-tFUS condition"), ("ipsilateral", "sham-tFUS post1")]
for k in ("ordinary", "repeated"):
    rows = []
    for h, c in want:
        r = res3b[h][k][1].set_index("comparison").loc[c]
        rows.append({"hemi": h, "comparison": c, "sham minus tFUS": round(r["diff"], 2), "p_family": round(r.p_family, 4), "p_all": round(r.p_all, 4)})
    print(k); print(pd.DataFrame(rows).to_string(index=False))
ordinary
         hemi          comparison  sham minus tFUS  p_family  p_all
contralateral     sham-tFUS post1            11.44    0.0749 0.1872
  ipsilateral sham-tFUS condition             9.82    0.1383 0.3458
  ipsilateral     sham-tFUS post1            10.02    0.1252 0.3129
repeated
         hemi          comparison  sham minus tFUS  p_family  p_all
contralateral     sham-tFUS post1            11.44    0.0970 0.2426
  ipsilateral sham-tFUS condition             9.82    0.1636 0.4090
  ipsilateral     sham-tFUS post1            10.02    0.1496 0.3740

Result: not reproduced. tFUS is lower than sham in all three named comparisons (by 11.4, 9.8 and 10.0 percentage points), but none is significant under either reading: contralateral post 1 p = 0.075 (ordinary) and 0.097 (repeated), ipsilateral stimulation 0.14 and 0.16, ipsilateral post 1 0.13 and 0.15, in the between family.

fig3c-interval-increase¶

Relative to baseline, the inter-seizure interval of the tFUS group increased by 27%, 49% and 28% (ipsilateral) and 30%, 52% and 31% (contralateral) during stimulation, post 1 and post 2; only post 1 in the contralateral S1 differed significantly from baseline.

The 8 tFUS rats left after the Methods' exclusion. Both readings of the interval are run; the gap reading is the one the paper's words favour.

In [19]:
print("Rats in the interval analysis per group:", met.dropna(subset=["isi_gap"]).groupby("group").subject.nunique().to_dict())
exp = {("ipsilateral", "condition"): 27, ("ipsilateral", "post1"): 49, ("ipsilateral", "post2"): 28,
       ("contralateral", "condition"): 30, ("contralateral", "post1"): 52, ("contralateral", "post2"): 31}
res3c = {}
for value in ("isi_gap", "isi_onset"):
    print(f"\n==== {value}")
    a, b, res3c[value] = fig3(value)
    for name, t in (("a", a), ("b", b)):
        rows = [{"hemi": h, "block": k, "expected": v, "measured increase": round(t.loc[h, k], 1),
                 "within 10%": abs(t.loc[h, k] - v) <= 0.1 * v} for (h, k), v in exp.items()]
        print(f"Reading ({name}) of M4:"); print(pd.DataFrame(rows).to_string(index=False))
Rats in the interval analysis per group: {'sham': 6, 'tFUS': 8}

==== isi_gap
isi_gap: tFUS change from baseline, %, reading (a) ratio of group means:
block          condition  post1  post2
hemi                                  
contralateral       10.8   46.8   21.8
ipsilateral          9.5   38.4   19.0
reading (b) mean of each rat's change:
block          condition  post1  post2
hemi                                  
contralateral       30.1   51.9   30.9
ipsilateral         27.4   49.1   27.8
Group means and SEM:
                           mean            sem        count     
group                      sham    tFUS   sham   tFUS  sham tFUS
hemi          block                                             
contralateral baseline   158.10  218.59  27.87  32.16     6    8
              condition  180.17  242.23  37.24  18.61     6    8
              post1      180.82  320.95  34.35  47.25     6    8
              post2      188.64  266.31  30.37  35.86     6    8
ipsilateral   baseline   161.71  220.19  27.90  31.89     6    8
              condition  180.77  241.12  38.81  20.48     6    8
              post1      182.82  304.71  32.71  39.78     6    8
              post2      186.57  262.02  29.61  35.02     6    8

ipsilateral:
  [ordinary] main effects: {'C(group, Sum)': 'F=11.28, p=0.00154', 'C(block, Sum)': 'F=1.08, p=0.369', 'C(group, Sum):C(block, Sum)': 'F=0.39, p=0.758'}
             comparison  family      diff    stat  p_raw  p_family  p_all
sham baseline-condition  within  -19.0616 -0.3788 0.7065    1.0000 1.0000
    sham baseline-post1  within  -21.1178 -0.4196 0.6766    1.0000 1.0000
    sham baseline-post2  within  -24.8681 -0.4941 0.6235    1.0000 1.0000
tFUS baseline-condition  within  -20.9385 -0.4804 0.6331    1.0000 1.0000
    tFUS baseline-post1  within  -84.5245 -1.9394 0.0583    0.3501 0.5834
    tFUS baseline-post2  within  -41.8303 -0.9598 0.3420    1.0000 1.0000
     sham-tFUS baseline between  -58.4799 -1.2423 0.2202    0.8807 1.0000
    sham-tFUS condition between  -60.3568 -1.2821 0.2060    0.8238 1.0000
        sham-tFUS post1 between -121.8866 -2.5892 0.0127    0.0508 0.1270
        sham-tFUS post2 between  -75.4422 -1.6026 0.1156    0.4623 1.0000
  [repeated] main effects: {'C(group, Sum)': 'F=4.50, p=0.0555', 'C(block, Sum)': 'F=1.80, p=0.165', 'C(group, Sum):C(block, Sum)': 'F=0.79, p=0.506'}
             comparison  family      diff    stat  p_raw  p_family  p_all
sham baseline-condition  within  -19.0616 -0.5371 0.5945    1.0000 1.0000
    sham baseline-post1  within  -21.1178 -0.5951 0.5555    1.0000 1.0000
    sham baseline-post2  within  -24.8681 -0.7008 0.4880    1.0000 1.0000
tFUS baseline-condition  within  -20.9385 -0.6813 0.5000    1.0000 1.0000
    tFUS baseline-post1  within  -84.5245 -2.7503 0.0093    0.0555 0.0926
    tFUS baseline-post2  within  -41.8303 -1.3611 0.1819    1.0000 1.0000
     sham-tFUS baseline between  -58.4799 -1.2423 0.2247    0.8988 1.0000
    sham-tFUS condition between  -60.3568 -1.2821 0.2106    0.8423 1.0000
        sham-tFUS post1 between -121.8866 -2.5892 0.0152    0.0610 0.1524
        sham-tFUS post2 between  -75.4422 -1.6026 0.1205    0.4821 1.0000

contralateral:
  [ordinary] main effects: {'C(group, Sum)': 'F=11.85, p=0.00121', 'C(block, Sum)': 'F=1.38, p=0.259', 'C(group, Sum):C(block, Sum)': 'F=0.58, p=0.634'}
             comparison  family      diff    stat  p_raw  p_family  p_all
sham baseline-condition  within  -22.0714 -0.4176 0.6781    1.0000 1.0000
    sham baseline-post1  within  -22.7293 -0.4300 0.6691    1.0000 1.0000
    sham baseline-post2  within  -30.5434 -0.5779 0.5661    1.0000 1.0000
tFUS baseline-condition  within  -23.6420 -0.5165 0.6079    1.0000 1.0000
    tFUS baseline-post1  within -102.3566 -2.2361 0.0300    0.1802 0.3003
    tFUS baseline-post2  within  -47.7221 -1.0426 0.3024    1.0000 1.0000
     sham-tFUS baseline between  -60.4932 -1.2235 0.2271    0.9084 1.0000
    sham-tFUS condition between  -62.0638 -1.2553 0.2154    0.8618 1.0000
        sham-tFUS post1 between -140.1205 -2.8341 0.0067    0.0268 0.0670
        sham-tFUS post2 between  -77.6719 -1.5710 0.1228    0.4910 1.0000
  [repeated] main effects: {'C(group, Sum)': 'F=4.32, p=0.0597', 'C(block, Sum)': 'F=2.71, p=0.0591', 'C(group, Sum):C(block, Sum)': 'F=1.37, p=0.267'}
             comparison  family      diff    stat  p_raw  p_family  p_all
sham baseline-condition  within  -22.0714 -0.6446 0.5233    1.0000 1.0000
    sham baseline-post1  within  -22.7293 -0.6638 0.5110    1.0000 1.0000
    sham baseline-post2  within  -30.5434 -0.8921 0.3783    1.0000 1.0000
tFUS baseline-condition  within  -23.6420 -0.7973 0.4305    1.0000 1.0000
    tFUS baseline-post1  within -102.3566 -3.4519 0.0014    0.0086 0.0144
    tFUS baseline-post2  within  -47.7221 -1.6094 0.1163    0.6976 1.0000
     sham-tFUS baseline between  -60.4932 -1.2235 0.2331    0.9323 1.0000
    sham-tFUS condition between  -62.0638 -1.2553 0.2215    0.8861 1.0000
        sham-tFUS post1 between -140.1205 -2.8341 0.0092    0.0368 0.0920
        sham-tFUS post2 between  -77.6719 -1.5710 0.1293    0.5174 1.0000
Reading (a) of M4:
         hemi     block  expected  measured increase  within 10%
  ipsilateral condition        27                9.5       False
  ipsilateral     post1        49               38.4       False
  ipsilateral     post2        28               19.0       False
contralateral condition        30               10.8       False
contralateral     post1        52               46.8        True
contralateral     post2        31               21.8       False
Reading (b) of M4:
         hemi     block  expected  measured increase  within 10%
  ipsilateral condition        27               27.4        True
  ipsilateral     post1        49               49.1        True
  ipsilateral     post2        28               27.8        True
contralateral condition        30               30.1        True
contralateral     post1        52               51.9        True
contralateral     post2        31               30.9        True

==== isi_onset
isi_onset: tFUS change from baseline, %, reading (a) ratio of group means:
block          condition  post1  post2
hemi                                  
contralateral        2.0   29.0   11.1
ipsilateral          1.3   22.3    8.9
reading (b) mean of each rat's change:
block          condition  post1  post2
hemi                                  
contralateral       13.9   30.6   15.3
ipsilateral         12.6   29.1   12.8
Group means and SEM:
                           mean            sem        count     
group                      sham    tFUS   sham   tFUS  sham tFUS
hemi          block                                             
contralateral baseline   214.74  285.67  30.73  36.01     6    8
              condition  228.85  291.44  34.47  20.22     6    8
              post1      225.74  368.51  34.10  47.57     6    8
              post2      229.49  317.31  30.39  37.42     6    8
ipsilateral   baseline   214.81  286.23  30.72  35.47     6    8
              condition  229.28  290.07  36.04  21.83     6    8
              post1      226.21  350.17  33.65  39.77     6    8
              post2      224.48  311.73  30.47  37.10     6    8

ipsilateral:
  [ordinary] main effects: {'C(group, Sum)': 'F=12.38, p=0.00096', 'C(block, Sum)': 'F=0.55, p=0.65', 'C(group, Sum):C(block, Sum)': 'F=0.32, p=0.81'}
             comparison  family      diff    stat  p_raw  p_family  p_all
sham baseline-condition  within  -14.4661 -0.2773 0.7827    1.0000 1.0000
    sham baseline-post1  within  -11.4011 -0.2185 0.8279    1.0000 1.0000
    sham baseline-post2  within   -9.6694 -0.1854 0.8537    1.0000 1.0000
tFUS baseline-condition  within   -3.8421 -0.0850 0.9326    1.0000 1.0000
    tFUS baseline-post1  within  -63.9484 -1.4155 0.1634    0.9803 1.0000
    tFUS baseline-post2  within  -25.5061 -0.5646 0.5750    1.0000 1.0000
     sham-tFUS baseline between  -71.4132 -1.4634 0.1499    0.5995 1.0000
    sham-tFUS condition between  -60.7892 -1.2457 0.2189    0.8756 1.0000
        sham-tFUS post1 between -123.9604 -2.5403 0.0144    0.0575 0.1437
        sham-tFUS post2 between  -87.2499 -1.7880 0.0801    0.3204 0.8009
  [repeated] main effects: {'C(group, Sum)': 'F=5.36, p=0.0391', 'C(block, Sum)': 'F=0.77, p=0.518', 'C(group, Sum):C(block, Sum)': 'F=0.57, p=0.639'}
             comparison  family      diff    stat  p_raw  p_family  p_all
sham baseline-condition  within  -14.4661 -0.3693 0.7141    1.0000 1.0000
    sham baseline-post1  within  -11.4011 -0.2911 0.7727    1.0000 1.0000
    sham baseline-post2  within   -9.6694 -0.2469 0.8064    1.0000 1.0000
tFUS baseline-condition  within   -3.8421 -0.1133 0.9105    1.0000 1.0000
    tFUS baseline-post1  within  -63.9484 -1.8852 0.0675    0.4050 0.6750
    tFUS baseline-post2  within  -25.5061 -0.7519 0.4570    1.0000 1.0000
     sham-tFUS baseline between  -71.4132 -1.4634 0.1536    0.6142 1.0000
    sham-tFUS condition between  -60.7892 -1.2457 0.2223    0.8893 1.0000
        sham-tFUS post1 between -123.9604 -2.5403 0.0164    0.0655 0.1639
        sham-tFUS post2 between  -87.2499 -1.7880 0.0837    0.3348 0.8370

contralateral:
  [ordinary] main effects: {'C(group, Sum)': 'F=12.77, p=0.000815', 'C(block, Sum)': 'F=0.81, p=0.493', 'C(group, Sum):C(block, Sum)': 'F=0.50, p=0.683'}
             comparison  family      diff    stat  p_raw  p_family  p_all
sham baseline-condition  within  -14.1054 -0.2590 0.7968    1.0000 1.0000
    sham baseline-post1  within  -11.0003 -0.2020 0.8408    1.0000 1.0000
    sham baseline-post2  within  -14.7488 -0.2708 0.7877    1.0000 1.0000
tFUS baseline-condition  within   -5.7705 -0.1223 0.9031    1.0000 1.0000
    tFUS baseline-post1  within  -82.8484 -1.7564 0.0854    0.5124 0.8540
    tFUS baseline-post2  within  -31.6409 -0.6708 0.5056    1.0000 1.0000
     sham-tFUS baseline between  -70.9235 -1.3920 0.1703    0.6813 1.0000
    sham-tFUS condition between  -62.5886 -1.2284 0.2253    0.9011 1.0000
        sham-tFUS post1 between -142.7716 -2.8022 0.0073    0.0292 0.0730
        sham-tFUS post2 between  -87.8157 -1.7236 0.0912    0.3649 0.9122
  [repeated] main effects: {'C(group, Sum)': 'F=4.84, p=0.0481', 'C(block, Sum)': 'F=1.40, p=0.26', 'C(group, Sum):C(block, Sum)': 'F=1.10, p=0.361'}
             comparison  family      diff    stat  p_raw  p_family  p_all
sham baseline-condition  within  -14.1054 -0.3840 0.7032    1.0000 1.0000
    sham baseline-post1  within  -11.0003 -0.2995 0.7663    1.0000 1.0000
    sham baseline-post2  within  -14.7488 -0.4015 0.6904    1.0000 1.0000
tFUS baseline-condition  within   -5.7705 -0.1814 0.8571    1.0000 1.0000
    tFUS baseline-post1  within  -82.8484 -2.6044 0.0133    0.0798 0.1329
    tFUS baseline-post2  within  -31.6409 -0.9946 0.3266    1.0000 1.0000
     sham-tFUS baseline between  -70.9235 -1.3920 0.1760    0.7040 1.0000
    sham-tFUS condition between  -62.5886 -1.2284 0.2306    0.9222 1.0000
        sham-tFUS post1 between -142.7716 -2.8022 0.0096    0.0383 0.0958
        sham-tFUS post2 between  -87.8157 -1.7236 0.0969    0.3878 0.9695
Reading (a) of M4:
         hemi     block  expected  measured increase  within 10%
  ipsilateral condition        27                1.3       False
  ipsilateral     post1        49               22.3       False
  ipsilateral     post2        28                8.9       False
contralateral condition        30                2.0       False
contralateral     post1        52               29.0       False
contralateral     post2        31               11.1       False
Reading (b) of M4:
         hemi     block  expected  measured increase  within 10%
  ipsilateral condition        27               12.6       False
  ipsilateral     post1        49               29.1       False
  ipsilateral     post2        28               12.8       False
contralateral condition        30               13.9       False
contralateral     post1        52               30.6       False
contralateral     post2        31               15.3       False

Result: reproduced, resting on an assumption. With the interval read as the gap between one seizure's end and the next one's start, and reading (b) of M4, the increases are 27.4%, 49.1% and 27.8% (ipsilateral) and 30.1%, 51.9% and 30.9% (contralateral), all within tolerance. Under the repeated-measures reading contralateral post 1 is the only significant comparison with baseline under both family readings (p = 0.0086 in the within family, 0.014 over all ten); ipsilateral post 1 is not (0.056 and 0.093), and the other four have p = 0.69 or more. The ordinary reading finds none (contralateral post 1 p = 0.18). The onset-to-onset reading gives increases of 12.6% to 30.6%, outside tolerance, so the outcome rests on the gap reading, which the paper's "time between neighboring seizures" favours.

fig3c-interval-sham-vs-tfus¶

The inter-seizure interval of the sham group stays steady, and sham and tFUS differ significantly during post 1 in both hemispheres.

In [20]:
for value in ("isi_gap", "isi_onset"):
    for h in ("ipsilateral", "contralateral"):
        for k, (table, post) in res3c[value][h].items():
            p = post[post.comparison.isin(["sham-tFUS post1", "sham baseline-condition", "sham baseline-post1", "sham baseline-post2"])]
            print(value, h, k, {r.comparison: (round(r.diff, 1), round(r.p_family, 4), round(r.p_all, 4)) for r in p.itertuples()})
isi_gap ipsilateral ordinary {'sham baseline-condition': (-19.1, 1.0, 1.0), 'sham baseline-post1': (-21.1, 1.0, 1.0), 'sham baseline-post2': (-24.9, 1.0, 1.0), 'sham-tFUS post1': (-121.9, 0.0508, 0.127)}
isi_gap ipsilateral repeated {'sham baseline-condition': (-19.1, 1.0, 1.0), 'sham baseline-post1': (-21.1, 1.0, 1.0), 'sham baseline-post2': (-24.9, 1.0, 1.0), 'sham-tFUS post1': (-121.9, 0.061, 0.1524)}
isi_gap contralateral ordinary {'sham baseline-condition': (-22.1, 1.0, 1.0), 'sham baseline-post1': (-22.7, 1.0, 1.0), 'sham baseline-post2': (-30.5, 1.0, 1.0), 'sham-tFUS post1': (-140.1, 0.0268, 0.067)}
isi_gap contralateral repeated {'sham baseline-condition': (-22.1, 1.0, 1.0), 'sham baseline-post1': (-22.7, 1.0, 1.0), 'sham baseline-post2': (-30.5, 1.0, 1.0), 'sham-tFUS post1': (-140.1, 0.0368, 0.092)}
isi_onset ipsilateral ordinary {'sham baseline-condition': (-14.5, 1.0, 1.0), 'sham baseline-post1': (-11.4, 1.0, 1.0), 'sham baseline-post2': (-9.7, 1.0, 1.0), 'sham-tFUS post1': (-124.0, 0.0575, 0.1437)}
isi_onset ipsilateral repeated {'sham baseline-condition': (-14.5, 1.0, 1.0), 'sham baseline-post1': (-11.4, 1.0, 1.0), 'sham baseline-post2': (-9.7, 1.0, 1.0), 'sham-tFUS post1': (-124.0, 0.0655, 0.1639)}
isi_onset contralateral ordinary {'sham baseline-condition': (-14.1, 1.0, 1.0), 'sham baseline-post1': (-11.0, 1.0, 1.0), 'sham baseline-post2': (-14.7, 1.0, 1.0), 'sham-tFUS post1': (-142.8, 0.0292, 0.073)}
isi_onset contralateral repeated {'sham baseline-condition': (-14.1, 1.0, 1.0), 'sham baseline-post1': (-11.0, 1.0, 1.0), 'sham baseline-post2': (-14.7, 1.0, 1.0), 'sham-tFUS post1': (-142.8, 0.0383, 0.0958)}

Result: partially reproduced. Sham against tFUS at post 1 is significant in the contralateral S1 with tFUS higher (by 140 s; ordinary p = 0.027, repeated 0.037, between family) and not in the ipsilateral S1 (by 122 s; ordinary 0.051, repeated 0.061); the onset-to-onset interval gives the same (contralateral 0.029 and 0.038, ipsilateral 0.058 and 0.066). No sham block differs from sham baseline (p = 1), so the sham interval is steady. The claim holds in one hemisphere, the criterion's partial outcome. The first version of this attempt reported the ipsilateral comparison as significant (p = 0.039) under the repeated reading; that p came from a normal reference in place of the t distribution.

fig3d-duration-decline¶

Seizure duration declines across time in both groups, and the only significant reduction is from baseline to post 2 in both hemispheres of the tFUS group.

In [21]:
a, b, res3d = fig3("duration")
for h in ("ipsilateral", "contralateral"):
    for k, (table, post) in res3d[h].items():
        p = post[post.family == "within"]
        print(h, k, "within-group against baseline:", {r.comparison: (round(r.diff, 1), round(r.p_family, 4)) for r in p.itertuples()})
print("\nGroup means at baseline and post 2:")
print(met[met.block.isin(["baseline", "post2"])].groupby(["group", "hemi", "block"]).duration.mean().round(1).unstack().to_string())
print("\nVariant, seizures within 2 s of a block end left out:")
for h in ("ipsilateral", "contralateral"):
    for k, (table, post) in group_tests(met_edge, "duration", h).items():
        p = post[post.family == "within"]
        print(h, k, {r.comparison: round(r.p_family, 4) for r in p.itertuples()})
duration: tFUS change from baseline, %, reading (a) ratio of group means:
block          condition  post1  post2
hemi                                  
contralateral      -19.4  -18.7  -18.2
ipsilateral        -18.9  -19.8  -18.6
reading (b) mean of each rat's change:
block          condition  post1  post2
hemi                                  
contralateral      -15.2  -13.5  -20.2
ipsilateral        -14.4  -12.3  -20.7
Group means and SEM:
                          mean          sem       count     
group                     sham   tFUS  sham  tFUS  sham tFUS
hemi          block                                         
contralateral baseline   56.85  61.00  9.37  5.79     6   10
              condition  48.88  49.15  4.03  4.53     6   10
              post1      43.29  49.59  2.78  3.15     6   10
              post2      40.60  49.88  1.74  4.79     6    8
ipsilateral   baseline   53.00  59.84  8.91  6.02     6   10
              condition  48.55  48.52  3.49  4.78     6   10
              post1      43.85  48.00  3.52  3.24     6   10
              post2      37.78  48.73  2.07  4.71     6    8

ipsilateral:
  [ordinary] main effects: {'C(group, Sum)': 'F=2.11, p=0.152', 'C(block, Sum)': 'F=2.52, p=0.0679', 'C(group, Sum):C(block, Sum)': 'F=0.38, p=0.765'}
             comparison  family     diff    stat  p_raw  p_family  p_all
sham baseline-condition  within   4.4504  0.5463 0.5871    1.0000 1.0000
    sham baseline-post1  within   9.1566  1.1239 0.2660    1.0000 1.0000
    sham baseline-post2  within  15.2199  1.8681 0.0672    0.4030 0.6717
tFUS baseline-condition  within  11.3168  1.7933 0.0785    0.4712 0.7853
    tFUS baseline-post1  within  11.8388  1.8760 0.0661    0.3964 0.6607
    tFUS baseline-post2  within  11.1085  1.6596 0.1028    0.6168 1.0000
     sham-tFUS baseline between  -6.8354 -0.9380 0.3524    1.0000 1.0000
    sham-tFUS condition between   0.0310  0.0042 0.9966    1.0000 1.0000
        sham-tFUS post1 between  -4.1533 -0.5700 0.5711    1.0000 1.0000
        sham-tFUS post2 between -10.9468 -1.4364 0.1567    0.6266 1.0000
  [repeated] main effects: {'C(group, Sum)': 'F=1.45, p=0.248', 'C(block, Sum)': 'F=2.88, p=0.0479', 'C(group, Sum):C(block, Sum)': 'F=0.43, p=0.736'}
             comparison  family     diff    stat  p_raw  p_family  p_all
sham baseline-condition  within   4.4504  0.5961 0.5545    1.0000 1.0000
    sham baseline-post1  within   9.1566  1.2264 0.2272    1.0000 1.0000
    sham baseline-post2  within  15.2199  2.0385 0.0481    0.2889 0.4814
tFUS baseline-condition  within  11.3168  1.9568 0.0574    0.3442 0.5737
    tFUS baseline-post1  within  11.8388  2.0470 0.0473    0.2835 0.4726
    tFUS baseline-post2  within  11.5148  1.8647 0.0693    0.4157 0.6928
     sham-tFUS baseline between  -6.8354 -0.9387 0.3524    1.0000 1.0000
    sham-tFUS condition between   0.0310  0.0043 0.9966    1.0000 1.0000
        sham-tFUS post1 between  -4.1533 -0.5704 0.5710    1.0000 1.0000
        sham-tFUS post2 between -10.5405 -1.3876 0.1713    0.6851 1.0000

contralateral:
  [ordinary] main effects: {'C(group, Sum)': 'F=1.82, p=0.183', 'C(block, Sum)': 'F=3.00, p=0.0385', 'C(group, Sum):C(block, Sum)': 'F=0.27, p=0.848'}
             comparison  family    diff    stat  p_raw  p_family  p_all
sham baseline-condition  within  7.9645  0.9900 0.3266    1.0000 1.0000
    sham baseline-post1  within 13.5612  1.6857 0.0976    0.5858 0.9763
    sham baseline-post2  within 16.2481  2.0197 0.0484    0.2903 0.4839
tFUS baseline-condition  within 11.8538  1.9022 0.0625    0.3749 0.6248
    tFUS baseline-post1  within 11.4108  1.8311 0.0726    0.4356 0.7260
    tFUS baseline-post2  within 11.1207  1.6825 0.0982    0.5895 0.9824
     sham-tFUS baseline between -4.1539 -0.5773 0.5662    1.0000 1.0000
    sham-tFUS condition between -0.2645 -0.0368 0.9708    1.0000 1.0000
        sham-tFUS post1 between -6.3043 -0.8761 0.3848    1.0000 1.0000
        sham-tFUS post2 between -9.2813 -1.2333 0.2228    0.8912 1.0000
  [repeated] main effects: {'C(group, Sum)': 'F=1.09, p=0.314', 'C(block, Sum)': 'F=3.85, p=0.0164', 'C(group, Sum):C(block, Sum)': 'F=0.31, p=0.818'}
             comparison  family    diff    stat  p_raw  p_family  p_all
sham baseline-condition  within  7.9645  1.1238 0.2678    1.0000 1.0000
    sham baseline-post1  within 13.5612  1.9134 0.0629    0.3772 0.6286
    sham baseline-post2  within 16.2481  2.2925 0.0272    0.1632 0.2721
tFUS baseline-condition  within 11.8538  2.1592 0.0369    0.2213 0.3688
    tFUS baseline-post1  within 11.4108  2.0785 0.0441    0.2647 0.4411
    tFUS baseline-post2  within 11.6358  1.9815 0.0542    0.3252 0.5421
     sham-tFUS baseline between -4.1539 -0.5781 0.5660    1.0000 1.0000
    sham-tFUS condition between -0.2645 -0.0368 0.9708    1.0000 1.0000
        sham-tFUS post1 between -6.3043 -0.8773 0.3847    1.0000 1.0000
        sham-tFUS post2 between -8.7662 -1.1717 0.2470    0.9881 1.0000
ipsilateral ordinary within-group against baseline: {'sham baseline-condition': (4.5, 1.0), 'sham baseline-post1': (9.2, 1.0), 'sham baseline-post2': (15.2, 0.403), 'tFUS baseline-condition': (11.3, 0.4712), 'tFUS baseline-post1': (11.8, 0.3964), 'tFUS baseline-post2': (11.1, 0.6168)}
ipsilateral repeated within-group against baseline: {'sham baseline-condition': (4.5, 1.0), 'sham baseline-post1': (9.2, 1.0), 'sham baseline-post2': (15.2, 0.2889), 'tFUS baseline-condition': (11.3, 0.3442), 'tFUS baseline-post1': (11.8, 0.2835), 'tFUS baseline-post2': (11.5, 0.4157)}
contralateral ordinary within-group against baseline: {'sham baseline-condition': (8.0, 1.0), 'sham baseline-post1': (13.6, 0.5858), 'sham baseline-post2': (16.2, 0.2903), 'tFUS baseline-condition': (11.9, 0.3749), 'tFUS baseline-post1': (11.4, 0.4356), 'tFUS baseline-post2': (11.1, 0.5895)}
contralateral repeated within-group against baseline: {'sham baseline-condition': (8.0, 1.0), 'sham baseline-post1': (13.6, 0.3772), 'sham baseline-post2': (16.2, 0.1632), 'tFUS baseline-condition': (11.9, 0.2213), 'tFUS baseline-post1': (11.4, 0.2647), 'tFUS baseline-post2': (11.6, 0.3252)}

Group means at baseline and post 2:
block                baseline  post2
group hemi                          
sham  contralateral      56.8   40.6
      ipsilateral        53.0   37.8
tFUS  contralateral      61.0   49.9
      ipsilateral        59.8   48.7

Variant, seizures within 2 s of a block end left out:
ipsilateral ordinary {'sham baseline-condition': 1.0, 'sham baseline-post1': 1.0, 'sham baseline-post2': 0.4282, 'tFUS baseline-condition': 0.4769, 'tFUS baseline-post1': 0.4086, 'tFUS baseline-post2': 0.6234}
ipsilateral repeated {'sham baseline-condition': 1.0, 'sham baseline-post1': 1.0, 'sham baseline-post2': 0.3078, 'tFUS baseline-condition': 0.3475, 'tFUS baseline-post1': 0.292, 'tFUS baseline-post2': 0.4187}
contralateral ordinary {'sham baseline-condition': 1.0, 'sham baseline-post1': 0.6138, 'sham baseline-post2': 0.3106, 'tFUS baseline-condition': 0.3767, 'tFUS baseline-post1': 0.4445, 'tFUS baseline-post2': 0.5919}
contralateral repeated {'sham baseline-condition': 1.0, 'sham baseline-post1': 0.3986, 'sham baseline-post2': 0.1767, 'tFUS baseline-condition': 0.2224, 'tFUS baseline-post1': 0.2709, 'tFUS baseline-post2': 0.3264}

Result: not reproduced. The group means decline from baseline to post 2 in both groups (tFUS 59.8 to 48.7 s ipsilateral and 61.0 to 49.9 s contralateral; sham 53.0 to 37.8 s and 56.8 to 40.6 s), but tFUS baseline against post 2 is not significant in either hemisphere (Bonferroni p = 0.42 and 0.33 repeated, 0.62 and 0.59 ordinary), nor is any other within-group comparison against baseline (smallest p = 0.16). Counting the seizures within 2 s of either end of a block as cut off gives the same (tFUS post 2 p = 0.42 and 0.33 repeated).

Summary¶

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.

Claim Notebook Outcome
fig2c-sham-duration-stable seizure_metrics not reproduced
fig2d-seizures-under-two-minutes seizure_metrics reproduced
fig2e-sham-count-stable seizure_metrics reproduced
fig2f-sham-percent-time-post3 seizure_metrics reproduced (assumed)
fig3a-count-reduction seizure_metrics reproduced
fig3a-count-sham-vs-tfus seizure_metrics partially reproduced
fig3b-percent-time-reduction seizure_metrics reproduced
fig3b-sham-percent-time-no-change seizure_metrics not reproduced (assumed)
fig3b-percent-time-sham-vs-tfus seizure_metrics not reproduced
fig3c-interval-increase seizure_metrics reproduced (assumed)
fig3c-interval-sham-vs-tfus seizure_metrics partially reproduced
fig3d-duration-decline seizure_metrics not reproduced
fig4-no-theta-alpha-gamma-power-change eeg_blocks not reproduced (assumed)
fig4c-beta-decrease eeg_blocks partially reproduced
figs4-sham-power-no-change eeg_blocks not reproduced (assumed)
fig4ef-ai-increase eeg_blocks partially reproduced
figs5-seizures-lower-ai eeg_blocks reproduced (assumed)
fig6-epileptic-pli-s1-decrease eeg_blocks not reproduced
figs7-seizure-pli-s1-vs-non-s1 eeg_blocks partially reproduced (assumed)
fig5b-tfus-evoked-potentials wild_type blocked: methods underspecified
fig5cdj-wild-type-gamma-pli-decrease wild_type blocked: data missing
fig5ghi-low-band-pli-s1-only wild_type not reproduced

How the analysis differs from the paper's. The seizure labels are the dandiset's own, so the metrics rest on the paper's labelling. The label times are in minutes and are converted. The percent changes of Fig. 3 match the paper to within one point under reading (b) of M4 (each rat's change from its own baseline), and the inter-seizure interval matches only when read as the gap from one seizure's end to the next one's start, so both readings are the paper's. The paper's two-way ANOVA is not specified further. Most of its significant within-group changes of Fig. 3 (the count at post 1 and post 2, percent time at the stimulation block, the interval at contralateral post 1) appear only under the repeated-measures reading; percent time at post 1 and post 2 is significant under the ordinary reading too. The reading is implemented here as a mixed model with a random intercept per rat, and it is adopted as an assumption where the readings disagree on a claim of absence. Its post hoc tests are t tests and its main effects F tests, on Satterthwaite degrees of freedom (on balanced data, the df of the classical repeated-measures ANOVA, as Prism uses); the first version of this attempt used normal and chi-squared references, which made two sham against tFUS comparisons look significant. The Bonferroni family is not specified either; both readings are shown. Each set of comparisons as its own family (reading i) is adopted where they disagree, as Prism corrects each set of multiple comparisons it is asked for on its own; this decides fig2f-sham-percent-time-post3 and fig3b-sham-percent-time-no-change. The durations leave out seizures that start or end at a block edge; counting the seizures within 2 s of either end of a block as cut off as well (14 left out, against 6) changes no result. BH635's five sham files are taken in time order though their labels say otherwise.

What was found about the dataset. It holds the paper's 16 epileptic rats (10 tFUS, 6 sham) with the seizure labels, and the percent changes computed from them match the paper's. The label table gives times in minutes, not the seconds NWB prescribes (the EEG check in eeg_blocks.ipynb confirms it). BH635's block files are mislabelled (two SHAM files, one named for rat BH636, no post3), and BH649's post 3 file has the session id None. Every file gives the strain as "HSD:WI rat" (Wistar) and the age as P24W, while the paper used Sprague-Dawley rats of 3 to 6 months. The labelling channels are not named in the files.

In [22]:
print(f"Notebook ran in {(time.time() - started) / 60:.1f} min")
Notebook ran in 0.8 min