Yu, Gutnisky, Hires & Svoboda (2016) on CRCNS ssc-7¶
Paper. Yu J, Gutnisky DA, Hires SA, Svoboda K (2016). Layer 4 fast-spiking interneurons filter thalamocortical signals during active somatosensation. Nature Neuroscience 19, 1647-1657. doi:10.1038/nn.4412. The claims file was written from the version of record (main text, figure legends, Online Methods) and its supplement.
Data set. CRCNS ssc-7 (doi:10.6080/K0T43R01), read anonymously
from the public bucket crcnsarchive at ssc-7/live/. CRCNS data sets are not versioned, so the
version is recorded as unversioned, the only version there is; ssc-7/live/ is the published
copy (the orig/ folder holds only a read-me). The files read and their MD5 sums from
checksums.md5: data.tar.gz 670a36de4916084ff3384d7e9450e6a8 (6,207,296,281 bytes, object last
modified 2026-02-11) and docs/yu_gutnisky_CellList.xlsx 9b0d4c9f4749de6d30fe6a17726f4754 (read
while preparing, for the example-cell names; the files' own unit descriptions are used here). The
data descriptor (version 0.6, July 27, 2017) and the example code example_analysis_code.tar.gz
(c178aa213fa11b4974023e147a26e637) were read while preparing; the code is cited where it settles a
detail.
Reading the data. data.tar.gz is a single gzipped tar of 148 NWB 1.0 files. A gzip stream
cannot be opened in place, so the notebook streams it once from the start (the next cell prints how long it took) and reduces each file in memory as it passes (ssc7.py). Nothing is written to disk.
What the data set holds. Seven folders: 29 VPM units (18 silicon-probe sessions), 37 whole-cell and 48 cell-attached L4 excitatory neurons, 7 whole-cell and 19 cell-attached L4 FS neurons, and after infraorbital nerve (ION) cut 9 whole-cell L4 excitatory and 10 cell-attached L4 FS neurons. Not in it: the 17 thalamic multiunit recordings of Fig. 6b,c, the rabies tracing, the L5 FS neurons after ION cut, and any recording with the depolarizing current injection of Fig. 3 (no whole-cell L4 excitatory trial has a median Vm above -30 mV).
| Claim | Tested |
|---|---|
| behavior-performance | yes |
| vpm-baseline-rate | yes |
| vpm-touch-response | yes |
| vpm-whisking-count | yes |
| vpm-whisking-rate | yes |
| vpm-phase-modulation | yes |
| vpm-rate-amplitude-trials | yes |
| l4e-example-e1 | yes |
| l4e-example-e24-e32 | yes |
| l4e-resting-vm | yes |
| l4e-touch-psp | yes |
| l4e-whisking-vm | yes |
| l4e-distance-threshold | yes |
| l4e-reversal-potential | yes |
| l4e-hf-fluctuations | yes |
| l4e-inhibition-window | no, data missing |
| l4e-whisking-inhibition | no, data missing |
| fs-baseline-rate | yes |
| fs-touch-vm | yes |
| fs-touch-spikes | yes |
| fs-whisking-count | yes |
| fs-whisking-vm | yes |
| fs-whisking-rate | yes |
| fs-phase-coupling | yes |
| fs-hf-fluctuations | yes |
| l4e-spikes-touch-selective | yes |
| thalamus-inhibition-vpm | no, data missing |
| thalamus-inhibition-l4e-vm | yes |
| thalamus-inhibition-fs | yes |
| thalamus-inhibition-dose | yes |
| rabies-vpm-input | no, data missing |
| ion-cut-behavior | yes |
| ion-cut-l4e-touch | yes |
| ion-cut-l4e-whisking | yes |
| ion-cut-l4e-phase | yes |
| ion-cut-l4e-spectra | yes |
| ion-cut-fs-touch | yes |
| ion-cut-fs-whisking | yes |
| ion-cut-fs-phase | yes |
| ion-cut-l5-fs | no, data missing |
| enphr-kruskal-wallis | yes |
| enphr-l4e-rates | yes |
| enphr-whisking-driven | yes |
| enphr-spikes-per-touch | yes |
| enphr-auc | yes |
| enphr-auc-groups | yes |
| enphr-pv-latency | yes |
| enphr-behavior | yes |
The outcomes are given in the summary at the end and in the attempt record.
import time
import warnings
import numpy as np
import pandas as pd
from scipy import stats
import ssc7
warnings.filterwarnings("ignore", category=RuntimeWarning)
warnings.filterwarnings("ignore", message="Unknown extension") # openpyxl, reading the cell list
pd.set_option("display.width", 220)
pd.set_option("display.max_columns", 40)
pd.set_option("display.max_rows", 300)
started = time.time()
cells = ssc7.load(verbose=False)
print(f"read {len(cells)} units from {ssc7.DATA_URL} in {time.time() - started:.0f} s; "
f"files that could not be read: {ssc7.load.failed}")
NAME = {ssc7.cell_name(c): c for c in cells}
def ci(x):
x = np.asarray(x, float)
x = x[np.isfinite(x)]
return f"mean {x.mean():.3g} +- {x.std(ddof=1):.3g} s.d., median {np.median(x):.3g}, n = {len(x)}"
def within(v, e, t):
return bool(np.isfinite(v) and abs(v - e) <= t + 1e-12)
read 159 units from https://crcnsarchive.s3-us-west-2.amazonaws.com/ssc-7/live/data.tar.gz in 787 s; files that could not be read: []
Data check¶
Counts by folder, mouse and recording, sampling rates, trial counts and the ranges of the variables used. Each check of the description against the data is stated below the output.
rows = []
for c in cells:
m = c["meta"]
rows.append(dict(group=ssc7.group(c), name=ssc7.cell_name(c), file=m["file"], subject=m["subject"],
unit=m.get("unit_description", ""), n_trials=m["n_trials"], good=int(c["good"].sum()),
stim=int(c["stim"].sum()), ephys_hz=round(m.get("ephys_fs", 0)),
n_whiskers=m["n_whiskers"], pw=str(m["principal_whisker"]),
config=str(m["whisker_configuration"]), pw_series=ssc7.pw_index(c),
notes=m["notes"].replace("Experiment type: behavior, ", "")))
info = pd.DataFrame(rows)
print("Units per folder group:")
print(info.group.value_counts().to_string())
print("\nFiles:", info.file.nunique(), "; mice (subject_id, cortex):", info[info.group != "VPM"].subject.nunique())
print("\nEphys sampling rates (Hz) in cortical files:", info[info.group != "VPM"].ephys_hz.value_counts().to_dict())
print("Trials per unit: median", info.n_trials.median(), "range", info.n_trials.min(), "-", info.n_trials.max())
print("\nUnit descriptions in folders that are not their own type:")
print(info[(info.group.str.startswith("FS")) & info.unit.str.contains("xcit")][["group", "name", "unit"]].to_string(index=False))
print("\nCortical files with more than one tracked whisker series:", int(((info.group != "VPM") & (info.n_whiskers > 1)).sum()),
"; VPM sessions with more than one:", info[(info.group == "VPM") & (info.n_whiskers > 1)].file.nunique())
# recordings deposited twice: identical spike-count and trial-count signatures
sig = {}
for c in cells:
st = np.atleast_1d(c["spike_times"])
key = (c["meta"]["n_trials"], len(st), round(float(st[:5].sum()), 4) if len(st) else 0.0)
sig.setdefault(key, []).append(ssc7.cell_name(c))
print("Units sharing trial count, spike count and first spike times (duplicates):", [v for v in sig.values() if len(v) > 1])
# clocks
d = []
for c in cells:
if ssc7.group(c) == "VPM":
continue
d.append((round(c["meta"]["ephys_fs"]), np.nanmin(c["vm_t0"]), np.nanmax(c["vm_t0"])))
d = pd.DataFrame(d, columns=["hz", "min", "max"]).round(4)
print("\nEphys trial start minus whisker trial start (s), after converting the whisker trial start from ms:")
print(d.groupby("hz").agg(["min", "max"]).to_string())
spk_rel = np.concatenate([np.concatenate(ssc7.spikes_by_trial(c)) for c in cells])
print(f"\nSpike times relative to the trial's first whisker frame: 1st-99th percentile "
f"{np.percentile(spk_rel, 1):.3f} to {np.percentile(spk_rel, 99):.3f} s (whisker video 5 s per trial)")
ang = np.concatenate([c["angle"][ssc7.pw_index(c)][np.isfinite(c["angle"][ssc7.pw_index(c)])].ravel()[::50] for c in cells])
print(f"Whisker angle (degrees, units not stated in the files): 1st-99th percentile {np.percentile(ang, 1):.1f} to {np.percentile(ang, 99):.1f}")
vmall = np.concatenate([np.concatenate([v[::200] for v in c["vm"]]) for c in cells if c["vm"]])
print(f"Whole-cell Vm (mV): 1st-99th percentile {np.percentile(vmall, 1):.1f} to {np.percentile(vmall, 99):.1f}")
# laser series and stimulus types
lz = []
for c in cells:
if ssc7.group(c) == "VPM":
continue
n_on = 0
if c["laser"]:
n_on = int(sum(ssc7.laser_power(c, i) > 0.05 for i in range(c["meta"]["n_trials"])))
kinds = pd.Series([x.replace("Go", "").replace("Nogo", "") or "none" for x in c["epoch_description"]]).value_counts().to_dict()
lz.append(dict(group=ssc7.group(c), name=ssc7.cell_name(c), stim_trials=int(c["stim"].sum()), trials_with_laser_trace=n_on, **{f"type{k}": v for k, v in kinds.items()}))
lz = pd.DataFrame(lz).fillna(0)
print("\nStimulus trials and trials whose stored photostimulus trace is above 0.05 mW, summed by group:")
print(lz.groupby("group").sum(numeric_only=True).astype(int).to_string())
print("Most trials with a stimulus flag in a file:", lz.stim_trials.max(), "; most trials with a nonzero laser trace in a file:", lz.trials_with_laser_trace.max())
print("\nCell list check: whole-cell L4E 37, cell-attached L4E 48, FS 7 + 19, ION cut 9 + 10, VPM 29 units in 18 sessions:",
info.groupby("group").size().to_dict(), "; VPM sessions:", info[info.group == "VPM"].file.nunique())
print("\nTrials tagged passive touch:", int(sum(sum("passive" in str(t) for t in c["epoch_tag"]) for c in cells)))
# Trial-type columns: the names each folder gives to the columns of analysis/trial_type_mat (the
# performance and behavior claims take columns 1 to 4 as Hit, Miss, CR, FA)
print("\nTrial-type column names by folder:")
for g in sorted(info.group.unique()):
nm = {tuple(c["meta"]["trial_type_names"][:6]) for c in cells if ssc7.group(c) == g}
print(f" {g}: {nm}")
# Pole times relative to each trial's first whisker frame (s), used by M-ROC reading (a)
pr = []
for c in cells:
if c["pole_in"] is None or ssc7.group(c) == "VPM":
continue
n_ = min(len(c["t0"]), len(np.atleast_1d(c["pole_in"])), len(np.atleast_1d(c["pole_out"])))
pr.append((ssc7.group(c), np.nanmin(np.asarray(c["pole_in"])[:n_] - c["t0"][:n_]), np.nanmax(np.asarray(c["pole_in"])[:n_] - c["t0"][:n_]),
np.nanmin(np.asarray(c["pole_out"])[:n_] - c["t0"][:n_]), np.nanmax(np.asarray(c["pole_out"])[:n_] - c["t0"][:n_])))
pr = pd.DataFrame(pr, columns=["group", "pole_in_min", "pole_in_max", "pole_out_min", "pole_out_max"])
print("\nPole-in and pole-out times minus the trial's first whisker frame (s), cortical files:")
print(pr.groupby("group").agg(pole_in_min=("pole_in_min", "min"), pole_in_max=("pole_in_max", "max"),
pole_out_min=("pole_out_min", "min"), pole_out_max=("pole_out_max", "max")).round(2).to_string())
# Whole-cell recordings: every ephys trial against the whisker trials, the per-trial median Vm and
# the largest injected current, to find depolarized trials (Fig. 3) and drifting recordings
wc_rows = []
for c in cells:
if c["vm"] is None:
continue
e = c["ephys_trials"]
med = e["median_vm"]
st_ = ssc7.stable_trials(c)
wc_rows.append(dict(group=ssc7.group(c), name=ssc7.cell_name(c), n_trials=c["meta"]["n_trials"], n_ephys_trials=c["meta"]["n_ephys_trials"],
median_vm=round(float(np.nanmedian(med)), 1), max_trial_median_vm=round(float(np.nanmax(med)), 1),
trials_above_minus30=int((med > -30).sum()), max_abs_current_nA=round(float(np.nanmax(e["max_abs_current"])), 2),
trials_far_from_median=int((~st_[: len(c["vm"])]).sum())))
WCT = pd.DataFrame(wc_rows)
print("\nWhole-cell neurons whose ephys trial count differs from the whisker trial count:", WCT[WCT.n_trials != WCT.n_ephys_trials].name.tolist())
print("Largest per-trial median Vm (mV) and largest |current| (nA) by group, over every ephys trial:")
print(WCT.groupby("group").agg(neurons=("name", "size"), max_trial_median_vm=("max_trial_median_vm", "max"), max_abs_current_nA=("max_abs_current_nA", "max"),
trials_above_minus30=("trials_above_minus30", "sum"), trials_far_from_median=("trials_far_from_median", "sum")).to_string())
print("Neurons with a trial above -30 mV, a current above 0.5 nA, or a trial more than 20 mV from their median:")
print(WCT[(WCT.trials_above_minus30 > 0) | (WCT.max_abs_current_nA > 0.5) | (WCT.trials_far_from_median > 0)].to_string(index=False))
# The data set's cell list (docs/yu_gutnisky_CellList.xlsx), against the folders
CL = ssc7.read_cell_list()
key = lambda s: str(s).replace("normal", "").replace("_", "-")[:24]
cl_keys = {key(x): sec for x, sec in zip(CL.cell, CL.section)}
info["cell_list_section"] = [cl_keys.get(key(f.replace(".nwb", "")), cl_keys.get(key(f.replace(".nwb", "")[:6]), "")) for f in info.file]
print("\nCell list sections against the data set's folders (cortical units):")
print(pd.crosstab(info[info.group != "VPM"].group, info[info.group != "VPM"].cell_list_section).to_string())
print("Cortical units not found in the cell list:", info[(info.group != "VPM") & (info.cell_list_section == "")].file.tolist())
Units per folder group:
group
L4E_ca 48
L4E_wc 37
VPM 29
FS_ca 19
FS_ion 10
L4E_ion 9
FS_wc 7
Files: 148 ; mice (subject_id, cortex): 49
Ephys sampling rates (Hz) in cortical files: {10000: 92, 20000: 38}
Trials per unit: median 98.0 range 16 - 542
Unit descriptions in folders that are not their own type:
group name unit
FS_wc JY1139AAAA Excitatory
Cortical files with more than one tracked whisker series: 70 ; VPM sessions with more than one: 10
Units sharing trial count, spike count and first spike times (duplicates): []
Ephys trial start minus whisker trial start (s), after converting the whisker trial start from ms:
min max
min max min max
hz
10000 -0.01 -0.01 -0.01 -0.01
20000 -0.00 -0.00 0.00 0.00
Spike times relative to the trial's first whisker frame: 1st-99th percentile 0.067 to 5.023 s (whisker video 5 s per trial)
Whisker angle (degrees, units not stated in the files): 1st-99th percentile -37.0 to 43.3
Whole-cell Vm (mV): 1st-99th percentile -82.7 to -31.3
Stimulus trials and trials whose stored photostimulus trace is above 0.05 mW, summed by group:
stim_trials trials_with_laser_trace typenone typeStim_constant typeStim_shift typeStim_5ms_pulse typeStim_constant_shift typeStim_shiftgrid typeStim_5ms_grid
group
FS_ca 548 548 1328 104 360 84 0 0 0
FS_ion 214 214 678 0 77 137 0 0 0
FS_wc 312 312 379 18 67 227 0 0 0
L4E_ca 1422 1422 2475 1280 117 25 0 0 0
L4E_ion 91 91 352 0 18 73 0 0 0
L4E_wc 855 700 2557 156 105 500 41 15 38
Most trials with a stimulus flag in a file: 108 ; most trials with a nonzero laser trace in a file: 108
Cell list check: whole-cell L4E 37, cell-attached L4E 48, FS 7 + 19, ION cut 9 + 10, VPM 29 units in 18 sessions: {'FS_ca': 19, 'FS_ion': 10, 'FS_wc': 7, 'L4E_ca': 48, 'L4E_ion': 9, 'L4E_wc': 37, 'VPM': 29} ; VPM sessions: 18
Trials tagged passive touch: 410
Trial-type column names by folder:
FS_ca: {('Hit', 'Miss', 'CR', 'FA', 'Stimtrials')}
FS_ion: {('Hit', 'Miss', 'CR', 'FA', 'Stimtrials')}
FS_wc: {('Hit', 'Miss', 'CR', 'FA', 'Stimtrials')}
L4E_ca: {('Hit', 'Miss', 'CR', 'FA', 'Stimtrials')}
L4E_ion: {('Hit', 'Miss', 'CR', 'FA', 'Stimtrials')}
L4E_wc: {('Hit', 'Miss', 'CR', 'FA', 'Stimtrials')}
VPM: {('Hit', 'Miss', 'CR', 'FA')}
Pole-in and pole-out times minus the trial's first whisker frame (s), cortical files:
pole_in_min pole_in_max pole_out_min pole_out_max
group
FS_ca 0.83 0.83 2.44 19.15
FS_ion 0.83 0.83 2.83 44.32
FS_wc 0.83 0.83 2.83 24.53
L4E_ca 0.83 0.83 2.43 23.37
L4E_ion 0.83 0.83 2.83 36.23
L4E_wc 0.83 1.08 2.67 25.39
Whole-cell neurons whose ephys trial count differs from the whisker trial count: []
Largest per-trial median Vm (mV) and largest |current| (nA) by group, over every ephys trial:
neurons max_trial_median_vm max_abs_current_nA trials_above_minus30 trials_far_from_median
group
FS_wc 7 -2.3 2.00 18 13
L4E_ion 9 -55.7 3.03 0 0
L4E_wc 37 -42.8 0.20 0 0
Neurons with a trial above -30 mV, a current above 0.5 nA, or a trial more than 20 mV from their median:
group name n_trials n_ephys_trials median_vm max_trial_median_vm trials_above_minus30 max_abs_current_nA trials_far_from_median
FS_wc JY1139AAAA 103 103 -40.5 -2.3 18 0.10 13
FS_wc JY1171AAAI 86 86 -40.7 -35.0 0 2.00 0
L4E_ion Exp_2015-11-25_008_0002-0050 32 32 -72.9 -70.8 0 2.03 0
L4E_ion Exp_2015-11-27_002_0001-0082 51 51 -64.8 -55.7 0 3.03 0
L4E_ion Exp_2015-11-27_008_0001-0087 51 51 -67.6 -64.8 0 3.03 0
L4E_ion Exp_2015-11-25_010_0001-0131 115 115 -70.7 -68.2 0 0.98 0
L4E_ion Exp_2015-11-25_001_0001-0027 19 19 -67.2 -62.2 0 2.03 0
L4E_ion Exp_2015-11-25_006_0001-0066 59 59 -71.5 -65.6 0 2.03 0
L4E_ion Exp_2015-11-27_009_0001-0069 35 35 -62.9 -61.5 0 3.03 0
L4E_ion Exp_2015-11-27_003_0001-0033 20 20 -69.0 -60.6 0 3.03 0
Cell list sections against the data set's folders (cortical units): cell_list_section Extracellular units Extracellular, FS neurons FS neurons, ION cut Whole-cell units Whole-cell units with ION cut Whole-cell, FS neurons group FS_ca 0 0 19 0 0 0 0 FS_ion 0 0 0 10 0 0 0 FS_wc 0 0 0 0 0 0 7 L4E_ca 1 47 0 0 0 0 0 L4E_ion 0 0 0 0 0 9 0 L4E_wc 0 0 0 0 37 0 0 Cortical units not found in the cell list: ['JY1268AAAA.nwb']
Checks of the description against the data¶
- Counts. The folders hold the counts the claims file gives from the paper's Supplementary Table 2: 37 whole-cell and 48 cell-attached L4 E neurons, 26 FS neurons (7 + 19), 9 + 10 after ION cut, 29 VPM units in 18 sessions. No two units share trial count, spike count and first spike times, so no recording is deposited twice. Seven VPM units in six sessions come from one mouse (ANM199552; two units share the session of 2013-06-08), with different unit names each day; they are treated as different units, as the paper's count of 29 does.
- Unit labels. One neuron in the whole-cell FS folder, JY1139, is described in its file as "Excitatory"; the folder and the cell list (section "Whole-cell, FS neurons", a PV-ChR2 mouse) call it FS, and it fires 2.7 spikes per touch, as FS neurons do. The folder is used.
- Cell list. The data set's cell list (
docs/yu_gutnisky_CellList.xlsx, sheet AllCellsReported) puts every cortical unit in the section of its folder, except JY1268 (in the cell-attached L4 E folder), which the cell list does not name; its "Extracellular units" section has 47 rows against 48 files. - Trial types. Every folder names the columns of
trial_type_matHit, Miss, CR, FA (and Stimtrials in the cortical folders), the order the behavior claims use. - Whole-cell trials. Every whole-cell file has as many ephys trials as whisker trials, so no ephys trial is dropped. No L4 E trial has a median Vm above -42.8 mV, and no L4 E current exceeds 0.2 nA: the depolarized recordings of Fig. 3 are not here, including those of JY0978, which the cell list names as the Fig. 3 example. One FS neuron, JY1139, starts near 0 mV (trials 0 to 17 above -30 mV) and settles at about -41 mV from trial 20, while it keeps firing (8 to 85 spikes per trial) with no current above 0.1 nA. That is a drifting recording, not the depolarization protocol, which inactivates spikes with about 1 nA. Trials whose median Vm lies more than 20 mV from the neuron's median are left out of the Vm measures (13 trials, all of JY1139; 5 of them control trials), after the Methods' rejection of recordings "with slow baseline drift (>20 mV)" (an assumption; the FS Vm claims show both).
- Pole times. Pole-in comes 0.83 s after the first whisker frame in nearly every cortical trial; pole-out times run from 2.4 s to well past the 5 s of video, so M-ROC reading (a) bounds its reference times by the video.
- Clocks. In the cortical files the whisker timestamps are the trial start in milliseconds plus the time within the trial in seconds (frame spacing 0.001 s, trial starts 1,000 times the ephys trial starts). Once the trial start is read as milliseconds, every ephys trial starts 10 ms before the first whisker frame (10 kHz files) or with it (20 kHz files). Spikes (ephys clock) aligned to touch onsets (whisker clock) peak 2 ms (VPM) and 5 ms (FS) after touch, and the peak vanishes when the touch times are shifted by 0.5 to 1.5 s, so the two clocks are consistent with each other, to within the 1 ms of the whisker frames. The example neuron E No. 1 below gives the paper's touch latency (4.8 against 4.7 ms). That is consistent with a shared clock but does not prove it.
- Units. Vm is in mV, laser power in mW, whisker angle in degrees (inferred from the range, -37 to 43 degrees; the files say "unknown"). The ephys sampling rate is 10 or 20 kHz, as the Methods say; 20 kHz Vm is averaged in pairs to 10 kHz.
- Principal whisker. Seventy cortical files hold two tracked whisker series, and the files do not
say which is which. Mapping the series to
whisker_configurationin order gives FS neurons with almost no touch response (0.45 spikes per touch against 1.78 with series 1; table above). The data set's example code always takes the first whisker as the main one (mainwid = 0inConvertfromNWB.m). Series 1 is used as the principal whisker (an assumption). This is recorded as a finding. - Light trials. Each file stores one photostimulus series per light site, sampled with the ephys.
The series give each trial's sites, power (3 mW at 594 nm; 3.8, 7.5 or 15 mW at 473 nm) and
light period, and the light sites agree with the experiments of the Online Methods. In most
files the light is on exactly in the trials the
Stimtrialsflag marks (the table above). Eight whole-cell L4 E files flag 132 stimulus trials but store no photostimulus series, and in two more (Exp_2015-09-24_004, JY1633) 23 flagged trials have no light in their series. Those trials count as neither control nor light trials. - 410 trials are tagged "passive touch"; their first touch is left out, as the example code does.
# Which tracked whisker series is the principal whisker: touch responses of the FS neurons (the
# strongest touch responders) with the series each reading picks, in files with two series.
rows = []
for c in cells:
if ssc7.group(c) not in ("FS_wc", "FS_ca", "L4E_wc", "L4E_ca") or c["meta"]["n_whiskers"] < 2:
continue
spk = ssc7.spikes_by_trial(c)
tr = ssc7.control_trials(c)
r = dict(group=ssc7.group(c), name=ssc7.cell_name(c), config=str(c["meta"]["whisker_configuration"]), pw=str(c["meta"]["principal_whisker"]))
for rd in ("code", "config"):
ssc7.PW_READING = rd
tt = ssc7.touch_table(c, 0.025, tr)
r[f"series_{rd}"] = ssc7.pw_index(c)
r[f"spt_{rd}"] = ssc7.spikes_per_touch(spk, tt) if len(tt) else np.nan
ssc7.PW_READING = "code"
rows.append(r)
PWT = pd.DataFrame(rows)
print("files with two tracked whiskers:", len(PWT), "; the readings pick different series in", int((PWT.series_code != PWT.series_config).sum()))
fs2 = PWT[PWT.group.str.startswith("FS")]
print(fs2.round(2).to_string(index=False))
print(f"FS neurons with two series: mean spikes per touch, reading 'code' (series 1) {fs2.spt_code.mean():.2f}, reading 'config' {fs2.spt_config.mean():.2f}")
e2 = PWT[PWT.group.str.startswith("L4E")]
print(f"L4 E neurons with two series: {len(e2)}; mean spikes per touch, reading 'code' {e2.spt_code.mean():.3f}, reading 'config' {e2.spt_config.mean():.3f}; "
f"the readings pick different series in {int((e2.series_code != e2.series_config).sum())}")
print(e2.round(3).to_string(index=False))
files with two tracked whiskers: 64 ; the readings pick different series in 43 group name config pw series_code spt_code series_config spt_config FS_ca JY1460AAAA ['C1', 'C2'] ['C2'] 1 1.96 2 0.36 FS_ca JY1458AAAA ['C1', 'C2'] ['C2'] 1 1.98 2 0.32 FS_ca JY1465AAAA ['C1', 'C2'] ['C2'] 1 2.90 2 -0.23 FS_ca JY1469AAAA ['C1', 'C2'] ['C2'] 1 1.97 2 -0.01 FS_ca JY1406AAAA ['C1', 'C2'] ['C2'] 1 1.09 2 -0.09 FS_ca JY1636AAAA ['C1', 'C2'] ['C1'] 1 0.17 1 0.17 FS_ca JY1663AAAA ['C1', 'C2'] ['C2'] 1 0.54 2 -0.10 FS_ca JY1474AAAA ['C1', 'C2'] ['C2'] 1 2.08 2 0.05 FS_wc JY1171AAAI ['C1', 'C2'] ['C2'] 1 2.83 2 0.38 FS_wc JY1045AAAA ['C1', 'C2'] ['C1'] 1 2.16 1 2.16 FS_wc JY1041AAAA ['C1', 'C2'] ['C1'] 1 1.89 1 1.89 FS neurons with two series: mean spikes per touch, reading 'code' (series 1) 1.78, reading 'config' 0.45 L4 E neurons with two series: 53; mean spikes per touch, reading 'code' 0.128, reading 'config' 0.082; the readings pick different series in 35 group name config pw series_code spt_code series_config spt_config L4E_ca Exp_2015-09-17_007_0001-0151 ['C1', 'C2'] ['C2'] 1 0.139 2 0.000 L4E_ca JY1357AAAA ['C2'] ['C2'] 1 0.582 1 0.582 L4E_ca JY1416AAAA ['C1', 'C2'] ['C2'] 1 0.040 2 -0.037 L4E_ca JY1419AAAA ['C1', 'C2'] ['C2'] 1 0.070 2 -0.068 L4E_ca Exp_2015-09-04_001_0001-0081 ['C1', 'C2'] ['C2'] 1 0.058 2 0.420 L4E_ca JY1363AAAA ['C2'] ['C2'] 1 -0.007 1 -0.007 L4E_ca JY1540AAAA ['C1', 'C2'] ['C2'] 1 0.026 2 0.000 L4E_ca JY1394AAAA ['C1', 'C2'] ['C2'] 1 0.008 2 0.000 L4E_ca JY1464AAAA ['C1', 'C2'] ['C2'] 1 0.059 2 NaN L4E_ca JY1336AAAA ['C2'] ['C2'] 1 0.070 1 0.070 L4E_ca JY1417AAAB ['C1', 'C2'] ['C2'] 1 1.607 2 -0.017 L4E_ca Exp_2015-09-25_003_0001-0043 ['C1', 'C2'] ['C1'] 1 -0.046 1 -0.046 L4E_ca JY1410AAAA ['C1', 'C2'] ['C2'] 1 -0.041 2 0.108 L4E_ca Exp_2015-08-27_002_0001-0078 ['C1', 'C2'] ['C2'] 1 0.314 2 0.194 L4E_ca Exp_2015-08-27_004_0001-0074 ['C1', 'C2'] ['C2'] 1 0.089 2 0.000 L4E_ca Exp_2015-08-28_009_0001-0057 ['C1', 'C2'] ['C2'] 1 -0.012 2 0.000 L4E_ca JY1579AAAA ['C1', 'C2'] ['C2'] 1 0.000 2 0.000 L4E_ca JY1409AAAA ['C1', 'C2'] ['C2'] 1 0.004 2 0.000 L4E_ca JY1535AAAA ['C1', 'C2'] ['C2'] 1 0.155 2 0.122 L4E_ca JY1356AAAA ['C2'] ['C2'] 1 0.571 1 0.571 L4E_ca Exp_2015-09-05_007_0001-0094 ['C1', 'C2'] ['C2'] 1 0.284 2 -0.278 L4E_ca Exp_2015-09-18_010_0001-0046 ['C1', 'C2'] ['C1'] 1 -0.074 1 -0.074 L4E_ca Exp_2016-06-09_004_0001-0101 ['C1', 'C2'] ['C2'] 1 0.041 2 -0.040 L4E_ca Exp_2015-08-28_003_0001-0105 ['C1', 'C2'] ['C2'] 1 -0.248 2 0.372 L4E_ca Exp_2015-09-04_006_0001-0061 ['C1', 'C2'] ['C2'] 1 0.130 2 -0.246 L4E_ca Exp_2015-09-18_011_0001-0102 ['C1', 'C2'] ['C1'] 1 0.636 1 0.636 L4E_ca JY1584AAAA ['C1', 'C2'] ['C2'] 1 0.023 2 0.000 L4E_wc JY1008AAAA ['C1', 'C2'] ['C2'] 1 0.110 2 0.290 L4E_wc JY0978AAAA ['C1', 'C2'] ['C2'] 1 0.000 2 0.000 L4E_wc JY1189AAAA ['C1', 'C2'] ['C2'] 1 0.000 2 0.000 L4E_wc JY1048AAAA ['C2'] ['C2'] 1 0.541 1 0.541 L4E_wc JY1002AAAA ['C1', 'C2'] ['C1'] 1 0.073 1 0.073 L4E_wc Exp_2015-09-24_004_0024-0130 ['C1', 'C2'] ['C1'] 1 -0.014 1 -0.014 L4E_wc JY0520AAAC ['C1', 'C2'] ['C1'] 1 0.014 1 0.014 L4E_wc JY1195AAAB ['C1', 'C2'] ['C2'] 1 0.000 2 0.000 L4E_wc Exp_2015-09-05_001_0001-0162 ['C1', 'C2'] ['C1'] 1 -0.020 1 -0.020 L4E_wc JY1633AAAA ['C1', 'C2'] ['C2'] 1 -0.068 2 0.225 L4E_wc JY0975AAAA ['C1', 'C2'] ['C2'] 1 0.000 2 0.000 L4E_wc JY0947AAAA ['C1', 'C2'] ['C2'] 1 0.004 2 0.016 L4E_wc JY0969AAAA ['C1', 'C2'] ['C2'] 1 0.000 2 0.000 L4E_wc JY1046AAAA ['C1', 'C2'] ['C1'] 1 -0.033 1 -0.033 L4E_wc Exp_2015-09-25_001_0001-0182 ['C1', 'C2'] ['C1'] 1 0.000 1 0.000 L4E_wc JY1211AAAB ['C2', 'C3'] ['C3'] 1 0.000 2 0.000 L4E_wc JY1345AAAA ['C1', 'C2'] ['C2'] 1 0.235 2 0.857 L4E_wc JY0913AAAA ['C1', 'C2'] ['C1'] 1 0.000 1 0.000 L4E_wc JY1397AAAA ['C1', 'C2'] ['C2'] 1 -0.024 2 0.000 L4E_wc JY1009AAAA ['C1', 'C2'] ['C2'] 1 0.606 2 0.056 L4E_wc JY1418AAAA ['C1', 'C2'] ['C2'] 1 0.885 2 0.000 L4E_wc JY0532AAAA ['D2', 'D1'] ['D2'] 1 0.000 1 0.000 L4E_wc JY1036AAAA ['C1', 'C2'] ['C1'] 1 0.000 1 0.000 L4E_wc Exp_2015-09-30_011_0001-0196 ['C1', 'C2'] ['C2'] 1 0.000 2 0.000 L4E_wc JY0544AAAB ['D2', 'D1'] ['D2'] 1 0.000 1 0.000 L4E_wc JY0950AAAA ['C1', 'C2'] ['C2'] 1 0.000 2 0.000
Per-unit measures used by the claims¶
Spike measures for every unit, in control trials (good trials without a stimulus flag), under both readings of the nonwhisking margin (M-EPOCH (a) and (b)); Vm measures for every whole-cell neuron. Each claim below uses these.
t1 = time.time()
S = {"a": {}, "b": {}}
for c in cells:
for mg in "ab":
S[mg][ssc7.cell_name(c)] = ssc7.spike_summary(c, margin=mg)
V = {}
for c in cells:
if c["vm"] is not None:
V[ssc7.cell_name(c)] = ssc7.vm_summary(c)
print(f"spike summaries for {len(S['a'])} units, Vm summaries for {len(V)} neurons in {time.time() - t1:.0f} s")
GROUP = {ssc7.cell_name(c): ssc7.group(c) for c in cells}
names = lambda *g: [n for n in S["a"] if GROUP[n] in g]
VPM, FS, L4E85 = names("VPM"), names("FS_wc", "FS_ca"), names("L4E_wc", "L4E_ca")
L4EWC, FSWC, L4EION, FSION = names("L4E_wc"), names("FS_wc"), names("L4E_ion"), names("FS_ion")
print({k: len(v) for k, v in dict(VPM=VPM, FS=FS, L4E85=L4E85, L4EWC=L4EWC, FSWC=FSWC, L4EION=L4EION, FSION=FSION).items()})
drop = pd.DataFrame([dict(name=n, group=GROUP[n], control_trials=S["a"][n]["n_trials"], touches=S["a"][n]["n_touch"],
whisk_s=round(S["a"][n]["whisk_s"], 1), nonw_s=round(S["a"][n]["nonw_s"], 1)) for n in S["a"]])
print("\nUnits with no nonwhisking or no whisking epoch (reading a):",
drop[(drop.whisk_s == 0) | (drop.nonw_s == 0)][["name", "group", "control_trials", "whisk_s", "nonw_s"]].to_string(index=False))
print("Units with no touch (ITI >= 25 ms):", drop[drop.touches == 0][["name", "group"]].to_string(index=False))
print("\nEpoch time per unit (s), reading a: whisking median", drop.whisk_s.median(), "; nonwhisking median", drop.nonw_s.median())
# Clock check: spikes (ephys clock) aligned to touch onsets (whisker clock). A shared clock gives a
# peak a few ms after touch; with touch times shifted by a random 0.5-1.5 s the peak must vanish.
rng0 = np.random.default_rng(0)
for g, nn in (("VPM", VPM), ("FS", FS), ("L4E", L4E85)):
ps = np.sum([S["a"][n]["psth"] for n in nn], 0) / sum(S["a"][n]["n_touch"] for n in nn) * 1000
sh = []
for n in nn:
tt = S["a"][n]["tt"].copy()
if len(tt):
tt[:, 1] = np.clip(tt[:, 1] + rng0.uniform(0.5, 1.5, len(tt)) * rng0.choice([-1, 1], len(tt)), 0.2, 4.8)
sh.append(ssc7.touch_psth(S["a"][n]["spk"], tt).sum(0))
sh = np.sum(sh, 0) / sum(S["a"][n]["n_touch"] for n in nn) * 1000
print(f"{g}: touch PSTH peak {ps[100:150].max():.0f} spikes/s at {np.argmax(ps[100:150])} ms after onset, baseline (-25-0 ms) {ps[75:100].mean():.0f}; "
f"with shifted touch times peak {sh[100:150].max():.0f} at {np.argmax(sh[100:150])} ms, baseline {sh[75:100].mean():.0f}")
def msig(s, reading):
"""M-SIG: sign of a significant whisking effect, two-sided rank-sum at p < 0.05."""
if reading == "a":
w, n = s["w_rows"], s["n_rows"]
if len(w) < 2 or len(n) < 2:
return 0, np.nan
x, y = w[:, 1] / w[:, 2], n[:, 1] / n[:, 2]
else:
x, y = s["w_trial"], s["n_trial"]
if len(x) < 2 or len(y) < 2:
return 0, np.nan
p = stats.ranksums(x, y).pvalue
if not np.isfinite(p) or p >= 0.05:
return 0, p
return (1 if np.mean(x) > np.mean(y) else -1), p
# Variants used by several claims below:
# - the principal whisker taken from the whisker configuration (ssc7.pw_index, reading "config"),
# for the L4 E neurons (spike and Vm measures) and the whole-cell FS neurons (Vm);
# - FS whole-cell Vm measures with every control trial, without leaving out trials far from the
# neuron's usual Vm (ssc7.stable_trials).
t1 = time.time()
ssc7.PW_READING = "config"
S_cfg = {n: ssc7.spike_summary(NAME[n], margin="a") for n in L4E85}
V_cfg = {n: ssc7.vm_summary(NAME[n]) for n in L4EWC + FSWC}
ssc7.PW_READING = "code"
V_all = {n: ssc7.vm_summary(NAME[n], drop_drift=False) for n in FSWC}
n_diff = int((PWT.group.str.startswith("L4E") & (PWT.series_code != PWT.series_config)).sum())
print(f"variant summaries in {time.time() - t1:.0f} s; L4 E neurons whose principal series differs between the readings: {n_diff}")
print("trials left out as far from the neuron's usual Vm, per FS whole-cell neuron:", {n: int(V_all[n]["n_trials"] - V[n]["n_trials"]) for n in FSWC})
spike summaries for 159 units, Vm summaries for 53 neurons in 71 s
{'VPM': 29, 'FS': 26, 'L4E85': 85, 'L4EWC': 37, 'FSWC': 7, 'L4EION': 9, 'FSION': 10}
Units with no nonwhisking or no whisking epoch (reading a): Empty DataFrame
Columns: [name, group, control_trials, whisk_s, nonw_s]
Index: []
Units with no touch (ITI >= 25 ms): name group
Exp_2015-11-25_006_0001-0066 L4E_ion
Epoch time per unit (s), reading a: whisking median 60.0 ; nonwhisking median 120.4
VPM: touch PSTH peak 139 spikes/s at 2 ms after onset, baseline (-25-0 ms) 18; with shifted touch times peak 18 at 11 ms, baseline 14
FS: touch PSTH peak 170 spikes/s at 5 ms after onset, baseline (-25-0 ms) 14; with shifted touch times peak 20 at 20 ms, baseline 16
L4E: touch PSTH peak 14 spikes/s at 9 ms after onset, baseline (-25-0 ms) 1; with shifted touch times peak 2 at 23 ms, baseline 1
variant summaries in 28 s; L4 E neurons whose principal series differs between the readings: 35
trials left out as far from the neuron's usual Vm, per FS whole-cell neuron: {'JY1139AAAA': 5, 'Exp_2015-09-09_005_0001-0154': 0, 'JY1171AAAI': 0, 'JY1045AAAA': 0, 'JY0995AAAA': 0, 'JY1041AAAA': 0, 'Exp_2015-09-15_001_0001-0110': 0}
behavior-performance¶
Mice performed the task at 0.72 +- 0.11 correct during the cortical recordings (111 cells) and 0.71 +- 0.07 during the VPM recordings (29 cells); they touched the pole 5.7 +- 5.3 times per trial at a proximal location (4,147 trials) and 0.9 +- 3.4 times at a distal location (4,173 trials), and licked 286 +- 329 ms after the first touch.
Correct = Hit or CR in the file's trial-type matrix; proximal = Go (lick) trials, distal = Nogo trials (Online Methods, Behavior: mice lick for the posterior positions). Cortical cells are the 111 non-ION-cut cortical recordings; touch counts pool the cortical and VPM recordings (each VPM session once). Readings: trials (a) all good trials, (b) control trials; touches counted (c) over the whole trial, (d) before the first lick.
def behav(c, trials):
tt = c["trial_type"]
typed = trials & (tt[:, :4].sum(1) > 0)
corr = (tt[:, 0] + tt[:, 2]) > 0
go = (tt[:, 0] + tt[:, 1]) > 0
T = ssc7.touches(c)
L = ssc7.licks_by_trial(c)
rows = []
for i in np.flatnonzero(typed):
a = T[i][0]
lk = L[i][(L[i] >= 0) & (L[i] < 5)]
fl = lk[0] if len(lk) else np.inf
rt = np.nan
if len(a):
after = lk[lk > a[0]]
rt = (after[0] - a[0]) * 1000 if len(after) else np.nan
rows.append((go[i], corr[i], len(a), int(np.sum(a < fl)), rt))
return np.array(rows, float).reshape(-1, 5)
cort = [c for c in cells if ssc7.group(c) in ("L4E_wc", "L4E_ca", "FS_wc", "FS_ca")]
vpm_sessions = {}
for c in cells:
if ssc7.group(c) == "VPM":
vpm_sessions.setdefault(c["meta"]["file"], []).append(c)
print("cortical cells:", len(cort), "; VPM units:", sum(len(v) for v in vpm_sessions.values()), "in", len(vpm_sessions), "sessions")
res_beh = {}
for rd in "ab":
sel = (lambda c: c["good"]) if rd == "a" else ssc7.control_trials
pc_cort = [behav(c, sel(c))[:, 1].mean() for c in cort]
# VPM: one performance per unit (the 29 cells), from the session's good trials of that unit
pc_vpm = [behav(c, sel(c))[:, 1].mean() for v in vpm_sessions.values() for c in v]
allrows = np.vstack([behav(c, sel(c)) for c in cort] + [behav(v[0], sel(v[0])) for v in vpm_sessions.values()])
go, nogo = allrows[allrows[:, 0] == 1], allrows[allrows[:, 0] == 0]
rt = allrows[:, 4][np.isfinite(allrows[:, 4])]
for cnt, col in (("c", 2), ("d", 3)):
vals = [np.mean(pc_cort), np.mean(pc_vpm), go[:, col].mean(), nogo[:, col].mean(), rt.mean()]
res_beh[rd + cnt] = vals
print(f"reading ({rd},{cnt}): correct cortical {np.mean(pc_cort):.3f} +- {np.std(pc_cort, ddof=1):.3f} (n={len(pc_cort)}); "
f"VPM {np.mean(pc_vpm):.3f} +- {np.std(pc_vpm, ddof=1):.3f} (n={len(pc_vpm)}); touches Go {go[:, col].mean():.2f} +- {go[:, col].std():.2f} "
f"({len(go)} trials), Nogo {nogo[:, col].mean():.2f} +- {nogo[:, col].std():.2f} ({len(nogo)} trials); "
f"reaction time {rt.mean():.0f} +- {rt.std():.0f} ms (n={len(rt)})")
exp_beh = [(0.72, 0.072), (0.71, 0.071), (5.7, 0.57), (0.9, 0.09), (286, 28.6)]
for k, v in res_beh.items():
print(k, ["%s" % within(x, e, t) for x, (e, t) in zip(v, exp_beh)])
# variant: touches counted on the series the whisker configuration names as principal
ssc7.PW_READING = "config"
allv = np.vstack([behav(c, c["good"]) for c in cort] + [behav(v[0], v[0]["good"]) for v in vpm_sessions.values()])
ssc7.PW_READING = "code"
print("variant, principal whisker by the configuration (reading a,c): Go touches %.2f, Nogo %.2f; reaction time %.0f ms" % (
allv[allv[:, 0] == 1, 2].mean(), allv[allv[:, 0] == 0, 2].mean(), np.nanmean(allv[:, 4])))
# cortical touch counts only, as a variant
allc = np.vstack([behav(c, c["good"]) for c in cort])
print("variant, cortical recordings only (reading a,c): Go touches %.2f (%d trials), Nogo %.2f (%d trials)" % (
allc[allc[:, 0] == 1, 2].mean(), (allc[:, 0] == 1).sum(), allc[allc[:, 0] == 0, 2].mean(), (allc[:, 0] == 0).sum()))
cortical cells: 111 ; VPM units: 29 in 18 sessions
reading (a,c): correct cortical 0.706 +- 0.104 (n=111); VPM 0.630 +- 0.119 (n=29); touches Go 7.56 +- 6.61 (7097 trials), Nogo 1.06 +- 2.78 (6872 trials); reaction time 328 +- 340 ms (n=5750) reading (a,d): correct cortical 0.706 +- 0.104 (n=111); VPM 0.630 +- 0.119 (n=29); touches Go 2.74 +- 3.24 (7097 trials), Nogo 0.36 +- 1.33 (6872 trials); reaction time 328 +- 340 ms (n=5750)
reading (b,c): correct cortical 0.721 +- 0.122 (n=111); VPM 0.630 +- 0.119 (n=29); touches Go 7.25 +- 6.54 (5565 trials), Nogo 1.02 +- 2.74 (5399 trials); reaction time 340 +- 334 ms (n=4453) reading (b,d): correct cortical 0.721 +- 0.122 (n=111); VPM 0.630 +- 0.119 (n=29); touches Go 2.86 +- 3.30 (5565 trials), Nogo 0.37 +- 1.35 (5399 trials); reaction time 340 +- 334 ms (n=4453) ac ['True', 'False', 'False', 'False', 'False'] ad ['True', 'False', 'False', 'False', 'False'] bc ['True', 'False', 'False', 'False', 'False'] bd ['True', 'False', 'False', 'False', 'False']
variant, principal whisker by the configuration (reading a,c): Go touches 5.93, Nogo 0.63; reaction time 334 ms
variant, cortical recordings only (reading a,c): Go touches 8.66 (4937 trials), Nogo 1.32 (4939 trials)
Result: partially reproduced. Cortical performance is 0.706 (all good trials) or 0.721 (control trials) correct, within 0.72 +- 0.072. VPM performance is 0.630, outside 0.71 +- 0.071. Touches per trial are 7.56 at the proximal (Go) pole and 1.06 at the distal pole over the whole trial, and 2.74 and 0.36 before the first lick. None of these is within 5.7 +- 0.57 and 0.9 +- 0.09. The reaction time is 328 to 340 ms, outside 286 +- 28.6. So one of the five values matches under every combination of readings. Proximal touches outnumber distal ones in every reading. With the principal whisker taken from the whisker configuration (variant), the Go count is 5.93 and the Nogo count 0.63.
vpm-baseline-rate¶
VPM neurons fire at substantial rates in the absence of whisker movement and touch (5.1 +- 5.5 spikes/s, median 3.3, n = 29).
for mg in "ab":
for rr in "ab":
x = [S[mg][n][f"nonw_{rr}"] for n in VPM]
print(f"margin ({mg}), rate reading ({rr}): {ci(x)}; mean within 5.1+-1.02: {within(np.nanmean(x), 5.1, 1.02)}, median within 3.3+-0.33: {within(np.nanmedian(x), 3.3, 0.33)}")
x = np.array([S["a"][n]["nonw_a"] for n in VPM])
print("range", x.min().round(2), "to", x.max().round(2))
print("by mouse (reading a,a):", pd.Series(x, index=[NAME[n]["meta"]["file"][:9] for n in VPM]).groupby(level=0).agg(["mean", "count"]).round(2).to_dict("index"))
boot = np.random.default_rng(1)
b = [np.mean(boot.choice(x, len(x))) for _ in range(1000)]
print("bootstrap 95% CI of the population mean (1,000 iterations):", np.percentile(b, [2.5, 97.5]).round(2))
margin (a), rate reading (a): mean 4.34 +- 4.79 s.d., median 1.99, n = 29; mean within 5.1+-1.02: True, median within 3.3+-0.33: False
margin (a), rate reading (b): mean 4.6 +- 5.24 s.d., median 2.08, n = 29; mean within 5.1+-1.02: True, median within 3.3+-0.33: False
margin (b), rate reading (a): mean 4.47 +- 4.85 s.d., median 2, n = 29; mean within 5.1+-1.02: True, median within 3.3+-0.33: False
margin (b), rate reading (b): mean 4.82 +- 5.31 s.d., median 2.18, n = 29; mean within 5.1+-1.02: True, median within 3.3+-0.33: False
range 0.03 to 17.66
by mouse (reading a,a): {'ANM184389': {'mean': 2.73, 'count': 12}, 'ANM186997': {'mean': 5.64, 'count': 2}, 'ANM199549': {'mean': 2.02, 'count': 5}, 'ANM199551': {'mean': 0.6, 'count': 1}, 'ANM199552': {'mean': 9.78, 'count': 7}, 'ANM203464': {'mean': 1.38, 'count': 2}}
bootstrap 95% CI of the population mean (1,000 iterations): [2.76 6.22]
Result: partially reproduced. The mean nonwhisking rate of the 29 VPM units is 4.34 to 4.82 spikes/s under the four readings, within 5.1 +- 1.02. The median is 1.99 to 2.18 spikes/s, below 3.3 +- 0.33 under every reading. Units fire at baseline (range 0.03 to 17.66 spikes/s), but the distribution is more skewed than the paper's.
vpm-touch-response¶
VPM neurons respond to active touch with a sharp, short-latency, brief increase in spike rate (0.6 +- 0.5 spikes per touch, median 0.4; latency 3.2 +- 1.0 ms, median 2.5 ms; duration 2.9 +- 1.7 ms).
spt = np.array([S["a"][n]["spt"] for n in VPM])
lat = np.array([S["a"][n]["latency"] for n in VPM])
dur = np.array([S["a"][n]["duration"] for n in VPM])
ntouch = np.array([S["a"][n]["n_touch"] for n in VPM])
print("touches per unit: median", np.median(ntouch), "range", ntouch.min(), "-", ntouch.max())
print("spikes per touch:", ci(spt), "range", np.nanmin(spt).round(2), "to", np.nanmax(spt).round(2))
print("latency (units passing the M-LAT exclusion):", ci(lat), "; excluded:", int(np.isnan(lat).sum()))
print("duration (25% of rate increase):", ci(dur[np.isfinite(lat)]), "(units with a latency)")
vals = [np.nanmean(spt), np.nanmedian(spt), np.nanmean(lat), np.nanmedian(lat), np.nanmean(dur[np.isfinite(lat)])]
exp = [(0.6, 0.093), (0.4, 0.04), (3.2, 0.32), (2.5, 0.25), (2.9, 0.32)]
print("within tolerance:", [within(v, e, t) for v, (e, t) in zip(vals, exp)])
pop = np.sum([S["a"][n]["psth"] for n in VPM], 0) / ntouch.sum() * 1000
print("population PSTH (spikes/s) at -3..+8 ms bins:", pop[97:109].round(1))
lat_c = np.array([ssc7.spike_latency(S["a"][n]["psth"], max(1, S["a"][n]["n_touch"]), centre=True) for n in VPM])
print(f"variant, latency at the centre of the crossing bin: {ci(lat_c)}; within (3.2+-0.32, 2.5+-0.25): {within(np.nanmean(lat_c), 3.2, 0.32)}, {within(np.nanmedian(lat_c), 2.5, 0.25)}")
print("latencies per unit (ms, left edge):", sorted(lat[np.isfinite(lat)].tolist()))
touches per unit: median 326.0 range 60 - 904 spikes per touch: mean 0.5 +- 0.43 s.d., median 0.363, n = 29 range 0.0 to 1.54 latency (units passing the M-LAT exclusion): mean 2.48 +- 4.54 s.d., median 1, n = 25 ; excluded: 4 duration (25% of rate increase): mean 4.08 +- 1.96 s.d., median 3, n = 25 (units with a latency) within tolerance: [False, True, False, False, False] population PSTH (spikes/s) at -3..+8 ms bins: [ 17. 19.9 18.4 20.8 60.5 138.8 131.8 87.9 53.1 44.5 34.3 28.3] variant, latency at the centre of the crossing bin: mean 2.98 +- 4.54 s.d., median 1.5, n = 25; within (3.2+-0.32, 2.5+-0.25): True, False latencies per unit (ms, left edge): [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 24.0]
Result: partially reproduced. Spikes per touch are 0.50 +- 0.43 (median 0.363). The median is within 0.4 +- 0.04; the mean is just below 0.6 +- 0.093. The population PSTH peaks 2 ms after touch (139 spikes/s against a baseline of about 18). By M-LAT the latency is 2.48 ms on average (median 1 ms, n = 25), against 3.2 +- 0.32 and 2.5 +- 0.25; 13 of the 25 units cross in the first 1 ms bin. Read at the bin centre, the latency is 2.98 ms (within) with median 1.5 ms (outside). The duration is 4.08 ms against 2.9 +- 0.32. The response is sharp and brief, but here it is earlier and longer than the paper's. The 1 ms difference in the median latency is not explained.
vpm-whisking-count¶
Most VPM neurons (25 of 29) significantly increase their spike rate during whisking without touch; 3 of 29 do not increase but still respond to touch, and one decreases significantly.
for mg in "ab":
for rd in "ab":
sg = [msig(S[mg][n], rd)[0] for n in VPM]
up, dn, ns = sg.count(1), sg.count(-1), sg.count(0)
print(f"margin ({mg}), samples ({rd}): increase {up}, decrease {dn}, no significant change {ns}; "
f"within (25+-2.5, 3+-1, 1+-1): {within(up, 25, 2.5) and within(ns, 3, 1) and within(dn, 1, 1)}")
sg = [msig(S["a"][n], "a") for n in VPM]
print("p values, reading (a,a):", [f"{n}:{s}:{p:.2g}" for n, (s, p) in zip(VPM, sg)])
margin (a), samples (a): increase 22, decrease 1, no significant change 6; within (25+-2.5, 3+-1, 1+-1): False margin (a), samples (b): increase 24, decrease 1, no significant change 4; within (25+-2.5, 3+-1, 1+-1): True margin (b), samples (a): increase 21, decrease 1, no significant change 7; within (25+-2.5, 3+-1, 1+-1): False margin (b), samples (b): increase 24, decrease 1, no significant change 4; within (25+-2.5, 3+-1, 1+-1): True p values, reading (a,a): ['8.2.99:1:1.2e-110', '17.1.230:0:0.54', '3.1.58:1:9.1e-13', '3.3.33:1:1.1e-177', '3.4.148:1:5.3e-115', '13.3.155:1:0.026', '4.4.46:1:2e-25', '4.4.57:1:3.2e-05', '12.2.50:1:8.7e-36', '12.2.62:0:0.37', '15.2.107:1:0.004', '15.3.188:0:0.46', '15.3.304:0:0.19', '16.2.86:1:0.04', '2.3.95:1:0.0053', '11.2.110:1:4.7e-84', '9.2.113:1:1.4e-05', '5.1.56:1:0.0017', '5.4.142:1:6.7e-55', '1.3.373:1:0.0052', '18.1.135:-1:2.8e-87', '10.2.38:1:2.8e-24', '14.3.244:1:2.7e-49', '6.1.17:0:0.49', '6.1.29:1:6e-06', '6.3.34:1:4.3e-162', '6.4.58:1:0.0026', '6.4.68:0:0.2', '7.2.145:1:2.8e-08']
Result: reproduced. With per-trial rates (M-SIG reading b), 24 of 29 units increase significantly with whisking, 1 decreases and 4 show no significant change. That is within 25 +- 2.5, 3 +- 1 and 1 +- 1 under both nonwhisking margins. With per-epoch rates (reading a) the counts are 22 or 21 increases, 1 decrease and 6 or 7 unchanged, outside tolerance. The criterion holds under one reading. Whether the unchanged units respond to touch was not tested.
vpm-whisking-rate¶
The average VPM spike rate increases severalfold with whisker movement, from 5.1 +- 5.5 to 13.5 +- 12.7 spikes/s (n = 29, P = 4e-6, Wilcoxon signed-rank).
for mg in "ab":
for rr in "ab":
nw = np.array([S[mg][n][f"nonw_{rr}"] for n in VPM])
wh = np.array([S[mg][n][f"whisk_{rr}"] for n in VPM])
p = stats.wilcoxon(wh, nw).pvalue
print(f"reading (a) epochs, margin ({mg}), rate ({rr}): nonwhisking {nw.mean():.2f} +- {nw.std(ddof=1):.2f}, whisking {wh.mean():.2f} +- {wh.std(ddof=1):.2f}, "
f"ratio {wh.mean() / nw.mean():.2f}, signed-rank p = {p:.2g}; within: {within(nw.mean(), 5.1, 1.02)}, {within(wh.mean(), 13.5, 2.36)}")
# variant (b): rate 0-400 ms after whisking onsets against 200 ms before
pre, post = [], []
for n in VPM:
s = S["a"][n]
a_, b_ = [], []
for i, d in s["ep"].items():
for e in d["onsets"]:
t = e / 1000
sp = s["spk"][i]
a_.append(np.sum((sp >= t - 0.2) & (sp < t)) / 0.2)
b_.append(np.sum((sp >= t) & (sp < t + 0.4)) / 0.4)
pre.append(np.mean(a_) if a_ else np.nan)
post.append(np.mean(b_) if b_ else np.nan)
pre, post = np.array(pre), np.array(post)
ok = np.isfinite(pre) & np.isfinite(post)
print(f"variant (b), onsets: before {np.nanmean(pre):.2f}, after {np.nanmean(post):.2f} spikes/s, n = {ok.sum()}, p = {stats.wilcoxon(post[ok], pre[ok]).pvalue:.2g}")
reading (a) epochs, margin (a), rate (a): nonwhisking 4.34 +- 4.79, whisking 11.92 +- 11.67, ratio 2.74, signed-rank p = 5.2e-08; within: True, True reading (a) epochs, margin (a), rate (b): nonwhisking 4.60 +- 5.24, whisking 12.55 +- 12.24, ratio 2.73, signed-rank p = 3.7e-08; within: True, True reading (a) epochs, margin (b), rate (a): nonwhisking 4.47 +- 4.85, whisking 11.92 +- 11.67, ratio 2.67, signed-rank p = 5.2e-08; within: True, True reading (a) epochs, margin (b), rate (b): nonwhisking 4.82 +- 5.31, whisking 12.55 +- 12.24, ratio 2.60, signed-rank p = 3.7e-08; within: True, True
variant (b), onsets: before 4.61, after 9.92 spikes/s, n = 29, p = 3.7e-09
Result: reproduced. Under reading (a), whisking against nonwhisking epochs, the mean rate rises from 4.34 to 11.92 spikes/s (margin a, rate a; 2.74-fold), signed-rank p = 5.2e-8, n = 29. Both means are within tolerance (5.1 +- 1.02, 13.5 +- 2.36) under all four sub-readings. The onset variant (b) gives 4.61 to 9.92 spikes/s, p = 3.7e-9.
vpm-phase-modulation¶
VPM spike rate is modulated by the phase of whisker movement.
for nb in (8, 16):
r2 = np.array([S["a"][n][f"phase{nb}"][0] for n in VPM])
cs = np.array([S["a"][n][f"phase{nb}"][1] for n in VPM])
pp = np.array([S["a"][n][f"phase{nb}"][2] for n in VPM])
good = r2 > 0.25
print(f"{nb} bins: r2 > 0.25 in {good.sum()} of {len(VPM)}; r2 median {np.nanmedian(r2):.2f}; coupling strength of those, median {np.median(cs[good]):.2f} spikes/s "
f"(range {cs[good].min():.2f}-{cs[good].max():.2f}); preferred phase median {np.median(pp[good]):.2f} rad")
# null: the same fit with spike counts shuffled across whisking samples, one unit per draw
rng = np.random.default_rng(2)
null = []
for n in VPM:
s = S["a"][n]
ph, y = ssc7.spike_phase_data(s["spk"], s["ep"])
null.append(ssc7.phase_fit(ph, rng.permutation(y), 8)[0])
print("null (shuffled spikes), 8 bins: r2 > 0.25 in", int(np.sum(np.array(null) > 0.25)), "of", len(VPM))
8 bins: r2 > 0.25 in 27 of 29; r2 median 0.57; coupling strength of those, median 1.63 spikes/s (range 0.13-6.54); preferred phase median -0.38 rad 16 bins: r2 > 0.25 in 25 of 29; r2 median 0.48; coupling strength of those, median 1.73 spikes/s (range 0.15-6.70); preferred phase median -0.37 rad
null (shuffled spikes), 8 bins: r2 > 0.25 in 14 of 29
Result: reproduced. The single-sinusoid fit has r2 > 0.25 in 27 of 29 units with 8 phase bins and 25 of 29 with 16 bins, more than half under both. The coupling strength of those units has a median of 1.63 spikes/s (range 0.13 to 6.54), and the preferred phase a median of -0.38 rad. The r2 cutoff is weak: with spike counts shuffled across whisking samples, 14 of 29 units still pass it.
vpm-rate-amplitude-trials¶
Within a single behavioral session, VPM spike rate and whisking amplitude co-vary across trials (Pearson r = 0.61, P = 1e-78, 310 trials).
rows = []
for n in VPM:
c = NAME[n]
s = S["a"][n]
rr, aa = [], []
for i, d in s["ep"].items():
rr.append(len(s["spk"][i][(s["spk"][i] >= 0) & (s["spk"][i] < 5)]) / 5.0)
aa.append(np.nanmean(d["amp"]))
r, p = stats.pearsonr(rr, aa)
rows.append(dict(unit=n, session=c["meta"]["file"], trials=len(rr), r=round(r, 3), p=p))
ra = pd.DataFrame(rows)
print(ra.to_string(index=False))
print("units with 310 trials:", (ra.trials == 310).sum(), "; significant positive r:", int(((ra.r > 0) & (ra.p < 0.05)).sum()), "of", len(ra))
print("units with r within 0.61 +- 0.061 and p < 0.05:", ra[(abs(ra.r - 0.61) <= 0.061) & (ra.p < 0.05)].unit.tolist())
unit session trials r p 8.2.99 ANM199552_20130602.nwb 336 0.506 3.345444e-23 17.1.230 ANM203464_20130702.nwb 287 0.321 2.731184e-08 3.1.58 ANM184389_20130207.nwb 298 0.435 3.739446e-15 3.3.33 ANM184389_20130207.nwb 300 0.585 5.618913e-29 3.4.148 ANM184389_20130207.nwb 290 0.220 1.642939e-04 13.3.155 ANM199551_20130626.nwb 260 0.496 1.480746e-17 4.4.46 ANM184389_20130211.nwb 157 0.735 5.786144e-28 4.4.57 ANM184389_20130211.nwb 154 0.704 2.393350e-24 12.2.50 ANM199552_20130608.nwb 144 0.322 8.329097e-05 12.2.62 ANM199552_20130608.nwb 144 0.331 5.201400e-05 15.2.107 ANM199549_20130604.nwb 75 0.485 1.025880e-05 15.3.188 ANM199549_20130604.nwb 75 0.368 1.166912e-03 15.3.304 ANM199549_20130604.nwb 74 0.574 8.955892e-08 16.2.86 ANM199549_20130605.nwb 342 0.297 2.042331e-08 2.3.95 ANM186997_20130321.nwb 217 0.061 3.687197e-01 11.2.110 ANM199552_20130606.nwb 213 0.553 1.718756e-18 9.2.113 ANM199552_20130603.nwb 216 0.184 6.709761e-03 5.1.56 ANM184389_20130212.nwb 159 0.677 1.124297e-22 5.4.142 ANM184389_20130212.nwb 159 0.906 1.277626e-60 1.3.373 ANM186997_20130317.nwb 84 0.157 1.550715e-01 18.1.135 ANM203464_20130705.nwb 248 0.004 9.547120e-01 10.2.38 ANM199552_20130604.nwb 322 0.283 2.394594e-07 14.3.244 ANM199549_20130530.nwb 251 0.504 1.312089e-17 6.1.17 ANM184389_20130213.nwb 150 0.193 1.771204e-02 6.1.29 ANM184389_20130213.nwb 150 0.286 3.925616e-04 6.3.34 ANM184389_20130213.nwb 151 0.491 1.618931e-10 6.4.58 ANM184389_20130213.nwb 152 0.106 1.942843e-01 6.4.68 ANM184389_20130213.nwb 150 0.094 2.547393e-01 7.2.145 ANM199552_20130601.nwb 334 0.345 8.917233e-11 units with 310 trials: 0 ; significant positive r: 24 of 29 units with r within 0.61 +- 0.061 and p < 0.05: ['3.3.33', '15.3.304', '11.2.110']
Result: reproduced. No unit has a session of 310 good trials, so the criterion's fallback applies. 24 of 29 units show a significant positive Pearson correlation between trial spike rate and mean whisking amplitude. Three units (3.3.33, 15.3.304, 11.2.110) have r within 0.61 +- 0.061.
fs-baseline-rate¶
L4 FS interneurons are active at baseline, even without whisker movement (9.3 +- 8.5 spikes/s, median 6.4, n = 26).
The neurons are the 26 in the data set's two control FS folders (7 whole-cell, 19 cell-attached).
for mg in "ab":
for rr in "ab":
x = [S[mg][n][f"nonw_{rr}"] for n in FS]
print(f"margin ({mg}), rate ({rr}): {ci(x)}; mean within 9.3+-1.67: {within(np.nanmean(x), 9.3, 1.67)}, median within 6.4+-0.64: {within(np.nanmedian(x), 6.4, 0.64)}")
x = np.array([S["a"][n]["nonw_a"] for n in FS])
print("range", x.min().round(2), "to", x.max().round(2))
print("whole-cell", ci(x[:0] if False else [S['a'][n]['nonw_a'] for n in FSWC]), "; cell-attached", ci([S['a'][n]['nonw_a'] for n in names('FS_ca')]))
margin (a), rate (a): mean 9.43 +- 8.33 s.d., median 6.3, n = 26; mean within 9.3+-1.67: True, median within 6.4+-0.64: True margin (a), rate (b): mean 9.96 +- 9.08 s.d., median 6.96, n = 26; mean within 9.3+-1.67: True, median within 6.4+-0.64: True margin (b), rate (a): mean 9.43 +- 8.32 s.d., median 6.28, n = 26; mean within 9.3+-1.67: True, median within 6.4+-0.64: True margin (b), rate (b): mean 9.94 +- 9 s.d., median 6.95, n = 26; mean within 9.3+-1.67: True, median within 6.4+-0.64: True range 0.21 to 31.37 whole-cell mean 11.4 +- 8.62 s.d., median 7.7, n = 7 ; cell-attached mean 8.72 +- 8.34 s.d., median 4.32, n = 19
Result: reproduced. The 26 FS neurons fire 9.43 spikes/s on average in nonwhisking epochs (median 6.3), within 9.3 +- 1.67 and 6.4 +- 0.64. All four readings fall within (means 9.43 to 9.96, medians 6.28 to 6.96).
fs-touch-spikes¶
L4 FS interneurons fire about two spikes per touch (1.9 +- 1.0, median 1.9, n = 26) with short latency (5.3 +- 2.1 ms, median 4.5 ms, n = 24).
spt = np.array([S["a"][n]["spt"] for n in FS])
lat = np.array([S["a"][n]["latency"] for n in FS])
print("spikes per touch (0-50 ms minus 2 x 0-25 ms before):", ci(spt), "range", spt.min().round(2), "to", spt.max().round(2))
print("latency:", ci(lat), "; passing the exclusion:", int(np.isfinite(lat).sum()))
vals = [spt.mean(), np.median(spt), np.nanmean(lat), np.nanmedian(lat), np.isfinite(lat).sum()]
exp = [(1.9, 0.2), (1.9, 0.19), (5.3, 0.53), (4.5, 0.45), (24, 2.4)]
print("within tolerance:", [within(v, e, t) for v, (e, t) in zip(vals, exp)])
print("whole-cell", ci([S['a'][n]['spt'] for n in FSWC]), "; cell-attached", ci([S['a'][n]['spt'] for n in names('FS_ca')]))
# variant: all trials, not only control trials
spt_all = [ssc7.spike_summary(NAME[n], trials=NAME[n]["good"])["spt"] for n in FS]
print("variant, all good trials:", ci(spt_all))
lat_c = np.array([ssc7.spike_latency(S["a"][n]["psth"], max(1, S["a"][n]["n_touch"]), centre=True) for n in FS])
print(f"variant, latency at the centre of the crossing bin: {ci(lat_c)}; within (5.3+-0.53, 4.5+-0.45): {within(np.nanmean(lat_c), 5.3, 0.53)}, {within(np.nanmedian(lat_c), 4.5, 0.45)}")
spikes per touch (0-50 ms minus 2 x 0-25 ms before): mean 1.83 +- 0.975 s.d., median 1.95, n = 26 range 0.17 to 3.9 latency: mean 5.92 +- 4.46 s.d., median 4, n = 25 ; passing the exclusion: 25 within tolerance: [True, True, False, False, True] whole-cell mean 2.46 +- 0.527 s.d., median 2.74, n = 7 ; cell-attached mean 1.6 +- 1.01 s.d., median 1.33, n = 19
variant, all good trials: mean 1.68 +- 0.92 s.d., median 1.72, n = 26 variant, latency at the centre of the crossing bin: mean 6.42 +- 4.46 s.d., median 4.5, n = 25; within (5.3+-0.53, 4.5+-0.45): False, True
Result: partially reproduced. FS neurons fire 1.83 +- 0.975 spikes per touch (median 1.95, n = 26), within 1.9 +- 0.2 and 1.9 +- 0.19. 25 neurons pass the latency exclusion (24 +- 2.4). The latency averages 5.92 ms (median 4 ms), outside 5.3 +- 0.53 and 4.5 +- 0.45. Read at the bin centre, the median is 4.5 ms (within) and the mean 6.42 ms (outside). At the bin edge three of the five values hold (spikes per touch, mean and median, and the count of 25); at the bin centre four do (the latency median as well). The latency mean is outside under both.
fs-whisking-count¶
Most L4 FS neurons (23 of 26) significantly increase their spike rate during whisker movement without touch, and the rest (3 of 26) decrease it.
for mg in "ab":
for rd in "ab":
sg = [msig(S[mg][n], rd)[0] for n in FS]
up, dn, ns = sg.count(1), sg.count(-1), sg.count(0)
print(f"margin ({mg}), samples ({rd}): increase {up}, decrease {dn}, no significant change {ns}; within (23+-2.3, 3+-1): {within(up, 23, 2.3) and within(dn, 3, 1)}")
margin (a), samples (a): increase 21, decrease 3, no significant change 2; within (23+-2.3, 3+-1): True margin (a), samples (b): increase 22, decrease 3, no significant change 1; within (23+-2.3, 3+-1): True margin (b), samples (a): increase 21, decrease 3, no significant change 2; within (23+-2.3, 3+-1): True margin (b), samples (b): increase 22, decrease 3, no significant change 1; within (23+-2.3, 3+-1): True
Result: reproduced. 21 or 22 of 26 FS neurons increase significantly with whisking and 3 decrease, within 23 +- 2.3 and 3 +- 1 under all four readings.
fs-whisking-rate¶
With whisking the L4 FS spike rate doubles (to 21.1 +- 15.8 spikes/s, median 14.6, n = 26, P = 2.7e-5).
for mg in "ab":
for rr in "ab":
nw = np.array([S[mg][n][f"nonw_{rr}"] for n in FS])
wh = np.array([S[mg][n][f"whisk_{rr}"] for n in FS])
p = stats.wilcoxon(wh, nw).pvalue
ratio = wh.mean() / nw.mean()
ok = within(wh.mean(), 21.1, 3.1) and within(np.median(wh), 14.6, 1.46) and p < 0.05 and wh.mean() > nw.mean() and 1.8 <= ratio <= 2.5
print(f"margin ({mg}), rate ({rr}): whisking {ci(wh)}; nonwhisking mean {nw.mean():.2f}; ratio {ratio:.2f}; signed-rank p = {p:.2g}; all parts hold: {ok}")
margin (a), rate (a): whisking mean 21.7 +- 16.3 s.d., median 14.2, n = 26; nonwhisking mean 9.43; ratio 2.30; signed-rank p = 2.3e-05; all parts hold: True margin (a), rate (b): whisking mean 22.5 +- 17 s.d., median 14.5, n = 26; nonwhisking mean 9.96; ratio 2.26; signed-rank p = 1.1e-05; all parts hold: True margin (b), rate (a): whisking mean 21.7 +- 16.3 s.d., median 14.2, n = 26; nonwhisking mean 9.43; ratio 2.30; signed-rank p = 2.3e-05; all parts hold: True margin (b), rate (b): whisking mean 22.5 +- 17 s.d., median 14.5, n = 26; nonwhisking mean 9.94; ratio 2.26; signed-rank p = 1.1e-05; all parts hold: True
Result: reproduced. The whisking rate is 21.7 +- 16.3 spikes/s (median 14.2), against 9.43 nonwhisking: a ratio of 2.30, signed-rank p = 2.3e-5, n = 26. The means, the medians, the test and the ratio (between 1.8 and 2.5) hold under all four readings (ratios 2.26 to 2.30).
fs-phase-coupling¶
L4 FS spikes are coupled to whisking phase; the phase relation is fit by a single sinusoid in 18 neurons and needs a second harmonic in 7 (n = 25).
A neuron needs the second harmonic when the r2 of the sum is at least 1.5 times that of the single sinusoid (Supplementary Fig. 7g legend).
for nb in (8, 16):
r1 = np.array([S["a"][n][f"phase{nb}"][0] for n in FS])
r2h = np.array([S["a"][n][f"phase{nb}h"][0] for n in FS])
harm = r2h >= 1.5 * r1
print(f"{nb} bins: single {int((~harm).sum())}, with second harmonic {int(harm.sum())} (n = {len(FS)}); within (18+-1.8, 7+-1): {within((~harm).sum(), 18, 1.8) and within(harm.sum(), 7, 1)}; "
f"single-sinusoid r2 median {np.median(r1):.2f}, r2 > 0.25 in {int((r1 > 0.25).sum())}")
8 bins: single 22, with second harmonic 4 (n = 26); within (18+-1.8, 7+-1): False; single-sinusoid r2 median 0.82, r2 > 0.25 in 25 16 bins: single 21, with second harmonic 5 (n = 26); within (18+-1.8, 7+-1): False; single-sinusoid r2 median 0.70, r2 > 0.25 in 22
Result: partially reproduced. FS spikes are coupled to whisking phase: the single sinusoid has r2 > 0.25 in 25 of 26 neurons (8 bins). The split differs from the paper's. A second harmonic raises r2 by half or more in 4 neurons (8 bins) or 5 (16 bins), leaving 22 or 21 with a single sinusoid, against 18 and 7. The counts are outside tolerance under both binnings.
l4e-spikes-touch-selective¶
L4 excitatory neurons respond mostly to touch (0.3 +- 0.4 spikes per touch, median 0.1, n = 85) and only weakly to whisker movement, with no significant change between nonwhisking (0.4 +- 0.6 spikes/s, median 0.1) and whisking (0.6 +- 0.9 spikes/s, median 0.2; P = 0.20).
exp = [(0.3, 0.043), (0.1, 0.01), (0.4, 0.065), (0.1, 0.01), (0.6, 0.098), (0.2, 0.02)]
for mg in "ab":
for rr in "ab":
spt = np.array([S[mg][n]["spt"] for n in L4E85])
nw = np.array([S[mg][n][f"nonw_{rr}"] for n in L4E85])
wh = np.array([S[mg][n][f"whisk_{rr}"] for n in L4E85])
ok = np.isfinite(spt)
vals = [np.nanmean(spt), np.nanmedian(spt), nw.mean(), np.median(nw), wh.mean(), np.median(wh)]
p = stats.wilcoxon(wh, nw).pvalue
print(f"margin ({mg}), rate ({rr}): spikes/touch {ci(spt)}; nonwhisking {ci(nw)}; whisking {ci(wh)}; "
f"signed-rank p = {p:.3g}; difference mean {np.mean(wh - nw):.3f}, median {np.median(wh - nw):.3f}; "
f"within: {[within(v, e, t) for v, (e, t) in zip(vals, exp)]}")
print("by recording type (margin a, rate a): whole-cell spikes/touch", ci([S['a'][n]['spt'] for n in L4EWC]), "; cell-attached", ci([S['a'][n]['spt'] for n in names('L4E_ca')]))
spt = np.array([S_cfg[n]["spt"] for n in L4E85])
nw = np.array([S_cfg[n]["nonw_a"] for n in L4E85])
wh = np.array([S_cfg[n]["whisk_a"] for n in L4E85])
ok = np.isfinite(nw) & np.isfinite(wh)
print(f"variant, principal whisker by the configuration (margin a, rate a): spikes/touch {ci(spt)}; nonwhisking {ci(nw)}; whisking {ci(wh)}; "
f"signed-rank p = {stats.wilcoxon(wh[ok], nw[ok]).pvalue:.3g}; within: {[within(v, e, t) for v, (e, t) in zip([np.nanmean(spt), np.nanmedian(spt), np.nanmean(nw), np.nanmedian(nw), np.nanmean(wh), np.nanmedian(wh)], exp)]}")
margin (a), rate (a): spikes/touch mean 0.2 +- 0.4 s.d., median 0.0415, n = 85; nonwhisking mean 0.428 +- 0.682 s.d., median 0.0922, n = 85; whisking mean 0.718 +- 1.16 s.d., median 0.214, n = 85; signed-rank p = 0.0273; difference mean 0.290, median 0.000; within: [False, False, True, True, False, True] margin (a), rate (b): spikes/touch mean 0.2 +- 0.4 s.d., median 0.0415, n = 85; nonwhisking mean 0.428 +- 0.728 s.d., median 0.116, n = 85; whisking mean 0.759 +- 1.21 s.d., median 0.204, n = 85; signed-rank p = 0.02; difference mean 0.331, median 0.000; within: [False, False, True, False, False, True] margin (b), rate (a): spikes/touch mean 0.2 +- 0.4 s.d., median 0.0415, n = 85; nonwhisking mean 0.428 +- 0.678 s.d., median 0.0914, n = 85; whisking mean 0.718 +- 1.16 s.d., median 0.214, n = 85; signed-rank p = 0.026; difference mean 0.290, median 0.000; within: [False, False, True, True, False, True] margin (b), rate (b): spikes/touch mean 0.2 +- 0.4 s.d., median 0.0415, n = 85; nonwhisking mean 0.426 +- 0.699 s.d., median 0.121, n = 85; whisking mean 0.759 +- 1.21 s.d., median 0.204, n = 85; signed-rank p = 0.0214; difference mean 0.333, median 0.000; within: [False, False, True, False, False, True] by recording type (margin a, rate a): whole-cell spikes/touch mean 0.0959 +- 0.223 s.d., median 0, n = 37 ; cell-attached mean 0.28 +- 0.483 s.d., median 0.0985, n = 48 variant, principal whisker by the configuration (margin a, rate a): spikes/touch mean 0.172 +- 0.374 s.d., median 0.00347, n = 84; nonwhisking mean 0.438 +- 0.709 s.d., median 0.0819, n = 85; whisking mean 0.805 +- 1.29 s.d., median 0.274, n = 85; signed-rank p = 0.00612; within: [False, False, True, False, False, False]
Result: not reproduced. The claim of no whisking effect fails its test. The signed-rank test of whisking against nonwhisking rates over the 85 neurons gives p = 0.020 to 0.027 under all four readings (mean difference 0.29 to 0.33 spikes/s, median difference 0). The nonwhisking mean (0.426 to 0.428) and the whisking median (0.204 to 0.214) are within tolerance under every reading. The nonwhisking median is within under rate reading (a) (0.091 and 0.092) and outside under reading (b) (0.116 and 0.121, against 0.1 +- 0.01). The whisking mean (0.718 to 0.759) is not, nor are spikes per touch (mean 0.20, median 0.04, against 0.3 and 0.1). Whole-cell neurons fire fewer spikes per touch (0.096) than cell-attached ones (0.28). With the principal whisker taken from the whisker configuration, the test gives p = 0.0061 and spikes per touch fall to 0.172, so the outcome does not rest on that choice.
ion-cut-behavior¶
After ION transection mice still whisk but perform the task at chance (48% correct).
ion = [c for c in cells if ssc7.group(c) in ("L4E_ion", "FS_ion")]
per = [behav(c, c["good"]) for c in ion]
pooled = np.vstack(per)[:, 1].mean()
mean_cells = np.mean([p[:, 1].mean() for p in per])
mice = pd.Series([p[:, 1].mean() for p in per], index=[c["meta"]["subject"] for c in ion])
print(f"ION-cut recordings: {len(ion)} cells, {mice.index.nunique()} mice, {sum(len(p) for p in per)} typed trials")
print(f"(a) pooled over trials: {pooled:.3f}; (b) mean over cells: {mean_cells:.3f} +- {np.std([p[:, 1].mean() for p in per], ddof=1):.3f}; within 0.48+-0.048: {within(pooled, 0.48, 0.048)}, {within(mean_cells, 0.48, 0.048)}")
print("by mouse:", mice.groupby(level=0).mean().round(3).to_dict())
amp_ion = np.concatenate([np.nanmean(np.vstack([d["amp"] for d in S["a"][ssc7.cell_name(c)]["ep"].values()]), 1) for c in ion])
amp_ctl = np.concatenate([np.nanmean(np.vstack([d["amp"] for d in S["a"][n]["ep"].values()]), 1) for n in L4E85 + FS])
print(f"mean whisking amplitude per trial (degrees): ION cut median {np.median(amp_ion):.2f}, control median {np.median(amp_ctl):.2f}")
ION-cut recordings: 19 cells, 7 mice, 1335 typed trials
(a) pooled over trials: 0.492; (b) mean over cells: 0.510 +- 0.061; within 0.48+-0.048: True, True
by mouse: {'ANM273341': 0.473, 'ANM275231': 0.461, 'ANM281589': 0.462, 'ANM281592': 0.63, 'ANM318530': 0.485, 'ANM318531': 0.532, 'ANM318532': 0.554}
mean whisking amplitude per trial (degrees): ION cut median 1.60, control median 2.56
Result: reproduced. After ION cut, 0.492 of 1,335 trials are correct (pooled), and the mean over 19 cells is 0.510. Both are within 0.48 +- 0.048. The median whisking amplitude per trial is 1.60 degrees, against 2.56 in control recordings, so the mice still whisk.
ion-cut-fs-touch¶
After ION transection touch does not evoke spikes in L4 FS interneurons (n = 10).
x = np.array([S["a"][n]["spt"] for n in FSION])
print("spikes per touch, ION cut:", ci(x), "; values", x.round(3))
p = stats.wilcoxon(x).pvalue
print(f"signed-rank against zero: p = {p:.3g}; control FS mean {np.mean([S['a'][n]['spt'] for n in FS]):.2f}")
spikes per touch, ION cut: mean 0.0614 +- 0.115 s.d., median 0.0401, n = 10 ; values [ 0.138 0.039 0.024 0.083 0. 0.041 -0.066 0.345 0.043 -0.033] signed-rank against zero: p = 0.0977; control FS mean 1.83
Result: reproduced. After ION cut, FS spikes per touch are 0.061 +- 0.115 (median 0.040, n = 10), and the signed-rank test against zero is not significant (p = 0.098). In control FS neurons the mean is 1.83.
ion-cut-fs-whisking¶
After ION transection whisking-related activation of L4 FS interneurons is absent in most cells (P = 0.80, n = 10).
for mg in "ab":
for rr in "ab":
nw = np.array([S[mg][n][f"nonw_{rr}"] for n in FSION])
wh = np.array([S[mg][n][f"whisk_{rr}"] for n in FSION])
p = stats.wilcoxon(wh, nw).pvalue
print(f"margin ({mg}), rate ({rr}): nonwhisking {nw.mean():.2f}, whisking {wh.mean():.2f}; signed-rank p = {p:.3g}; median ratio {np.median(wh / nw):.2f}")
for rd in "ab":
sg = [msig(S["a"][n], rd)[0] for n in FSION]
print(f"M-SIG ({rd}): increase {sg.count(1)}, decrease {sg.count(-1)}, no change {sg.count(0)} of {len(FSION)}")
print("control FS median whisking/nonwhisking ratio:", np.median([S['a'][n]['whisk_a'] / S['a'][n]['nonw_a'] for n in FS]).round(2))
margin (a), rate (a): nonwhisking 8.65, whisking 9.63; signed-rank p = 0.846; median ratio 0.96 margin (a), rate (b): nonwhisking 9.07, whisking 9.51; signed-rank p = 0.625; median ratio 0.97 margin (b), rate (a): nonwhisking 8.65, whisking 9.63; signed-rank p = 0.846; median ratio 0.96 margin (b), rate (b): nonwhisking 8.99, whisking 9.51; signed-rank p = 0.77; median ratio 0.97
M-SIG (a): increase 3, decrease 6, no change 1 of 10 M-SIG (b): increase 3, decrease 1, no change 6 of 10 control FS median whisking/nonwhisking ratio: 2.71
Result: reproduced. After ION cut the whisking and nonwhisking rates of the 10 FS neurons do not differ (signed-rank p = 0.85 under reading a; 0.63 to 0.85 under all four). The median whisking to nonwhisking ratio is 0.96, against 2.71 in controls. By M-SIG, 3 of 10 neurons increase significantly under either reading, so the activation is absent in most cells.
ion-cut-fs-phase¶
After ION transection phase-locking of L4 FS spikes to whisker movement is reduced but not entirely abolished.
for nb in (8, 16):
rc = np.array([S["a"][n][f"phase{nb}"][0] for n in FS])
ri = np.array([S["a"][n][f"phase{nb}"][0] for n in FSION])
p = stats.ranksums(ri, rc).pvalue
print(f"{nb} bins: r2 control median {np.median(rc):.2f} (n={len(rc)}), ION cut median {np.median(ri):.2f} (n={len(ri)}); rank-sum p = {p:.3g}; "
f"ION-cut neurons with r2 > 0.25: {int((ri > 0.25).sum())}; holds: {p < 0.05 and np.median(ri) < np.median(rc) and (ri > 0.25).any()}")
8 bins: r2 control median 0.82 (n=26), ION cut median 0.48 (n=10); rank-sum p = 0.0134; ION-cut neurons with r2 > 0.25: 9; holds: True 16 bins: r2 control median 0.70 (n=26), ION cut median 0.30 (n=10); rank-sum p = 0.00378; ION-cut neurons with r2 > 0.25: 6; holds: True
Result: reproduced. The r2 of the spike-phase fit falls from a median of 0.82 in control FS neurons to 0.48 after ION cut (8 bins, rank-sum p = 0.013), or from 0.70 to 0.30 (16 bins, p = 0.0038). Nine (8 bins) or six (16 bins) of the 10 ION-cut neurons keep r2 > 0.25.
l4e-example-e1¶
The example L4 spiny stellate cell E No. 1 rests at -76 mV, far from its spike threshold (-45.1 +- 3.7 mV); touch evokes large (14.4 +- 8.2 mV), short-latency (4.7 ms), transient (24.5 ms at half max) depolarizations with 0 to 7 spikes per touch, while whisking without touch causes a smaller sustained depolarization (6.7 +- 4.0 mV) with little increase in spike rate (0.4 spikes/s).
E No. 1 is JY0861 (the cell list's ExampleCells sheet, Figure 2 "# 1: 'JY0861'", and the file's unit description "L4 excitatory neuron: # 1").
v = V["JY0861AAAA"]
print("unit description:", NAME["JY0861AAAA"]["meta"]["unit_description"], "; control trials", v["n_trials"], "; touches", v["n_touch"], "; onsets", v["n_onsets"])
cnt = np.array(v["spk_counts_touch"])
rows = [("resting Vm (a) nonwhisking mean", v["rest_a"], -76, 7.6), ("resting Vm (b) median outside touch", v["rest_b"], -76, 7.6),
("spike threshold, mean over spikes", v["thr_mean"], -45.1, 4.51),
("touch PSP amplitude (peak 0-50 ms of the average)", v["amp50"], 14.4, 1.44),
("touch PSP amplitude (peak 0-25 ms)", v["amp25"], 14.4, 1.44),
("touch PSP latency (ms)", v["lat"], 4.7, 0.47), ("half width (ms)", v["hw"], 24.5, 2.45),
("whisking depolarization (a) onset 100-300 ms minus 0-200 ms before", v["wdep_a"], 6.7, 0.67),
("whisking depolarization (b) whisking minus nonwhisking epochs", v["wdep_b"], 6.7, 0.67),
("spike rate (a) whisking minus nonwhisking", v["whisk_rate"] - v["nonw_rate"], 0.4, 0.04),
("spike rate (b) whisking", v["whisk_rate"], 0.4, 0.04)]
for r in rows:
print(f"{r[0]}: {r[1]:.2f} (paper {r[2]}, tolerance {r[3]}) within: {within(r[1], r[2], r[3])}")
print(f"threshold s.d. over spikes {np.std(ssc7.prep_vm(NAME['JY0861AAAA'])['thr']):.2f} mV; amplitude s.d. over touches {v['amp_sd']:.2f}; whisking change s.d. over onsets {v['wdep_a_sd']:.2f}")
print("spikes per touch 0-50 ms: range", cnt.min(), "to", cnt.max(), "; distribution", np.bincount(cnt).tolist())
# variant: dVm/dt as a forward difference in the threshold search (M-VM does not say which)
c1, thr_f = NAME["JY0861AAAA"], []
spk1 = ssc7.spikes_by_trial(c1)
for i, v_ in enumerate(c1["vm"]):
s_ = spk1[i] - c1["vm_t0"][i]
thr_f.append(ssc7.remove_spikes(v_, s_[(s_ >= 0) & (s_ < len(v_) / ssc7.VM_FS)], forward=True)[1])
thr_f = np.concatenate(thr_f)
print(f"variant, forward difference: threshold mean {thr_f.mean():.2f} mV, s.d. {thr_f.std():.2f} over {len(thr_f)} spikes; within (-45.1 +- 4.51): {within(thr_f.mean(), -45.1, 4.51)}")
unit description: L4 excitatory neuron: # 1 ; control trials 62 ; touches 235 ; onsets 25 resting Vm (a) nonwhisking mean: -76.00 (paper -76, tolerance 7.6) within: True resting Vm (b) median outside touch: -76.34 (paper -76, tolerance 7.6) within: True spike threshold, mean over spikes: -44.87 (paper -45.1, tolerance 4.51) within: True touch PSP amplitude (peak 0-50 ms of the average): 15.50 (paper 14.4, tolerance 1.44) within: True touch PSP amplitude (peak 0-25 ms): 15.50 (paper 14.4, tolerance 1.44) within: True touch PSP latency (ms): 4.80 (paper 4.7, tolerance 0.47) within: True half width (ms): 23.50 (paper 24.5, tolerance 2.45) within: True whisking depolarization (a) onset 100-300 ms minus 0-200 ms before: 6.10 (paper 6.7, tolerance 0.67) within: True whisking depolarization (b) whisking minus nonwhisking epochs: 5.52 (paper 6.7, tolerance 0.67) within: False spike rate (a) whisking minus nonwhisking: 0.41 (paper 0.4, tolerance 0.04) within: True spike rate (b) whisking: 0.55 (paper 0.4, tolerance 0.04) within: False
threshold s.d. over spikes 8.91 mV; amplitude s.d. over touches 11.71; whisking change s.d. over onsets 3.95 spikes per touch 0-50 ms: range 0 to 7 ; distribution [164, 30, 24, 8, 3, 2, 2, 2] variant, forward difference: threshold mean -45.53 mV, s.d. 7.98 over 245 spikes; within (-45.1 +- 4.51): True
Result: reproduced. For JY0861 (E No. 1), all seven values are within tolerance under readings (a). Resting Vm is -76.0 mV, spike threshold -44.87 mV, touch PSP 15.50 mV, latency 4.8 ms, half width 23.5 ms, whisking depolarization 6.10 mV (onsets) and whisking minus nonwhisking rate 0.41 spikes/s. Spikes per touch range from 0 to 7. The readings not chosen differ: 5.52 mV for the epoch-based whisking change and 0.55 spikes/s for the whisking rate. The spread over spikes and touches is larger than the paper's (threshold s.d. 8.91 against 3.7 mV). With dVm/dt as a forward difference in the threshold search (variant), the threshold is -45.53 mV with s.d. 7.98 mV: still within, and the spread still about twice the paper's.
l4e-example-e24-e32¶
In the more depolarized example neurons, whisking causes a small depolarization (1.0 +- 1.4 mV, E No. 24) or a hyperpolarization (-1.8 +- 2.7 mV, E No. 32).
E No. 24 is JY0520 and E No. 32 is JY1008 (ExampleCells sheet; unit descriptions "#24", "#32").
for n, e in (("JY0520AAAC", 1.0), ("JY1008AAAA", -1.8)):
v = V[n]
t = abs(e) * 0.1
print(f"{n} ({NAME[n]['meta']['unit_description']}): paper {e} +- {t:.2f}; resting Vm {v['rest_a']:.1f}; onsets n = {v['n_onsets']}")
for k, lab in (("wdep_a", "(a) onsets, 250 ms rise"), ("wdep_a_rise100", "(a) onsets, 100 ms rise"), ("wdep_b", "(b) epochs")):
print(f" {lab}: {v[k]:.2f}; within {within(v[k], e, t)}; sign as the paper's {np.sign(v[k]) == np.sign(e)}")
JY0520AAAC (L4 excitatory neuron: #24): paper 1.0 +- 0.10; resting Vm -60.9; onsets n = 104 (a) onsets, 250 ms rise: 1.29; within False; sign as the paper's True (a) onsets, 100 ms rise: 1.07; within True; sign as the paper's True (b) epochs: 1.47; within False; sign as the paper's True JY1008AAAA (L4 excitatory neuron: #32): paper -1.8 +- 0.18; resting Vm -55.5; onsets n = 53 (a) onsets, 250 ms rise: -1.65; within True; sign as the paper's True (a) onsets, 100 ms rise: -1.75; within True; sign as the paper's True (b) epochs: -2.04; within False; sign as the paper's True
Result: reproduced. Both neurons have the paper's sign under every reading. With the onset measure and the 100 ms rise of M-EPOCH reading (b), E No. 24 (JY0520) changes by +1.07 mV and E No. 32 (JY1008) by -1.75 mV, both within tolerance (1.0 +- 0.1, -1.8 +- 0.18). With the 250 ms rise, E No. 24 gives +1.29 (outside) and E No. 32 -1.65 (within); the epoch measure gives +1.47 and -2.04, both outside. The criterion accepts one reading. The reading that matches here is not the one that matches l4e-whisking-vm (the 250 ms rise), so no single reading matches both claims.
l4e-resting-vm¶
The resting membrane potential of L4 excitatory neurons spans a large range, -76 to -45 mV (mean -63 +- 8 mV, median -64 mV, n = 37).
exp = [(-76, 7.6), (-45, 4.5), (-63, 6.3), (-64, 6.4)]
for rd in "ab":
x = np.array([V[n][f"rest_{rd}"] for n in L4EWC])
vals = [x.min(), x.max(), x.mean(), np.median(x)]
print(f"reading ({rd}): min {x.min():.1f}, max {x.max():.1f}, {ci(x)}; within: {[within(v_, e, t) for v_, (e, t) in zip(vals, exp)]}")
reading (a): min -76.0, max -44.3, mean -62.7 +- 7.4 s.d., median -63.4, n = 37; within: [True, True, True, True] reading (b): min -76.3, max -44.9, mean -62.4 +- 7.1 s.d., median -62.7, n = 37; within: [True, True, True, True]
Result: reproduced. Over the 37 whole-cell L4 E neurons, resting Vm spans -76.0 to -44.3 mV, with mean -62.7 +- 7.4 and median -63.4 mV (reading a). All four values are within tolerance under both readings.
l4e-touch-psp¶
Touch evokes short-latency depolarizations in every L4 excitatory neuron (latency 4.8 +- 0.8 ms, median 4.7; amplitude 6.0 +- 2.9 mV, median 5.7; n = 37).
lat = np.array([V[n]["lat"] for n in L4EWC])
for win in ("amp50", "amp25"):
amp = np.array([V[n][win] for n in L4EWC])
vals = [np.nanmean(lat), np.nanmedian(lat), amp.mean(), np.median(amp)]
exp = [(4.8, 0.48), (4.7, 0.47), (6.0, 0.6), (5.7, 0.57)]
print(f"peak window {win}: latency {ci(lat)}; amplitude {ci(amp)}; all amplitudes positive: {bool((amp > 0).all())}; within: {[within(v_, e, t) for v_, (e, t) in zip(vals, exp)]}")
print("touches per neuron: median", np.median([V[n]["n_touch"] for n in L4EWC]), "min", min(V[n]["n_touch"] for n in L4EWC))
print("neurons without a latency crossing:", [n for n in L4EWC if not np.isfinite(V[n]['lat'])])
print("latencies (ms):", np.round(sorted(lat[np.isfinite(lat)]), 1).tolist())
lat_cfg = np.array([V_cfg[n]["lat"] for n in L4EWC])
amp_cfg = np.array([V_cfg[n]["amp50"] for n in L4EWC])
vals = [np.nanmean(lat_cfg), np.nanmedian(lat_cfg), np.nanmean(amp_cfg), np.nanmedian(amp_cfg)]
print(f"variant, principal whisker by the configuration (peak 0-50 ms): latency {ci(lat_cfg)}; amplitude {ci(amp_cfg)}; all positive {bool((amp_cfg[np.isfinite(amp_cfg)] > 0).all())}; "
f"within: {[within(v_, e, t) for v_, (e, t) in zip(vals, exp)]}")
# per neuron, sorted by latency: latency (ms) and amplitude (mV, peak 0-50 ms)
LA = pd.DataFrame({"lat": lat, "amp50": [V[n]["amp50"] for n in L4EWC], "touches": [V[n]["n_touch"] for n in L4EWC]}, index=L4EWC).sort_values("lat")
print(LA.round(2).T.to_string())
short, long_ = LA[LA.lat < 2.5], LA[LA.lat > 8]
print(f"latencies below 2.5 ms (the paper's VPM median): {len(short)}, amplitudes {short.amp50.round(2).tolist()}; "
f"latencies above 8 ms: {len(long_)}, amplitudes {long_.amp50.round(2).tolist()}; amplitude median of the others {LA[(LA.lat >= 2.5) & (LA.lat <= 8)].amp50.median():.2f}")
peak window amp50: latency mean 6.03 +- 4.32 s.d., median 5, n = 35; amplitude mean 5.26 +- 3.79 s.d., median 5.4, n = 37; all amplitudes positive: True; within: [False, True, False, True]
peak window amp25: latency mean 6.03 +- 4.32 s.d., median 5, n = 35; amplitude mean 5.21 +- 3.77 s.d., median 5.4, n = 37; all amplitudes positive: True; within: [False, True, False, True]
touches per neuron: median 251.0 min 4
neurons without a latency crossing: ['Exp_2015-09-24_004_0024-0130', 'Exp_2015-09-25_001_0001-0182']
latencies (ms): [0.0, 0.8, 1.1, 1.4, 3.1, 4.0, 4.4, 4.5, 4.7, 4.8, 4.8, 4.8, 4.8, 4.8, 4.9, 4.9, 4.9, 5.0, 5.0, 5.1, 5.1, 5.4, 5.6, 5.7, 5.8, 5.8, 6.1, 6.4, 7.0, 7.1, 9.5, 10.1, 13.0, 18.4, 22.1]
variant, principal whisker by the configuration (peak 0-50 ms): latency mean 6.1 +- 6.18 s.d., median 4.8, n = 32; amplitude mean 4.18 +- 3.48 s.d., median 3.7, n = 37; all positive True; within: [False, True, False, False]
JY1189AAAA Exp_2015-09-30_011_0001-0196 JY0975AAAA JY1154AAAA JY0544AAAB JY1195AAAB JY1046AAAA JY0965AAAA JY1345AAAA JY0861AAAA JY1048AAAA JY1144AAAA JY0989AAAA JY0865AAAA JY0963AAAA JY1035AAAA JY0978AAAA JY0950AAAA JY0520AAAC JY1008AAAA JY0969AAAA JY0947AAAA JY1009AAAA JY0986AAAA JY1418AAAA JY0532AAAA JY0781AAAA JY1211AAAB JY0913AAAA Exp_2015-09-10_002_0001-0046 JY1397AAAA JY1002AAAA Exp_2015-09-05_001_0001-0162 JY1633AAAA JY1036AAAA Exp_2015-09-24_004_0024-0130 Exp_2015-09-25_001_0001-0182
lat 0.0 0.80 1.10 1.40 3.1 4.00 4.40 4.50 4.70 4.8 4.80 4.80 4.80 4.80 4.9 4.90 4.90 5.00 5.00 5.10 5.10 5.40 5.60 5.70 5.800000 5.80 6.10 6.40 7.00 7.10 9.50 10.10 13.0 18.40 22.10 NaN NaN
amp50 5.4 8.04 4.07 8.57 3.7 4.83 7.35 5.72 9.04 15.5 8.37 3.31 7.39 6.96 6.1 3.94 6.87 5.78 6.08 7.54 3.37 4.76 2.42 2.68 16.120001 6.04 7.82 2.32 0.78 9.19 1.12 1.66 0.3 0.17 0.81 0.31 0.3
touches 72.0 121.00 299.00 234.00 381.0 200.00 307.00 175.00 119.00 235.0 181.00 154.00 321.00 641.00 251.0 308.00 359.00 245.00 146.00 427.00 463.00 458.00 307.00 73.00 78.000000 338.00 304.00 173.00 245.00 4.00 295.00 110.00 202.0 280.00 372.00 296.00 382.0
latencies below 2.5 ms (the paper's VPM median): 4, amplitudes [5.400000095367432, 8.039999961853027, 4.070000171661377, 8.569999694824219]; latencies above 8 ms: 5, amplitudes [1.1200000047683716, 1.659999966621399, 0.30000001192092896, 0.17000000178813934, 0.8100000023841858]; amplitude median of the others 6.06
Result: partially reproduced. Every one of the 37 neurons has a positive touch PSP. The amplitude has a mean of 5.26 mV, outside 6.0 +- 0.6, and a median of 5.4 mV, within 5.7 +- 0.57. The latency has a median of 5.0 ms, within 4.7 +- 0.47. Its mean is 6.03 ms (n = 35), outside 4.8 +- 0.48, raised by five latencies above 8 ms (9.5 to 22.1 ms), all in neurons with small PSPs (0.17 to 1.66 mV, against a median of 6.06 mV for the neurons with latencies of 2.5 to 8 ms). Four latencies (0.0, 0.8, 1.1 and 1.4 ms, in JY1189, Exp_2015-09-30_011, JY0975 and JY1154, with PSPs of 4.1 to 8.6 mV) are shorter than the paper's VPM touch latency (median 2.5 ms), so they are unlikely to mark the onset of a thalamocortical PSP; the rule probably crosses on noise before it. Leaving them out would raise the mean further. Two of four values hold under both peak windows. With the principal whisker taken from the whisker configuration, the amplitude falls to 4.18 mV (median 3.7) and only the latency median (4.8 ms) holds.
l4e-whisking-vm¶
Whisking induces only a small depolarization or hyperpolarization in L4 excitatory neurons (1.2 +- 2.1 mV, median 1.2 mV).
for k in ("wdep_a", "wdep_a_rise100", "wdep_b"):
x = np.array([V[n][k] for n in L4EWC])
print(f"{k}: {ci(x)}; range {np.nanmin(x):.2f} to {np.nanmax(x):.2f}; within (1.2+-0.35, 1.2+-0.12): {within(np.nanmean(x), 1.2, 0.35)}, {within(np.nanmedian(x), 1.2, 0.12)}")
wdep_a: mean 0.994 +- 2.03 s.d., median 1.16, n = 37; range -6.49 to 6.10; within (1.2+-0.35, 1.2+-0.12): True, True wdep_a_rise100: mean 0.677 +- 1.67 s.d., median 0.851, n = 37; range -4.47 to 5.43; within (1.2+-0.35, 1.2+-0.12): False, False wdep_b: mean 1.37 +- 1.81 s.d., median 1.35, n = 37; range -4.33 to 5.52; within (1.2+-0.35, 1.2+-0.12): True, False
Result: reproduced. With the onset measure (reading a), whisking changes Vm by 0.994 +- 2.03 mV (median 1.16, range -6.49 to 6.10, n = 37), within 1.2 +- 0.35 and 1.2 +- 0.12. The epoch measure (b) gives 1.37 (median 1.35, outside), and the 100 ms rise rule gives 0.677 (median 0.851, outside).
l4e-distance-threshold¶
Touch moves the membrane potential of L4 excitatory neurons much closer to spike threshold than whisking does (shift 6.1 +- 3.2 mV against 1.1 +- 2.0 mV, P = 1e-7, Wilcoxon signed-rank).
for thr, sfx in (("per-trial line (M-VM)", ""), ("line held outside the trials with spikes (variant)", "_clamp"), ("one mean threshold per neuron (variant)", "_const")):
for rd in "ab":
w = np.array([V[n][f"shift_whisk_{rd}{sfx}"] for n in L4EWC])
t = np.array([V[n][f"shift_touch_{rd}{sfx}"] for n in L4EWC])
ok = np.isfinite(w) & np.isfinite(t)
p = stats.wilcoxon(t[ok], w[ok]).pvalue
print(f"{thr}, spikes {'removed' if rd == 'a' else 'kept'} ({rd}): whisking shift {ci(w)}; touch shift {ci(t)}; signed-rank p = {p:.2g}; "
f"within (1.1+-0.33, 6.1+-0.61): {within(np.nanmean(w), 1.1, 0.33)}, {within(np.nanmean(t), 6.1, 0.61)}")
print(f" medians: whisking {np.nanmedian(w):.2f}, touch {np.nanmedian(t):.2f}; |shift| > 15 mV: {int(np.sum(np.abs(w[ok]) > 15) + np.sum(np.abs(t[ok]) > 15))}")
silent = [n for n in L4EWC if V[n]["n_spikes_thr"] == 0]
print("neurons with no detected spike threshold (the -42 mV default):", len(silent))
TS = pd.DataFrame([dict(name=n, thresholds=V[n]["n_spikes_thr"], slope_mV_per_trial=round(V[n]["thr_slope"], 3), first_trial=V[n]["thr_trial_range"][0],
last_trial=V[n]["thr_trial_range"][1], n_trials=len(NAME[n]["vm"]), shift_whisk_line=round(V[n]["shift_whisk_a"], 2),
shift_whisk_clamp=round(V[n]["shift_whisk_a_clamp"], 2), shift_whisk_const=round(V[n]["shift_whisk_a_const"], 2),
shift_touch_line=round(V[n]["shift_touch_a"], 2), shift_touch_const=round(V[n]["shift_touch_a_const"], 2)) for n in L4EWC])
print("threshold line per neuron (spikes removed):")
print(TS.to_string(index=False))
w = np.array([V_cfg[n]["shift_whisk_a"] for n in L4EWC])
t = np.array([V_cfg[n]["shift_touch_a"] for n in L4EWC])
ok = np.isfinite(w) & np.isfinite(t)
print(f"variant, principal whisker by the configuration (line, removed): whisking {ci(w)}; touch {ci(t)}; signed-rank p = {stats.wilcoxon(t[ok], w[ok]).pvalue:.2g}")
per-trial line (M-VM), spikes removed (a): whisking shift mean -0.236 +- 5.89 s.d., median 0.873, n = 37; touch shift mean 5.74 +- 3.99 s.d., median 5.42, n = 37; signed-rank p = 2.9e-11; within (1.1+-0.33, 6.1+-0.61): False, True
medians: whisking 0.87, touch 5.42; |shift| > 15 mV: 3
per-trial line (M-VM), spikes kept (b): whisking shift mean -0.234 +- 5.89 s.d., median 0.873, n = 37; touch shift mean 5.81 +- 4.03 s.d., median 5.49, n = 37; signed-rank p = 2.9e-11; within (1.1+-0.33, 6.1+-0.61): False, True
medians: whisking 0.87, touch 5.49; |shift| > 15 mV: 3
line held outside the trials with spikes (variant), spikes removed (a): whisking shift mean 0.767 +- 3.34 s.d., median 1.02, n = 37; touch shift mean 5.34 +- 3.15 s.d., median 5.42, n = 37; signed-rank p = 2.9e-11; within (1.1+-0.33, 6.1+-0.61): False, False
medians: whisking 1.02, touch 5.42; |shift| > 15 mV: 1
line held outside the trials with spikes (variant), spikes kept (b): whisking shift mean 0.769 +- 3.34 s.d., median 1.02, n = 37; touch shift mean 5.41 +- 3.21 s.d., median 5.49, n = 37; signed-rank p = 2.9e-11; within (1.1+-0.33, 6.1+-0.61): False, False
medians: whisking 1.02, touch 5.49; |shift| > 15 mV: 1
one mean threshold per neuron (variant), spikes removed (a): whisking shift mean 0.782 +- 3.37 s.d., median 1.02, n = 37; touch shift mean 5.45 +- 3.28 s.d., median 5.13, n = 37; signed-rank p = 2.9e-11; within (1.1+-0.33, 6.1+-0.61): True, False
medians: whisking 1.02, touch 5.13; |shift| > 15 mV: 1
one mean threshold per neuron (variant), spikes kept (b): whisking shift mean 0.784 +- 3.37 s.d., median 1.02, n = 37; touch shift mean 5.52 +- 3.35 s.d., median 5.13, n = 37; signed-rank p = 2.9e-11; within (1.1+-0.33, 6.1+-0.61): True, True
medians: whisking 1.02, touch 5.13; |shift| > 15 mV: 2
neurons with no detected spike threshold (the -42 mV default): 11
threshold line per neuron (spikes removed):
name thresholds slope_mV_per_trial first_trial last_trial n_trials shift_whisk_line shift_whisk_clamp shift_whisk_const shift_touch_line shift_touch_const
JY1008AAAA 196 -0.029 2 109 110 -2.34 -2.34 -2.29 3.56 3.71
JY0963AAAA 0 NaN -1 -1 139 2.02 2.02 2.02 5.85 5.85
JY0865AAAA 35 -0.046 5 98 99 0.74 0.74 1.19 2.90 3.62
JY0978AAAA 1 0.000 1 1 115 2.06 2.06 2.06 8.27 8.27
JY1189AAAA 2 0.000 1 1 32 1.66 1.66 1.66 8.69 8.69
JY1048AAAA 542 0.025 0 105 106 3.42 3.42 3.14 9.13 8.82
JY1002AAAA 888 0.020 0 82 83 -0.83 -0.83 -0.80 1.44 1.17
Exp_2015-09-24_004_0024-0130 90 -0.109 1 85 93 3.49 3.43 1.00 5.93 4.86
JY0861AAAA 245 -0.123 0 61 62 3.65 3.65 5.44 12.26 14.87
JY0520AAAC 1536 -0.050 0 138 139 1.03 1.03 1.41 5.10 4.90
JY1195AAAB 0 NaN -1 -1 106 0.76 0.76 0.76 3.91 3.91
Exp_2015-09-05_001_0001-0162 1198 -0.009 4 144 145 -0.67 -0.67 -0.67 -0.71 -0.76
JY1633AAAA 431 0.099 1 68 69 5.95 5.95 6.16 8.49 8.12
JY0975AAAA 0 NaN -1 -1 108 1.50 1.50 1.50 5.13 5.13
JY0947AAAA 2 2.272 126 129 150 -28.88 2.99 2.54 11.87 7.67
Exp_2015-09-10_002_0001-0046 280 0.206 2 39 40 -15.53 -15.53 -15.58 5.42 5.42
JY0969AAAA 0 NaN -1 -1 140 0.87 0.87 0.87 2.79 2.79
JY1046AAAA 383 0.701 2 127 128 -0.86 -0.66 0.11 -0.02 2.76
JY0989AAAA 2 -5.020 0 2 101 -2.51 2.60 2.62 19.27 6.85
Exp_2015-09-25_001_0001-0182 0 NaN -1 -1 78 0.90 0.90 0.90 3.25 3.25
JY1211AAAB 0 NaN -1 -1 103 1.17 1.17 1.17 3.62 3.62
JY1154AAAA 1 0.000 0 0 69 -0.17 -0.17 -0.17 7.54 7.54
JY1345AAAA 143 0.098 0 19 20 -4.80 -4.80 -4.91 0.91 0.61
JY1144AAAA 0 NaN -1 -1 49 -0.02 -0.02 -0.02 5.69 5.69
JY0913AAAA 1 0.000 74 74 185 0.79 0.79 0.79 1.15 1.15
JY1397AAAA 119 -0.003 0 94 114 0.07 0.07 0.08 1.00 1.04
JY1009AAAA 1520 0.013 0 94 95 1.42 1.42 1.42 2.99 2.93
JY0781AAAA 53 -0.049 1 82 103 0.44 0.40 0.34 7.96 9.34
JY1035AAAA 2 0.000 79 79 87 1.21 1.21 1.21 4.55 4.55
JY1418AAAA 93 0.268 1 15 16 0.44 0.46 0.67 11.04 11.84
JY0986AAAA 0 NaN -1 -1 23 3.03 3.03 3.03 6.75 6.75
JY0532AAAA 1 0.000 20 20 106 1.02 1.02 1.02 6.27 6.27
JY1036AAAA 0 NaN -1 -1 75 0.63 0.63 0.63 2.75 2.75
Exp_2015-09-30_011_0001-0196 1 0.000 20 20 40 3.63 3.63 3.63 9.30 9.30
JY0544AAAB 2 0.000 2 2 103 0.43 0.43 0.43 3.75 3.75
JY0965AAAA 0 NaN -1 -1 70 3.87 3.87 3.87 8.23 8.23
JY0950AAAA 0 NaN -1 -1 111 1.70 1.70 1.70 6.56 6.56
variant, principal whisker by the configuration (line, removed): whisking mean -0.033 +- 5.69 s.d., median 1.02, n = 37; touch mean 3.76 +- 8.75 s.d., median 5.1, n = 37; signed-rank p = 6.1e-06
Result: partially reproduced. Touch moves Vm closer to threshold than whisking does: medians 5.42 against 0.87 mV, signed-rank p = 2.9e-11. With the per-trial threshold line of M-VM, the touch mean (5.74 mV, spikes removed; 5.81 kept) is within 6.1 +- 0.61, but the whisking mean (-0.236 +- 5.89) is outside 1.1 +- 0.33. Three shifts exceed 15 mV. The largest whisking shift, -28.9 mV in JY0947, comes from a line through two thresholds in trials 126 and 129 extrapolated over 150 trials. With the line held at its end values outside the trials with spikes (variant), the means are 0.767 and 5.34 mV, both outside. Only with one mean threshold per neuron, which is not the paper's method, are both means within tolerance (0.784 and 5.52 mV, spikes kept). 11 neurons have no detected threshold and take the -42 mV default. The principal-whisker variant gives the same test result (p = 6.1e-6).
l4e-reversal-potential¶
The effective reversal potential of the touch response in L4 excitatory neurons is more depolarized than resting Vm, while that of the whisking response is close to resting Vm and more hyperpolarized than that of touch.
def reversal(pre, post):
if len(pre) < 5:
return np.nan, np.nan
sl, ic = np.polyfit(pre, post - pre, 1)
return (-ic / sl if sl < 0 else np.nan), sl
rv = []
for n in L4EWC:
v = V[n]
et, st_ = reversal(v.get("touch_pre", np.array([])), v.get("touch_post", np.array([])))
oc = v["onset_pre_post"]
ew, sw = reversal(oc[:, 0], oc[:, 1]) if len(oc) else (np.nan, np.nan)
rv.append(dict(name=n, rest=v["rest_a"], e_touch=et, slope_touch=st_, e_whisk=ew, slope_whisk=sw))
rv = pd.DataFrame(rv)
print("non-negative slopes (no crossing), touch:", int((rv.slope_touch >= 0).sum()), ", whisking:", int((rv.slope_whisk >= 0).sum()))
ok = rv.e_touch.notna() & rv.e_whisk.notna()
p = stats.wilcoxon(rv.e_touch[ok], rv.e_whisk[ok]).pvalue
print(f"(a) per neuron, n = {ok.sum()}: touch reversal median {rv.e_touch[ok].median():.1f} mV, whisking reversal median {rv.e_whisk[ok].median():.1f}, signed-rank p = {p:.2g}")
print(f" touch reversal above resting Vm in {int((rv.e_touch > rv.rest).sum())} of {int(rv.e_touch.notna().sum())}; median whisking reversal minus median resting Vm "
f"{rv.e_whisk.median() - rv.rest.median():.1f} mV (rest median {rv.rest.median():.1f})")
# (b) pooled over neurons
tp = np.concatenate([V[n]["touch_pre"] for n in L4EWC if "touch_pre" in V[n]])
tq = np.concatenate([V[n]["touch_post"] for n in L4EWC if "touch_post" in V[n]])
oc = np.vstack([V[n]["onset_pre_post"] for n in L4EWC if len(V[n]["onset_pre_post"])])
print(f"(b) pooled: touch reversal {reversal(tp, tq)[0]:.1f} mV ({len(tp)} touches), whisking reversal {reversal(oc[:, 0], oc[:, 1])[0]:.1f} mV ({len(oc)} onsets)")
print(rv.round(2).to_string(index=False))
non-negative slopes (no crossing), touch: 1 , whisking: 0
(a) per neuron, n = 35: touch reversal median -49.8 mV, whisking reversal median -58.7, signed-rank p = 2.6e-05
touch reversal above resting Vm in 34 of 35; median whisking reversal minus median resting Vm 4.9 mV (rest median -63.4)
(b) pooled: touch reversal -45.4 mV (9556 touches), whisking reversal -57.6 mV (2456 onsets)
name rest e_touch slope_touch e_whisk slope_whisk
JY1008AAAA -55.49 -45.86 -0.60 -57.33 -0.77
JY0963AAAA -68.21 -51.61 -0.45 -47.50 -0.11
JY0865AAAA -58.96 -49.78 -0.74 -55.49 -0.94
JY0978AAAA -72.15 -12.17 -0.12 -58.75 -0.12
JY1189AAAA -68.39 -49.86 -0.36 -65.84 -0.31
JY1048AAAA -57.74 -47.61 -1.03 -53.70 -0.74
JY1002AAAA -44.34 -42.57 -0.65 -45.19 -0.44
Exp_2015-09-24_004_0024-0130 -59.26 -54.72 -0.70 -55.86 -0.33
JY0861AAAA -76.00 -36.70 -0.42 -67.83 -0.79
JY0520AAAC -60.87 -34.87 -0.25 -46.41 -0.09
JY1195AAAB -67.05 -5.73 -0.08 -67.46 -0.66
Exp_2015-09-05_001_0001-0162 -54.24 -55.99 -0.38 -57.25 -0.20
JY1633AAAA -58.66 -25.29 -0.01 -32.28 -0.15
JY0975AAAA -64.94 -53.10 -0.48 -59.94 -0.27
JY0947AAAA -67.22 -49.58 -0.38 139.70 -0.01
Exp_2015-09-10_002_0001-0046 -53.25 NaN NaN NaN NaN
JY0969AAAA -62.37 -54.64 -0.47 -55.36 -0.18
JY1046AAAA -56.93 -37.43 -0.38 -57.02 -0.78
JY0989AAAA -65.04 -51.24 -0.68 -59.73 -0.51
Exp_2015-09-25_001_0001-0182 -63.90 -61.16 -0.37 -58.87 -0.10
JY1211AAAB -63.37 -25.97 -0.07 -63.03 -0.83
JY1154AAAA -69.14 -44.61 -0.38 -62.96 -0.17
JY1345AAAA -55.49 -41.48 -0.40 -62.34 -0.92
JY1144AAAA -75.52 -60.12 -0.33 -63.15 -0.18
JY0913AAAA -64.59 -61.25 -0.37 -58.69 -0.20
JY1397AAAA -51.19 -49.13 -0.71 -50.31 -0.39
JY1009AAAA -51.94 -45.94 -0.76 -48.57 -0.58
JY0781AAAA -63.05 -52.73 -0.88 -60.47 -0.48
JY1035AAAA -56.26 -21.29 -0.11 -20.50 -0.03
JY1418AAAA -56.23 NaN 0.17 -58.25 -0.60
JY0986AAAA -73.50 -52.37 -0.16 -69.37 -0.91
JY0532AAAA -64.80 -51.08 -0.46 -61.52 -0.41
JY1036AAAA -61.39 -54.93 -0.21 -52.31 -0.08
Exp_2015-09-30_011_0001-0196 -71.76 -59.47 -1.09 -62.70 -0.35
JY0544AAAB -65.60 -60.49 -0.78 -62.53 -0.16
JY0965AAAA -72.65 -35.51 -0.17 -51.75 -0.11
JY0950AAAA -68.11 -54.77 -0.57 -62.76 -0.34
Result: reproduced. Per neuron (n = 35), the touch reversal potential (median -49.8 mV) exceeds the whisking reversal (median -58.7 mV), signed-rank p = 2.6e-5. The touch reversal lies above resting Vm in 34 of 35 neurons. The median whisking reversal lies 4.9 mV above the median resting Vm (-63.4 mV), just inside the 5 mV margin the criterion fixes. The pooled fit gives the same picture (touch -45.4, whisking -57.6 mV). The margin is close, so this part could change with small differences in the onset rules.
l4e-hf-fluctuations¶
Whisking enhances membrane potential fluctuations of L4 excitatory neurons at high frequencies (above 10 Hz).
def band_power(spec, lo, hi):
if spec is None:
return np.nan
f, m, l_, h_ = spec
k = (f >= lo) & (f <= hi)
return m[k].mean()
def above_ci(v, lo, hi):
"""Fraction of the band where whisking power lies above the nonwhisking upper 95% bound."""
if v["spec_nonw"] is None or v["spec_whisk"] is None:
return np.nan
f, mn, ln, hn = v["spec_nonw"]
_, mw, lw, hw = v["spec_whisk"]
k = (f >= lo) & (f <= hi)
return np.mean(mw[k] > hn[k])
def spectra_test(group, label):
out = {}
for rd, (lo, hi) in (("a", (10, 100)), ("b", (10, 500))):
pn = np.array([band_power(V[n]["spec_nonw"], lo, hi) for n in group])
pw_ = np.array([band_power(V[n]["spec_whisk"], lo, hi) for n in group])
ok = np.isfinite(pn) & np.isfinite(pw_)
p = stats.wilcoxon(pw_[ok], pn[ok]).pvalue
frac = np.array([above_ci(V[n], lo, hi) for n in group])
out[rd] = (p, np.median(pw_[ok] / pn[ok]), ok.sum(), frac)
print(f"{label}, band ({rd}) {lo}-{hi} Hz: n = {ok.sum()}, whisking/nonwhisking power median ratio {np.median(pw_[ok] / pn[ok]):.2f}, "
f"higher in {int(np.sum(pw_[ok] > pn[ok]))}; signed-rank p = {p:.2g}; neurons with whisking above the nonwhisking 95% bound over most of the band: {int(np.nansum(frac > 0.5))}")
return out
segs = pd.DataFrame([dict(name=n, nonw=V[n]["n_seg"][0], whisk=V[n]["n_seg"][1]) for n in L4EWC])
print("500 ms segments per neuron: nonwhisking median", segs.nonw.median(), "; whisking median", segs.whisk.median(), "; neurons with no whisking segment:", int((segs.whisk == 0).sum()))
hf_l4e = spectra_test(L4EWC, "L4E")
500 ms segments per neuron: nonwhisking median 92.0 ; whisking median 21.0 ; neurons with no whisking segment: 1 L4E, band (a) 10-100 Hz: n = 36, whisking/nonwhisking power median ratio 1.17, higher in 23; signed-rank p = 0.046; neurons with whisking above the nonwhisking 95% bound over most of the band: 24 L4E, band (b) 10-500 Hz: n = 36, whisking/nonwhisking power median ratio 1.18, higher in 24; signed-rank p = 0.03; neurons with whisking above the nonwhisking 95% bound over most of the band: 30
Result: reproduced. Over the 36 neurons with both kinds of segment, whisking power exceeds nonwhisking power by a signed-rank test in band (a), 10 to 100 Hz (median ratio 1.17, p = 0.046), and in band (b), 10 to 500 Hz (ratio 1.18, p = 0.030). Whisking power lies above the nonwhisking 95% bound over most of the band in 24 (a) and 30 (b) neurons. The p-value in band (a) is close to 0.05.
fs-touch-vm¶
Touch depolarizes L4 FS interneurons (7.0 +- 5.2 mV, median 6.7 mV, n = 7) with short onset latency (4.0 +- 0.6 ms, median 4.2 ms).
lat = np.array([V[n]["lat"] for n in FSWC])
exp = [(7.0, 1.97), (6.7, 0.67), (4.0, 0.4), (4.2, 0.42)]
for win in ("amp50", "amp25"):
amp = np.array([V[n][win] for n in FSWC])
vals = [amp.mean(), np.median(amp), np.nanmean(lat), np.nanmedian(lat)]
print(f"{win}: amplitude {ci(amp)}; latency {ci(lat)}; within: {[within(v_, e, t) for v_, (e, t) in zip(vals, exp)]}")
print("per neuron:", {n: (round(V[n]['amp50'], 2), round(V[n]['lat'], 1), V[n]['n_touch']) for n in FSWC})
lat_all = np.array([V_all[n]["lat"] for n in FSWC])
amp_all = np.array([V_all[n]["amp50"] for n in FSWC])
vals = [amp_all.mean(), np.median(amp_all), np.nanmean(lat_all), np.nanmedian(lat_all)]
print(f"variant, every control trial (JY1139's trials far from its usual Vm kept): amplitude {ci(amp_all)}; latency {ci(lat_all)}; within: {[within(v_, e, t) for v_, (e, t) in zip(vals, exp)]}")
lat_cfg = np.array([V_cfg[n]["lat"] for n in FSWC])
amp_cfg = np.array([V_cfg[n]["amp50"] for n in FSWC])
vals = [np.nanmean(amp_cfg), np.nanmedian(amp_cfg), np.nanmean(lat_cfg), np.nanmedian(lat_cfg)]
print(f"variant, principal whisker by the configuration: amplitude {ci(amp_cfg)}; latency {ci(lat_cfg)}; within: {[within(v_, e, t) for v_, (e, t) in zip(vals, exp)]}; "
f"neurons whose series differs: {PWT[PWT["name"].isin(FSWC) & (PWT.series_code != PWT.series_config)]["name"].tolist()}")
amp50: amplitude mean 6.8 +- 1.93 s.d., median 6.97, n = 7; latency mean 3.67 +- 1.18 s.d., median 3.9, n = 7; within: [True, True, True, True]
amp25: amplitude mean 6.8 +- 1.93 s.d., median 6.97, n = 7; latency mean 3.67 +- 1.18 s.d., median 3.9, n = 7; within: [True, True, True, True]
per neuron: {'JY1139AAAA': (np.float32(7.62), np.float64(3.9), 103), 'Exp_2015-09-09_005_0001-0154': (np.float32(6.97), np.float64(1.4), 11), 'JY1171AAAI': (np.float32(5.1), np.float64(5.1), 223), 'JY1045AAAA': (np.float32(5.45), np.float64(3.1), 184), 'JY0995AAAA': (np.float32(9.99), np.float64(4.4), 126), 'JY1041AAAA': (np.float32(8.0), np.float64(4.1), 469), 'Exp_2015-09-15_001_0001-0110': (np.float32(4.49), np.float64(3.7), 85)}
variant, every control trial (JY1139's trials far from its usual Vm kept): amplitude mean 6.74 +- 1.91 s.d., median 6.97, n = 7; latency mean 3.69 +- 1.18 s.d., median 4, n = 7; within: [True, True, True, True]
variant, principal whisker by the configuration: amplitude mean 6.23 +- 2.89 s.d., median 6.97, n = 7; latency mean 7.24 +- 10.1 s.d., median 3.9, n = 7; within: [True, True, False, True]; neurons whose series differs: ['JY1171AAAI']
Result: reproduced. The seven whole-cell FS neurons depolarize by 6.8 +- 1.93 mV after touch (median 6.97), with latency 3.67 +- 1.18 ms (median 3.9). All four values are within tolerance. Keeping JY1139's drifting trials (variant) gives 6.74, 6.97, 3.69 and 4 ms, also all within. The outcome rests on taking series 1 as the principal whisker (an assumption, as for fs-touch-spikes): with the series from the whisker configuration, which changes only JY1171, the latency mean is 7.24 ms (outside) and the other three values are within (6.23 mV, median 6.97 mV, latency median 3.9 ms), which would be partially reproduced. The FS spike responses support series 1 (data check above).
fs-whisking-vm¶
After whisking onset the membrane potential of L4 FS neurons depolarizes toward spike threshold (2.7 +- 2.1 mV, median 2.4 mV, n = 7).
for lab, VV in (("trials far from the usual Vm left out", V), ("every control trial (variant)", V_all)):
print(lab + ":")
for k in ("wdep_a", "wdep_a_rise100", "wdep_b", "shift_whisk_a", "shift_whisk_a_clamp", "shift_whisk_a_const"):
x = np.array([VV[n][k] for n in FSWC])
print(f" {k}: {ci(x)}; within (2.7+-0.79, 2.4+-0.24): {within(np.nanmean(x), 2.7, 0.79)}, {within(np.nanmedian(x), 2.4, 0.24)}")
print("per neuron, wdep_a:", {n: round(V[n]["wdep_a"], 2) for n in FSWC})
trials far from the usual Vm left out:
wdep_a: mean 2.02 +- 2.23 s.d., median 1.52, n = 7; within (2.7+-0.79, 2.4+-0.24): True, False
wdep_a_rise100: mean 1.54 +- 1.56 s.d., median 0.867, n = 7; within (2.7+-0.79, 2.4+-0.24): False, False
wdep_b: mean 2.43 +- 1.6 s.d., median 2, n = 7; within (2.7+-0.79, 2.4+-0.24): True, False
shift_whisk_a: mean 0.976 +- 2.15 s.d., median 1.24, n = 7; within (2.7+-0.79, 2.4+-0.24): False, False
shift_whisk_a_clamp: mean 0.976 +- 2.15 s.d., median 1.24, n = 7; within (2.7+-0.79, 2.4+-0.24): False, False
shift_whisk_a_const: mean 1.29 +- 2.31 s.d., median 1.18, n = 7; within (2.7+-0.79, 2.4+-0.24): False, False
every control trial (variant):
wdep_a: mean 2 +- 2.24 s.d., median 1.49, n = 7; within (2.7+-0.79, 2.4+-0.24): True, False
wdep_a_rise100: mean 1.45 +- 1.62 s.d., median 0.679, n = 7; within (2.7+-0.79, 2.4+-0.24): False, False
wdep_b: mean 2.36 +- 1.65 s.d., median 2, n = 7; within (2.7+-0.79, 2.4+-0.24): True, False
shift_whisk_a: mean 0.547 +- 2.34 s.d., median 0.952, n = 7; within (2.7+-0.79, 2.4+-0.24): False, False
shift_whisk_a_clamp: mean 0.547 +- 2.34 s.d., median 0.952, n = 7; within (2.7+-0.79, 2.4+-0.24): False, False
shift_whisk_a_const: mean 0.54 +- 2.46 s.d., median 0.996, n = 7; within (2.7+-0.79, 2.4+-0.24): False, False
per neuron, wdep_a: {'JY1139AAAA': 1.52, 'Exp_2015-09-09_005_0001-0154': 0.02, 'JY1171AAAI': 2.1, 'JY1045AAAA': 0.35, 'JY0995AAAA': 6.76, 'JY1041AAAA': 1.49, 'Exp_2015-09-15_001_0001-0110': 1.9}
Result: partially reproduced. FS neurons depolarize after whisking onset. The onset measure gives a mean of 2.02 mV, within 2.7 +- 0.79, and a median of 1.52, outside 2.4 +- 0.24. The epoch measure gives 2.43, median 2.0. The 100 ms rise gives 1.54 (median 0.867). The distance-to-threshold reading (c) gives 0.976 mV (1.29 with one threshold per neuron). Under no reading is the median within tolerance, with or without JY1139's drifting trials (onsets 2.0 and 1.49 with them).
fs-hf-fluctuations¶
In L4 FS interneurons, membrane potential fluctuations at high frequencies (above 10 Hz) increase with whisking in some cells but not in others (n = 7 whole-cell).
print("500 ms segments (nonwhisking, whisking):", {n: V[n]["n_seg"] for n in FSWC})
hf_fs = spectra_test(FSWC, "FS")
for rd in "ab":
frac = hf_fs[rd][3]
k = int(np.nansum(frac > 0.5))
print(f"band ({rd}): fraction of band above the bound per neuron {np.round(frac, 2).tolist()}; neurons showing the increase {k}; 1 to 6 of 7: {1 <= k <= 6}")
# variant: every control trial, JY1139's trials far from its usual Vm kept
V_keep = V
V = {**V, **V_all}
print("variant, every control trial:")
hf_fs_all = spectra_test(FSWC, "FS")
V = V_keep
# Chance level of the per-neuron rule: nonwhisking segments split at random into a pseudo-whisking
# set (as many segments as the neuron has whisking segments) and the rest; how often does the
# pseudo-whisking power lie above the bound over most of the band?
rng = np.random.default_rng(9)
chance = {"a": [], "b": []}
for n in FSWC:
c = NAME[n]
P_ = ssc7.prep_vm(c)
ep_ = ssc7.cell_epochs(c, ssc7.control_trials(c) & ssc7.stable_trials(c))
sn = ssc7.segments_500ms(c, P_["vm"], ep_, "nonw")
k = V[n]["n_seg"][1]
if k == 0 or len(sn) < k + 3:
for rd in "ab":
chance[rd].append(np.nan)
continue
hits = {"a": 0, "b": 0}
for _ in range(200):
perm = rng.permutation(len(sn))
fake = dict(spec_whisk=ssc7.multitaper(sn[perm[:k]]), spec_nonw=ssc7.multitaper(sn[perm[k:]]))
for rd, (lo, hi) in (("a", (10, 100)), ("b", (10, 500))):
hits[rd] += above_ci(fake, lo, hi) > 0.5
for rd in "ab":
chance[rd].append(hits[rd] / 200)
for rd in "ab":
print(f"band ({rd}): chance that a neuron shows the increase with no whisking effect, per neuron {np.round(chance[rd], 2).tolist()}; expected count {np.nansum(chance[rd]):.1f} of 7")
500 ms segments (nonwhisking, whisking): {'JY1139AAAA': (114, 3), 'Exp_2015-09-09_005_0001-0154': (41, 1), 'JY1171AAAI': (53, 18), 'JY1045AAAA': (101, 7), 'JY0995AAAA': (99, 3), 'JY1041AAAA': (300, 19), 'Exp_2015-09-15_001_0001-0110': (84, 2)}
FS, band (a) 10-100 Hz: n = 7, whisking/nonwhisking power median ratio 1.21, higher in 6; signed-rank p = 0.047; neurons with whisking above the nonwhisking 95% bound over most of the band: 6
FS, band (b) 10-500 Hz: n = 7, whisking/nonwhisking power median ratio 1.20, higher in 6; signed-rank p = 0.031; neurons with whisking above the nonwhisking 95% bound over most of the band: 6 band (a): fraction of band above the bound per neuron [0.59, 0.7, 0.87, 0.67, 0.83, 0.89, 0.35]; neurons showing the increase 6; 1 to 6 of 7: True band (b): fraction of band above the bound per neuron [0.6, 0.74, 0.9, 0.61, 0.81, 0.96, 0.09]; neurons showing the increase 6; 1 to 6 of 7: True variant, every control trial: FS, band (a) 10-100 Hz: n = 7, whisking/nonwhisking power median ratio 1.21, higher in 6; signed-rank p = 0.047; neurons with whisking above the nonwhisking 95% bound over most of the band: 5 FS, band (b) 10-500 Hz: n = 7, whisking/nonwhisking power median ratio 1.20, higher in 6; signed-rank p = 0.047; neurons with whisking above the nonwhisking 95% bound over most of the band: 6
band (a): chance that a neuron shows the increase with no whisking effect, per neuron [0.22, 0.18, 0.04, 0.04, 0.18, 0.07, 0.22]; expected count 1.0 of 7 band (b): chance that a neuron shows the increase with no whisking effect, per neuron [0.16, 0.13, 0.02, 0.1, 0.16, 0.1, 0.06]; expected count 0.7 of 7
Result: reproduced. Whisking power lies above the nonwhisking 95% jackknife bound over most of the band in 6 of 7 FS neurons, for 10 to 100 Hz and for 10 to 500 Hz (5 and 6 with JY1139's drifting trials kept). Both counts are between 1 and 6, so some cells increase and one does not. The test is weak: four neurons have 1 to 3 whisking segments. With nonwhisking segments split at random into pseudo-whisking and nonwhisking sets, a neuron passes the rule by chance with probability 0.02 to 0.22, about 1.0 (a) and 0.7 (b) of the 7 neurons, so 6 of 7 is well above chance.
ion-cut-l4e-touch¶
After ION transection L4 excitatory neurons do not depolarize after touch.
amp = np.array([V[n]["amp50"] for n in L4EION])
print("touches per ION-cut neuron:", [V[n]["n_touch"] for n in L4EION])
ok = np.isfinite(amp)
p = stats.wilcoxon(amp[ok]).pvalue
print(f"touch PSP amplitude (peak 0-50 ms minus 0-5 ms before), ION cut: {ci(amp)}; signed-rank against zero p = {p:.3g}; control L4E mean {np.mean([V[n]['amp50'] for n in L4EWC]):.2f} mV")
amp25 = np.array([V[n]["amp25"] for n in L4EION])
print(f"variant, peak 0-25 ms: {ci(amp25)}")
# reference: the same peak measure on random times (no touch), which is positive by construction
rng = np.random.default_rng(3)
null = []
for n in L4EION:
c = NAME[n]
P = ssc7.prep_vm(c)
tr = np.flatnonzero(ssc7.control_trials(c))
tt = np.column_stack([rng.choice(tr, 200), rng.uniform(0.5, 4.5, 200)])
X = ssc7.touch_vm(c, P["vm"], tt)
null.append(ssc7.psp_amplitude(X.mean(0))[0] if len(X) else np.nan)
print(f"same measure at 200 random times per neuron: {ci(null)}; touch minus random-time amplitude, signed-rank p = {stats.wilcoxon(amp[ok] - np.array(null)[ok]).pvalue:.3g}")
touches per ION-cut neuron: [31, 53, 138, 159, 116, 40, 0, 80, 48] touch PSP amplitude (peak 0-50 ms minus 0-5 ms before), ION cut: mean 0.321 +- 0.222 s.d., median 0.308, n = 8; signed-rank against zero p = 0.00781; control L4E mean 5.26 mV variant, peak 0-25 ms: mean 0.281 +- 0.241 s.d., median 0.254, n = 8 same measure at 200 random times per neuron: mean 0.208 +- 0.125 s.d., median 0.231, n = 9; touch minus random-time amplitude, signed-rank p = 0.148
Result: not reproduced. The criterion's test finds an effect. The touch PSP amplitude of the 8 ION-cut neurons with touches is 0.321 +- 0.222 mV, positive in all, and the signed-rank test against zero gives p = 0.0078. The amplitude is a peak minus a baseline, so it is positive even without a response. At random times the same measure gives 0.208 mV, and touch does not differ from it (p = 0.148, variant). The amplitude is 0.32 mV against 5.26 mV in controls.
ion-cut-l4e-whisking¶
After ION transection whisking-related depolarization of L4 excitatory neurons is reduced (0.62 +- 0.50 mV, n = 9, against 1.54 +- 0.79 mV in 15 control neurons with matched resting potential; P = 0.005, Wilcoxon rank-sum).
rest_ion = np.array([V[n]["rest_a"] for n in L4EION])
rest_ctl = pd.Series({n: V[n]["rest_a"] for n in L4EWC})
match_a = rest_ctl[(rest_ctl >= rest_ion.min()) & (rest_ctl <= rest_ion.max())].index.tolist()
match_b = (rest_ctl - rest_ion.mean()).abs().sort_values().index[:15].tolist()
print(f"ION-cut resting Vm range {rest_ion.min():.1f} to {rest_ion.max():.1f}; controls in range (a): {len(match_a)} (paper 15)")
MATCH = {"a": match_a, "b": match_b}
for k in ("wdep_a", "wdep_b"):
xi = np.array([V[n][k] for n in L4EION])
for rd, grp in MATCH.items():
xc = np.array([V[n][k] for n in grp])
p = stats.ranksums(xi, xc).pvalue
print(f"{k}, controls ({rd}): ION {xi.mean():.3f} +- {xi.std(ddof=1):.2f} (n={len(xi)}), control {xc.mean():.3f} +- {xc.std(ddof=1):.2f} (n={len(xc)}); rank-sum p = {p:.3g}; "
f"within (0.62+-0.17, 1.54+-0.2): {within(xi.mean(), 0.62, 0.17)}, {within(xc.mean(), 1.54, 0.2)}; holds: {within(xi.mean(), 0.62, 0.17) and within(xc.mean(), 1.54, 0.2) and p < 0.05 and xi.mean() < xc.mean()}")
ION-cut resting Vm range -72.9 to -62.7; controls in range (a): 17 (paper 15) wdep_a, controls (a): ION 0.582 +- 0.35 (n=9), control 1.337 +- 0.98 (n=17); rank-sum p = 0.0333; within (0.62+-0.17, 1.54+-0.2): True, False; holds: False wdep_a, controls (b): ION 0.582 +- 0.35 (n=9), control 1.282 +- 1.01 (n=15); rank-sum p = 0.0603; within (0.62+-0.17, 1.54+-0.2): True, False; holds: False wdep_b, controls (a): ION 0.610 +- 0.84 (n=9), control 1.825 +- 1.06 (n=17); rank-sum p = 0.00466; within (0.62+-0.17, 1.54+-0.2): True, False; holds: False wdep_b, controls (b): ION 0.610 +- 0.84 (n=9), control 1.800 +- 1.05 (n=15); rank-sum p = 0.00667; within (0.62+-0.17, 1.54+-0.2): True, False; holds: False
Result: partially reproduced. Whisking depolarization is lower after ION cut under every reading, but the control mean is just outside its tolerance under all of them. With the onset measure and controls whose resting Vm lies within the ION-cut range (reading a, 17 neurons against the paper's 15), it is 0.582 +- 0.35 mV after ION cut against 1.337 +- 0.98 mV in controls, rank-sum p = 0.033: the control mean lies 0.003 mV below the bound of 1.54 - 0.2 = 1.34. With the 15 nearest controls (b) the control mean is 1.282 and p = 0.060. With the epoch measure the control mean is 1.80 to 1.83 (p = 0.0047 and 0.0067). The effect is present and significant under three of the four readings; only the control mean misses, by a margin smaller than any rounding in the paper.
ion-cut-l4e-phase¶
After ION transection phase-locking of L4 excitatory Vm to whisker movement is abolished (coupling 0.12 +- 0.04 mV against 0.38 +- 0.31 mV in controls, P = 0.005).
for nb in (8, 16):
ci_ = np.array([V[n][f"vphase{nb}"][1] for n in L4EION])
for rd, grp, tol in (("a", match_a, 0.08), ("a'", match_b, 0.08), ("b", L4EWC, 0.051)):
cc = np.array([V[n][f"vphase{nb}"][1] for n in grp])
p = stats.ranksums(ci_, cc).pvalue
print(f"{nb} bins, controls ({rd}, n={len(cc)}): ION {ci_.mean():.3f} +- {ci_.std(ddof=1):.3f}, control {cc.mean():.3f} +- {cc.std(ddof=1):.3f} mV; rank-sum p = {p:.3g}; "
f"within (0.12+-0.013, 0.38+-{tol}): {within(ci_.mean(), 0.12, 0.013)}, {within(cc.mean(), 0.38, tol)}")
8 bins, controls (a, n=17): ION 0.111 +- 0.052, control 0.304 +- 0.239 mV; rank-sum p = 0.0333; within (0.12+-0.013, 0.38+-0.08): True, True 8 bins, controls (a', n=15): ION 0.111 +- 0.052, control 0.317 +- 0.243 mV; rank-sum p = 0.0185; within (0.12+-0.013, 0.38+-0.08): True, True 8 bins, controls (b, n=37): ION 0.111 +- 0.052, control 0.454 +- 0.455 mV; rank-sum p = 0.00694; within (0.12+-0.013, 0.38+-0.051): True, False 16 bins, controls (a, n=17): ION 0.114 +- 0.051, control 0.311 +- 0.243 mV; rank-sum p = 0.0253; within (0.12+-0.013, 0.38+-0.08): True, True 16 bins, controls (a', n=15): ION 0.114 +- 0.051, control 0.325 +- 0.248 mV; rank-sum p = 0.0133; within (0.12+-0.013, 0.38+-0.08): True, True 16 bins, controls (b, n=37): ION 0.114 +- 0.051, control 0.464 +- 0.463 mV; rank-sum p = 0.00587; within (0.12+-0.013, 0.38+-0.051): True, False
Result: reproduced. The Vm phase-coupling strength is 0.111 +- 0.052 mV after ION cut against 0.304 +- 0.239 mV in the range-matched controls (8 bins, rank-sum p = 0.033). Both are within tolerance (0.12 +- 0.013, 0.38 +- 0.08). The 15 nearest controls and 16 bins also hold. Against all 37 controls (reading b) the control mean is 0.454, outside 0.38 +- 0.051, with p = 0.0069.
ion-cut-l4e-spectra¶
After ION transection the Vm fluctuations of L4 excitatory neurons do not differ between nonwhisking and whisking epochs.
print("500 ms segments (nonwhisking, whisking):", {n: V[n]["n_seg"] for n in L4EION})
hf_ion = spectra_test(L4EION, "ION-cut L4E")
500 ms segments (nonwhisking, whisking): {'Exp_2015-11-25_008_0002-0050': (76, 0), 'Exp_2015-12-30_010_0001-0067': (130, 4), 'Exp_2015-11-27_002_0001-0082': (48, 18), 'Exp_2015-11-27_008_0001-0087': (44, 33), 'Exp_2015-11-25_010_0001-0131': (214, 12), 'Exp_2015-11-25_001_0001-0027': (35, 4), 'Exp_2015-11-25_006_0001-0066': (222, 0), 'Exp_2015-11-27_009_0001-0069': (19, 32), 'Exp_2015-11-27_003_0001-0033': (27, 1)}
ION-cut L4E, band (a) 10-100 Hz: n = 7, whisking/nonwhisking power median ratio 0.97, higher in 2; signed-rank p = 0.47; neurons with whisking above the nonwhisking 95% bound over most of the band: 1
ION-cut L4E, band (b) 10-500 Hz: n = 7, whisking/nonwhisking power median ratio 0.96, higher in 2; signed-rank p = 0.47; neurons with whisking above the nonwhisking 95% bound over most of the band: 2
Result: reproduced. Over the 7 ION-cut neurons with both kinds of segment, whisking and nonwhisking power do not differ (10 to 100 Hz: median ratio 0.97, p = 0.47). The 10 to 500 Hz variant gives the same (ratio 0.96, p = 0.47). Two neurons have no whisking segment.
Photostimulation trials¶
Each file stores one photostimulus series per light site (for example "VPM", "VPM and vS1", "vS1" or "vM1", with its wavelength), sampled with the ephys. A trial's light is read from these series: its sites, its power (the peak of the series, mW) and its onset and offset. The experiments are those of the Online Methods, Optogenetic stimulation:
- thalamic photoinhibition: the VPM-only 473 nm series on and no other series ("For trials in which only VPM stimulation was applied, a galvanometer in the optic path moved the laser away from the craniotomy");
- eNpHR suppression of PV interneurons: the 594 nm series on ("constant over time");
- direct cortical GABAergic activation: the vS1 473 nm series on alone, in VGAT-ChR2 mice.
Control trials are good trials without a stimulus flag and without light. Light periods: M-LIGHT reading (a) takes the epochs and touches inside each light trial's own light period, and inside the median light period of the neuron's light trials for control trials; reading (b) takes whole trials.
def site_of(c, key):
return c["meta"]["opto_sites"].get(c["meta"]["lasers"].get(key, ""), ("", ""))
def light_info(c):
"""Per trial: dict of series on (power), first onset and last offset (s, whisker clock)."""
n = c["meta"]["n_trials"]
on = {k: np.array([np.nanmax(c["laser"][k][i]) for i in range(n)]) for k in (c["laser"] or {})}
return on
def light_trials(c, kind):
if not c["laser"]:
return np.zeros(c["meta"]["n_trials"], bool)
P = light_info(c)
keys = list(P)
lit = {k: P[k] > 0.05 for k in keys}
any_on = np.any([lit[k] for k in keys], 0)
out = np.zeros(c["meta"]["n_trials"], bool)
gd = c["meta"]["genotype"] + " " + c["meta"]["description"]
vgat = "Slc32a1" in gd or "VGAT" in gd.upper()
for k in keys:
lam, loc = site_of(c, k)
others = np.any([lit[j] for j in keys if j != k], 0) if len(keys) > 1 else np.zeros_like(any_on)
if kind == "vpm" and lam == "473" and loc.startswith("VPM,"):
out |= lit[k] & ~others
if kind == "enphr" and lam == "594":
out |= lit[k]
if kind == "cortex" and lam == "473" and loc.startswith("vS1") and vgat:
out |= lit[k] & ~others
return out & c["good"]
def light_window(c, i, kind):
w = []
for k in c["laser_on"] or {}:
a, b = c["laser_on"][k][i]
if np.isfinite(a):
w.append((a, b))
if not w:
return None
return min(x[0] for x in w), max(x[1] for x in w)
def light_power(c, i):
return max([np.nanmax(c["laser"][k][i]) for k in c["laser"]] or [0.0])
def windows(c, trials, kind, ctl_window):
"""Per-trial windows (ms): the trial's own light period, or `ctl_window` for trials without light."""
out = {}
for i in np.flatnonzero(trials):
w = light_window(c, i, kind)
out[i] = (w[0] * 1000, w[1] * 1000) if w is not None else ctl_window
return out
def light_summary(c, kind, reading="b", margin="a", min_iti=0.025, spt_kind="cortex5", top_power=False):
"""Rates in epochs and spikes per touch in control and light trials (M-LIGHT (a) or (b));
with `top_power`, only the light trials at the neuron's highest power (M-LIGHT reading d)."""
out = {}
ctl = ssc7.control_trials(c)
las = light_trials(c, kind)
if top_power and las.any():
pw = np.round([light_power(c, i) for i in range(len(las))], 1)
las = las & (pw == pw[las].max())
spk = ssc7.spikes_by_trial(c)
lw = [light_window(c, i, kind) for i in np.flatnonzero(las)]
med = (np.median([w[0] for w in lw]) * 1000, np.median([w[1] for w in lw]) * 1000) if lw else None
for lab, tr in (("ctl", ctl), ("las", las)):
ep = ssc7.cell_epochs(c, tr, margin)
tt = ssc7.touch_table(c, min_iti, tr)
if reading == "a" and med is not None:
W = windows(c, tr, kind, med)
for i, d in ep.items():
a0, b0 = W[i]
d["whisk"] = [(a, b) for a, b in d["whisk"] if a >= a0 and b <= b0]
d["nonw"] = [(max(a, a0), min(b, b0)) for a, b in d["nonw"] if min(b, b0) - max(a, a0) >= 100]
if len(tt):
keep = [W[int(i)][0] <= t * 1000 < W[int(i)][1] for i, t in tt]
tt = tt[np.array(keep, bool)]
w = ssc7.epoch_rates(spk, ep, "whisk")
n = ssc7.epoch_rates(spk, ep, "nonw")
out[lab] = dict(n_trials=int(tr.sum()), whisk=ssc7.rate_readings(w)[0], nonw=ssc7.rate_readings(n)[0],
whisk_s=w[:, 2].sum() if len(w) else 0, nonw_s=n[:, 2].sum() if len(n) else 0,
spt=ssc7.spikes_per_touch(spk, tt, spt_kind) if len(tt) else np.nan, n_touch=len(tt),
ep=ep, tt=tt, w_rows=w, n_rows=n)
return out
LIGHT = {}
for c in cells:
n_ = ssc7.cell_name(c)
if GROUP[n_] == "VPM":
continue
LIGHT[n_] = {k: int(light_trials(c, k).sum()) for k in ("vpm", "enphr", "cortex")}
LT = pd.DataFrame(LIGHT).T
LT["group"] = [GROUP[n] for n in LT.index]
print("neurons with light trials of each experiment, by group (neurons, trials):")
print(LT.groupby("group").agg(vpm_neurons=("vpm", lambda x: int((x > 0).sum())), vpm_trials=("vpm", "sum"),
enphr_neurons=("enphr", lambda x: int((x > 0).sum())), enphr_trials=("enphr", "sum"),
cortex_neurons=("cortex", lambda x: int((x > 0).sum())), cortex_trials=("cortex", "sum")).to_string())
pw_ = pd.Series({n: tuple(sorted({round(light_power(NAME[n], i), 1) for i in np.flatnonzero(light_trials(NAME[n], "vpm"))})) for n in LT.index[LT.vpm > 0]})
print("VPM light powers (mW) per neuron:", pw_.value_counts().to_dict())
neurons with light trials of each experiment, by group (neurons, trials):
vpm_neurons vpm_trials enphr_neurons enphr_trials cortex_neurons cortex_trials
group
FS_ca 12 318 4 104 0 0
FS_ion 0 0 0 0 10 84
FS_wc 2 76 0 0 4 215
L4E_ca 6 105 39 1280 0 0
L4E_ion 0 0 0 0 7 18
L4E_wc 13 318 4 106 8 114
VPM light powers (mW) per neuron: {(np.float32(3.8), np.float32(15.0)): 16, (np.float32(15.0),): 16, (np.float32(3.8), np.float32(7.5), np.float32(15.0)): 1}
thalamus-inhibition-vpm¶
Blocked, data missing: the 17 thalamic multiunit recordings with patch pipettes (Fig. 6b,c) are not in the data set (the data check lists every folder and file; the only thalamic recordings are the 29 silicon-probe units without photostimulation).
thalamus-inhibition-fs¶
Thalamic photoinhibition reduces L4 FS spike rates during nonwhisking (to 4% of control, n = 13), whisking (to 13%, n = 15) and touch (to 32%, n = 14).
The FS neurons with thalamic photoinhibition trials. A neuron enters an epoch's comparison when it has at least 1 s of that epoch and (for touch) at least 5 touches in both trial types; the differing n of the paper are read this way (criterion).
def light_table(group_names, kind, reading, power=None):
rows = []
for n in group_names:
c = NAME[n]
if light_trials(c, kind).sum() == 0:
continue
L = light_summary(c, kind, reading, top_power=power == "top")
rows.append(dict(name=n, light_trials=L["las"]["n_trials"], control_trials=L["ctl"]["n_trials"],
nonw_ctl=L["ctl"]["nonw"] if L["ctl"]["nonw_s"] >= 1 else np.nan,
nonw_las=L["las"]["nonw"] if L["las"]["nonw_s"] >= 1 else np.nan,
whisk_ctl=L["ctl"]["whisk"] if L["ctl"]["whisk_s"] >= 1 else np.nan,
whisk_las=L["las"]["whisk"] if L["las"]["whisk_s"] >= 1 else np.nan,
spt_ctl=L["ctl"]["spt"] if L["ctl"]["n_touch"] >= 5 else np.nan,
spt_las=L["las"]["spt"] if L["las"]["n_touch"] >= 5 else np.nan))
return pd.DataFrame(rows)
def pct_report(T, cols, label):
res = {}
for m, (a, b) in cols.items():
ok = T[a].notna() & T[b].notna()
x, y = T.loc[ok, a].values, T.loc[ok, b].values
if ok.sum() < 2:
print(f"{label} {m}: n = {ok.sum()}")
continue
p = stats.wilcoxon(y, x).pvalue
e = 100 * y.mean() / x.mean()
r = y[x > 0] / x[x > 0]
f = 100 * np.median(r) if len(r) else np.nan
res[m] = (e, f, p, int(ok.sum()), y.mean() < x.mean())
print(f"{label} {m}: n = {ok.sum()}, control {x.mean():.2f}, light {y.mean():.2f}; (e) ratio of means {e:.0f}%, (f) median ratio {f:.0f}%; signed-rank p = {p:.2g}")
return res
TH = {}
for rd in "ab":
T = light_table(FS, "vpm", rd)
print(f"--- M-LIGHT reading ({rd}): FS neurons with thalamic photoinhibition trials: {len(T)}")
TH[rd] = pct_report(T, {"nonwhisking": ("nonw_ctl", "nonw_las"), "whisking": ("whisk_ctl", "whisk_las"), "touch": ("spt_ctl", "spt_las")}, "FS")
if rd == "a":
print(T.round(2).to_string(index=False))
# M-LIGHT reading (d): the highest light power of each neuron only, within the light period (a)
T = light_table(FS, "vpm", "a", power="top")
print("--- M-LIGHT readings (a) and (d): FS neurons, light trials at their highest power only:", len(T), "; light trials per neuron", T.light_trials.tolist())
TH["ad"] = pct_report(T, {"nonwhisking": ("nonw_ctl", "nonw_las"), "whisking": ("whisk_ctl", "whisk_las"), "touch": ("spt_ctl", "spt_las")}, "FS")
exp = {"nonwhisking": (4, 0.4), "whisking": (13, 1.3), "touch": (32, 3.2)}
for rd in ("a", "b", "ad"):
for col in (0, 1):
print(f"reading ({rd}), {'(e) ratio of means' if col == 0 else '(f) median ratio'}: within tolerance "
f"{[within(TH[rd][m][col], *exp[m]) for m in exp if m in TH[rd]]}; tests p < 0.05 with light lower: {[bool(TH[rd][m][2] < 0.05 and TH[rd][m][4]) for m in exp if m in TH[rd]]}")
--- M-LIGHT reading (a): FS neurons with thalamic photoinhibition trials: 14
FS nonwhisking: n = 12, control 8.82, light 1.08; (e) ratio of means 12%, (f) median ratio 9%; signed-rank p = 0.00098
FS whisking: n = 14, control 21.39, light 5.79; (e) ratio of means 27%, (f) median ratio 24%; signed-rank p = 0.0017
FS touch: n = 14, control 2.07, light 0.97; (e) ratio of means 47%, (f) median ratio 47%; signed-rank p = 0.00037
name light_trials control_trials nonw_ctl nonw_las whisk_ctl whisk_las spt_ctl spt_las
JY1460AAAA 35 84 4.73 0.00 13.55 1.36 1.98 0.19
JY1557AAAA 26 67 12.04 0.67 6.48 0.33 3.82 2.22
JY1569AAAA 20 38 11.05 NaN 4.19 9.72 0.98 0.80
JY1458AAAA 31 71 1.44 0.00 19.14 0.92 1.83 0.56
JY1465AAAA 38 110 3.85 0.71 6.73 9.03 2.76 0.78
JY1559AAAA 23 54 0.29 1.20 5.52 3.61 0.39 0.34
JY1528AAAA 24 57 20.26 2.04 43.74 10.62 1.93 0.55
JY1469AAAA 41 83 17.50 NaN 38.39 8.91 2.00 0.92
JY1527AAAA 27 64 4.55 2.28 13.01 3.37 1.43 0.71
JY1560AAAA 20 57 5.50 0.40 6.57 2.85 3.34 1.43
JY1474AAAA 23 69 5.08 2.69 17.81 3.59 2.16 0.43
JY1619AAAA 10 29 18.52 0.33 61.06 11.45 0.78 0.87
JY1139AAAA 58 45 6.70 2.36 15.32 9.19 2.74 2.45
JY1171AAAI 18 62 22.85 0.23 47.98 6.14 2.83 1.38
--- M-LIGHT reading (b): FS neurons with thalamic photoinhibition trials: 14 FS nonwhisking: n = 14, control 8.95, light 7.64; (e) ratio of means 85%, (f) median ratio 101%; signed-rank p = 0.71 FS whisking: n = 14, control 20.48, light 13.71; (e) ratio of means 67%, (f) median ratio 72%; signed-rank p = 0.025 FS touch: n = 14, control 2.08, light 1.43; (e) ratio of means 69%, (f) median ratio 69%; signed-rank p = 0.0023
--- M-LIGHT readings (a) and (d): FS neurons, light trials at their highest power only: 14 ; light trials per neuron [35, 16, 10, 31, 31, 11, 14, 24, 18, 10, 13, 7, 58, 18] FS nonwhisking: n = 12, control 8.82, light 0.54; (e) ratio of means 6%, (f) median ratio 2%; signed-rank p = 0.0015 FS whisking: n = 14, control 21.39, light 4.61; (e) ratio of means 22%, (f) median ratio 13%; signed-rank p = 0.0017 FS touch: n = 14, control 2.07, light 0.79; (e) ratio of means 38%, (f) median ratio 35%; signed-rank p = 0.00037 reading (a), (e) ratio of means: within tolerance [False, False, False]; tests p < 0.05 with light lower: [True, True, True] reading (a), (f) median ratio: within tolerance [False, False, False]; tests p < 0.05 with light lower: [True, True, True] reading (b), (e) ratio of means: within tolerance [False, False, False]; tests p < 0.05 with light lower: [False, True, True] reading (b), (f) median ratio: within tolerance [False, False, False]; tests p < 0.05 with light lower: [False, True, True] reading (ad), (e) ratio of means: within tolerance [False, False, False]; tests p < 0.05 with light lower: [True, True, True] reading (ad), (f) median ratio: within tolerance [False, True, True]; tests p < 0.05 with light lower: [True, True, True]
Result: partially reproduced. Within each trial's light period (M-LIGHT reading a), thalamic photoinhibition lowers FS rates to 12% of control in nonwhisking (ratio of means; median ratio 9%, n = 12, signed-rank p = 0.00098), 27% in whisking (24%, n = 14, p = 0.0017) and 47% for touch (47%, n = 14, p = 0.00037). All three tests hold. None of the percentages is within tolerance of 4%, 13% and 32%: the inhibition here is weaker. Over whole trials (reading b), the reductions are smaller still (85%, 67%, 69%), and the nonwhisking test fails (p = 0.71). With only each neuron's highest power (reading d, within the light period), the rates fall to 6%, 22% and 38% (ratio of means) or 2%, 13% and 35% (median ratios), all tests holding. Under (d) with median ratios the whisking and touch values are within tolerance, but the nonwhisking 2% is outside 4 +- 0.4, so no reading has all three.
thalamus-inhibition-dose¶
The reduction of L4 FS spiking by thalamic photoinhibition is dose dependent.
def per_trial_epoch_rates(c, kind):
"""Per trial (power, nonwhisking rate, whisking rate, spikes per touch) inside the light window
(reading a), over control and light trials."""
ctl = ssc7.control_trials(c)
las = light_trials(c, kind)
tr = ctl | las
lw = [light_window(c, i, kind) for i in np.flatnonzero(las)]
med = (np.median([w[0] for w in lw]) * 1000, np.median([w[1] for w in lw]) * 1000)
W = windows(c, tr, kind, med)
spk = ssc7.spikes_by_trial(c)
ep = ssc7.cell_epochs(c, tr)
T_ = ssc7.touch_table(c, 0.025, tr)
rows = []
for i, d in ep.items():
a0, b0 = W[i]
s = spk[i]
out = [light_power(c, i) if las[i] else 0.0]
for k in ("nonw", "whisk"):
segs = [(max(a, a0), min(b, b0)) for a, b in d[k] if min(b, b0) - max(a, a0) >= (100 if k == "nonw" else 1)] if k == "nonw" else [(a, b) for a, b in d[k] if a >= a0 and b <= b0]
dur = sum(b - a for a, b in segs) / 1000
cnt = sum(np.sum((s >= a / 1000) & (s < b / 1000)) for a, b in segs)
out.append(cnt / dur if dur > 0 else np.nan)
tt = T_[(T_[:, 0] == i) & (T_[:, 1] * 1000 >= a0) & (T_[:, 1] * 1000 < b0)] if len(T_) else T_
out.append(ssc7.spikes_per_touch(spk, tt) if len(tt) else np.nan)
rows.append(out)
return np.array(rows, float)
rho = {"nonw": [], "whisk": [], "touch": []}
for n in FS:
c = NAME[n]
if light_trials(c, "vpm").sum() == 0:
continue
R = per_trial_epoch_rates(c, "vpm")
for j, k in enumerate(("nonw", "whisk", "touch")):
ok = np.isfinite(R[:, j + 1])
if ok.sum() >= 10 and len(np.unique(R[ok, 0])) >= 2:
rho[k].append(stats.spearmanr(R[ok, 0], R[ok, j + 1]).statistic)
neg = 0
for k, v in rho.items():
v = np.array(v)
v = v[np.isfinite(v)]
p = stats.wilcoxon(v).pvalue if len(v) > 1 else np.nan
neg += int(p < 0.05 and np.median(v) < 0)
print(f"{k}: Spearman rho (power with control as 0, rate) over {len(v)} FS neurons: median {np.median(v):.2f}, negative in {int((v < 0).sum())}; signed-rank against 0 p = {p:.2g}")
print("epochs with a significant negative dose relation:", neg, "of 3")
levels = []
for n in FS:
c = NAME[n]
if light_trials(c, "vpm").sum():
levels.append(len({round(light_power(c, i), 1) for i in np.flatnonzero(light_trials(c, "vpm"))}))
print("FS neurons with 1 or 2 light powers:", pd.Series(levels).value_counts().to_dict())
# variant: ratio of mean whisking rate at each power to control, pooled over neurons
pooled = []
for n in FS:
c = NAME[n]
if light_trials(c, "vpm").sum() == 0:
continue
R = per_trial_epoch_rates(c, "vpm")
for pw in np.unique(R[:, 0]):
sel = R[:, 0] == pw
pooled.append(dict(name=n, power=pw, nonw=np.nanmean(R[sel, 1]), whisk=np.nanmean(R[sel, 2]), spt=np.nanmean(R[sel, 3])))
PP = pd.DataFrame(pooled)
print(PP.groupby("power")[["nonw", "whisk", "spt"]].agg(["mean", "count"]).round(2).to_string())
# variant: light trials only (control trials left out), for the neurons with two light powers, so
# that the correlation tests dose and not light against no light
rho2 = {"nonw": [], "whisk": [], "touch": []}
for n in FS:
c = NAME[n]
if light_trials(c, "vpm").sum() == 0:
continue
R = per_trial_epoch_rates(c, "vpm")
R = R[R[:, 0] > 0]
for j, k in enumerate(("nonw", "whisk", "touch")):
ok = np.isfinite(R[:, j + 1])
if ok.sum() >= 10 and len(np.unique(R[ok, 0])) >= 2:
rho2[k].append(stats.spearmanr(R[ok, 0], R[ok, j + 1]).statistic)
for k, v in rho2.items():
v = np.array(v)
v = v[np.isfinite(v)]
p = stats.wilcoxon(v).pvalue if len(v) > 1 else np.nan
print(f"variant, light trials only, {k}: Spearman rho (power, rate) over {len(v)} FS neurons with two powers: median {np.median(v) if len(v) else np.nan:.2f}, negative in {int((v < 0).sum())}; signed-rank against 0 p = {p:.2g}")
nonw: Spearman rho (power with control as 0, rate) over 13 FS neurons: median -0.47, negative in 12; signed-rank against 0 p = 0.00049
whisk: Spearman rho (power with control as 0, rate) over 14 FS neurons: median -0.65, negative in 13; signed-rank against 0 p = 0.0012
touch: Spearman rho (power with control as 0, rate) over 14 FS neurons: median -0.36, negative in 12; signed-rank against 0 p = 0.0012
epochs with a significant negative dose relation: 3 of 3
FS neurons with 1 or 2 light powers: {2: 10, 1: 4}
nonw whisk spt
mean count mean count mean count
power
0.00 10.22 14 21.97 14 2.15 14
3.75 4.67 10 9.32 10 1.48 10
15.00 0.56 13 5.14 14 1.02 14
variant, light trials only, nonw: Spearman rho (power, rate) over 6 FS neurons with two powers: median -0.58, negative in 4; signed-rank against 0 p = 0.31 variant, light trials only, whisk: Spearman rho (power, rate) over 10 FS neurons with two powers: median -0.28, negative in 7; signed-rank against 0 p = 0.074 variant, light trials only, touch: Spearman rho (power, rate) over 7 FS neurons with two powers: median -0.23, negative in 6; signed-rank against 0 p = 0.031
Result: reproduced. Per FS neuron, the Spearman correlation between light power (control as 0) and the rate inside the light period is negative in 12 of 13 neurons for nonwhisking (median rho -0.47, signed-rank p = 0.00049), 13 of 14 for whisking (-0.65, p = 0.0012) and 12 of 14 for touch (-0.36, p = 0.0012). Pooled over neurons, the mean whisking rate falls with power: 21.97, 9.32 and 5.14 spikes/s at 0, 3.75 and 15 mW. Ten of the 14 neurons have two light powers, four have one. The test as fixed mostly compares light with no light. Among light trials only, in the neurons with two powers, the correlation is weaker: median rho -0.58 (nonwhisking, 6 neurons, p = 0.31), -0.28 (whisking, 10, p = 0.074) and -0.23 (touch, 7, p = 0.031), so only one epoch shows a dose relation beyond light against no light.
thalamus-inhibition-l4e-vm¶
Thalamic photoinhibition hyperpolarizes L4 excitatory neurons and reduces their Vm fluctuations, with an onset latency of 4.2 ms, longer than the 2.8 ms of direct cortical GABAergic activation.
from scipy import signal as sps
HP = sps.butter(2, 10, btype="highpass", fs=ssc7.VM_FS)
def vm_outside_touch(c, P, tr, win=None):
T_ = ssc7.touches(c)
vs, vv = [], []
for i in np.flatnonzero(tr):
if i >= len(P["vm"]):
continue
v = P["vm"][i]
m = np.zeros(len(v), bool)
a0, b0 = (0.0, 5.0) if win is None else win(i)
m[max(0, ssc7.vm_at(c, P["vm"], i, a0)):ssc7.vm_at(c, P["vm"], i, b0)] = True
for x in T_[i][0]:
kk = ssc7.vm_at(c, P["vm"], i, x)
m[max(0, kk - 100):kk + 1000] = False
vs.append(v[m])
vv.append(sps.filtfilt(*HP, v)[m])
if not vs:
return np.nan, np.nan
return float(np.median(np.concatenate(vs))), float(np.var(np.concatenate(vv)))
def onset_average(c, P, tr, pre=0.05, post=0.1):
X = []
for i in np.flatnonzero(tr):
w = light_window(c, i, None)
if w is None or i >= len(P["vm"]):
continue
k = ssc7.vm_at(c, P["vm"], i, w[0])
v = P["vm"][i]
a, b = k - int(pre * ssc7.VM_FS), k + int(post * ssc7.VM_FS)
if a >= 0 and b <= len(v):
X.append(v[a:b])
return np.mean(X, 0) if X else None
def neg_latency(avg, pre=0.05, fs=ssc7.VM_FS):
"""M-LAT Vm rule for a hyperpolarization: first time dVm/dt falls below the mean minus 3 s.d.
of dVm/dt over the 25 ms before light onset."""
z = int(pre * fs)
d = np.gradient(avg) * fs
base = d[z - int(0.025 * fs):z]
k = np.flatnonzero(d[z:z + int(0.05 * fs)] < base.mean() - 3 * base.std())
return np.nan if len(k) == 0 else 1000.0 * k[0] / fs
def neg_latency_smooth(avg, pre=0.05, fs=ssc7.VM_FS, smooth=10, hold=10):
"""Variant of the rule above, robust to the light artifact at onset (an assumption): dVm/dt of
Vm smoothed over 1 ms, baseline 25 ms before onset, and the crossing must last 1 ms."""
z = int(pre * fs)
v = np.convolve(avg, np.ones(smooth) / smooth, mode="same")
d = np.gradient(v) * fs
base = d[z - int(0.025 * fs):z - smooth]
below = d[z:z + int(0.05 * fs)] < base.mean() - 3 * base.std()
for k in range(len(below) - hold):
if below[k:k + hold].all():
return 1000.0 * k / fs
return np.nan
rows, avgs = [], {"vpm": [], "cortex": []}
for n in L4EWC:
c = NAME[n]
P = ssc7.prep_vm(c)
for kind in ("vpm", "cortex"):
las = light_trials(c, kind)
if las.sum() == 0:
continue
av = onset_average(c, P, las)
if av is not None:
avgs[kind].append(av)
if kind == "vpm":
lw = [light_window(c, i, kind) for i in np.flatnonzero(las)]
med = (np.median([w[0] for w in lw]), np.median([w[1] for w in lw]))
win = lambda i, c=c, med=med: light_window(c, i, "vpm") or med
vc, varc = vm_outside_touch(c, P, ssc7.control_trials(c), win)
vl, varl = vm_outside_touch(c, P, las, win)
vc_b, varc_b = vm_outside_touch(c, P, ssc7.control_trials(c))
vl_b, varl_b = vm_outside_touch(c, P, las)
rows.append(dict(name=n, n_light=int(las.sum()), vm_ctl=vc, vm_las=vl, var_ctl=varc, var_las=varl,
vm_ctl_b=vc_b, vm_las_b=vl_b, var_ctl_b=varc_b, var_las_b=varl_b,
latency_own=neg_latency(av) if av is not None else np.nan))
TL = pd.DataFrame(rows)
print(TL.round(3).to_string(index=False))
for rd, sfx in (("a", ""), ("b", "_b")):
p1 = stats.wilcoxon(TL["vm_las" + sfx], TL["vm_ctl" + sfx]).pvalue
p2 = stats.wilcoxon(TL["var_las" + sfx], TL["var_ctl" + sfx]).pvalue
print(f"M-LIGHT ({rd}), n = {len(TL)}: Vm outside touch, light minus control median {np.median(TL['vm_las' + sfx] - TL['vm_ctl' + sfx]):.2f} mV, lower in {int((TL['vm_las' + sfx] < TL['vm_ctl' + sfx]).sum())}, p = {p1:.2g}; "
f"10 Hz high-passed variance ratio median {np.median(TL['var_las' + sfx] / TL['var_ctl' + sfx]):.2f}, lower in {int((TL['var_las' + sfx] < TL['var_ctl' + sfx]).sum())}, p = {p2:.2g}")
for rule, f in (("M-LAT Vm rule", neg_latency), ("variant, 1 ms smoothing and 1 ms hold", neg_latency_smooth)):
lat = {}
for kind in ("vpm", "cortex"):
if avgs[kind]:
g = np.mean(avgs[kind], 0)
lat[kind] = f(g)
z = int(0.05 * ssc7.VM_FS)
d0 = np.gradient(g)[z] * ssc7.VM_FS
print(f"{rule}, {kind}: grand average over {len(avgs[kind])} neurons; Vm change 5-50 ms after onset {g[z + 50:z + 500].mean() - g[z - 250:z].mean():.2f} mV; "
f"dVm/dt at the onset sample {d0:.0f} mV/s; latency {lat[kind]:.1f} ms; per-neuron median {np.nanmedian([f(a) for a in avgs[kind]]):.1f} ms")
print(f" thalamic within 4.2+-0.42: {within(lat.get('vpm', np.nan), 4.2, 0.42)}; cortical within 2.8+-0.28: {within(lat.get('cortex', np.nan), 2.8, 0.28)}; thalamic longer: {lat.get('vpm', np.nan) > lat.get('cortex', np.nan)}")
# variant: the smoothing and hold windows of the onset-latency rule
grid = []
for sm in (5, 10, 20):
for hd in (5, 10, 20):
lv = neg_latency_smooth(np.mean(avgs["vpm"], 0), smooth=sm, hold=hd)
lc = neg_latency_smooth(np.mean(avgs["cortex"], 0), smooth=sm, hold=hd)
grid.append(dict(smooth_ms=sm / 10, hold_ms=hd / 10, thalamic=lv, cortical=lc, thalamic_longer=lv > lc,
thalamic_within=within(lv, 4.2, 0.42), cortical_within=within(lc, 2.8, 0.28)))
print("onset latency (ms) on the grand averages, by smoothing and hold window:")
print(pd.DataFrame(grid).round(2).to_string(index=False))
name n_light vm_ctl vm_las var_ctl var_las vm_ctl_b vm_las_b var_ctl_b var_las_b latency_own
JY1008AAAA 20 -57.528 -67.370 5.150 3.022 -57.204 -65.042 5.347 4.178 6.1
JY0963AAAA 24 -67.606 -67.902 0.640 0.579 -67.753 -67.431 0.677 0.681 0.0
JY0978AAAA 20 -71.102 -76.458 1.537 0.955 -71.297 -74.793 1.706 1.484 5.2
JY1189AAAA 9 -67.803 -74.470 1.995 0.333 -67.875 -73.029 1.968 1.344 0.0
JY1195AAAB 16 -65.745 -72.029 8.369 2.288 -65.804 -69.958 8.186 3.432 5.2
JY0975AAAA 30 -63.397 -64.835 0.490 0.242 -63.549 -64.286 0.529 0.421 4.9
JY0947AAAA 42 -64.455 -67.447 0.645 0.623 -64.659 -67.681 0.571 0.674 0.0
JY0969AAAA 41 -62.215 -63.095 0.422 0.365 -62.319 -62.637 0.532 0.546 0.0
JY1211AAAB 28 -61.754 -64.273 3.224 2.086 -61.718 -63.572 3.005 1.988 0.0
JY1154AAAA 19 -68.184 -77.416 3.170 1.131 -68.866 -74.043 3.160 2.497 5.2
JY1144AAAA 22 -74.295 -79.691 1.893 0.440 -75.230 -78.347 1.964 1.532 NaN
JY0965AAAA 22 -71.901 -74.303 0.642 0.484 -71.988 -73.689 0.688 0.621 0.0
JY0950AAAA 25 -67.243 -68.200 1.426 0.831 -67.457 -67.986 1.511 1.213 0.0
M-LIGHT (a), n = 13: Vm outside touch, light minus control median -2.99 mV, lower in 13, p = 0.00024; 10 Hz high-passed variance ratio median 0.59, lower in 13, p = 0.00024
M-LIGHT (b), n = 13: Vm outside touch, light minus control median -3.02 mV, lower in 12, p = 0.00073; 10 Hz high-passed variance ratio median 0.80, lower in 10, p = 0.0046
M-LAT Vm rule, vpm: grand average over 13 neurons; Vm change 5-50 ms after onset -2.94 mV; dVm/dt at the onset sample -295 mV/s; latency 0.0 ms; per-neuron median 0.0 ms
M-LAT Vm rule, cortex: grand average over 8 neurons; Vm change 5-50 ms after onset -5.37 mV; dVm/dt at the onset sample -392 mV/s; latency 0.0 ms; per-neuron median 2.6 ms
thalamic within 4.2+-0.42: False; cortical within 2.8+-0.28: False; thalamic longer: False
variant, 1 ms smoothing and 1 ms hold, vpm: grand average over 13 neurons; Vm change 5-50 ms after onset -2.94 mV; dVm/dt at the onset sample -295 mV/s; latency 4.8 ms; per-neuron median 5.6 ms
variant, 1 ms smoothing and 1 ms hold, cortex: grand average over 8 neurons; Vm change 5-50 ms after onset -5.37 mV; dVm/dt at the onset sample -392 mV/s; latency 2.6 ms; per-neuron median 2.8 ms
thalamic within 4.2+-0.42: False; cortical within 2.8+-0.28: True; thalamic longer: True
onset latency (ms) on the grand averages, by smoothing and hold window:
smooth_ms hold_ms thalamic cortical thalamic_longer thalamic_within cortical_within
0.5 0.5 5.0 2.7 True False True
0.5 1.0 5.0 2.7 True False True
0.5 2.0 5.0 2.7 True False True
1.0 0.5 4.8 2.6 True False True
1.0 1.0 4.8 2.6 True False True
1.0 2.0 4.8 2.6 True False True
2.0 0.5 4.5 2.0 True True False
2.0 1.0 4.5 2.0 True True False
2.0 2.0 4.5 2.0 True True False
Result: partially reproduced. Within the light period, Vm outside touch is lower with thalamic photoinhibition in all 13 L4 E neurons (median -2.99 mV, signed-rank p = 0.00024). The 10 Hz high-passed variance falls to a median of 0.59 of control (lower in 13, p = 0.00024). Both tests hold. The latency rule as the claims file gives it crosses at the onset sample itself, giving 0.0 ms for both grand averages; at that sample dVm/dt is -295 and -392 mV/s, a step the light makes. With 1 ms smoothing and a 1 ms hold (assumed), the latency is 4.8 ms for thalamic photoinhibition (13 neurons) and 2.6 ms for direct cortical activation (8 neurons). The thalamic latency is the longer, as the paper says. The cortical one is within 2.8 +- 0.28; the thalamic one is outside 4.2 +- 0.42. Over smoothing windows of 0.5 to 2 ms and holds of 0.5 to 2 ms, the thalamic latency is 4.5 to 5.0 ms and the cortical 2.0 to 2.7 ms: the thalamic one is always longer, and no window puts both within tolerance (2 ms smoothing gives 4.5 and 2.0 ms, thalamic within and cortical outside).
enphr-kruskal-wallis¶
Partially suppressing PV (FS) interneurons with eNpHR changes the responses of L4 excitatory neurons (P = 1e-6, Kruskal-Wallis).
The neurons are the L4 E neurons (whole-cell and cell-attached) with 594 nm light trials.
EN = {}
for rd in "ab":
rows = []
for n in L4E85:
c = NAME[n]
if light_trials(c, "enphr").sum() == 0:
continue
L = light_summary(c, "enphr", rd)
L8 = light_summary(c, "enphr", rd, min_iti=0.010, spt_kind="cortex8")
rows.append(dict(name=n, group=GROUP[n], mouse=c["meta"]["subject"], light_trials=L["las"]["n_trials"], control_trials=L["ctl"]["n_trials"],
nonw_ctl=L["ctl"]["nonw"], nonw_las=L["las"]["nonw"], whisk_ctl=L["ctl"]["whisk"], whisk_las=L["las"]["whisk"],
spt8_ctl=L8["ctl"]["spt"], spt8_las=L8["las"]["spt"]))
EN[rd] = pd.DataFrame(rows)
E = EN["a"]
print(f"L4E neurons with eNpHR trials: {len(E)} ({E.group.value_counts().to_dict()}) in {E.mouse.nunique()} mice; paper n = 40")
for rd, D in EN.items():
D = D.dropna(subset=["nonw_ctl", "nonw_las", "whisk_ctl", "whisk_las"])
h4 = stats.kruskal(D.nonw_ctl, D.whisk_ctl, D.nonw_las, D.whisk_las)
h2 = stats.kruskal(np.r_[D.nonw_ctl, D.whisk_ctl], np.r_[D.nonw_las, D.whisk_las])
print(f"M-LIGHT ({rd}), n = {len(D)}: Kruskal-Wallis (a) four groups H = {h4.statistic:.1f}, p = {h4.pvalue:.2g}; (b) two groups H = {h2.statistic:.1f}, p = {h2.pvalue:.2g}")
# The eNpHR neurons against the cell list: the cell list's L4 E rows from PV-IRES-Cre mice
cl_e = CL[CL.section.isin(["Whole-cell units", "Extracellular units"])]
cl_pv = cl_e[cl_e.mouse_type.astype(str).str.lower().str.contains("pv-ires-cre")]
e_keys = {key(n[:6] if n.startswith("JY") else n) for n in E.name}
pv_keys = {key(x) for x in cl_pv.cell}
print(f"cell list L4 E rows from PV-IRES-Cre mice: {len(cl_pv)} ({cl_pv.section.value_counts().to_dict()}), in {cl_pv.mouse.nunique()} mice")
print(" eNpHR neurons here not among them:", sorted(n for n in E.name if key(n[:6] if n.startswith('JY') else n) not in pv_keys))
print(" of them, not here:", sorted(x for x in cl_pv.cell if key(x) not in e_keys))
L4E neurons with eNpHR trials: 43 ({'L4E_ca': 39, 'L4E_wc': 4}) in 9 mice; paper n = 40
M-LIGHT (a), n = 43: Kruskal-Wallis (a) four groups H = 18.0, p = 0.00044; (b) two groups H = 13.6, p = 0.00022
M-LIGHT (b), n = 43: Kruskal-Wallis (a) four groups H = 9.8, p = 0.021; (b) two groups H = 3.7, p = 0.053
cell list L4 E rows from PV-IRES-Cre mice: 43 ({'Extracellular units': 38, 'Whole-cell units': 5}), in 10 mice
eNpHR neurons here not among them: ['JY1268AAAA']
of them, not here: ['JY0781']
Result: reproduced. Over the 43 L4 E neurons with eNpHR trials, within the light period (M-LIGHT reading a), the Kruskal-Wallis test of the four groups (nonwhisking and whisking, control and eNpHR) gives H = 18.0, p = 0.00044. The two-group reading gives p = 0.00022. Over whole trials, the four-group test gives p = 0.021. The paper's P is 1e-6. The cell list names 43 L4 E neurons from PV-IRES-Cre mice (38 extracellular, 5 whole-cell). The 43 here are those, less JY0781 (no eNpHR light in its file) and plus JY1268, which the cell list does not name. The paper's 40 cannot be matched to a subset.
enphr-l4e-rates¶
Suppressing PV interneurons increases L4 excitatory spike rates during nonwhisking (0.6 +- 0.1 to 1.6 +- 0.3 spikes/s, P = 6e-5) and whisking (0.8 +- 0.2 to 2.7 +- 0.5 spikes/s, P = 2e-6), mean +- s.e.m., n = 40.
sem = lambda x: np.std(x, ddof=1) / np.sqrt(len(x))
for rd, D in EN.items():
D = D.dropna(subset=["nonw_ctl", "nonw_las", "whisk_ctl", "whisk_las"])
vals = [D.nonw_ctl.mean(), D.nonw_las.mean(), D.whisk_ctl.mean(), D.whisk_las.mean()]
exp = [(0.6, 0.1), (1.6, 0.3), (0.8, 0.2), (2.7, 0.5)]
p1 = stats.wilcoxon(D.nonw_las, D.nonw_ctl).pvalue
p2 = stats.wilcoxon(D.whisk_las, D.whisk_ctl).pvalue
print(f"M-LIGHT ({rd}), n = {len(D)}: nonwhisking {D.nonw_ctl.mean():.2f} +- {sem(D.nonw_ctl):.2f} -> {D.nonw_las.mean():.2f} +- {sem(D.nonw_las):.2f} (p = {p1:.2g}); "
f"whisking {D.whisk_ctl.mean():.2f} +- {sem(D.whisk_ctl):.2f} -> {D.whisk_las.mean():.2f} +- {sem(D.whisk_las):.2f} (p = {p2:.2g}); "
f"within: {[within(v_, e, t) for v_, (e, t) in zip(vals, exp)]}")
if rd == "a":
print("by mouse, light minus control whisking rate (mean):", D.assign(d=D.whisk_las - D.whisk_ctl).groupby("mouse").d.agg(["mean", "count"]).round(2).to_dict("index"))
M-LIGHT (a), n = 43: nonwhisking 0.54 +- 0.11 -> 1.45 +- 0.31 (p = 0.00012); whisking 1.13 +- 0.24 -> 2.82 +- 0.54 (p = 3e-05); within: [True, True, False, True]
by mouse, light minus control whisking rate (mean): {'ANM244024': {'mean': -0.21, 'count': 8}, 'ANM244025': {'mean': 1.2, 'count': 5}, 'ANM244028': {'mean': 0.67, 'count': 5}, 'ANM266945': {'mean': 2.54, 'count': 10}, 'ANM266951': {'mean': 0.0, 'count': 1}, 'ANM300169': {'mean': 3.7, 'count': 2}, 'ANM300170': {'mean': 7.27, 'count': 3}, 'ANM300171': {'mean': 0.94, 'count': 4}, 'ANM300172': {'mean': 1.35, 'count': 5}}
M-LIGHT (b), n = 43: nonwhisking 0.59 +- 0.11 -> 0.78 +- 0.12 (p = 0.0012); whisking 1.04 +- 0.20 -> 1.58 +- 0.27 (p = 7.6e-05); within: [True, False, False, False]
Result: partially reproduced. Within the light period (n = 43), PV suppression raises the nonwhisking rate from 0.54 +- 0.11 to 1.45 +- 0.31 spikes/s (p = 0.00012) and the whisking rate from 1.13 +- 0.24 to 2.82 +- 0.54 (p = 3e-5). Both tests hold. Three of the four means are within tolerance; the control whisking mean, 1.13, is above 0.8 +- 0.2. Over whole trials the rises are smaller (0.59 to 0.78, 1.04 to 1.58).
enphr-whisking-driven¶
With PV interneurons suppressed, L4 excitatory neurons become driven by whisker movement (whisking against nonwhisking, P = 0.02).
for rd, D in EN.items():
D = D.dropna(subset=["nonw_ctl", "nonw_las", "whisk_ctl", "whisk_las"])
p_l = stats.wilcoxon(D.whisk_las, D.nonw_las).pvalue
p_c = stats.wilcoxon(D.whisk_ctl, D.nonw_ctl).pvalue
print(f"M-LIGHT ({rd}), n = {len(D)}: eNpHR trials whisking {D.whisk_las.mean():.2f} vs nonwhisking {D.nonw_las.mean():.2f}, p = {p_l:.2g}; "
f"control trials {D.whisk_ctl.mean():.2f} vs {D.nonw_ctl.mean():.2f}, p = {p_c:.2g}")
M-LIGHT (a), n = 43: eNpHR trials whisking 2.82 vs nonwhisking 1.45, p = 0.013; control trials 1.13 vs 0.54, p = 0.052 M-LIGHT (b), n = 43: eNpHR trials whisking 1.58 vs nonwhisking 0.78, p = 0.0065; control trials 1.04 vs 0.59, p = 0.035
Result: reproduced. In eNpHR trials, whisking rates exceed nonwhisking rates: 2.82 against 1.45 spikes/s within the light period (signed-rank p = 0.013, n = 43), or 1.58 against 0.78 over whole trials (p = 0.0065). The same test in control trials gives p = 0.052 within the light period and p = 0.035 over whole trials.
enphr-spikes-per-touch¶
PV interneuron suppression changes touch-evoked spiking of L4 excitatory neurons heterogeneously, with no significant mean change (0.27 +- 0.06 to 0.32 +- 0.06 spikes per touch, n = 40, P = 0.09, Wilcoxon signed-rank); weakly responding neurons tend to respond more, and strongly driven neurons stay the same or decrease.
for rd, D in EN.items():
D = D.dropna(subset=["spt8_ctl", "spt8_las"])
p = stats.wilcoxon(D.spt8_las, D.spt8_ctl).pvalue
rho = stats.spearmanr(D.spt8_ctl, D.spt8_las - D.spt8_ctl)
print(f"M-LIGHT ({rd}), n = {len(D)}: spikes per touch (4-20 ms minus 0-16 ms before, ITI >= 10 ms) {D.spt8_ctl.mean():.3f} +- {sem(D.spt8_ctl):.3f} -> "
f"{D.spt8_las.mean():.3f} +- {sem(D.spt8_las):.3f}; signed-rank p = {p:.2g}; Spearman (control, change) rho = {rho.statistic:.2f}, p = {rho.pvalue:.2g}; "
f"within: {within(D.spt8_ctl.mean(), 0.27, 0.06)}, {within(D.spt8_las.mean(), 0.32, 0.06)}")
M-LIGHT (a), n = 43: spikes per touch (4-20 ms minus 0-16 ms before, ITI >= 10 ms) 0.254 +- 0.063 -> 0.342 +- 0.057; signed-rank p = 0.009; Spearman (control, change) rho = -0.13, p = 0.42; within: True, True M-LIGHT (b), n = 43: spikes per touch (4-20 ms minus 0-16 ms before, ITI >= 10 ms) 0.220 +- 0.060 -> 0.279 +- 0.052; signed-rank p = 0.027; Spearman (control, change) rho = -0.22, p = 0.16; within: True, True
Result: not reproduced. Both means are within tolerance. Within the light period, spikes per touch are 0.254 +- 0.063 in control and 0.342 +- 0.057 with eNpHR (0.27 +- 0.06, 0.32 +- 0.06). The claim of no mean change fails: signed-rank p = 0.009 (0.027 over whole trials). The negative correlation between control response and change is not significant (rho = -0.13, p = 0.42; over whole trials -0.22, p = 0.16). One of the three parts holds under either reading.
enphr-auc¶
PV interneuron suppression improves touch detection (AUC) for neurons with weak touch responses and diminishes it for neurons with robust touch responses.
def auc(pos, neg):
pos, neg = np.asarray(pos, float), np.asarray(neg, float)
if len(pos) == 0 or len(neg) == 0:
return np.nan
r = stats.rankdata(np.r_[pos, neg])
return (r[:len(pos)].sum() - len(pos) * (len(pos) + 1) / 2) / (len(pos) * len(neg))
def roc_cell(c, tr, reading, rng, skip_passive=True):
spk = ssc7.spikes_by_trial(c)
T_ = ssc7.touches(c)
pin = np.asarray(c["pole_in"]) - c["t0"] if c["pole_in"] is not None else np.full(len(spk), 0.5)
pout = np.asarray(c["pole_out"]) - c["t0"] if c["pole_out"] is not None else np.full(len(spk), 4.5)
tags = c.get("epoch_tag") or []
pos, ntr, ft = [], [], []
for i in np.flatnonzero(tr):
a = T_[i][0]
s = spk[i]
if skip_passive and i < len(tags) and "passive" in str(tags[i]):
# the first touch of a trial tagged passive is left out, as in touch_table; a trial
# whose only touch is that one is neither a touch nor a no-touch trial
if len(a) <= 1:
continue
a = a[1:]
if len(a):
t = a[0]
ft.append(t)
pos.append(np.sum((s >= t) & (s < t + 0.25)) - np.sum((s >= t - 0.25) & (s < t)))
else:
ntr.append(i)
if len(pos) < 3 or len(ntr) < 3:
return np.nan
if reading == "a":
neg = []
for _ in range(5000):
i = ntr[rng.integers(len(ntr))]
lo, hi = max(0.25, pin[i]), min(4.75, pout[i] if pout[i] > pin[i] else 4.75)
t = rng.uniform(lo, max(lo + 1e-3, hi))
s = spk[i]
neg.append(np.sum((s >= t) & (s < t + 0.25)) - np.sum((s >= t - 0.25) & (s < t)))
return auc(pos, neg)
t = np.median(ft)
neg = np.array([np.sum((spk[i] >= t) & (spk[i] < t + 0.25)) - np.sum((spk[i] >= t - 0.25) & (spk[i] < t)) for i in ntr])
pos = np.array(pos)
return np.mean([auc(rng.choice(pos, len(pos)), rng.choice(neg, len(neg))) for _ in range(5000)])
def touch_rates(c, tr):
spk = ssc7.spikes_by_trial(c)
tt = ssc7.touch_table(c, 0.025, tr)
if len(tt) == 0:
return np.nan, np.nan
post = np.mean([np.sum((spk[int(i)] - t >= 0) & (spk[int(i)] - t < 0.25)) for i, t in tt]) / 0.25
pre = np.mean([np.sum((spk[int(i)] - t >= -0.25) & (spk[int(i)] - t < 0)) for i, t in tt]) / 0.25
return post, pre
rng = np.random.default_rng(4)
rows = []
for n in E.name:
c = NAME[n]
ctl, las = ssc7.control_trials(c), light_trials(c, "enphr")
r = dict(name=n)
for rd in "ab":
r[f"auc_ctl_{rd}"] = roc_cell(c, ctl, rd, rng)
r[f"auc_las_{rd}"] = roc_cell(c, las, rd, rng)
r["touch_ctl"], r["base_ctl"] = touch_rates(c, ctl)
r["touch_las"], r["base_las"] = touch_rates(c, las)
rows.append(r)
AUC = pd.DataFrame(rows)
print("neurons without enough touch and no-touch trials for an AUC:", int(AUC[["auc_ctl_a", "auc_las_a"]].isna().any(axis=1).sum()), "of", len(AUC))
for rd in "ab":
D = AUC.dropna(subset=[f"auc_ctl_{rd}", f"auc_las_{rd}", "touch_ctl"])
dA = D[f"auc_las_{rd}"] - D[f"auc_ctl_{rd}"]
ev = D.touch_ctl - D.base_ctl
rho = stats.spearmanr(ev, dA)
up, dn = dA > 0, dA < 0
pv = stats.ranksums(ev[dn], ev[up]).pvalue if up.any() and dn.any() else np.nan
print(f"M-ROC ({rd}), n = {len(D)}: AUC control median {D[f'auc_ctl_{rd}'].median():.3f}, eNpHR {D[f'auc_las_{rd}'].median():.3f}; "
f"Spearman (control touch-evoked rate, AUC change) rho = {rho.statistic:.2f}, p = {rho.pvalue:.2g}; AUC up {int(up.sum())}, down {int(dn.sum())}; "
f"variant rank-sum of evoked rate, down vs up: medians {ev[dn].median():.2f} vs {ev[up].median():.2f}, p = {pv:.2g}")
# Regression to the mean: the control touch-evoked rate and the control AUC come from the same
# trials, so their noise is shared and the correlation with (eNpHR - control) AUC is biased
# negative. Control trials are split at random into halves: the evoked rate from one half, the
# control AUC from the other (reading b). (i) estimates the bias with no light at all, the AUC
# difference between the halves; (ii) is the claim's test without the shared trials.
rng = np.random.default_rng(14)
rows = []
for n in E.name:
c = NAME[n]
ctl, las = np.flatnonzero(ssc7.control_trials(c)), light_trials(c, "enphr")
perm = rng.permutation(ctl)
h1, h2 = np.zeros(len(las), bool), np.zeros(len(las), bool)
h1[perm[: len(perm) // 2]] = True
h2[perm[len(perm) // 2:]] = True
t1, b1 = touch_rates(c, h1)
rows.append(dict(name=n, ev1=t1 - b1, auc1=roc_cell(c, h1, "b", rng), auc2=roc_cell(c, h2, "b", rng), auc_las=roc_cell(c, las, "b", rng)))
SH = pd.DataFrame(rows).dropna()
r1 = stats.spearmanr(SH.ev1, SH.auc2 - SH.auc1)
r2 = stats.spearmanr(SH.ev1, SH.auc_las - SH.auc2)
print(f"split control trials, n = {len(SH)}: (i) no light, evoked rate (half 1) against AUC half 2 minus half 1: rho = {r1.statistic:.2f}, p = {r1.pvalue:.2g}; "
f"(ii) evoked rate (half 1) against eNpHR AUC minus control AUC (half 2): rho = {r2.statistic:.2f}, p = {r2.pvalue:.2g}")
# variant: the first touch of trials tagged passive kept as the trial's first touch (the rule of
# the first run of this notebook), readings (a) and (b)
n_pass = sum(int(sum("passive" in str(t) for t in (NAME[n].get("epoch_tag") or []))) for n in E.name)
for rd, seed in (("a", 16), ("b", 15)):
rng = np.random.default_rng(seed)
PV_ = pd.DataFrame([dict(name=n, a_ctl=roc_cell(NAME[n], ssc7.control_trials(NAME[n]), rd, rng, skip_passive=False),
a_las=roc_cell(NAME[n], light_trials(NAME[n], "enphr"), rd, rng, skip_passive=False)) for n in E.name]).merge(AUC[["name", "touch_ctl", "base_ctl"]])
PV_ = PV_.dropna()
r3 = stats.spearmanr(PV_.touch_ctl - PV_.base_ctl, PV_.a_las - PV_.a_ctl)
print(f"variant, passive first touches kept, M-ROC ({rd}), n = {len(PV_)}: rho = {r3.statistic:.2f}, p = {r3.pvalue:.2g}")
print("trials tagged passive in these neurons:", n_pass)
neurons without enough touch and no-touch trials for an AUC: 6 of 43 M-ROC (a), n = 37: AUC control median 0.599, eNpHR 0.655; Spearman (control touch-evoked rate, AUC change) rho = -0.23, p = 0.16; AUC up 17, down 20; variant rank-sum of evoked rate, down vs up: medians 0.66 vs 0.09, p = 0.1 M-ROC (b), n = 37: AUC control median 0.600, eNpHR 0.678; Spearman (control touch-evoked rate, AUC change) rho = -0.28, p = 0.09; AUC up 24, down 13; variant rank-sum of evoked rate, down vs up: medians 0.66 vs 0.37, p = 0.43
split control trials, n = 35: (i) no light, evoked rate (half 1) against AUC half 2 minus half 1: rho = 0.02, p = 0.91; (ii) evoked rate (half 1) against eNpHR AUC minus control AUC (half 2): rho = -0.19, p = 0.27
variant, passive first touches kept, M-ROC (a), n = 37: rho = -0.29, p = 0.086
variant, passive first touches kept, M-ROC (b), n = 37: rho = -0.34, p = 0.038 trials tagged passive in these neurons: 143
Result: not reproduced. With the first touch of trials tagged passive left out, as everywhere else in this notebook (an assumption), the AUC change correlates negatively with the control touch-evoked rate, but not significantly: Spearman rho = -0.23, p = 0.16 under M-ROC reading (a) and rho = -0.28, p = 0.09 under reading (b) (n = 37). The rank-sum variant is not significant either (p = 0.1 and 0.43). Keeping those passive first touches, as the first run of this notebook did, gives rho = -0.34, p = 0.038 under reading (b) and rho = -0.29, p = 0.086 under reading (a) (143 trials tagged passive in these neurons), so the outcome rests on that choice. Regression to the mean does not drive the correlation here: with control trials split in halves, the evoked rate of one half does not correlate with the AUC difference between the halves (rho = 0.02, p = 0.91). With the evoked rate and the control AUC taken from different halves, the claim's correlation is rho = -0.19, p = 0.27.
enphr-auc-groups¶
Of the 40 neurons, eNpHR stimulation increased AUC in 19 and reduced it in 21. Those with increased AUC raised their touch-evoked rates (3.4 +- 0.8 to 8.7 +- 1.9 spikes/s, P = 0.0001); those with reduced AUC kept their touch-evoked rates (7.3 +- 1.5 to 7.0 +- 1.4 spikes/s, P = 0.98) but raised their baseline rates (0.9 +- 0.2 to 2.6 +- 0.6 spikes/s, P = 0.0002).
exp = [(3.4, 0.8), (8.7, 1.9), (7.3, 1.5), (7.0, 1.4), (0.9, 0.2), (2.6, 0.6)]
for rd in "ab":
D = AUC.dropna(subset=[f"auc_ctl_{rd}", f"auc_las_{rd}", "touch_ctl", "touch_las"]).copy()
dA = D[f"auc_las_{rd}"] - D[f"auc_ctl_{rd}"]
for ev in ("a", "b"):
tc = D.touch_ctl if ev == "a" else D.touch_ctl - D.base_ctl
tl = D.touch_las if ev == "a" else D.touch_las - D.base_las
up, dn = (dA > 0).values, (dA < 0).values
p_up = stats.wilcoxon(tl[up], tc[up]).pvalue
p_dn = stats.wilcoxon(tl[dn], tc[dn]).pvalue
p_bs = stats.wilcoxon(D.base_las[dn], D.base_ctl[dn]).pvalue
vals = [tc[up].mean(), tl[up].mean(), tc[dn].mean(), tl[dn].mean(), D.base_ctl[dn].mean(), D.base_las[dn].mean()]
print(f"M-ROC ({rd}), touch rate ({'raw' if ev == 'a' else 'baseline-subtracted'}): up {int(up.sum())}, down {int(dn.sum())}; "
f"up group {vals[0]:.2f} -> {vals[1]:.2f} (p = {p_up:.2g}); down group {vals[2]:.2f} -> {vals[3]:.2f} (p = {p_dn:.2g}); "
f"down-group baseline {vals[4]:.2f} -> {vals[5]:.2f} (p = {p_bs:.2g}); within: {[within(v_, e, t) for v_, (e, t) in zip(vals, exp)]}, "
f"groups {within(up.sum(), 19, 1.9)}, {within(dn.sum(), 21, 2.1)}")
M-ROC (a), touch rate (raw): up 17, down 20; up group 2.04 -> 3.16 (p = 0.04); down group 5.33 -> 5.24 (p = 0.99); down-group baseline 3.53 -> 4.20 (p = 0.083); within: [False, False, False, False, False, False], groups False, True M-ROC (a), touch rate (baseline-subtracted): up 17, down 20; up group 0.44 -> 0.87 (p = 0.0067); down group 1.80 -> 1.04 (p = 0.0094); down-group baseline 3.53 -> 4.20 (p = 0.083); within: [False, False, False, False, False, False], groups False, True M-ROC (b), touch rate (raw): up 24, down 13; up group 3.50 -> 4.28 (p = 0.084); down group 4.41 -> 4.29 (p = 1); down-group baseline 2.89 -> 3.69 (p = 0.13); within: [True, False, False, False, False, False], groups False, False M-ROC (b), touch rate (baseline-subtracted): up 24, down 13; up group 0.99 -> 1.16 (p = 0.069); down group 1.52 -> 0.60 (p = 0.00073); down-group baseline 2.89 -> 3.69 (p = 0.13); within: [False, False, False, False, False, False], groups False, False
Result: not reproduced. The AUC rose in 17 and fell in 20 neurons (reading a), or 24 and 13 (reading b), against 19 and 21. Under no combination of readings are both group sizes and all six rates within tolerance; at most one rate is. With raw touch rates and reading (a), the increased-AUC group's touch-evoked rate rises from 2.04 to 3.16 spikes/s (p = 0.04), against 3.4 to 8.7, and the reduced-AUC group's baseline rise (3.53 to 4.20) is not significant (p = 0.083). Under reading (b) the increase is not significant (p = 0.069 to 0.084).
enphr-pv-latency¶
eNpHR stimulation strongly inhibits 3 of 4 recorded L4 PV interneurons; their spike rate falls 3 ms after laser onset and L4 excitatory activity rises only 2 ms later.
def onset_psth(c, tr, pre=0.05, post=0.1):
spk = ssc7.spikes_by_trial(c)
H, n = np.zeros(int((pre + post) * 1000)), 0
for i in np.flatnonzero(tr):
w = light_window(c, i, None)
if w is None:
continue
s = spk[i] - w[0]
H += np.histogram(s[(s >= -pre) & (s < post)], bins=len(H), range=(-pre, post))[0]
n += 1
return H / max(n, 1) * 1000, n
def psth_latency(rate, sign, reading, pre=0.05):
"""Readings: (1) dPSTH/dt crosses 3 s.d. of its values over the 25 ms before onset (M-LAT adapted);
(2) the rate crosses its baseline mean by 3 s.d. of the baseline rate. sign -1 for a decrease."""
z = int(pre * 1000)
if reading == 1:
d = np.diff(rate)
base = d[z - 25:z - 1]
k = np.flatnonzero(sign * (d[z:z + 50] - base.mean()) > 3 * base.std())
return np.nan if len(k) == 0 else float(k[0] + 1)
base = rate[z - 25:z]
k = np.flatnonzero(sign * (rate[z:z + 50] - base.mean()) > 3 * base.std())
return np.nan if len(k) == 0 else float(k[0])
pv = [n for n in FS if light_trials(NAME[n], "enphr").sum()]
strong = 0
for n in pv:
c = NAME[n]
las, ctl = light_trials(c, "enphr"), ssc7.control_trials(c)
lw = [light_window(c, i, None) for i in np.flatnonzero(las)]
med = (np.median([w[0] for w in lw]), np.median([w[1] for w in lw]))
spk = ssc7.spikes_by_trial(c)
rl = [np.sum((spk[i] >= w[0]) & (spk[i] < w[1])) / (w[1] - w[0]) for i, w in zip(np.flatnonzero(las), lw)]
rc = [np.sum((spk[i] >= med[0]) & (spk[i] < med[1])) / (med[1] - med[0]) for i in np.flatnonzero(ctl)]
p = stats.ranksums(rl, rc).pvalue
st_ = p < 0.05 and np.mean(rl) < 0.5 * np.mean(rc)
strong += st_
print(f"PV {n}: rate in the light window, control {np.mean(rc):.2f} (n={len(rc)}), light {np.mean(rl):.2f} (n={len(rl)}), ratio {np.mean(rl) / np.mean(rc):.2f}, rank-sum p = {p:.2g}; strongly inhibited: {st_}")
print("PV neurons strongly inhibited:", strong, "of", len(pv))
pv_rate = np.mean([onset_psth(NAME[n], light_trials(NAME[n], "enphr"))[0] for n in pv], 0)
e_rate = np.mean([onset_psth(NAME[n], light_trials(NAME[n], "enphr"))[0] for n in E.name], 0)
for rd in (1, 2):
lp = psth_latency(pv_rate, -1, rd)
le = psth_latency(e_rate, 1, rd)
print(f"reading ({rd}): PV decrease latency {lp} ms, L4E increase latency {le} ms, delay {le - lp} ms; within (3+-1, 2+-1): {within(lp, 3, 1)}, {within(le - lp, 2, 1)}")
print("PV grand-average rate (spikes/s), -5 to +10 ms:", pv_rate[45:61].round(1).tolist())
print("L4E grand-average rate (spikes/s), -5 to +10 ms:", e_rate[45:61].round(2).tolist())
PV Exp_2015-09-26_007_0001-0092: rate in the light window, control 22.17 (n=62), light 1.06 (n=24), ratio 0.05, rank-sum p = 9.7e-13; strongly inhibited: True PV JY1305AAAA: rate in the light window, control 14.90 (n=41), light 3.12 (n=26), ratio 0.21, rank-sum p = 1.8e-10; strongly inhibited: True PV Exp_2015-09-08_004_0001-0076: rate in the light window, control 7.93 (n=38), light 8.54 (n=35), ratio 1.08, rank-sum p = 0.64; strongly inhibited: False PV JY1406AAAA: rate in the light window, control 38.58 (n=42), light 3.33 (n=19), ratio 0.09, rank-sum p = 5.2e-10; strongly inhibited: True PV neurons strongly inhibited: 3 of 4
reading (1): PV decrease latency nan ms, L4E increase latency 17.0 ms, delay nan ms; within (3+-1, 2+-1): False, False reading (2): PV decrease latency nan ms, L4E increase latency 7.0 ms, delay nan ms; within (3+-1, 2+-1): False, False PV grand-average rate (spikes/s), -5 to +10 ms: [0.0, 29.9, 22.8, 23.6, 0.0, 9.6, 49.9, 36.7, 13.2, 0.0, 0.0, 0.0, 0.0, 7.1, 9.6, 0.0] L4E grand-average rate (spikes/s), -5 to +10 ms: [0.6, 2.57, 1.41, 2.23, 1.63, 3.26, 0.48, 0.48, 1.19, 1.87, 3.08, 3.86, 4.22, 3.29, 3.23, 7.0]
Result: partially reproduced. Three of the four PV neurons are strongly inhibited inside the light period: their rate falls to 0.05, 0.21 and 0.09 of control (rank-sum p < 1e-9). The fourth is unchanged (ratio 1.08, p = 0.64). Neither latency rule can read the latencies. The grand-average PV rate in 1 ms bins is sparse (several baseline bins at 0 spikes/s), so neither the dPSTH/dt rule nor the 3 s.d. rate rule finds the decrease. The L4 E increase crosses at 17 ms (dPSTH/dt) or 7 ms (rate). The 3 ms and the 2 ms delay are not reproduced.
enphr-behavior¶
With PV interneurons suppressed most mice (6 of 8) are more likely to report touch with the pole out of reach; in an example session the false alarm rate rose from 20% to 61%.
The data set holds the behavior of the recording sessions. The test is run on them: per mouse with eNpHR trials, the proportion correct in Nogo trials with and without light, pooled over the mouse's sessions, chi-squared test (Supplementary Fig. 14c legend).
rows = []
for c in cells:
n = ssc7.cell_name(c)
if GROUP[n] == "VPM" or light_trials(c, "enphr").sum() == 0:
continue
tt = c["trial_type"]
nogo = (tt[:, 2] + tt[:, 3]) > 0
las = light_trials(c, "enphr")
ctl = ssc7.control_trials(c)
rows.append(dict(mouse=c["meta"]["subject"], session=n, cr_ctl=int((nogo & ctl & (tt[:, 2] > 0)).sum()), fa_ctl=int((nogo & ctl & (tt[:, 3] > 0)).sum()),
cr_las=int((nogo & las & (tt[:, 2] > 0)).sum()), fa_las=int((nogo & las & (tt[:, 3] > 0)).sum())))
B = pd.DataFrame(rows)
M = B.groupby("mouse")[["cr_ctl", "fa_ctl", "cr_las", "fa_las"]].sum()
out = []
for m, r in M.iterrows():
tab = np.array([[r.cr_ctl, r.fa_ctl], [r.cr_las, r.fa_las]])
p = stats.chi2_contingency(tab)[1] if (tab.sum(0) > 0).all() and (tab.sum(1) > 0).all() else np.nan
pc, pl = r.cr_ctl / max(1, r.cr_ctl + r.fa_ctl), r.cr_las / max(1, r.cr_las + r.fa_las)
out.append(dict(mouse=m, nogo_correct_ctl=round(pc, 2), nogo_correct_light=round(pl, 2), n_ctl=r.cr_ctl + r.fa_ctl, n_light=r.cr_las + r.fa_las, p=p,
decrease=bool(p < 0.05 and pl < pc), increase=bool(p < 0.05 and pl > pc)))
O = pd.DataFrame(out)
print(O.to_string(index=False))
print(f"mice: {len(O)}; significant decrease in Nogo performance with light: {int(O.decrease.sum())}; significant increase: {int(O.increase.sum())}")
B["fa_rate_ctl"] = B.fa_ctl / (B.fa_ctl + B.cr_ctl)
B["fa_rate_las"] = B.fa_las / (B.fa_las + B.cr_las)
B["dist"] = (B.fa_rate_ctl - 0.20).abs() + (B.fa_rate_las - 0.61).abs()
print("sessions closest to the example (FA 20% -> 61%):")
print(B.sort_values("dist").head(3)[["mouse", "session", "fa_rate_ctl", "fa_rate_las", "fa_ctl", "cr_ctl", "fa_las", "cr_las"]].round(2).to_string(index=False))
# The paper has 8 mice; which 8 of these 9 (if any) cannot be told. Dropping each mouse in turn:
drop1 = [int(O[O.mouse != m].decrease.sum()) for m in O.mouse]
print("significant decreases with one mouse left out:", dict(zip(O.mouse, drop1)), "; range", min(drop1), "to", max(drop1), "; within 6 +- 1:", any(within(x, 6, 1) for x in drop1))
print("light trials as a share of Nogo trials per mouse:", (O.n_light / (O.n_light + O.n_ctl)).round(2).tolist())
# Are these the paper's behavior sessions? Light share of Nogo trials per session, and sessions per mouse
B["light_share"] = (B.fa_las + B.cr_las) / (B.fa_las + B.cr_las + B.fa_ctl + B.cr_ctl)
print("sessions per mouse:", B.groupby("mouse").size().to_dict())
print(f"light share of Nogo trials per session: min {B.light_share.min():.2f}, median {B.light_share.median():.2f}, max {B.light_share.max():.2f}; "
f"sessions with light in under 20% of Nogo trials: {int((B.light_share < 0.2).sum())} of {len(B)}")
mouse nogo_correct_ctl nogo_correct_light n_ctl n_light p decrease increase
ANM244024 0.80 0.69 200 181 1.939021e-02 True False
ANM244025 0.64 0.67 116 85 7.412077e-01 False False
ANM244028 0.90 0.63 154 67 5.509723e-06 True False
ANM266945 0.57 0.52 340 188 3.500878e-01 False False
ANM266951 0.80 0.50 5 2 1.000000e+00 False False
ANM300169 0.92 0.72 59 18 8.326500e-02 False False
ANM300170 0.90 0.38 86 32 2.190994e-08 True False
ANM300171 0.79 0.88 77 66 2.474076e-01 False False
ANM300172 0.89 0.75 137 96 8.060011e-03 True False
mice: 9; significant decrease in Nogo performance with light: 4; significant increase: 0
sessions closest to the example (FA 20% -> 61%):
mouse session fa_rate_ctl fa_rate_las fa_ctl cr_ctl fa_las cr_las
ANM244028 JY1247AAAB 0.14 0.58 7 43 14 10
ANM266951 JY1345AAAA 0.20 0.50 1 4 1 1
ANM300169 Exp_2015-09-26_006_0042-0082 0.07 0.67 1 13 2 1
significant decreases with one mouse left out: {'ANM244024': 3, 'ANM244025': 4, 'ANM244028': 3, 'ANM266945': 4, 'ANM266951': 4, 'ANM300169': 4, 'ANM300170': 3, 'ANM300171': 4, 'ANM300172': 3} ; range 3 to 4 ; within 6 +- 1: False
light trials as a share of Nogo trials per mouse: [0.48, 0.42, 0.3, 0.36, 0.29, 0.23, 0.27, 0.46, 0.41]
sessions per mouse: {'ANM244024': 9, 'ANM244025': 5, 'ANM244028': 5, 'ANM266945': 11, 'ANM266951': 1, 'ANM300169': 3, 'ANM300170': 3, 'ANM300171': 4, 'ANM300172': 6}
light share of Nogo trials per session: min 0.14, median 0.37, max 0.70; sessions with light in under 20% of Nogo trials: 3 of 47
Result: not reproduced. In the recording sessions of the 9 mice with eNpHR trials, 4 show a significant decrease in Nogo performance with light (chi-squared p < 0.05) and none an increase, against 6 of 8 and 1. Leaving out any one mouse gives 3 or 4, so no 8 of these 9 mice match. No session matches the example's false alarm rates (20% to 61%); the closest goes from 14% to 58% (JY1247). The outcome rests on an assumption (marked in the attempt record): that the recording sessions held here are the sessions of Supplementary Fig. 14. The paper does not say which sessions it used, and the data set holds no other behavior with eNpHR light. Against the assumption: here there are 9 mice, not 8, and no session matches the example. For it: one mouse (ANM266951) has 7 Nogo trials in one session and cannot give a significant result, so the paper's 8 mice may be these less that one, and some sessions have light in a small share of Nogo trials (per session 14% to 70%, median 37%; 3 of 47 under 20%; per mouse 23% to 48%). Leaving ANM266951 out still gives 4 decreases, not 6 +- 1. Since the data set may well hold the paper's sessions, the claim is kept as tested and not blocked.
Blocked claims¶
l4e-inhibition-windowandl4e-whisking-inhibition(Fig. 3): data missing. The six neurons recorded at rest and depolarized near 0 mV by current injection are not in the data set. No trial of a whole-cell L4 E neuron, JY0978 (the cell list's Fig. 3 example) included, has a median Vm above -42.8 mV, and their largest stored current is 0.2 nA. Every ephys trial is read (the counts match the whisker trials). The only trials near 0 mV are the first 18 of the FS neuron JY1139, which keeps firing in them with no current above 0.1 nA: a drifting recording, not the protocol of Fig. 3, which inactivates spikes with about 1 nA. The FS neuron JY1171 carries a steady current above 0.5 nA in every trial at a median Vm of -40.7 mV, also not that protocol. No part of either claim can be tested (printed below).thalamus-inhibition-vpm: data missing (above).rabies-vpm-input: data missing. The data set holds no histology.ion-cut-l5-fs: data missing. The paper shows no data ("data not shown"), and the ION-cut folders hold only L4 neurons (depths are not stored in the cell-attached files; the cell list gives 444 to 614 um for the ION-cut FS neurons).
dep = {}
for c in cells:
if c["vm"] is None:
continue
med = c["ephys_trials"]["median_vm"]
cur = c["ephys_trials"]["max_abs_current"]
dep[ssc7.cell_name(c)] = (GROUP[ssc7.cell_name(c)], float(np.nanmax(med)), float(np.nanmax(cur)))
D = pd.DataFrame(dep, index=["group", "max_trial_median_vm", "max_abs_current_nA"]).T
print("largest per-trial median Vm by group (mV), over every ephys trial:", D.groupby("group").max_trial_median_vm.max().round(1).to_dict())
print("largest stored current (nA) by group:", D.groupby("group").max_abs_current_nA.max().round(3).to_dict())
print("JY0978 (the cell list's Fig. 3 example):", WCT[WCT.name.str.startswith("JY0978")].to_string(index=False))
# The one neuron with trials near 0 mV: JY1139 (FS folder; cell list FS sheet, PV-ChR2 mouse)
c = NAME["JY1139AAAA"]
med = c["ephys_trials"]["median_vm"]
spk = ssc7.spikes_by_trial(c)
hi = np.flatnonzero(med > -30)
print(f"JY1139: trials with median Vm above -30 mV: {hi.tolist()} (median Vm {med[hi].round(1).tolist()}); spikes in those trials {[len(spk[i]) for i in hi]}; "
f"largest |current| in them {np.nanmax(c['ephys_trials']['max_abs_current'][hi]):.4f} nA; median Vm of trials 20 on {np.median(med[20:]):.1f} mV")
# neurons with currents above 0.5 nA: how much of each trial
for n in WCT[WCT.max_abs_current_nA > 0.5].name:
cc = NAME[n]
big = np.nansum(np.abs(cc["current"]) > 0.5, 1)
print(f"{n} ({GROUP[n]}): trials with any 1 ms bin above 0.5 nA {int((big > 0).sum())} of {len(big)}; most bins above 0.5 nA in one trial {int(big.max())} ms; "
f"median Vm of those trials {np.median(cc['ephys_trials']['median_vm'][big > 0]):.1f} mV")
dep_ion_fs = pd.to_numeric(CL[CL.section == "FS neurons, ION cut"].depth, errors="coerce")
print(f"cell list depths of the ION-cut FS neurons: {dep_ion_fs.min():.0f} to {dep_ion_fs.max():.0f} um (n = {dep_ion_fs.notna().sum()})")
largest per-trial median Vm by group (mV), over every ephys trial: {'FS_wc': -2.3, 'L4E_ion': -55.7, 'L4E_wc': -42.8}
largest stored current (nA) by group: {'FS_wc': 1.996, 'L4E_ion': 3.034, 'L4E_wc': 0.202}
JY0978 (the cell list's Fig. 3 example): group name n_trials n_ephys_trials median_vm max_trial_median_vm trials_above_minus30 max_abs_current_nA trials_far_from_median
L4E_wc JY0978AAAA 115 115 -72.0 -66.0 0 0.0 0
JY1139: trials with median Vm above -30 mV: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17] (median Vm [-2.3, -2.9, -2.7, -2.4, -2.5, -2.8, -3.0, -4.7, -7.9, -18.7, -12.7, -14.0, -23.1, -22.8, -26.8, -23.7, -18.0, -26.6]); spikes in those trials [13, 9, 16, 10, 15, 8, 16, 22, 19, 26, 18, 85, 82, 71, 26, 38, 28, 32]; largest |current| in them 0.1011 nA; median Vm of trials 20 on -40.8 mV
JY1171AAAI (FS_wc): trials with any 1 ms bin above 0.5 nA 86 of 86; most bins above 0.5 nA in one trial 2230 ms; median Vm of those trials -40.7 mV
Exp_2015-11-25_008_0002-0050 (L4E_ion): trials with any 1 ms bin above 0.5 nA 0 of 32; most bins above 0.5 nA in one trial 0 ms; median Vm of those trials nan mV
Exp_2015-11-27_002_0001-0082 (L4E_ion): trials with any 1 ms bin above 0.5 nA 0 of 51; most bins above 0.5 nA in one trial 0 ms; median Vm of those trials nan mV
Exp_2015-11-27_008_0001-0087 (L4E_ion): trials with any 1 ms bin above 0.5 nA 0 of 51; most bins above 0.5 nA in one trial 0 ms; median Vm of those trials nan mV
Exp_2015-11-25_010_0001-0131 (L4E_ion): trials with any 1 ms bin above 0.5 nA 0 of 115; most bins above 0.5 nA in one trial 0 ms; median Vm of those trials nan mV
Exp_2015-11-25_001_0001-0027 (L4E_ion): trials with any 1 ms bin above 0.5 nA 0 of 19; most bins above 0.5 nA in one trial 0 ms; median Vm of those trials nan mV
Exp_2015-11-25_006_0001-0066 (L4E_ion): trials with any 1 ms bin above 0.5 nA 0 of 59; most bins above 0.5 nA in one trial 0 ms; median Vm of those trials nan mV
Exp_2015-11-27_009_0001-0069 (L4E_ion): trials with any 1 ms bin above 0.5 nA 0 of 35; most bins above 0.5 nA in one trial 0 ms; median Vm of those trials nan mV
Exp_2015-11-27_003_0001-0033 (L4E_ion): trials with any 1 ms bin above 0.5 nA 0 of 20; most bins above 0.5 nA in one trial 0 ms; median Vm of those trials nan mV
cell list depths of the ION-cut FS neurons: 444 to 614 um (n = 10)
Summary¶
A failure to reproduce here may be a failure of this attempt, not of the paper: see the reasoning and the differences from the paper's method.
Of 48 claims, 43 were tested and 5 blocked. Of those tested, 24 reproduced, 13 partially reproduced and 6 did not reproduce.
| Claim | Outcome |
|---|---|
| behavior-performance | partially reproduced (assumed) |
| vpm-baseline-rate | partially reproduced |
| vpm-touch-response | partially reproduced |
| vpm-whisking-count | reproduced |
| vpm-whisking-rate | reproduced |
| vpm-phase-modulation | reproduced |
| vpm-rate-amplitude-trials | reproduced |
| l4e-example-e1 | reproduced |
| l4e-example-e24-e32 | reproduced |
| l4e-resting-vm | reproduced |
| l4e-touch-psp | partially reproduced |
| l4e-whisking-vm | reproduced |
| l4e-distance-threshold | partially reproduced |
| l4e-reversal-potential | reproduced |
| l4e-hf-fluctuations | reproduced |
| l4e-inhibition-window | blocked: data missing |
| l4e-whisking-inhibition | blocked: data missing |
| fs-baseline-rate | reproduced |
| fs-touch-vm | reproduced (assumed) |
| fs-touch-spikes | partially reproduced (assumed) |
| fs-whisking-count | reproduced |
| fs-whisking-vm | partially reproduced |
| fs-whisking-rate | reproduced |
| fs-phase-coupling | partially reproduced |
| fs-hf-fluctuations | reproduced |
| l4e-spikes-touch-selective | not reproduced |
| thalamus-inhibition-vpm | blocked: data missing |
| thalamus-inhibition-l4e-vm | partially reproduced (assumed) |
| thalamus-inhibition-fs | partially reproduced |
| thalamus-inhibition-dose | reproduced |
| rabies-vpm-input | blocked: data missing |
| ion-cut-behavior | reproduced |
| ion-cut-l4e-touch | not reproduced |
| ion-cut-l4e-whisking | partially reproduced |
| ion-cut-l4e-phase | reproduced |
| ion-cut-l4e-spectra | reproduced |
| ion-cut-fs-touch | reproduced |
| ion-cut-fs-whisking | reproduced |
| ion-cut-fs-phase | reproduced |
| ion-cut-l5-fs | blocked: data missing |
| enphr-kruskal-wallis | reproduced |
| enphr-l4e-rates | partially reproduced |
| enphr-whisking-driven | reproduced |
| enphr-spikes-per-touch | not reproduced |
| enphr-auc | not reproduced (assumed) |
| enphr-auc-groups | not reproduced |
| enphr-pv-latency | partially reproduced |
| enphr-behavior | not reproduced (assumed) |
Three tests fixed by the claims file cannot tell the effect from its null well, and are asked of a reader: ion-cut-l4e-touch (a peak measure tested against zero is positive with no response), thalamus-inhibition-dose (with control as zero power, the correlation mostly tests light against no light) and enphr-auc (the evoked rate and the control AUC share their trials; here the split-half check finds no bias).
How the analysis differs from the paper's¶
- The principal whisker of cortical files with two tracked whiskers is taken to be the first series, as the data set's example code takes it. The files do not say.
- Light trials are told apart by the photostimulus series that is on in each trial (its site and wavelength), mapped to the three experiments of the Online Methods. Light effects are measured inside each trial's light period (M-LIGHT reading a), with whole trials as reading (b).
- The light-onset latency rule of the claims file finds a crossing at the onset sample itself, where the light produces a step in the average Vm. A variant with 1 ms smoothing and a 1 ms hold is used as an assumption.
- The touch-speed cutoff of the example code (
prct_speed) is not applied. Touches are not split by direction. - Spike thresholds come from the data set's spike times, searched back to the dVm/dt crossing. For neurons with few spikes the threshold line extrapolates far; a line held at its end values and a per-neuron threshold are shown as variants.
- Whole-cell trials whose median Vm lies more than 20 mV from the neuron's median are left out of the Vm measures (13 trials of JY1139, an FS recording that drifts from near 0 mV), an assumption after the Methods' rejection of drifting recordings.
- In whisking-onset windows, Vm after a later touch is set to NaN (M-EPOCH). Two outcomes sit at their margins because of it: l4e-reversal-potential (4.9 against 5 mV) and ion-cut-l4e-whisking (control mean 1.337 against a bound of 1.34).
- The first touch of trials tagged passive is left out everywhere, the ROC of enphr-auc included; enphr-auc reproduces only with those touches kept, and only under M-ROC reading (b) (p = 0.038; reading (a) gives p = 0.086).
- fs-touch-vm rests on series 1 as the principal whisker: the configuration order changes one FS neuron (JY1171) and moves the latency mean outside tolerance.
- enphr-behavior is tested on the recording sessions, assumed to be the sessions of Supplementary Fig. 14; the paper does not say, and 9 mice are found where it has 8.
- Where the claims file lists readings, every reading is shown, and the outcome is the one the criterion gives under them.
What was found about the data set¶
- The whisker timestamps of the cortical files mix units: the trial start is in milliseconds and the time within a trial in seconds.
- Which tracked whisker series is the principal whisker is not recorded. For the FS neurons the
order of
whisker_configurationpicks a series with almost no touch response; for several L4 E neurons (JY1345, Exp_2015-09-04_001, Exp_2015-08-28_003) it picks the series with the larger response. Neither reading is confirmed; series 1 is used. - The thalamic multiunit recordings under TRN-axon photostimulation, the rabies tracing, the L5 FS neurons after ION cut and the recordings with depolarizing current injection are not in the data set. The behavior sessions of Supplementary Fig. 14 may not be either: the recording sessions give 9 mice where the paper has 8.
- Eight whole-cell L4 E files flag 132 stimulus trials but hold no photostimulus series, and two more have 23 flagged trials without light in their series.
- The neuron JY1139 in the whole-cell FS folder is described in its file as "Excitatory", and its first 18 trials sit near 0 mV while it fires, with no current injected.
- The cell list does not name JY1268, in the cell-attached L4 E folder, and it counts JY0781 among the PV-IRES-Cre L4 E neurons, though its file holds no eNpHR light.
- The eNpHR experiments hold 43 L4 E neurons with constant-light trials, against the paper's 40.