Reproducing Asari & Zador (2009) from CRCNS ac-1¶

Paper. Asari H, Zador AM (2009). Long-lasting context dependence constrains neural encoding models in rodent auditory cortex. J Neurophysiol 102:2638-2656. doi:10.1152/jn.00577.2009

Dataset. CRCNS ac-1, Asari, Wehr, Machens & Zador (2009), "Auditory cortex and thalamic neuronal responses to various natural and synthetic sounds", doi:10.6080/K0KW5CXR. Streamed from the public S3 bucket crcnsarchive (ac-1/), zip files opened in place.

Version. CRCNS data sets are not versioned, so the version is recorded as unversioned (docs/archives.md, CRCNS). The paper cites no version. The files read and their MD5 sums from the data set's checksums.md5 (2026-11-14) are crcns-ac1.zip 2300ee76d93383ab8c808ddf16761a23, crcns-ac1-asari-results-1.zip 18537da81d98e311c0274f62aea04daa and crcns-ac1-asari-results-2.zip 2f7ab955cc778fc6839ce59ed51bce89; a later change of the files would change these sums. This is the only version the archive offers, and its contents match the claims file's description (39 natural-sound A1 cells, 14 MGB cells, the synthetic-sound cells).

Claims. claims/asari-2009.yaml, written from the version of record (text extraction of the publisher's PDF); the supplement was not read by the claims reader.

Code. The paper links no code. The data set ships the authors' analysis scripts (asari/Tools/CxtDep.m, "Basic analysis script for Asari and Zador (2008)", with ViewResp.m, GetEvoked.m, GetSpikes.m; wehr/Tools/STRFanalysis.m). They are followed here where the Methods leave a detail open; asari.py says which detail comes from where.

claim tested here
methods-recording-counts tested (voltage-clamp counts: no voltage-clamp recordings in the data set)
a1-mgb-firing-rates tested
fig2-example-reliability tested
fig2-example-long-context tested
fig3a-proportion-significant tested
fig3a-significance-decay tested
fig3b-fractional-power-decay tested
timescale-longer-than-membrane tested
fig4-predictability-upper-bound tested
fig4-strf-performance-low tested in strf_wehr.ipynb
fig5-example-conductances blocked: no voltage-clamp recordings
fig6-conductance-decay blocked: no voltage-clamp recordings
fig8a-proportion-by-property tested
fig8b-decay-by-property tested
fig8a-significance-fits tested
fig8c-relative-effects tested
fig8-natural-synthetic-probes-alike tested
fig9-mgb-fast-decay tested
fig9-example-first-bin tested
fig7-example-frequency-context blocked: no recording with the Figure 7 design
figs1-silence-probe tested
In [1]:
import time
import resource
import collections
import warnings

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

import asari

pd.set_option("display.width", 200)
pd.set_option("display.max_columns", 40)
pd.set_option("display.max_rows", 200)
warnings.filterwarnings("ignore", category=RuntimeWarning)
T0 = time.time()
A = asari.Archive()
rows = pd.DataFrame(asari.summary(A))
print("zip members:", len(A.members))
zip members: 2332

Loading¶

Every recording the analyses use is read once and reduced as it loads to the per-probe measures (significance at 0.1-ms resolution, stored as 1-ms means, and the power terms). Seeds: each file has its own generator for the shuffles of the noise floor (seed below), so that adding a file does not change the numbers of another.

In [2]:
SEED_NAT, SEED_NAT_NOSIL, SEED_SYN = 10_000, 20_000, 30_000
N_BOOT_TRIALS = 200   # trial resamples of the power measures (claim fig8c-relative-effects, trial reading)
nat_rows = rows[(rows.experiment == 0) & (rows.description != "tuning curve")].reset_index(drop=True)
mgb_rows = rows[(rows.experiment == 1) & (rows.description != "tuning curve")].reset_index(drop=True)
syn_rows = rows[(rows.experiment == 2) & (rows.description != "tuning curve")].reset_index(drop=True)
import os
if os.environ.get("ASARI_DEV_SUBSET"):   # development only: a few files of each group
    k = int(os.environ["ASARI_DEV_SUBSET"])
    nat_rows, mgb_rows, syn_rows = nat_rows.iloc[15:15 + k], mgb_rows.iloc[:k], syn_rows.iloc[::max(1, len(syn_rows) // k)]

t = time.time()
nat_cells, nat_probes = [], []
for i, r in nat_rows.iterrows():
    c, res = asari.analyze_cc_cell(A, A.result_member(r.file), seed=SEED_NAT + i, silence_probe=True,
                                   n_boot=N_BOOT_TRIALS)
    c.update(cell=r.cell, description=r.description)
    nat_cells.append(c)
    for x in res:
        x["cell"] = r.cell
    nat_probes += res
print(f"A1 natural sounds: {len(nat_rows)} files in {time.time() - t:.0f} s")

# reading without "silence" among the contexts (claims fig3a-proportion-significant, fig3b, fig4)
t = time.time()
nat_probes_nosil = []
for i, r in nat_rows.iterrows():
    c, res = asari.analyze_cc_cell(A, A.result_member(r.file), seed=SEED_NAT_NOSIL + i,
                                   include_silence=False, extras=False)
    for x in res:
        x["cell"] = r.cell
    nat_probes_nosil += res
print(f"A1 natural sounds, silence left out: {time.time() - t:.0f} s")

t = time.time()
mgb = {}
for det in ["getspikes", "mad:5", "mad:8"]:
    infos, probes = [], []
    for i, r in mgb_rows.iterrows():
        info, out = asari.analyze_mgb_file(A, A.result_member(r.file), det)
        info["cell"] = r.cell
        infos.append(info)
        for x in out:
            x["cell"] = r.cell
        probes += out
    mgb[det] = (infos, probes)
print(f"MGB: {len(mgb_rows)} files x 3 spike detectors in {time.time() - t:.0f} s")

t = time.time()
syn_infos, syn_entries = [], []
for i, r in syn_rows.iterrows():
    info, out = asari.analyze_synthetic_file(A, A.result_member(r.file), seed=SEED_SYN + i, n_boot=N_BOOT_TRIALS)
    info.update(cell=r.cell, description=r.description)
    syn_infos.append(info)
    for x in out:
        x["cell"] = r.cell
    syn_entries += out
print(f"A1 synthetic sounds: {len(syn_rows)} files in {time.time() - t:.0f} s")
print(f"peak memory {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1e6:.1f} GB; "
      f"elapsed {(time.time() - T0) / 60:.1f} min")
A1 natural sounds: 46 files in 545 s
A1 natural sounds, silence left out: 380 s
MGB: 21 files x 3 spike detectors in 189 s
A1 synthetic sounds: 105 files in 844 s
peak memory 2.5 GB; elapsed 32.7 min

Data check¶

In [3]:
print("Summary.mat experiments (cells, files other than tuning curves):")
for e, g in rows.groupby("experiment"):
    print(f"  {e}: {g.experiment_description.iloc[0]!r} | reference {g.reference.iloc[0][:40]!r}: "
          f"{g.cell.nunique()} cells, {(g.description != 'tuning curve').sum()} files")
listed = set(rows.file.str.replace("Results/", "", regex=False))
in_zip = {m.split("/", 1)[1] for m in A.members if m.startswith("asari-results-") and m.endswith(".mat")}
print("files listed in Summary.mat but not in the zip files:", sorted(listed - in_zip))
print("files in the zip files not listed in Summary.mat:", sorted(in_zip - listed))
others = rows[(rows.experiment == 3) | (rows.description == "tuning curve")]
rt = others.assign(type=[asari.recording_type(A, A.result_member(f)) for f in others.file])
print("recording types and trace units of the files not analysed (experiment 3 and tuning curves):")
print(rt.groupby(["experiment", rt.description == "tuning curve", "type"]).size().rename("files").to_string())
Summary.mat experiments (cells, files other than tuning curves):
  0: 'Auditory cortical cell responses to natural sound combinations.' | reference 'Asari and Zador (submitted) Long-lasting': 39 cells, 46 files
  1: 'Thalamic cell responses to natural sound combinations.' | reference 'Asari and Zador (submitted) Long-lasting': 14 cells, 21 files
  2: 'Auditory cortical cell responses to synthetic sound combinations.' | reference 'Asari and Zador (submitted) Long-lasting': 96 cells, 105 files
  3: 'Auditory cortical cell responses to various acoustic stimuli.' | reference 'Unpublished': 12 cells, 15 files
files listed in Summary.mat but not in the zip files: []
files in the zip files not listed in Summary.mat: []
recording types and trace units of the files not analysed (experiment 3 and tuning curves):
experiment  description  type             
0           True         Whole-cell, mV       39
1           True         Cell-attached, mV    14
2           True         Whole-cell, mV       96
3           False        Whole-cell, mV       15
            True         Whole-cell, mV       12
In [4]:
def recinfo(infos, kind):
    df = pd.DataFrame([{"kind": kind, "cell": i["cell"], "type": i["recording_type"],
                        "sf": i["checks"]["sf"], "rep": i["rep"],
                        "pres_min": i["checks"]["presentations_min"], "pres_max": i["checks"]["presentations_max"],
                        "dur_mismatch_ms": i["checks"]["duration_mismatch_ms"],
                        "gap_min_s": i["checks"]["gap_min"], "gap_median_s": i["checks"]["gap_median"],
                        "gap_max_s": i["checks"]["gap_max"],
                        "onset_effect": i["checks"]["onset_effect"][0], "onset_p": i["checks"]["onset_effect"][1],
                        "shifted_effect": i["checks"]["shifted_effect"][0], "shifted_p": i["checks"]["shifted_effect"][1]}
                       for i in infos])
    return df

chk = pd.concat([recinfo(nat_cells, "A1 natural"), recinfo(mgb["getspikes"][0], "MGB"),
                 recinfo(syn_infos, "A1 synthetic")])
print("recording types by group:")
print(chk.groupby(["kind", "type"]).size().to_string())
print("\nsampling rates:", sorted(chk.sf.unique()))
print("\nby group: files, effective repeats (range), presentations per sequence (range), largest mismatch"
      " between the sum of fragment durations and the trigger duration (ms), gaps between sequences (s)")
print(chk.groupby("kind").agg(files=("cell", "size"), cells=("cell", "nunique"), rep_min=("rep", "min"),
                              rep_max=("rep", "max"), pres_min=("pres_min", "min"), pres_max=("pres_max", "max"),
                              mismatch_max=("dur_mismatch_ms", "max"), gap_min=("gap_min_s", "min"),
                              gap_median=("gap_median_s", "median"), gap_max=("gap_max_s", "max")).round(3).to_string())
print("\nfiles with fewer presentations of a sequence than the stated effective repeats:",
      int((chk.pres_min < chk.rep).sum()), "of", len(chk))
print(chk[chk.pres_min < chk.rep][["kind", "cell", "rep", "pres_min", "pres_max"]].to_string())
mis = pd.DataFrame([{"kind": k, "file": i["member"].split("/")[-1], "stored_mismatch_ms": i["checks"]["stored_mismatch_ms"],
                     "fragment list taken from": i["checks"]["stimulus_source"].split("/")[-1],
                     "mismatch_after_ms": i["checks"]["duration_mismatch_ms"]}
                    for k, infos in [("A1 natural", nat_cells), ("MGB", mgb["getspikes"][0]), ("A1 synthetic", syn_infos)]
                    for i in infos if i["checks"]["stored_mismatch_ms"] > asari.MAX_MISMATCH_MS])
print("\nfiles whose stored fragment durations do not add up to the trigger durations (> 5 ms):")
print(mis.round(1).to_string())
recording types by group:
kind          type         
A1 natural    Whole-cell        46
A1 synthetic  Whole-cell       105
MGB           Cell-attached     21

sampling rates: [np.int64(10000)]

by group: files, effective repeats (range), presentations per sequence (range), largest mismatch between the sum of fragment durations and the trigger duration (ms), gaps between sequences (s)
              files  cells  rep_min  rep_max  pres_min  pres_max  mismatch_max  gap_min  gap_median  gap_max
kind                                                                                                        
A1 natural       46     39        4       12         4        12         0.478    1.916       6.487   47.424
A1 synthetic    105     96        4        9         3         9       308.000    2.627       5.754   16.819
MGB              21     14       10       25        10        25         0.166    4.424       4.762    7.283

files with fewer presentations of a sequence than the stated effective repeats: 1 of 172
            kind              cell  rep  pres_min  pres_max
88  A1 synthetic  20061231-ha2-001    4         3         4

files whose stored fragment durations do not add up to the trigger durations (> 5 ms):
           kind                      file  stored_mismatch_ms                                                   fragment list taken from  mismatch_after_ms
0    A1 natural  20051108-ha1-001-002.mat              1796.8                                                   20051108-ha1-001-003.mat                0.2
1    A1 natural  20051108-ha1-001-003.mat              1797.2                                                   20051108-ha1-001-002.mat                0.2
2           MGB  20071010-ha2-005-002.mat              2295.2                                                   20071010-ha2-005-003.mat                0.2
3           MGB  20071010-ha2-005-003.mat              2294.9                                                   20071010-ha2-005-002.mat                0.2
4  A1 synthetic  20061201-ha2-001-002.mat               308.0  20061201-ha2-001-002.mat (stored list kept; it does not fit the triggers)              308.0
In [5]:
# Clock check: response in the 0.3 s after each sequence onset minus the 0.3 s before it, against
# the same contrast with the onsets moved 3 s back into the silence (membrane potential in mV for
# A1, spike rate in Hz for MGB). Wilcoxon signed-rank over sequences, per file.
g = chk.groupby("kind")
print(pd.DataFrame({
    "files": g.size(),
    "onset effect median": g.onset_effect.median(),
    "files p<0.01 at onset": g.onset_p.apply(lambda p: int((p < 0.01).sum())),
    "shifted effect median": g.shifted_effect.median(),
    "files p<0.01 shifted": g.shifted_p.apply(lambda p: int((p < 0.01).sum())),
}).round(3).to_string())
print("\nfiles without an onset effect at p<0.01:")
print(chk[chk.onset_p >= 0.01][["kind", "cell", "onset_effect", "onset_p"]].round(4).to_string())
              files  onset effect median  files p<0.01 at onset  shifted effect median  files p<0.01 shifted
kind                                                                                                        
A1 natural       46                3.660                     36                  0.027                     1
A1 synthetic    105                4.338                     83                 -0.122                     3
MGB              21                2.236                     18                  0.000                     2

files without an onset effect at p<0.01:
             kind              cell  onset_effect  onset_p
0      A1 natural  20051101-ha1-005       -0.4315   0.3012
2      A1 natural  20051107-ha1-001        1.5272   0.0266
6      A1 natural  20051114-ha2-001        0.3645   0.1909
7      A1 natural  20051125-ha1-001        1.9222   0.0384
8      A1 natural  20051126-ha2-001        0.4045   0.3766
15     A1 natural  20051127-ha1-002        2.0234   0.0274
18     A1 natural  20051207-ha2-001        1.4403   0.0130
35     A1 natural  20060226-ha2-002        2.5184   0.0319
36     A1 natural  20060228-ha1-001        0.8315   0.2485
37     A1 natural  20060301-ha2-001        1.2079   0.0216
5             MGB  20071009-ha1-004        0.2008   0.0253
15            MGB  20071011-ha1-002        0.4762   0.0778
17            MGB  20071012-ha1-002       -1.3553   0.0523
6    A1 synthetic  20061125-ha1-001        1.9810   0.0168
10   A1 synthetic  20061201-ha2-001        2.2407   0.0291
18   A1 synthetic  20060313-ha1-001       -0.0459   0.7983
19   A1 synthetic  20060313-ha1-002        1.5807   0.0546
20   A1 synthetic  20060313-ha1-003        1.7315   0.0101
28   A1 synthetic  20060316-ha1-001        3.2545   0.0354
31   A1 synthetic  20060320-ha3-003        0.0540   0.9643
34   A1 synthetic  20060321-ha1-002        1.0150   0.1876
39   A1 synthetic  20060909-ha1-001        3.4472   0.0222
40   A1 synthetic  20060909-ha2-001        1.0921   0.3369
48   A1 synthetic  20060916-ha3-001        2.0099   0.0216
49   A1 synthetic  20060916-ha3-002        0.1298   0.8932
57   A1 synthetic  20060929-ha2-001        2.4377   0.0161
63   A1 synthetic  20060930-ha2-003        2.6924   0.0140
64   A1 synthetic  20060930-ha6-001        1.3668   0.1272
67   A1 synthetic  20060930-ha8-004        1.9867   0.0435
86   A1 synthetic  20061231-ha1-002        2.3916   0.0300
88   A1 synthetic  20061231-ha2-001        1.7991   0.0268
89   A1 synthetic  20061231-ha2-002        3.3158   0.0127
90   A1 synthetic  20070101-ha1-002        2.8144   0.0157
99   A1 synthetic  20061223-ha3-002        1.7179   0.0484
100  A1 synthetic  20061226-ha1-001        3.1343   0.0215
In [6]:
tr = pd.DataFrame([{"kind": "A1 natural", "min": c["trace_min"], "max": c["trace_max"], "unit": c["unit"]} for c in nat_cells]
                  + [{"kind": "MGB", "min": i["trace_min"], "max": i["trace_max"], "unit": i["unit"]} for i in mgb["getspikes"][0]])
print("trace ranges after the 10-ms median filter (A1) or raw (MGB):")
print(tr.groupby(["kind", "unit"]).agg(min_lo=("min", "min"), min_hi=("min", "max"), max_lo=("max", "min"),
                                       max_hi=("max", "max")).round(1).to_string())
el_nat = [p for p in nat_probes if p["eligible"]]
print("\nA1 natural probes: durations (s)", np.round(np.percentile([p["duration"] for p in el_nat], [0, 50, 100]), 2),
      "| contexts per probe", dict(collections.Counter(p["n_contexts"] for p in el_nat)),
      "| trials per context", dict(sorted(collections.Counter(p["rep"] for p in el_nat).items())))
trace ranges after the 10-ms median filter (A1) or raw (MGB):
                 min_lo  min_hi  max_lo  max_hi
kind       unit                                
A1 natural mV     -85.0   -54.5   -44.4    29.3
MGB        mV     -21.8    -4.8     0.6    80.6

A1 natural probes: durations (s) [1.98 5.27 6.06] | contexts per probe {5: 53, 7: 54, 11: 25, 8: 48, 3: 114, 10: 9, 19: 2} | trials per context {4: 113, 5: 44, 6: 59, 7: 58, 8: 16, 9: 7, 10: 4, 12: 4}
In [7]:
# The authors' CxtDep.m: how ranks are formed in the Kruskal-Wallis test (no tie correction; MATLAB's
# sort is stable, so tied values are ranked in trial order, as asari.kw_significance does) and the PSTH.
src = A.read("asari/Tools/CxtDep.m").decode("latin-1").splitlines()
for a, b in [(284, 306), (365, 381)]:
    print("\n".join(f"{k + 1:4d} {src[k]}" for k in range(a - 1, b)))
    print("...")
sc = pd.DataFrame([{"kind": k, "scale_mV": i["scale"]} for k, infos in
                   [("A1 natural", nat_cells), ("MGB", mgb["getspikes"][0]), ("A1 synthetic", syn_infos)] for i in infos])
print("\nint16 scale (mV per step) by group:", sc.groupby("kind").scale_mV.agg(["min", "median", "max"]).round(5).to_dict("index"))
sd = np.array([float(np.sqrt(np.nanmean(p["total"]))) for p in nat_probes if p["eligible"]])
step = np.median(sc[sc.kind == "A1 natural"].scale_mV)
print(f"RMS of the centred trials over the probe window, natural-sound probes: median {np.median(sd):.2f} mV, "
      f"5th percentile {np.percentile(sd, 5):.2f} mV, i.e. {np.percentile(sd, 5) / step:.0f} or more int16 steps per SD in 95% of probes")
 284 function [kw,p,signif,noise,alpha,dt,nn] = KWtest(PARAM)
 285 
 286 if isfield(PARAM,'alpha') && ~isempty(PARAM.alpha), alpha = PARAM.alpha;
 287 else                                                alpha = 0.01;
 288 end
 289 if isfield(PARAM,'alpha_dt') && ~isempty(PARAM.alpha_dt), dt = PARAM.alpha_dt;
 290 else                                                      dt = 5; % msec
 291 end
 292 dt = dt*PARAM.sf/1000;
 293 if isfield(PARAM,'bootstrap') && ~isempty(PARAM.bootstrap), nn = ceil(abs(PARAM.bootstrap));
 294 else                                                        nn = 1000;
 295 end
 296 
 297 [resp,rep] = GetResp(PARAM);
 298 
 299 M = length(resp); % number of groups
 300 [resp,r] = sort(cell2mat(resp)); [resp,r] = sort(r); % rank
 301 N = size(r,1); % total sample number
 302 rbar = reshape(mean(reshape(r,rep,[])),M,[]); % mean rank
 303 
 304 kw = 12*sum((rbar - (N+1)/2).^2)/(M*(N+1)); % kruskal-wallis statistic
 305 p = 1 - chi2cdf(kw,M-1); % KW statistic ~ Chi-square distribution
 306 
...
 365 function [dt,psth,stdev] = psth(PARAM)
 366 
 367 if isfield(PARAM,'dt') && ~isempty(PARAM.dt), dt = PARAM.dt;
 368 else                                          dt = 0.1; % bin size in second
 369 end
 370 
 371 [i,j]=unique(PARAM.context); 
 372 rep = diff([0,j])*size(PARAM.resp{1},2); spk = {};
 373 for i=1:length(PARAM.context), spk = [spk,PARAM.resp{2,i}];end
 374 spk = mat2cell(spk,1,rep); rep = min(rep); n = length(spk);
 375 t = 0:dt:PARAM.Tend; psth = zeros(length(t),n);
 376 for i=1:n,
 377     spk{i} = cell2mat(reshape(spk{i}(1:rep),[],1));
 378     spk{i} = spk{i}(spk{i}>0 & spk{i}<=PARAM.Tend);
 379     if ~isempty(spk{i}), psth(:,i) = histc(spk{i},t)/rep/dt;end % PSTH (bin size: dt)
 380 end
 381 stdev = std(psth,[],2); % standard deviation of PSTHs across contexts
...

int16 scale (mV per step) by group: {'A1 natural': {'min': 0.0061, 'median': 0.01526, 'max': 0.01526}, 'A1 synthetic': {'min': 0.0061, 'median': 0.01526, 'max': 0.01526}, 'MGB': {'min': 0.00153, 'median': 0.00305, 'max': 0.00305}}
RMS of the centred trials over the probe window, natural-sound probes: median 5.10 mV, 5th percentile 3.52 mV, i.e. 231 or more int16 steps per SD in 95% of probes

Checks of the description against the data are stated with the numbers above: all A1 recordings are whole-cell (current clamp) and all MGB recordings cell-attached, at 10 kHz, in mV. No recording in the data set is a voltage-clamp recording. The fragment durations stored with each recording add up to the trigger duration of each sequence to within a fraction of a millisecond, except in the files listed: in two cells (one A1, one MGB) the fragment lists of a cell's two files are swapped, the stored durations of each file fitting the triggers of the other exactly, and here each file's probes are cut with the list that fits its triggers; in one synthetic recording the triggers are 308 ms longer than the seven stored fragment durations (4200 ms each) in every sequence; no other file fits, and the stored durations are used, as the authors' CxtDep.m would use them. The gaps between sequences are about 6 s for the natural-sound recordings, as the Methods say, and shorter in others (minimum and median above). Every sequence onset evokes a response in nearly every file while the same contrast moved into the silence does not, which is consistent with the triggers sharing the clock of the traces; files without an onset effect are listed.

methods-recording-counts¶

Of 194 A1 cells recorded in current clamp, 123 met the analysis criterion (39 tested with natural sounds, 14 with TORCs, 6 with DMRs, 39 with modulated harmonic tones, 27 with modulated colored noise); 14 of 42 voltage-clamped cells and 14 of 16 MGB cells were analysed.

In [8]:
def counts_cc(probes):
    el = [p for p in probes if p["eligible"]]
    return len(el), len({p["cell"] for p in el})

n_p, n_c = counts_cc(nat_probes)
n_p2, n_c2 = counts_cc(nat_probes_nosil)
print(f"A1 natural-sound probes (silence counted as a context): {n_p} probes in {n_c} cells "
      f"(of {len(nat_probes)} probes with at least two contexts)")
print(f"A1 natural-sound probes (silence not counted):          {n_p2} probes in {n_c2} cells")
mgb_el = [p for p in mgb["getspikes"][1] if p["eligible"]]
print(f"MGB probes (at least 10 trials per context): {len(mgb_el)} probes in {len({p['cell'] for p in mgb_el})} cells "
      f"(Summary.mat lists {mgb_rows.cell.nunique()} MGB cells)")
syn_cells_any = {i["cell"] for i in syn_infos if i["n_eligible_any"] > 0}
syn_cells_prop = {e["cell"] for e in syn_entries if e["eligible"]}
nat_cells_set = {p["cell"] for p in nat_probes if p["eligible"]}
print(f"A1 synthetic-sound cells with an eligible probe (any contexts): {len(syn_cells_any)}; "
      f"with an eligible probe x property ensemble: {len(syn_cells_prop)} (Summary.mat lists {syn_rows.cell.nunique()})")
print(f"A1 current-clamp cells meeting the criterion, natural + synthetic: {len(nat_cells_set | syn_cells_any)} "
      f"(any contexts) or {len(nat_cells_set | syn_cells_prop)} (property ensembles); overlap {len(nat_cells_set & syn_cells_any)}")
fam = {i["member"]: i["trigger_type"] for i in syn_infos}
fam_cells = collections.defaultdict(set)
for e in syn_entries:
    if e["eligible"]:
        fam_cells[fam[e["member"]]].add(e["cell"])
print("synthetic cells by stimulus family (cells with an eligible ensemble):",
      {k: len(v) for k, v in sorted(fam_cells.items())}, "| paper: TORC 14, DMR 6, MHT ('synthetic') 39, MCN ('pinknoise') 27")
print("recording types in the whole data set:", dict(chk.groupby("type").size()), "| voltage-clamp recordings: 0")
cell_fam = collections.defaultdict(set)
for c in nat_cells_set:
    cell_fam[c].add("natural")
for i_ in syn_infos:
    if i_["n_eligible_any"] > 0:
        cell_fam[i_["cell"]].add(i_["trigger_type"])
fam_tab = pd.Series({c: "+".join(sorted(v)) for c, v in cell_fam.items()}).sort_index()
print("\nA1 cells meeting the criterion, by the stimulus families of their recordings:", dict(fam_tab.value_counts()))
for f, g in fam_tab.groupby(fam_tab):
    print(f"  {f} ({len(g)}):", ", ".join(g.index))
dropped = sorted(set(syn_rows.cell) - {i_["cell"] for i_ in syn_infos if i_["n_eligible_any"] > 0})
print("synthetic-sound cells without an eligible probe:", dropped)
A1 natural-sound probes (silence counted as a context): 305 probes in 39 cells (of 305 probes with at least two contexts)
A1 natural-sound probes (silence not counted):          305 probes in 39 cells
MGB probes (at least 10 trials per context): 93 probes in 14 cells (Summary.mat lists 14 MGB cells)
A1 synthetic-sound cells with an eligible probe (any contexts): 95; with an eligible probe x property ensemble: 95 (Summary.mat lists 96)
A1 current-clamp cells meeting the criterion, natural + synthetic: 132 (any contexts) or 132 (property ensembles); overlap 2
synthetic cells by stimulus family (cells with an eligible ensemble): {'dmr': 15, 'naturalistic': 14, 'pinknoise': 26, 'synthetic': 26, 'torc': 14} | paper: TORC 14, DMR 6, MHT ('synthetic') 39, MCN ('pinknoise') 27
recording types in the whole data set: {'Cell-attached': np.int64(21), 'Whole-cell': np.int64(151)} | voltage-clamp recordings: 0

A1 cells meeting the criterion, by the stimulus families of their recordings: {'natural': np.int64(37), 'synthetic': np.int64(26), 'pinknoise': np.int64(26), 'dmr': np.int64(14), 'naturalistic': np.int64(14), 'torc': np.int64(13), 'natural+torc': np.int64(1), 'dmr+natural': np.int64(1)}
  dmr (14): 20060320-ha1-001, 20060320-ha3-001, 20060321-ha1-001, 20060321-ha1-002, 20060321-ha2-002, 20060915-ha1-001, 20060916-ha1-001, 20060916-ha2-001, 20060916-ha3-001, 20060916-ha3-002, 20060916-ha3-003, 20060916-ha4-001, 20060916-ha5-002, 20060917-ha1-002
  dmr+natural (1): 20060320-ha3-003
  natural (37): 20051101-ha1-005, 20051107-ha1-001, 20051107-ha1-002, 20051108-ha1-001, 20051114-ha2-001, 20051125-ha1-001, 20051126-ha2-001, 20051126-ha2-002, 20051126-ha2-003, 20051127-ha1-001, 20051127-ha1-002, 20051203-ha1-001, 20051207-ha1-002, 20051207-ha2-001, 20051213-ha1-001, 20051215-ha1-001, 20051222-ha1-001, 20051224-ha2-001, 20051225-ha3-001, 20051226-ha1-001, 20051226-ha1-002, 20051226-ha2-001, 20051227-ha1-001, 20051228-ha1-001, 20060105-ha1-001, 20060220-ha1-005, 20060225-ha1-001, 20060225-ha2-001, 20060226-ha2-002, 20060228-ha1-001, 20060301-ha2-001, 20060329-ha1-001, 20060402-ha1-001, 20060430-ha1-001, 20061006-ha1-001, 20061007-ha2-001, 20061007-ha4-001
  natural+torc (1): 20060314-ha1-001
  naturalistic (14): 20060904-ha1-001, 20060906-ha1-001, 20060908-ha1-001, 20060909-ha1-001, 20060909-ha2-001, 20060909-ha4-001, 20060909-ha4-002, 20060910-ha1-001, 20060910-ha1-002, 20061125-ha1-001, 20061125-ha2-003, 20061126-ha1-002, 20061126-ha1-003, 20061201-ha2-001
  pinknoise (26): 20061217-ha1-001, 20061217-ha2-001, 20061217-ha3-002, 20061218-ha1-001, 20061218-ha1-002, 20061219-ha1-002, 20061219-ha3-001, 20061219-ha3-002, 20061223-ha3-002, 20061226-ha1-001, 20061226-ha1-002, 20061226-ha2-001, 20061227-ha1-001, 20061227-ha1-003, 20061229-ha1-001, 20061229-ha2-004, 20061231-ha1-002, 20061231-ha1-003, 20061231-ha2-002, 20070101-ha1-002, 20070101-ha2-001, 20070101-ha2-002, 20070101-ha2-003, 20070105-ha1-001, 20070105-ha1-002, 20070105-ha1-003
  synthetic (26): 20060929-ha1-001, 20060929-ha1-002, 20060929-ha2-001, 20060929-ha3-001, 20060929-ha4-001, 20060929-ha4-002, 20060929-ha5-001, 20060930-ha1-001, 20060930-ha2-003, 20060930-ha6-001, 20060930-ha7-003, 20060930-ha8-001, 20060930-ha8-004, 20061006-ha2-001, 20061006-ha3-001, 20061006-ha4-001, 20061006-ha5-001, 20061007-ha4-002, 20061008-ha1-001, 20061008-ha2-001, 20061008-ha4-001, 20061022-ha4-001, 20061022-ha6-001, 20061022-ha6-002, 20061022-ha7-001, 20061022-ha7-003
  torc (13): 20060202-ha2-001, 20060202-ha2-002, 20060202-ha3-004, 20060212-ha1-001, 20060212-ha2-001, 20060216-ha2-002, 20060313-ha1-001, 20060313-ha1-002, 20060313-ha1-003, 20060315-ha1-001, 20060315-ha1-002, 20060315-ha2-001, 20060316-ha1-001
synthetic-sound cells without an eligible probe: ['20061231-ha2-001']

Result: partially reproduced. The natural-sound A1 counts match exactly: 305 probes in 39 cells, under both readings of silence. The MGB counts match exactly: 93 probes in 14 cells. The A1 current-clamp total is 132 cells (39 natural, 95 synthetic, 2 in both) against 123; one synthetic-sound cell (20061231-ha2-001) has no eligible probe. By the families of their recordings the 132 cells are 37 natural only, 26 MHT, 26 MCN, 14 DMR, 14 natural-sound variants, 13 TORC, one natural and TORC and one natural and DMR, listed above; TORC (14 with the shared cell) matches the paper, and the other families do not map onto the paper's (DMR 6, MHT 39, MCN 27), so which 9 cells make the difference cannot be said. The voltage-clamp counts (29 probes, 14 cells) cannot be tested: the data set holds no voltage-clamp recording.

a1-mgb-firing-rates¶

Firing rates were low in A1 (spontaneous 0.47 +/- 0.61 Hz, evoked 0.57 +/- 0.77 Hz, mean +/- SD, 194 cells) and high in MGB (spontaneous 0.78 +/- 1.25 Hz, evoked 11.4 +/- 16.9 Hz, 16 cells).

Readings of the windows (criterion): spontaneous is the whole intersequence silence (spont) or the last 1 s before each sequence (pre1s); evoked is all sound periods (the analysed probes cover all fragments of the natural-sound sequences, so the two evoked readings coincide). MGB spikes: the authors' automatic detector (GetSpikes.m) is the main detector; robust thresholds of 5 and 8 SD on the same filter are variants. A1 spikes: upward crossings of -20 mV on the raw membrane potential (assumption; -10 and -30 mV shown). Rates are per cell, pooling a cell's files, then averaged over cells.

In [9]:
def cell_rates(infos, key=None):
    agg = {}
    for i in infos:
        r = i["rates"][key] if key is not None else i["rates"]
        a = agg.setdefault(i["cell"], dict(sp=0.0, sp_t=0.0, ev=0.0, ev_t=0.0, pre=[]))
        a["sp"] += r["spont"] * r["spont_s"]; a["sp_t"] += r["spont_s"]
        a["ev"] += r["evoked"] * r["evoked_s"]; a["ev_t"] += r["evoked_s"]
        a["pre"].append(r["pre1s"])
    return pd.DataFrame([{"cell": c, "spont": a["sp"] / a["sp_t"], "evoked": a["ev"] / a["ev_t"],
                          "pre1s": np.nanmean(a["pre"])} for c, a in agg.items()])

rate_rows = []
a1_infos = nat_cells + syn_infos
for thr in asari.A1_THRESHOLDS:
    d = cell_rates(a1_infos, thr)
    for w in ["spont", "pre1s", "evoked"]:
        rate_rows.append(dict(area="A1", detector=f"Vm {thr:+.0f} mV", window=w, cells=len(d),
                              mean=d[w].mean(), sd=d[w].std(ddof=1)))
for det, (infos, _) in mgb.items():
    d = cell_rates(infos)
    for w in ["spont", "pre1s", "evoked"]:
        rate_rows.append(dict(area="MGB", detector=det, window=w, cells=len(d), mean=d[w].mean(), sd=d[w].std(ddof=1)))
rates = pd.DataFrame(rate_rows)
exp = {("A1", "spont"): 0.47, ("A1", "pre1s"): 0.47, ("A1", "evoked"): 0.57,
       ("MGB", "spont"): 0.78, ("MGB", "pre1s"): 0.78, ("MGB", "evoked"): 11.4}
rates["paper"] = [exp[(a, w)] for a, w in zip(rates.area, rates.window)]
rates["within_10pct"] = (rates["mean"] - rates.paper).abs() <= 0.1 * rates.paper
print(rates.round(3).to_string())
   area   detector  window  cells    mean      sd  paper  within_10pct
0    A1  Vm -20 mV   spont    133   0.392   0.614   0.47         False
1    A1  Vm -20 mV   pre1s    133   0.415   0.780   0.47         False
2    A1  Vm -20 mV  evoked    133   0.439   0.689   0.57         False
3    A1  Vm -10 mV   spont    133   0.228   0.469   0.47         False
4    A1  Vm -10 mV   pre1s    133   0.234   0.597   0.47         False
5    A1  Vm -10 mV  evoked    133   0.248   0.505   0.57         False
6    A1  Vm -30 mV   spont    133   0.601   0.985   0.47         False
7    A1  Vm -30 mV   pre1s    133   0.640   1.219   0.47         False
8    A1  Vm -30 mV  evoked    133   0.669   1.013   0.57         False
9   MGB  getspikes   spont     14   0.549   1.236   0.78         False
10  MGB  getspikes   pre1s     14   0.709   1.199   0.78          True
11  MGB  getspikes  evoked     14   4.992  11.452  11.40         False
12  MGB      mad:5   spont     14   1.663   3.565   0.78         False
13  MGB      mad:5   pre1s     14   1.979   3.437   0.78         False
14  MGB      mad:5  evoked     14  13.571  13.681  11.40         False
15  MGB      mad:8   spont     14   0.975   1.534   0.78         False
16  MGB      mad:8   pre1s     14   1.248   1.533   0.78         False
17  MGB      mad:8  evoked     14  10.376  13.204  11.40          True

Result: partially reproduced (resting on the choice of spike detector). No reading has all four means within 10%. The A1 means are below 1 Hz with every threshold (0.392 Hz spontaneous and 0.439 Hz evoked at -20 mV over 133 cells; paper 0.47 and 0.57). The MGB evoked mean is above 5 Hz with the robust 5-SD (13.57 Hz) and 8-SD (10.38 Hz, within tolerance) detectors, so the partial rule holds under those readings; with the authors' automatic detector it is 4.99 Hz, just under 5 Hz, and the MGB spontaneous mean is 0.549 Hz (0.709 Hz in the last second before each sequence, within tolerance).

fig2-example-reliability¶

The example A1 neuron of Figure 2 had high trial-to-trial reliability (correlation across trials 0.74 +/- 0.08 for the shown probe and 0.61 +/- 0.07 over the seven natural sound fragments tested), and the mean correlation over the population was 0.31 +/- 0.09.

Readings (criterion): the coefficient as the mean over pairs of trials (pairs) or each trial against the mean of the others (loo), within each context over the probe window, averaged over contexts; the population mean over cells or over probes.

In [10]:
cp = pd.DataFrame([{"cell": p["cell"], "member": p["member"], "probe": p["probe"], "pairs": p["corr"]["pairs"],
                    "loo": p["corr"]["loo"]} for p in el_nat])
per_cell = cp.groupby("cell")[["pairs", "loo"]].mean()
print("population, over cells (n = %d):" % len(per_cell))
print(per_cell.agg(["mean", "std"]).round(3).to_string())
print("population, over probes (n = %d):" % len(cp))
print(cp[["pairs", "loo"]].agg(["mean", "std"]).round(3).to_string())
# candidate example cells: seven natural fragments, six repeats (Figure 2A)
cand = [c for c in nat_cells if c["n_fragments"] == 7 and c["rep"] == 6]
rowsx = []
for c in cand:
    sub = cp[cp.member == c["member"]]
    rowsx.append(dict(cell=c["cell"], probes=len(sub), cell_pairs_mean=sub.pairs.mean(), cell_pairs_sd=sub.pairs.std(ddof=1),
                      cell_loo_mean=sub.loo.mean(), best_probe_pairs=sub.pairs.max(),
                      best_probe=int(sub.probe[sub.pairs.idxmax()])))
print("\ncandidate example cells (7 fragments, 6 repeats):")
print(pd.DataFrame(rowsx).round(3).to_string())
population, over cells (n = 39):
      pairs    loo
mean  0.310  0.437
std   0.092  0.098
population, over probes (n = 305):
      pairs    loo
mean  0.319  0.448
std   0.129  0.139

candidate example cells (7 fragments, 6 repeats):
               cell  probes  cell_pairs_mean  cell_pairs_sd  cell_loo_mean  best_probe_pairs  best_probe
0  20051222-ha1-001       7            0.611          0.081          0.732             0.737           4
1  20051226-ha1-001       7            0.244          0.080          0.382             0.320           4
2  20051226-ha1-002       7            0.300          0.146          0.437             0.538           7
3  20060105-ha1-001       7            0.309          0.107          0.455             0.447           4
4  20061007-ha2-001       7            0.294          0.070          0.440             0.371           7

Result: reproduced. The mean pairwise trial-to-trial correlation over the 39 cells is 0.310 +/- 0.092 (paper 0.31 +/- 0.09); over the 305 probes it is 0.319. One candidate example cell (20051222-ha1-001, seven fragments, six repeats) has a mean of 0.611 +/- 0.081 over its probes (paper 0.61 +/- 0.07) and 0.737 for probe 4 (paper 0.74), the probe heard after silence and two other fragments. The leave-one-out reading gives higher values (0.437 over cells).

fig2-example-long-context¶

In an example A1 neuron, changing the conditioning stimulus changed the response to the probe for about 4 s; responses did not differ between 2 and 4 s after probe onset and diverged again after about 4 s.

The criterion, as amended after a reader's answer (questions/asari-2009.yaml), identifies the example by the Figure 2A legend and the Results: a current-clamp cell tested with seven natural sound fragments, with trial-to-trial correlation 0.61 +/- 0.07 over them, and a probe of that cell with reliability 0.74 +/- 0.08, heard after silence and two other fragments, with six repeats. The probe of the cell that matches these values within 10% is tested (the closest to both if several match). Reproduced when it has significant periods before 2 s, none between 2.2 and 3.6 s, and one starting after 3.6 s.

Readings: the matched values are the two mean correlations (the criterion's "closest to both"), in the pairwise reading of fig2-example-reliability; as variants, the leave-one-out reading and a match that also asks the SDs (0.07 over the cell's fragments, 0.08 over the probe's pairs of trials) to fall within 10%. The strict windows of the earlier criterion (none between 2 and 4 s, one after 4 s) are shown for reference.

In [11]:
def pattern(runs):
    return dict(before_2s=any(a < 2 for a, b in runs), in_2_2_3_6s=any(b > 2.2 and a < 3.6 for a, b in runs),
                starts_after_3_6s=any(a > 3.6 for a, b in runs),
                in_2_4s_strict=any(b > 2 and a < 4 for a, b in runs), after_4s_strict=any(b > 4 for a, b in runs))

def within(x, ref, tol=0.1):
    return abs(x - ref) <= tol * ref

# candidates: probes of 7-fragment cells heard after silence (context 0) and two other fragments
rows2 = []
for c in [c for c in nat_cells if c["n_fragments"] == 7]:
    sub = cp[cp.member == c["member"]]
    for p in el_nat:
        if p["member"] == c["member"] and p["n_contexts"] == 3 and 0 in p["contexts"]:
            rows2.append(dict(cell=p["cell"], probe=p["probe"], contexts=p["contexts"], trials=p["rep"],
                              cell_pairs=sub.pairs.mean(), cell_pairs_sd=sub.pairs.std(ddof=1), probe_pairs=p["corr"]["pairs"],
                              probe_pairs_sd=p["corr"]["pairs_sd"], cell_loo=sub.loo.mean(), probe_loo=p["corr"]["loo"],
                              **pattern(p["runs"]),
                              runs_after_1_5s=[(round(float(a), 3), round(float(b), 3)) for a, b in p["runs"] if b > 1.5]))
ex = pd.DataFrame(rows2)
six = ex.trials >= 6
ex["match_pairs"] = six & ex.cell_pairs.apply(within, ref=0.61) & ex.probe_pairs.apply(within, ref=0.74)
ex["match_loo"] = six & ex.cell_loo.apply(within, ref=0.61) & ex.probe_loo.apply(within, ref=0.74)
ex["match_with_sd"] = (ex.match_pairs & ex.cell_pairs_sd.apply(within, ref=0.07)
                       & ex.probe_pairs_sd.apply(within, ref=0.08))
ex["dist"] = (ex.cell_pairs / 0.61 - 1).abs() + (ex.probe_pairs / 0.74 - 1).abs()
print(f"candidate probes (7-fragment cells, contexts silence and two fragments): {len(ex)}, "
      f"of which with at least 6 trials per context: {int(six.sum())}")
cols = ["cell", "probe", "contexts", "trials", "cell_pairs", "cell_pairs_sd", "probe_pairs", "probe_pairs_sd",
        "cell_loo", "probe_loo", "dist", "match_pairs", "match_loo", "match_with_sd"]
print(ex[cols].round(3).to_string())
for reading in ["match_pairs", "match_loo", "match_with_sd"]:
    print(f"\n{reading}: {int(ex[reading].sum())} probe(s) match")
    m = ex[ex[reading]].sort_values("dist")
    if len(m):
        r = m.iloc[0]
        print(f"  tested: {r.cell} probe {r.probe}; cell {r.cell_pairs:.3f} +/- {r.cell_pairs_sd:.3f} (0.61 +/- 0.07), "
              f"probe {r.probe_pairs:.3f} +/- {r.probe_pairs_sd:.3f} (0.74 +/- 0.08)")
        print(f"  significant before 2 s: {r.before_2s}; any between 2.2 and 3.6 s: {r.in_2_2_3_6s}; "
              f"one starting after 3.6 s: {r.starts_after_3_6s}")
        print(f"  reproduced under the criterion: {bool(r.before_2s and not r.in_2_2_3_6s and r.starts_after_3_6s)}")
        print(f"  strict windows (reference): any between 2 and 4 s: {r.in_2_4s_strict}; after 4 s: {r.after_4s_strict}")
        print(f"  significant periods after 1.5 s: {r.runs_after_1_5s}")
    else:
        print("  none matches: not testable under this reading")
print("\nfor reference, probes of this design meeting the pattern: amended windows",
      int((six & ex.before_2s & ~ex.in_2_2_3_6s & ex.starts_after_3_6s).sum()),
      "| strict windows", int((six & ex.before_2s & ex.after_4s_strict & ~ex.in_2_4s_strict).sum()), "of", int(six.sum()))
print("natural-sound probes with a significant period later than 4 s:",
      sum(any(b > 4 for a, b in p["runs"]) for p in el_nat), "of", len(el_nat))
candidate probes (7-fragment cells, contexts silence and two fragments): 96, of which with at least 6 trials per context: 40
                cell  probe   contexts  trials  cell_pairs  cell_pairs_sd  probe_pairs  probe_pairs_sd  cell_loo  probe_loo   dist  match_pairs  match_loo  match_with_sd
0   20051207-ha1-002      4  [0, 2, 3]       7       0.224          0.044        0.199           0.137     0.374      0.343  1.364        False      False          False
1   20051207-ha1-002      5  [0, 1, 3]       7       0.224          0.044        0.222           0.153     0.374      0.376  1.333        False      False          False
2   20051207-ha1-002      6  [0, 1, 2]       7       0.224          0.044        0.225           0.133     0.374      0.378  1.329        False      False          False
3   20051207-ha1-002      7  [0, 1, 2]       7       0.224          0.044        0.254           0.130     0.374      0.414  1.290        False      False          False
4   20051207-ha2-001      4  [0, 2, 3]       4       0.265          0.085        0.288           0.076     0.367      0.389  1.176        False      False          False
5   20051207-ha2-001      5  [0, 1, 3]       4       0.265          0.085        0.210           0.183     0.367      0.313  1.282        False      False          False
6   20051207-ha2-001      6  [0, 1, 2]       4       0.265          0.085        0.292           0.133     0.367      0.405  1.170        False      False          False
7   20051207-ha2-001      7  [0, 1, 2]       4       0.265          0.085        0.370           0.105     0.367      0.487  1.066        False      False          False
8   20051213-ha1-001      4  [0, 2, 3]       9       0.276          0.088        0.348           0.152     0.447      0.529  1.077        False      False          False
9   20051213-ha1-001      5  [0, 1, 3]       9       0.276          0.088        0.299           0.172     0.447      0.473  1.144        False      False          False
10  20051213-ha1-001      6  [0, 1, 2]       9       0.276          0.088        0.313           0.149     0.447      0.499  1.125        False      False          False
11  20051213-ha1-001      7  [0, 1, 2]       9       0.276          0.088        0.138           0.134     0.447      0.278  1.362        False      False          False
12  20051222-ha1-001      4  [0, 2, 3]       6       0.611          0.081        0.737           0.075     0.732      0.830  0.006         True      False          False
13  20051222-ha1-001      5  [0, 1, 3]       6       0.611          0.081        0.619           0.146     0.732      0.738  0.166        False      False          False
14  20051222-ha1-001      6  [0, 1, 2]       6       0.611          0.081        0.551           0.099     0.732      0.688  0.258        False      False          False
15  20051222-ha1-001      7  [0, 1, 2]       6       0.611          0.081        0.619           0.083     0.732      0.743  0.165        False      False          False
16  20051225-ha3-001      4  [0, 2, 3]       4       0.211          0.058        0.218           0.127     0.305      0.315  1.360        False      False          False
17  20051225-ha3-001      5  [0, 1, 3]       4       0.211          0.058        0.281           0.142     0.305      0.390  1.275        False      False          False
18  20051225-ha3-001      6  [0, 1, 2]       4       0.211          0.058        0.200           0.137     0.305      0.291  1.384        False      False          False
19  20051225-ha3-001      7  [0, 1, 2]       4       0.211          0.058        0.094           0.153     0.305      0.150  1.528        False      False          False
20  20051226-ha1-001      4  [0, 2, 3]       6       0.244          0.080        0.320           0.118     0.382      0.474  1.167        False      False          False
21  20051226-ha1-001      5  [0, 1, 3]       6       0.244          0.080        0.200           0.137     0.382      0.333  1.329        False      False          False
22  20051226-ha1-001      6  [0, 1, 2]       6       0.244          0.080        0.289           0.114     0.382      0.436  1.209        False      False          False
23  20051226-ha1-001      7  [0, 1, 2]       6       0.244          0.080        0.292           0.117     0.382      0.443  1.205        False      False          False
24  20051226-ha1-002      4  [0, 2, 3]       6       0.300          0.146        0.389           0.107     0.437      0.545  0.982        False      False          False
25  20051226-ha1-002      5  [0, 1, 3]       6       0.300          0.146        0.284           0.127     0.437      0.437  1.125        False      False          False
26  20051226-ha1-002      6  [0, 1, 2]       6       0.300          0.146        0.376           0.096     0.437      0.530  1.000        False      False          False
27  20051226-ha1-002      7  [0, 1, 2]       6       0.300          0.146        0.538           0.090     0.437      0.675  0.781        False      False          False
28  20051226-ha2-001      4  [0, 2, 3]       4       0.283          0.064        0.303           0.118     0.390      0.417  1.127        False      False          False
29  20051226-ha2-001      5  [0, 1, 3]       4       0.283          0.064        0.263           0.070     0.390      0.366  1.181        False      False          False
30  20051226-ha2-001      6  [0, 1, 2]       4       0.283          0.064        0.280           0.117     0.390      0.394  1.157        False      False          False
31  20051226-ha2-001      7  [0, 1, 2]       4       0.283          0.064        0.405           0.070     0.390      0.523  0.989        False      False          False
32  20051227-ha1-001      4  [0, 2, 3]       7       0.347          0.130        0.494           0.122     0.501      0.648  0.764        False      False          False
33  20051227-ha1-001      5  [0, 1, 3]       7       0.347          0.130        0.197           0.128     0.501      0.343  1.165        False      False          False
34  20051227-ha1-001      6  [0, 1, 2]       7       0.347          0.130        0.514           0.107     0.501      0.668  0.737        False      False          False
35  20051227-ha1-001      7  [0, 1, 2]       7       0.347          0.130        0.403           0.121     0.501      0.568  0.887        False      False          False
36  20051228-ha1-001      4  [0, 2, 3]       5       0.260          0.062        0.255           0.134     0.387      0.385  1.229        False      False          False
37  20051228-ha1-001      5  [0, 1, 3]       5       0.260          0.062        0.231           0.105     0.387      0.356  1.261        False      False          False
38  20051228-ha1-001      6  [0, 1, 2]       5       0.260          0.062        0.367           0.146     0.387      0.503  1.078        False      False          False
39  20051228-ha1-001      7  [0, 1, 2]       5       0.260          0.062        0.278           0.092     0.387      0.413  1.198        False      False          False
40  20060105-ha1-001      4  [0, 2, 3]       6       0.309          0.107        0.447           0.161     0.455      0.594  0.889        False      False          False
41  20060105-ha1-001      5  [0, 1, 3]       6       0.309          0.107        0.369           0.129     0.455      0.526  0.995        False      False          False
42  20060105-ha1-001      6  [0, 1, 2]       6       0.309          0.107        0.310           0.143     0.455      0.467  1.074        False      False          False
43  20060105-ha1-001      7  [0, 1, 2]       6       0.309          0.107        0.119           0.136     0.455      0.223  1.333        False      False          False
44  20060220-ha1-005      4  [0, 2, 3]       4       0.283          0.059        0.279           0.239     0.388      0.391  1.159        False      False          False
45  20060220-ha1-005      5  [0, 1, 3]       4       0.283          0.059        0.244           0.137     0.388      0.348  1.206        False      False          False
46  20060220-ha1-005      6  [0, 1, 2]       4       0.283          0.059        0.391           0.162     0.388      0.502  1.008        False      False          False
47  20060220-ha1-005      7  [0, 1, 2]       4       0.283          0.059        0.277           0.135     0.388      0.376  1.162        False      False          False
48  20060225-ha1-001      4  [0, 2, 3]       8       0.382          0.117        0.637           0.131     0.539      0.765  0.513        False      False          False
49  20060225-ha1-001      5  [0, 1, 3]       8       0.382          0.117        0.401           0.189     0.539      0.568  0.832        False      False          False
50  20060225-ha1-001      6  [0, 1, 2]       8       0.382          0.117        0.336           0.220     0.539      0.502  0.919        False      False          False
51  20060225-ha1-001      7  [0, 1, 2]       8       0.382          0.117        0.337           0.171     0.539      0.516  0.918        False      False          False
52  20060225-ha2-001      4  [0, 2, 3]       4       0.231          0.054        0.146           0.164     0.323      0.234  1.425        False      False          False
53  20060225-ha2-001      5  [0, 1, 3]       4       0.231          0.054        0.214           0.234     0.323      0.302  1.332        False      False          False
54  20060225-ha2-001      6  [0, 1, 2]       4       0.231          0.054        0.290           0.190     0.323      0.404  1.230        False      False          False
55  20060225-ha2-001      7  [0, 1, 2]       4       0.231          0.054        0.297           0.120     0.323      0.405  1.220        False      False          False
56  20060226-ha2-002      4  [0, 2, 3]       4       0.204          0.094        0.128           0.130     0.296      0.197  1.493        False      False          False
57  20060226-ha2-002      5  [0, 1, 3]       4       0.204          0.094        0.284           0.120     0.296      0.398  1.281        False      False          False
58  20060226-ha2-002      6  [0, 1, 2]       4       0.204          0.094        0.225           0.160     0.296      0.334  1.361        False      False          False
59  20060226-ha2-002      7  [0, 1, 2]       4       0.204          0.094        0.372           0.094     0.296      0.486  1.163        False      False          False
60  20060228-ha1-001      4  [0, 2, 3]       5       0.219          0.042        0.261           0.098     0.338      0.395  1.288        False      False          False
61  20060228-ha1-001      5  [0, 1, 3]       5       0.219          0.042        0.207           0.118     0.338      0.320  1.361        False      False          False
62  20060228-ha1-001      6  [0, 1, 2]       5       0.219          0.042        0.158           0.101     0.338      0.264  1.427        False      False          False
63  20060228-ha1-001      7  [0, 1, 2]       5       0.219          0.042        0.228           0.093     0.338      0.351  1.332        False      False          False
64  20060301-ha2-001      4  [0, 2, 3]       5       0.244          0.095        0.155           0.155     0.362      0.260  1.391        False      False          False
65  20060301-ha2-001      5  [0, 1, 3]       5       0.244          0.095        0.297           0.132     0.362      0.431  1.199        False      False          False
66  20060301-ha2-001      6  [0, 1, 2]       5       0.244          0.095        0.247           0.170     0.362      0.366  1.267        False      False          False
67  20060301-ha2-001      7  [0, 1, 2]       5       0.244          0.095        0.215           0.126     0.362      0.333  1.310        False      False          False
68  20060314-ha1-001      4  [0, 2, 3]       4       0.233          0.056        0.310           0.127     0.332      0.424  1.199        False      False          False
69  20060314-ha1-001      5  [0, 1, 3]       4       0.233          0.056        0.227           0.143     0.332      0.328  1.312        False      False          False
70  20060314-ha1-001      6  [0, 1, 2]       4       0.233          0.056        0.181           0.147     0.332      0.273  1.373        False      False          False
71  20060314-ha1-001      7  [0, 1, 2]       4       0.233          0.056        0.158           0.138     0.332      0.236  1.405        False      False          False
72  20060320-ha3-003      4  [0, 2, 3]       5       0.232          0.061        0.159           0.161     0.355      0.262  1.405        False      False          False
73  20060320-ha3-003      5  [0, 1, 3]       5       0.232          0.061        0.187           0.134     0.355      0.301  1.367        False      False          False
74  20060320-ha3-003      6  [0, 1, 2]       5       0.232          0.061        0.232           0.139     0.355      0.359  1.305        False      False          False
75  20060320-ha3-003      7  [0, 1, 2]       5       0.232          0.061        0.338           0.101     0.355      0.478  1.163        False      False          False
76  20060329-ha1-001      4  [0, 2, 3]       7       0.343          0.093        0.396           0.134     0.505      0.565  0.903        False      False          False
77  20060329-ha1-001      5  [0, 1, 3]       7       0.343          0.093        0.313           0.119     0.505      0.479  1.015        False      False          False
78  20060329-ha1-001      6  [0, 1, 2]       7       0.343          0.093        0.387           0.135     0.505      0.556  0.915        False      False          False
79  20060329-ha1-001      7  [0, 1, 2]       7       0.343          0.093        0.499           0.098     0.505      0.656  0.763        False      False          False
80  20060402-ha1-001      4  [0, 2, 3]       4       0.272          0.097        0.432           0.105     0.375      0.550  0.970        False      False          False
81  20060402-ha1-001      5  [0, 1, 3]       4       0.272          0.097        0.308           0.121     0.375      0.417  1.137        False      False          False
82  20060402-ha1-001      6  [0, 1, 2]       4       0.272          0.097        0.272           0.141     0.375      0.381  1.186        False      False          False
83  20060402-ha1-001      7  [0, 1, 2]       4       0.272          0.097        0.256           0.165     0.375      0.369  1.207        False      False          False
84  20061006-ha1-001      4  [0, 2, 3]       4       0.401          0.086        0.502           0.085     0.515      0.615  0.664        False      False          False
85  20061006-ha1-001      5  [0, 1, 3]       4       0.401          0.086        0.338           0.099     0.515      0.453  0.886        False      False          False
86  20061006-ha1-001      6  [0, 1, 2]       4       0.401          0.086        0.491           0.092     0.515      0.604  0.679        False      False          False
87  20061006-ha1-001      7  [0, 1, 2]       4       0.401          0.086        0.324           0.113     0.515      0.440  0.904        False      False          False
88  20061007-ha2-001      4  [0, 2, 3]       6       0.294          0.070        0.224           0.139     0.440      0.363  1.215        False      False          False
89  20061007-ha2-001      5  [0, 1, 3]       6       0.294          0.070        0.314           0.115     0.440      0.468  1.093        False      False          False
90  20061007-ha2-001      6  [0, 1, 2]       6       0.294          0.070        0.266           0.117     0.440      0.411  1.159        False      False          False
91  20061007-ha2-001      7  [0, 1, 2]       6       0.294          0.070        0.371           0.132     0.440      0.526  1.017        False      False          False
92  20061007-ha4-001      4  [0, 2, 3]       4       0.291          0.085        0.192           0.106     0.398      0.282  1.265        False      False          False
93  20061007-ha4-001      5  [0, 1, 3]       4       0.291          0.085        0.274           0.089     0.398      0.383  1.154        False      False          False
94  20061007-ha4-001      6  [0, 1, 2]       4       0.291          0.085        0.263           0.112     0.398      0.373  1.168        False      False          False
95  20061007-ha4-001      7  [0, 1, 2]       4       0.291          0.085        0.461           0.077     0.398      0.579  0.900        False      False          False

match_pairs: 1 probe(s) match
  tested: 20051222-ha1-001 probe 4; cell 0.611 +/- 0.081 (0.61 +/- 0.07), probe 0.737 +/- 0.075 (0.74 +/- 0.08)
  significant before 2 s: True; any between 2.2 and 3.6 s: False; one starting after 3.6 s: True
  reproduced under the criterion: True
  strict windows (reference): any between 2 and 4 s: True; after 4 s: True
  significant periods after 1.5 s: [(1.382, 1.521), (1.571, 1.59), (1.595, 1.6), (3.97, 4.008), (4.135, 4.203), (4.286, 4.444), (4.448, 4.455), (4.456, 4.476), (4.586, 4.596)]

match_loo: 0 probe(s) match
  none matches: not testable under this reading

match_with_sd: 0 probe(s) match
  none matches: not testable under this reading

for reference, probes of this design meeting the pattern: amended windows 3 | strict windows 2 of 40
natural-sound probes with a significant period later than 4 s: 15 of 305

Result: reproduced (assumption: the match is on the two mean correlations). Under the amended criterion, one probe of the 40 candidates with six or more trials per context matches the Figure 2 values within 10%: 20051222-ha1-001 probe 4, contexts silence and fragments 2 and 3, six trials each, with a cell mean of 0.611 +/- 0.081 over its seven probes (paper 0.61 +/- 0.07) and 0.737 +/- 0.075 for the probe (paper 0.74 +/- 0.08). Its significant periods run to 1.60 s, none falls between 2.2 and 3.6 s, and the next starts at 3.97 s, so the pattern holds. Under the strict windows of the earlier criterion, the period starting at 3.97 s overlaps the 2 to 4 s window by 30 ms. No probe matches in the leave-one-out reading (cell 0.732) or when the cell SD must also fall within 10% of 0.07 (0.081 is 16% above it); under those readings the claim would not be testable. Over all natural-sound probes, 15 of 305 have a significant period later than 4 s.

fig3a-proportion-significant¶

Of 305 natural sound probes tested in 39 A1 cells with typically five to eight natural sound contexts, 204 (66.9%) showed significant context dependence, and about a quarter (23.7%) of the significant events occurred more than 1 s after probe onset.

Readings (criterion): "silence" counted among the contexts or not; the proportion at time t over all 305 probes (ended probes count as not significant) or over the probes still running at t.

In [12]:
def prop_curves(probes, reading):
    el = [p for p in probes if p["eligible"]]
    prop = asari.population_mean(asari.stack(el, "signif"), reading)
    noise = asari.population_mean(asari.stack(el, "noise"), reading)
    return el, prop, noise

out3 = []
curves3 = {}
for sil, probes in [("silence counted", nat_probes), ("silence left out", nat_probes_nosil)]:
    for reading in ["all", "running"]:
        el, prop, noise = prop_curves(probes, reading)
        lf, tpk, cum = asari.late_fraction(prop, noise)
        nsig = sum(p["significant"] for p in el)
        curves3[(sil, reading)] = (prop, noise)
        out3.append(dict(contexts=sil, proportion_over=reading, probes=len(el), significant=nsig,
                         fraction=nsig / len(el), late_fraction=lf, cum_peak_s=tpk,
                         mean_noise_0_6s=float(np.nanmean(noise[:6000]))))
out3 = pd.DataFrame(out3)
out3["count_ok"] = (out3.significant - 204).abs() <= 20.4
out3["fraction_ok"] = (out3.fraction - 0.669).abs() <= 0.0669
out3["late_ok"] = (out3.late_fraction - 0.237).abs() <= 0.0237
print(out3.round(4).to_string())
nsig_cell = collections.Counter(p["cell"] for p in el_nat if p["significant"])
print("\ncells with at least one significant probe:", len(nsig_cell), "of", len({p['cell'] for p in el_nat}))

prop, noise = curves3[("silence counted", "all")]
tt = np.arange(len(prop)) / 1000
fig, ax = plt.subplots(figsize=(6, 3))
ax.plot(tt, prop, "k", lw=1, label="proportion significant")
ax.plot(tt, noise, color="0.6", lw=1, label="noise floor")
ax.set_xlim(0, 6.1); ax.set_xlabel("time from probe onset (s)"); ax.set_ylabel("probability"); ax.legend()
print(f"plotted range: proportion {np.nanmin(prop):.4f} to {np.nanmax(prop):.4f}, noise {np.nanmin(noise):.5f} to {np.nanmax(noise):.5f}, all points within the axes")
           contexts proportion_over  probes  significant  fraction  late_fraction  cum_peak_s  mean_noise_0_6s  count_ok  fraction_ok  late_ok
0   silence counted             all     305          183    0.6000         0.2250       4.718           0.0022     False        False     True
1   silence counted         running     305          183    0.6000         0.2370       4.718           0.0028     False        False     True
2  silence left out             all     305          160    0.5246         0.1390       3.401           0.0025     False        False    False
3  silence left out         running     305          160    0.5246         0.1443       3.401           0.0032     False        False    False

cells with at least one significant probe: 35 of 39
plotted range: proportion 0.0000 to 0.2692, noise 0.00015 to 0.00308, all points within the axes
No description has been provided for this image

Result: not reproduced. 183 of 305 probes (60.0%) show significant context dependence, against 204 (66.9%): the count is 21 below the paper's, outside the tolerance of 20.4, and the fraction 0.002 below its lower bound. The late fraction is within tolerance: 0.225 over all probes and 0.237 over running probes (paper 0.237), with the cumulative curve peaking at 4.718 s (paper 4.72 s). Leaving silence out of the contexts gives 160 significant probes and a late fraction of 0.139 to 0.144. The criterion's partial rule needs the count within tolerance, so it does not apply; the effect is present but weaker, with its timing reproduced.

fig3a-significance-decay¶

The proportion of probes with significant context dependence decays after probe onset as the sum of two exponentials (sizes 0.17 and 0.09, decay constants 0.20 and 0.90 s), above a noise floor of about 2.8 x 10^-3.

Readings: fit range 0 to 4.72 s or 0 to 6 s (criterion); bounds on the sizes (none, or sizes of a decay kept non-negative; the paper gives no bounds); the proportion readings of the claim it depends on. The constant is fixed at the mean noise floor over 0 to 6 s of the same reading.

In [13]:
fit3 = []
for (sil, reading), (prop, noise) in curves3.items():
    tt = np.arange(len(prop)) / 1000
    kap = float(np.nanmean(noise[:6000]))
    for hi in [4.72, 6.0]:
        m = tt <= hi
        for nonneg in [False, True]:
            n, fits = asari.choose_n_exp(tt[m], prop[m], kappa=kap, nonneg=nonneg)
            f2 = fits[2]["params"]
            fit3.append(dict(contexts=sil, over=reading, range=hi, nonneg_sizes=nonneg, chosen=n,
                             a1=f2[0][0], tau1=f2[0][1], a2=f2[1][0], tau2=f2[1][1], kappa=kap,
                             one_exp=(round(fits[1]["params"][0][0], 3), round(fits[1]["params"][0][1], 3))))
fit3 = pd.DataFrame(fit3)
tol = dict(a1=(0.17, 0.017), tau1=(0.20, 0.02), a2=(0.09, 0.009), tau2=(0.90, 0.09), kappa=(0.0028, 0.00028))
for k, (v, d) in tol.items():
    fit3[k + "_ok"] = (fit3[k] - v).abs() <= d
fit3["all_ok"] = fit3[[k + "_ok" for k in tol]].all(1) & (fit3.chosen == 2)
fit3["partial"] = (fit3.chosen == 2) & fit3.tau2.between(0.5, 2.0)
print(fit3.round(4).to_string())
            contexts     over  range  nonneg_sizes  chosen      a1    tau1      a2    tau2   kappa         one_exp  a1_ok  tau1_ok  a2_ok  tau2_ok  kappa_ok  all_ok  partial
0    silence counted      all   4.72         False       2 -0.1730  0.0153  0.2299  0.4244  0.0022  (0.204, 0.485)  False    False  False    False     False   False    False
1    silence counted      all   4.72          True       2  0.1479  0.2563  0.0776  0.9206  0.0022  (0.204, 0.485)  False    False  False     True     False   False     True
2    silence counted      all   6.00         False       2 -0.1730  0.0153  0.2299  0.4244  0.0022  (0.204, 0.485)  False    False  False    False     False   False    False
3    silence counted      all   6.00          True       2  0.1455  0.2534  0.0800  0.9017  0.0022  (0.204, 0.485)  False    False  False     True     False   False     True
4    silence counted  running   4.72         False       2 -0.1748  0.0154  0.2307  0.4180  0.0028   (0.204, 0.48)  False    False  False    False      True   False    False
5    silence counted  running   4.72          True       2  0.1544  0.2645  0.0704  0.9675  0.0028   (0.204, 0.48)   True    False  False     True      True   False     True
6    silence counted  running   6.00         False       2 -0.1748  0.0154  0.2307  0.4180  0.0028   (0.204, 0.48)  False    False  False    False      True   False    False
7    silence counted  running   6.00          True       2  0.1511  0.2602  0.0738  0.9371  0.0028   (0.204, 0.48)  False    False  False     True      True   False     True
8   silence left out      all   4.72         False       2 -0.2001  0.0218  0.2269  0.2253  0.0025  (0.166, 0.307)  False    False  False    False     False   False    False
9   silence left out      all   4.72          True       1  0.1583  0.2637  0.0120  1.2900  0.0025  (0.166, 0.307)   True    False  False    False     False   False    False
10  silence left out      all   6.00         False       2 -0.2001  0.0218  0.2269  0.2253  0.0025  (0.166, 0.307)  False    False  False    False     False   False    False
11  silence left out      all   6.00          True       1  0.1568  0.2616  0.0135  1.1514  0.0025  (0.166, 0.307)   True    False  False    False     False   False    False
12  silence left out  running   4.72         False       2 -0.2035  0.0222  0.2295  0.2198  0.0032  (0.166, 0.301)  False    False  False    False     False   False    False
13  silence left out  running   4.72          True       1  0.1594  0.2654  0.0101  1.2908  0.0032  (0.166, 0.301)   True    False  False    False     False   False    False
14  silence left out  running   6.00         False       2 -0.2035  0.0222  0.2295  0.2198  0.0032  (0.166, 0.301)  False    False  False    False     False   False    False
15  silence left out  running   6.00          True       1  0.1579  0.2635  0.0117  1.1303  0.0032  (0.166, 0.301)   True    False  False    False     False   False    False
/tmp/ipykernel_2514/3367359776.py:17: Pandas4Warning: Starting with pandas version 4.0 all arguments of all will be keyword-only.
  fit3["all_ok"] = fit3[[k + "_ok" for k in tol]].all(1) & (fit3.chosen == 2)

Result: partially reproduced (resting on non-negative sizes). With decay sizes kept non-negative, two exponentials are selected in every reading with silence counted, with a slow constant of 0.90 to 0.97 s (paper 0.90 s) with the constant fixed at the mean noise floor, 0.0028 for running probes (paper 2.8 x 10^-3); the fast constant (0.25 to 0.26 s against 0.20 s) and the slow size (0.070 to 0.080 against 0.09) are outside tolerance, and the fast size is within it in one reading (0.154). Without bounds the fit takes a negative fast component for the rise in the first 50 ms, which is not a decay: with silence counted -0.173 to -0.175 with 0.015 s, and a slow constant of 0.42 s; with silence left out -0.200 to -0.204 with 0.022 s, and a slow constant of 0.22 s.

fig3b-fractional-power-decay¶

The context-dependent fraction of the stimulus-related response power, normalized by the smoothed stimulus-related power, decays from about 0.49 with a time constant of about 1.04 s.

Q(t) = (Eq. 17 - Eq. 18) / running mean of Eq. 17 over [0, 2t]; one exponential with constant 0. Readings: silence counted or not; probes averaged over those running at t or all (ended probes as 0); fit range 0 to 4 s or 0 to 6 s.

In [14]:
fitq, qcurves = [], {}
for sil, probes in [("silence counted", nat_probes), ("silence left out", nat_probes_nosil)]:
    el = [p for p in probes if p["eligible"]]
    for reading in ["running", "all"]:
        q = asari.q_curves(el, reading)
        qcurves[(sil, reading)] = q
        for hi in [4.0, 6.0]:
            m = (q["t"] <= hi) & np.isfinite(q["Q"])
            f = asari.fit_exponentials(q["t"][m], q["Q"][m], 1, kappa=0.0)
            g = asari.fit_exponentials(q["t"][m], q["ratio"][m], 1, kappa=1.0, sign=-1)
            g2 = asari.fit_exponentials(q["t"][m], q["ratio_raw"][m], 1, kappa=1.0, sign=-1)
            fitq.append(dict(contexts=sil, over=reading, range=hi, Q_a1=f["params"][0][0], Q_tau1=f["params"][0][1],
                             ratio_1_plus_a1=1 + g["params"][0][0], ratio_tau1=g["params"][0][1],
                             raw_1_plus_a1=1 + g2["params"][0][0], raw_tau1=g2["params"][0][1]))
fitq = pd.DataFrame(fitq)
fitq["Q_ok"] = ((fitq.Q_a1 - 0.49).abs() <= 0.049) & ((fitq.Q_tau1 - 1.04).abs() <= 0.104)
print(fitq[["contexts", "over", "range", "Q_a1", "Q_tau1", "Q_ok"]].round(3).to_string())
q = qcurves[("silence counted", "running")]
print("\nQ(t) at selected times (silence counted, running):",
      {s: round(float(q["Q"][int(s * 1000)]), 3) for s in [0, 0.1, 0.25, 0.5, 1, 1.5, 2, 3, 4, 5, 6]})
fig, ax = plt.subplots(figsize=(6, 3))
ax.plot(q["t"], q["Q"], "k", lw=1)
r0 = fitq.iloc[0]
ax.plot(q["t"], r0.Q_a1 * np.exp(-q["t"] / r0.Q_tau1), color="0.6")
ax.set_xlim(0, 6.1); ax.set_ylim(-0.5, 1.5); ax.set_xlabel("time from probe onset (s)"); ax.set_ylabel("normalized power Q")
print("points outside the plotted y range [-0.5, 1.5]:", int(np.sum((q["Q"] < -0.5) | (q["Q"] > 1.5))),
      "; Q range", np.round([np.nanmin(q["Q"]), np.nanmax(q["Q"])], 3))

# The same fit with the two files of 20051108-ha1-001 cut by their stored (swapped) fragment lists
sw = nat_rows[nat_rows.cell == "20051108-ha1-001"]
sw_members = {A.result_member(f) for f in sw.file}
sw_probes = []
for i, r in sw.iterrows():
    _, res = asari.analyze_cc_cell(A, A.result_member(r.file), seed=SEED_NAT + i, extras=False, fix_swaps=False)
    sw_probes += res
el_sw = [p for p in nat_probes if p["eligible"] and p["member"] not in sw_members] + [p for p in sw_probes if p["eligible"]]
print(f"\nstored lists kept for {sorted(sw_members)}: {sum(p['eligible'] for p in sw_probes)} eligible probes "
      f"(corrected: {sum(p['eligible'] for p in nat_probes if p['member'] in sw_members)}); {len(el_sw)} probes in all")
for reading in ["running", "all"]:
    q_sw = asari.q_curves(el_sw, reading)
    for hi in [4.0, 6.0]:
        m = (q_sw["t"] <= hi) & np.isfinite(q_sw["Q"])
        f = asari.fit_exponentials(q_sw["t"][m], q_sw["Q"][m], 1, kappa=0.0)
        print(f"  silence counted, {reading}, 0-{hi:.0f} s: a1 {f['params'][0][0]:.3f}, tau1 {f['params'][0][1]:.3f} s")
           contexts     over  range   Q_a1  Q_tau1   Q_ok
0   silence counted  running    4.0  0.495   1.008   True
1   silence counted  running    6.0  0.488   1.040   True
2   silence counted      all    4.0  0.492   1.023   True
3   silence counted      all    6.0  0.487   1.050   True
4  silence left out  running    4.0  0.555   0.545  False
5  silence left out  running    6.0  0.555   0.545  False
6  silence left out      all    4.0  0.553   0.549  False
7  silence left out      all    6.0  0.554   0.548  False

Q(t) at selected times (silence counted, running): {0: 1.04, 0.1: 0.546, 0.25: 0.441, 0.5: 0.24, 1: 0.112, 1.5: 0.125, 2: 0.004, 3: 0.082, 4: 0.056, 5: -0.038, 6: -0.046}
points outside the plotted y range [-0.5, 1.5]: 0 ; Q range [-0.165  1.042]
stored lists kept for ['asari-results-1/20051108-ha1-001/20051108-ha1-001-002.mat', 'asari-results-1/20051108-ha1-001/20051108-ha1-001-003.mat']: 8 eligible probes (corrected: 8); 305 probes in all
  silence counted, running, 0-4 s: a1 0.468, tau1 1.744 s
  silence counted, running, 0-6 s: a1 0.464, tau1 1.784 s
  silence counted, all, 0-4 s: a1 0.467, tau1 1.770 s
  silence counted, all, 0-6 s: a1 0.467, tau1 1.773 s
No description has been provided for this image

Result: reproduced (resting on silence counted as a context). With silence among the contexts, as in the authors' CxtDep.m and Figure 2B, Q(t) decays from 0.487 to 0.495 with time constants of 1.008 to 1.050 s in all four readings of the average and fit range (paper 0.49 and 1.04 s). Leaving silence out gives sizes of 0.553 to 0.555 and constants of 0.545 to 0.549 s, outside tolerance. With the two files of 20051108-ha1-001 cut by their stored, swapped fragment lists (data check), the fits with silence counted give 0.464 to 0.468 and 1.74 to 1.78 s, outside tolerance, so the result depends on cutting those probes at the right times.

timescale-longer-than-membrane¶

The trial-to-trial noise autocorrelation and the autocorrelation of spontaneous activity decay within about 100 ms, much faster than the second-long timescale of context dependence in A1.

In [15]:
lag_ms = np.arange(501)
nac = np.nanmean([p["noise_ac"] for p in el_nat], 0)
sac = np.nanmean([c["spont_ac"] for c in nat_cells if c.get("spont_ac") is not None], 0)
sac1 = np.nanmean([c["spont_ac_late"] for c in nat_cells if c.get("spont_ac_late") is not None], 0)
def first_below(a, v):
    return int(np.argmax(a < v)) if (a < v).any() else None
tab = pd.DataFrame([dict(series=n, lag_1e_ms=first_below(a, 1 / np.e), lag_0p1_ms=first_below(a, 0.1),
                         ac_at_100ms=a[100], ac_at_200ms=a[200])
                    for n, a in [("noise (Eq. 14, 45), probes", nac), ("spontaneous, whole interval", sac),
                                 ("spontaneous, without first 1 s", sac1)]])
print(tab.round(3).to_string())
print("probes:", len(el_nat), "| files with spontaneous segments:", sum(c.get("spont_ac") is not None for c in nat_cells))
print("one third of 1.04 s = 347 ms")
                           series  lag_1e_ms  lag_0p1_ms  ac_at_100ms  ac_at_200ms
0      noise (Eq. 14, 45), probes         71         115        0.173       -0.114
1     spontaneous, whole interval         77         121        0.206       -0.111
2  spontaneous, without first 1 s         75         118        0.197       -0.125
probes: 305 | files with spontaneous segments: 46
one third of 1.04 s = 347 ms

Result: reproduced. The noise autocorrelation falls below 1/e at 71 ms and below 0.1 at 115 ms; the autocorrelation of the intersequence silences falls below 1/e at 77 ms (75 ms without the first second) and below 0.1 at 121 ms (118 ms). All are under 150 ms, and the 1/e lags are below 347 ms, a third of 1.04 s.

fig4-predictability-upper-bound¶

Without knowledge of the context, no model can capture more than about half (0.51) of the predictable response power with a window of about 100 ms; the upper bound approaches one only with a window of seconds (time constant 1.04 s).

Eq. 43, Eq. 18 over the smoothed Eq. 17 (main) or the unsmoothed Eq. 17 (variant), one exponential with constant 1; readings as for fig3b.

In [16]:
fitq["ratio_ok"] = ((fitq.ratio_1_plus_a1 - 0.51).abs() <= 0.051) & ((fitq.ratio_tau1 - 1.04).abs() <= 0.104)
fitq["raw_ok"] = ((fitq.raw_1_plus_a1 - 0.51).abs() <= 0.051) & ((fitq.raw_tau1 - 1.04).abs() <= 0.104)
print(fitq[["contexts", "over", "range", "ratio_1_plus_a1", "ratio_tau1", "ratio_ok", "raw_1_plus_a1", "raw_tau1", "raw_ok"]].round(3).to_string())
q = qcurves[("silence counted", "running")]
print("\nratio (smoothed) at", {s: round(float(q["ratio"][int(s * 1000)]), 3) for s in [0, 0.1, 0.5, 1, 2, 3, 4]})
print("ratio (unsmoothed) at", {s: round(float(q["ratio_raw"][int(s * 1000)]), 3) for s in [0, 0.1, 0.5, 1, 2, 3, 4]})
# Variant: 1 - Q(t) with constant 1. Under Eq. 19 the smoothed Eq. 43 is pred/smooth - Q, which is 1 - Q where the
# stimulus-related power equals its running mean; the Figure 4 legend gives the same fit as Figure 3B (0.49, 1.04 s).
# The claims file does not offer this reading; it is asked in questions/asari-2009.yaml and does not decide.
rows1q = []
for (sil, reading), q in qcurves.items():
    for hi in [4.0, 6.0]:
        m = (q["t"] <= hi) & np.isfinite(q["Q"])
        g = asari.fit_exponentials(q["t"][m], 1 - q["Q"][m], 1, kappa=1.0, sign=-1)
        rows1q.append(dict(contexts=sil, over=reading, range=hi, one_minus_Q_1_plus_a1=1 + g["params"][0][0],
                           one_minus_Q_tau1=g["params"][0][1]))
f1q = pd.DataFrame(rows1q)
f1q["within_tolerance"] = ((f1q.one_minus_Q_1_plus_a1 - 0.51).abs() <= 0.051) & ((f1q.one_minus_Q_tau1 - 1.04).abs() <= 0.104)
print("\nvariant, 1 - Q(t) (not a reading of the criterion):")
print(f1q.round(3).to_string())
for key in [("silence counted", "running"), ("silence left out", "running")]:
    q = qcurves[key]
    print(f"{key[0]}: mean over the first 100 ms of the smoothed ratio {np.nanmean(q['ratio'][:100]):.3f}, "
          f"of the unsmoothed ratio {np.nanmean(q['ratio_raw'][:100]):.3f}, of 1 - Q {np.nanmean(1 - q['Q'][:100]):.3f}; "
          f"stimulus-related power over its running mean at 0.5, 1, 2, 4 s: "
          f"{[round(float(q['predictable'][int(s * 1000)] / q['smooth'][int(s * 1000)]), 3) for s in [0.5, 1, 2, 4]]}")
           contexts     over  range  ratio_1_plus_a1  ratio_tau1  ratio_ok  raw_1_plus_a1  raw_tau1  raw_ok
0   silence counted  running    4.0            0.448       1.819     False          0.495     1.203   False
1   silence counted  running    6.0            0.496       2.327     False          0.502     1.239   False
2   silence counted      all    4.0            0.445       1.696     False          0.495     1.203   False
3   silence counted      all    6.0            0.702     100.000     False          0.502     1.239   False
4  silence left out  running    4.0            0.477       1.410     False          0.466     0.698   False
5  silence left out  running    6.0            0.501       1.589     False          0.465     0.695   False
6  silence left out      all    4.0            0.466       1.260     False          0.466     0.698   False
7  silence left out      all    6.0            0.755     100.000     False          0.465     0.695   False

ratio (smoothed) at {0: -0.04, 0.1: 0.75, 0.5: 0.508, 1: 0.555, 2: 0.757, 3: 0.82, 4: 0.745}
ratio (unsmoothed) at {0: -0.04, 0.1: 0.579, 0.5: 0.679, 1: 0.832, 2: 0.995, 3: 0.909, 4: 0.93}
variant, 1 - Q(t) (not a reading of the criterion):
           contexts     over  range  one_minus_Q_1_plus_a1  one_minus_Q_tau1  within_tolerance
0   silence counted  running    4.0                  0.505             1.008              True
1   silence counted  running    6.0                  0.512             1.040              True
2   silence counted      all    4.0                  0.508             1.023              True
3   silence counted      all    6.0                  0.513             1.050              True
4  silence left out  running    4.0                  0.445             0.545             False
5  silence left out  running    6.0                  0.445             0.545             False
6  silence left out      all    4.0                  0.447             0.549             False
7  silence left out      all    6.0                  0.446             0.548             False
silence counted: mean over the first 100 ms of the smoothed ratio 0.570, of the unsmoothed ratio 0.453, of 1 - Q 0.406; stimulus-related power over its running mean at 0.5, 1, 2, 4 s: [0.747, 0.668, 0.761, 0.801]
silence left out: mean over the first 100 ms of the smoothed ratio 0.655, of the unsmoothed ratio 0.509, of 1 - Q 0.470; stimulus-related power over its running mean at 0.5, 1, 2, 4 s: [0.751, 0.645, 0.77, 0.859]

Result: not reproduced. The ratio of context-independent to stimulus-related power (Eq. 43) has 1 + alpha1 near half: with silence counted, 0.445 to 0.496 with the smoothed denominator (one fit, over all probes to 6 s, gives 0.702 with its time constant at the 100-s bound) and 0.495 to 0.502 unsmoothed (paper 0.51). Its approach to one is slower than the paper's in every reading of the criterion: time constants of 1.70 to 2.33 s smoothed and 1.20 to 1.24 s unsmoothed (paper 1.04 s). With silence left out the constants are 1.26 to 1.59 s smoothed (one more fit at the bound) and 0.70 s unsmoothed. No reading has both values within tolerance, and the criterion has no partial rule. As a variant that is not a reading of the criterion, 1 - Q(t) with silence counted gives 1 + alpha1 of 0.505 to 0.513 and time constants of 1.008 to 1.050 s, within tolerance: the Figure 4 legend gives the same fit as Figure 3B, which Eq. 43 matches only where the stimulus-related power equals its running mean (here 0.67 to 0.80 of it at 0.5 to 4 s). Whether 1 - Q is what Figure 4 plots is asked in questions/asari-2009.yaml.

fig4-strf-performance-low¶

Linear STRF models of 20 A1 cells from Machens et al. (2004) predicted less than about 20% of the predictable response power, and extending the window from 180 ms to about 4 s did not improve them significantly, with or without a static nonlinearity; the LN model did only slightly better.

Tested in strf_wehr.ipynb on the Wehr recordings (wehr/), with the helper wehr_strf.py.

fig5-example-conductances and fig6-conductance-decay¶

In an example voltage-clamped A1 cell, excitatory and inhibitory conductances ... (fig5) Across 29 probes in 14 voltage-clamped cells, context dependence of both excitatory and inhibitory conductances decayed with a long constant of seconds ... (fig6)

Blocked: the data set holds no voltage-clamp recording (recording types in the data check).

In [17]:
print("recording types of every file read:", dict(chk.groupby("type").size()))
print("Summary.mat experiment descriptions:", list(rows.experiment_description.unique()))
recording types of every file read: {'Cell-attached': np.int64(21), 'Whole-cell': np.int64(151)}
Summary.mat experiment descriptions: ['Auditory cortical cell responses to natural sound combinations.', 'Thalamic cell responses to natural sound combinations.', 'Auditory cortical cell responses to synthetic sound combinations.', 'Auditory cortical cell responses to various acoustic stimuli.']

fig8a-proportion-by-property¶

When only one property of synthetic conditioning stimuli varied, context dependence was found in 77 of 95 probes (81.1%, 31 cells) for amplitude, 73 of 110 (35 cells) for frequency, 62 of 96 (64.6%, 27 cells) for AM, 47 of 82 (57.3%, 25 cells) for FM and 59 of 137 (43.1%, 27 cells) for higher-order properties.

Each probe is tested with only the conditioning stimuli that differ in one property (asari.property_classes, from the parameters stored with each fragment). A probe can have more than one such ensemble (for example AM variants at each of four FM settings). Readings of what Table 1 counts: probe (a probe counts once per property, significant when any of its ensembles is) and entry (each probe x ensemble counts).

In [18]:
se = pd.DataFrame([{k: e[k] for k in ["member", "cell", "probe", "probe_type", "property", "eligible", "n_trials"]}
                   | {"n_ctx": len(e["contexts"]), "significant": e.get("significant", False), "idx": i}
                   for i, e in enumerate(syn_entries)])
se["family"] = se.member.map(fam)
print("probe x ensemble entries:", len(se), "| eligible (>= 4 trials per context):", int(se.eligible.sum()),
      "| dropped:", dict(se[~se.eligible].groupby(["property", "n_trials"]).size()))
see = se[se.eligible]
print("\nTable 1 layout (probe type x property): probes (cells) | entries")
t1 = see.groupby(["probe_type", "property"]).agg(probes=("member", lambda s: len(set(zip(s, see.loc[s.index, "probe"])))),
                                                  cells=("cell", "nunique"), entries=("idx", "size"))
print(t1.to_string())
paper = {"amplitude": (77, 95), "frequency": (73, 110), "AM": (62, 96), "FM": (47, 82), "higher-order": (59, 137)}
rows8 = []
for prop, (ps, pn) in paper.items():
    s = see[see.property == prop]
    byp = s.groupby(["member", "probe"]).significant.any()
    rows8.append(dict(property=prop, paper_sig=ps, paper_n=pn, probe_n=len(byp), probe_sig=int(byp.sum()),
                      entry_n=len(s), entry_sig=int(s.significant.sum()), cells=s.cell.nunique()))
f8 = pd.DataFrame(rows8)
f8["probe_frac"] = f8.probe_sig / f8.probe_n
f8["entry_frac"] = f8.entry_sig / f8.entry_n
f8["paper_frac"] = f8.paper_sig / f8.paper_n
f8["reading_matching_n"] = np.where(f8.probe_n == f8.paper_n, "probe", np.where(f8.entry_n == f8.paper_n, "entry", "neither"))
f8["probe_ok"] = (f8.probe_sig - f8.paper_sig).abs() <= 0.1 * f8.paper_sig
f8["entry_ok"] = (f8.entry_sig - f8.paper_sig).abs() <= 0.1 * f8.paper_sig
print()
print(f8.round(3).to_string())
probe x ensemble entries: 756 | eligible (>= 4 trials per context): 738 | dropped: {('higher-order', 3): np.int64(18)}

Table 1 layout (probe type x property): probes (cells) | entries
                         probes  cells  entries
probe_type property                            
DMR        amplitude          8      2        8
           frequency         20      5       20
MCN        higher-order      73     25      181
MHT        AM                14      2       14
TORC       amplitude         42      9       42
           frequency         44      9       44
natural    AM                25     24       82
           FM                25     24       82
           amplitude         45     19       54
           frequency         46     20       56
           higher-order      58     25      155

       property  paper_sig  paper_n  probe_n  probe_sig  entry_n  entry_sig  cells  probe_frac  entry_frac  paper_frac reading_matching_n  probe_ok  entry_ok
0     amplitude         77       95       95         58      104         61     30       0.611       0.587       0.811              probe     False     False
1     frequency         73      110      110         62      120         70     34       0.564       0.583       0.664              probe     False      True
2            AM         62       96       39         25       96         41     26       0.641       0.427       0.646              entry     False     False
3            FM         47       82       25         16       82         29     24       0.640       0.354       0.573              entry     False     False
4  higher-order         59      137      131         64      336        109     26       0.489       0.324       0.431            neither      True     False
In [19]:
# Table 1 rebuilt by the family of the recording (trigger type: torc, dmr, synthetic = MHT, pinknoise = MCN,
# naturalistic = natural-sound variants) and the probe type, with cells
t1f = see.groupby(["family", "probe_type", "property"]).agg(
    probes=("idx", lambda s: len(set(zip(see.loc[s.index, "member"], see.loc[s.index, "probe"])))),
    cells=("cell", "nunique"), entries=("idx", "size"))
print(t1f.to_string())
print("\nTable 1 (paper), probes (cells): natural 23 (23), 25 (25), 25 (25), 25 (25), 63 (27); TORC 39 (9), 40 (9); "
      "DMR 8 (2), 20 (5); MHT 25 (20), 25 (21), 71 (27), 57 (25); MCN 74 (27)")
# natural probes with AM or FM ensembles: the first ensemble of each probe and the further ones
for prop in ["AM", "FM"]:
    s = see[(see.property == prop) & (see.probe_type == "natural")]
    n_probe = s.groupby(["member", "probe"]).ngroups
    other = see[(see.property == prop) & (see.probe_type != "natural")]
    print(f"{prop}: natural probes {n_probe} in {s.cell.nunique()} cells; further ensembles of the same probes {len(s) - n_probe}; "
          f"synthetic-probe entries {len(other)}; further ensembles + synthetic-probe entries = {len(s) - n_probe + len(other)} "
          f"in {pd.concat([s.cell, other.cell]).nunique()} cells")
print()
for rd in ["probe", "entry"]:
    ff = dict(zip(f8.property, f8[rd + "_frac"]))
    print(f"{rd} reading: amplitude > frequency {ff['amplitude'] > ff['frequency']} (margin {ff['amplitude'] - ff['frequency']:.3f}); "
          f"AM > FM > higher-order {ff['AM'] > ff['FM'] > ff['higher-order']} "
          f"(margins {ff['AM'] - ff['FM']:.3f}, {ff['FM'] - ff['higher-order']:.3f}); counts within tolerance: "
          f"{dict(zip(f8.property, f8[rd + '_ok']))}")
                                      probes  cells  entries
family       probe_type property                            
dmr          DMR        amplitude          8      2        8
                        frequency         20      5       20
             natural    amplitude          5      5       10
                        frequency          5      5       10
naturalistic natural    amplitude         34      9       38
                        frequency         35     10       40
pinknoise    MCN        higher-order      73     25      181
             natural    higher-order      58     25      155
synthetic    MHT        AM                14      2       14
             natural    AM                25     24       82
                        FM                25     24       82
                        amplitude          6      5        6
                        frequency          6      5        6
torc         TORC       amplitude         42      9       42
                        frequency         44      9       44

Table 1 (paper), probes (cells): natural 23 (23), 25 (25), 25 (25), 25 (25), 63 (27); TORC 39 (9), 40 (9); DMR 8 (2), 20 (5); MHT 25 (20), 25 (21), 71 (27), 57 (25); MCN 74 (27)
AM: natural probes 25 in 24 cells; further ensembles of the same probes 57; synthetic-probe entries 14; further ensembles + synthetic-probe entries = 71 in 26 cells
FM: natural probes 25 in 24 cells; further ensembles of the same probes 57; synthetic-probe entries 0; further ensembles + synthetic-probe entries = 57 in 24 cells

probe reading: amplitude > frequency True (margin 0.047); AM > FM > higher-order True (margins 0.001, 0.151); counts within tolerance: {'amplitude': False, 'frequency': False, 'AM': False, 'FM': False, 'higher-order': True}
entry reading: amplitude > frequency True (margin 0.003); AM > FM > higher-order True (margins 0.073, 0.029); counts within tolerance: {'amplitude': False, 'frequency': True, 'AM': False, 'FM': False, 'higher-order': False}
In [20]:
# Table 1 reading: count each property as Table 1's denominators are counted. Probes reproduce the
# amplitude (95) and frequency (110) totals and probe x ensemble entries the AM (96) and FM (82) totals
# and the MHT sub-rows (71, 57, cell above); higher-order matches neither (131 probes, 336 entries,
# against 137) and is counted by probes, as Table 1's legend says each row is a probe type.
t1r = {"amplitude": "probe", "frequency": "probe", "AM": "entry", "FM": "entry", "higher-order": "probe"}
f8t1 = pd.DataFrame([dict(property=p, reading=rd, n=int(f8.set_index("property").loc[p, rd + "_n"]),
                          sig=int(f8.set_index("property").loc[p, rd + "_sig"]),
                          frac=float(f8.set_index("property").loc[p, rd + "_frac"]),
                          paper=f"{paper[p][0]}/{paper[p][1]}", within_tolerance=bool(f8.set_index("property").loc[p, rd + "_ok"]))
                     for p, rd in t1r.items()])
print(f8t1.round(3).to_string())
ff = dict(zip(f8t1.property, f8t1.frac))
order_amp = ff["amplitude"] > ff["frequency"]
order_mod = ff["AM"] > ff["FM"] > ff["higher-order"]
print(f"Table 1 reading: all counts within tolerance {bool(f8t1.within_tolerance.all())}; amplitude > frequency {order_amp}; "
      f"AM > FM > higher-order {order_mod} (AM {ff['AM']:.3f}, FM {ff['FM']:.3f}, higher-order {ff['higher-order']:.3f}); "
      f"partial rule {order_amp and order_mod}")
       property reading    n  sig   frac   paper  within_tolerance
0     amplitude   probe   95   58  0.611   77/95             False
1     frequency   probe  110   62  0.564  73/110             False
2            AM   entry   96   41  0.427   62/96             False
3            FM   entry   82   29  0.354   47/82             False
4  higher-order   probe  131   64  0.489  59/137              True
Table 1 reading: all counts within tolerance False; amplitude > frequency True; AM > FM > higher-order False (AM 0.427, FM 0.354, higher-order 0.489); partial rule False

Result: not reproduced (resting on the grouping of conditioning stimuli). The claims file says the populations follow the columns of Table 1. Counting each property as Table 1 counts its denominators (cell above: probes for amplitude, frequency and higher-order; probe x ensemble entries for AM and FM, the counts that reproduce 95, 110, 96 and 82 and the MHT sub-rows 71 and 57), 58 of 95 probes are significant for amplitude (paper 77), 62 of 110 for frequency (73), 41 of 96 for AM (62), 29 of 82 for FM (47) and 64 of 131 for higher-order properties (59 of 137, the only count within tolerance). Amplitude > frequency holds (0.611 > 0.564), but the order AM > FM > higher-order fails: AM (0.427) and FM (0.354) both fall below higher-order (0.489). The partial rule does not hold. Higher-order matches neither count (131 probes, 336 entries, against 137) and is counted by probes, as Table 1's legend says each row is a probe type; counted by entries it would be 109 of 336 (0.324) and the order would hold.

The uniform readings keep the paper's order by small margins but match Table 1's totals worse. Counting each probe once per property: 58 of 95, 62 of 110, 25 of 39, 16 of 25 and 64 of 131 (AM over FM by 0.001). Counting probe x ensemble entries: 61 of 104, 70 of 120 (within tolerance), 41 of 96, 29 of 82 and 109 of 336 (amplitude over frequency by 0.003). The populations do not split by probe type as Table 1 does: the data set holds 14 MHT probes with AM ensembles (2 cells) against the paper's MHT row of 25, 25, 71 and 57, and its natural probes with amplitude and frequency ensembles (45 and 46) come mostly from the natural-sound variant recordings. For AM and FM, the further ensembles of the 25 natural probes plus the MHT-probe entries number 71 and 57, the paper's MHT counts, but counting them as the MHT row conflicts with the legend's "each row represents the probe stimulus type". This outcome was partially reproduced after round 1 (probe reading) and was changed after the third verification round agreed with the Table 1 reading.

fig8b-decay-by-property¶

The normalized context-dependent power decays slowly for amplitude and frequency changes (time constants 0.66 and 0.97 s) and fast for AM, FM and higher-order changes (0.11, 0.15 and 0.20 s), so higher-order properties act mainly on a timescale of about 100 ms.

Q(t) per property over the probes of fig8a; one exponential with constant 0 from 0 to 4 s (main) and from 0 to the shortest probe length of the property (variant). Readings of which entries form a property's population: every entry, or one ensemble per probe (the one with the most conditioning stimuli).

In [21]:
def entries_for(prop, reading):
    s = see[see.property == prop]
    if reading == "probe":
        s = s.sort_values("n_ctx", ascending=False).drop_duplicates(["member", "probe"])
    return [syn_entries[i] for i in s.idx]

paper8b = {"amplitude": (0.57, 0.66), "frequency": (0.54, 0.97), "AM": (0.86, 0.11), "FM": (0.64, 0.15), "higher-order": (0.52, 0.20)}
rows8b, q8 = [], {}
for prop in paper8b:
    for reading in ["entry", "probe"]:
        ents = entries_for(prop, reading)
        q = asari.q_curves(ents, "running")
        q8[(prop, reading)] = q
        tmin = min(e["T"] for e in ents) / asari.SF
        for rng_name, hi in [("0-4 s", 4.0), ("0-shortest", tmin)]:
            m = (q["t"] <= hi) & np.isfinite(q["Q"])
            f = asari.fit_exponentials(q["t"][m], q["Q"][m], 1, kappa=0.0)
            rows8b.append(dict(property=prop, reading=reading, n=len(ents), range=rng_name, hi=round(hi, 2),
                               a1=f["params"][0][0], tau1=f["params"][0][1], paper_a1=paper8b[prop][0], paper_tau1=paper8b[prop][1]))
f8b = pd.DataFrame(rows8b)
f8b["tau_ok"] = (f8b.tau1 - f8b.paper_tau1).abs() <= 0.1 * f8b.paper_tau1
f8b["a_ok"] = (f8b.a1 - f8b.paper_a1).abs() <= 0.1 * f8b.paper_a1
print(f8b.round(3).to_string())
for (reading, rng_name), g in f8b.groupby(["reading", "range"]):
    tau = dict(zip(g.property, g.tau1))
    print(f"{reading}, {rng_name}: all tau within tolerance {bool(g.tau_ok.all())}; amplitude and frequency > 0.4 s "
          f"{tau['amplitude'] > 0.4 and tau['frequency'] > 0.4}; AM, FM, higher-order < 0.3 s "
          f"{all(tau[k] < 0.3 for k in ['AM', 'FM', 'higher-order'])}")
g = pd.concat([f8b[(f8b.reading == rd) & (f8b.property == p) & (f8b.range == "0-4 s")] for p, rd in t1r.items()])
tau = dict(zip(g.property, g.tau1))
print(f"Table 1 reading, 0-4 s: tau1 {dict((k, round(v, 3)) for k, v in tau.items())}; all within tolerance {bool(g.tau_ok.all())}; "
      f"amplitude and frequency > 0.4 s {tau['amplitude'] > 0.4 and tau['frequency'] > 0.4}; AM, FM, higher-order < 0.3 s "
      f"{all(tau[k] < 0.3 for k in ['AM', 'FM', 'higher-order'])}")
        property reading    n       range    hi     a1   tau1  paper_a1  paper_tau1  tau_ok   a_ok
0      amplitude   entry  104       0-4 s  4.00  0.369  1.353      0.57        0.66   False  False
1      amplitude   entry  104  0-shortest  4.00  0.369  1.353      0.57        0.66   False  False
2      amplitude   probe   95       0-4 s  4.00  0.400  1.350      0.57        0.66   False  False
3      amplitude   probe   95  0-shortest  4.00  0.400  1.350      0.57        0.66   False  False
4      frequency   entry  120       0-4 s  4.00  0.480  0.841      0.54        0.97   False  False
5      frequency   entry  120  0-shortest  4.00  0.480  0.841      0.54        0.97   False  False
6      frequency   probe  110       0-4 s  4.00  0.497  0.784      0.54        0.97   False   True
7      frequency   probe  110  0-shortest  4.00  0.497  0.784      0.54        0.97   False   True
8             AM   entry   96       0-4 s  4.00  0.865  0.109      0.86        0.11    True   True
9             AM   entry   96  0-shortest  5.00  0.865  0.109      0.86        0.11    True   True
10            AM   probe   39       0-4 s  4.00  0.863  0.118      0.86        0.11    True   True
11            AM   probe   39  0-shortest  5.00  0.863  0.118      0.86        0.11    True   True
12            FM   entry   82       0-4 s  4.00  0.214  0.278      0.64        0.15   False  False
13            FM   entry   82  0-shortest  5.08  0.214  0.278      0.64        0.15   False  False
14            FM   probe   25       0-4 s  4.00  0.705  0.113      0.64        0.15   False  False
15            FM   probe   25  0-shortest  5.08  0.705  0.113      0.64        0.15   False  False
16  higher-order   entry  336       0-4 s  4.00  0.850  0.224      0.52        0.20   False  False
17  higher-order   entry  336  0-shortest  4.11  0.850  0.224      0.52        0.20   False  False
18  higher-order   probe  131       0-4 s  4.00  1.227  0.176      0.52        0.20   False  False
19  higher-order   probe  131  0-shortest  4.11  1.227  0.176      0.52        0.20   False  False
entry, 0-4 s: all tau within tolerance False; amplitude and frequency > 0.4 s True; AM, FM, higher-order < 0.3 s True
entry, 0-shortest: all tau within tolerance False; amplitude and frequency > 0.4 s True; AM, FM, higher-order < 0.3 s True
probe, 0-4 s: all tau within tolerance False; amplitude and frequency > 0.4 s True; AM, FM, higher-order < 0.3 s True
probe, 0-shortest: all tau within tolerance False; amplitude and frequency > 0.4 s True; AM, FM, higher-order < 0.3 s True
Table 1 reading, 0-4 s: tau1 {'amplitude': 1.35, 'frequency': 0.784, 'AM': 0.109, 'FM': 0.278, 'higher-order': 0.176}; all within tolerance False; amplitude and frequency > 0.4 s True; AM, FM, higher-order < 0.3 s True

Result: partially reproduced (resting on the grouping of conditioning stimuli). The amplitude and frequency constants exceed 0.4 s (amplitude 1.35 s, frequency 0.78 to 0.84 s; paper 0.66 and 0.97 s) and the AM, FM and higher-order constants are below 0.3 s (AM 0.109 to 0.118 s, FM 0.113 to 0.278 s, higher-order 0.176 to 0.224 s; paper 0.11, 0.15 and 0.20 s) in every reading. Within tolerance are only the AM constant and size and, counting probes, the frequency size (0.497 against 0.54). The Table 1 reading (probes for amplitude, frequency and higher-order, entries for AM and FM) gives 1.350, 0.784, 0.109, 0.278 and 0.176 s, and the partial rule holds.

fig8a-significance-fits¶

The proportion of probes with significant context dependence decays fastest and is smallest for higher-order changes, with fitted (size, time constant) of (0.23, 0.25 s) for amplitude, (0.19, 0.27 s) for frequency, (0.13, 0.17 s) for AM, (0.07, 0.15 s) for FM and (0.04, 0.13 s) for higher-order properties.

One exponential, constant fixed at the property's mean noise floor (1000 shuffles per probe), 0 to 4 s; proportion over the probes still running at t (main) or over all; populations as in fig8b. Size bounds: none, or non-negative.

In [22]:
paper8a = {"amplitude": (0.23, 0.25, 2.8e-3), "frequency": (0.19, 0.27, 2.3e-3), "AM": (0.13, 0.17, 2.3e-3),
           "FM": (0.07, 0.15, 2.1e-3), "higher-order": (0.04, 0.13, 3.6e-3)}
rows8f = []
for prop in paper8a:
    for reading in ["entry", "probe"]:
        ents = entries_for(prop, reading)
        for over in ["running", "all"]:
            prop_c = asari.population_mean(asari.stack(ents, "signif"), over)
            noise_c = asari.population_mean(asari.stack(ents, "noise"), over)
            tt = np.arange(len(prop_c)) / 1000
            m = tt <= 4.0
            kap = float(np.nanmean(noise_c[:4000]))
            for nonneg in [False, True]:
                f = asari.fit_exponentials(tt[m], prop_c[m], 1, kappa=kap, nonneg=nonneg)
                rows8f.append(dict(property=prop, reading=reading, over=over, nonneg=nonneg, n=len(ents),
                                   a1=f["params"][0][0], tau1=f["params"][0][1], kappa=kap,
                                   paper_a1=paper8a[prop][0], paper_tau1=paper8a[prop][1], paper_kappa=paper8a[prop][2]))
f8f = pd.DataFrame(rows8f)
f8f["ok"] = ((f8f.a1 - f8f.paper_a1).abs() <= 0.1 * f8f.paper_a1) & ((f8f.tau1 - f8f.paper_tau1).abs() <= 0.1 * f8f.paper_tau1)
print(f8f.round(4).to_string())
order = ["amplitude", "frequency", "AM", "FM", "higher-order"]
for (reading, over, nonneg), g in f8f.groupby(["reading", "over", "nonneg"]):
    a = dict(zip(g.property, g.a1))
    print(f"{reading}/{over}/nonneg={nonneg}: all ten within tolerance {bool(g.ok.all())}; values within tolerance "
          f"{int(g.ok.sum())} of 5 properties; sizes in the printed order {all(a[order[i]] > a[order[i + 1]] for i in range(4))}")
        property reading     over  nonneg    n      a1    tau1   kappa  paper_a1  paper_tau1  paper_kappa     ok
0      amplitude   entry  running   False  104  0.1189  0.2687  0.0033      0.23        0.25       0.0028  False
1      amplitude   entry  running    True  104  0.1189  0.2687  0.0033      0.23        0.25       0.0028  False
2      amplitude   entry      all   False  104  0.1189  0.2687  0.0033      0.23        0.25       0.0028  False
3      amplitude   entry      all    True  104  0.1189  0.2687  0.0033      0.23        0.25       0.0028  False
4      amplitude   probe  running   False   95  0.1245  0.2722  0.0033      0.23        0.25       0.0028  False
5      amplitude   probe  running    True   95  0.1245  0.2722  0.0033      0.23        0.25       0.0028  False
6      amplitude   probe      all   False   95  0.1245  0.2722  0.0033      0.23        0.25       0.0028  False
7      amplitude   probe      all    True   95  0.1245  0.2722  0.0033      0.23        0.25       0.0028  False
8      frequency   entry  running   False  120  0.1473  0.2891  0.0022      0.19        0.27       0.0023  False
9      frequency   entry  running    True  120  0.1473  0.2891  0.0022      0.19        0.27       0.0023  False
10     frequency   entry      all   False  120  0.1473  0.2891  0.0022      0.19        0.27       0.0023  False
11     frequency   entry      all    True  120  0.1473  0.2891  0.0022      0.19        0.27       0.0023  False
12     frequency   probe  running   False  110  0.1467  0.2804  0.0022      0.19        0.27       0.0023  False
13     frequency   probe  running    True  110  0.1467  0.2804  0.0022      0.19        0.27       0.0023  False
14     frequency   probe      all   False  110  0.1467  0.2804  0.0022      0.19        0.27       0.0023  False
15     frequency   probe      all    True  110  0.1467  0.2804  0.0022      0.19        0.27       0.0023  False
16            AM   entry  running   False   96  0.0643  0.1982  0.0021      0.13        0.17       0.0023  False
17            AM   entry  running    True   96  0.0643  0.1982  0.0021      0.13        0.17       0.0023  False
18            AM   entry      all   False   96  0.0643  0.1982  0.0021      0.13        0.17       0.0023  False
19            AM   entry      all    True   96  0.0643  0.1982  0.0021      0.13        0.17       0.0023  False
20            AM   probe  running   False   39  0.0733  0.2004  0.0022      0.13        0.17       0.0023  False
21            AM   probe  running    True   39  0.0733  0.2004  0.0022      0.13        0.17       0.0023  False
22            AM   probe      all   False   39  0.0733  0.2004  0.0022      0.13        0.17       0.0023  False
23            AM   probe      all    True   39  0.0733  0.2004  0.0022      0.13        0.17       0.0023  False
24            FM   entry  running   False   82  0.0122  0.1352  0.0020      0.07        0.15       0.0021  False
25            FM   entry  running    True   82  0.0122  0.1352  0.0020      0.07        0.15       0.0021  False
26            FM   entry      all   False   82  0.0122  0.1352  0.0020      0.07        0.15       0.0021  False
27            FM   entry      all    True   82  0.0122  0.1352  0.0020      0.07        0.15       0.0021  False
28            FM   probe  running   False   25  0.0356  0.1340  0.0021      0.07        0.15       0.0021  False
29            FM   probe  running    True   25  0.0356  0.1340  0.0021      0.07        0.15       0.0021  False
30            FM   probe      all   False   25  0.0356  0.1340  0.0021      0.07        0.15       0.0021  False
31            FM   probe      all    True   25  0.0356  0.1340  0.0021      0.07        0.15       0.0021  False
32  higher-order   entry  running   False  336  0.0362  0.1091  0.0025      0.04        0.13       0.0036  False
33  higher-order   entry  running    True  336  0.0362  0.1091  0.0025      0.04        0.13       0.0036  False
34  higher-order   entry      all   False  336  0.0362  0.1091  0.0025      0.04        0.13       0.0036  False
35  higher-order   entry      all    True  336  0.0362  0.1091  0.0025      0.04        0.13       0.0036  False
36  higher-order   probe  running   False  131  0.0256  0.1284  0.0024      0.04        0.13       0.0036  False
37  higher-order   probe  running    True  131  0.0256  0.1284  0.0024      0.04        0.13       0.0036  False
38  higher-order   probe      all   False  131  0.0256  0.1284  0.0024      0.04        0.13       0.0036  False
39  higher-order   probe      all    True  131  0.0256  0.1284  0.0024      0.04        0.13       0.0036  False
entry/all/nonneg=False: all ten within tolerance False; values within tolerance 0 of 5 properties; sizes in the printed order False
entry/all/nonneg=True: all ten within tolerance False; values within tolerance 0 of 5 properties; sizes in the printed order False
entry/running/nonneg=False: all ten within tolerance False; values within tolerance 0 of 5 properties; sizes in the printed order False
entry/running/nonneg=True: all ten within tolerance False; values within tolerance 0 of 5 properties; sizes in the printed order False
probe/all/nonneg=False: all ten within tolerance False; values within tolerance 0 of 5 properties; sizes in the printed order False
probe/all/nonneg=True: all ten within tolerance False; values within tolerance 0 of 5 properties; sizes in the printed order False
probe/running/nonneg=False: all ten within tolerance False; values within tolerance 0 of 5 properties; sizes in the printed order False
probe/running/nonneg=True: all ten within tolerance False; values within tolerance 0 of 5 properties; sizes in the printed order False

Result: not reproduced. No property has its size and time constant both within tolerance in any reading. The sizes are smaller than the paper's (amplitude 0.119 to 0.125 against 0.23, frequency 0.147 against 0.19, AM 0.064 to 0.073 against 0.13, FM 0.012 to 0.036 against 0.07, higher-order 0.026 to 0.036 against 0.04) and their order fails at the first step, amplitude below frequency. The time constants are close to the printed ones (amplitude 0.27 s, frequency 0.28 to 0.29 s, AM 0.20 s, FM 0.13 s, higher-order 0.11 to 0.13 s), and the fitted noise floors are 0.0020 to 0.0033 (paper 0.0021 to 0.0036).

fig8c-relative-effects¶

Changes in amplitude and frequency of the conditioning stimuli produced context effects as large and long-lasting as natural sound contexts, while AM, FM and higher-order changes produced substantially smaller and shorter effects; A1 is more sensitive to lower-order than to higher-order properties.

Area under Q(t) from 0 to 4 s for each property over the area for natural sounds (Figure 3B, silence counted, probes running at t). Confidence intervals: 200 resamplings of 1000 probes drawn with replacement (the probe reading of "sample"); the natural-sound denominator is resampled in the same way. The trial reading of "sample" was not run (see the record).

In [23]:
rng8c = np.random.default_rng(80_003)

def q_area(ents, idx=None):
    if idx is not None:
        ents = [ents[i] for i in idx]
    q = asari.q_curves(ents, "running")
    m = q["t"] < 4.0
    return float(np.nansum(q["Q"][m]) * 1e-3)

nat_area = q_area(el_nat)
rows8c = []
for reading in ["entry", "probe"]:
    for prop in order:
        ents = entries_for(prop, reading)
        point = q_area(ents) / nat_area
        boots = []
        for b in range(200):
            i1 = rng8c.integers(0, len(ents), 1000)
            i2 = rng8c.integers(0, len(el_nat), 1000)
            boots.append(q_area(ents, i1) / q_area(el_nat, i2))
        lo, hi = np.percentile(boots, [2.5, 97.5])
        rows8c.append(dict(reading=reading, property=prop, n=len(ents), area=q_area(ents), ratio=point, ci_lo=lo, ci_hi=hi))
f8c = pd.DataFrame(rows8c)
print("natural-sound area 0-4 s:", round(nat_area, 3), "s")
print(f8c.round(3).to_string())
for reading, g in f8c.groupby("reading"):
    d = g.set_index("property")
    low_ok = all(d.ci_hi[k] >= 1 for k in ["amplitude", "frequency"])
    high_lo = min(d.ci_lo["amplitude"], d.ci_lo["frequency"])
    hi_ok = all(d.ci_hi[k] < 1 and d.ci_hi[k] < high_lo for k in ["AM", "FM", "higher-order"])
    pt = all(d.ratio[k] >= 1 for k in ["amplitude", "frequency"]) and all(
        d.ratio[k] < 1 and d.ratio[k] < min(d.ratio["amplitude"], d.ratio["frequency"]) for k in ["AM", "FM", "higher-order"])
    print(f"{reading}: amplitude and frequency intervals include or exceed 1: {low_ok}; AM, FM, higher-order intervals "
          f"below 1 and below the amplitude/frequency lower bounds: {hi_ok}; point estimates in that pattern: {pt}")

# Variant: each resample draws as many probes (or entries) as the population holds, not 1000
rng8c_n = np.random.default_rng(80_004)
rows8c_n = []
for reading in ["entry", "probe"]:
    for prop in order:
        ents = entries_for(prop, reading)
        boots = []
        for b in range(200):
            i1 = rng8c_n.integers(0, len(ents), len(ents))
            i2 = rng8c_n.integers(0, len(el_nat), len(el_nat))
            boots.append(q_area(ents, i1) / q_area(el_nat, i2))
        lo, hi = np.percentile(boots, [2.5, 97.5])
        rows8c_n.append(dict(reading=reading, property=prop, n=len(ents), ratio=q_area(ents) / nat_area, ci_lo=lo, ci_hi=hi))
f8c_n = pd.DataFrame(rows8c_n)
print("\nvariant, resamples of n:")
print(f8c_n.round(3).to_string())
for reading, g in f8c_n.groupby("reading"):
    d = g.set_index("property")
    low_ok = all(d.ci_hi[k] >= 1 for k in ["amplitude", "frequency"])
    high_lo = min(d.ci_lo["amplitude"], d.ci_lo["frequency"])
    hi_ok = all(d.ci_hi[k] < 1 and d.ci_hi[k] < high_lo for k in ["AM", "FM", "higher-order"])
    print(f"{reading}, resamples of n: amplitude and frequency intervals include or exceed 1: {low_ok}; AM, FM, higher-order "
          f"intervals below 1 and below the amplitude/frequency lower bounds: {hi_ok}")

# Table 1 reading (cell above): probes for amplitude, frequency and higher-order, entries for AM and FM
d = pd.concat([f8c[(f8c.reading == rd) & (f8c.property == p)] for p, rd in t1r.items()]).set_index("property")
print("\nTable 1 reading, 1000 probes or entries per resample:")
print(d.round(3).to_string())
low_ok = all(d.ci_hi[k] >= 1 for k in ["amplitude", "frequency"])
high_lo = min(d.ci_lo["amplitude"], d.ci_lo["frequency"])
hi_ok = all(d.ci_hi[k] < 1 and d.ci_hi[k] < high_lo for k in ["AM", "FM", "higher-order"])
print(f"Table 1 reading: amplitude and frequency intervals include or exceed 1: {low_ok}; AM, FM, higher-order intervals "
      f"below 1 and below the amplitude/frequency lower bounds: {hi_ok} (higher-order upper {d.ci_hi['higher-order']:.3f}, "
      f"amplitude/frequency lower {high_lo:.3f})")

# Trial reading: in each of 200 resamples the trials of every probe and context are drawn with replacement
# (asari.boot_power, computed while loading, on 1-ms means of the trials, stored as 10-ms means to 4 s)
def boot_areas(ents):
    nb_ = 400
    P = np.full((N_BOOT_TRIALS + 1, len(ents), nb_), np.nan, np.float32)
    I = np.full_like(P, np.nan)
    for k, e in enumerate(ents):
        b = e["boot"]
        n = b["pred10"].shape[0]
        P[0, k, :n], I[0, k, :n] = b["pred10"], b["inv10"]
        P[1:, k, :n], I[1:, k, :n] = b["boot_pred"], b["boot_inv"]
    out = []
    with np.errstate(invalid="ignore"), warnings.catch_warnings():
        warnings.simplefilter("ignore", RuntimeWarning)
        pm, im = np.nanmean(P, 1), np.nanmean(I, 1)
    for j in range(N_BOOT_TRIALS + 1):
        sm = asari.running_mean_0_2t(pm[j].astype(float))
        out.append(float(np.nansum((pm[j] - im[j]) / sm) * 0.01))
    return out[0], np.array(out[1:])

nat_pt, nat_bt = boot_areas(el_nat)
print(f"\ntrial reading: natural-sound area 0-4 s on 10-ms bins {nat_pt:.3f} s (1-ms bins {nat_area:.3f} s); "
      f"mean of the resampled areas {nat_bt.mean():.3f} s")
rows8t = []
for reading in ["entry", "probe"]:
    for prop in order:
        pt, bt = boot_areas(entries_for(prop, reading))
        lo, hi = np.percentile(bt / nat_bt, [2.5, 97.5])
        rows8t.append(dict(reading=reading, property=prop, n=len(entries_for(prop, reading)), area=pt, ratio=pt / nat_pt,
                           boot_mean_area=bt.mean(), ci_lo=lo, ci_hi=hi))
f8t = pd.DataFrame(rows8t)
print(f8t.round(3).to_string())
for reading, d in [("entry", f8t[f8t.reading == "entry"].set_index("property")),
                   ("probe", f8t[f8t.reading == "probe"].set_index("property")),
                   ("Table 1", pd.concat([f8t[(f8t.reading == rd) & (f8t.property == p)] for p, rd in t1r.items()]).set_index("property"))]:
    low_ok = all(d.ci_hi[k] >= 1 for k in ["amplitude", "frequency"])
    high_lo = min(d.ci_lo["amplitude"], d.ci_lo["frequency"])
    hi_ok = all(d.ci_hi[k] < 1 and d.ci_hi[k] < high_lo for k in ["AM", "FM", "higher-order"])
    print(f"trial reading, {reading}: amplitude and frequency intervals include or exceed 1: {low_ok}; AM, FM, higher-order "
          f"intervals below 1 and below the amplitude/frequency lower bounds: {hi_ok}")
natural-sound area 0-4 s: 0.525 s
  reading      property    n   area  ratio  ci_lo  ci_hi
0   entry     amplitude  104  0.511  0.974  0.848  1.127
1   entry     frequency  120  0.482  0.919  0.814  1.037
2   entry            AM   96  0.112  0.213  0.161  0.259
3   entry            FM   82  0.102  0.194  0.143  0.255
4   entry  higher-order  336  0.285  0.543  0.455  0.638
5   probe     amplitude   95  0.548  1.045  0.918  1.183
6   probe     frequency  110  0.476  0.907  0.792  1.012
7   probe            AM   39  0.070  0.134  0.084  0.181
8   probe            FM   25  0.154  0.293  0.231  0.349
9   probe  higher-order  131  0.376  0.717  0.637  0.826
entry: amplitude and frequency intervals include or exceed 1: True; AM, FM, higher-order intervals below 1 and below the amplitude/frequency lower bounds: True; point estimates in that pattern: False
probe: amplitude and frequency intervals include or exceed 1: True; AM, FM, higher-order intervals below 1 and below the amplitude/frequency lower bounds: False; point estimates in that pattern: False
variant, resamples of n:
  reading      property    n  ratio  ci_lo  ci_hi
0   entry     amplitude  104  0.974  0.655  1.349
1   entry     frequency  120  0.919  0.652  1.169
2   entry            AM   96  0.213  0.053  0.386
3   entry            FM   82  0.194  0.001  0.387
4   entry  higher-order  336  0.543  0.423  0.726
5   probe     amplitude   95  1.045  0.729  1.448
6   probe     frequency  110  0.907  0.684  1.210
7   probe            AM   39  0.134 -0.191  0.424
8   probe            FM   25  0.293 -0.067  0.650
9   probe  higher-order  131  0.717  0.517  0.932
entry, resamples of n: amplitude and frequency intervals include or exceed 1: True; AM, FM, higher-order intervals below 1 and below the amplitude/frequency lower bounds: False
probe, resamples of n: amplitude and frequency intervals include or exceed 1: True; AM, FM, higher-order intervals below 1 and below the amplitude/frequency lower bounds: False

Table 1 reading, 1000 probes or entries per resample:
             reading    n   area  ratio  ci_lo  ci_hi
property                                             
amplitude      probe   95  0.548  1.045  0.918  1.183
frequency      probe  110  0.476  0.907  0.792  1.012
AM             entry   96  0.112  0.213  0.161  0.259
FM             entry   82  0.102  0.194  0.143  0.255
higher-order   probe  131  0.376  0.717  0.637  0.826
Table 1 reading: amplitude and frequency intervals include or exceed 1: True; AM, FM, higher-order intervals below 1 and below the amplitude/frequency lower bounds: False (higher-order upper 0.826, amplitude/frequency lower 0.792)

trial reading: natural-sound area 0-4 s on 10-ms bins 0.520 s (1-ms bins 0.525 s); mean of the resampled areas 1.515 s
  reading      property    n   area  ratio  boot_mean_area  ci_lo  ci_hi
0   entry     amplitude  104  0.501  0.964           1.958  1.214  1.373
1   entry     frequency  120  0.476  0.916           1.823  1.145  1.267
2   entry            AM   96  0.112  0.215           1.467  0.895  1.035
3   entry            FM   82  0.097  0.186           1.389  0.856  0.980
4   entry  higher-order  336  0.285  0.548           1.573  0.987  1.088
5   probe     amplitude   95  0.540  1.038           1.999  1.242  1.404
6   probe     frequency  110  0.471  0.906           1.850  1.155  1.283
7   probe            AM   39  0.073  0.140           1.525  0.912  1.118
8   probe            FM   25  0.145  0.279           1.439  0.857  1.066
9   probe  higher-order  131  0.375  0.721           1.587  0.984  1.133
trial reading, entry: amplitude and frequency intervals include or exceed 1: True; AM, FM, higher-order intervals below 1 and below the amplitude/frequency lower bounds: False
trial reading, probe: amplitude and frequency intervals include or exceed 1: True; AM, FM, higher-order intervals below 1 and below the amplitude/frequency lower bounds: False
trial reading, Table 1: amplitude and frequency intervals include or exceed 1: True; AM, FM, higher-order intervals below 1 and below the amplitude/frequency lower bounds: False

Result: partially reproduced (resting on the grouping of conditioning stimuli). Relative to natural sounds, counting probe x ensemble entries, the area under Q from 0 to 4 s is 0.97 [0.85, 1.13] for amplitude and 0.92 [0.81, 1.04] for frequency, so both intervals include 1, and 0.21 [0.16, 0.26] for AM, 0.19 [0.14, 0.26] for FM and 0.54 [0.46, 0.64] for higher-order properties, all below 1 and below the amplitude and frequency lower bounds: the criterion holds in this reading. Counting each probe once, the higher-order interval [0.64, 0.83] overlaps the frequency lower bound of 0.79, and the criterion fails on that comparison alone. The point estimates for amplitude and frequency are below 1 in both readings (0.907 to 1.045), so the partial rule's pattern holds only if "include 1" is read for intervals. Resampling as many probes or entries as the population holds, not 1000, widens the intervals: amplitude and frequency still include 1, but the higher-order upper bound (0.73 entries, 0.93 probes) passes the amplitude and frequency lower bounds (0.65 to 0.73) in both readings. Read as Table 1 counts (probes for amplitude, frequency and higher-order, entries for AM and FM), the intervals are those of the probe reading for amplitude, frequency and higher-order, so the higher-order upper bound 0.826 again passes the frequency lower bound 0.792. The trial reading (trials drawn with replacement within each probe and context, 200 resamples, on 1-ms means of the trials and 10-ms bins of the power) does not meet the criterion in any population: the resampled areas are biased upwards (natural sounds 1.515 s against 0.520 s unresampled), because a trial drawn twice makes the context means noisier and Eqs. 17 and 18 no longer remove the noise, so the intervals of the ratios lie near or above 1 for every property: the AM and higher-order upper bounds pass 1 (1.035 to 1.118 and 1.088 to 1.133) and the amplitude and frequency intervals lie above 1 (lower bounds 1.145 to 1.242).

fig8-natural-synthetic-probes-alike¶

Natural and synthetic probes gave no difference in the context effects of the synthetic conditioning stimuli, so they were combined.

Fisher's exact test per property on the proportion of significant probes, natural against synthetic (TORC, DMR, MHT, MCN) probes, Bonferroni over the properties tested with both (criterion). Shown for the probe and the entry readings of fig8a.

In [24]:
rows8n = []
for reading in ["probe", "entry", "table1"]:
    for prop in order:
        s = see[see.property == prop].copy()
        if reading == "probe" or (reading == "table1" and t1r[prop] == "probe"):
            s = s.groupby(["member", "probe"]).agg(significant=("significant", "any"), probe_type=("probe_type", "first")).reset_index()
        s["natural"] = s.probe_type == "natural"
        a = int((s.natural & s.significant).sum()); b = int((s.natural & ~s.significant).sum())
        c = int((~s.natural & s.significant).sum()); d = int((~s.natural & ~s.significant).sum())
        if (a + b) and (c + d):
            orr, p = stats.fisher_exact([[a, b], [c, d]])
        else:
            orr, p = np.nan, np.nan
        rows8n.append(dict(reading=reading, property=prop, natural=f"{a}/{a + b}", synthetic=f"{c}/{c + d}",
                           nat_frac=a / (a + b) if a + b else np.nan, syn_frac=c / (c + d) if c + d else np.nan,
                           odds_ratio=orr, p=p))
f8n = pd.DataFrame(rows8n)
for reading, g in f8n.groupby("reading"):
    k = int(g.p.notna().sum())
    f8n.loc[g.index, "tested"] = k
    f8n.loc[g.index, "p_bonferroni"] = np.minimum(g.p * k, 1)
print(f8n.round(4).to_string())
   reading      property natural synthetic  nat_frac  syn_frac  odds_ratio       p  tested  p_bonferroni
0    probe     amplitude   27/45     31/50    0.6000    0.6200      0.9194  1.0000     4.0        1.0000
1    probe     frequency   23/46     39/64    0.5000    0.6094      0.6410  0.3301     4.0        1.0000
2    probe            AM   17/25      8/14    0.6800    0.5714      1.5938  0.5119     4.0        1.0000
3    probe            FM   16/25       0/0    0.6400       NaN         NaN     NaN     4.0           NaN
4    probe  higher-order   29/58     35/73    0.5000    0.4795      1.0857  0.8614     4.0        1.0000
5    entry     amplitude   30/54     31/50    0.5556    0.6200      0.7661  0.5536     4.0        1.0000
6    entry     frequency   31/56     39/64    0.5536    0.6094      0.7949  0.5807     4.0        1.0000
7    entry            AM   33/82      8/14    0.4024    0.5714      0.5051  0.2577     4.0        1.0000
8    entry            FM   29/82       0/0    0.3537       NaN         NaN     NaN     4.0           NaN
9    entry  higher-order  56/155    53/181    0.3613    0.2928      1.3661  0.1994     4.0        0.7975
10  table1     amplitude   27/45     31/50    0.6000    0.6200      0.9194  1.0000     4.0        1.0000
11  table1     frequency   23/46     39/64    0.5000    0.6094      0.6410  0.3301     4.0        1.0000
12  table1            AM   33/82      8/14    0.4024    0.5714      0.5051  0.2577     4.0        1.0000
13  table1            FM   29/82       0/0    0.3537       NaN         NaN     NaN     4.0           NaN
14  table1  higher-order   29/58     35/73    0.5000    0.4795      1.0857  0.8614     4.0        1.0000

Result: reproduced (the test is this file's, not the paper's). No property shows a difference between natural and synthetic probes: Fisher's exact test gives Bonferroni-corrected p of 1.0 for amplitude (27/45 against 31/50), frequency (23/46 against 39/64), AM (17/25 against 8/14) and higher-order properties (29/58 against 35/73), and 0.80 or more in the entry reading. FM has no synthetic probes and is not tested. The Table 1 reading (entries for AM, probes otherwise) gives the same: AM 33/82 against 8/14, corrected p 1.0.

fig9-mgb-fast-decay¶

In the auditory thalamus (MGB), context dependence of spike responses decayed within a short time (time constant about 80 ms; 93 probes in 14 cells), so the long-lasting component in A1 arises mainly in cortex.

PSTHs in 100-ms bins (k = 0 to 60), SD over contexts (n - 1), averaged over probes; one exponential with a free constant. Readings: time of a bin at its start or its centre; average over probes still running or over all (ended probes as 0); spike detectors as in a1-mgb-firing-rates.

In [25]:
rows9 = []
for det, (infos, probes) in mgb.items():
    el = [p for p in probes if p["eligible"]]
    M = np.full((len(el), 61), np.nan)
    for k, p in enumerate(el):
        n = min(61, len(p["sd"]))
        M[k, :n] = p["sd"][:n]
    for over in ["running", "all"]:
        msd = asari.population_mean(M, over)
        for tb in ["start", "centre"]:
            tt = np.arange(61) * 0.1 + (0.05 if tb == "centre" else 0.0)
            f = asari.fit_exponentials(tt, msd, 1, kappa=None)
            rows9.append(dict(detector=det, over=over, bin_time=tb, probes=len(el), cells=len({p["cell"] for p in el}),
                              a1=f["params"][0][0], tau1=f["params"][0][1], kappa=f["kappa"],
                              mean_sd_after_0p5s=float(np.nanmean(msd[6:])), first_bins=np.round(msd[:4], 2).tolist()))
f9 = pd.DataFrame(rows9)
f9["tau_ok"] = (f9.tau1 - 0.08).abs() <= 0.008
f9["tau_below_0p1"] = f9.tau1 < 0.1
f9["plateau_vs_fit_kappa"] = (f9.mean_sd_after_0p5s - f9.kappa).abs() <= 0.25 * f9.kappa.abs()
f9["plateau_vs_paper_kappa"] = (f9.mean_sd_after_0p5s - 2.0).abs() <= 0.5
print(f9.round(3).to_string())
     detector     over bin_time  probes  cells      a1   tau1  kappa  mean_sd_after_0p5s                first_bins  tau_ok  tau_below_0p1  plateau_vs_fit_kappa  plateau_vs_paper_kappa
0   getspikes  running    start      93     14   5.273  0.060  1.140               1.129  [6.43, 2.01, 1.55, 1.44]   False           True                  True                   False
1   getspikes  running   centre      93     14  12.189  0.060  1.140               1.129  [6.43, 2.01, 1.55, 1.44]   False           True                  True                   False
2   getspikes      all    start      93     14   5.571  0.079  0.792               0.766  [6.43, 2.01, 1.55, 1.44]    True           True                  True                   False
3   getspikes      all   centre      93     14  10.449  0.080  0.792               0.766  [6.43, 2.01, 1.55, 1.44]    True           True                  True                   False
4       mad:5  running    start      93     14   8.871  0.063  2.303               2.281  [11.2, 3.92, 3.02, 2.87]   False           True                  True                    True
5       mad:5  running   centre      93     14  19.562  0.063  2.303               2.281  [11.2, 3.92, 3.02, 2.87]   False           True                  True                    True
6       mad:5      all    start      93     14   9.438  0.090  1.600               1.553  [11.2, 3.92, 3.02, 2.87]   False           True                  True                    True
7       mad:5      all   centre      93     14  16.498  0.090  1.600               1.553  [11.2, 3.92, 3.02, 2.87]   False           True                  True                    True
8       mad:8  running    start      93     14   8.043  0.063  1.752               1.729   [9.82, 3.2, 2.42, 2.29]   False           True                  True                    True
9       mad:8  running   centre      93     14  17.709  0.063  1.752               1.729   [9.82, 3.2, 2.42, 2.29]   False           True                  True                    True
10      mad:8      all    start      93     14   8.470  0.084  1.231               1.189   [9.82, 3.2, 2.42, 2.29]    True           True                  True                   False
11      mad:8      all   centre      93     14  15.330  0.084  1.231               1.189   [9.82, 3.2, 2.42, 2.29]    True           True                  True                   False

Result: reproduced. The mean SD of PSTHs over contexts in 93 probes of 14 MGB cells decays with a time constant of 0.060 s (probes running) or 0.079 to 0.080 s (all probes), below 0.1 s in every reading and within tolerance of 0.080 s over all probes. The claim rests on the time constant: the mean SD after 0.5 s equals the fitted constant (1.13 against 1.14 spikes/s; 0.77 against 0.79), but that constant is fitted to the same plateau, so the comparison checks little. The size (5.3 to 12.2 spikes/s against 15.0) and constant (0.79 to 1.14 against 2.0) are lower than the paper's with the authors' detector; with robust thresholds the time constants are 0.063 to 0.090 s and the plateau is within 0.5 of 2.0 for the 5-SD detector.

fig9-example-first-bin¶

In an example MGB unit, the response to a probe differed between contexts only in the first 100-ms bin of the PSTH.

In [26]:
for det, (infos, probes) in mgb.items():
    el = [p for p in probes if p["eligible"]]
    fb = [bool(p["sd"][0] >= 2 * np.max(p["sd"][1:])) for p in el]
    design = [p for p in el if p["n_contexts"] == 3 and 0 in p["contexts"] and p["n_trials"] >= 10]
    fbd = [p for p in design if p["sd"][0] >= 2 * np.max(p["sd"][1:])]
    print(f"{det}: first-bin SD at least twice every later bin in {sum(fb)} of {len(el)} probes "
          f"({sum(fb) / len(el):.3f}); probes with silence and two fragments as contexts: {len(design)}, of which {len(fbd)} pass: "
          f"{[(p['cell'], p['probe']) for p in fbd]}")
    if det == "getspikes":
        for p in design:
            print("   ", p["cell"], "probe", p["probe"], "trials", p["n_trials"], "contexts", p["contexts"],
                  "SD first bins", np.round(p["sd"][:4], 2), "max later", round(float(np.max(p["sd"][1:])), 2))
getspikes: first-bin SD at least twice every later bin in 38 of 93 probes (0.409); probes with silence and two fragments as contexts: 12, of which 4 pass: [('20071010-ha2-003', 4), ('20071010-ha2-003', 5), ('20071010-ha2-003', 6), ('20071010-ha2-003', 7)]
    20071009-ha1-003 probe 4 trials 17 contexts [0, 2, 3] SD first bins [1.48 0.   0.9  0.34] max later 2.07
    20071009-ha1-003 probe 5 trials 17 contexts [0, 1, 3] SD first bins [0.   0.   0.59 0.  ] max later 2.38
    20071009-ha1-003 probe 6 trials 17 contexts [0, 1, 2] SD first bins [1.02 0.68 1.48 0.34] max later 1.48
    20071009-ha1-003 probe 7 trials 17 contexts [0, 1, 2] SD first bins [0.   0.   0.34 1.18] max later 1.48
    20071010-ha2-003 probe 4 trials 10 contexts [0, 2, 3] SD first bins [31.34  5.2   7.23  5.13] max later 11.15
    20071010-ha2-003 probe 5 trials 10 contexts [0, 1, 3] SD first bins [28.69 12.    3.06  5.77] max later 12.0
    20071010-ha2-003 probe 6 trials 10 contexts [0, 1, 2] SD first bins [26.15  7.02  6.11  5.51] max later 12.0
    20071010-ha2-003 probe 7 trials 10 contexts [0, 1, 2] SD first bins [30.17 13.5  11.37 10.5 ] max later 14.73
    20071012-ha1-002 probe 4 trials 10 contexts [0, 2, 3] SD first bins [0.   1.   2.08 1.  ] max later 3.06
    20071012-ha1-002 probe 5 trials 10 contexts [0, 1, 3] SD first bins [2.08 0.58 1.53 1.53] max later 3.79
    20071012-ha1-002 probe 6 trials 10 contexts [0, 1, 2] SD first bins [1.   0.58 0.58 0.58] max later 3.21
    20071012-ha1-002 probe 7 trials 10 contexts [0, 1, 2] SD first bins [2.   0.58 1.53 2.08] max later 4.73
mad:5: first-bin SD at least twice every later bin in 46 of 93 probes (0.495); probes with silence and two fragments as contexts: 12, of which 4 pass: [('20071010-ha2-003', 4), ('20071010-ha2-003', 5), ('20071010-ha2-003', 6), ('20071010-ha2-003', 7)]
mad:8: first-bin SD at least twice every later bin in 47 of 93 probes (0.505); probes with silence and two fragments as contexts: 12, of which 4 pass: [('20071010-ha2-003', 4), ('20071010-ha2-003', 5), ('20071010-ha2-003', 6), ('20071010-ha2-003', 7)]

Result: reproduced. Of the 12 MGB probes heard after silence and two fragments with at least 10 trials, 4 (all in 20071010-ha2-003) have an SD over contexts in the first 100-ms bin at least twice that of every later bin (first bin 26 to 31 spikes/s against at most 11 to 15 later). Over all 93 probes this holds for 38 (0.41); with the robust-threshold detectors for 46 and 47, and among the 12 for the same 4 probes (probes 4 to 7 of 20071010-ha2-003).

fig7-example-frequency-context¶

In an example A1 neuron, a natural sound probe preceded by three DMR contexts that differed only in frequency band gave significant context dependence for about 4 s.

Blocked: no recording has DMR conditioning stimuli in the bands 0.625-2.5, 2.5-10 and 10-40 kHz before a natural probe. The search over the stored bands of every synthetic recording, then every fragment of the recordings whose fragments store the band vector (625, 2500, 10000, 40000): it is one fragment with two bands, 0.625-2.5 and 10-40 kHz ("DMR4: bandwidth 625-2500, 10000-40000 Hz"), in recordings of four DMR (or six TORC) fragments with no natural fragment.

In [27]:
target = {(625.0, 2500.0), (2500.0, 10000.0), (10000.0, 40000.0)}
for i in syn_infos:
    b = sorted({x for x in i["bands"] if x is not None})
    if b:
        print(i["cell"], i["trigger_type"], "bands (Hz):", b, "| has all three Figure 7 bands:", target <= set(b))
nb_torc = [i["cell"] for i in syn_infos if any("bandwidth variants" in d for d in i["descriptions"]) and not any(i["bands"])]
print("TORC bandwidth-variant recordings without stored bands:", nb_torc)
# The recordings whose fragments store the vector (625, 2500, 10000, 40000): every fragment, its kind and description
split = [i_ for i_ in syn_infos if any(b is not None and len(b) == 4 for b in i_["bands"])]
for i_ in split:
    print(i_["member"].split("/")[-1], i_["trigger_type"], "| natural fragments:", i_["kinds"].count("natural"))
    for k, (kind, b, d) in enumerate(zip(i_["kinds"], i_["bands"], i_["descriptions"])):
        print(f"    {k + 1} {kind} ff={b} | {d[:90]}")
20060202-ha2-001 torc bands (Hz): [(np.float64(2500.0), np.float64(40000.0))] | has all three Figure 7 bands: False
20060202-ha2-002 torc bands (Hz): [(np.float64(2500.0), np.float64(40000.0))] | has all three Figure 7 bands: False
20060202-ha3-004 torc bands (Hz): [(np.float64(625.0), np.float64(1250.0), np.float64(5000.0), np.float64(40000.0)), (np.float64(625.0), np.float64(2500.0), np.float64(10000.0), np.float64(40000.0)), (np.float64(625.0), np.float64(5000.0), np.float64(20000.0), np.float64(40000.0)), (np.float64(625.0), np.float64(10000.0)), (np.float64(1250.0), np.float64(20000.0)), (np.float64(2500.0), np.float64(40000.0))] | has all three Figure 7 bands: False
20060212-ha1-001 torc bands (Hz): [(np.float64(625.0), np.float64(1250.0), np.float64(5000.0), np.float64(40000.0)), (np.float64(625.0), np.float64(2500.0), np.float64(10000.0), np.float64(40000.0)), (np.float64(625.0), np.float64(5000.0), np.float64(20000.0), np.float64(40000.0)), (np.float64(625.0), np.float64(10000.0)), (np.float64(1250.0), np.float64(20000.0)), (np.float64(2500.0), np.float64(40000.0))] | has all three Figure 7 bands: False
20060212-ha1-001 torc bands (Hz): [(np.float64(2500.0), np.float64(40000.0))] | has all three Figure 7 bands: False
20060212-ha2-001 torc bands (Hz): [(np.float64(625.0), np.float64(1250.0), np.float64(5000.0), np.float64(40000.0)), (np.float64(625.0), np.float64(2500.0), np.float64(10000.0), np.float64(40000.0)), (np.float64(625.0), np.float64(5000.0), np.float64(20000.0), np.float64(40000.0)), (np.float64(625.0), np.float64(10000.0)), (np.float64(1250.0), np.float64(20000.0)), (np.float64(2500.0), np.float64(40000.0))] | has all three Figure 7 bands: False
20060216-ha2-002 torc bands (Hz): [(np.float64(625.0), np.float64(1250.0), np.float64(5000.0), np.float64(40000.0)), (np.float64(625.0), np.float64(2500.0), np.float64(10000.0), np.float64(40000.0)), (np.float64(625.0), np.float64(5000.0), np.float64(20000.0), np.float64(40000.0)), (np.float64(625.0), np.float64(10000.0)), (np.float64(1250.0), np.float64(20000.0)), (np.float64(2500.0), np.float64(40000.0))] | has all three Figure 7 bands: False
20060320-ha1-001 dmr bands (Hz): [(np.float64(625.0), np.float64(2500.0), np.float64(10000.0), np.float64(40000.0)), (np.float64(625.0), np.float64(10000.0)), (np.float64(1250.0), np.float64(20000.0)), (np.float64(2500.0), np.float64(40000.0))] | has all three Figure 7 bands: False
20060320-ha3-001 dmr bands (Hz): [(np.float64(625.0), np.float64(2500.0), np.float64(10000.0), np.float64(40000.0)), (np.float64(625.0), np.float64(10000.0)), (np.float64(1250.0), np.float64(20000.0)), (np.float64(2500.0), np.float64(40000.0))] | has all three Figure 7 bands: False
20060320-ha3-003 dmr bands (Hz): [(np.float64(625.0), np.float64(2500.0), np.float64(10000.0), np.float64(40000.0)), (np.float64(625.0), np.float64(10000.0)), (np.float64(1250.0), np.float64(20000.0)), (np.float64(2500.0), np.float64(40000.0))] | has all three Figure 7 bands: False
20060321-ha1-001 dmr bands (Hz): [(np.float64(625.0), np.float64(2500.0), np.float64(10000.0), np.float64(40000.0)), (np.float64(625.0), np.float64(10000.0)), (np.float64(1250.0), np.float64(20000.0)), (np.float64(2500.0), np.float64(40000.0))] | has all three Figure 7 bands: False
20060321-ha1-001 dmr bands (Hz): [(np.float64(880.0), np.float64(28160.0))] | has all three Figure 7 bands: False
20060321-ha1-002 dmr bands (Hz): [(np.float64(625.0), np.float64(2500.0), np.float64(10000.0), np.float64(40000.0)), (np.float64(625.0), np.float64(10000.0)), (np.float64(1250.0), np.float64(20000.0)), (np.float64(2500.0), np.float64(40000.0))] | has all three Figure 7 bands: False
20060321-ha2-002 dmr bands (Hz): [(np.float64(880.0), np.float64(28160.0))] | has all three Figure 7 bands: False
20060915-ha1-001 dmr bands (Hz): [(np.float64(3000.0), np.float64(12000.0))] | has all three Figure 7 bands: False
20060916-ha1-001 dmr bands (Hz): [(np.float64(3000.0), np.float64(12000.0))] | has all three Figure 7 bands: False
20060916-ha2-001 dmr bands (Hz): [(np.float64(5000.0), np.float64(20000.0))] | has all three Figure 7 bands: False
20060916-ha3-001 dmr bands (Hz): [(np.float64(5000.0), np.float64(20000.0))] | has all three Figure 7 bands: False
20060916-ha3-002 dmr bands (Hz): [(np.float64(250.0), np.float64(1000.0)), (np.float64(500.0), np.float64(2000.0)), (np.float64(1000.0), np.float64(4000.0)), (np.float64(2000.0), np.float64(8000.0)), (np.float64(4000.0), np.float64(16000.0)), (np.float64(8000.0), np.float64(32000.0))] | has all three Figure 7 bands: False
20060916-ha3-003 dmr bands (Hz): [(np.float64(250.0), np.float64(1000.0)), (np.float64(500.0), np.float64(2000.0)), (np.float64(1000.0), np.float64(4000.0)), (np.float64(2000.0), np.float64(8000.0)), (np.float64(4000.0), np.float64(16000.0)), (np.float64(8000.0), np.float64(32000.0))] | has all three Figure 7 bands: False
20060916-ha4-001 dmr bands (Hz): [(np.float64(250.0), np.float64(1000.0)), (np.float64(500.0), np.float64(2000.0)), (np.float64(1000.0), np.float64(4000.0)), (np.float64(2000.0), np.float64(8000.0)), (np.float64(4000.0), np.float64(16000.0)), (np.float64(8000.0), np.float64(32000.0))] | has all three Figure 7 bands: False
20060916-ha5-002 dmr bands (Hz): [(np.float64(250.0), np.float64(1000.0)), (np.float64(500.0), np.float64(2000.0)), (np.float64(1000.0), np.float64(4000.0)), (np.float64(2000.0), np.float64(8000.0)), (np.float64(4000.0), np.float64(16000.0)), (np.float64(8000.0), np.float64(32000.0))] | has all three Figure 7 bands: False
20060916-ha5-002 dmr bands (Hz): [(np.float64(2500.0), np.float64(10000.0))] | has all three Figure 7 bands: False
20060917-ha1-002 dmr bands (Hz): [(np.float64(250.0), np.float64(1000.0)), (np.float64(500.0), np.float64(2000.0)), (np.float64(1000.0), np.float64(4000.0)), (np.float64(2000.0), np.float64(8000.0)), (np.float64(4000.0), np.float64(16000.0)), (np.float64(8000.0), np.float64(32000.0))] | has all three Figure 7 bands: False
TORC bandwidth-variant recordings without stored bands: ['20060313-ha1-001', '20060313-ha1-002', '20060314-ha1-001', '20060315-ha1-001', '20060315-ha1-002']
20060202-ha3-004-002.mat torc | natural fragments: 0
    1 TORC ff=(np.float64(2500.0), np.float64(40000.0)) | TORCs: bandwidth variants
    2 TORC ff=(np.float64(1250.0), np.float64(20000.0)) | TORCs: bandwidth variants
    3 TORC ff=(np.float64(625.0), np.float64(10000.0)) | TORCs: bandwidth variants
    4 TORC ff=(np.float64(625.0), np.float64(1250.0), np.float64(5000.0), np.float64(40000.0)) | TORCs: bandwidth variants
    5 TORC ff=(np.float64(625.0), np.float64(2500.0), np.float64(10000.0), np.float64(40000.0)) | TORCs: bandwidth variants
    6 TORC ff=(np.float64(625.0), np.float64(5000.0), np.float64(20000.0), np.float64(40000.0)) | TORCs: bandwidth variants
20060212-ha1-001-002.mat torc | natural fragments: 0
    1 TORC ff=(np.float64(2500.0), np.float64(40000.0)) | TORCs: bandwidth variants
    2 TORC ff=(np.float64(1250.0), np.float64(20000.0)) | TORCs: bandwidth variants
    3 TORC ff=(np.float64(625.0), np.float64(10000.0)) | TORCs: bandwidth variants
    4 TORC ff=(np.float64(625.0), np.float64(1250.0), np.float64(5000.0), np.float64(40000.0)) | TORCs: bandwidth variants
    5 TORC ff=(np.float64(625.0), np.float64(2500.0), np.float64(10000.0), np.float64(40000.0)) | TORCs: bandwidth variants
    6 TORC ff=(np.float64(625.0), np.float64(5000.0), np.float64(20000.0), np.float64(40000.0)) | TORCs: bandwidth variants
20060212-ha2-001-002.mat torc | natural fragments: 0
    1 TORC ff=(np.float64(2500.0), np.float64(40000.0)) | TORCs: bandwidth variants
    2 TORC ff=(np.float64(1250.0), np.float64(20000.0)) | TORCs: bandwidth variants
    3 TORC ff=(np.float64(625.0), np.float64(10000.0)) | TORCs: bandwidth variants
    4 TORC ff=(np.float64(625.0), np.float64(1250.0), np.float64(5000.0), np.float64(40000.0)) | TORCs: bandwidth variants
    5 TORC ff=(np.float64(625.0), np.float64(2500.0), np.float64(10000.0), np.float64(40000.0)) | TORCs: bandwidth variants
    6 TORC ff=(np.float64(625.0), np.float64(5000.0), np.float64(20000.0), np.float64(40000.0)) | TORCs: bandwidth variants
20060216-ha2-002-002.mat torc | natural fragments: 0
    1 TORC ff=(np.float64(2500.0), np.float64(40000.0)) | TORCs: bandwidth variants
    2 TORC ff=(np.float64(1250.0), np.float64(20000.0)) | TORCs: bandwidth variants
    3 TORC ff=(np.float64(625.0), np.float64(10000.0)) | TORCs: bandwidth variants
    4 TORC ff=(np.float64(625.0), np.float64(1250.0), np.float64(5000.0), np.float64(40000.0)) | TORCs: bandwidth variants
    5 TORC ff=(np.float64(625.0), np.float64(2500.0), np.float64(10000.0), np.float64(40000.0)) | TORCs: bandwidth variants
    6 TORC ff=(np.float64(625.0), np.float64(5000.0), np.float64(20000.0), np.float64(40000.0)) | TORCs: bandwidth variants
20060320-ha1-001-002.mat dmr | natural fragments: 0
    1 DMR ff=(np.float64(625.0), np.float64(10000.0)) | DMR1: bandwidth 625-10000 Hz, specmod 0 to 1.5 c/o, tempmod -25 to 25 Hz
    2 DMR ff=(np.float64(1250.0), np.float64(20000.0)) | DMR2: bandwidth 1250-20000 Hz, specmod 0 to 1.5 c/o, tempmod -25 to 25 Hz
    3 DMR ff=(np.float64(2500.0), np.float64(40000.0)) | DMR3: bandwidth 2500-40000 Hz, specmod 0 to 1.5 c/o, tempmod -25 to 25 Hz
    4 DMR ff=(np.float64(625.0), np.float64(2500.0), np.float64(10000.0), np.float64(40000.0)) | DMR4: bandwidth 625-2500, 10000-40000 Hz, specmod 0 to 1.5 c/o, tempmod -25 to 25 Hz
20060320-ha3-001-002.mat dmr | natural fragments: 0
    1 DMR ff=(np.float64(625.0), np.float64(10000.0)) | DMR1: bandwidth 625-10000 Hz, specmod 0 to 1.5 c/o, tempmod -25 to 25 Hz
    2 DMR ff=(np.float64(1250.0), np.float64(20000.0)) | DMR2: bandwidth 1250-20000 Hz, specmod 0 to 1.5 c/o, tempmod -25 to 25 Hz
    3 DMR ff=(np.float64(2500.0), np.float64(40000.0)) | DMR3: bandwidth 2500-40000 Hz, specmod 0 to 1.5 c/o, tempmod -25 to 25 Hz
    4 DMR ff=(np.float64(625.0), np.float64(2500.0), np.float64(10000.0), np.float64(40000.0)) | DMR4: bandwidth 625-2500, 10000-40000 Hz, specmod 0 to 1.5 c/o, tempmod -25 to 25 Hz
20060320-ha3-003-002.mat dmr | natural fragments: 0
    1 DMR ff=(np.float64(625.0), np.float64(10000.0)) | DMR1: bandwidth 625-10000 Hz, specmod 0 to 1.5 c/o, tempmod -25 to 25 Hz
    2 DMR ff=(np.float64(1250.0), np.float64(20000.0)) | DMR2: bandwidth 1250-20000 Hz, specmod 0 to 1.5 c/o, tempmod -25 to 25 Hz
    3 DMR ff=(np.float64(2500.0), np.float64(40000.0)) | DMR3: bandwidth 2500-40000 Hz, specmod 0 to 1.5 c/o, tempmod -25 to 25 Hz
    4 DMR ff=(np.float64(625.0), np.float64(2500.0), np.float64(10000.0), np.float64(40000.0)) | DMR4: bandwidth 625-2500, 10000-40000 Hz, specmod 0 to 1.5 c/o, tempmod -25 to 25 Hz
20060321-ha1-001-002.mat dmr | natural fragments: 0
    1 DMR ff=(np.float64(625.0), np.float64(10000.0)) | DMR1: bandwidth 625-10000 Hz, specmod 0 to 1.5 c/o, tempmod -25 to 25 Hz
    2 DMR ff=(np.float64(1250.0), np.float64(20000.0)) | DMR2: bandwidth 1250-20000 Hz, specmod 0 to 1.5 c/o, tempmod -25 to 25 Hz
    3 DMR ff=(np.float64(2500.0), np.float64(40000.0)) | DMR3: bandwidth 2500-40000 Hz, specmod 0 to 1.5 c/o, tempmod -25 to 25 Hz
    4 DMR ff=(np.float64(625.0), np.float64(2500.0), np.float64(10000.0), np.float64(40000.0)) | DMR4: bandwidth 625-2500, 10000-40000 Hz, specmod 0 to 1.5 c/o, tempmod -25 to 25 Hz
20060321-ha1-002-002.mat dmr | natural fragments: 0
    1 DMR ff=(np.float64(625.0), np.float64(10000.0)) | DMR1: bandwidth 625-10000 Hz, specmod 0 to 1.5 c/o, tempmod -25 to 25 Hz
    2 DMR ff=(np.float64(1250.0), np.float64(20000.0)) | DMR2: bandwidth 1250-20000 Hz, specmod 0 to 1.5 c/o, tempmod -25 to 25 Hz
    3 DMR ff=(np.float64(2500.0), np.float64(40000.0)) | DMR3: bandwidth 2500-40000 Hz, specmod 0 to 1.5 c/o, tempmod -25 to 25 Hz
    4 DMR ff=(np.float64(625.0), np.float64(2500.0), np.float64(10000.0), np.float64(40000.0)) | DMR4: bandwidth 625-2500, 10000-40000 Hz, specmod 0 to 1.5 c/o, tempmod -25 to 25 Hz

figs1-silence-probe¶

A subset of cells showed significant context dependence soon after the onset of the intersequence silences, but the response power attributable to the preceding stimulus alone faded within about 1 s after the stimulus ended.

The silence after each sequence as a probe (2.5 s, cut to the shortest gap; CxtDep.m), its context the last fragment of the sequence; significance as for the other probes; power Eq. 17 (main) and Eq. 19 (variant) averaged over the silence probes.

In [28]:
sp = [(c["cell"], c["silence_probe"]) for c in nat_cells if c.get("silence_probe") is not None]
print("natural-sound files with a silence probe (>= 2 contexts, >= 4 trials):", len(sp), "of", len(nat_cells),
      "| cells:", len({c for c, _ in sp}))
early = [(c, s["runs"][0]) for c, s in sp if s["runs"] and s["runs"][0][0] < 0.5]
print("silence probes with a significant period starting within 0.5 s:", len(early), "| cells:", len({c for c, _ in early}))
print("  first periods (s):", [(c, round(float(a), 3), round(float(b), 3)) for c, (a, b) in early])
print("  starting within 0.1 s:", sum(a < 0.1 for _, (a, b) in early), "of", len(early))
pred = asari.population_mean(asari.stack([s for _, s in sp], "predictable"), "running")
inv = asari.population_mean(asari.stack([s for _, s in sp], "invariant"), "running")
dep = pred - inv
tt = np.arange(len(pred)) / 1000
for name, y in [("Eq. 17 (stimulus-related)", pred), ("Eq. 19 (context-dependent)", dep)]:
    y0 = float(np.mean(y[:10]))
    below = np.nonzero(y < 0.1 * y0)[0]
    print(f"{name}: mean over first 10 ms {y0:.3f} mV^2; first time below 10% of it: "
          f"{below[0] / 1000 if len(below) else None} s; at 0.5, 1.0, 1.1, 2.0 s:",
          [round(float(y[int(s * 1000)]), 3) for s in [0.5, 1.0, 1.1, 2.0] if int(s * 1000) < len(y)])
natural-sound files with a silence probe (>= 2 contexts, >= 4 trials): 44 of 46 | cells: 38
silence probes with a significant period starting within 0.5 s: 22 | cells: 19
  first periods (s): [('20051101-ha1-005', 0.028, 0.059), ('20051107-ha1-001', 0.04, 0.078), ('20051126-ha2-002', 0.014, 0.075), ('20051126-ha2-003', 0.087, 0.117), ('20051126-ha2-003', 0.093, 0.112), ('20051126-ha2-003', 0.0, 0.143), ('20051127-ha1-001', 0.001, 0.031), ('20051203-ha1-001', 0.008, 0.026), ('20051207-ha1-002', 0.0, 0.032), ('20051213-ha1-001', 0.169, 0.374), ('20051213-ha1-001', 0.009, 0.037), ('20051215-ha1-001', 0.0, 0.078), ('20051222-ha1-001', 0.227, 0.471), ('20051224-ha2-001', 0.0, 0.029), ('20051225-ha3-001', 0.016, 0.064), ('20051226-ha1-001', 0.086, 0.097), ('20060105-ha1-001', 0.0, 0.082), ('20060225-ha1-001', 0.22, 0.392), ('20060228-ha1-001', 0.0, 0.007), ('20060320-ha3-003', 0.0, 0.013), ('20060329-ha1-001', 0.009, 0.03), ('20061007-ha4-001', 0.0, 0.03)]
  starting within 0.1 s: 19 of 22
Eq. 17 (stimulus-related): mean over first 10 ms 5.594 mV^2; first time below 10% of it: 0.541 s; at 0.5, 1.0, 1.1, 2.0 s: [1.27, -0.182, -0.087, 0.297]
Eq. 19 (context-dependent): mean over first 10 ms 5.791 mV^2; first time below 10% of it: 0.458 s; at 0.5, 1.0, 1.1, 2.0 s: [0.723, -0.347, 0.049, -0.083]

Result: reproduced. Treating the intersequence silence as a probe, 22 silence probes in 19 cells have a significant period starting within 0.5 s of silence onset, 19 of them within the first 0.1 s. The stimulus-related power (Eq. 17) over the 44 silence probes falls from 5.59 mV^2 to below 10% of it at 0.541 s, before 1.1 s; the context-dependent power (Eq. 19) does so at 0.458 s.

Summary¶

claim outcome
methods-recording-counts partially reproduced
a1-mgb-firing-rates partially reproduced (assumption: spike detectors)
fig2-example-reliability reproduced
fig2-example-long-context reproduced (assumption: matching on the mean correlations)
fig3a-proportion-significant not reproduced
fig3a-significance-decay partially reproduced (assumption: non-negative sizes)
fig3b-fractional-power-decay reproduced (assumption: silence as a context)
timescale-longer-than-membrane reproduced
fig4-predictability-upper-bound not reproduced
fig4-strf-performance-low not reproduced (assumptions: pooled validation performance, the cells, the test; strf_wehr.ipynb)
fig5-example-conductances blocked: data missing
fig6-conductance-decay blocked: data missing
fig8a-proportion-by-property not reproduced (assumption: ensembles, Table 1 reading)
fig8b-decay-by-property partially reproduced (assumption: ensembles)
fig8a-significance-fits not reproduced
fig8c-relative-effects partially reproduced (assumption: ensembles)
fig8-natural-synthetic-probes-alike reproduced (assumption: the test)
fig9-mgb-fast-decay reproduced
fig9-example-first-bin reproduced
fig7-example-frequency-context blocked: data missing
figs1-silence-probe reproduced

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

Differences from the paper's method: details the Methods leave open are taken from the authors' scripts shipped with the data (CxtDep.m and its helpers), and the readings the claims file names are all shown above. A1 spikes are detected by a fixed threshold, not by hand. The ensembles of conditioning stimuli that differ in one property are this attempt's reading of the stored stimulus parameters, and Table 1's split by probe type is not reproduced by them. Exponential fits use scipy's least squares with a grid of start values. The STRF analysis (strf_wehr.ipynb) is a reimplementation of the Methods and STRFanalysis.m on the 16 Wehr cells with repeated stimuli (or all 25), not the paper's unnamed 20.

What was found about the data set: it holds the natural-sound A1 data (39 cells, 305 probes), the MGB data (14 cells, 93 probes), the synthetic-sound A1 data and Wehr's recordings, with the authors' analysis scripts, but no voltage-clamp recording: every file, including the unpublished experiment and the tuning curves, is a whole-cell or cell-attached recording in mV. In two cells (20051108-ha1-001 in A1 and 20071010-ha2-005 in MGB) the fragment lists stored with the cell's two files are swapped; each file's stored durations fit the other file's triggers exactly. In 20061201-ha2-001 every sequence trigger is 308 ms longer than its seven stored fragment durations. One synthetic file (20061231-ha2-001) has a sequence presented 3 times against 4 stated effective repeats. The MHT recordings hold natural probes after MHT variants and only 14 MHT probes with property ensembles, against the 178 MHT probe entries of Table 1.

In [29]:
print(f"total run time {(time.time() - T0) / 60:.1f} min; peak memory {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1e6:.1f} GB")
total run time 37.1 min; peak memory 2.5 GB