Reproducing Bell Vila et al. (2026) from dandiset 001678¶

Paper. Bell Vila M, Koletar M, Dorr A, Trevisiol A, Goubran M, Sled JG, Bazzigaluppi P, Stefanovic B. Parametrizing alternating current stimulation for neuromodulation. Imaging Neuroscience 4 (2026). doi:10.1162/imag.a.1066. The claims file (claims/001678/10.1162-imag.a.1066.yaml) was written from the version of record, open access in Europe PMC (PMC12779756), with its supplementary material; this attempt read the same text.

Dandiset. DANDI:001678, version 0.260227.1824 (doi:10.48324/dandi.001678/0.260227.1824). The paper cites no DANDI version: its data statement points to Science Data Bank (doi:10.57760/sciencedb.32375), whose record answers "PERMISSION NO ACCESS" without a login. 0.260227.1824 is the only published version, so it is pinned; the draft holds the same 22 files (checked below).

What the dandiset holds (shown in the data check). The 9 files of the 1-minute paradigm hold one channel per trial, and that channel is the stimulation command (a sinusoid at the trial's frequency whose peak is the current in uA, zero outside stimulation). They hold no recording channel: no multi-unit activity, no LFP and no stimulation monitor. The 13 files of the 20-minute paradigm hold a 16-channel stream at 12207 Hz that carries both the LFP and spikes (the multi-unit band is not filtered out), but no sorted units. The sham recording is not in the dandiset. Every claim on the 1-minute recordings or the sham recording is blocked for missing data. The claims on 20-minute spikes need the recordings sorted: one rat is sorted below over its whole 50-minute window, and at its measured speed sorting the 13 rats exceeds the notebook's 60-minute limit, so these claims, with the LFP claims that select channels by their neurons, are blocked as too large. The claim tested is the electric field of the 20-minute experiments, from the stimulation artifact.

Claim Tested here
efield-20min-median tested
efield-1min-medians blocked, data missing (no recording channel in the 1-minute files)
fem-depth-falloff, fem-lognormal-fits, fem-ellipsoid-axes blocked, data missing (the ViZOO rat model is licensed, not public, and Sim4Life is commercial; fem-lognormal-fits and fem-ellipsoid-axes are also scaled to the missing 1-minute fields, while fem-depth-falloff, a ratio, is not)
units-1min and the 25 claims on 1-minute spikes or LFP (baseline-fr and baseline-ppc, whose 20-minute parts are blocked with units-20min as too large; table1-any-change, fr-change-more-common-than-timing, fr-change-mostly-negative, ppc-change-mostly-increase, table2-magnitudes, fr-change-within-2hz, fig4-distributions, the four lmer claims, fig6a, fig6b, fig6d, fig7, fig8a, fig8b, fig8c, fig9a, fig9b, fig9cd, fig10a, lfp-1min-no-change) blocked, data missing
units-20min, 20min-during-percentages, 20min-post-percentages, 20min-magnitudes blocked, too large (spike sorting of 13 rats, timed on one full rat below)
the four power and four PAC claims on channels near affected neurons blocked, too large (the channels are chosen by the neurons of 20min-during-percentages)
sham-no-fr-change, sham-lfp-baseline blocked, data missing (no sham recording)
In [1]:
import time
from concurrent.futures import ProcessPoolExecutor

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import requests

import acs

pd.set_option("display.width", 220)
pd.set_option("display.max_columns", 40)
pd.set_option("display.max_rows", 300)
np.set_printoptions(precision=3, suppress=True, linewidth=160)

started = time.time()
assets = acs.assets()
print(f"dandiset {acs.DANDISET_ID} version {acs.DANDISET_VERSION}: {len(assets)} files, "
      f"{sum(a['size'] for a in assets) / 1e9:.1f} GB")
info = acs.version_info()
print("name:", info["metadata"]["name"])
print("description:", info["metadata"]["description"])
dandiset 001678 version 0.260227.1824: 22 files, 55.2 GB
name: Data for parametrizing alternating current stimulation for neuromodulation (Bell Vila, M., et al, 2026)
description: Data collected using a 4x4 multielectrode array (Microprobes) in propofol anesthetized rats receiving subcutaneous alternating current stimulation.

Recording electrodes had platinum iridium shanks with a tip width of 125μm, an impedance of 0.4 MOhm, and were spaced 0.5mm apart in the lateral plane. An additional shank with 10 kOhm impedance served as a reference. Electrodes were inserted ~300μm into the craniotomy exposed sensorimotor cortex (L2/3). Data was acquired with a sampling rate of 24 kHz (Tucker-Davis Technologies).

Stimulation electrodes were adhered directly to the skull, medial and lateral the cranial window.



There are two data files.

The first contains experiments where 9 three-month old Sprague-Dawley rats received a randomized order of stimulation parameters (frequencies: 5, 10, 20, 40, and 140 Hz, amplitudes: 50, 100, 200, and 400 μA). Each dated folder contains recordings for a single rat, with subfolders for each stimulation parameter delivery (1-min baseline + 1-min sACS + 1-min baseline).

The second data file contains experiments where 13 rats received a single 20-min delivery of 40 Hz, 100 μA stimulation. Each dated folder contains experiments from a single rat. Baseline activity was recorded for 20-min before stimulation onset and subsequently following sACS for 10 minutes. Additional subfolders contain further 20-min of post stimulation baseline activity, collected to an hour following stimulation offset.

Data check¶

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

In [2]:
versions = requests.get(f"{acs.API}/dandisets/{acs.DANDISET_ID}/versions/", timeout=60).json()["results"]
print("versions:", [(v["version"], v["status"], v["asset_count"], v["size"]) for v in versions])
draft = requests.get(f"{acs.API}/dandisets/{acs.DANDISET_ID}/versions/draft/assets/?page_size=200", timeout=60).json()["results"]
pub = {(a["path"], a["size"]) for a in assets}
dr = {(a["path"], a["size"]) for a in draft}
print("draft files equal to the published version's (path and size):", pub == dr)

with ProcessPoolExecutor(max_workers=4) as ex:
    summaries = list(ex.map(acs.file_summary, assets))
rows = []
for s in summaries:
    ser = s["series"]
    rows.append({
        "subject": s["subject_id"], "paradigm": s["paradigm"], "sex": s["sex"], "age": s["age"],
        "species": s["species"], "GB": round(s["size_GB"], 2), "n_series": len(ser),
        "channels": ser[0]["shape"][1], "channel_names": ",".join(sorted(set(s["channel_names"])))[:40],
        "rate_hz": sorted({x["rate"] for x in ser}), "conversion": sorted({x["conversion"] for x in ser}),
        "unit": sorted({x["unit"] for x in ser}), "minutes_total": round(sum(x["shape"][0] / x["rate"] for x in ser) / 60, 1),
        "units_table": s["has_units"], "intervals": s["has_intervals"],
        "other_groups": {k: v for k, v in s["groups"].items() if v},
        "electrode_columns": ",".join(s["electrode_columns"]), "locations": ",".join(s["locations"]),
        "session_description": s["session_description"],
    })
files = pd.DataFrame(rows)
print(files.drop(columns=["channel_names"]).to_string(index=False))
print()
print(files.groupby(["paradigm", "sex"]).size().rename("rats").to_string())
print("\nChannel names, 1-min files:", sorted({n for s in summaries if s["paradigm"] == "1-min" for n in s["channel_names"]}))
print("Channel names, 20-min files:", sorted({n for s in summaries if s["paradigm"] == "20-min" for n in s["channel_names"]},
                                             key=lambda n: int(n.split()[-1])))
print("Any units table, intervals, processing, analysis or stimulus data:",
      bool(files.units_table.any() or files.intervals.any() or any(files.other_groups.map(bool))))
versions: [('draft', 'Published', 22, 55247366195), ('0.260227.1824', 'Valid', 22, 55247366195)]
draft files equal to the published version's (path and size): True
   subject paradigm sex age           species   GB  n_series  channels       rate_hz conversion    unit  minutes_total  units_table  intervals other_groups                      electrode_columns locations session_description
2021-11-29    1-min   M P3M Rattus norvegicus 0.11        20         1  [24414.0625] [0.000001] [volts]           62.2        False      False           {} location,group,group_name,channel_name   unknown                    
2021-11-30    1-min   M P3M Rattus norvegicus 0.10        18         1  [24414.0625] [0.000001] [volts]           55.5        False      False           {} location,group,group_name,channel_name   unknown                    
2021-12-01    1-min   M P3M Rattus norvegicus 0.08        15         1  [24414.0625] [0.000001] [volts]           46.4        False      False           {} location,group,group_name,channel_name   unknown                    
2021-12-06    1-min   M P3M Rattus norvegicus 0.11        21         1  [24414.0625] [0.000001] [volts]           64.9        False      False           {} location,group,group_name,channel_name   unknown                    
2021-12-07    1-min   F P3M Rattus norvegicus 0.12        22         1  [24414.0625] [0.000001] [volts]           70.2        False      False           {} location,group,group_name,channel_name   unknown                    
2021-12-14    1-min   F P3M Rattus norvegicus 0.11        21         1  [24414.0625] [0.000001] [volts]           68.0        False      False           {} location,group,group_name,channel_name   unknown                    
2021-12-15    1-min   F P3M Rattus norvegicus 0.12        22         1  [24414.0625] [0.000001] [volts]           69.5        False      False           {} location,group,group_name,channel_name   unknown                    
2021-12-16    1-min   F P3M Rattus norvegicus 0.12        23         1  [24414.0625] [0.000001] [volts]           73.3        False      False           {} location,group,group_name,channel_name   unknown                    
2021-12-17    1-min   F P3M Rattus norvegicus 0.12        23         1  [24414.0625] [0.000001] [volts]           71.6        False      False           {} location,group,group_name,channel_name   unknown                    
2023-03-22   20-min   F P3M Rattus norvegicus 4.38         4        16 [12207.03125] [0.000001] [volts]          116.5        False      False           {} location,group,group_name,channel_name   unknown                    
2023-04-27   20-min   M P3M Rattus norvegicus 3.62         5        16 [12207.03125] [0.000001] [volts]          119.0        False      False           {} location,group,group_name,channel_name   unknown                    
2023-04-28   20-min   M P3M Rattus norvegicus 3.91         4        16 [12207.03125] [0.000001] [volts]          122.4        False      False           {} location,group,group_name,channel_name   unknown                    
2023-05-01   20-min   F P3M Rattus norvegicus 4.07         4        16 [12207.03125] [0.000001] [volts]          120.8        False      False           {} location,group,group_name,channel_name   unknown                    
2023-05-04   20-min   F P3M Rattus norvegicus 2.63         3        16 [12207.03125] [0.000001] [volts]           82.3        False      False           {} location,group,group_name,channel_name   unknown                    
2023-05-05   20-min   M P3M Rattus norvegicus 4.62         5        16 [12207.03125] [0.000001] [volts]          136.5        False      False           {} location,group,group_name,channel_name   unknown                    
2023-05-08   20-min   M P3M Rattus norvegicus 4.35         5        16 [12207.03125] [0.000001] [volts]          145.7        False      False           {} location,group,group_name,channel_name   unknown                    
2023-06-07   20-min   F P3M Rattus norvegicus 5.15         5        16 [12207.03125] [0.000001] [volts]          142.4        False      False           {} location,group,group_name,channel_name   unknown                    
2023-06-27   20-min   M P3M Rattus norvegicus 4.43         5        16 [12207.03125] [0.000001] [volts]          140.7        False      False           {} location,group,group_name,channel_name   unknown                    
2023-08-01   20-min   F P3M Rattus norvegicus 4.14         4        16 [12207.03125] [0.000001] [volts]          131.3        False      False           {} location,group,group_name,channel_name   unknown                    
2023-08-03   20-min   F P3M Rattus norvegicus 4.62         4        16 [12207.03125] [0.000001] [volts]          130.7        False      False           {} location,group,group_name,channel_name   unknown                    
2023-08-08   20-min   F P3M Rattus norvegicus 4.21         4        16 [12207.03125] [0.000001] [volts]          125.5        False      False           {} location,group,group_name,channel_name   unknown                    
2023-08-09   20-min   M P3M Rattus norvegicus 4.13         4        16 [12207.03125] [0.000001] [volts]          126.8        False      False           {} location,group,group_name,channel_name   unknown                    

paradigm  sex
1-min     F      5
          M      4
20-min    F      7
          M      6

Channel names, 1-min files: ['S1r 1']
Channel names, 20-min files: ['aw_ 1', 'aw_ 2', 'aw_ 3', 'aw_ 4', 'aw_ 5', 'aw_ 6', 'aw_ 7', 'aw_ 8', 'aw_ 9', 'aw_ 10', 'aw_ 11', 'aw_ 12', 'aw_ 13', 'aw_ 14', 'aw_ 15', 'aw_ 16']
Any units table, intervals, processing, analysis or stimulus data: False

The paper (Methods 2.1, 2.4) has 9 rats in the 1-minute paradigm (4 male, 5 female) and 13 in the 20-minute paradigm (7 male, 6 female). The files have 9 and 13 subjects, 4 male and 5 female in the 1-minute set, as the paper says, but 6 male and 7 female in the 20-minute set, the reverse of the paper's count. Every file has an electrodes table with only location ("unknown"), group, group_name and channel_name: no positions, so the 4 x 4 layout of the array is not in the files. No file has a units table, trial or epoch intervals, or a processing module. The series are in "volts" with a conversion of 1e-6, which the next cells test.

In [3]:
one_min = [a for a in assets if acs.paradigm(a["path"]) == "1-min"]
with ProcessPoolExecutor(max_workers=4) as ex:
    trials = pd.DataFrame([r for rows in ex.map(acs.stim_trials, one_min) for r in rows])
trials["freq_hz"] = trials.freq_fft_hz.round(0)
trials["amp"] = trials.peak.round(0)
print("Trials (one-channel series) per rat:", trials.groupby("subject").size().to_dict())
print("Total trials:", len(trials), "; paper, Methods 2.4: 20 per rat, 180 for 9 rats")
print("\nWaveform frequency from the spectrum (Hz), values:", sorted(trials.freq_hz.unique()))
print("Zero-crossing frequency minus spectral frequency, max abs (Hz):",
      round((trials.freq_zero_cross_hz - trials.freq_fft_hz).abs().max(), 3))
print("Peak values:", sorted(trials.peak.round(2).unique()))
print("Peak / RMS, range:", (trials.peak / trials.rms).min().round(4), "to", (trials.peak / trials.rms).max().round(4),
      "(a sinusoid gives 1.4142)")
print("Nonzero samples outside the waveform, total:", int(trials.nonzero_outside.sum()))
print("\nOnset within the series (s): %.2f to %.2f; duration (s): %.2f to %.2f; series length (s): %.1f to %.1f" % (
    trials.onset_s.min(), trials.onset_s.max(), trials.duration_s.min(), trials.duration_s.max(),
    trials.length_s.min(), trials.length_s.max()))
print("\nTrials by frequency (rows) and peak (columns), all rats:")
print(pd.crosstab(trials.freq_hz, trials.amp).to_string())
design = trials[trials.freq_hz.isin([5, 10, 20, 40]) & trials.amp.isin([50, 100, 200, 400])]
per_rat = design.groupby("subject").apply(lambda g: pd.Series({
    "trials_5_to_40Hz": len(g), "distinct_combinations": g.groupby(["freq_hz", "amp"]).ngroups,
    "repeated": int((g.groupby(["freq_hz", "amp"]).size() > 1).sum())}), include_groups=False)
per_rat["trials_140Hz"] = trials[trials.freq_hz == 140].groupby("subject").size()
per_rat["other"] = trials[~trials.index.isin(design.index) & (trials.freq_hz != 140)].groupby("subject").size()
print("\nPer rat, of the 16 combinations of 5 to 40 Hz and 50 to 400 uA:")
print(per_rat.fillna(0).astype(int).to_string())
missing = {s: sorted(set((f, a) for f in [5, 10, 20, 40] for a in [50, 100, 200, 400]) -
                     set(map(tuple, g[["freq_hz", "amp"]].values))) for s, g in design.groupby("subject")}
print("Combinations without a trial:", {k: v for k, v in missing.items() if v})
Trials (one-channel series) per rat: {'sub-2021-11-29': 20, 'sub-2021-11-30': 18, 'sub-2021-12-01': 15, 'sub-2021-12-06': 21, 'sub-2021-12-07': 22, 'sub-2021-12-14': 21, 'sub-2021-12-15': 22, 'sub-2021-12-16': 23, 'sub-2021-12-17': 23}
Total trials: 185 ; paper, Methods 2.4: 20 per rat, 180 for 9 rats

Waveform frequency from the spectrum (Hz), values: [np.float64(5.0), np.float64(10.0), np.float64(20.0), np.float64(40.0), np.float64(100.0), np.float64(140.0)]
Zero-crossing frequency minus spectral frequency, max abs (Hz): 0.017
Peak values: [np.float64(19.99), np.float64(49.98), np.float64(99.97), np.float64(199.94), np.float64(399.87)]
Peak / RMS, range: 1.4144 to 1.4145 (a sinusoid gives 1.4142)
Nonzero samples outside the waveform, total: 0

Onset within the series (s): 60.17 to 60.28; duration (s): 60.02 to 60.02; series length (s): 180.9 to 257.9

Trials by frequency (rows) and peak (columns), all rats:
amp      20.0   50.0   100.0  200.0  400.0
freq_hz                                   
5.0          0     11      9      9      8
10.0         0      9      9     11      7
20.0         0     11      8      9      7
40.0         0     10      9     10      7
100.0        1      0      0      0      0
140.0        0      9     11     12      8

Per rat, of the 16 combinations of 5 to 40 Hz and 50 to 400 uA:
                trials_5_to_40Hz  distinct_combinations  repeated  trials_140Hz  other
subject                                                                               
sub-2021-11-29                15                     15         0             4      1
sub-2021-11-30                13                     13         0             5      0
sub-2021-12-01                12                     12         0             3      0
sub-2021-12-06                16                     16         0             5      0
sub-2021-12-07                18                     16         2             4      0
sub-2021-12-14                17                     16         1             4      0
sub-2021-12-15                18                     16         2             4      0
sub-2021-12-16                17                     16         1             6      0
sub-2021-12-17                18                     16         2             5      0
Combinations without a trial: {'sub-2021-11-29': [(20, 100)], 'sub-2021-11-30': [(10, 400), (20, 400), (40, 400)], 'sub-2021-12-01': [(5, 400), (10, 400), (20, 400), (40, 400)]}

Each one-channel series of a 1-minute file is the stimulation command, not a recording: it is exactly zero for the first 60.2 s and the last minute, and during the minute between is a pure sinusoid (peak over RMS of 1.414) at 5, 10, 20, 40 or 140 Hz whose peak is 50, 100, 200 or 400 to within 0.2%, the currents of Methods 2.4 in uA. The channel name "S1r 1" matches the stream uS1r that the paper's MUAartrem.m reads as the "stimulation channel"; the multi-unit stream (Wav2) and the monitor (MonA) that the code uses are not stored. The stated unit (volts, times 1e-6) is wrong for this channel: the values are the current in uA. The trial timing agrees with the paradigm (1 min of baseline, 1 min of stimulation, then the post-stimulus minute). The files give the frequency and amplitude of every trial, which the paper's analysis needs, but no neural data to apply them to. The counts of trials differ from the paper's 20 per rat (printed above), and one trial at 100 Hz and 20 uA is outside the paper's design.

In [4]:
twenty = [a for a in assets if acs.paradigm(a["path"]) == "20-min"]
with ProcessPoolExecutor(max_workers=4) as ex:
    profiles = list(ex.map(acs.band_power_profile, twenty))
prof = pd.DataFrame([{"subject": p["path"].split("/")[0], **{k: v for k, v in p["bands_psd"].items()},
                      "median_abs": p["raw_median_abs"], "p99_abs": p["raw_p99_abs"],
                      "500-3000Hz_std": p["mua_band_std"], "crossings_6MAD_per_s": p["mua_crossings_per_s_median"],
                      "kurtosis_500-3000Hz": p["mua_kurtosis_median"]} for p in profiles])
print("Welch power spectral density of the stored values (units^2/Hz), 30 s of baseline from minute 5, mean over 16 channels:")
print(prof.set_index("subject").iloc[:, :9].map(lambda v: f"{v:.1e}").to_string())
ratio = prof["100-200 Hz"] / prof["500-1000 Hz"]
print("\nPSD 100-200 Hz over 500-1000 Hz, range: %.0f to %.0f" % (ratio.min(), ratio.max()))
print("PSD 500-1000 Hz over 3000-6000 Hz, range: %.1f to %.1f" % ((prof["500-1000 Hz"] / prof["3000-6000 Hz"]).min(),
                                                                (prof["500-1000 Hz"] / prof["3000-6000 Hz"]).max()))
print("\nStored values, median |x| and 99th percentile |x| over channels:")
print(prof[["subject", "median_abs", "p99_abs", "500-3000Hz_std", "crossings_6MAD_per_s", "kurtosis_500-3000Hz"]].to_string(index=False))
print("\nIf the stored values were scaled by the conversion 1e-6 to volts, the median |LFP| would be "
      f"{prof.median_abs.median() * 1e-6 * 1e9:.2f} nV; read as volts it is {prof.median_abs.median() * 1e3:.2f} mV.")
Welch power spectral density of the stored values (units^2/Hz), 30 s of baseline from minute 5, mean over 16 channels:
               0.3-4 Hz  4-30 Hz 30-100 Hz 100-200 Hz 200-300 Hz 300-500 Hz 500-1000 Hz 1000-3000 Hz 3000-6000 Hz
subject                                                                                                          
sub-2023-03-22  7.3e-08  4.5e-09   1.5e-09    2.1e-11    1.7e-12    4.9e-13     1.7e-13      1.0e-13      3.4e-14
sub-2023-04-27  2.7e-10  4.6e-11   2.7e-11    1.5e-12    1.4e-13    6.6e-14     3.3e-14      1.8e-14      1.3e-14
sub-2023-04-28  4.2e-09  4.6e-10   1.2e-11    6.8e-13    2.7e-13    1.7e-13     8.7e-14      2.5e-14      1.2e-14
sub-2023-05-01  3.5e-09  4.6e-10   1.8e-11    6.0e-13    1.9e-13    8.8e-14     4.3e-14      1.9e-14      1.3e-14
sub-2023-05-04  2.9e-09  9.4e-10   6.2e-12    2.5e-13    1.1e-13    6.2e-14     3.7e-14      2.8e-14      2.3e-14
sub-2023-05-05  4.3e-09  4.9e-10   6.6e-12    4.7e-13    1.6e-13    8.1e-14     4.0e-14      1.8e-14      1.3e-14
sub-2023-05-08  6.2e-09  5.4e-10   7.7e-12    7.9e-13    1.8e-13    1.2e-13     8.0e-14      2.8e-14      1.7e-14
sub-2023-06-07  2.0e-10  1.2e-11   1.6e-09    1.7e-11    3.4e-13    3.0e-13     3.1e-14      1.1e-14      1.0e-14
sub-2023-06-27  4.7e-10  7.5e-11   1.2e-11    3.3e-13    1.1e-13    1.4e-13     3.4e-14      4.0e-14      1.1e-14
sub-2023-08-01  1.1e-09  1.2e-10   6.4e-11    2.3e-13    2.6e-13    3.2e-13     7.3e-14      7.2e-14      1.4e-14
sub-2023-08-03  6.7e-09  9.2e-10   1.4e-11    1.3e-12    5.9e-13    3.9e-13     2.2e-13      9.6e-14      4.3e-14
sub-2023-08-08  2.6e-09  2.5e-10   8.2e-12    4.7e-13    1.7e-13    8.9e-14     4.1e-14      1.9e-14      1.3e-14
sub-2023-08-09  3.1e-09  3.3e-10   1.2e-11    3.1e-13    8.5e-14    4.5e-14     3.2e-14      2.7e-14      2.1e-14

PSD 100-200 Hz over 500-1000 Hz, range: 3 to 544
PSD 500-1000 Hz over 3000-6000 Hz, range: 1.6 to 7.4

Stored values, median |x| and 99th percentile |x| over channels:
       subject  median_abs  p99_abs  500-3000Hz_std  crossings_6MAD_per_s  kurtosis_500-3000Hz
sub-2023-03-22    0.000622 0.006325        0.000017              1.133333             3.597643
sub-2023-04-27    0.000055 0.000366        0.000007              0.000000             3.090035
sub-2023-04-28    0.000124 0.000626        0.000008             22.000000            15.257885
sub-2023-05-01    0.000110 0.000731        0.000007              6.766667             9.919430
sub-2023-05-04    0.000116 0.000782        0.000008              0.000000             3.032982
sub-2023-05-05    0.000103 0.000731        0.000007              2.000000             5.979816
sub-2023-05-08    0.000094 0.000931        0.000009              0.400000             3.848778
sub-2023-06-07    0.000164 0.001148        0.000005              0.000000             3.054934
sub-2023-06-27    0.000052 0.000453        0.000005              0.966667             4.080626
sub-2023-08-01    0.000074 0.000648        0.000006              0.066667             3.218656
sub-2023-08-03    0.000301 0.002217        0.000008              0.000000             3.049820
sub-2023-08-08    0.000132 0.001111        0.000006              0.200000             3.321969
sub-2023-08-09    0.000483 0.002996        0.000006              0.166667            63.724640

If the stored values were scaled by the conversion 1e-6 to volts, the median |LFP| would be 0.12 nV; read as volts it is 0.12 mV.
In [5]:
spikes = pd.DataFrame([{"subject": p["path"].split("/")[0], "line_60Hz_ratio": p["line60_ratio"],
                        "events_per_s_busiest_channel": p["events_per_s_max"], "busiest_channel": p["busiest_channel"],
                        "share_coincident_on_other_channel": p["coincident_share"],
                        "mean_event_trough_uV": p["trough_uV"], "trough_width_ms": p["trough_width_ms"]} for p in profiles])
print("60 Hz line over its neighbours (50 to 70 Hz), negative 500-3000 Hz peaks beyond 6 MAD on the busiest channel,")
print("and the mean unfiltered waveform at those peaks (trough and its width at half depth):")
print(spikes.round(3).to_string(index=False))
lr = spikes.line_60Hz_ratio
print(f"\n60 Hz line ratio: at least 10 in {(lr >= 10).sum()} of {len(lr)} rats; below 10 in",
      spikes.loc[lr < 10, ["subject", "line_60Hz_ratio"]].round(3).values.tolist())
60 Hz line over its neighbours (50 to 70 Hz), negative 500-3000 Hz peaks beyond 6 MAD on the busiest channel,
and the mean unfiltered waveform at those peaks (trough and its width at half depth):
       subject  line_60Hz_ratio  events_per_s_busiest_channel  busiest_channel  share_coincident_on_other_channel  mean_event_trough_uV  trough_width_ms
sub-2023-03-22          265.588                         1.167               13                              0.914              -135.839            0.410
sub-2023-04-27          220.380                         0.333               16                              0.000               -77.705            0.164
sub-2023-04-28           15.424                        43.833               12                              0.396              -134.730            0.328
sub-2023-05-01           10.919                        17.433               15                              0.239               -60.952            0.246
sub-2023-05-04            1.000                         0.000                1                                NaN                   NaN              NaN
sub-2023-05-05            1.041                        13.233               10                              0.116               -87.721            0.246
sub-2023-05-08           10.248                         9.000                9                              0.044              -131.106            0.410
sub-2023-06-07         1099.002                         0.033                1                                NaN               -43.454            0.328
sub-2023-06-27           65.994                         9.633                3                              0.121               -53.516            0.246
sub-2023-08-01          334.095                         6.200               15                              0.005              -164.603            0.737
sub-2023-08-03            2.945                         2.200                4                              0.000              -181.952            0.410
sub-2023-08-08            9.607                         2.733                6                              0.012               -64.230            0.328
sub-2023-08-09            5.810                         0.467                2                              0.143               -90.925            0.246

60 Hz line ratio: at least 10 in 8 of 13 rats; below 10 in [['sub-2023-05-04', 1.0], ['sub-2023-05-05', 1.041], ['sub-2023-08-03', 2.945], ['sub-2023-08-08', 9.607], ['sub-2023-08-09', 5.81]]

The 20-minute files hold one 16-channel stream at 12207 Hz. Methods 2.3 describe two: the LFP (0.3 to 300 Hz, notch-filtered at 60, 120 and 180 Hz, stored at 12 kHz) and the multi-unit band (500 to 3000 Hz, stored at 24 kHz). This stream has the LFP's rate but is not low-passed at 300 Hz, and in most rats it is not notch-filtered: in 8 of the 13 the 60 Hz line stands 10 to over a thousand times above its neighbours, which a 60 Hz notch would have removed. In the other five the ratio is 1.0 to 9.6 (printed above), so a notch cannot be ruled out there; in sub-2023-05-04 and sub-2023-05-05 there is no line at all. The spectral density above 300 Hz falls slowly, in some rats by less than tenfold from 100-200 Hz to 500-1000 Hz. In several rats the 500 to 3000 Hz band carries spikes: negative peaks beyond 6 MAD at up to tens per second on the busiest channel, in most rats seldom coincident with other channels 0.5 mm away (in sub-2023-03-22 they are coincident, and are more likely noise), with an unfiltered mean waveform whose trough is 50 to 180 uV deep and a few tenths of a millisecond wide. So the files hold what spike sorting needs for the 20-minute experiments, at half the paper's sampling rate. In other rats few such events appear in the 30 s examined. The stated conversion of 1e-6 would make the signals tenths of a nanovolt, far below the noise of any amplifier; read as volts, the median of about 0.1 mV and the 99th percentiles below 7 mV are typical of cortical recordings, and the spike troughs of about 100 uV are typical of extracellular spikes. The values are taken as volts, and the conversion factor is recorded as a metadata error.

In [6]:
with ProcessPoolExecutor(max_workers=4) as ex:
    prints = pd.DataFrame([r for rows in ex.map(acs.series_fingerprints, assets) for r in rows])
nonzero = prints[~prints.all_zero]
dup = nonzero[nonzero.duplicated("sha1_first_second", keep=False)]
print("Series:", len(prints), "; with a nonzero first second:", len(nonzero), "; all-zero first second:", int(prints.all_zero.sum()))
print("Series whose first second is identical to another's:", len(dup))
print(dup.to_string(index=False) if len(dup) else "")
lengths = trials.groupby("subject").apply(lambda g: tuple(zip(g.freq_hz, g.amp)), include_groups=False)
print("1-min rats with the same sequence of trial parameters as another rat:",
      int(lengths.duplicated(keep=False).sum()))
Series: 241 ; with a nonzero first second: 56 ; all-zero first second: 185
Series whose first second is identical to another's: 0

1-min rats with the same sequence of trial parameters as another rat: 0

No 20-minute series repeats another (the first second of each differs), and no two 1-minute rats share the same sequence of trial parameters, so no recording was found deposited twice. The 1-minute series all start with zeros (the command before stimulation), so their first seconds cannot be compared; their parameter sequences can.

In [7]:
t0 = time.time()
with ProcessPoolExecutor(max_workers=4) as ex:
    peaks = list(ex.map(acs.cycle_peaks, twenty))
print(f"cycle peaks of 13 rats in {time.time() - t0:.0f} s")
timing = pd.DataFrame([{
    "subject": r["subject"], "series_min": r["series_s"] / 60, "baseline_min": r["onset_s"] / 60,
    "stimulation_min": (r["offset_s"] - r["onset_s"]) / 60, "after_offset_min": (r["series_s"] - r["offset_s"]) / 60,
    "cycles": r["n_cycles"], "cycles_per_s": r["n_cycles"] / (r["offset_s"] - r["onset_s"] - 2 * acs.EDGE_S)} for r in peaks])
print(timing.round(2).to_string(index=False))
later = files[files.paradigm == "20-min"][["subject", "n_series", "minutes_total"]]
print("\nSeries per 20-min file and total minutes:", dict(zip(later.subject, zip(later.n_series, later.minutes_total))))
cycle peaks of 13 rats in 216 s
       subject  series_min  baseline_min  stimulation_min  after_offset_min  cycles  cycles_per_s
sub-2023-03-22       52.31         20.18            20.00             12.12   47919          40.0
sub-2023-04-27       47.55         20.53            19.98              7.03   47879          40.0
sub-2023-04-28       52.14         22.85            19.98              9.30   47879          40.0
sub-2023-05-01       59.61         23.02            19.98             16.61   47879          40.0
sub-2023-05-04       53.91         21.08            20.00             12.82   47919          40.0
sub-2023-05-05       48.05         21.48            19.98              6.58   47879          40.0
sub-2023-05-08       54.62         23.52            19.98             11.12   47879          40.0
sub-2023-06-07       56.72         31.12            19.98              5.62   47879          40.0
sub-2023-06-27       62.45         21.62            19.98             20.85   47879          40.0
sub-2023-08-01       61.66         21.82            20.00             19.85   47919          40.0
sub-2023-08-03       61.52         22.03            19.98             19.50   47879          40.0
sub-2023-08-08       61.59         23.85            19.98             17.76   47879          40.0
sub-2023-08-09       58.64         22.85            19.98             15.80   47879          40.0

Series per 20-min file and total minutes: {'2023-03-22': (4, 116.5), '2023-04-27': (5, 119.0), '2023-04-28': (4, 122.4), '2023-05-01': (4, 120.8), '2023-05-04': (3, 82.3), '2023-05-05': (5, 136.5), '2023-05-08': (5, 145.7), '2023-06-07': (5, 142.4), '2023-06-27': (5, 140.7), '2023-08-01': (4, 131.3), '2023-08-03': (4, 130.7), '2023-08-08': (4, 125.5), '2023-08-09': (4, 126.8)}

The files have no epochs, so the stimulation is found from its 40 Hz artifact (1-s resolution) in the first series of each file. In every rat the artifact lasts 20 minutes (printed above), as Methods 2.4 state, at 40 cycles per second. The baseline before it is about 20 minutes in most rats and up to 31 minutes in one. The first series continues 5.6 to 20.9 minutes after offset, less than the 10 minutes that the paper compares after offset in four rats (the paper's nulldistribution.py shortens the window when the first post-stimulation segment is shorter); the further series are the later post-stimulation recordings that the dandiset's description names. There is no trial table whose clock the streams could be compared with; the stimulation times come from the data, and the analysis below uses only the stimulation period.

Spike sorting of the 20-minute recordings: how long it takes¶

units-20min and every claim built on its neurons need the 20-minute recordings sorted, as the paper did with SpyKING CIRCUS (Methods 2.6). The claims use 20 minutes of baseline, the 20 minutes of stimulation and the 10 minutes after offset, so a sort needs 50 minutes per rat (less in the four rats whose first series ends sooner). Here one rat is sorted over its whole 50-minute window, as every rat would be: the multi-unit band (500 to 3000 Hz, Methods 2.3) is streamed and filtered, the artifact is removed during stimulation with a causal uniform comb filter over the 10 preceding periods (Methods 2.5, ARtACS; the paper's MUAartrem.m uses 10 periods), and SpyKING CIRCUS 2 sorts it at the paper's detection threshold of 6. The time of this rat, per minute of recording, gives the time for all 13 rats. The earlier version of this notebook extrapolated from 5 and 15 minutes of the same rat, and its estimate moved widely between runs; the full window measures it directly. The time depends on the machine, and the numbers printed below are those of this run.

In [8]:
rat = next(a for a in twenty if a["path"].startswith("sub-2023-04-28"))
pr = next(r for r in peaks if r["subject"] == "sub-2023-04-28")
t0 = time.time()
mua = acs.load_mua(rat, pr["onset_s"], pr["offset_s"])
load_s = time.time() - t0
x, fs = mua["x"], mua["fs"]
window_min = mua["end"] / fs / 60
print(f"{pr['subject']}: {window_min:.1f} min window ({mua['onset'] / fs / 60:.1f} min baseline, "
      f"{(mua['offset'] - mua['onset']) / fs / 60:.1f} min stimulation, {(mua['end'] - mua['offset']) / fs / 60:.1f} min after), "
      f"streamed, filtered and cleaned in {load_s:.0f} s")

# The artifact in the multi-unit band: the part locked to the 40 Hz cycle, in uV, per channel, for
# one minute of baseline, one minute of stimulation before and after the comb filter, and one
# minute after offset; with the noise (MAD) of each minute for scale.
m1 = int(60 * fs)
f_ = acs.open_asset(rat["asset_id"])
d_ = f_["acquisition/ElectricalSeries0/data"]
s_on = mua["start"] + mua["onset"] + 5 * m1
from scipy import signal
sos = signal.butter(3, acs.MUA_BAND, btype="band", fs=fs, output="sos")
raw_stim = signal.sosfiltfilt(sos, d_[s_on - int(fs):s_on + m1 + int(fs), :].astype(float), axis=0)[int(fs):int(fs) + m1]
segments = {"baseline, last minute": x[mua["onset"] - m1:mua["onset"]],
            "stimulation minute 6, before comb": raw_stim,
            "stimulation minute 6, after comb": x[mua["onset"] + 5 * m1:mua["onset"] + 6 * m1],
            "after offset, first minute": x[mua["offset"]:mua["offset"] + m1]}
art = pd.DataFrame({k: acs.locked_ptp(v.astype(float), fs) * 1e6 for k, v in segments.items()}).T
art["median_MAD_uV"] = [np.median(np.median(np.abs(v), axis=0) / 0.6745) * 1e6 for v in segments.values()]
print("\n40 Hz-locked peak-to-peak (uV) per channel, and median noise (MAD):")
print(art.round(2).to_string())

import spikeinterface
print("\nspikeinterface", spikeinterface.__version__)
srt = acs.sort_mua(x, fs)
sort_s = srt["seconds"]
counts = np.array([len(v) for v in srt["trains"].values()])
by_channel = np.bincount(list(srt["channel"].values()), minlength=16)
print(f"\nSpyKING CIRCUS 2: {len(counts)} units in {sort_s:.0f} s; spikes per unit {counts.min()} to {counts.max()}")
print("Units per channel (aw_1 to aw_16):", by_channel.tolist(), "; median", np.median(by_channel))
# inclusion, Methods 2.6: at least 0.25 Hz (3 spikes) in at least half of the 10-s windows of the
# baseline and the stimulation, and more than 2 spikes in each period (phaseextract.py)
edges = np.arange(mua["onset"] - int(acs.BASELINE_S * fs), mua["offset"] + 1, int(10 * fs))
edges = edges[edges >= 0]
inc = 0
for st in srt["trains"].values():
    n10 = np.histogram(st, edges)[0]
    pre_n = np.sum(st < mua["onset"]); stim_n = np.sum((st >= mua["onset"]) & (st < mua["offset"]))
    inc += int(np.mean(n10 / 10 >= 0.25) >= 0.5 and pre_n > 2 and stim_n > 2)
print(f"Units passing the 0.25 Hz rule in this rat: {inc} of {len(counts)}")
del x, mua, raw_stim, segments

per_min = (load_s + sort_s) / window_min
need = (np.minimum(timing.baseline_min, 20) + timing.stimulation_min + np.minimum(timing.after_offset_min, 10))
est_min = per_min * need / 60
print(f"\nTime per minute of recording: {per_min:.1f} s (load {load_s / window_min:.1f}, sort {sort_s / window_min:.1f})")
print("Window per rat (min):", dict(zip(timing.subject, need.round(1))))
ran_min = (time.time() - started) / 60
rest_min = ran_min - (load_s + sort_s) / 60
print(f"Estimated time to load and sort the 13 rats: {est_min.sum():.0f} min, against the notebook limit of 60 min.")
print(f"Sorting alone {'exceeds' if est_min.sum() > 60 else 'fits within'} the limit, by {abs(est_min.sum() - 60):.0f} min. "
      f"The rest of this notebook up to here took {rest_min:.0f} min, giving {est_min.sum() + rest_min:.0f} min "
      f"before any analysis of the neurons.")
sub-2023-04-28: 49.3 min window (20.0 min baseline, 20.0 min stimulation, 9.3 min after), streamed, filtered and cleaned in 78 s
40 Hz-locked peak-to-peak (uV) per channel, and median noise (MAD):
                                       0      1      2      3      4      5      6      7      8      9     10     11     12     13     14     15  median_MAD_uV
baseline, last minute               0.63   0.52   0.51   0.42   0.91   0.65   0.72   0.60   0.75   0.61   1.09   2.03   0.57   0.69   0.50   1.30           6.44
stimulation minute 6, before comb  22.34  11.54  11.58  12.01  16.84  20.53  17.92  12.38  16.31  13.84  13.11  11.35  12.59  11.74  12.03  17.42           7.14
stimulation minute 6, after comb    1.64   0.81   0.84   0.85   1.23   1.54   1.33   0.85   1.08   1.00   0.97   0.91   0.91   0.79   0.82   1.24           7.17
after offset, first minute          0.62   0.45   0.46   0.51   0.78   0.83   0.55   0.52   0.64   0.85   1.00   2.19   0.57   0.61   0.73   1.79           6.62
/home/runner/work/_temp/executed/.venv/lib/python3.13/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
spikeinterface 0.103.0
spykingcircus2 could benefit from using torch. Consider installing it
/home/runner/work/_temp/executed/.venv/lib/python3.13/site-packages/spikeinterface/core/baserecordingsnippets.py:242: UserWarning: There is no Probe attached to this recording. Creating a dummy one with contact positions
  warn("There is no Probe attached to this recording. Creating a dummy one with contact positions")
/home/runner/work/_temp/executed/.venv/lib/python3.13/site-packages/spikeinterface/core/baserecordingsnippets.py:242: UserWarning: There is no Probe attached to this recording. Creating a dummy one with contact positions
  warn("There is no Probe attached to this recording. Creating a dummy one with contact positions")
/home/runner/work/_temp/executed/.venv/lib/python3.13/site-packages/spikeinterface/core/baserecordingsnippets.py:242: UserWarning: There is no Probe attached to this recording. Creating a dummy one with contact positions
  warn("There is no Probe attached to this recording. Creating a dummy one with contact positions")
/home/runner/work/_temp/executed/.venv/lib/python3.13/site-packages/spikeinterface/core/sortinganalyzer.py:487: UserWarning: The Recording is not serializable! The recording link will be lost for future load
  warnings.warn("The Recording is not serializable! The recording link will be lost for future load")
/home/runner/work/_temp/executed/.venv/lib/python3.13/site-packages/spikeinterface/core/sortinganalyzer.py:487: UserWarning: The Recording is not serializable! The recording link will be lost for future load
  warnings.warn("The Recording is not serializable! The recording link will be lost for future load")
SpyKING CIRCUS 2: 25 units in 359 s; spikes per unit 1501 to 84112
Units per channel (aw_1 to aw_16): [1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 2, 2, 2, 1, 1, 4] ; median 1.0
Units passing the 0.25 Hz rule in this rat: 25 of 25

Time per minute of recording: 8.9 s (load 1.6, sort 7.3)
Window per rat (min): {'sub-2023-03-22': 50.0, 'sub-2023-04-27': 47.0, 'sub-2023-04-28': 49.3, 'sub-2023-05-01': 50.0, 'sub-2023-05-04': 50.0, 'sub-2023-05-05': 46.6, 'sub-2023-05-08': 50.0, 'sub-2023-06-07': 45.6, 'sub-2023-06-27': 50.0, 'sub-2023-08-01': 50.0, 'sub-2023-08-03': 50.0, 'sub-2023-08-08': 50.0, 'sub-2023-08-09': 50.0}
Estimated time to load and sort the 13 rats: 94 min, against the notebook limit of 60 min.
Sorting alone exceeds the limit, by 34 min. The rest of this notebook up to here took 6 min, giving 100 min before any analysis of the neurons.

The time printed above is for one rat sorted over its whole window, scaled by each rat's window (45.6 to 50 minutes); it is not an extrapolation from short stretches. The estimate for the 13 rats is over the 60 minutes a notebook may run, before the permutation tests, the phase extraction and the LFP analyses that build on the neurons, and before the time this notebook spends on everything else. The margin is narrow and depends on the machine: the sorter's time varies between runs and machines, and a faster machine could bring the sorting alone under the limit, though not the sorting together with the rest of the notebook. units-20min is therefore blocked as too large, and with it the claims that use its neurons: 20min-during-percentages, 20min-post-percentages, 20min-magnitudes, the four power and four PAC claims, whose channels are those near the affected neurons, and the 20-minute parts of baseline-fr and baseline-ppc.

The comb filter removes the artifact from the multi-unit band: the part locked to the 40 Hz cycle falls from 11 to 22 uV peak to peak during stimulation to 0.8 to 1.6 uV, against 0.4 to 2.0 uV in the minute before onset and noise of about 7 uV (MAD). The number of units the sorter finds in this rat, and how many pass the 0.25 Hz rule, are printed above (the paper's median is 44 per rat and 4 per channel); the count varies a little between runs. These are one rat's numbers, shown to confirm that the files hold sortable spikes; they do not test units-20min, whose values are over 13 rats.

Claim efield-20min-median¶

The median electric field in the 20-minute 100 uA experiments was 1.65 mV/mm. (Results 3.4, paragraph 1; Figure 1D. Expected 1.65 +/- 0.21 mV/mm.)

Criterion: as efield-1min-medians (Methods 2.8, 40 Hz band), over the 13 rats, with the same readings: (a) the median over rats of each rat's average field, (b) the median over all channel-pair estimates of all rats; the field per axis read as (i) each neighbour pair, (ii) the largest pair per axis and rat; a zero-phase Butterworth band of +/- 1 Hz on the LFP stream. Reading (i) is run two ways, since the paper does not say how a pair along one axis is matched with a pair along the other for the vector addition: per 2 x 2 cell (the mean of its two differences along each axis) and per electrode (the differences to its neighbours to the right and below). Methods 2.8 apply Grubbs' test to "electric field values" without saying over which set; it is run over all estimates of all rats together (main), within each rat, and not at all.

In [9]:
rng = np.random.default_rng(1678)  # this section's generator
pk = np.array([r["peak_mean"] for r in peaks])  # rats x 16, volts as stored
subjects = [r["subject"] for r in peaks]
print("Average cycle peak per channel (mV), channels aw_1 to aw_16 laid out row by row:")
for s, v in zip(subjects, pk):
    print(s)
    print(acs.grid(v) * 1e3)
print("\nAll average peaks, range (mV): %.3f to %.3f" % (pk.min() * 1e3, pk.max() * 1e3))
cv = np.array([r["peak_cv"] for r in peaks])
print("Spread of cycle peaks within a channel (CV), median %.3f, range %.3f to %.3f" % (np.median(cv), cv.min(), cv.max()))
half = np.array([r["peak_first_half"] / r["peak_second_half"] for r in peaks])
print("First-half over second-half average peak, per channel, median %.2f, range %.2f to %.2f" % (np.median(half), half.min(), half.max()))
Average cycle peak per channel (mV), channels aw_1 to aw_16 laid out row by row:
sub-2023-03-22
[[1.849 2.114 1.355 1.801]
 [1.241 1.315 1.251 0.866]
 [0.595 0.342 0.352 0.368]
 [0.262 0.415 0.432 0.45 ]]
sub-2023-04-27
[[0.258 0.266 0.266 0.402]
 [0.766 0.699 0.784 0.644]
 [2.86  2.761 2.763 2.854]
 [1.595 1.839 1.743 1.694]]
sub-2023-04-28
[[0.111 0.038 0.038 0.036]
 [0.45  0.448 0.464 0.489]
 [1.657 1.504 1.487 1.566]
 [0.854 1.015 0.953 0.991]]
sub-2023-05-01
[[0.475 0.122 0.122 0.088]
 [0.76  0.629 0.541 0.603]
 [1.679 1.616 1.795 2.138]
 [0.858 1.048 1.132 1.407]]
sub-2023-05-04
[[0.216 0.05  0.02  0.077]
 [0.561 0.723 0.692 0.799]
 [2.39  2.295 2.451 2.413]
 [1.68  1.666 1.666 1.396]]
sub-2023-05-05
[[0.894 0.305 0.306 0.247]
 [1.499 1.319 1.13  1.172]
 [3.391 3.444 3.672 4.028]
 [1.849 2.151 2.449 2.801]]
sub-2023-05-08
[[0.959 0.317 0.317 0.119]
 [1.488 1.34  0.897 0.604]
 [3.062 3.163 3.348 3.612]
 [1.575 1.885 1.764 2.179]]
sub-2023-06-07
[[0.406 0.402 0.408 0.422]
 [1.097 0.968 0.98  1.147]
 [2.778 2.854 3.304 3.507]
 [1.804 2.098 2.032 2.358]]
sub-2023-06-27
[[0.93  0.772 0.604 0.478]
 [1.34  1.019 0.945 0.816]
 [1.78  0.74  0.785 0.777]
 [1.229 1.68  1.932 1.855]]
sub-2023-08-01
[[0.728 0.901 0.686 0.412]
 [1.569 1.393 1.435 1.222]
 [2.699 1.932 3.248 3.247]
 [2.014 1.977 2.167 2.62 ]]
sub-2023-08-03
[[0.726 0.432 0.421 0.222]
 [0.832 1.025 0.924 0.933]
 [1.872 1.95  1.933 2.022]
 [1.508 1.427 1.499 2.47 ]]
sub-2023-08-08
[[0.612 0.631 0.595 0.243]
 [1.247 1.157 1.184 1.17 ]
 [2.238 2.474 3.035 2.439]
 [1.91  1.935 1.865 2.339]]
sub-2023-08-09
[[2.826 1.843 1.434 1.677]
 [2.108 2.156 1.853 1.276]
 [2.473 2.299 2.265 2.53 ]
 [2.068 1.925 2.232 2.677]]

All average peaks, range (mV): 0.020 to 4.028
Spread of cycle peaks within a channel (CV), median 0.041, range 0.012 to 0.775
First-half over second-half average peak, per channel, median 1.01, range 0.30 to 2.82
In [10]:
# How stable the artifact is over the 20 minutes, and where onset and offset fall.
ppm = [r["peak_per_minute"] / r["peak_mean"] for r in peaks]  # minutes x 16, relative to each channel's mean
print("Average cycle peak per minute relative to the channel's 20-min mean: per rat, median over channels of the")
print("smallest and largest minute, and the channels whose first-half over second-half ratio is outside 0.67 to 1.5:")
flag = {}
for s, r, q, h in zip(subjects, peaks, ppm, half):
    bad = np.flatnonzero((h < 0.67) | (h > 1.5))
    flag[s] = bad
    print(f"  {s}: minutes {len(q)}, min {np.median(q.min(0)):.2f}, max {np.median(q.max(0)):.2f}; "
          f"unstable channels {[int(b) + 1 for b in bad]} (ratios {np.round(h[bad], 2).tolist()})")
print("Unstable channels, all rats:", sum(len(v) for v in flag.values()), "of", 16 * len(subjects))
print("\n40 Hz line ratio (largest over channels), per second from 15 s before to 15 s after the detected onset and offset:")
for s, r in zip(subjects, peaks):
    on, off = r["onset_profile"], r["offset_profile"]
    print(f"  {s}: onset, before max {on[:15].max():.0f}, after min {on[15:].min():.0f};"
          f" offset, before min {off[:15].min():.0f}, after max {off[15:].max():.0f}")
fig, ax = plt.subplots(1, 3, figsize=(14, 3.5))
for s, q in zip(subjects, ppm):
    ax[0].plot(np.arange(len(q)) + 0.5, np.median(q, axis=1), lw=1)
ax[0].set_xlabel("minute of stimulation"); ax[0].set_ylabel("peak / 20-min mean, median over channels")
ax[0].set_title("artifact over time, 13 rats")
allq = np.concatenate([np.median(q, axis=1) for q in ppm])
print("\nPlotted median relative peaks, range %.2f to %.2f" % (allq.min(), allq.max()))
for s, r in zip(subjects, peaks):
    ax[1].semilogy(np.arange(-15, 15), r["onset_profile"], lw=1)
    ax[2].semilogy(np.arange(-15, 15), r["offset_profile"], lw=1)
for a_, t in [(ax[1], "onset"), (ax[2], "offset")]:
    a_.axhline(1000, color="k", ls=":"); a_.axvline(0, color="k", lw=0.5)
    a_.set_xlabel(f"s from detected {t}"); a_.set_ylabel("40 Hz line ratio"); a_.set_title(f"detection at {t} (threshold dotted)")
plt.tight_layout(); plt.show()
Average cycle peak per minute relative to the channel's 20-min mean: per rat, median over channels of the
smallest and largest minute, and the channels whose first-half over second-half ratio is outside 0.67 to 1.5:
  sub-2023-03-22: minutes 19, min 0.78, max 1.70; unstable channels [9, 13, 14, 15, 16] (ratios [0.6, 2.74, 2.42, 2.64, 2.58])
  sub-2023-04-27: minutes 19, min 0.97, max 1.04; unstable channels [] (ratios [])
  sub-2023-04-28: minutes 19, min 0.85, max 1.06; unstable channels [1, 2, 3, 4] (ratios [0.35, 0.31, 0.31, 0.34])
  sub-2023-05-01: minutes 19, min 0.96, max 1.07; unstable channels [] (ratios [])
  sub-2023-05-04: minutes 19, min 0.96, max 1.12; unstable channels [3] (ratios [1.76])
  sub-2023-05-05: minutes 19, min 0.95, max 1.01; unstable channels [] (ratios [])
  sub-2023-05-08: minutes 19, min 0.78, max 1.27; unstable channels [1, 2, 3, 4] (ratios [1.73, 2.81, 2.82, 0.3])
  sub-2023-06-07: minutes 19, min 0.98, max 1.12; unstable channels [] (ratios [])
  sub-2023-06-27: minutes 19, min 0.99, max 1.03; unstable channels [] (ratios [])
  sub-2023-08-01: minutes 19, min 0.99, max 1.01; unstable channels [] (ratios [])
  sub-2023-08-03: minutes 19, min 0.91, max 1.14; unstable channels [] (ratios [])
  sub-2023-08-08: minutes 19, min 0.96, max 1.10; unstable channels [] (ratios [])
  sub-2023-08-09: minutes 19, min 0.94, max 1.12; unstable channels [] (ratios [])
Unstable channels, all rats: 14 of 208

40 Hz line ratio (largest over channels), per second from 15 s before to 15 s after the detected onset and offset:
  sub-2023-03-22: onset, before max 10, after min 2406; offset, before min 4316, after max 10
  sub-2023-04-27: onset, before max 12, after min 591704; offset, before min 251469, after max 242
  sub-2023-04-28: onset, before max 310, after min 14261; offset, before min 43244, after max 104
  sub-2023-05-01: onset, before max 281, after min 26935; offset, before min 20558, after max 8
  sub-2023-05-04: onset, before max 9, after min 13823; offset, before min 48861, after max 12
  sub-2023-05-05: onset, before max 269, after min 147497; offset, before min 90690, after max 220
  sub-2023-05-08: onset, before max 284, after min 474308; offset, before min 1498999, after max 9
  sub-2023-06-07: onset, before max 163, after min 286720; offset, before min 128218, after max 79
  sub-2023-06-27: onset, before max 247, after min 256190; offset, before min 253434, after max 9
  sub-2023-08-01: onset, before max 9, after min 31370; offset, before min 493576, after max 7
  sub-2023-08-03: onset, before max 257, after min 60227; offset, before min 114152, after max 75
  sub-2023-08-08: onset, before max 7, after min 162261; offset, before min 826847, after max 810
  sub-2023-08-09: onset, before max 150, after min 51871; offset, before min 3929969, after max 63

Plotted median relative peaks, range 0.81 to 1.70
No description has been provided for this image
In [11]:
# The channel layout is not in the files or the paper. Test the assumed order (aw_1 to aw_16 row by
# row) against the serpentine order and random orders: under the right layout the artifact, which
# falls off with distance from the stimulating pads, should vary smoothly across the grid.
n_perm = 2000
rows = []
for s, v in zip(subjects, pk):
    r_row = acs.roughness(acs.grid(v))
    r_serp = acs.roughness(acs.grid(v, acs.SERPENTINE))
    r_rand = np.array([acs.roughness(acs.grid(v, rng.permutation(16))) for _ in range(n_perm)])
    rows.append({"subject": s, "rough_row_by_row": r_row * 1e6, "rough_serpentine": r_serp * 1e6,
                 "rough_random_median": np.median(r_rand) * 1e6,
                 "frac_random_smoother_than_row": np.mean(r_rand <= r_row),
                 "frac_random_smoother_than_serp": np.mean(r_rand <= r_serp)})
maps = pd.DataFrame(rows)
print("Sum of squared neighbour differences (mV^2) under each order, and the share of", n_perm, "random orders as smooth or smoother:")
print(maps.round(4).to_string(index=False))
print("\nRats where row-by-row is smoother than serpentine:", int((maps.rough_row_by_row < maps.rough_serpentine).sum()), "of", len(maps))

# How the field depends on the layout: (a) and (b) per 2 x 2 cell, no outlier removal, under the
# random orders above (the same order for every rat), and under the smoothest 5% of them.
lay_rng = np.random.default_rng(16781)
rand = []
for _ in range(n_perm):
    o = lay_rng.permutation(16)
    cellsets = [acs.fields(acs.grid(v, o))["cells"] for v in pk]
    rand.append({"a": np.median([c.mean() for c in cellsets]), "b": np.median(np.concatenate(cellsets)),
                 "rough": sum(acs.roughness(acs.grid(v, o)) / acs.roughness(acs.grid(v)) for v in pk)})
rand = pd.DataFrame(rand)
smooth = rand[rand.rough <= rand.rough.quantile(0.05)]
for name, sub in [("all random orders", rand), ("smoothest 5%", smooth)]:
    print(f"{name} (n = {len(sub)}): (a) median {sub.a.median():.3f}, 2.5-97.5% {sub.a.quantile(0.025):.3f} to {sub.a.quantile(0.975):.3f}, "
          f"within 1.44-1.86 {sub.a.between(1.44, 1.86).mean():.2f}; (b) median {sub.b.median():.3f}, "
          f"2.5-97.5% {sub.b.quantile(0.025):.3f} to {sub.b.quantile(0.975):.3f}, within {sub.b.between(1.44, 1.86).mean():.2f}")
print(f"Roughness score (each rat's roughness over that of row-by-row, summed over rats): row-by-row {len(pk)}, "
      f"serpentine {sum(acs.roughness(acs.grid(v, acs.SERPENTINE)) / acs.roughness(acs.grid(v)) for v in pk):.1f}, "
      f"smoothest-5% cut {rand.rough.quantile(0.05):.1f}, median random {rand.rough.median():.1f}")
Sum of squared neighbour differences (mV^2) under each order, and the share of 2000 random orders as smooth or smoother:
       subject  rough_row_by_row  rough_serpentine  rough_random_median  frac_random_smoother_than_row  frac_random_smoother_than_serp
sub-2023-03-22            5.5338            5.7514              18.5757                         0.0000                          0.0000
sub-2023-04-27           23.1824           23.1475              47.9011                         0.0015                          0.0015
sub-2023-04-28            7.0171            6.9804              16.0164                         0.0015                          0.0015
sub-2023-05-01            8.9267            9.4074              19.4492                         0.0010                          0.0020
sub-2023-05-04           15.7866           15.7108              39.2912                         0.0000                          0.0000
sub-2023-05-05           33.5977           34.8673              75.7293                         0.0010                          0.0025
sub-2023-05-08           32.3097           33.2769              62.1082                         0.0030                          0.0035
sub-2023-06-07           23.9568           24.7908              55.5567                         0.0000                          0.0000
sub-2023-06-27            5.9706            6.2824              10.6923                         0.0075                          0.0105
sub-2023-08-01           15.9447           17.0400              37.0998                         0.0000                          0.0000
sub-2023-08-03            7.2024            7.4230              21.4258                         0.0000                          0.0000
sub-2023-08-08           12.4990           12.6474              32.5213                         0.0000                          0.0000
sub-2023-08-09            5.2027            7.3380               8.6746                         0.0135                          0.1980

Rats where row-by-row is smoother than serpentine: 10 of 13
all random orders (n = 2000): (a) median 2.108, 2.5-97.5% 1.582 to 2.678, within 1.44-1.86 0.18; (b) median 1.882, 2.5-97.5% 1.416 to 2.448, within 0.43
smoothest 5% (n = 100): (a) median 1.961, 2.5-97.5% 1.579 to 2.397, within 1.44-1.86 0.29; (b) median 1.749, 2.5-97.5% 1.406 to 2.130, within 0.65
Roughness score (each rat's roughness over that of row-by-row, summed over rats): row-by-row 13, serpentine 13.8, smoothest-5% cut 22.4, median random 30.4
In [12]:
def estimates(order=None):
    out = []
    for s, v in zip(subjects, pk):
        g = acs.grid(v, order)
        F = acs.fields(g)
        node = np.hypot(F["ex"][:3, :3], F["ey"][:3, :3]).ravel()
        out.append({"subject": s, "cell": F["cells"], "node": node, "node16": F["nodes_all"],
                    "maximal": np.array([F["maximal"]])})
    return out


def summarise(est, kind, grubbs):
    pooled = np.concatenate([e[kind] for e in est])
    if grubbs == "pooled":
        kept, removed = acs.grubbs(pooled)
        keep_sets = []
        for e in est:
            keep_sets.append(np.array([x for x in e[kind] if not np.any(np.isclose(x, removed))]))
    elif grubbs == "per rat":
        keep_sets = [acs.grubbs(e[kind])[0] if len(e[kind]) > 2 else e[kind] for e in est]
        removed = np.array([0] * (len(pooled) - sum(len(k) for k in keep_sets)))
    else:
        keep_sets = [e[kind] for e in est]
        removed = np.array([])
    allkept = np.concatenate(keep_sets)
    per_rat = np.array([k.mean() for k in keep_sets if len(k)])
    return {"estimates": len(pooled), "removed": len(removed),
            "(a) median of rat means": np.median(per_rat), "(b) median of all estimates": np.median(allkept),
            "rat means min": per_rat.min(), "rat means max": per_rat.max(),
            "IQR of all (b)": np.subtract(*np.percentile(allkept, [75, 25])), "SD of rat means": per_rat.std(ddof=1)}


rows = []
for order_name, order in [("row by row (assumed)", None), ("serpentine", acs.SERPENTINE)]:
    est = estimates(order)
    for kind, label in [("cell", "(i) per 2x2 cell"), ("node", "(i) per electrode, 9"), ("node16", "(i) per electrode, all 16"),
                        ("maximal", "(ii) largest pair per axis")]:
        for gr in ["pooled", "per rat", "none"]:
            if kind == "maximal" and gr == "per rat":
                continue
            rows.append({"layout": order_name, "pairs": label, "Grubbs": gr, **summarise(est, kind, gr)})
table = pd.DataFrame(rows)
lo, hi = 1.65 - 0.21, 1.65 + 0.21
table["(a) within 1.44-1.86"] = table["(a) median of rat means"].between(lo, hi)
table["(b) within 1.44-1.86"] = table["(b) median of all estimates"].between(lo, hi)
print("Electric field (mV/mm), 13 rats, expected 1.65 +/- 0.21:")
print(table.round(3).to_string(index=False))

# Bootstrap 95% intervals of (a) and (b), assumed layout, no outlier removal: resampling rats (a, and b
# with all of a rat's estimates kept together) and, for (b), resampling the estimates themselves.
boot_rng = np.random.default_rng(16782)
est0 = estimates()
brows = []
for kind, label in [("cell", "(i) per 2x2 cell"), ("node", "(i) per electrode, 9"), ("node16", "(i) per electrode, all 16"),
                    ("maximal", "(ii) largest pair per axis")]:
    sets = [e[kind] for e in est0]
    means = np.array([v.mean() for v in sets]); pooled = np.concatenate(sets)
    ba, bb, bp = [], [], []
    for _ in range(2000):
        k = boot_rng.integers(0, len(sets), len(sets))
        ba.append(np.median(means[k])); bb.append(np.median(np.concatenate([sets[j] for j in k])))
        bp.append(np.median(boot_rng.choice(pooled, len(pooled))))
    for name, val, b in [("(a) rats resampled", np.median(means), ba), ("(b) rats resampled", np.median(pooled), bb),
                         ("(b) estimates resampled", np.median(pooled), bp)]:
        lo_, hi_ = np.percentile(b, [2.5, 97.5])
        brows.append({"pairs": label, "reading": name, "median": val, "CI low": lo_, "CI high": hi_, "half-width": (hi_ - lo_) / 2})
print("\nBootstrap 95% intervals (2000 resamples), mV/mm; the paper gives 1.65 +/- 0.21:")
print(pd.DataFrame(brows).round(3).to_string(index=False))

# Without the unstable channels (first-half over second-half peak outside 0.67 to 1.5): cells that
# touch one are dropped, per 2 x 2 cell, assumed layout, no outlier removal.
kept_means, kept_all = [], []
for s, v in zip(subjects, pk):
    bad = np.zeros(16, bool); bad[flag[s]] = True
    gb = acs.grid(bad)
    touch = np.array([[gb[r:r + 2, c:c + 2].any() for c in range(3)] for r in range(3)]).ravel()
    c_ = acs.fields(acs.grid(v))["cells"][~touch]
    if len(c_):
        kept_means.append(c_.mean()); kept_all.append(c_)
print(f"\nWithout cells touching an unstable channel: {sum(len(c) for c in kept_all)} of {9 * len(pk)} cells in {len(kept_means)} rats; "
      f"(a) {np.median(kept_means):.3f}, (b) {np.median(np.concatenate(kept_all)):.3f} mV/mm")
Electric field (mV/mm), 13 rats, expected 1.65 +/- 0.21:
              layout                      pairs  Grubbs  estimates  removed  (a) median of rat means  (b) median of all estimates  rat means min  rat means max  IQR of all (b)  SD of rat means  (a) within 1.44-1.86  (b) within 1.44-1.86
row by row (assumed)           (i) per 2x2 cell  pooled        117        0                    1.834                        1.525          0.810          3.052           1.223            0.730                  True                  True
row by row (assumed)           (i) per 2x2 cell per rat        117        0                    1.834                        1.525          0.810          3.052           1.223            0.730                  True                  True
row by row (assumed)           (i) per 2x2 cell    none        117        0                    1.834                        1.525          0.810          3.052           1.223            0.730                  True                  True
row by row (assumed)       (i) per electrode, 9  pooled        117        0                    1.890                        1.648          1.047          2.976           1.404            0.650                 False                  True
row by row (assumed)       (i) per electrode, 9 per rat        117        1                    1.890                        1.642          0.873          2.976           1.413            0.670                 False                  True
row by row (assumed)       (i) per electrode, 9    none        117        0                    1.890                        1.648          1.047          2.976           1.404            0.650                 False                  True
row by row (assumed)  (i) per electrode, all 16  pooled        208        2                    1.748                        1.644          0.969          2.806           1.344            0.612                  True                  True
row by row (assumed)  (i) per electrode, all 16 per rat        208        3                    1.748                        1.648          0.828          2.987           1.357            0.692                  True                  True
row by row (assumed)  (i) per electrode, all 16    none        208        0                    1.748                        1.650          0.969          2.987           1.378            0.664                  True                  True
row by row (assumed) (ii) largest pair per axis  pooled         13        0                    3.698                        3.698          2.437          6.150           1.710            1.214                 False                 False
row by row (assumed) (ii) largest pair per axis    none         13        0                    3.698                        3.698          2.437          6.150           1.710            1.214                 False                 False
          serpentine           (i) per 2x2 cell  pooled        117        0                    1.848                        1.589          0.939          3.039           1.235            0.709                  True                  True
          serpentine           (i) per 2x2 cell per rat        117        0                    1.848                        1.589          0.939          3.039           1.235            0.709                  True                  True
          serpentine           (i) per 2x2 cell    none        117        0                    1.848                        1.589          0.939          3.039           1.235            0.709                  True                  True
          serpentine       (i) per electrode, 9  pooled        117        0                    1.855                        1.571          1.202          2.875           1.347            0.601                  True                  True
          serpentine       (i) per electrode, 9 per rat        117        0                    1.855                        1.571          1.202          2.875           1.347            0.601                  True                  True
          serpentine       (i) per electrode, 9    none        117        0                    1.855                        1.571          1.202          2.875           1.347            0.601                  True                  True
          serpentine  (i) per electrode, all 16  pooled        208        0                    1.766                        1.570          0.962          3.055           1.467            0.684                  True                  True
          serpentine  (i) per electrode, all 16 per rat        208        2                    1.766                        1.555          0.816          3.055           1.446            0.715                  True                  True
          serpentine  (i) per electrode, all 16    none        208        0                    1.766                        1.570          0.962          3.055           1.467            0.684                  True                  True
          serpentine (ii) largest pair per axis  pooled         13        0                    3.744                        3.744          2.358          5.194           1.475            0.978                 False                 False
          serpentine (ii) largest pair per axis    none         13        0                    3.744                        3.744          2.358          5.194           1.475            0.978                 False                 False
Bootstrap 95% intervals (2000 resamples), mV/mm; the paper gives 1.65 +/- 0.21:
                     pairs                 reading  median  CI low  CI high  half-width
          (i) per 2x2 cell      (a) rats resampled   1.834   1.329    2.374       0.522
          (i) per 2x2 cell      (b) rats resampled   1.525   1.222    1.848       0.313
          (i) per 2x2 cell (b) estimates resampled   1.525   1.310    1.777       0.234
      (i) per electrode, 9      (a) rats resampled   1.890   1.285    2.408       0.561
      (i) per electrode, 9      (b) rats resampled   1.648   1.270    2.018       0.374
      (i) per electrode, 9 (b) estimates resampled   1.648   1.350    1.950       0.300
 (i) per electrode, all 16      (a) rats resampled   1.748   1.362    2.361       0.500
 (i) per electrode, all 16      (b) rats resampled   1.650   1.297    2.042       0.372
 (i) per electrode, all 16 (b) estimates resampled   1.650   1.441    1.914       0.236
(ii) largest pair per axis      (a) rats resampled   3.698   3.095    4.805       0.855
(ii) largest pair per axis      (b) rats resampled   3.698   3.095    4.805       0.855
(ii) largest pair per axis (b) estimates resampled   3.698   3.095    4.805       0.855

Without cells touching an unstable channel: 105 of 117 cells in 13 rats; (a) 1.834, (b) 1.695 mV/mm
In [13]:
est = estimates()
per_rat = pd.DataFrame([{"subject": e["subject"], "cell mean": e["cell"].mean(), "cell median": np.median(e["cell"]),
                         "node mean": e["node"].mean(), "maximal": e["maximal"][0],
                         "max |Ex| pair": np.abs(acs.fields(acs.grid(v))["ex"]).max(),
                         "max |Ey| pair": np.abs(acs.fields(acs.grid(v))["ey"]).max()}
                        for e, v in zip(est, pk)])
print("Per rat, assumed layout, no outlier removal (mV/mm):")
print(per_rat.round(3).to_string(index=False))
allcells = np.concatenate([e["cell"] for e in est])
print("\nAll 117 cell estimates: range %.3f to %.3f mV/mm; median %.3f" % (allcells.min(), allcells.max(), np.median(allcells)))

fig, ax = plt.subplots(1, 2, figsize=(10, 3.5))
ax[0].hist(allcells, bins=30, color="0.4")
ax[0].axvline(1.65, color="C3", label="paper 1.65")
ax[0].axvspan(lo, hi, color="C3", alpha=0.15)
ax[0].set_xlabel("field per 2x2 cell (mV/mm)"); ax[0].set_ylabel("estimates"); ax[0].legend()
ax[0].set_title("all 13 rats; no estimate outside the axes")
med = np.median(np.array([acs.grid(v) for v in pk]) * 1e3, axis=0)
im = ax[1].imshow(med, cmap="viridis"); plt.colorbar(im, ax=ax[1], label="median peak (mV)")
ax[1].set_title("median average peak over rats, row-by-row layout")
plt.tight_layout(); plt.show()
print("Median-over-rats peak grid range (mV): %.3f to %.3f" % (med.min(), med.max()))
Per rat, assumed layout, no outlier removal (mV/mm):
       subject  cell mean  cell median  node mean  maximal  max |Ex| pair  max |Ey| pair
sub-2023-03-22      1.028        1.222      1.200    2.469          1.519          1.946
sub-2023-04-27      2.374        2.180      2.408    4.446          0.487          4.419
sub-2023-04-28      1.372        1.115      1.404    2.437          0.322          2.416
sub-2023-05-01      1.550        1.396      1.494    3.150          0.707          3.070
sub-2023-05-04      2.052        1.422      2.011    3.698          0.541          3.659
sub-2023-05-05      3.052        2.571      2.976    5.833          1.177          5.713
sub-2023-05-08      2.941        2.863      2.840    6.150          1.284          6.015
sub-2023-06-07      2.503        2.064      2.417    4.805          0.899          4.720
sub-2023-06-27      1.029        0.725      1.201    3.095          2.079          2.293
sub-2023-08-01      1.924        1.766      2.029    4.830          2.632          4.049
sub-2023-08-03      1.329        1.102      1.285    2.920          1.943          2.179
sub-2023-08-08      1.834        1.559      1.890    3.888          1.190          3.701
sub-2023-08-09      0.810        0.719      1.047    3.186          1.965          2.507

All 117 cell estimates: range 0.155 to 5.459 mV/mm; median 1.525
No description has been provided for this image
Median-over-rats peak grid range (mV): 0.247 to 2.451
In [14]:
# Variants that cannot change the reading but show how sensitive the number is.
# 1) The band: +/- 2 Hz instead of +/- 1 Hz changes the filtered amplitude of a pure 40 Hz line by
#    less than the filter's ripple; computed on one rat to bound it.
r0 = twenty[0]
f = acs.open_asset(r0["asset_id"])
d = f["acquisition/ElectricalSeries0/data"]
fs = float(f["acquisition/ElectricalSeries0/starting_time"].attrs["rate"])
on = peaks[0]["onset_s"]
from scipy import signal
y = signal.decimate(d[int((on + 300) * fs):int((on + 360) * fs), :].astype(float), acs.LFP_DECIMATE, axis=0)
fs2 = fs / acs.LFP_DECIMATE
res = {}
for hw in [1.0, 2.0]:
    sos = signal.butter(acs.BUTTER_ORDER, [40 - hw, 40 + hw], btype="band", fs=fs2, output="sos")
    yb = signal.sosfiltfilt(sos, y, axis=0)
    per = fs2 / 40
    idx = (np.arange(int(len(yb) / per) + 1) * per).astype(int)
    res[hw] = np.maximum.reduceat(np.abs(yb), idx[:-1], axis=0)[:-1].mean(0)
print(f"{peaks[0]['subject']}, 60 s from 5 min after onset: peaks with +/-2 Hz over +/-1 Hz, per channel:",
      (res[2.0] / res[1.0]).round(3))
F1 = acs.fields(acs.grid(res[1.0])); F2 = acs.fields(acs.grid(res[2.0]))
print("cell-field median, +/-1 Hz %.3f, +/-2 Hz %.3f mV/mm" % (np.median(F1["cells"]), np.median(F2["cells"])))
# 2) The unit: with the files' conversion factor applied the fields are a million times smaller.
print("Main reading with the stored conversion (1e-6) applied: %.2e mV/mm" % (table.iloc[0]["(a) median of rat means"] * 1e-6))
sub-2023-03-22, 60 s from 5 min after onset: peaks with +/-2 Hz over +/-1 Hz, per channel: [1.002 1.002 1.002 1.002 1.002 1.002 1.002 1.002 1.003 1.003 1.004 1.007 1.004 1.003 1.003 1.003]
cell-field median, +/-1 Hz 1.236, +/-2 Hz 1.239 mV/mm
Main reading with the stored conversion (1e-6) applied: 1.83e-06 mV/mm

Result: reproduced, resting on an assumed channel layout. With channels aw_1 to aw_16 laid out row by row and reading (i) taken per 2 x 2 cell, the median field is 1.834 mV/mm as the median of the 13 rat means (a) and 1.525 mV/mm as the median of all 117 estimates (b), both within 1.65 +/- 0.21. Taken per electrode on the 9 electrodes with a right and a lower neighbour, reading (b) gives 1.648 (within) and reading (a) 1.890 (just outside); taken per electrode on all 16, so that every neighbour pair is used, (a) gives 1.748 and (b) 1.650, both within. Reading (ii), the largest pair per axis, gives 3.698, outside. Grubbs' test over the pooled estimates removes none per 2 x 2 cell. The serpentine layout gives the same outcome (1.848 and 1.589 per cell).

The layout matters. Over 2000 random layouts, the same for every rat, (a) per cell falls within 1.44 to 1.86 in 18% and (b) in 43%; over the smoothest 5% of them, in 29% and 65%. Even that 5% is much rougher than any layout in rows: summed over rats, its roughness is at least 22.4 against 13 for row by row and 13.8 for serpentine, so these shares understate how well row-structured layouts support the outcome. Row by row is smoother than serpentine in 10 of 13 rats, and at most 1.35% of random layouts are as smooth in any rat, which supports a layout in rows of four but does not prove this one; the maker's map is not published (see the helper's docstring).

A bootstrap over the 117 cell estimates gives a 95% interval of 1.310 to 1.777 mV/mm for (b), a half-width of 0.234, close to the paper's +/- 0.21; resampling rats gives 0.313 for (b) and 0.522 for (a). The spread between rats is wide: rat means range from 0.810 to 3.052 mV/mm (SD 0.730). The artifact is steady over the 20 minutes in 9 rats; in 4 rats 1 to 5 channels change by more than half between the two halves (14 of 208 channels, the whole first row in two rats). Dropping the cells that touch them gives 1.834 (a) and 1.695 (b). The detected onsets and offsets fall where the 40 Hz line ratio crosses from at most 310 to at least 2406 (and back to at most 810). Widening the band to +/- 2 Hz changes the peaks by under 1% in the rat checked.

Summary¶

Claim Outcome
efield-20min-median reproduced (assumed channel layout): 1.83 mV/mm (a), 1.53 (b), expected 1.65 +/- 0.21
efield-1min-medians blocked, data missing
fem-depth-falloff, fem-lognormal-fits, fem-ellipsoid-axes blocked, data missing (the FEM model is not public)
units-1min and 25 claims on the 1-minute spikes or LFP blocked, data missing (the 20-minute parts of baseline-fr and baseline-ppc are blocked as too large)
units-20min, 20min-during-percentages, 20min-post-percentages, 20min-magnitudes blocked, too large (sorting the 13 rats takes over the 60-min limit at the speed measured on one full rat, by a narrow, machine-dependent margin)
power-entrained-channels, power-reduced-entrainment-channels, power-excited-channels, power-suppressed-channels blocked, too large
pac-entrained-channels, pac-reduced-entrainment-channels, pac-excited-channels, pac-suppressed-channels blocked, too large
sham-no-fr-change, sham-lfp-baseline blocked, data missing

How the analysis differs from the paper's. The electric field is computed from the stored 16-channel stream of the 20-minute files, decimated to 1.2 kHz, with a +/- 1 Hz Butterworth band at 40 Hz (the paper names no filter). The 4 x 4 layout of the channels is assumed (row by row), as neither the files nor the paper give it. The stimulation period is found from the artifact, as the files have no epochs. How the two orthogonal differences are paired for the vector addition is not stated; three pairings are shown. The spike sorting, timed on one rat, uses SpyKING CIRCUS 2 in place of SpyKING CIRCUS 1, after a comb filter in place of ARtACS.

What was found about the dataset.

  • The 1-minute files hold only the stimulation command channel ("S1r 1", the stream uS1r), one series per trial: the multi-unit recordings, the LFP and the stimulation monitor that the paper analysed are not there. The command gives each trial's frequency and amplitude.
  • The command channel is labelled volts with a conversion of 1e-6, but its values are the current in uA; the 20-minute streams are labelled the same way, but their values are volts.
  • The 20-minute files hold one 16-channel stream at 12207 Hz that is neither low-passed at 300 Hz nor notch-filtered, and carries spikes. No sorted units, trial or epoch tables, stimulation times or stimulation waveform are stored.
  • The electrodes table has no positions, so the 4 x 4 layout of the array is not documented.
  • The 1-minute rats have 15 to 23 trials (the paper says 20), three rats lack some of the 16 combinations, and one trial at 100 Hz and 20 uA is outside the paper's design.
  • The 20-minute subjects are 6 male and 7 female; the paper says 7 male and 6 female.
  • The sham recording is not in the dandiset.