Reproducing Danish, Aronov & Fee (2017) from CRCNS aa-3ΒΆ
Paper. Danish HH, Aronov D, Fee MS (2017). Rhythmic syllable-related activity in a songbird
motor thalamic nucleus necessary for learned vocalizations. PLoS ONE 12(6): e0169568.
doi:10.1371/journal.pone.0169568. The claims
file (claims/danish-2017.yaml) was written from the version of record (PMC5472270), with the
legends of the supporting information.
Data set. CRCNS aa-3, read from the public bucket
crcnsarchive under aa-3/live/: Electrophysiology.tar.gz (4,254,324,000 bytes, MD5
0a93b3d4c7c2f98e8d29ffcb91842db4) and Lesion_Experiments.tar.gz (5,134,663,426 bytes, MD5
0d4f55eba659b1e3976c3220663e6e9e), as listed in the data set's
checksums.md5. CRCNS data sets are not versioned; the version recorded is unversioned, and
these checksums pin what was read. The paper cites the data set without a version, and there is
only this one copy (aa-3/live/; there is no aa-3/old/). The two archives are streamed once
each (twice for the lesion archive) and reduced as they are read; nothing is written to disk.
What the data set holds. Multiunit recordings in Uva during singing from 3 birds (the paper recorded 5), with the authors' segmentations and labels, and one day of song before and one day after bilateral Uva lesions from 7 birds (the paper's 7 Uva-lesioned birds). There are no control-lesion birds, no directed-song labels in the lesion data, and no sorted single units.
| Claim | Tested here |
|---|---|
| lesion-directed-song-abolished | blocked: metadata insufficient (no recording is marked as directed song) |
| lesion-undirected-rate-similar | tested |
| fig2g-maturity-index-drop | tested |
| fig2f-closer-to-exponential | tested |
| fig2c-small-syllable-peak | tested |
| fig2d-gaps-broader | tested |
| fig2e-rhythmicity-drop | tested |
| fig2e-residual-rhythm-peak | tested |
| figs1-control-lesions-no-effect | blocked: data missing (no control-lesion birds) |
| fig3-antidromic | blocked: other (no stimulus times and no identified units; the artefacts are described below) |
| single-unit-spontaneous-rates | blocked: metadata insufficient (no sorted or identified units) |
| fig4c-call-premotor | tested |
| fig4b-introductory-note-premotor | tested |
| fig4a-elevated-during-song | tested |
| fig5-consistent-across-renditions | tested |
| fig5-consistent-across-sites | tested |
| fig6-peak-before-onset | tested |
| fig6-dip-before-offset | tested |
| fig7a-correlation-with-amplitude | tested |
| spectral-features-weak | tested |
| fig7b-10hz-power-peaks | tested |
| fig7d-10hz-coherence | tested |
| fig8-no-gte-relation | blocked: other (GTE extraction not attempted) |
| fig9-long-syllable-gamma | tested |
| bout-offset-suppression | tested |
| no-motif-bout-signal | tested |
import io
import time
import resource
import warnings
import numpy as np
import pandas as pd
from scipy import stats
import uva
warnings.filterwarnings("ignore", category=RuntimeWarning)
pd.set_option("display.width", 200)
pd.set_option("display.max_columns", 40)
pd.set_option("display.max_rows", 200)
started = time.time()
eph = uva.load_ephys()
print(f"Electrophysiology archive streamed and reduced in {time.time() - started:.0f} s; "
f"peak memory {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1e6:.1f} GB")
Electrophysiology archive streamed and reduced in 238 s; peak memory 5.5 GB
Data check: electrophysiologyΒΆ
files = uva.file_table(eph)
sheet = uva.sheet_table(eph["sheets"])
print("Archive members read:", len(eph["md5"]))
print("Analysis files (dbase) per bird and day, with the recordings each lists:")
print(files.groupby(["bird", "day"]).agg(files=("file", "size"), loaded=("loaded", "sum"),
minutes=("seconds", lambda s: round(s.sum() / 60, 1)), segments=("n_seg", "sum"),
selected=("n_selected", "sum"), song_syllables=("n_song_syl", "sum"), intro=("n_intro", "sum"),
calls=("n_call", "sum"), outside_uva=("outside", "sum"), with_stim=("stim_artefacts", "sum")).to_string())
fs_all = sorted({round(r["fs"], 3) for r in eph["recs"].values()})
print("\nSampling rates of the .dat files (Hz):", fs_all, "; data description: 40,000")
print("Files whose closing sample count is unreadable (rate taken as 40 kHz):", eph.get("bad_tail", []))
print("Neural channel numbers per bird:", {k[0]: r["chans"] for k, r in eph["recs"].items()})
nest = eph["nested_md5"]
same = sum(eph["md5"].get("Electrophysiology/Bird_2-Orange150/" + k) == v for k, v in nest.items())
print(f"\nNested archive Bird_2-Orange150/2013-10-06.tar.gz: {len(nest)} files, {same} identical (MD5) "
"to the files of the folder Bird_2-Orange150/2013-10-06; it is a second copy and is not used.")
dat_md5 = pd.Series({k: v for k, v in eph["md5"].items() if k.endswith(".dat")})
print("Distinct .dat files with identical content elsewhere in the archive:", int(dat_md5.duplicated(keep=False).sum()))
print("\nSpreadsheet rows per sheet tab:")
print(sheet.groupby(["bird", "tab"]).agg(rows=("file", "size"), first=("file", "min"), last=("file", "max"),
depths=("depth", "nunique")).to_string())
print("\nSpreadsheet notes (top 15):")
print(sheet.note.value_counts().head(15).to_string())
Archive members read: 3589
Analysis files (dbase) per bird and day, with the recordings each lists:
files loaded minutes segments selected song_syllables intro calls outside_uva with_stim
bird day
Bird_1-b871 2013-09-08 262 262 85.8 3084 1560 1291 20 110 0 35
2013-09-09 276 276 86.8 3792 2005 1907 0 60 53 10
Bird_2-Orange150 2013-10-05 136 136 36.9 2461 1898 1703 129 0 5 36
2013-10-06 43 43 10.5 379 301 300 0 0 0 11
Bird_3-Uva4 2007-07-25 178 178 27.8 956 485 329 10 86 1 55
Sampling rates of the .dat files (Hz): [np.float64(40000.0)] ; data description: 40,000
Files whose closing sample count is unreadable (rate taken as 40 kHz): ['Electrophysiology/Bird_3-Uva4/2007-07-25/UVA4_d000020_20070725T165953chan2.dat', 'Electrophysiology/Bird_3-Uva4/2007-07-25/UVA4_d000020_20070725T165953chan3.dat', 'Electrophysiology/Bird_3-Uva4/2007-07-25/UVA4_d000020_20070725T165953chan0.dat', 'Electrophysiology/Bird_3-Uva4/2007-07-25/UVA4_d000020_20070725T165953chan1.dat']
Neural channel numbers per bird: {'Bird_2-Orange150': [5, 6, 7], 'Bird_3-Uva4': [1, 2, 3], 'Bird_1-b871': [5, 6, 7]}
Nested archive Bird_2-Orange150/2013-10-06.tar.gz: 173 files, 173 identical (MD5) to the files of the folder Bird_2-Orange150/2013-10-06; it is a second copy and is not used.
Distinct .dat files with identical content elsewhere in the archive: 0
Spreadsheet rows per sheet tab:
rows first last depths
bird tab
Bird_1-b871 September 8, 2013 247 1 247 9
September 9, 2013 248 1 248 5
Bird_2-Orange150 October 5, 2013 134 1 134 8
October 6, 2016 43 1 43 5
Bird_3-Uva4 October 6, 2016 56 4 167 9
Spreadsheet notes (top 15):
note
song undirected 278
undirected song 205
distance calls 37
calls 33
spontaneous activity 32
stim 150uA 26
15
song 12
undirected song calls 7
stim 200uA 7
noise 6
stim 6
chirps 6
intro notes 4
stim 200uA 4
lab = files.groupby(["bird"]).agg(n=("file", "size")).index.tolist()
titles = {}
for (bird, day), db in eph["dbase"].items():
for f in db["files"]:
for t, s in zip(f["titles"], f["selected"]):
titles.setdefault(bird, {}).setdefault((t if t else "(none)", bool(s)), 0)
titles[bird][(t if t else "(none)", bool(s))] += 1
for bird, c in titles.items():
print(bird, "segment labels (label, selected): count")
print(" ", dict(sorted(c.items(), key=lambda kv: -kv[1])))
# Durations of the labels, to say what they are.
rows = []
for bird in sorted(titles):
for ev in uva.events(eph, bird):
for t, a, b, s in zip(ev["title"], ev["on"], ev["off"], ev["sel"]):
rows.append({"bird": bird, "label": t if t else "(none)", "selected": s, "dur": b - a})
lab = pd.DataFrame(rows)
print("\nMedian duration (ms) by bird and label, selected segments:")
print(lab[lab.selected].groupby(["bird", "label"]).dur.agg(["size", "median"]).round(0).to_string())
Bird_2-Orange150 segment labels (label, selected): count
{('(none)', False): 450, ('d', True): 291, ('c', True): 290, ('e', True): 277, ('f', True): 261, ('g', True): 250, ('h', True): 239, ('b', True): 199, ('a', True): 196, ('i', True): 129, ('(none)', True): 67, ('g', False): 28, ('c', False): 27, ('d', False): 26, ('e', False): 24, ('f', False): 23, ('h', False): 23, ('a', False): 19, ('b', False): 17, ('i', False): 4}
Bird_3-Uva4 segment labels (label, selected): count
{('(none)', False): 470, ('k', True): 86, ('(none)', True): 60, ('a', True): 58, ('b', True): 58, ('c', True): 58, ('d', True): 54, ('e', True): 54, ('f', True): 47, ('i', True): 10, ('f', False): 1}
Bird_1-b871 segment labels (label, selected): count
{('(none)', False): 3251, ('a', True): 1402, ('c', True): 759, ('b', True): 698, ('d', True): 335, ('(none)', True): 177, ('k', True): 170, ('i', True): 20, ('a', False): 19, ('c', False): 12, ('b', False): 10, ('0', False): 8, ('d', False): 6, ('e', True): 2, ('\\', True): 1, ('k', False): 1, ('f', True): 1, ('e', False): 1, ('h', False): 1, ('i', False): 1, ('`', False): 1}
Median duration (ms) by bird and label, selected segments:
size median
bird label
Bird_1-b871 (none) 177 83.0
\ 1 349.0
a 1402 90.0
b 698 293.0
c 759 70.0
d 335 198.0
e 2 242.0
f 1 92.0
i 20 73.0
k 170 214.0
Bird_2-Orange150 (none) 67 73.0
a 196 163.0
b 199 149.0
c 290 81.0
d 291 104.0
e 277 161.0
f 261 128.0
g 250 182.0
h 239 149.0
i 129 61.0
Bird_3-Uva4 (none) 60 63.0
a 58 64.0
b 58 281.0
c 58 54.0
d 54 123.0
e 54 45.0
f 47 146.0
i 10 53.0
k 86 138.0
The labels are not described in the data descriptor beyond "syllable name". The data say what they are: letters a to h (Orange150), a to d (b871) and a to f (Uva4) are the motif syllables, "i" occurs at the start of bouts before "a" (introductory notes), and "k" is a sound of about 210 ms that makes up the files the spreadsheets mark as "distance calls" (b871, Uva4). The descriptor says that introductory notes and calls are unselected; in the files, "i" and "k" are selected. Orange150 has no call labels.
Which neural channel. Each recording has a sound channel and three neural channels (5, 6 and
7, or 1, 2 and 3 for Uva4). The paper describes a single electrode, and neither the descriptor
nor the files say which channel is the Uva electrode (the plotting script asks the user to
choose 1 to 3). The cell below shows, for each bird and channel, the syllable-onset-aligned MUA.
The channel used is, for each bird, the one with the largest range of the onset-aligned average
(an assumption; stated with the claims that rest on it, which show the other channels too). The
analysis files list files for all three channels (ChannelFiles, which the data set's
process_recording.m reads as the neural channels), so they do not settle it. One analysis
file, Orange150's first day, ran its event detectors (threshold crossings and stimulus
detection) on channel 7, the channel chosen here for that bird. The choice uses the syllable
modulation that later claims measure; the fig6 section shows the latencies on every channel.
def song_events(bird, exclude_outside=True):
"""Song files of a bird: selected syllables other than introductory notes and calls."""
out = []
for ev in uva.events(eph, bird):
if exclude_outside and any(ev["props"].get(p, False) for p in uva.OUTSIDE_FLAGS):
continue
song = ev["sel"] & ~np.isin(ev["title"], ["i", "k", ""])
if song.sum() >= 3:
out.append(ev)
return out
BIRDS = ["Bird_1-b871", "Bird_2-Orange150", "Bird_3-Uva4"]
chan_rows = []
for bird in BIRDS:
evs = song_events(bird)
nch = len(eph["recs"][evs[0]["key"]]["chans"])
for ci in range(nch):
rows_ = []
for ev in evs:
r = eph["recs"][ev["key"]]
m = r["mua"][ci]
song = ev["sel"] & ~np.isin(ev["title"], ["i", "k", ""])
a, _ = uva.aligned(m / m.mean(), ev["on"][song], 150, 150)
rows_.append(a)
A = np.concatenate(rows_).mean(0)
chan_rows.append({"bird": bird, "channel": eph["recs"][evs[0]["key"]]["chans"][ci],
"onsets": sum(len(x) for x in rows_), "range": A.max() - A.min(),
"peak_ms": int(np.argmax(A[100:150]) - 50), "mean_-150_-100": A[:50].mean()})
chan_tab = pd.DataFrame(chan_rows)
print("Syllable-onset-aligned MUA (each file's MUA divided by its mean), per channel:")
print(chan_tab.round(3).to_string(index=False))
CHAN = {b: int(chan_tab[chan_tab.bird == b].sort_values("range").iloc[-1].channel) for b in BIRDS}
CI = {b: eph["recs"][song_events(b)[0]["key"]]["chans"].index(CHAN[b]) for b in BIRDS}
print("\nChannel used per bird:", CHAN)
print("\nWhat the analysis files say about the neural channels (ChannelFiles lists that are not empty, which "
"process_recording.m of the data set reads as the neural channels; event detectors and their source):")
for (bird, day), db in sorted(eph["dbase"].items()):
print(f" {bird} {day}: channels with files {sorted(db['channel_files'])}; "
f"event detectors {db['event_detectors']} on {db['event_sources']}")
r0 = eph["recs"][song_events("Bird_2-Orange150")[0]["key"]]
cc = np.corrcoef(np.stack([r0["mua"][i] for i in range(3)]))
print("Correlation of the three MUA traces in one Orange150 song file:\n", cc.round(3))
Syllable-onset-aligned MUA (each file's MUA divided by its mean), per channel:
bird channel onsets range peak_ms mean_-150_-100
Bird_1-b871 5 2135 0.076 -9 0.984
Bird_1-b871 6 2135 0.718 -13 1.324
Bird_1-b871 7 2135 0.318 -18 1.143
Bird_2-Orange150 5 1931 0.176 -50 1.033
Bird_2-Orange150 6 1931 0.174 -50 1.033
Bird_2-Orange150 7 1931 0.988 -16 1.652
Bird_3-Uva4 1 317 0.077 -50 0.971
Bird_3-Uva4 2 317 0.127 -29 1.077
Bird_3-Uva4 3 317 1.302 -22 1.426
Channel used per bird: {'Bird_1-b871': 6, 'Bird_2-Orange150': 7, 'Bird_3-Uva4': 3}
What the analysis files say about the neural channels (ChannelFiles lists that are not empty, which process_recording.m of the data set reads as the neural channels; event detectors and their source):
Bird_1-b871 2013-09-08: channels with files [5, 6, 7]; event detectors [] on []
Bird_1-b871 2013-09-09: channels with files [5, 6, 7]; event detectors [] on []
Bird_2-Orange150 2013-10-05: channels with files [5, 6, 7]; event detectors ['ThresholdCrossings', 'StimDetection'] on ['Channel 7', 'Channel 7']
Bird_2-Orange150 2013-10-06: channels with files [5, 6, 7]; event detectors [] on []
Bird_3-Uva4 2007-07-25: channels with files [1, 2, 3]; event detectors [] on []
Correlation of the three MUA traces in one Orange150 song file:
[[1. 1. 0.535]
[1. 1. 0.535]
[0.535 0.535 1. ]]
Clock check. Sound and neural channels are separate files per recording, each with its own header. They share a clock if the syllable labels, made on the sound, line up with the neural signal. The cell below decodes song from MUA: within song files, the MUA in 50 ms windows before syllable onsets against the MUA at random times inside bouts, with the true onsets and with the onsets shifted by 0.5 to 2 s.
rng = np.random.default_rng(11)
for bird in BIRDS:
out = {}
for shift in [0, 500, 1000, 2000]:
auc = []
for ev in song_events(bird):
m = eph["recs"][ev["key"]]["mua"][CI[bird]]
song = ev["sel"] & ~np.isin(ev["title"], ["i", "k", ""])
on = ev["on"][song] + shift
on = on[(on > 60) & (on < len(m) - 1)]
if len(on) < 3:
continue
pre = np.array([m[int(t) - 40:int(t)].mean() for t in on])
inb = np.concatenate([np.arange(int(a), int(b)) for a, b, _ in ev["bouts"]])
inb = inb[(inb > 60) & (inb < len(m))]
rnd = np.array([m[t - 40:t].mean() for t in rng.choice(inb, len(on))])
auc.append(np.mean(pre[:, None] > rnd[None, :]))
out[shift] = np.mean(auc)
print(bird, "probability that pre-onset MUA exceeds MUA at a random time in a bout; by onset shift (ms):",
{k: round(v, 3) for k, v in out.items()})
Bird_1-b871 probability that pre-onset MUA exceeds MUA at a random time in a bout; by onset shift (ms): {0: np.float64(0.679), 500: np.float64(0.436), 1000: np.float64(0.246), 2000: np.float64(0.23)}
Bird_2-Orange150 probability that pre-onset MUA exceeds MUA at a random time in a bout; by onset shift (ms): {0: np.float64(0.64), 500: np.float64(0.45), 1000: np.float64(0.348), 2000: np.float64(0.191)}
Bird_3-Uva4 probability that pre-onset MUA exceeds MUA at a random time in a bout; by onset shift (ms): {0: np.float64(0.828), 500: np.float64(0.572), 1000: np.float64(0.444), 2000: np.float64(0.365)}
Electrophysiology claimsΒΆ
Common choices for this part, each from the claims file or the paper:
- MUA is the chosen channel of each bird (assumption above), from song files at sites inside Uva (files whose properties mark them above, below or outside Uva are left out).
- Bouts are vocal segments with gaps of at most 300 ms (Methods, Sound analysis).
- The shuffled baseline is reading (a) of the claims file header: averages of the same number of windows taken at random times inside bouts (for the bout-offset claim, outside singing), 1000 times; the band is the 2.5 and 97.5 percentiles of the shuffles' minima and maxima over the window (-150 to +150 ms here, a standard choice). Reading (b), MUA circularly shifted within each bout, is run for the syllable-onset and offset claims.
- Values are per bird and then averaged over the 3 birds; the paper averages over 5.
PRE, POST = 150, 150
LAGS = np.arange(-PRE, POST + 1)
def bird_traces(bird, ci=None):
ci = CI[bird] if ci is None else ci
return [(ev, eph["recs"][ev["key"]]["mua"][ci]) for ev in song_events(bird)]
def inside_bout_pool(bird, ci=None):
pool = []
for ev, m in bird_traces(bird, ci):
t = np.concatenate([np.arange(int(a), int(b)) for a, b, _ in ev["bouts"]])
t = t[(t >= PRE) & (t < len(m) - POST - 1)]
if len(t):
pool.append((m, t))
return pool
def event_average(bird, times_of, ci=None):
rows = []
for ev, m in bird_traces(bird, ci):
a, _ = uva.aligned(m, times_of(ev), PRE, POST)
rows.append(a)
A = np.concatenate(rows)
return A
def circ_shift_band(bird, times_of, n_shuffle, rng, ci=None):
"""Shuffled baseline reading (b): MUA circularly shifted within each bout relative to the
event times; band of the shuffles' minima and maxima (2.5 and 97.5 percentiles). The windows
are cut from the shifted bout taken as periodic, so the 150 ms before and after each event
come from shifted bout activity too (events at a bout's start see the bout's shifted end)."""
items = []
for ev, m in bird_traces(bird, ci):
t = times_of(ev)
for a, b, _ in ev["bouts"]:
a, b = int(a), int(b)
sel = t[(t >= a) & (t < b)]
if len(sel) and a - PRE >= 0 and b + POST < len(m):
items.append((m[a - PRE:b + POST], sel - a + PRE, b - a))
mins, maxs, means = [], [], []
for _ in range(n_shuffle):
acc = np.zeros(PRE + POST + 1); n = 0
for seg, tt, L in items:
core = seg[PRE:PRE + L]
sh = np.roll(core, rng.integers(L))
full = np.take(sh, np.arange(-PRE, L + POST), mode="wrap")
a, ok = uva.aligned(full, tt, PRE, POST)
acc += a.sum(0); n += len(a)
avg = acc / n
means.append(avg.mean()); mins.append(avg.min()); maxs.append(avg.max())
return float(np.mean(means)), np.percentile(mins, 2.5), np.percentile(maxs, 97.5)
AVG = {} # (event name, bird, shuffle) -> (average, level, band low, band high), for the figure
def latency_table(times_of, direction, n_shuffle=1000, seed=0, readings=("a",), ci_of=None, name=None):
rows = []
for bird in BIRDS:
rng = np.random.default_rng(seed)
ci = None if ci_of is None else ci_of[bird]
A = event_average(bird, times_of, ci)
avg = A.mean(0)
n_ev = len(A)
for rd in readings:
if rd == "a":
level, lo, hi = uva.shuffle_band(inside_bout_pool(bird, ci), n_ev, PRE, POST, n_shuffle, rng)
else:
level, lo, hi = circ_shift_band(bird, times_of, n_shuffle, rng, ci)
if name:
AVG[(name, bird, rd)] = (avg, level, lo, hi)
thr = hi if direction == "up" else lo
t_ext, t_cross = uva.crossing_before(avg, LAGS, 0, thr, direction)
rows.append({"bird": bird, "shuffle": rd, "events": n_ev, "extreme_ms": t_ext,
"leaves_band_ms": t_cross, "avg_level": level, "band_lo": lo, "band_hi": hi,
"extreme_value": avg[LAGS == t_ext][0]})
return pd.DataFrame(rows)
fig4c-call-premotorΒΆ
Uva activity rises sharply just before distance calls, leaving baseline 30 ms and peaking 15 ms before call onset.
Calls are the segments labelled "k" (b871 and Uva4; Orange150 has none). Calls occur outside song bouts, so the baseline windows are drawn from the call files themselves (random times in the call files) as well as from inside bouts, the claims file's reading; both are shown.
def call_events(bird):
out = []
for ev in uva.events(eph, bird):
if any(ev["props"].get(p, False) for p in uva.OUTSIDE_FLAGS):
continue
k = ev["sel"] & (ev["title"] == "k")
if k.sum():
out.append((ev, eph["recs"][ev["key"]]["mua"][CI[bird]], ev["on"][k]))
return out
rows = []
for bird in BIRDS:
ce = call_events(bird)
if not ce:
rows.append({"bird": bird, "calls": 0}); continue
A = np.concatenate([uva.aligned(m, t, PRE, POST)[0] for _, m, t in ce])
avg = A.mean(0)
for base in ["inside bouts (claims file)", "call files"]:
rng = np.random.default_rng(1)
if base.startswith("inside"):
level, lo, hi = uva.shuffle_band(inside_bout_pool(bird), len(A), PRE, POST, 1000, rng)
else:
pool = [(m, np.arange(PRE, len(m) - POST - 1)) for _, m, _ in ce]
level, lo, hi = uva.shuffle_band(pool, len(A), PRE, POST, 1000, rng)
t_pk, t_cross = uva.crossing_before(avg, LAGS, 0, hi, "up")
if base.startswith("inside"):
AVG[("calls", bird, "a")] = (avg, level, lo, hi)
rows.append({"bird": bird, "calls": len(A), "baseline": base, "peak_ms": t_pk, "leaves_band_ms": t_cross,
"peak": avg[LAGS == t_pk][0], "band_hi": hi, "avg_level": level})
calls_tab = pd.DataFrame(rows)
print(calls_tab.round(4).to_string(index=False))
for base in calls_tab.baseline.dropna().unique():
s = calls_tab[calls_tab.baseline == base]
crossed = s[s.leaves_band_ms.notna()].bird.tolist()
print(f"{base}: latency of peak, mean over {s.peak_ms.notna().sum()} birds with calls, {-s.peak_ms.mean():.1f} ms "
f"(paper 15 +- 5); latency from baseline, mean over the {len(crossed)} birds that leave the band "
f"{crossed}: {-s.leaves_band_ms.mean():.1f} ms (paper 30 +- 7)")
bird calls baseline peak_ms leaves_band_ms peak band_hi avg_level
Bird_1-b871 145 inside bouts (claims file) -13.0 NaN 0.0486 0.0712 0.0330
Bird_1-b871 145 call files -13.0 NaN 0.0486 0.0818 0.0263
Bird_2-Orange150 0 NaN NaN NaN NaN NaN NaN
Bird_3-Uva4 86 inside bouts (claims file) -17.0 -22.0 0.0821 0.0679 0.0370
Bird_3-Uva4 86 call files -17.0 NaN 0.0821 0.0939 0.0275
inside bouts (claims file): latency of peak, mean over 2 birds with calls, 15.0 ms (paper 15 +- 5); latency from baseline, mean over the 1 birds that leave the band ['Bird_3-Uva4']: 22.0 ms (paper 30 +- 7)
call files: latency of peak, mean over 2 birds with calls, 15.0 ms (paper 15 +- 5); latency from baseline, mean over the 0 birds that leave the band []: nan ms (paper 30 +- 7)
Result: partially reproduced (assumed channel). The call-aligned MUA peaks 13 ms (b871, 145 calls) and 17 ms (Uva4, 86 calls) before onset, mean 15.0 ms over the two birds with labelled calls (paper 15 +- 5). Only Uva4 leaves the inside-bout band before onset, at 22 ms (paper 30 +- 7), so the latency from baseline is that one bird's value; b871 never exceeds the band (peak 0.0486 against 0.0712), and neither bird does against the band drawn from the call files. Orange150 has no calls labelled.
fig4b-introductory-note-premotorΒΆ
Uva is robustly active before each introductory note, leaving baseline 39 ms and peaking 21 ms before note onset.
def intro_on(ev):
return ev["on"][ev["sel"] & (ev["title"] == "i")]
intro_tab = latency_table(intro_on, "up", readings=("a", "b"), name="introductory notes")
print(intro_tab.round(4).to_string(index=False))
for rd in ["a", "b"]:
s = intro_tab[intro_tab.shuffle == rd]
crossed = s[s.leaves_band_ms.notna()].bird.tolist()
print(f"shuffle {rd}: peak, mean over 3 birds, {-s.extreme_ms.mean():.1f} ms (paper 21 +- 9); latency from "
f"baseline, mean over the {len(crossed)} birds that leave the band {crossed}: "
f"{-s.leaves_band_ms.mean():.1f} ms (paper 39 +- 8)")
bird shuffle events extreme_ms leaves_band_ms avg_level band_lo band_hi extreme_value
Bird_1-b871 a 20 -20.0 NaN 0.0328 0.0240 0.2304 0.0359
Bird_1-b871 b 20 -20.0 NaN 0.0293 0.0235 0.0737 0.0359
Bird_2-Orange150 a 113 -24.0 NaN 0.0532 0.0470 0.0948 0.0747
Bird_2-Orange150 b 113 -24.0 -36.0 0.0532 0.0481 0.0631 0.0747
Bird_3-Uva4 a 10 -26.0 NaN 0.0367 0.0215 0.2706 0.0734
Bird_3-Uva4 b 10 -26.0 -38.0 0.0416 0.0222 0.0642 0.0734
shuffle a: peak, mean over 3 birds, 23.3 ms (paper 21 +- 9); latency from baseline, mean over the 0 birds that leave the band []: nan ms (paper 39 +- 8)
shuffle b: peak, mean over 3 birds, 23.3 ms (paper 21 +- 9); latency from baseline, mean over the 2 birds that leave the band ['Bird_2-Orange150', 'Bird_3-Uva4']: 37.0 ms (paper 39 +- 8)
Result: partially reproduced (assumed channel). The introductory-note-aligned MUA peaks 23.3 ms before onset, averaged over the 3 birds (paper 21 +- 9). Under shuffle reading (b), with the 150 ms around each note now cut from the shifted bout, Orange150 (113 notes) and Uva4 (10) leave the band 36 and 38 ms before onset (mean 37.0 ms over these two birds; paper 39 +- 8); b871 (20 notes) does not leave it. Under reading (a) no bird does, as the band for maxima is wide with so few notes.
fig4a-elevated-during-songΒΆ
During bouts of singing Uva activity is persistently elevated and modulated in a way locked to song.
Per recording site (depth), mean MUA inside bouts against mean MUA more than 300 ms from any vocal segment in the same files. Sites are the depths of the spreadsheets (b871, Orange150) or the depth properties of the analysis file (Uva4).
def site_of(ev):
bird, day, f = ev["key"]
if bird == "Bird_3-Uva4":
d = [k for k, v in ev["props"].items() if v and k.replace(".", "").isdigit()]
return d[0] if d else None
s = sheet[(sheet.bird == bird) & (sheet.day == day) & (sheet.file == f)]
return f"{day} {s.depth.iloc[0]}" if len(s) and np.isfinite(s.depth.iloc[0]) else None
rows = []
for bird in BIRDS:
for ci in range(3):
for ev, m in bird_traces(bird, ci):
alls = np.zeros(len(m), bool)
for a, b in zip(ev["on"], ev["off"]):
alls[max(0, int(a) - 300):int(b) + 300] = True
inb = np.zeros(len(m), bool)
for a, b, _ in ev["bouts"]:
inb[int(a):int(b)] = True
if (~alls).sum() < 200 or inb.sum() < 200:
continue
rows.append({"bird": bird, "channel": eph["recs"][ev["key"]]["chans"][ci], "site": site_of(ev),
"inside": m[inb].mean(), "outside": m[~alls].mean(), "ms_out": int((~alls).sum())})
el = pd.DataFrame(rows)
site_el = el.groupby(["bird", "channel", "site"]).agg(files=("inside", "size"), inside=("inside", "mean"),
outside=("outside", "mean")).reset_index()
site_el["ratio"] = site_el.inside / site_el.outside
main_el = site_el[[CHAN[b] == c for b, c in zip(site_el.bird, site_el.channel)]]
print("Chosen channels, per site:")
print(main_el.round(4).to_string(index=False))
t = stats.ttest_rel(main_el.inside, main_el.outside)
print(f"\nSites higher inside bouts: {(main_el.inside > main_el.outside).sum()} of {len(main_el)}; "
f"paired t-test over sites t = {t.statistic:.2f}, p = {t.pvalue:.2g}")
print("\nAll channels, sites higher inside bouts / sites:")
print(site_el.groupby(["bird", "channel"]).apply(lambda d: f"{(d.inside > d.outside).sum()}/{len(d)}, median ratio {d.ratio.median():.2f}").to_string())
Chosen channels, per site:
bird channel site files inside outside ratio
Bird_1-b871 6 2013-09-08 806.92 2 0.0304 0.0230 1.3206
Bird_1-b871 6 2013-09-08 834.68 9 0.0364 0.0251 1.4480
Bird_1-b871 6 2013-09-08 864.48 23 0.0286 0.0200 1.4309
Bird_1-b871 6 2013-09-08 960.8 39 0.0344 0.0232 1.4837
Bird_1-b871 6 2013-09-09 1082.44 2 0.0164 0.0158 1.0393
Bird_1-b871 6 2013-09-09 546.12 1 0.0215 0.0188 1.1422
Bird_1-b871 6 2013-09-09 835.1 45 0.0358 0.0231 1.5468
Bird_2-Orange150 7 2013-10-05 537.34 29 0.0511 0.0270 1.8892
Bird_2-Orange150 7 2013-10-05 586.12 39 0.0571 0.0310 1.8413
Bird_2-Orange150 7 2013-10-05 652.24 12 0.0313 0.0270 1.1602
Bird_2-Orange150 7 2013-10-06 533.84 22 0.0600 0.0283 2.1200
Bird_3-Uva4 3 1540 2 0.0409 0.0253 1.6181
Bird_3-Uva4 3 1610 3 0.0386 0.0225 1.7155
Bird_3-Uva4 3 1655 1 0.0458 0.0215 2.1251
Bird_3-Uva4 3 1680 1 0.0362 0.0215 1.6836
Bird_3-Uva4 3 1709 1 0.0435 0.0269 1.6167
Bird_3-Uva4 3 1849 1 0.0281 0.0184 1.5329
Bird_3-Uva4 3 1872 2 0.0369 0.0232 1.5903
Sites higher inside bouts: 18 of 18; paired t-test over sites t = 7.09, p = 1.8e-06
All channels, sites higher inside bouts / sites:
bird channel
Bird_1-b871 5 6/7, median ratio 1.04
6 7/7, median ratio 1.43
7 7/7, median ratio 1.19
Bird_2-Orange150 5 3/4, median ratio 1.04
6 3/4, median ratio 1.04
7 4/4, median ratio 1.87
Bird_3-Uva4 1 4/7, median ratio 1.01
2 7/7, median ratio 1.09
3 7/7, median ratio 1.62
Result: reproduced (assumed channel). On the chosen channels, mean MUA inside bouts is higher than outside singing at all 18 sites (paired t-test over sites p = 1.8e-06; ratios 1.04 to 2.13). The other channels are higher at most sites too, by less.
fig6-peak-before-onset and fig6-dip-before-offsetΒΆ
Uva activity rises significantly before syllable onsets in every bird, peaking 20 ms before onset and rising above its average level during singing 32 ms before onset.
Uva activity falls significantly before syllable offsets in every bird, reaching a minimum 18 ms before offset and dropping below its average level during singing 48 ms before offset.
Syllables are the selected song syllables (motif letters; introductory notes and calls are separate claims).
def syl_mask(ev):
return ev["sel"] & ~np.isin(ev["title"], ["i", "k", ""])
def syl_on(ev):
return ev["on"][syl_mask(ev)]
def syl_off(ev):
return ev["off"][syl_mask(ev)]
on_tab = latency_table(syl_on, "up", readings=("a", "b"), name="syllable onsets")
print(on_tab.round(4).to_string(index=False))
for rd in ["a", "b"]:
s = on_tab[on_tab.shuffle == rd]
print(f"shuffle {rd}: mean over birds, peak {-s.extreme_ms.mean():.1f} ms (SEM {s.extreme_ms.sem():.1f}), "
f"rises above band {-s.leaves_band_ms.mean():.1f} ms (SEM {s.leaves_band_ms.sem():.1f}) "
"(paper 20 +- 2 and 32 +- 5, SEM)")
def paired_tests(win_of, ref, bird):
"""Per rendition: mean MUA in the window against the rendition's bout mean (a) or the
reference window (b)."""
x, ya, yb = [], [], []
for ev, m in bird_traces(bird):
idx = np.where(syl_mask(ev))[0]
for i in idx:
w0, w1 = win_of(ev, i)
if w0 < 0 or w1 > len(m):
continue
bt = [(a, b) for a, b, _ in ev["bouts"] if a <= ev["on"][i] <= b]
r = ref(ev, i)
if not bt or r is None or r[0] < 0 or r[1] > len(m):
continue
x.append(m[int(w0):int(w1)].mean())
ya.append(m[int(bt[0][0]):int(bt[0][1])].mean())
yb.append(m[int(r[0]):int(r[1])].mean())
x, ya, yb = map(np.array, (x, ya, yb))
ta, tb = stats.ttest_rel(x, ya), stats.ttest_rel(x, yb)
return {"bird": bird, "n": len(x), "mean_window": x.mean(), "mean_bout": ya.mean(), "t_a": ta.statistic,
"p_a": ta.pvalue, "mean_ref_b": yb.mean(), "t_b": tb.statistic, "p_b": tb.pvalue}
def prev_offset_window(ev, i):
if i == 0:
return None
o = ev["off"][i - 1]
return (o - 20, o + 20)
# The same latencies on every channel (shuffle a), to show how they depend on the channel choice.
ch_rows = []
for ci in range(3):
t_ = latency_table(syl_on, "up", readings=("a",), ci_of={b: ci for b in BIRDS})
for _, r in t_.iterrows():
ch_rows.append({"bird": r.bird, "channel": eph["recs"][song_events(r.bird)[0]["key"]]["chans"][ci],
"chosen": ci == CI[r.bird], "peak_ms": r.extreme_ms, "rises_above_band_ms": r.leaves_band_ms})
ch_lat = pd.DataFrame(ch_rows)
print("\nOnset latencies on each channel (shuffle a):")
print(ch_lat.to_string(index=False))
print("Channels whose average rises above the band before onset:",
ch_lat.dropna(subset=["rises_above_band_ms"])[["bird", "channel"]].values.tolist())
tests_on = pd.DataFrame([paired_tests(lambda ev, i: (ev["on"][i] - 40, ev["on"][i]), prev_offset_window, b)
for b in BIRDS])
print("\nPaired t-tests, 40 ms before onset against (a) the bout mean, (b) 40 ms centred on the preceding offset:")
print(tests_on.to_string(index=False))
bird shuffle events extreme_ms leaves_band_ms avg_level band_lo band_hi extreme_value
Bird_1-b871 a 2135 -13.0 -25.0 0.0330 0.0307 0.0386 0.0424
Bird_1-b871 b 2135 -13.0 -29.0 0.0327 0.0319 0.0347 0.0424
Bird_2-Orange150 a 1931 -16.0 -27.0 0.0533 0.0508 0.0582 0.0743
Bird_2-Orange150 b 1931 -16.0 -27.0 0.0545 0.0530 0.0577 0.0743
Bird_3-Uva4 a 317 -22.0 -32.0 0.0371 0.0331 0.0487 0.0712
Bird_3-Uva4 b 317 -22.0 -31.0 0.0396 0.0356 0.0507 0.0712
shuffle a: mean over birds, peak 17.0 ms (SEM 2.6), rises above band 28.0 ms (SEM 2.1) (paper 20 +- 2 and 32 +- 5, SEM)
shuffle b: mean over birds, peak 17.0 ms (SEM 2.6), rises above band 29.0 ms (SEM 1.2) (paper 20 +- 2 and 32 +- 5, SEM)
Onset latencies on each channel (shuffle a):
bird channel chosen peak_ms rises_above_band_ms
Bird_1-b871 5 False -9.0 NaN
Bird_2-Orange150 5 False -86.0 NaN
Bird_3-Uva4 1 False -53.0 NaN
Bird_1-b871 6 True -13.0 -25.0
Bird_2-Orange150 6 False -86.0 NaN
Bird_3-Uva4 2 False -55.0 NaN
Bird_1-b871 7 False -18.0 NaN
Bird_2-Orange150 7 True -16.0 -27.0
Bird_3-Uva4 3 True -22.0 -32.0
Channels whose average rises above the band before onset: [['Bird_1-b871', 6], ['Bird_2-Orange150', 7], ['Bird_3-Uva4', 3]]
Paired t-tests, 40 ms before onset against (a) the bout mean, (b) 40 ms centred on the preceding offset:
bird n mean_window mean_bout t_a p_a mean_ref_b t_b p_b
Bird_1-b871 2136 0.037892 0.032713 47.602173 0.0 0.025130 77.067360 0.000000e+00
Bird_2-Orange150 1931 0.060641 0.054488 41.480427 0.0 0.052383 34.834469 0.000000e+00
Bird_3-Uva4 316 0.052899 0.039712 34.283199 0.0 0.046894 11.477045 1.040776e-25
Result: partially reproduced (assumed channel). MUA before syllable onsets is higher than the bout mean and than the preceding offset in every bird (paired t-tests, p below 1e-24 in each bird, both readings). Averaged over the 3 birds the peak is 17.0 ms before onset (paper 20 +- 2; outside the tolerance) and the average rises above the band 28.0 ms (shuffle a) or 29.0 ms (shuffle b) before onset (paper 32 +- 5; within). On the other channels no average rises above the band before onset; b871's channel 7 peaks 18 ms before onset against 13 ms on channel 6, so the peak time depends on the channel.
off_tab = latency_table(syl_off, "down", readings=("a", "b"), name="syllable offsets")
print(off_tab.round(4).to_string(index=False))
for rd in ["a", "b"]:
s = off_tab[off_tab.shuffle == rd]
print(f"shuffle {rd}: mean over birds, minimum {-s.extreme_ms.mean():.1f} ms (SEM {s.extreme_ms.sem():.1f}), "
f"drops below band {-s.leaves_band_ms.mean():.1f} ms (SEM {s.leaves_band_ms.sem():.1f}) "
"(paper 18 +- 1 and 48 +- 8, SEM)")
def next_onset_window(ev, i):
if i + 1 >= len(ev["on"]):
return None
o = ev["on"][i + 1]
return (o - 40, o)
tests_off = pd.DataFrame([paired_tests(lambda ev, i: (ev["off"][i] - 50, ev["off"][i]), next_onset_window, b)
for b in BIRDS])
print("\nPaired t-tests, 50 ms before offset against (a) the bout mean, (b) the 40 ms before the next onset:")
print(tests_off.to_string(index=False))
bird shuffle events extreme_ms leaves_band_ms avg_level band_lo band_hi extreme_value
Bird_1-b871 a 2137 -12.0 -38.0 0.0330 0.0307 0.0385 0.0232
Bird_1-b871 b 2137 -12.0 -40.0 0.0328 0.0318 0.0351 0.0232
Bird_2-Orange150 a 1931 -17.0 -41.0 0.0533 0.0508 0.0582 0.0378
Bird_2-Orange150 b 1931 -17.0 -43.0 0.0545 0.0530 0.0581 0.0378
Bird_3-Uva4 a 317 -25.0 -30.0 0.0371 0.0331 0.0487 0.0321
Bird_3-Uva4 b 317 -25.0 -39.0 0.0397 0.0357 0.0507 0.0321
shuffle a: mean over birds, minimum 18.0 ms (SEM 3.8), drops below band 36.3 ms (SEM 3.3) (paper 18 +- 1 and 48 +- 8, SEM)
shuffle b: mean over birds, minimum 18.0 ms (SEM 3.8), drops below band 40.7 ms (SEM 1.2) (paper 18 +- 1 and 48 +- 8, SEM)
Paired t-tests, 50 ms before offset against (a) the bout mean, (b) the 40 ms before the next onset:
bird n mean_window mean_bout t_a p_a mean_ref_b t_b p_b
Bird_1-b871 2116 0.026772 0.032725 -65.735458 0.000000e+00 0.035877 -62.107567 0.0
Bird_2-Orange150 1876 0.044659 0.054522 -58.698479 0.000000e+00 0.059923 -77.692444 0.0
Bird_3-Uva4 316 0.036817 0.039633 -5.823069 1.424453e-08 0.052483 -28.912659 0.0
Result: reproduced (assumed channel). MUA in the 50 ms before syllable offsets is lower than the bout mean and than the 40 ms before the next onset in every bird (p below 1e-7 in each). The minimum averages 18.0 ms before offset (paper 18 +- 1) and the average drops below the band 40.7 ms before offset under shuffle reading (b) (paper 48 +- 8; 36.3 ms under reading a, outside).
fig5-consistent-across-renditions and fig5-consistent-across-sitesΒΆ
Uva activity is consistent across renditions of the song motif; time-warped MUA is correlated across renditions (0.64 with 5 ms smoothing) and coherent below 12 Hz (mean coherence 0.68 between 1 and 12 Hz).
Uva activity is similar at different recording depths along a penetration; correlation 0.62 with 5 ms smoothing and mean coherence 0.65 between 1 and 12 Hz, with no evidence that activity varies across sites.
The motif of each bird is its most common sequence of motif letters (printed). A rendition is a run of consecutive segments spelling the motif, each selected. MUA is warped onto the template (the rendition whose length is closest to the median; Methods, Time warping), with the syllable onsets and offsets as alignment points. For the correlation the 2 ms MUA is smoothed further to a 5 ms total SD. Coherence uses one Slepian taper with time half-bandwidth 2 on the 2 ms MUA; the null is 1000 random circular shifts of each rendition (Rhythmicity).
from collections import Counter
def motif_of(bird):
c = Counter()
for ev in song_events(bird):
s = "".join(t if (sel and t not in ("i", "k", "")) else "|" for t, sel in zip(ev["title"], ev["sel"]))
for part in s.split("|"):
letters = sorted(set(part))
n = len(letters)
for j in range(len(part) - n + 1):
c[part[j:j + n]] += 1
full = max((m for m in c if len(set(m)) == len(m)), key=lambda m: (len(m) >= 4, c[m] * len(m)))
return full, c[full]
renditions = {}
for bird in BIRDS:
motif, n = motif_of(bird)
rows = []
for ev, m in bird_traces(bird):
tt = list(ev["title"])
for j in range(len(tt) - len(motif) + 1):
if "".join(tt[j:j + len(motif)]) == motif and ev["sel"][j:j + len(motif)].all():
pts = np.ravel(np.c_[ev["on"][j:j + len(motif)], ev["off"][j:j + len(motif)]])
if np.all(np.diff(pts) > 0) and pts[0] >= 0 and pts[-1] < len(m):
rows.append((ev, m, pts))
lens = np.array([p[-1] - p[0] for _, _, p in rows])
tmpl = rows[int(np.argmin(np.abs(lens - np.median(lens))))][2]
renditions[bird] = {"motif": motif, "rows": rows, "template": tmpl - tmpl[0], "lens": lens}
print(f"{bird}: motif '{motif}', {len(rows)} renditions, length median {np.median(lens):.0f} ms "
f"(range {lens.min():.0f} to {lens.max():.0f})")
def warped(bird, smooth_total_sd=None):
R = renditions[bird]
out = []
for ev, m, pts in R["rows"]:
x = m if smooth_total_sd is None else uva.gauss_smooth(m, np.sqrt(smooth_total_sd ** 2 - 2 ** 2))
out.append(uva.warp(x, pts, R["template"]))
return np.stack(out)
def corr_readings(W):
Z = (W - W.mean(1, keepdims=True)) / W.std(1, keepdims=True)
C = Z @ Z.T / W.shape[1]
iu = np.triu_indices(len(W), 1)
a = C[iu].mean()
# (b) peak of the cross-correlation within +-50 ms, averaged over pairs (up to 300 pairs)
rng = np.random.default_rng(5)
pairs = np.array(iu).T
pairs = pairs[rng.choice(len(pairs), min(300, len(pairs)), replace=False)]
L = W.shape[1]
b = np.mean([max(np.corrcoef(Z[i][max(0, s):L + min(0, s)], Z[j][max(0, -s):L - max(0, s)])[0, 1]
for s in range(-50, 51, 2)) for i, j in pairs])
c = np.mean([np.corrcoef(W[i], np.delete(W, i, 0).mean(0))[0, 1] for i in range(len(W))])
return a, b, c
def coherence_readings(W, n_null=1000, seed=0):
nfft = 2 ** int(np.ceil(np.log2(W.shape[1])) + 2)
f = np.fft.rfftfreq(nfft, 1 / 1000)
X = uva.mt_fft(W, nfft)
band = (f >= 1) & (f <= 12)
n = len(W)
iu = np.triu_indices(n, 1)
if len(iu[0]) > 2000:
sel = np.random.default_rng(seed).choice(len(iu[0]), 2000, replace=False)
iu = (iu[0][sel], iu[1][sel])
Ca = np.abs(uva.coherency(X[iu[0]], X[iu[1]]))
others = np.stack([np.delete(W, i, 0).mean(0) for i in range(n)])
Cc = np.abs(uva.coherency(X, uva.mt_fft(others, nfft)))
rng = np.random.default_rng(seed)
null = []
for _ in range(n_null):
Ws = np.stack([np.roll(w, rng.integers(len(w))) for w in W])
Xs = uva.mt_fft(Ws, nfft)
null.append(np.abs(uva.coherency(X[iu[0]], Xs[iu[1]]))[band].max())
return Ca[band].mean(), Cc[band].mean(), np.percentile(null, 95), f, Ca
Bird_1-b871: motif 'abcd', 112 renditions, length median 813 ms (range 760 to 968) Bird_2-Orange150: motif 'abcdefgh', 153 renditions, length median 1306 ms (range 1111 to 1464) Bird_3-Uva4: motif 'abcdef', 44 renditions, length median 838 ms (range 793 to 984)
rend_rows = []
for bird in BIRDS:
W5 = warped(bird, 5.0)
W2 = warped(bird)
a, b, c = corr_readings(W5)
ca, cc_, null95, f, Ca = coherence_readings(W2, n_null=1000)
rend_rows.append({"bird": bird, "renditions": len(W5), "corr_a_pairs": a, "corr_b_xcorr_peak": b,
"corr_c_vs_others": c, "coh_a_pairs_1_12": ca, "coh_c_vs_others_1_12": cc_,
"null95_max_1_12_pairs": null95})
rend_tab = pd.DataFrame(rend_rows)
print(rend_tab.round(3).to_string(index=False))
print("\nMean over birds:")
print(rend_tab.drop(columns=["bird", "renditions"]).mean().round(3).to_string())
print("Paper: correlation 0.64 +- 0.06, coherence 0.68 +- 0.09 (1 to 12 Hz).")
bird renditions corr_a_pairs corr_b_xcorr_peak corr_c_vs_others coh_a_pairs_1_12 coh_c_vs_others_1_12 null95_max_1_12_pairs
Bird_1-b871 112 0.721 0.728 0.829 0.500 0.656 0.226
Bird_2-Orange150 153 0.732 0.759 0.855 0.630 0.768 0.205
Bird_3-Uva4 44 0.651 0.732 0.803 0.626 0.766 0.345
Mean over birds:
corr_a_pairs 0.701
corr_b_xcorr_peak 0.740
corr_c_vs_others 0.829
coh_a_pairs_1_12 0.585
coh_c_vs_others_1_12 0.730
null95_max_1_12_pairs 0.259
Paper: correlation 0.64 +- 0.06, coherence 0.68 +- 0.09 (1 to 12 Hz).
Result: partially reproduced (assumed channel). Time-warped MUA is consistent across renditions in all 3 birds, far above the shifted null (its 95th percentile of the 1 to 12 Hz maximum is about 0.2 to 0.35). No reading puts both values in tolerance: all pairs give correlation 0.701 (paper 0.64 +- 0.06, just above) and coherence 0.585 (paper 0.68 +- 0.09, just below); against the mean of the other renditions, 0.829 and 0.730.
site_rows, site_pair_rows = [], []
for bird in BIRDS:
R = renditions[bird]
W5 = warped(bird, 5.0); W2 = warped(bird)
sites = np.array([site_of(ev) for ev, _, _ in R["rows"]], dtype=object)
days = np.array([ev["key"][1] for ev, _, _ in R["rows"]])
names = [s for s in pd.unique(sites) if s is not None and np.sum(sites == s) >= 5]
for s in names:
site_rows.append({"bird": bird, "site": s, "renditions": int(np.sum(sites == s))})
for i in range(len(names)):
for j in range(i + 1, len(names)):
si, sj = sites == names[i], sites == names[j]
if days[si][0] != days[sj][0]:
continue # sites of one penetration: same day
r_avg = np.corrcoef(W5[si].mean(0), W5[sj].mean(0))[0, 1]
Zi = (W5[si] - W5[si].mean(1, keepdims=True)) / W5[si].std(1, keepdims=True)
Zj = (W5[sj] - W5[sj].mean(1, keepdims=True)) / W5[sj].std(1, keepdims=True)
r_single = (Zi @ Zj.T / W5.shape[1]).mean()
nfft = 2 ** int(np.ceil(np.log2(W2.shape[1])) + 2)
f = np.fft.rfftfreq(nfft, 1 / 1000)
Xi, Xj = uva.mt_fft(W2[si], nfft), uva.mt_fft(W2[sj], nfft)
ii, jj = np.meshgrid(np.arange(si.sum()), np.arange(sj.sum()), indexing="ij")
ii, jj = ii.ravel(), jj.ravel()
if len(ii) > 2000:
k = np.random.default_rng(3).choice(len(ii), 2000, replace=False); ii, jj = ii[k], jj[k]
coh = np.abs(uva.coherency(Xi[ii], Xj[jj]))
band = (f >= 1) & (f <= 12)
site_pair_rows.append({"bird": bird, "site_1": names[i], "site_2": names[j], "corr_a_site_averages": r_avg,
"corr_b_single_renditions": r_single, "coh_b_single_renditions_1_12": coh[band].mean()})
print("Sites with at least 5 renditions:")
print(pd.DataFrame(site_rows).to_string(index=False))
sp = pd.DataFrame(site_pair_rows)
print("\nPairs of sites recorded on the same day:")
print(sp.round(3).to_string(index=False))
by_bird = sp.groupby("bird").mean(numeric_only=True)
print("\nPer bird (mean over pairs):\n", by_bird.round(3).to_string())
print("\nMean over birds with a pair:\n", by_bird.mean().round(3).to_string())
print("Paper: correlation 0.62 +- 0.03, coherence 0.65 +- 0.13. Coherence of two site averages with one taper is "
"identically 1, so coherence is computed between single renditions of the two sites (reading b).")
Sites with at least 5 renditions:
bird site renditions
Bird_1-b871 2013-09-08 864.48 16
Bird_1-b871 2013-09-08 960.8 40
Bird_1-b871 2013-09-08 834.68 14
Bird_1-b871 2013-09-09 835.1 38
Bird_2-Orange150 2013-10-05 537.34 41
Bird_2-Orange150 2013-10-05 586.12 78
Bird_2-Orange150 2013-10-05 652.24 9
Bird_2-Orange150 2013-10-06 533.84 25
Bird_3-Uva4 1709 5
Bird_3-Uva4 1872 8
Bird_3-Uva4 1540 12
Bird_3-Uva4 1610 10
Pairs of sites recorded on the same day:
bird site_1 site_2 corr_a_site_averages corr_b_single_renditions coh_b_single_renditions_1_12
Bird_1-b871 2013-09-08 864.48 2013-09-08 960.8 0.956 0.736 0.650
Bird_1-b871 2013-09-08 864.48 2013-09-08 834.68 0.968 0.726 0.636
Bird_1-b871 2013-09-08 960.8 2013-09-08 834.68 0.923 0.680 0.629
Bird_2-Orange150 2013-10-05 537.34 2013-10-05 586.12 0.934 0.706 0.666
Bird_2-Orange150 2013-10-05 537.34 2013-10-05 652.24 0.914 0.717 0.632
Bird_2-Orange150 2013-10-05 586.12 2013-10-05 652.24 0.930 0.701 0.608
Bird_3-Uva4 1709 1872 0.696 0.591 0.762
Bird_3-Uva4 1709 1540 0.953 0.832 0.871
Bird_3-Uva4 1709 1610 0.801 0.707 0.837
Bird_3-Uva4 1872 1540 0.683 0.581 0.745
Bird_3-Uva4 1872 1610 0.905 0.768 0.715
Bird_3-Uva4 1540 1610 0.784 0.688 0.811
Per bird (mean over pairs):
corr_a_site_averages corr_b_single_renditions coh_b_single_renditions_1_12
bird
Bird_1-b871 0.949 0.714 0.638
Bird_2-Orange150 0.926 0.708 0.635
Bird_3-Uva4 0.804 0.694 0.790
Mean over birds with a pair:
corr_a_site_averages 0.893
corr_b_single_renditions 0.705
coh_b_single_renditions_1_12 0.688
Paper: correlation 0.62 +- 0.03, coherence 0.65 +- 0.13. Coherence of two site averages with one taper is identically 1, so coherence is computed between single renditions of the two sites (reading b).
Result: partially reproduced (assumed channel). Activity at sites of the same day is similar: coherence between single renditions of two sites averages 0.688 over birds (paper 0.65 +- 0.13). The correlation is higher than the paper's: 0.705 for single renditions and 0.893 for site averages (paper 0.62 +- 0.03). For Uva4 the penetration of each site is not known.
fig7a-correlation-with-amplitude, fig7b-10hz-power-peaks, fig7d-10hz-coherenceΒΆ
Uva activity correlates with song amplitude (peak correlation 0.40) and leads it by 42 ms.
Song amplitude and Uva activity both have a broad spectral peak near 10 Hz, at 8.0 Hz for song and 8.8 Hz for Uva.
Uva activity and song amplitude are significantly coherent near 10 Hz (peak at 8.8 Hz, coherence 0.75, p < 0.01, phase -0.77 pi), with a large peak in their cross-spectrum.
Segments are (a) bouts of 1 to 8.192 s (the shortest bout is not given; 1 s, a standard choice, so that the taper's 4 Hz resolution can show a 10 Hz peak) and (b) motif renditions (unwarped). The amplitude readings are (a) dB, (b) power without the log, (c) rectified audio smoothed at 2 ms. Spectra are padded to 8192 points at 1 kHz; longer bouts are left out (counted).
NFFT = 8192
FR = np.fft.rfftfreq(NFFT, 1 / 1000)
long_bouts = {}
def segments(bird, kind):
out = []
if kind == "bouts":
for ev, m in bird_traces(bird):
r = eph["recs"][ev["key"]]
for a, b, _ in ev["bouts"]:
a, b = int(a), int(b)
if b - a > NFFT:
long_bouts[bird] = long_bouts.get(bird, 0) + 1
continue
if b - a >= 1000 and b <= len(m):
out.append((m[a:b], r["amp_db"][a:b], 10 ** (r["amp_db"][a:b] / 10), r["amp_rect"][a:b]))
else:
for ev, m, pts in renditions[bird]["rows"]:
r = eph["recs"][ev["key"]]
a, b = int(pts[0]), int(pts[-1])
out.append((m[a:b], r["amp_db"][a:b], 10 ** (r["amp_db"][a:b] / 10), r["amp_rect"][a:b]))
return out
AMP = {"a": 1, "b": 2, "c": 3}
xc_rows = []
for bird in BIRDS:
for kind in ["bouts", "motifs"]:
segs = segments(bird, kind)
for rd, j in AMP.items():
lags = np.arange(-150, 151)
cc = []
for s in segs:
x, y = s[0].astype(float), s[j].astype(float)
vals = []
for L in lags: # positive lag: MUA earlier than amplitude
if L >= 0:
xx, yy = x[:len(x) - L], y[L:]
else:
xx, yy = x[-L:], y[:len(y) + L]
vals.append(np.corrcoef(xx, yy)[0, 1])
cc.append(vals)
cc = np.nanmean(cc, 0)
k = int(np.argmax(np.abs(cc)))
xc_rows.append({"bird": bird, "segments": kind, "amplitude": rd, "n": len(segs),
"peak_corr": cc[k], "lag_ms_mua_first": lags[k], "corr_at_0": cc[150]})
xc = pd.DataFrame(xc_rows)
print(xc.round(3).to_string(index=False))
print("Bouts longer than 8.192 s left out (counted once per reading):", long_bouts)
print("\nMean over birds (peak magnitude, lag):")
print(xc.assign(mag=xc.peak_corr.abs()).groupby(["segments", "amplitude"])[["mag", "lag_ms_mua_first"]].mean().round(3).to_string())
print("Paper: 0.40 +- 0.04 at 42 +- 6 ms, MUA first.")
bird segments amplitude n peak_corr lag_ms_mua_first corr_at_0
Bird_1-b871 bouts a 319 0.651 37 0.190
Bird_1-b871 bouts b 319 0.349 52 0.102
Bird_1-b871 bouts c 319 0.481 42 0.188
Bird_1-b871 motifs a 112 0.619 39 0.059
Bird_1-b871 motifs b 112 -0.391 -126 0.059
Bird_1-b871 motifs c 112 0.435 41 0.092
Bird_2-Orange150 bouts a 162 0.606 35 -0.051
Bird_2-Orange150 bouts b 162 0.306 41 0.119
Bird_2-Orange150 bouts c 162 0.441 38 0.111
Bird_2-Orange150 motifs a 153 0.588 32 -0.204
Bird_2-Orange150 motifs b 153 0.308 40 0.091
Bird_2-Orange150 motifs c 153 0.435 37 0.055
Bird_3-Uva4 bouts a 16 0.538 41 -0.003
Bird_3-Uva4 bouts b 16 0.394 46 0.088
Bird_3-Uva4 bouts c 16 0.454 42 0.071
Bird_3-Uva4 motifs a 44 -0.441 6 -0.391
Bird_3-Uva4 motifs b 44 0.264 47 -0.122
Bird_3-Uva4 motifs c 44 0.277 44 -0.204
Bouts longer than 8.192 s left out (counted once per reading): {'Bird_3-Uva4': 3}
Mean over birds (peak magnitude, lag):
mag lag_ms_mua_first
segments amplitude
bouts a 0.598 37.667
b 0.349 46.333
c 0.459 40.667
motifs a 0.549 25.667
b 0.321 -13.000
c 0.382 40.667
Paper: 0.40 +- 0.04 at 42 +- 6 ms, MUA first.
Result: reproduced (assumed channel). With motif segments and the rectified amplitude (reading c), the peak correlation averages 0.382 over birds with MUA leading by 40.7 ms (paper 0.40 +- 0.04 at 42 +- 6). With bouts the same amplitude gives 0.459 at 40.7 ms; the dB amplitude gives larger correlations (0.55 to 0.60).
spec_rows, coh_store = [], {}
for bird in BIRDS:
for kind in ["bouts", "motifs"]:
segs = segments(bird, kind)
for rd, j in AMP.items():
Xm = np.concatenate([uva.mt_fft(s[0].astype(float), NFFT) for s in segs])
Xa = np.concatenate([uva.mt_fft(s[j].astype(float), NFFT) for s in segs])
lens = np.array([len(s[0]) for s in segs], float)
Pm = np.abs(Xm[:, 0]) ** 2; Pa = np.abs(Xa[:, 0]) ** 2
coh_store[(bird, kind, rd)] = (Xm, Xa)
for norm in ["sum", "length"]:
if norm == "sum":
pm = (Pm / Pm.sum(1, keepdims=True)).mean(0); pa = (Pa / Pa.sum(1, keepdims=True)).mean(0)
else:
pm = (Pm / lens[:, None]).mean(0); pa = (Pa / lens[:, None]).mean(0)
spec_rows.append({"bird": bird, "segments": kind, "amplitude": rd, "norm": norm, "pm": pm, "pa": pa})
spec = pd.DataFrame(spec_rows)
win = (FR > 3) & (FR < 30)
rows = []
for (kind, rd, norm), g in spec.groupby(["segments", "amplitude", "norm"]):
# each bird's spectrum as the reading normalizes it, averaged over birds without renormalizing
pm, pa = np.mean(list(g.pm), 0), np.mean(list(g.pa), 0)
per_bird_m = [FR[win][np.argmax(p[win])] for p in g.pm]
per_bird_a = [FR[win][np.argmax(p[win])] for p in g.pa]
rows.append({"segments": kind, "amplitude": rd, "norm": norm, "peak_song_Hz": FR[win][np.argmax(pa[win])],
"peak_mua_Hz": FR[win][np.argmax(pm[win])],
"per_bird_song": np.round(per_bird_a, 1).tolist(), "per_bird_mua": np.round(per_bird_m, 1).tolist()})
print(pd.DataFrame(rows).to_string(index=False))
print("Paper: song 8.0 Hz, MUA 8.8 Hz. Search window 3 to 30 Hz.")
segments amplitude norm peak_song_Hz peak_mua_Hz per_bird_song per_bird_mua bouts a length 6.225586 11.596680 [6.2, 9.3, 4.3] [11.4, 9.3, 4.4] bouts a sum 6.225586 6.347656 [6.2, 9.3, 10.4] [6.3, 9.2, 10.4] bouts b length 6.103516 11.596680 [3.1, 6.2, 4.4] [11.4, 9.3, 4.4] bouts b sum 6.225586 6.347656 [6.2, 9.3, 3.4] [6.3, 9.2, 10.4] bouts c length 6.225586 11.596680 [6.1, 9.3, 4.4] [11.4, 9.3, 4.4] bouts c sum 6.225586 6.347656 [6.2, 9.3, 3.4] [6.3, 9.2, 10.4] motifs a length 9.033203 12.573242 [8.7, 9.0, 13.2] [3.1, 8.8, 13.1] motifs a sum 9.033203 8.911133 [8.7, 9.0, 13.2] [3.1, 8.9, 13.2] motifs b length 6.225586 12.573242 [3.1, 6.1, 13.1] [3.1, 8.8, 13.1] motifs b sum 9.277344 8.911133 [3.1, 6.2, 13.3] [3.1, 8.9, 13.2] motifs c length 6.225586 12.573242 [8.8, 6.2, 13.2] [3.1, 8.8, 13.1] motifs c sum 9.277344 8.911133 [8.8, 6.2, 13.4] [3.1, 8.9, 13.2] Paper: song 8.0 Hz, MUA 8.8 Hz. Search window 3 to 30 Hz.
Result: partially reproduced (assumed channel). With the spectra normalized by their sum, over motifs both peak near 9 Hz: MUA at 8.9 Hz (paper 8.8) and song amplitude at 9.0 Hz (dB) or 9.3 Hz (power or rectified), above the song tolerance (7.2 to 8.8 Hz). Normalized by length and averaged without renormalizing, the MUA peak moves to 12.6 Hz over motifs and 11.6 Hz over bouts, and over bouts the song amplitude peaks at 6.1 to 6.2 Hz. No reading puts both peaks within tolerance.
rng = np.random.default_rng(7)
rows = []
for kind in ["bouts", "motifs"]:
for rd in AMP:
cohs, nulls = [], []
for bird in BIRDS:
Xm, Xa = coh_store[(bird, kind, rd)]
cohs.append(uva.coherency(Xm, Xa))
C = np.mean(cohs, 0)
# null: MUA of each segment shifted circularly by a random amount, 1000 times
segs_by_bird = {b: [s[0].astype(float) for s in segments(b, kind)] for b in BIRDS}
nmax = []
for it in range(1000):
cn = []
for bird in BIRDS:
Xa = coh_store[(bird, kind, rd)][1]
Xs = uva.shifted_ffts(segs_by_bird[bird], NFFT, rng)
cn.append(uva.coherency(Xs, Xa))
nmax.append(np.abs(np.mean(cn, 0))[win].max())
k = np.argmax(np.abs(C)[win])
rows.append({"segments": kind, "amplitude": rd, "peak_Hz": FR[win][k], "coherence": np.abs(C)[win][k],
"phase_pi": np.angle(C[win][k]) / np.pi, "null_99_max": np.percentile(nmax, 99),
"p": (np.sum(np.array(nmax) >= np.abs(C)[win][k]) + 1) / (len(nmax) + 1), "null_draws": len(nmax),
"per_bird_peak_Hz": [round(FR[win][np.argmax(np.abs(c)[win])], 1) for c in cohs]})
coh_tab = pd.DataFrame(rows)
print(coh_tab.round(3).to_string(index=False))
print("Paper: 8.8 Hz, coherence 0.75, p < 0.01, phase -0.77 pi. Phase as Chronux coherencyc(MUA, amplitude) "
"returns it; the opposite convention (amplitude first) is the same value with the sign changed.")
segments amplitude peak_Hz coherence phase_pi null_99_max p null_draws per_bird_peak_Hz bouts a 6.348 0.693 -0.533 0.277 0.001 1000 [6.1, 5.1, 13.8] bouts b 6.348 0.503 -0.525 0.305 0.001 1000 [6.3, 9.2, 13.9] bouts c 6.348 0.581 -0.529 0.270 0.001 1000 [6.1, 5.1, 13.9] motifs a 8.789 0.854 -0.797 0.188 0.001 1000 [3.1, 8.9, 12.3] motifs b 9.033 0.789 -0.721 0.209 0.001 1000 [8.7, 9.3, 12.2] motifs c 8.911 0.851 -0.740 0.209 0.001 1000 [3.1, 9.0, 12.2] Paper: 8.8 Hz, coherence 0.75, p < 0.01, phase -0.77 pi. Phase as Chronux coherencyc(MUA, amplitude) returns it; the opposite convention (amplitude first) is the same value with the sign changed.
Result: reproduced (assumed channel). Over motifs with the amplitude as power (reading b), the averaged coherency peaks at 9.0 Hz with coherence 0.789 and phase -0.721 pi, above the null of shifted MUA (p = 0.001, 1000 shifts; paper 8.8 Hz, 0.75, -0.77 pi, p < 0.01). With the dB or rectified amplitude the peak is at 8.8 to 8.9 Hz but the coherence is higher (0.85). Over bouts the peak is at 6.3 Hz.
spectral-features-weakΒΆ
None of six spectral song features correlates significantly with Uva activity within a bird; pooled over birds only amplitude (r = 0.18) and gravity center (r = 0.17) do, after Bonferroni correction.
The six features are computed from the sound channel at 1 kHz after the Sound Analysis Pro
definitions (uva.sap_features; the claims file adopts SAP as an assumption, and the details of
the window, taper, band, AM and FM are standard choices stated in the helper). Windows run from
10 ms after each selected song syllable's onset to 10 ms before its offset, and the MUA window
is the same window 42 ms earlier. Reading (a): per rendition, mean feature against mean MUA;
reading (b): per 1 ms bin within the windows. Pearson r, Bonferroni over 6 features (p < 0.05/6).
Pooled: all birds' renditions together, raw and (variant, reading a) with features and MUA
z-scored within each bird's syllable type.
rows, pooled = [], {"a": [], "a_z": [], "b": []}
for bird in BIRDS:
per_a, per_b = [], []
for ev, m in bird_traces(bird):
F = eph["recs"][ev["key"]]["features"]
for i in np.where(syl_mask(ev))[0]:
a, z = int(ev["on"][i]) + 10, int(ev["off"][i]) - 10
if z - a < 5 or a - 42 < 0 or z > len(m):
continue
mu = m[a - 42:z - 42]
per_a.append([ev["title"][i], mu.mean()] + [F[f][a:z].mean() for f in uva.FEATURES])
per_b.append(np.c_[mu, np.stack([F[f][a:z] for f in uva.FEATURES], 1)])
A = pd.DataFrame(per_a, columns=["type", "mua"] + uva.FEATURES)
B = np.concatenate(per_b)
Az = A.copy()
for col in ["mua"] + uva.FEATURES:
Az[col] = A.groupby("type")[col].transform(lambda v: (v - v.mean()) / v.std() if v.std() > 0 else v * 0)
pooled["a"].append(A); pooled["a_z"].append(Az.dropna()); pooled["b"].append(B)
for j, f in enumerate(uva.FEATURES):
ra = stats.pearsonr(A.mua, A[f]); rb = stats.pearsonr(B[:, 0], B[:, j + 1])
rows.append({"bird": bird, "feature": f, "renditions": len(A), "r_a": ra.statistic, "p_a": ra.pvalue,
"sig_a": ra.pvalue < 0.05 / 6, "bins": len(B), "r_b": rb.statistic, "p_b": rb.pvalue,
"sig_b": rb.pvalue < 0.05 / 6})
sf = pd.DataFrame(rows)
print("Per bird:")
print(sf.to_string(index=False, float_format=lambda v: f"{v:.3g}"))
prow = []
for rd in ["a", "a_z", "b"]:
if rd == "b":
X = np.concatenate(pooled["b"]); mua_, feats_ = X[:, 0], {f: X[:, j + 1] for j, f in enumerate(uva.FEATURES)}
else:
X = pd.concat(pooled[rd]); mua_, feats_ = X.mua.values, {f: X[f].values for f in uva.FEATURES}
for f in uva.FEATURES:
r = stats.pearsonr(mua_, feats_[f])
prow.append({"reading": rd, "feature": f, "n": len(mua_), "r": r.statistic, "p": r.pvalue,
"significant_bonferroni": r.pvalue < 0.05 / 6})
print("\nPooled over birds:")
print(pd.DataFrame(prow).to_string(index=False, float_format=lambda v: f"{v:.3g}"))
print("\nFeatures significant in single birds, per reading:",
{rd: int(sf[f"sig_{rd}"].sum()) for rd in ["a", "b"]}, "of", len(sf), "bird-feature pairs")
print("Paper: none significant in single birds; pooled, amplitude r = 0.18 and gravity center r = 0.17 significant, "
"the other four not.")
Per bird:
bird feature renditions r_a p_a sig_a bins r_b p_b sig_b
Bird_1-b871 amplitude 2138 0.0579 0.0074 True 257170 0.0867 0 True
Bird_1-b871 pitch_goodness 2138 -0.116 6.76e-08 True 257170 0.0159 7.76e-16 True
Bird_1-b871 wiener_entropy 2138 0.0248 0.252 False 257170 0.01 3.66e-07 True
Bird_1-b871 gravity_center 2138 0.0417 0.054 False 257170 0.0141 7.43e-13 True
Bird_1-b871 am 2138 0.0945 1.21e-05 True 257170 -0.000347 0.86 False
Bird_1-b871 fm 2138 0.16 1.13e-13 True 257170 -0.00275 0.163 False
Bird_2-Orange150 amplitude 1931 0.00618 0.786 False 225155 0.154 0 True
Bird_2-Orange150 pitch_goodness 1931 -0.12 1.31e-07 True 225155 -0.00521 0.0134 False
Bird_2-Orange150 wiener_entropy 1931 0.0581 0.0106 False 225155 0.0132 4.15e-10 True
Bird_2-Orange150 gravity_center 1931 -0.0447 0.0494 False 225155 0.112 0 True
Bird_2-Orange150 am 1931 -0.0306 0.179 False 225155 0.0653 0 True
Bird_2-Orange150 fm 1931 0.0492 0.0305 False 225155 0.0125 3.15e-09 True
Bird_3-Uva4 amplitude 317 0.181 0.00117 True 31359 0.113 0 True
Bird_3-Uva4 pitch_goodness 317 0.45 3.58e-17 True 31359 0.132 0 True
Bird_3-Uva4 wiener_entropy 317 -0.0713 0.205 False 31359 -0.0551 1.7e-22 True
Bird_3-Uva4 gravity_center 317 0.08 0.155 False 31359 0.0387 7.22e-12 True
Bird_3-Uva4 am 317 0.382 2.01e-12 True 31359 0.0648 1.39e-30 True
Bird_3-Uva4 fm 317 -0.473 4.63e-19 True 31359 -0.0511 1.43e-19 True
Pooled over birds:
reading feature n r p significant_bonferroni
a amplitude 4386 0.156 3.19e-25 True
a pitch_goodness 4386 0.229 0 True
a wiener_entropy 4386 -0.195 9.55e-39 True
a gravity_center 4386 0.291 0 True
a am 4386 -0.00121 0.936 False
a fm 4386 -0.121 7.44e-16 True
a_z amplitude 4386 0.0962 1.69e-10 True
a_z pitch_goodness 4386 -0.0485 0.00131 True
a_z wiener_entropy 4386 -0.0284 0.06 False
a_z gravity_center 4386 -0.0374 0.0133 False
a_z am 4386 0.00543 0.719 False
a_z fm 4386 -0.0459 0.00236 True
b amplitude 513684 0.183 0 True
b pitch_goodness 513684 0.142 0 True
b wiener_entropy 513684 -0.0578 0 True
b gravity_center 513684 0.0816 0 True
b am 513684 0.00783 1.96e-08 True
b fm 513684 -0.0481 0 True
Features significant in single birds, per reading: {'a': 9, 'b': 15} of 18 bird-feature pairs
Paper: none significant in single birds; pooled, amplitude r = 0.18 and gravity center r = 0.17 significant, the other four not.
Result: not reproduced (assumed feature definitions). Within single birds, 9 of 18 bird-feature pairs are significant per rendition (reading a) and 15 of 18 per 1 ms bin (reading b); the paper reports none. Pooled over birds, amplitude correlates with MUA (r = 0.156 per rendition, 0.183 per bin, the latter within 0.18 +- 0.018), but so do the other features: gravity center r = 0.291 (a) and 0.082 (b), outside 0.17 +- 0.017, and pitch goodness, Wiener entropy and FM are significant under readings (a) and (b). With each feature z-scored within syllable type, pitch goodness and FM stay significant and Wiener entropy does not (p = 0.06). The features follow SAP's definitions only as far as the helper states, but amplitude, the feature that depends least on them, alone breaks the single-bird condition. With hundreds to thousands of renditions per bird, correlations as small as 0.06 are significant; the paper does not give its n, so a difference in power may explain part of the disagreement.
fig9-long-syllable-gammaΒΆ
In long syllables (> 150 ms; 13 syllables, 43% of song syllables) Uva activity can oscillate fast; 8 of 13 have a significant spectral peak above 10 Hz, at 17 to 51 Hz, and Uva activity is coherent with song amplitude from 1 to 55 Hz.
Syllable types (labels) of each bird whose median duration exceeds 150 ms. For each type, MUA and amplitude (reading a, dB) from onset to 50 ms before offset, spectra with [2 1] tapers padded to 1024 points, normalized by their sum and averaged over renditions. Null for the MUA spectrum: the 1 kHz MUA samples of each window scrambled and smoothed again with the 2 ms Gaussian, taking the scrambled window as periodic so that the smoothing adds no dip at its edges (the paper scrambles the raw signal; the reduced trace is scrambled here), 1000 times; a type has a significant peak when its largest local maximum above 10 Hz exceeds the 95th percentile of the null's maxima above 10 Hz. Coherence with amplitude is averaged over renditions per type, then over all long types, against the null of scrambled MUA averaged the same way (95th percentile of its maxima over 1 to 60 Hz, 200 draws).
NF9 = 1024
F9 = np.fft.rfftfreq(NF9, 1 / 1000)
hi = F9 > 10
band9 = (F9 >= 1) & (F9 <= 60)
rng = np.random.default_rng(9)
long_rows, coh9, null9 = [], [], []
n_types = 0
for bird in BIRDS:
durs = {}
for ev, m in bird_traces(bird):
for t, a, b, s in zip(ev["title"], ev["on"], ev["off"], ev["sel"]):
if s and t not in ("i", "k", ""):
durs.setdefault(t, []).append((ev, m, a, b))
for t, items in sorted(durs.items()):
if len(items) < 5:
continue
n_types += 1
med = np.median([b - a for _, _, a, b in items])
if med <= 150:
continue
segs = [(m[int(a):int(b) - 50].astype(float), eph["recs"][ev["key"]]["amp_db"][int(a):int(b) - 50].astype(float))
for ev, m, a, b in items if b - a - 50 >= 50 and int(b) - 50 <= len(m)]
Xm = np.concatenate([uva.mt_fft(x, NF9) for x, _ in segs])
Xa = np.concatenate([uva.mt_fft(y, NF9) for _, y in segs])
P = np.abs(Xm[:, 0]) ** 2
P = (P / P.sum(1, keepdims=True)).mean(0)
nullmax = []
nc = []
for it in range(1000):
Xs = uva.scrambled_ffts([x for x, _ in segs], NF9, rng)
Ps = np.abs(Xs[:, 0]) ** 2
Ps = (Ps / Ps.sum(1, keepdims=True)).mean(0)
nullmax.append(Ps[hi].max())
if it < 200:
nc.append(np.abs(uva.coherency(Xs, Xa)))
thr = np.percentile(nullmax, 95)
# the largest local maximum above 10 Hz (a peak, not the edge of the band)
locmax = np.r_[False, (P[1:-1] > P[:-2]) & (P[1:-1] > P[2:]), False] & hi
k = np.argmax(np.where(locmax, P, -np.inf)[hi])
C = np.abs(uva.coherency(Xm, Xa))
coh9.append(C); null9.append(np.array(nc))
thr_t = np.percentile(np.array(nc)[:, band9].max(1), 95)
ok_t = C > thr_t
span = (F9 >= 1.1) & (F9 <= 49.5)
long_rows.append({"bird": bird, "type": t, "median_ms": med, "renditions": len(segs),
"peak_above_10Hz": F9[hi][k], "peak_power": P[hi][k], "null95_max": thr,
"significant": bool(P[hi][k] > thr), "coh_null95": thr_t,
"coh_above_null_1.1_49.5Hz": f"{ok_t[span].mean():.2f}", "coh_unbroken_1.1_49.5Hz": bool(ok_t[span].all())})
lt = pd.DataFrame(long_rows)
print(lt.round(5).to_string(index=False))
print(f"\nLong types: {len(lt)} of {n_types} syllable types with at least 5 renditions ({len(lt) / n_types:.2f}); "
f"paper 13 (43%) over 5 birds")
sig = lt[lt.significant]
print(f"Long types with a significant peak above 10 Hz: {len(sig)} of {len(lt)} ({len(sig) / len(lt):.2f}); "
f"peak frequencies {sorted(sig.peak_above_10Hz.round(1).tolist())}; paper 8 of 13 (0.62), 17 to 51 Hz")
Cm = np.mean(coh9, 0)
thr_c = np.percentile(np.mean(null9, 0)[:, band9].max(1), 95) # null of the across-type average, maxima over 1-60 Hz
above = Cm > thr_c
band = (F9 >= 1) & (F9 <= 60)
runs = []
start = None
for fv, ab in zip(F9[band], above[band]):
if ab and start is None:
start = fv
if not ab and start is not None:
runs.append((start, prev)); start = None
prev = fv
if start is not None:
runs.append((start, prev))
print(f"Average coherence over long types above the null band (95th percentile of the averaged null's maxima, "
f"{thr_c:.3f}), ranges in Hz within 1 to 60 Hz: {[(round(a, 1), round(b, 1)) for a, b in runs]}")
print("Coherence at 1, 5, 10, 20, 30, 40, 50, 55 Hz:", [round(float(np.interp(v, F9, Cm)), 3) for v in [1, 5, 10, 20, 30, 40, 50, 55]])
# The criterion's across-bird average: long types averaged within each bird, then over birds (the
# null averaged the same way, draw by draw).
birds9 = list(dict.fromkeys(lt.bird))
Cb = np.mean([np.mean([c for c, b in zip(coh9, lt.bird) if b == bb], 0) for bb in birds9], 0)
Nb = np.mean([np.mean([n for n, b in zip(null9, lt.bird) if b == bb], 0) for bb in birds9], 0)
thr_b = np.percentile(Nb[:, band9].max(1), 95)
runs_b, start = [], None
for fv, ab in zip(F9[band9], (Cb > thr_b)[band9]):
if ab and start is None:
start = fv
if not ab and start is not None:
runs_b.append((start, prev)); start = None
prev = fv
if start is not None:
runs_b.append((start, prev))
print(f"Across-bird average ({len(birds9)} birds) above its null ({thr_b:.3f}), ranges in Hz within 1 to 60 Hz: "
f"{[(round(float(a), 1), round(float(b), 1)) for a, b in runs_b]}; unbroken over 1.1 to 49.5 Hz: "
f"{bool((Cb > thr_b)[span].all())}")
print("Across-bird coherence at 1, 5, 10, 20, 30, 40, 50, 55 Hz:", [round(float(np.interp(v, F9, Cb)), 3) for v in [1, 5, 10, 20, 30, 40, 50, 55]])
bird type median_ms renditions peak_above_10Hz peak_power null95_max significant coh_null95 coh_above_null_1.1_49.5Hz coh_unbroken_1.1_49.5Hz
Bird_1-b871 b 290.6625 467 40.03906 0.02903 0.01466 True 0.11756 0.88 False
Bird_1-b871 d 195.7375 209 22.46094 0.02376 0.01489 True 0.12912 0.18 False
Bird_2-Orange150 a 162.9750 187 44.92188 0.01028 0.01466 False 0.16700 1.00 True
Bird_2-Orange150 e 161.5250 268 10.74219 0.02014 0.01434 True 0.13354 1.00 True
Bird_2-Orange150 g 182.3250 240 21.48438 0.01588 0.01471 True 0.14104 0.98 False
Bird_3-Uva4 b 281.2875 56 20.50781 0.02541 0.01714 True 0.30825 1.00 True
Long types: 6 of 18 syllable types with at least 5 renditions (0.33); paper 13 (43%) over 5 birds
Long types with a significant peak above 10 Hz: 5 of 6 (0.83); peak frequencies [10.7, 20.5, 21.5, 22.5, 40.0]; paper 8 of 13 (0.62), 17 to 51 Hz
Average coherence over long types above the null band (95th percentile of the averaged null's maxima, 0.107), ranges in Hz within 1 to 60 Hz: [(np.float64(2.0), np.float64(59.6))]
Coherence at 1, 5, 10, 20, 30, 40, 50, 55 Hz: [0.408, 0.452, 0.49, 0.435, 0.347, 0.459, 0.293, 0.282]
Across-bird average (3 birds) above its null (0.141), ranges in Hz within 1 to 60 Hz: [(2.0, 59.6)]; unbroken over 1.1 to 49.5 Hz: True
Across-bird coherence at 1, 5, 10, 20, 30, 40, 50, 55 Hz: [0.408, 0.466, 0.507, 0.486, 0.395, 0.498, 0.263, 0.261]
Result: not reproduced (assumed channel). Over 3 birds, 6 of 18 syllable types are longer than 150 ms (0.33; paper 0.43 +- 0.043). 5 of the 6 have a significant MUA peak above 10 Hz (0.83; paper 0.62 +- 0.062), at 10.7 to 40.0 Hz (lower bound outside 15.3 to 56.1 Hz). With the scrambled null smoothed without edge effects, the coherence with amplitude averaged over the long types exceeds its null (0.107) from 2.0 to 59.6 Hz without a break, covering 1.1 to 49.5 Hz; averaged within each bird and then over the 3 birds, as the criterion says, it exceeds its null (0.141) over the same range. The coherence part holds; the counts and the frequency range do not.
bout-offset-suppressionΒΆ
Uva activity is transiently suppressed for about 200 ms after bout offsets.
MUA aligned to bout offsets (the end of the last segment of each bout holding song syllables), against the shuffled baseline drawn at random times outside singing (more than 300 ms from any segment) in the same files, with the 95% band of the shuffles' minima over -100 to +500 ms.
rows = []
for bird in BIRDS:
rng = np.random.default_rng(21)
A, pool = [], []
for ev, m in bird_traces(bird):
song = syl_mask(ev)
offs = np.array([b for a, b, idx in ev["bouts"] if song[idx].any()])
A.append(uva.aligned(m, offs, 100, 500)[0])
alls = np.zeros(len(m), bool)
for a, b in zip(ev["on"], ev["off"]):
alls[max(0, int(a) - 300):int(b) + 300] = True
t = np.where(~alls)[0]
t = t[(t >= 100) & (t < len(m) - 501)]
if len(t):
pool.append((m, t))
A = np.concatenate(A)
avg = A.mean(0)
lags = np.arange(-100, 501)
level, lo, hi_ = uva.shuffle_band(pool, len(A), 100, 500, 1000, rng)
AVG[("bout offsets", bird, "a")] = (avg, level, lo, hi_)
below = avg < lo
post = lags >= 0
first = np.argmax(below & post) if np.any(below & post) else None
if first is not None:
j = first
while j + 1 < len(avg) and avg[j + 1] < lo:
j += 1
end_below = lags[j]
back = np.where((lags > lags[first]) & (avg >= lo))[0]
dur_in = lags[back[0]] if len(back) else np.nan
k = np.where((lags > lags[first]) & (avg >= level))[0]
dur_level = lags[k[0]] if len(k) else np.nan
else:
end_below, dur_in, dur_level = np.nan, np.nan, np.nan
rows.append({"bird": bird, "bout_offsets": len(A), "baseline_level": level, "band_lo": lo, "min_after": avg[post].min(),
"min_at_ms": lags[post][np.argmin(avg[post])], "first_below_ms": lags[first] if first is not None else np.nan,
"back_in_band_ms": dur_in, "back_to_level_ms": dur_level})
bo = pd.DataFrame(rows)
print(bo.round(4).to_string(index=False))
print(f"Mean over birds: returns into the band {bo.back_in_band_ms.mean():.0f} ms after offset; "
f"returns to the baseline level {bo.back_to_level_ms.mean():.0f} ms (paper about 200 ms, tolerance 180 to 220)")
bird bout_offsets baseline_level band_lo min_after min_at_ms first_below_ms back_in_band_ms back_to_level_ms
Bird_1-b871 426 0.0227 0.0210 0.0192 4 0 30 256
Bird_2-Orange150 159 0.0287 0.0254 0.0212 98 0 309 381
Bird_3-Uva4 14 0.0223 0.0181 0.0179 40 40 42 63
Mean over birds: returns into the band 127 ms after offset; returns to the baseline level 233 ms (paper about 200 ms, tolerance 180 to 220)
Result: partially reproduced (assumed channel). MUA falls below the non-singing band after bout offsets in all 3 birds, but returns into the band 30, 309 and 42 ms after offset (mean 127 ms; paper about 200, tolerance 180 to 220). The suppression is present; its duration is outside the tolerance and varies widely between birds.
Event-aligned averagesΒΆ
Each bird's average MUA around calls, introductory notes, syllable onsets and offsets, and bout offsets, with the 95% bands of the shuffled baselines that the claims above use.
import matplotlib.pyplot as plt
names = ["calls", "introductory notes", "syllable onsets", "syllable offsets", "bout offsets"]
fig, axs = plt.subplots(len(BIRDS), len(names), figsize=(18, 9), sharex="col")
for j, nm in enumerate(names):
for i, bird in enumerate(BIRDS):
ax = axs[i, j]
for rd, col in [("a", "C0"), ("b", "C1")]:
if (nm, bird, rd) not in AVG:
continue
avg, level, lo, hi_ = AVG[(nm, bird, rd)]
lags = np.arange(-100, 501) if nm == "bout offsets" else LAGS
if rd == "a":
ax.plot(lags, avg, "k", lw=1)
print(f"{nm}, {bird}: average {avg.min():.4f} to {avg.max():.4f} V; band (shuffle a) {lo:.4f} to {hi_:.4f}")
ax.axhspan(lo, hi_, color=col, alpha=0.15)
ax.axhline(level, color=col, lw=0.6)
ax.axvline(0, color="grey", lw=0.5)
if i == 0:
ax.set_title(nm)
if j == 0:
ax.set_ylabel(f"{bird}\nMUA (V)")
for ax in axs[-1]:
ax.set_xlabel("ms from event")
plt.tight_layout()
plt.show()
print("Bands: blue shuffle (a), orange shuffle (b); lines are the shuffles' mean level. Every average is within its axes.")
calls, Bird_1-b871: average 0.0210 to 0.0486 V; band (shuffle a) 0.0284 to 0.0712 calls, Bird_3-Uva4: average 0.0234 to 0.0821 V; band (shuffle a) 0.0302 to 0.0679 introductory notes, Bird_1-b871: average 0.0199 to 0.0359 V; band (shuffle a) 0.0240 to 0.2304 introductory notes, Bird_2-Orange150: average 0.0250 to 0.0747 V; band (shuffle a) 0.0470 to 0.0948 introductory notes, Bird_3-Uva4: average 0.0198 to 0.0734 V; band (shuffle a) 0.0215 to 0.2706 syllable onsets, Bird_1-b871: average 0.0237 to 0.0424 V; band (shuffle a) 0.0307 to 0.0386 syllable onsets, Bird_2-Orange150: average 0.0387 to 0.0743 V; band (shuffle a) 0.0508 to 0.0582 syllable onsets, Bird_3-Uva4: average 0.0307 to 0.0712 V; band (shuffle a) 0.0331 to 0.0487 syllable offsets, Bird_1-b871: average 0.0232 to 0.0429 V; band (shuffle a) 0.0307 to 0.0385 syllable offsets, Bird_2-Orange150: average 0.0378 to 0.0658 V; band (shuffle a) 0.0508 to 0.0582 syllable offsets, Bird_3-Uva4: average 0.0321 to 0.0566 V; band (shuffle a) 0.0331 to 0.0487 bout offsets, Bird_1-b871: average 0.0192 to 0.0385 V; band (shuffle a) 0.0210 to 0.0428 bout offsets, Bird_2-Orange150: average 0.0212 to 0.0591 V; band (shuffle a) 0.0254 to 0.0723 bout offsets, Bird_3-Uva4: average 0.0179 to 0.0353 V; band (shuffle a) 0.0181 to 0.0529
Bands: blue shuffle (a), orange shuffle (b); lines are the shuffles' mean level. Every average is within its axes.
no-motif-bout-signalΒΆ
Uva shows little activation related to the onsets or offsets of motifs or bouts.
Per rendition, mean MUA in the 40 ms before onset (the window of the fig6 test) for motif onsets (first syllable of a motif rendition), bout onsets (the first song syllable of a bout, after any introductory notes) and other syllable onsets. One-sided two-sample t-test (motif or bout larger) at p < 0.05, the claims file's standard choice. After motif and bout offsets, the offset-aligned average is compared with the upper band of the shuffled baseline (inside bouts) from 0 to +150 ms.
rows = []
for bird in BIRDS:
R = renditions[bird]
motif_on = {}
motif_off = {}
for ev, m, pts in R["rows"]:
motif_on.setdefault(ev["key"], []).append(pts[0]); motif_off.setdefault(ev["key"], []).append(pts[-1])
v_motif, v_bout, v_other = [], [], []
off_motif, off_bout = [], []
for ev, m in bird_traces(bird):
song = syl_mask(ev)
bout_first = set()
for a, b, idx in ev["bouts"]:
s = [i for i in idx if song[i]]
if s:
bout_first.add(s[0])
off_bout.append(ev["off"][s[-1]])
mo = set(np.round(motif_on.get(ev["key"], [])).astype(int))
for i in np.where(song)[0]:
t = int(round(ev["on"][i]))
if t < 40:
continue
v = m[t - 40:t].mean()
if t in mo:
v_motif.append(v)
elif i in bout_first:
v_bout.append(v)
else:
v_other.append(v)
off_motif += [(m, t) for t in motif_off.get(ev["key"], [])]
tm = stats.ttest_ind(v_motif, v_other, alternative="greater")
tb = stats.ttest_ind(v_bout, v_other, alternative="greater")
rng = np.random.default_rng(31)
exc = {}
for name, items in [("motif offsets", off_motif)]:
A = np.concatenate([uva.aligned(m, [t], PRE, POST)[0] for m, t in items])
level, lo, hi_ = uva.shuffle_band(inside_bout_pool(bird), len(A), PRE, POST, 1000, rng)
exc[name] = float((A.mean(0)[PRE:PRE + 151] - hi_).max())
Ab = []
for ev, m in bird_traces(bird):
song = syl_mask(ev)
offs = [ev["off"][[i for i in idx if song[i]][-1]] for a, b, idx in ev["bouts"] if any(song[i] for i in idx)]
Ab.append(uva.aligned(m, offs, PRE, POST)[0])
Ab = np.concatenate(Ab)
level, lo, hi_ = uva.shuffle_band(inside_bout_pool(bird), len(Ab), PRE, POST, 1000, rng)
exc["bout offsets"] = float((Ab.mean(0)[PRE:PRE + 151] - hi_).max())
rows.append({"bird": bird, "n_motif_on": len(v_motif), "n_bout_on": len(v_bout), "n_other": len(v_other),
"motif_on": np.mean(v_motif), "bout_on": np.mean(v_bout), "other_on": np.mean(v_other),
"p_motif_gt_other": tm.pvalue, "p_bout_gt_other": tb.pvalue,
"max_excess_after_motif_off": exc["motif offsets"], "max_excess_after_bout_off": exc["bout offsets"]})
nm = pd.DataFrame(rows)
print(nm.to_string(index=False))
print("A positive excess means the offset-aligned average rises above the band's upper edge after the offset.")
bird n_motif_on n_bout_on n_other motif_on bout_on other_on p_motif_gt_other p_bout_gt_other max_excess_after_motif_off max_excess_after_bout_off
Bird_1-b871 112 410 1616 0.038184 0.037679 0.038107 0.458209 0.845021 -0.059037 -0.028354
Bird_2-Orange150 153 28 1750 0.063482 0.059118 0.060709 0.001182 0.778045 -0.050140 -0.065066
Bird_3-Uva4 44 2 271 0.054234 0.035676 0.052732 0.183383 0.990107 -0.027898 -0.172770
A positive excess means the offset-aligned average rises above the band's upper edge after the offset.
Result: not reproduced (assumed channel). MUA before motif onsets is significantly higher than before other syllable onsets in Orange150 (0.0635 against 0.0607, p = 0.0012), though not in b871 (p = 0.46) or Uva4 (p = 0.18). Bout onsets are not higher in any bird (p 0.78 to 0.99), and no average rises above the band after motif or bout offsets (largest excess below zero in all).
Lesion dataΒΆ
The lesion archive holds, for each of 7 birds, a folder of song before the lesion and one after it, each with the authors' analysis file (segment times at 44.1 kHz, and which segments are selected) and the .wav files it lists. The archive is streamed twice: first for the analysis files, then for the audio, of which only the amplitude traces and the bouts chosen for the maturity index are kept.
t0 = time.time()
les = uva.load_lesion_dbases()
print(f"Lesion analysis files read in {time.time() - t0:.0f} s")
def syllables(db):
"""Selected segments per file (ms), sorted, and the file name."""
out = []
for f in db["files"]:
s = f["seg"][f["selected"]] / db["fs"] * 1000.0
if len(s):
out.append((f["sound_file"], s[np.argsort(s[:, 0])]))
return out
LKEYS = sorted(les["dbase"])
LBIRDS = sorted({k[0] for k in LKEYS})
summary = []
for k in LKEYS:
db = les["dbase"][k]
T = np.array([f["time"] for f in db["files"]])
syl = syllables(db)
durs = np.concatenate([s[:, 1] - s[:, 0] for _, s in syl])
days = pd.Series(pd.to_datetime(T - 719529, unit="D")).dt.date.value_counts().to_dict()
summary.append({"bird": k[0], "condition": k[1], "fs": db["fs"], "files": len(db["files"]),
"segments": sum(len(f["seg"]) for f in db["files"]), "selected": len(durs),
"dates": {str(d): n for d, n in sorted(days.items())},
"span_h": (T.max() - T.min()) * 24, "audio_min": sum(f["length"] for f in db["files"]) / db["fs"] / 60,
"median_syl_ms": np.median(durs)})
summ = pd.DataFrame(summary)
Lesion analysis files read in 67 s
print(summ.round(2).to_string(index=False))
print("\nOther files:")
for name, v in les["other"].items():
print(" ", name, v["bytes"], "bytes, MD5", les["md5"][name])
for k, v in les["syllgaps"].items():
db = les["dbase"][k]
syl = syllables(db)
durs = np.concatenate([s[:, 1] - s[:, 0] for _, s in syl])
print(f"\nSyllGaps.mat in {k}: {len(v['durs'])} durations (median {np.median(v['durs']):.1f} ms) and {len(v['gaps'])} gaps; "
f"the analysis file's selected segments: {len(durs)} (median {np.median(durs):.1f} ms). The two differ; "
"SyllGaps.mat is not described by the data descriptor and is shown as a variant only.")
bird condition fs files segments selected dates span_h audio_min median_syl_ms
Bird_1-Purple53 post-lesion 44100.0 2567 25905 8690 {'2012-12-06': 2567} 23.66 146.71 71.41
Bird_1-Purple53 pre-lesion 44100.0 1414 13222 7850 {'2012-12-03': 1414} 21.49 73.28 94.55
Bird_2-Purple94 post-lesion 44100.0 856 16299 7233 {'2012-09-30': 856} 23.65 56.54 66.80
Bird_2-Purple94 pre-lesion 44100.0 2073 33996 15880 {'2012-09-26': 2073} 22.55 163.27 75.33
Bird_3-LBlue15 post-lesion 44100.0 260 4967 3572 {'2012-12-16': 49, '2012-12-17': 211} 36.32 21.23 76.49
Bird_3-LBlue15 pre-lesion 44100.0 702 7318 6694 {'2012-12-13': 702} 8.96 38.19 79.86
Bird_4-LPink13 post-lesion 44100.0 677 6217 2855 {'2013-01-27': 677} 3.43 39.67 73.97
Bird_4-LPink13 pre-lesion 44100.0 589 10302 7047 {'2013-01-25': 589} 2.22 58.31 146.78
Bird_5-Blue68 post-lesion 44100.0 1088 28624 14133 {'2012-11-13': 1088} 23.73 122.34 64.13
Bird_5-Blue68 pre-lesion 44100.0 1167 34702 20127 {'2012-11-10': 1167} 21.48 133.85 69.02
Bird_6-LPink15 post-lesion 44100.0 162 3138 2129 {'2013-01-30': 162} 22.72 15.13 84.83
Bird_6-LPink15 pre-lesion 44100.0 432 10629 7744 {'2013-01-27': 432} 23.02 48.92 146.87
Bird_7-Red92 post-lesion 44100.0 215 6062 2541 {'2012-11-13': 99, '2012-11-14': 116} 41.58 27.09 57.07
Bird_7-Red92 pre-lesion 44100.0 631 22789 17125 {'2012-11-08': 631} 21.17 101.91 87.51
Other files:
Lesion_Experiments/Bird_3-LBlue15/Post-lesion/LBlue15_Vector_Clust_Post_Lesion_20140313.mat 133977969 bytes, MD5 45d1b12dd609d0e231fdc7d833edf4f7
Lesion_Experiments/Bird_3-LBlue15/Pre-lesion/LBlue15_Vector_Clust_Pre_Lesion_20140313.mat 82154120 bytes, MD5 2d374ac6a4e4803c7923f9f75e02fc54
Lesion_Experiments/Bird_4-LPink13/Post-lesion/LPink13_Vector_Cluster_20140313.mat 133977969 bytes, MD5 0746bf6e9ead66188f2b864731e7ed7b
Lesion_Experiments/Bird_4-LPink13/Pre-lesion/LPink13_vector_cluster_Pre_lesion_20140313.mat 220444487 bytes, MD5 e47fad418160a953b05c4930d4b4e633
SyllGaps.mat in ('Bird_2-Purple94', 'post-lesion'): 6933 durations (median 56.7 ms) and 6706 gaps; the analysis file's selected segments: 7233 (median 66.8 ms). The two differ; SyllGaps.mat is not described by the data descriptor and is shown as a variant only.
SEED_MI = 1
rng_mi = np.random.default_rng(SEED_MI)
chosen, keep = {}, {}
for k in LKEYS:
db = les["dbase"][k]
fs = db["fs"]
for gap in (300, 350):
cands = []
for f in db["files"]:
s = f["seg"][f["selected"]] # samples
for b in uva.bouts_from_segments(s, gap / 1000 * fs):
a, z = s[b, 0].min(), s[b, 1].max()
if 0.7 * fs <= z - a <= 2 * fs:
cands.append((f["sound_file"], int(a), int(z)))
pick = [cands[i] for i in sorted(rng_mi.choice(len(cands), min(100, len(cands)), replace=False))]
chosen[(k, gap)] = (len(cands), pick)
for w, a, z in pick:
keep.setdefault((k[0], k[1], w), set()).add((a, z))
keep = {k: sorted(v) for k, v in keep.items()}
t0 = time.time()
aud = uva.load_lesion_audio(keep)
print(f"Lesion audio streamed in {time.time() - t0:.0f} s; peak memory "
f"{resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1e6:.1f} GB")
Lesion audio streamed in 179 s; peak memory 5.5 GB
print("Sampling rates of the .wav files:", pd.Series(list(aud["fs"].values())).value_counts().to_dict(),
"; analysis files: 44100")
listed = {(k[0], k[1], f["sound_file"]) for k in LKEYS for f in les["dbase"][k]["files"]}
have = set(aud["amp"])
print(f"Files listed in the analysis files: {len(listed)}; .wav files in the archive: {len(have)}; "
f"listed but missing: {len(listed - have)}; present but not listed: {len(have - listed)}")
lens_ok = [abs(len(aud["amp"][(k[0], k[1], f["sound_file"])][0]) - f["length"] / 44.1) <= 2
for k in LKEYS for f in les["dbase"][k]["files"] if (k[0], k[1], f["sound_file"]) in have]
print(f"Files whose length matches the analysis file's FileLength: {sum(lens_ok)} of {len(lens_ok)}")
wav_md5 = pd.Series(aud["md5"])
print("wav files with identical content to another:", int(wav_md5.duplicated(keep=False).sum()))
# Clock check: amplitude (dB) inside selected segments against outside, true and shifted labels.
rows = []
for k in LKEYS:
db = les["dbase"][k]
r = {"bird": k[0], "condition": k[1]}
for shift in [0, 200, 1000]:
ins, outs = [], []
for w, s in syllables(db)[:300]:
a = aud["amp"][(k[0], k[1], w)][0]
mask = np.zeros(len(a), bool)
for x, y in s + shift:
mask[int(max(0, x)):int(min(len(a), y))] = True
if mask.any() and (~mask).any():
ins.append(a[mask].mean()); outs.append(a[~mask].mean())
r[f"dB in minus out, shift {shift} ms"] = np.mean(ins) - np.mean(outs)
rows.append(r)
print(pd.DataFrame(rows).round(2).to_string(index=False))
Sampling rates of the .wav files: {44100: 12833} ; analysis files: 44100
Files listed in the analysis files: 12833; .wav files in the archive: 12833; listed but missing: 0; present but not listed: 0
Files whose length matches the analysis file's FileLength: 12833 of 12833
wav files with identical content to another: 0
bird condition dB in minus out, shift 0 ms dB in minus out, shift 200 ms dB in minus out, shift 1000 ms Bird_1-Purple53 post-lesion 20.389999 2.330000 -2.24 Bird_1-Purple53 pre-lesion 29.700001 11.640000 -7.25 Bird_2-Purple94 post-lesion 17.270000 3.180000 -1.64 Bird_2-Purple94 pre-lesion 22.620001 7.680000 -0.03 Bird_3-LBlue15 post-lesion 24.600000 7.150000 -1.90 Bird_3-LBlue15 pre-lesion 34.740002 12.710000 -6.48 Bird_4-LPink13 post-lesion 26.389999 0.780000 -0.95 Bird_4-LPink13 pre-lesion 37.959999 19.879999 4.71 Bird_5-Blue68 post-lesion 25.129999 4.430000 0.11 Bird_5-Blue68 pre-lesion 30.500000 9.010000 1.05 Bird_6-LPink15 post-lesion 30.559999 3.890000 -1.37 Bird_6-LPink15 pre-lesion 38.139999 18.299999 0.76 Bird_7-Red92 post-lesion 23.070000 4.420000 -1.09 Bird_7-Red92 pre-lesion 34.169998 12.710000 1.74
The analysis files hold one recording day before and one after the lesion for each bird (two post-lesion folders span two calendar dates, recordings that run past midnight). So the claims' readings of which post-lesion day to use (first day, or all days pooled) are the same here. The data do not say whether this post-lesion day is the first day of singing after surgery.
# Is directed song marked anywhere? File names, their parts, recording hours and properties.
for k in LKEYS:
db = les["dbase"][k]
names = [f["sound_file"] for f in db["files"]]
T = np.array([f["time"] for f in db["files"]])
hours = pd.Series(pd.to_datetime(T - 719529, unit="D")).dt.hour
fields = {len(n[:-4].split("_")) for n in names}
print(f"{k[0]} {k[1]}: {len(names)} files, e.g. {names[0]} ... {names[-1]}; fields per name {sorted(fields)}; "
f"properties {db['property_names'] or 'none'}; files per hour of day {hours.value_counts().sort_index().to_dict()}")
print("Names are <bird>_<MATLAB date number>_<month>_<day>_<hour>_<minute>_<second>.wav; no part of them, and no "
"property, marks a recording as directed or undirected.")
Bird_1-Purple53 post-lesion: 2567 files, e.g. 53_41249.0024768518_12_6_0_3_34.wav ... 53_41249.9884953704_12_6_23_43_26.wav; fields per name [7]; properties none; files per hour of day {0: 13, 1: 19, 2: 9, 3: 5, 4: 2, 5: 2, 6: 7, 7: 13, 8: 1, 9: 13, 10: 152, 11: 216, 12: 320, 13: 275, 14: 159, 15: 172, 16: 231, 17: 415, 18: 136, 19: 189, 20: 140, 21: 62, 22: 14, 23: 2}
Bird_1-Purple53 pre-lesion: 1414 files, e.g. 53_41246.0076157407_12_3_0_10_58.wav ... 53_41246.903125_12_3_21_40_30.wav; fields per name [7]; properties none; files per hour of day {0: 12, 1: 4, 2: 8, 3: 7, 4: 9, 5: 9, 6: 3, 7: 1, 8: 3, 9: 7, 10: 286, 11: 590, 12: 82, 13: 44, 14: 55, 15: 62, 16: 32, 17: 53, 18: 44, 19: 47, 20: 32, 21: 24}
Bird_2-Purple94 post-lesion: 856 files, e.g. 94_41182.0044675926_9_30_0_6_26.wav ... 94_41182.9900925926_9_30_23_45_44.wav; fields per name [7]; properties none; files per hour of day {0: 20, 1: 3, 2: 6, 3: 3, 5: 3, 9: 56, 10: 65, 11: 67, 12: 176, 13: 59, 14: 49, 15: 1, 16: 99, 17: 79, 18: 18, 19: 78, 20: 28, 21: 43, 22: 2, 23: 1}
Bird_2-Purple94 pre-lesion: 2073 files, e.g. 94_41178.0378703704_9_26_0_54_32.wav ... 94_41178.9775_9_26_23_27_36.wav; fields per name [7]; properties none; files per hour of day {0: 1, 10: 193, 11: 268, 12: 284, 13: 340, 14: 201, 15: 179, 16: 185, 17: 79, 18: 91, 19: 108, 20: 52, 21: 65, 22: 24, 23: 3}
Bird_3-LBlue15 post-lesion: 260 files, e.g. 15_41259.4525462963_12_16_10_51_40.wav ... 15_41260.9660185185_12_17_23_11_4.wav; fields per name [7]; properties none; files per hour of day {4: 1, 10: 17, 11: 40, 12: 29, 13: 24, 14: 33, 15: 27, 16: 20, 17: 2, 18: 13, 19: 20, 20: 11, 21: 19, 22: 3, 23: 1}
Bird_3-LBlue15 pre-lesion: 702 files, e.g. 15_41256.4056712963_12_13_9_44_10.wav ... 15_41256.7791435185_12_13_18_41_58.wav; fields per name [7]; properties none; files per hour of day {9: 1, 10: 42, 11: 225, 12: 164, 13: 213, 14: 56, 18: 1}
Bird_4-LPink13 post-lesion: 677 files, e.g. 13_41301.38120106_1_27_10_35_20.wav ... 13_41301.50465621_1_27_14_1_5.wav; fields per name [7]; properties none; files per hour of day {10: 63, 11: 233, 12: 236, 13: 144, 14: 1}
Bird_4-LPink13 pre-lesion: 589 files, e.g. 4_41299.41169312_1_25_11_26_9.wav ... 4_41299.49136578_1_25_13_38_56.wav; fields per name [7]; properties none; files per hour of day {11: 206, 12: 223, 13: 160}
Bird_5-Blue68 post-lesion: 1088 files, e.g. 68_41226.0102777778_11_13_0_14_48.wav ... 68_41226.9989583333_11_13_23_58_30.wav; fields per name [7]; properties none; files per hour of day {0: 7, 1: 2, 2: 5, 3: 1, 9: 2, 10: 100, 11: 137, 12: 148, 13: 139, 14: 85, 15: 126, 16: 113, 17: 87, 18: 32, 19: 10, 20: 49, 21: 22, 22: 22, 23: 1}
Bird_5-Blue68 pre-lesion: 1167 files, e.g. 68_41223.0269675926_11_10_0_38_50.wav ... 68_41223.92_11_10_22_4_48.wav; fields per name [7]; properties none; files per hour of day {0: 1, 1: 1, 2: 2, 3: 1, 4: 4, 5: 5, 6: 1, 7: 2, 9: 1, 10: 281, 11: 302, 12: 182, 13: 118, 14: 137, 15: 17, 16: 15, 17: 28, 18: 10, 19: 19, 20: 12, 21: 26, 22: 2}
Bird_6-LPink15 post-lesion: 162 files, e.g. 15_41304.0459953704_1_30_1_6_14.wav ... 15_41304.9926388889_1_30_23_49_24.wav; fields per name [7]; properties none; files per hour of day {1: 1, 10: 1, 11: 15, 12: 11, 13: 25, 14: 18, 15: 47, 16: 3, 17: 26, 18: 5, 19: 2, 21: 6, 23: 2}
Bird_6-LPink15 pre-lesion: 432 files, e.g. 15_41301.0407638889_1_27_0_58_42.wav ... 15_41301.9997685185_1_27_23_59_40.wav; fields per name [7]; properties none; files per hour of day {0: 1, 1: 2, 3: 3, 4: 4, 5: 1, 6: 4, 7: 6, 8: 1, 9: 1, 10: 61, 11: 138, 12: 150, 13: 5, 17: 1, 20: 1, 21: 36, 22: 5, 23: 12}
Bird_7-Red92 post-lesion: 215 files, e.g. 92_41226.0059027778_11_13_0_8_30.wav ... 92_41227.7381944444_11_14_17_43_0.wav; fields per name [7]; properties none; files per hour of day {0: 9, 1: 3, 2: 7, 3: 3, 4: 5, 5: 6, 6: 8, 8: 2, 9: 10, 10: 12, 11: 20, 12: 40, 13: 17, 14: 22, 15: 6, 16: 6, 17: 5, 18: 1, 20: 2, 21: 3, 22: 28}
Bird_7-Red92 pre-lesion: 631 files, e.g. 92_41221.077037037_11_8_1_50_56.wav ... 92_41221.9592361111_11_8_23_1_18.wav; fields per name [7]; properties none; files per hour of day {1: 2, 3: 2, 4: 1, 5: 2, 6: 1, 8: 2, 10: 204, 11: 193, 12: 138, 13: 72, 21: 1, 22: 12, 23: 1}
Names are <bird>_<MATLAB date number>_<month>_<day>_<hour>_<minute>_<second>.wav; no part of them, and no property, marks a recording as directed or undirected.
lesion-undirected-rate-similarΒΆ
In social isolation, Uva-lesioned birds sing at rates similar to intact birds.
Recording hours are the span from the first to the last file of the day (the recordings are triggered by sound, so silent hours are not recorded; the span is the closest measure of time available). Rates per hour of span: syllables, bouts (gaps up to 300 ms) and singing time (bout durations), counted on the selected segments (the authors' song syllables) and, as a variant, on all segments. Rates per hour of recorded audio (summed file lengths) are shown too.
rows = []
for k in LKEYS:
db = les["dbase"][k]
T = np.array([f["time"] for f in db["files"]])
span = (T.max() - T.min()) * 24
syl = syllables(db)
n_syl = sum(len(s) for _, s in syl)
bouts = [(s[b, 0].min(), s[b, 1].max()) for _, s in syl for b in uva.bouts_from_segments(s, 300)]
# all segments (selected or not), the authors' segmentation before their selection
alls = [f["seg"][np.argsort(f["seg"][:, 0])] / db["fs"] * 1000.0 for f in db["files"] if len(f["seg"])]
n_all = sum(len(s) for s in alls)
bouts_all = [(s[b, 0].min(), s[b, 1].max()) for s in alls for b in uva.bouts_from_segments(s, 300)]
audio_h = sum(f["length"] for f in db["files"]) / db["fs"] / 3600
rows.append({"bird": k[0], "condition": k[1], "span_h": span, "audio_h": audio_h,
"selected_fraction": n_syl / n_all,
"syllables_per_h": n_syl / span, "bouts_per_h": len(bouts) / span,
"singing_s_per_h": sum(b - a for a, b in bouts) / 1000 / span,
"all_segments_per_h": n_all / span, "all_bouts_per_h": len(bouts_all) / span,
"all_singing_s_per_h": sum(b - a for a, b in bouts_all) / 1000 / span,
"all_segments_per_audio_h": n_all / audio_h, "syllables_per_audio_h": n_syl / audio_h,
"syllables": n_syl, "bouts": len(bouts), "all_segments": n_all, "all_bouts": len(bouts_all)})
rate = pd.DataFrame(rows)
print(rate.round(2).to_string(index=False))
for col in ["syllables_per_h", "bouts_per_h", "singing_s_per_h", "all_segments_per_h", "all_bouts_per_h",
"all_singing_s_per_h", "syllables_per_audio_h", "all_segments_per_audio_h", "syllables", "bouts",
"all_segments", "all_bouts"]:
p = rate.pivot(index="bird", columns="condition", values=col)
w = stats.wilcoxon(p["post-lesion"], p["pre-lesion"])
print(f"{col}: post/pre ratio per bird {np.round((p['post-lesion'] / p['pre-lesion']).values, 2).tolist()}; "
f"Wilcoxon signed-rank p = {w.pvalue:.3f}")
bird condition span_h audio_h selected_fraction syllables_per_h bouts_per_h singing_s_per_h all_segments_per_h all_bouts_per_h all_singing_s_per_h all_segments_per_audio_h syllables_per_audio_h syllables bouts all_segments all_bouts Bird_1-Purple53 post-lesion 23.66 2.45 0.34 367.22 77.04 56.23 1094.69 317.53 128.81 10594.72 3554.07 8690 1823 25905 7514 Bird_1-Purple53 pre-lesion 21.49 1.22 0.59 365.25 53.93 53.85 615.20 160.66 76.98 10826.12 6427.55 7850 1159 13222 3453 Bird_2-Purple94 post-lesion 23.65 0.94 0.44 305.77 35.51 46.90 689.03 89.37 78.89 17296.54 7675.68 7233 840 16299 2114 Bird_2-Purple94 pre-lesion 22.55 2.72 0.47 704.11 79.63 96.50 1507.36 329.53 175.27 12492.86 5835.59 15880 1796 33996 7432 Bird_3-LBlue15 post-lesion 36.32 0.35 0.72 98.34 10.68 17.70 136.74 17.62 20.68 14039.73 10096.62 3572 388 4967 640 Bird_3-LBlue15 pre-lesion 8.96 0.64 0.91 746.82 103.31 116.74 816.44 138.79 121.96 11497.09 10516.74 6694 926 7318 1244 Bird_4-LPink13 post-lesion 3.43 0.66 0.46 832.50 155.13 159.48 1812.83 536.24 241.70 9402.49 4317.86 2855 532 6217 1839 Bird_4-LPink13 pre-lesion 2.22 0.97 0.68 3181.09 287.55 563.11 4650.43 888.38 675.20 10601.08 7251.59 7047 637 10302 1968 Bird_5-Blue68 post-lesion 23.73 2.04 0.49 595.62 104.35 95.08 1206.32 220.79 163.05 14037.85 6931.14 14133 2476 28624 5239 Bird_5-Blue68 pre-lesion 21.48 2.23 0.58 936.94 123.87 135.84 1615.42 252.35 198.76 15555.74 9022.26 20127 2661 34702 5421 Bird_6-LPink15 post-lesion 22.72 0.25 0.68 93.71 15.71 19.08 138.12 24.69 23.31 12443.57 8442.44 2129 357 3138 561 Bird_6-LPink15 pre-lesion 23.02 0.82 0.73 336.46 41.49 63.21 461.81 64.91 73.92 13035.98 9497.66 7744 955 10629 1494 Bird_7-Red92 post-lesion 41.58 0.45 0.42 61.12 9.84 9.17 145.81 29.42 17.71 13428.78 5628.92 2541 409 6062 1223 Bird_7-Red92 pre-lesion 21.17 1.70 0.75 808.83 75.48 115.18 1076.35 205.31 143.06 13417.39 10082.62 17125 1598 22789 4347 syllables_per_h: post/pre ratio per bird [1.01, 0.43, 0.13, 0.26, 0.64, 0.28, 0.08]; Wilcoxon signed-rank p = 0.031 bouts_per_h: post/pre ratio per bird [1.43, 0.45, 0.1, 0.54, 0.84, 0.38, 0.13]; Wilcoxon signed-rank p = 0.047 singing_s_per_h: post/pre ratio per bird [1.04, 0.49, 0.15, 0.28, 0.7, 0.3, 0.08]; Wilcoxon signed-rank p = 0.031 all_segments_per_h: post/pre ratio per bird [1.78, 0.46, 0.17, 0.39, 0.75, 0.3, 0.14]; Wilcoxon signed-rank p = 0.078 all_bouts_per_h: post/pre ratio per bird [1.98, 0.27, 0.13, 0.6, 0.87, 0.38, 0.14]; Wilcoxon signed-rank p = 0.109 all_singing_s_per_h: post/pre ratio per bird [1.67, 0.45, 0.17, 0.36, 0.82, 0.32, 0.12]; Wilcoxon signed-rank p = 0.078 syllables_per_audio_h: post/pre ratio per bird [0.55, 1.32, 0.96, 0.6, 0.77, 0.89, 0.56]; Wilcoxon signed-rank p = 0.078 all_segments_per_audio_h: post/pre ratio per bird [0.98, 1.38, 1.22, 0.89, 0.9, 0.95, 1.0]; Wilcoxon signed-rank p = 1.000 syllables: post/pre ratio per bird [1.11, 0.46, 0.53, 0.41, 0.7, 0.27, 0.15]; Wilcoxon signed-rank p = 0.031 bouts: post/pre ratio per bird [1.57, 0.47, 0.42, 0.84, 0.93, 0.37, 0.26]; Wilcoxon signed-rank p = 0.156 all_segments: post/pre ratio per bird [1.96, 0.48, 0.68, 0.6, 0.82, 0.3, 0.27]; Wilcoxon signed-rank p = 0.156 all_bouts: post/pre ratio per bird [2.18, 0.28, 0.51, 0.93, 0.97, 0.38, 0.28]; Wilcoxon signed-rank p = 0.219
Result: not reproduced (assumed measure). Counting the selected segments per hour of the recording span, lesioned birds sing less after the lesion: syllables per hour fall in 6 of 7 birds (post/pre ratio 0.08 to 1.01; Wilcoxon p = 0.031), as do bouts per hour (p = 0.047) and singing time (p = 0.031). The result depends on the count: with all segments, selected or not, the decreases are not significant (p = 0.078, 0.109 and 0.078), and the selected fraction differs between days (Purple53 0.59 before, 0.34 after). Per hour of recorded audio, all segments give p = 1.000 and selected segments p = 0.078, but recordings are triggered by sound, so recorded audio is not a measure of time. Spans range from 2.2 to 41.6 h.
fig2g-maturity-index-dropΒΆ
Uva lesions lower the maturity index, a measure of song repeatability, from 0.26 to 0.08 (Wilcoxon signed-rank test, p < 0.025, 7 birds).
100 bouts of 0.7 to 2 s drawn at random (seed fixed) per bird and condition, for bout gaps of 300 and 350 ms. Spectrograms by the Methods' parameters, 860 Hz to 8.6 kHz. The claims file's readings (a) and (b) of the lag correlation function are run. The paper says "correlation of power spectra"; read literally (Pearson correlation of each pair of slices' power spectra), the silent and noisy slices of every bout correlate through the shared shape of the background spectrum. Whether the spectra are log-scaled and whether the mean spectrum is removed before correlating is not stated, and these change the outcome, so four forms are run: power or log power, each as is or with the mean over all slices of the bird's condition removed from each frequency (and divided by its SD). See the deviations for the reading adopted. The Methods cite Aronov et al. 2008 for this measure; its supplement could not be read in this run (HTTP 403).
mi_rows = []
t0 = time.time()
for k in LKEYS:
for gap in (300, 350):
n_c, pick = chosen[(k, gap)]
specs = [uva.spectrogram_mt(aud["raw"][((k[0], k[1], w), a, z)].astype(float), 44100) for w, a, z in pick]
for form in ["power", "log", "power centred", "log centred"]:
S = [np.log(s + 1e-12) for s in specs] if form.startswith("log") else specs
if form.endswith("centred"):
allS = np.concatenate(S)
mu, sd = allS.mean(0), allS.std(0)
S = [(s - mu) / sd for s in S]
a_, b_ = uva.maturity_index(S)
mi_rows.append({"bird": k[0], "condition": k[1], "gap": gap, "form": form, "candidates": n_c,
"bouts": len(pick), "MI_a": a_, "MI_b": b_})
mi = pd.DataFrame(mi_rows)
print(f"(computed in {time.time() - t0:.0f} s)")
res = []
for (gap, form), g in mi.groupby(["gap", "form"]):
for rd in ["MI_a", "MI_b"]:
p = g.pivot(index="bird", columns="condition", values=rd)
w = stats.wilcoxon(p["post-lesion"], p["pre-lesion"])
res.append({"gap": gap, "form": form, "lag reading": rd[-1], "pre_mean": p["pre-lesion"].mean(),
"pre_sd": p["pre-lesion"].std(), "post_mean": p["post-lesion"].mean(), "post_sd": p["post-lesion"].std(),
"birds_decreasing": int((p["post-lesion"] < p["pre-lesion"]).sum()), "wilcoxon_p": w.pvalue,
"pre_in_tol": abs(p["pre-lesion"].mean() - 0.26) <= 0.03, "post_in_tol": abs(p["post-lesion"].mean() - 0.08) <= 0.02})
mi_res = pd.DataFrame(res)
print(mi_res.round(3).to_string(index=False))
print("\nPer bird, log centred, gap 300 ms, reading a:")
print(mi[(mi.gap == 300) & (mi.form == "log centred")].pivot(index="bird", columns="condition", values="MI_a").round(3).to_string())
print("\nPer bird, power (literal reading), gap 300 ms, reading a:")
print(mi[(mi.gap == 300) & (mi.form == "power")].pivot(index="bird", columns="condition", values="MI_a").round(3).to_string())
print("Paper: pre 0.26 +- 0.03, post 0.08 +- 0.02, p < 0.025, 7 birds.")
(computed in 376 s) gap form lag reading pre_mean pre_sd post_mean post_sd birds_decreasing wilcoxon_p pre_in_tol post_in_tol 300 log a 0.406 0.094 0.462 0.089 2 0.469 False False 300 log b 0.554 0.099 0.620 0.048 1 0.078 False False 300 log centred a 0.235 0.087 0.096 0.031 7 0.016 True True 300 log centred b 0.355 0.055 0.249 0.022 7 0.016 False False 300 power a 0.330 0.057 0.396 0.050 1 0.109 False False 300 power b 0.456 0.059 0.542 0.024 0 0.016 False False 300 power centred a 0.501 0.078 0.493 0.069 4 0.812 False False 300 power centred b 0.618 0.124 0.654 0.076 2 0.469 False False 350 log a 0.386 0.087 0.458 0.099 2 0.297 False False 350 log b 0.545 0.100 0.612 0.059 2 0.109 False False 350 log centred a 0.213 0.077 0.098 0.033 7 0.016 False True 350 log centred b 0.346 0.048 0.257 0.025 7 0.016 False False 350 power a 0.321 0.055 0.401 0.054 1 0.078 False False 350 power b 0.451 0.061 0.539 0.034 1 0.047 False False 350 power centred a 0.507 0.102 0.500 0.075 4 1.000 False False 350 power centred b 0.630 0.135 0.656 0.076 2 0.812 False False Per bird, log centred, gap 300 ms, reading a: condition post-lesion pre-lesion bird Bird_1-Purple53 0.094 0.292 Bird_2-Purple94 0.083 0.104 Bird_3-LBlue15 0.115 0.304 Bird_4-LPink13 0.056 0.280 Bird_5-Blue68 0.066 0.115 Bird_6-LPink15 0.144 0.287 Bird_7-Red92 0.116 0.261 Per bird, power (literal reading), gap 300 ms, reading a: condition post-lesion pre-lesion bird Bird_1-Purple53 0.344 0.434 Bird_2-Purple94 0.391 0.308 Bird_3-LBlue15 0.393 0.294 Bird_4-LPink13 0.391 0.374 Bird_5-Blue68 0.354 0.274 Bird_6-LPink15 0.397 0.293 Bird_7-Red92 0.498 0.336 Paper: pre 0.26 +- 0.03, post 0.08 +- 0.02, p < 0.025, 7 birds.
Result: partially reproduced, resting on an assumption. With log spectra centred on the condition's mean spectrum, lag reading (a) and 300 ms gaps, MI falls from 0.235 to 0.096 (paper 0.26 +- 0.03 and 0.08 +- 0.02), in all 7 birds (Wilcoxon p = 0.016). That form is this attempt's, not a reading the claims file lists, and it is the only one of the 16 combinations that puts both values in tolerance (with 350 ms gaps the pre value is 0.213, just outside). Read literally (raw power or log power, not centred), MI does not fall (2 or fewer birds decrease) and its values (0.32 to 0.62) are far from the paper's. The Methods take the measure from Aronov et al. 2008, whose supplement could not be read in this run, so the decrease rests on the adopted form.
fig2f-closer-to-exponentialΒΆ
After Uva lesions syllable-duration distributions are much closer to exponential (goodness of fit Gamma 3.7 against 16 before; Wilcoxon signed-rank test, p < 0.025, 7 birds), but stay above the subsong criterion of Gamma < 2.
Syllables are the selected segments of each day. Gamma readings (a) D times the square root of n and (b) D over the Lilliefors critical value at alpha 0.05 (1.06 / sqrt(n) for the exponential, Lilliefors 1969). Ref 41 (Aronov et al. 2008) could not be read in this run (its supplement returned HTTP 403), so its definition could not be checked. Variant: the durations of SyllGaps.mat (one bird).
rows = []
for k in LKEYS:
durs = np.concatenate([s[:, 1] - s[:, 0] for _, s in syllables(les["dbase"][k])])
g = uva.gamma_readings(durs)
rows.append({"bird": k[0], "condition": k[1], "n": g["n"], "D": g["D"], "Gamma_a": g["a"], "Gamma_b": g["b"]})
gam = pd.DataFrame(rows)
print(gam.round(3).to_string(index=False))
for rd in ["Gamma_a", "Gamma_b", "D"]:
p = gam.pivot(index="bird", columns="condition", values=rd)
w = stats.wilcoxon(p["post-lesion"], p["pre-lesion"])
print(f"{rd}: pre {p['pre-lesion'].mean():.2f} +- {p['pre-lesion'].std():.2f}, post {p['post-lesion'].mean():.2f} +- "
f"{p['post-lesion'].std():.2f}; birds decreasing {(p['post-lesion'] < p['pre-lesion']).sum()} of 7; Wilcoxon p = {w.pvalue:.4f}")
for k, v in les["syllgaps"].items():
g = uva.gamma_readings(v["durs"])
print(f"Variant, SyllGaps.mat {k}: n = {g['n']}, D = {g['D']:.3f}, Gamma_a = {g['a']:.2f}, Gamma_b = {g['b']:.2f}")
print("Paper: pre 16 +- 6, post 3.7 +- 1.2, p < 0.025; post above 2.")
bird condition n D Gamma_a Gamma_b
Bird_1-Purple53 post-lesion 8690 0.209 19.438 18.338
Bird_1-Purple53 pre-lesion 7850 0.321 28.480 26.868
Bird_2-Purple94 post-lesion 7233 0.192 16.316 15.392
Bird_2-Purple94 pre-lesion 15880 0.269 33.926 32.006
Bird_3-LBlue15 post-lesion 3572 0.209 12.477 11.771
Bird_3-LBlue15 pre-lesion 6694 0.411 33.586 31.685
Bird_4-LPink13 post-lesion 2855 0.222 11.857 11.186
Bird_4-LPink13 pre-lesion 7047 0.269 22.581 21.303
Bird_5-Blue68 post-lesion 14133 0.231 27.420 25.868
Bird_5-Blue68 pre-lesion 20127 0.204 28.955 27.316
Bird_6-LPink15 post-lesion 2129 0.170 7.825 7.382
Bird_6-LPink15 pre-lesion 7744 0.276 24.315 22.938
Bird_7-Red92 post-lesion 2541 0.219 11.027 10.403
Bird_7-Red92 pre-lesion 17125 0.313 41.014 38.692
Gamma_a: pre 30.41 +- 6.31, post 15.19 +- 6.57; birds decreasing 7 of 7; Wilcoxon p = 0.0156
Gamma_b: pre 28.69 +- 5.96, post 14.33 +- 6.20; birds decreasing 7 of 7; Wilcoxon p = 0.0156
D: pre 0.29 +- 0.06, post 0.21 +- 0.02; birds decreasing 6 of 7; Wilcoxon p = 0.0312
Variant, SyllGaps.mat ('Bird_2-Purple94', 'post-lesion'): n = 6933, D = 0.111, Gamma_a = 9.26, Gamma_b = 8.74
Paper: pre 16 +- 6, post 3.7 +- 1.2, p < 0.025; post above 2.
Result: partially reproduced. Syllable durations are closer to exponential after the lesion in all 7 birds (Wilcoxon p = 0.016 under both readings) and stay above 2, but Gamma is about twice the paper's: reading (a) 30.4 before and 15.2 after (paper 16 +- 6 and 3.7 +- 1.2), reading (b) 28.7 and 14.3.
fig2c-small-syllable-peakΒΆ
In 6 of 7 Uva-lesioned birds the post-lesion syllable-duration distribution has a small peak at 50 to 100 ms.
rows = []
for k in [k for k in LKEYS if k[1] == "post-lesion"]:
durs = np.concatenate([s[:, 1] - s[:, 0] for _, s in syllables(les["dbase"][k])])
for bw in (5, 10):
edges = np.arange(0, 1000 + bw, bw)
h, _ = np.histogram(durs, edges)
c = edges[:-1] + bw / 2
expd = len(durs) * (np.exp(-edges[:-1] / durs.mean()) - np.exp(-edges[1:] / durs.mean()))
w = (c >= 50) & (c <= 100)
loc = np.r_[False, (h[1:-1] > h[:-2]) & (h[1:-1] >= h[2:]), False]
a_ = bool(np.any(loc & w & (h > expd)))
hi95 = stats.poisson.ppf(0.975, expd)
b_ = bool(np.any(loc & w & (h > hi95)))
rows.append({"bird": k[0], "bin_ms": bw, "n": len(durs), "local_max_50_100_ms": c[loc & w].tolist(),
"reading_a": a_, "reading_b": b_})
pk = pd.DataFrame(rows)
print(pk.to_string(index=False))
for bw in (5, 10):
s = pk[pk.bin_ms == bw]
print(f"bins {bw} ms: reading (a) {s.reading_a.sum()} of 7, reading (b) {s.reading_b.sum()} of 7 (paper 6 of 7)")
bird bin_ms n local_max_50_100_ms reading_a reading_b Bird_1-Purple53 5 8690 [52.5, 67.5, 87.5] True True Bird_1-Purple53 10 8690 [55.0] True True Bird_2-Purple94 5 7233 [52.5, 67.5, 92.5] True True Bird_2-Purple94 10 7233 [65.0] True True Bird_3-LBlue15 5 3572 [57.5, 72.5] True True Bird_3-LBlue15 10 3572 [75.0] True True Bird_4-LPink13 5 2855 [67.5, 97.5] True True Bird_4-LPink13 10 2855 [65.0, 95.0] True True Bird_5-Blue68 5 14133 [67.5] True True Bird_5-Blue68 10 14133 [55.0] True True Bird_6-LPink15 5 2129 [52.5, 62.5, 77.5, 97.5] True True Bird_6-LPink15 10 2129 [55.0] True True Bird_7-Red92 5 2541 [62.5, 77.5, 92.5] True True Bird_7-Red92 10 2541 [] False False bins 5 ms: reading (a) 7 of 7, reading (b) 7 of 7 (paper 6 of 7) bins 10 ms: reading (a) 6 of 7, reading (b) 6 of 7 (paper 6 of 7)
fig, axs = plt.subplots(1, 7, figsize=(21, 3), sharex=True)
for ax, k in zip(axs, [k for k in LKEYS if k[1] == "post-lesion"]):
durs = np.concatenate([s[:, 1] - s[:, 0] for _, s in syllables(les["dbase"][k])])
edges = np.arange(0, 1005, 5)
h, _ = np.histogram(durs, edges)
expd = len(durs) * (np.exp(-edges[:-1] / durs.mean()) - np.exp(-edges[1:] / durs.mean()))
c = edges[:-1] + 2.5
ax.bar(c, h, width=5, color="0.6")
ax.plot(c, expd, "C0", lw=1, label="fitted exponential")
ax.plot(c, stats.poisson.ppf(0.975, expd), "C0--", lw=1, label="its 97.5% bound")
ax.axvspan(50, 100, color="C1", alpha=0.15)
ax.set_xlim(0, 300); ax.set_title(k[0], fontsize=9); ax.set_xlabel("syllable duration (ms)")
print(f"{k[0]}: {int((durs > 300).sum())} of {len(durs)} syllables beyond 300 ms (off the axes); "
f"largest bin count {h.max()}")
axs[0].set_ylabel("syllables per 5 ms bin"); axs[0].legend(fontsize=7)
plt.tight_layout(); plt.show()
Bird_1-Purple53: 46 of 8690 syllables beyond 300 ms (off the axes); largest bin count 487 Bird_2-Purple94: 47 of 7233 syllables beyond 300 ms (off the axes); largest bin count 492
Bird_3-LBlue15: 60 of 3572 syllables beyond 300 ms (off the axes); largest bin count 203
Bird_4-LPink13: 14 of 2855 syllables beyond 300 ms (off the axes); largest bin count 184
Bird_5-Blue68: 36 of 14133 syllables beyond 300 ms (off the axes); largest bin count 871 Bird_6-LPink15: 58 of 2129 syllables beyond 300 ms (off the axes); largest bin count 111
Bird_7-Red92: 20 of 2541 syllables beyond 300 ms (off the axes); largest bin count 182
Result: partially reproduced. With 5 ms bins all 7 birds have a local maximum at 50 to 100 ms above the fitted exponential and above its 97.5% Poisson bound (both readings); with 10 ms bins (variant) 6 of 7 do, as the paper reports. The count under the main bins is 7, one more than the paper's 6. The histograms show that several of these maxima are bumps of one or two bins (LPink15 has four between 50 and 100 ms), so the 5 ms count is sensitive to count noise.
fig2d-gaps-broaderΒΆ
After Uva lesions gap durations become broadly distributed, with more long and more short gaps, like subsong.
rows = []
for b in LBIRDS:
g = {}
for cond in ["pre-lesion", "post-lesion"]:
gs = []
for _, s in syllables(les["dbase"][(b, cond)]):
d = s[1:, 0] - s[:-1, 1]
gs.append(d[d <= 300])
g[cond] = np.concatenate(gs)
lo, hi5 = np.percentile(g["pre-lesion"], [5, 95])
post = g["post-lesion"]
iqr = lambda x: np.subtract(*np.percentile(np.log(x[x > 0]), [75, 25]))
rows.append({"bird": b, "gaps_pre": len(g["pre-lesion"]), "gaps_post": len(post), "pre_p5_ms": lo, "pre_p95_ms": hi5,
"post_frac_short": np.mean(post < lo), "post_frac_long": np.mean(post > hi5),
"post_frac_outside": np.mean((post < lo) | (post > hi5)),
"iqr_log_pre": iqr(g["pre-lesion"]), "iqr_log_post": iqr(post)})
gp = pd.DataFrame(rows)
print(gp.round(3).to_string(index=False))
print(f"Reading (a): birds with more than 10% outside {(gp.post_frac_outside > 0.10).sum()} of 7; both short and long fractions "
f"above 5%: {((gp.post_frac_short > 0.05) & (gp.post_frac_long > 0.05)).sum()} of 7")
w = stats.wilcoxon(gp.post_frac_outside - 0.10)
print(f" Wilcoxon on (fraction outside - 0.10): p = {w.pvalue:.4f}")
w2 = stats.wilcoxon(gp.iqr_log_post, gp.iqr_log_pre)
print(f"Reading (b): IQR of log gap larger after in {(gp.iqr_log_post > gp.iqr_log_pre).sum()} of 7; Wilcoxon p = {w2.pvalue:.4f}")
bird gaps_pre gaps_post pre_p5_ms pre_p95_ms post_frac_short post_frac_long post_frac_outside iqr_log_pre iqr_log_post Bird_1-Purple53 6691 6867 9.070 144.512 0.029 0.193 0.221 1.265 1.187 Bird_2-Purple94 14084 6393 11.837 157.729 0.096 0.128 0.224 0.558 1.498 Bird_3-LBlue15 5768 3184 26.471 145.313 0.145 0.203 0.349 0.625 1.024 Bird_4-LPink13 6410 2323 29.076 185.278 0.125 0.259 0.384 0.669 1.057 Bird_5-Blue68 17466 11657 12.477 205.692 0.051 0.112 0.163 1.242 1.129 Bird_6-LPink15 6789 1772 17.347 195.410 0.087 0.127 0.214 0.826 1.068 Bird_7-Red92 15527 2132 16.825 145.741 0.094 0.209 0.303 0.708 0.983 Reading (a): birds with more than 10% outside 7 of 7; both short and long fractions above 5%: 6 of 7 Wilcoxon on (fraction outside - 0.10): p = 0.0156 Reading (b): IQR of log gap larger after in 5 of 7; Wilcoxon p = 0.0781
Result: reproduced. After the lesion 16 to 38% of gaps fall outside the bird's pre-lesion 5th to 95th percentiles, against 10% if unchanged (Wilcoxon p = 0.016); the long fraction rises in all 7 birds and the short fraction exceeds 5% in 6 of 7. The interquartile range of log gap widens in 5 of 7 birds (p = 0.078).
fig2e-rhythmicity-drop and fig2e-residual-rhythm-peakΒΆ
Uva lesions decrease song rhythmicity, R, from 3.30 to 1.7 (Wilcoxon signed-rank test, p < 0.025, 7 birds).
Unlike subsong, 6 of 7 Uva-lesioned birds keep a significant peak in the song rhythm spectrum between 3 and 8 Hz.
Bouts with gaps of at most 350 ms and at least 1 s long (the shortest bout is not given; a standard choice). Amplitude readings (a) dB and (c) the log of the rectified, 2 ms smoothed audio (the Song rhythmicity section log-scales the amplitude, so reading (b), without the log, is not run for R). Null readings (a) the condition's own syllable and gap distributions, (b) the post-lesion distributions; synthetic bouts match each real bout's length; levels are the mean amplitude inside and outside syllables. R is the maximum of the ratio between 3 and 30 Hz (the upper bound is not given; a standard choice). The peak test draws 1000 synthetic bout sets, as the claims file asks. For post-lesion song the two null readings are the same, so the peak test is run once. A maximum of the ratio at the band's edge is not a peak, so the test is also run requiring a local maximum inside the band, and, as a variant, on the peak's prominence.
def rhythm_inputs(k, minlen=1000):
db = les["dbase"][k]
B, durs, gaps = [], [], []
for w, s in syllables(db):
durs += list(s[:, 1] - s[:, 0])
d = s[1:, 0] - s[:-1, 1]
gaps += list(d[d <= 350])
dbt, rect = aud["amp"][(k[0], k[1], w)]
for b in uva.bouts_from_segments(s, 350):
a, z = int(s[b, 0].min()), int(s[b, 1].max())
if z - a >= minlen and z <= len(dbt) and z - a <= uva.NFFT_RHYTHM:
inside = np.zeros(z - a, bool)
for x, y in s[b] - a:
inside[int(x):int(y)] = True
B.append({"a": dbt[a:z].astype(float), "c": np.log(rect[a:z].astype(float) + 1e-9), "inside": inside})
gaps = np.array(gaps)
return B, np.array(durs), gaps[gaps > 0]
FRH = np.fft.rfftfreq(uva.NFFT_RHYTHM, 1 / 1000)
N_PEAK_DRAWS = 1000 # the claims file's number of null draws
peak_store = {}
rh_in = {k: rhythm_inputs(k) for k in LKEYS}
rh_rows, peak_rows = [], []
for k in LKEYS:
B, durs, gaps = rh_in[k]
for amp in ["a", "c"]:
spec = np.mean([uva.bout_spectrum(b[amp]) for b in B], 0)
lev_s = np.mean([b[amp][b["inside"]].mean() for b in B])
lev_g = np.mean([b[amp][~b["inside"]].mean() for b in B if (~b["inside"]).any()])
for null in ["a", "b"]:
src = k if null == "a" else (k[0], "post-lesion")
d_, g_ = rh_in[src][1], rh_in[src][2]
rng = np.random.default_rng([LKEYS.index(k), ord(amp), ord(null)])
lg = np.log(g_)
def draw():
return np.mean([uva.bout_spectrum(uva.synthetic_bout(len(b[amp]), d_.mean(), lg.mean(), lg.std(),
lev_s, lev_g, rng)) for b in B], 0)
nullspec = np.mean([draw() for _ in range(5)], 0)
ratio = spec / nullspec
m = (FRH > 3) & (FRH <= 30)
rh_rows.append({"bird": k[0], "condition": k[1], "amplitude": amp, "null": null, "bouts": len(B),
"R": ratio[m].max(), "R_freq": FRH[m][np.argmax(ratio[m])],
"R_3_50": ratio[(FRH > 3) & (FRH <= 50)].max()})
if k[1] == "post-lesion" and amp == "a" and null == "a":
rr = []
for _ in range(N_PEAK_DRAWS):
rr.append(draw() / nullspec)
rr = np.array(rr)
peak_store[k[0]] = (ratio, rr)
for lo_, hi_ in [(3, 8), (4, 8)]:
bm = (FRH >= lo_) & (FRH <= hi_)
thr_max = np.percentile(rr[:, bm].max(1), 95)
thr_f = np.percentile(rr[:, bm], 95, axis=0)
peak_rows.append({"bird": k[0], "null": null, "band": f"{lo_}-{hi_} Hz", "max_ratio": ratio[bm].max(),
"at_Hz": FRH[bm][np.argmax(ratio[bm])], "null95_of_max": thr_max,
"significant_max": bool(ratio[bm].max() > thr_max),
"significant_any_freq": bool(np.any(ratio[bm] > thr_f))})
rh = pd.DataFrame(rh_rows)
print(rh.round(3).to_string(index=False))
for (amp, null), g in rh.groupby(["amplitude", "null"]):
p = g.pivot(index="bird", columns="condition", values="R")
w = stats.wilcoxon(p["post-lesion"], p["pre-lesion"])
print(f"amplitude {amp}, null {null}: R pre {p['pre-lesion'].mean():.2f} +- {p['pre-lesion'].std():.2f}, post "
f"{p['post-lesion'].mean():.2f} +- {p['post-lesion'].std():.2f}; decreasing in {(p['post-lesion'] < p['pre-lesion']).sum()} "
f"of 7; Wilcoxon p = {w.pvalue:.4f}")
print("Paper: pre 3.30 +- 1.1, post 1.7 +- 0.3, p < 0.025.")
bird condition amplitude null bouts R R_freq R_3_50 Bird_1-Purple53 post-lesion a a 445 2.108 7.080 2.108 Bird_1-Purple53 post-lesion a b 445 2.152 9.033 2.152 Bird_1-Purple53 post-lesion c a 445 5.103 26.611 10.595 Bird_1-Purple53 post-lesion c b 445 4.960 29.297 10.520 Bird_1-Purple53 pre-lesion a a 634 7.512 8.789 7.512 Bird_1-Purple53 pre-lesion a b 634 8.039 8.789 8.039 Bird_1-Purple53 pre-lesion c a 634 8.096 8.789 8.096 Bird_1-Purple53 pre-lesion c b 634 8.232 8.789 8.232 Bird_2-Purple94 post-lesion a a 453 2.229 3.174 2.229 Bird_2-Purple94 post-lesion a b 453 2.211 3.174 2.211 Bird_2-Purple94 post-lesion c a 453 12.301 28.564 15.798 Bird_2-Purple94 post-lesion c b 453 12.340 29.541 16.900 Bird_2-Purple94 pre-lesion a a 572 6.843 8.545 6.843 Bird_2-Purple94 pre-lesion a b 572 8.584 8.545 8.584 Bird_2-Purple94 pre-lesion c a 572 8.998 8.545 8.998 Bird_2-Purple94 pre-lesion c b 572 11.288 8.545 11.288 Bird_3-LBlue15 post-lesion a a 257 3.342 5.371 3.342 Bird_3-LBlue15 post-lesion a b 257 3.233 5.371 3.233 Bird_3-LBlue15 post-lesion c a 257 459.630 29.785 459.630 Bird_3-LBlue15 post-lesion c b 257 419.838 29.785 427.074 Bird_3-LBlue15 pre-lesion a a 513 4.038 9.521 4.038 Bird_3-LBlue15 pre-lesion a b 513 5.418 9.521 5.418 Bird_3-LBlue15 pre-lesion c a 513 63.972 12.451 63.972 Bird_3-LBlue15 pre-lesion c b 513 83.708 12.695 83.708 Bird_4-LPink13 post-lesion a a 242 2.314 3.174 2.314 Bird_4-LPink13 post-lesion a b 242 2.395 3.174 2.395 Bird_4-LPink13 post-lesion c a 242 7.081 25.879 13.952 Bird_4-LPink13 post-lesion c b 242 7.337 25.146 13.932 Bird_4-LPink13 pre-lesion a a 412 2.909 15.381 2.909 Bird_4-LPink13 pre-lesion a b 412 4.123 15.381 4.123 Bird_4-LPink13 pre-lesion c a 412 3.627 15.381 3.627 Bird_4-LPink13 pre-lesion c b 412 5.023 15.381 5.023 Bird_5-Blue68 post-lesion a a 938 2.717 5.615 2.717 Bird_5-Blue68 post-lesion a b 938 2.712 5.859 2.712 Bird_5-Blue68 post-lesion c a 938 4.154 28.564 7.841 Bird_5-Blue68 post-lesion c b 938 4.051 28.809 7.519 Bird_5-Blue68 pre-lesion a a 947 3.787 7.568 3.787 Bird_5-Blue68 pre-lesion a b 947 4.503 7.568 4.503 Bird_5-Blue68 pre-lesion c a 947 5.486 7.568 5.486 Bird_5-Blue68 pre-lesion c b 947 6.290 7.568 6.290 Bird_6-LPink15 post-lesion a a 177 2.168 3.174 2.168 Bird_6-LPink15 post-lesion a b 177 1.980 3.174 1.980 Bird_6-LPink15 post-lesion c a 177 116.416 27.100 116.416 Bird_6-LPink15 post-lesion c b 177 110.803 26.611 110.803 Bird_6-LPink15 pre-lesion a a 450 4.461 4.395 4.461 Bird_6-LPink15 pre-lesion a b 450 4.740 4.395 4.740 Bird_6-LPink15 pre-lesion c a 450 18.339 11.963 18.339 Bird_6-LPink15 pre-lesion c b 450 23.235 11.963 23.235 Bird_7-Red92 post-lesion a a 137 2.180 5.127 2.180 Bird_7-Red92 post-lesion a b 137 2.179 7.324 2.179 Bird_7-Red92 post-lesion c a 137 70.761 29.785 174.395 Bird_7-Red92 post-lesion c b 137 69.802 29.785 172.907 Bird_7-Red92 pre-lesion a a 857 4.297 8.057 4.297 Bird_7-Red92 pre-lesion a b 857 5.667 8.057 5.667 Bird_7-Red92 pre-lesion c a 857 21.562 9.277 25.620 Bird_7-Red92 pre-lesion c b 857 26.869 9.277 30.696 amplitude a, null a: R pre 4.84 +- 1.69, post 2.44 +- 0.45; decreasing in 7 of 7; Wilcoxon p = 0.0156 amplitude a, null b: R pre 5.87 +- 1.76, post 2.41 +- 0.43; decreasing in 7 of 7; Wilcoxon p = 0.0156 amplitude c, null a: R pre 18.58 +- 21.08, post 96.49 +- 165.78; decreasing in 2 of 7; Wilcoxon p = 0.0781 amplitude c, null b: R pre 23.52 +- 27.86, post 89.88 +- 151.17; decreasing in 2 of 7; Wilcoxon p = 0.2188 Paper: pre 3.30 +- 1.1, post 1.7 +- 0.3, p < 0.025.
Result: partially reproduced. With the dB amplitude, R falls in all 7 birds (Wilcoxon p = 0.016 under both nulls), but the values are higher than the paper's: 4.84 before and 2.44 after with null (a) (paper 3.30 +- 1.1 and 1.7 +- 0.3), and 5.87 and 2.41 with null (b). The rectified amplitude gives unstable ratios dominated by frequencies near 30 Hz and no consistent decrease.
def band_peak(r, bm):
"""Largest local maximum of the ratio strictly inside the band (higher than both neighbours,
so not the band's edge), and its prominence within the band: its height above the higher
of the lowest points on either side of it in the band. (nan, 0) when there is none."""
idx = np.where(bm)[0]
best, prom = np.nan, 0.0
for j in idx[1:-1]:
if r[j] > r[j - 1] and r[j] > r[j + 1] and not (r[j] <= best):
best = r[j]
prom = r[j] - max(r[idx[0]:j + 1].min(), r[j:idx[-1] + 1].min())
return best, prom
pkr = pd.DataFrame(peak_rows)
print("Maximum of the ratio anywhere in the band (the test as first run; a maximum at the band's edge counts):")
print(pkr.round(3).to_string(index=False))
for (null, band_), g in pkr.groupby(["null", "band"]):
print(f"null {null}, {band_}: significant (max over band) {g.significant_max.sum()} of 7; "
f"(any frequency, per-frequency 95th percentile) {g.significant_any_freq.sum()} of 7 (paper 6 of 7)")
rows = []
for bird, (ratio, rr) in peak_store.items():
for lo_, hi_ in [(3, 8), (4, 8)]:
bm = (FRH >= lo_) & (FRH <= hi_)
pk_, pr_ = band_peak(ratio, bm)
null_pk = np.array([band_peak(r, bm) for r in rr])
null_max = rr[:, bm].max(1)
thr_pk = np.percentile(null_max, 95) # a local maximum must exceed the null's maximum anywhere in the band
thr_pr = np.percentile(null_pk[:, 1], 95)
at = FRH[np.where(bm & (ratio == pk_))[0][0]] if np.isfinite(pk_) else np.nan
rows.append({"bird": bird, "band": f"{lo_}-{hi_} Hz", "local_max": pk_, "at_Hz": at, "null95_of_max": thr_pk,
"a_local_max_significant": bool(pk_ > thr_pk), "prominence": pr_, "null95_prominence": thr_pr,
"null_draws_with_a_local_max": int(np.isfinite(null_pk[:, 0]).sum()),
"b_prominence_significant": bool(pr_ > thr_pr)})
lp = pd.DataFrame(rows)
print(f"\nWith a local maximum required ({N_PEAK_DRAWS} null draws per bird):")
print(lp.round(3).to_string(index=False))
for band_, g in lp.groupby("band"):
print(f"{band_}: local maximum above the null's 95th percentile of maxima {g.a_local_max_significant.sum()} of 7; "
f"prominence above the null's 95th percentile of prominences {g.b_prominence_significant.sum()} of 7 (paper 6 of 7)")
fig, axs = plt.subplots(1, 7, figsize=(21, 3), sharey=True)
for ax, (bird, (ratio, rr)) in zip(axs, peak_store.items()):
m = (FRH > 1) & (FRH <= 30)
ax.plot(FRH[m], ratio[m], "k", lw=1)
ax.fill_between(FRH[m], np.percentile(rr[:, m], 2.5, axis=0), np.percentile(rr[:, m], 97.5, axis=0), color="C0", alpha=0.3)
ax.axvspan(3, 8, color="C1", alpha=0.1)
ax.set_title(bird, fontsize=9); ax.set_xlabel("Hz")
print(f"{bird}: ratio 1 to 30 Hz ranges {ratio[m].min():.2f} to {ratio[m].max():.2f}")
axs[0].set_ylabel("post-lesion spectrum / null"); axs[0].set_ylim(0, 4)
plt.tight_layout(); plt.show()
print("Black: real ratio; blue: 2.5 to 97.5 percentiles of the null draws' ratio per frequency; shaded 3 to 8 Hz.")
Maximum of the ratio anywhere in the band (the test as first run; a maximum at the band's edge counts):
bird null band max_ratio at_Hz null95_of_max significant_max significant_any_freq
Bird_1-Purple53 a 3-8 Hz 2.108 7.080 1.149 True True
Bird_1-Purple53 a 4-8 Hz 2.108 7.080 1.137 True True
Bird_2-Purple94 a 3-8 Hz 2.229 3.174 1.149 True True
Bird_2-Purple94 a 4-8 Hz 1.938 6.104 1.144 True True
Bird_3-LBlue15 a 3-8 Hz 3.342 5.371 1.177 True True
Bird_3-LBlue15 a 4-8 Hz 3.342 5.371 1.170 True True
Bird_4-LPink13 a 3-8 Hz 2.314 3.174 1.187 True True
Bird_4-LPink13 a 4-8 Hz 1.658 4.150 1.175 True True
Bird_5-Blue68 a 3-8 Hz 2.717 5.615 1.110 True True
Bird_5-Blue68 a 4-8 Hz 2.717 5.615 1.110 True True
Bird_6-LPink15 a 3-8 Hz 2.168 3.174 1.250 True True
Bird_6-LPink15 a 4-8 Hz 1.690 4.150 1.196 True True
Bird_7-Red92 a 3-8 Hz 2.180 5.127 1.262 True True
Bird_7-Red92 a 4-8 Hz 2.180 5.127 1.261 True True
null a, 3-8 Hz: significant (max over band) 7 of 7; (any frequency, per-frequency 95th percentile) 7 of 7 (paper 6 of 7)
null a, 4-8 Hz: significant (max over band) 7 of 7; (any frequency, per-frequency 95th percentile) 7 of 7 (paper 6 of 7)
With a local maximum required (1000 null draws per bird):
bird band local_max at_Hz null95_of_max a_local_max_significant prominence null95_prominence null_draws_with_a_local_max b_prominence_significant
Bird_1-Purple53 3-8 Hz 2.108 7.080 1.149 True 0.141 0.148 1000 False
Bird_1-Purple53 4-8 Hz 2.108 7.080 1.137 True 0.141 0.133 994 True
Bird_2-Purple94 3-8 Hz 1.938 6.104 1.149 True 0.310 0.162 1000 True
Bird_2-Purple94 4-8 Hz 1.938 6.104 1.144 True 0.310 0.156 999 True
Bird_3-LBlue15 3-8 Hz 3.342 5.371 1.177 True 1.723 0.208 1000 True
Bird_3-LBlue15 4-8 Hz 3.342 5.371 1.170 True 1.262 0.198 1000 True
Bird_4-LPink13 3-8 Hz 1.587 6.104 1.187 True 0.125 0.201 1000 False
Bird_4-LPink13 4-8 Hz 1.587 6.104 1.175 True 0.125 0.197 999 False
Bird_5-Blue68 3-8 Hz 2.717 5.615 1.110 True 0.792 0.130 1000 True
Bird_5-Blue68 4-8 Hz 2.717 5.615 1.110 True 0.792 0.098 999 True
Bird_6-LPink15 3-8 Hz 1.286 7.080 1.250 True 0.080 0.245 1000 False
Bird_6-LPink15 4-8 Hz 1.286 7.080 1.196 True 0.080 0.233 1000 False
Bird_7-Red92 3-8 Hz 2.180 5.127 1.262 True 0.485 0.250 998 True
Bird_7-Red92 4-8 Hz 2.180 5.127 1.261 True 0.485 0.207 990 True
3-8 Hz: local maximum above the null's 95th percentile of maxima 7 of 7; prominence above the null's 95th percentile of prominences 4 of 7 (paper 6 of 7)
4-8 Hz: local maximum above the null's 95th percentile of maxima 7 of 7; prominence above the null's 95th percentile of prominences 5 of 7 (paper 6 of 7)
Bird_1-Purple53: ratio 1 to 30 Hz ranges 0.89 to 2.11
Bird_2-Purple94: ratio 1 to 30 Hz ranges 0.73 to 2.26
Bird_3-LBlue15: ratio 1 to 30 Hz ranges 0.80 to 3.34
Bird_4-LPink13: ratio 1 to 30 Hz ranges 0.43 to 2.82
Bird_5-Blue68: ratio 1 to 30 Hz ranges 0.96 to 2.72
Bird_6-LPink15: ratio 1 to 30 Hz ranges 0.81 to 2.17
Bird_7-Red92: ratio 1 to 30 Hz ranges 0.85 to 2.18
Black: real ratio; blue: 2.5 to 97.5 percentiles of the null draws' ratio per frequency; shaded 3 to 8 Hz.
Result: not reproduced. No version of the test gives the paper's 6 of 7. Taking the maximum of the ratio anywhere in the band, all 7 birds pass, but in 3 of them (Purple94, LPink13, LPink15) that maximum is the band's lower edge, 3.17 Hz. Requiring a local maximum inside the band, all 7 still pass (local maxima 1.29 to 3.34 against null thresholds of about 1.1 to 1.3, 1000 draws): the synthetic null has no amplitude texture within syllables, so the whole real ratio lies above it. Requiring the peak's prominence to exceed the null's prominences, 4 of 7 pass (5 of 7 between 4 and 8 Hz).
Blocked claimsΒΆ
- lesion-directed-song-abolished: the paper and the data descriptor say directed song was recorded, but neither the file names (bird, date number, date and time; printed in the lesion data check), the analysis files (no properties) nor the descriptor mark any recording as directed. If directed recordings are in the folders, they cannot be told apart. Blocked, metadata insufficient.
- figs1-control-lesions-no-effect: the archive holds 7 lesioned birds, the paper's Uva lesion count; there are no control-lesion birds. Blocked, data missing.
- single-unit-spontaneous-rates: the analysis files hold no spike times (EventTimes empty) and no sorted units; the spreadsheets mark 32 "spontaneous activity" recordings, which are raw multiunit signals with no unit identities and nothing to say which units project to HVC. Blocked, metadata insufficient.
- fig3-antidromic: the stimulation files are described in the cell below. Stimulus times can be taken from the artefacts, which come back to within 0.25 V of baseline a median 2.3 ms after their onset (1.3 to 8.7 ms over 40 files), inside the claim's 1.5 to 5 ms window; 36 of 779 stimuli have recovered before 1.5 ms. The claim's latency and jitter are those of identified single units, measured from stimulus times. The files hold no stimulus times and no sorted or identified units, and in a multiunit trace a response locked to the stimulus with under 100 us of jitter repeats on every trial like the artefact, so it cannot be told apart from it without the units and collision tests. The claim is not tested. Blocked, other. An earlier version of the cell counted spikes after subtracting each file's median trace; that removes any response locked to the stimulus, so the count was dropped.
- fig8-no-gte-relation: needs GTE times from the model-based method of Boari et al. (ref 50). The paper links no code. A third-party copy of GTE extraction code from the Mindlin lab exists (github.com/kylerbrown/mindlin_auto); it is not the paper's implementation, was not tried here, and whether it runs is not known. Blocked, other (not attempted).
# fig3-antidromic: the stimulation artefacts and how long they last against the 1.5 to 5 ms window
rows = []
for _, r in sheet[sheet.note.str.contains("stim")].iterrows():
key = (r.bird, r.day, int(r.file))
if key not in eph["recs"] or CHAN[r.bird] not in eph["recs"][key]["stim"]:
continue
sn, on = eph["recs"][key]["stim"][CHAN[r.bird]]
t = (np.arange(sn.shape[1]) - 200) / 40.0 # ms from the artefact's first saturated sample
base = np.median(sn[:, :180], axis=1, keepdims=True)
dev = np.abs(sn - base) > 0.25 # V; the baseline's spread is about 0.05 V
rec = np.array([t[np.where(d & (t <= 10))[0][-1]] if d.any() else np.nan for d in dev])
w = (t >= 1.5) & (t <= 5)
rows.append({"bird": r.bird, "day": r.day, "file": int(r.file), "note": r.note, "stimuli": len(sn),
"recovery_ms_median": np.nanmedian(rec), "recovered_before_1.5ms": int((rec < 1.5).sum()),
"frac_1.5_5ms_beyond_0.25V": dev[:, w].mean()})
art = pd.DataFrame(rows)
print(art.round(2).to_string(index=False))
print(f"\nStimulation files with artefacts on the chosen channel: {len(art)}; median recovery to within 0.25 V of "
f"baseline {art.recovery_ms_median.median():.1f} ms (range {art.recovery_ms_median.min():.1f} to "
f"{art.recovery_ms_median.max():.1f}); fraction of the 1.5 to 5 ms window beyond 0.25 V, median "
f"{art['frac_1.5_5ms_beyond_0.25V'].median():.2f}")
print(f"Stimuli whose artefact is back within 0.25 V before 1.5 ms: {art['recovered_before_1.5ms'].sum()} of {art.stimuli.sum()}")
print("Intensities in the spreadsheet notes:", sorted(set(art.note.str.extract(r"(\d+)\s*uA")[0].dropna())))
fig, axs = plt.subplots(1, 4, figsize=(16, 3), sharey=True)
for ax, (_, r) in zip(axs, art.iloc[np.linspace(0, len(art) - 1, 4).astype(int)].iterrows()):
sn, _ = eph["recs"][(r.bird, r.day, r.file)]["stim"][CHAN[r.bird]]
t = (np.arange(sn.shape[1]) - 200) / 40.0
ax.plot(t, sn.T, lw=0.4); ax.axvspan(1.5, 5, color="C1", alpha=0.15)
ax.set_xlim(-1, 10); ax.set_ylim(-1, 1); ax.set_title(f"{r.bird} {r.day} file {r.file}", fontsize=9)
ax.set_xlabel("ms from artefact onset")
axs[0].set_ylabel("V (clipped to +-1)")
plt.tight_layout(); plt.show()
print("The traces saturate at +-10 V; the axes show +-1 V, so the saturated part lies outside them.")
bird day file note stimuli recovery_ms_median recovered_before_1.5ms frac_1.5_5ms_beyond_0.25V
Bird_1-b871 2013-09-08 2 stim 21 2.68 1 0.07
Bird_1-b871 2013-09-08 3 stim 22 1.29 12 0.01
Bird_1-b871 2013-09-08 4 stim 22 2.36 6 0.02
Bird_1-b871 2013-09-08 5 stim 21 2.10 10 0.02
Bird_1-b871 2013-09-08 6 stim 22 2.28 3 0.04
Bird_1-b871 2013-09-08 7 stim 22 2.31 3 0.04
Bird_1-b871 2013-09-08 8 stim 150uA 21 1.95 0 0.13
Bird_1-b871 2013-09-08 9 stim 150uA 22 1.92 0 0.12
Bird_1-b871 2013-09-08 10 stim Very long, must delete 150uA 23 1.90 0 0.11
Bird_1-b871 2013-09-08 24 stim 150uA 21 1.98 0 0.15
Bird_1-b871 2013-09-08 52 stim 150uA 20 8.72 0 0.12
Bird_1-b871 2013-09-08 53 song undirected initial 4 seconds with stim activity 4 2.01 0 0.13
Bird_1-b871 2013-09-08 75 stim 150uA 23 2.05 0 0.16
Bird_1-b871 2013-09-08 89 stim 150uA 26 2.01 0 0.20
Bird_1-b871 2013-09-08 90 stim 150uA 18 1.85 0 0.11
Bird_1-b871 2013-09-08 91 song undirected with stim activity 4 2.06 0 0.16
Bird_1-b871 2013-09-08 92 song undirected with stim activity 5 2.05 0 0.15
Bird_1-b871 2013-09-08 102 stim 150uA 14 2.12 0 0.19
Bird_1-b871 2013-09-08 103 stim 150uA 21 1.88 0 0.12
Bird_1-b871 2013-09-08 106 stim 150uA 23 1.88 0 0.11
Bird_1-b871 2013-09-08 121 stim 150uA 20 2.99 0 0.43
Bird_1-b871 2013-09-08 123 stim 150uA 21 2.68 0 0.34
Bird_1-b871 2013-09-08 162 stim 150uA 20 2.29 0 0.23
Bird_1-b871 2013-09-08 165 stim 150uA 19 2.25 0 0.22
Bird_1-b871 2013-09-08 189 stim 150uA 21 2.68 0 0.34
Bird_1-b871 2013-09-08 204 stim 150uA 13 2.75 0 0.36
Bird_1-b871 2013-09-08 205 stim 150uA 24 2.58 0 0.31
Bird_1-b871 2013-09-08 209 stim 150uA 21 2.30 0 0.24
Bird_2-Orange150 2013-10-05 37 stim 200uA 20 2.38 0 0.24
Bird_2-Orange150 2013-10-05 39 stim 200uA 20 2.30 0 0.24
Bird_2-Orange150 2013-10-05 46 stim 200uA 22 2.41 0 0.26
Bird_2-Orange150 2013-10-05 51 stim 200uA 3 1.52 1 0.01
Bird_2-Orange150 2013-10-05 67 stim 200uA 30 2.22 0 0.22
Bird_2-Orange150 2013-10-05 100 stim 200uA 22 2.20 0 0.20
Bird_2-Orange150 2013-10-05 120 stim 320uA 20 3.26 0 0.25
Bird_2-Orange150 2013-10-05 123 stim 320uA 21 2.35 0 0.24
Bird_2-Orange150 2013-10-06 4 stim 200uA 20 2.46 0 0.26
Bird_2-Orange150 2013-10-06 7 stim 23 2.65 0 0.27
Bird_2-Orange150 2013-10-06 21 stim 200uA 24 2.44 0 0.26
Bird_2-Orange150 2013-10-06 43 stim 200uA 20 2.72 0 0.31
Stimulation files with artefacts on the chosen channel: 40; median recovery to within 0.25 V of baseline 2.3 ms (range 1.3 to 8.7); fraction of the 1.5 to 5 ms window beyond 0.25 V, median 0.19
Stimuli whose artefact is back within 0.25 V before 1.5 ms: 36 of 779
Intensities in the spreadsheet notes: ['150', '200', '320']
The traces saturate at +-10 V; the axes show +-1 V, so the saturated part lies outside them.
SummaryΒΆ
| Claim | Outcome |
|---|---|
| lesion-directed-song-abolished | blocked (metadata insufficient) |
| lesion-undirected-rate-similar | not reproduced (assumption) |
| fig2g-maturity-index-drop | partially reproduced (assumption) |
| fig2f-closer-to-exponential | partially reproduced |
| fig2c-small-syllable-peak | partially reproduced |
| fig2d-gaps-broader | reproduced |
| fig2e-rhythmicity-drop | partially reproduced |
| fig2e-residual-rhythm-peak | not reproduced |
| figs1-control-lesions-no-effect | blocked (data missing) |
| fig3-antidromic | blocked (other: no stimulus times or identified units) |
| single-unit-spontaneous-rates | blocked (metadata insufficient) |
| fig4c-call-premotor | partially reproduced (assumption) |
| fig4b-introductory-note-premotor | partially reproduced (assumption) |
| fig4a-elevated-during-song | reproduced (assumption) |
| fig5-consistent-across-renditions | partially reproduced (assumption) |
| fig5-consistent-across-sites | partially reproduced (assumption) |
| fig6-peak-before-onset | partially reproduced (assumption) |
| fig6-dip-before-offset | reproduced (assumption) |
| fig7a-correlation-with-amplitude | reproduced (assumption) |
| spectral-features-weak | not reproduced (assumption) |
| fig7b-10hz-power-peaks | partially reproduced (assumption) |
| fig7d-10hz-coherence | reproduced (assumption) |
| fig8-no-gte-relation | blocked (other: not attempted) |
| fig9-long-syllable-gamma | not reproduced (assumption) |
| bout-offset-suppression | partially reproduced (assumption) |
| no-motif-bout-signal | not reproduced (assumption) |
A failure to reproduce here may be a failure of this attempt, not of the paper: see the reasoning and the differences from the paper's method.
How the analysis differs from the paper's. The electrophysiology covers 3 of the paper's 5 birds. Each recording has three neural channels and nothing in the files settles which is the Uva electrode; the channel with the largest syllable-onset modulation is used for each bird (an assumption that every electrophysiology outcome rests on; for Orange150 it is the channel the authors' analysis file ran its event detectors on). MUA is computed from the raw signal as the Methods say, then sampled at 1 kHz. Several methods the paper leaves open were run under each reading the claims file lists; the maturity index needed a form the claims file does not list (log spectra centred on the mean spectrum), adopted as an assumption because the literal reading cannot give values near the paper's. The song features follow Sound Analysis Pro's definitions as far as the helper states. The rhythm null and the shuffled baselines are built as the claims file describes; the synthetic rhythm null has no amplitude texture within syllables.
What was found about the data set. The lesion data match their analysis files exactly (12,833 wav files, all listed, all lengths equal). The electrophysiology archive holds a second copy of one recording day as a nested archive (173 identical files). The descriptor says introductory notes and calls are unselected, but they are selected and labelled "i" and "k"; it does not say which of the three neural channels is the recording electrode, nor what the labels mean. No lesion recording is marked as directed or undirected. One Uva4 recording (file 20) has an unreadable closing sample count. Two vector clustering files that the descriptor does not mention have the same size in two birds' folders. The spreadsheet tab for Uva4 is named "October 6, 2016" and lists dates from 2007-07-25 to 2007-07-27, while the analysis file runs to 2007-08-06.