Reproducing Li, Chen, Guo, Gerfen & Svoboda (2015) from CRCNS alm-1¶
Paper. Li N, Chen T-W, Guo ZV, Gerfen CR, Svoboda K (2015). A motor cortex circuit for motor
planning and movement. Nature 519, 51-56.
doi:10.1038/nature14178. The claims file
(claims/crcns-alm-1/10.1038-nature14178.yaml) was written from the version of record (main
text, Methods and the legends of Figures 1 to 5 and Extended Data Figures 1 to 7).
Data set. CRCNS alm-1, "Extracellular recordings from anterior lateral motor cortex (ALM)
neurons of adult mice performing a tactile decision behavior",
doi:10.6080/K0RF5RZT, read from the public bucket
crcnsarchive under alm-1/live/. Version: unversioned. CRCNS data sets have no versions;
the bucket holds alm-1/live/ (the data) and alm-1/version_1/ and alm-1/version_2/, which
hold only earlier copies of the documentation, and alm-1/live/old/, three example sessions
that the data description says are superseded. The paper cites no version, so the only
published copy of the data, live, is used. A later change can be detected with the MD5 sums
of the files read, from the data set's checksums.md5 (checked against the bucket below):
| file | MD5 |
|---|---|
| datafiles/meta_data_files.tar.gz | cfacee06a26e5252ff22c922cab6e728 |
| datafiles/data_structure_files/data_structure_ANM210861.tar.gz | ffc4cd8784c52d59509dec395f4dca6c |
| datafiles/data_structure_files/data_structure_ANM210862.tar.gz | 455903de0b4efbbe3b6702d096001fd0 |
| datafiles/data_structure_files/data_structure_ANM210863.tar.gz | a7ff42aed79240ce6522decd5a378bcc |
| datafiles/data_structure_files/data_structure_ANM214427.tar.gz | 6506e8e3e5426af5e6aae2a7d4be020f |
| datafiles/data_structure_files/data_structure_ANM214429.tar.gz | 72e04c6020096fc38de13b4e34d9a2f2 |
| datafiles/data_structure_files/data_structure_ANM214430.tar.gz | 52747848292c53270f69093dd0aa72be |
| datafiles/data_structure_files/data_structure_ANM218453.tar.gz | dbec672edde54c4fdf15a57ec1153deb |
| datafiles/data_structure_files/data_structure_ANM218457.tar.gz | 4ab95446cc36e12debe2c85b86ec6ecc |
| datafiles/data_structure_files/data_structure_ANM218693.tar.gz | 62ff3d44e9fd34c094d7e16cc27d14ad |
| datafiles/data_structure_files/data_structure_ANM219030.tar.gz | 8d71cd3922820875730d56946e39f2be |
| datafiles/data_structure_files/data_structure_ANM219031.tar.gz | ef87eff90c4ed2aff67f5260acd0cc8c |
| datafiles/data_structure_files/data_structure_ANM219033.tar.gz | 29493ad8cce197c3f01c1ee117bedd26 |
| datafiles/data_structure_files/data_structure_ANM219036.tar.gz | 146b101d61fa9628cd3da54f279664c4 |
| datafiles/data_structure_files/data_structure_ANM219037.tar.gz | 73f788942ec903eebd048001b2f4db6f |
| datafiles/data_structure_files/data_structure_ANM219038.tar.gz | 5aca92550f1707fa5c0a82fe80b2ab4f |
| datafiles/data_structure_files/data_structure_ANM219247.tar.gz | 234db2241f25af06233ad58fcf101c73 |
| datafiles/data_structure_files/data_structure_ANM219248.tar.gz | e2cae036a2b333cb3a06eeb691093468 |
| datafiles/data_structure_files/data_structure_ANM219253.tar.gz | 4f118c0085d3011a7ff6d0f35f298bf9 |
| datafiles/data_structure_files/data_structure_ANM221977.tar.gz | 44ceb341033227f98693e39c7103527a |
The session files (MATLAB "data structure" files, one tar.gz per animal) are used. The same
sessions are also in NWB 1.0 files, which lack the photostimulation type, the AOM and laser
power traces and the GoodTrials flag, so they are not used. The raw voltage traces
(about 800 GB) are not read. The data set also holds the authors' MATLAB scripts that
"reproduce the figures" and their compiled output (ALM_compiled_all_data.mat); the output is
not read. The scripts are cited below where the paper leaves a detail open.
What the data set holds. The electrophysiology of Figures 2 and 3 and Extended Data Figures 1, 2 and 5: 99 sessions from 19 mice, 1,408 units with cell type labels, trial types, epoch times, photostimulation type per trial, and the lick, AOM and laser power traces. The photoinhibition and photoactivation behaviour (Figs 1 and 5, ED Figs 3 and 6), the imaging (Fig. 4), the anatomy (ED Fig. 3) and the recordings with somatic PT photoactivation (ED Fig. 7) are not in it.
| claim | tested |
|---|---|
| fig1d-photoinhibition-ipsilateral-bias | blocked, data missing |
| fig1d-sample-epoch-smaller-bias | blocked, data missing |
| task-performance | tested, on the 19 electrophysiology mice |
| unit-counts | tested |
| fig2-selective-fraction | tested |
| fig2d-response-categories | tested |
| fig2c-selectivity-time-course | tested |
| fig2c-dynamic-single-neurons | tested |
| ed2-error-trials-predict-choice | tested |
| fig2e-equal-contra-ipsi | tested |
| ed1-no-population-contra-bias | tested |
| ed1-fast-spiking-properties | tested |
| tagging-counts | tested |
| antidromic-latency-jitter | tested |
| ed5g-it-second-pulse-jitter | tested |
| fig3ei-both-types-preparatory-and-movement | tested |
| fig3fj-contra-preferring-pt-not-it | tested |
| fig3f-late-contra-selectivity-pt | tested |
| reaction-time | tested; blocked, methods underspecified |
| fig4-imaging-intermingled | blocked, data missing |
| fig4h-imaging-pt-contra-bias | blocked, data missing |
| imaging-overall-counts | blocked, data missing |
| contra-ipsi-selectivity-forms | tested |
| fig5-pt-activation-contralateral-bias | blocked, data missing |
| ed6b-pt-dose-response | blocked, data missing |
| ed6d-it-activation-inconsistent | blocked, data missing |
| ed3-high-power-contralateral-licking | blocked, data missing |
| ed3d-non-overlapping-it-pt | blocked, data missing |
| ed7-pt-stimulation-persistent-activity | blocked, data missing |
Lick right trials are contralateral to the recorded left ALM. "R" and "L" below are lick right and lick left trials. Loading streams about 14 GB and takes about four minutes.
import time
import warnings
from collections import Counter
import fsspec
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from scipy import stats
import alm
pd.set_option("display.width", 200)
pd.set_option("display.max_columns", 40)
pd.set_option("display.max_rows", 200)
warnings.filterwarnings("ignore", category=RuntimeWarning)
started = time.time()
S = alm.load_all(workers=4)
meta = alm.load_meta()
print(f"{alm.DATASET} ({alm.VERSION}, doi:{alm.DATASET_DOI}): {len(S)} sessions streamed in {time.time() - started:.0f} s")
crcns:alm-1 (unversioned, doi:10.6080/K0RF5RZT): 99 sessions streamed in 305 s
Data check¶
with fsspec.open(alm.BASE + "checksums.md5", "rt") as fh:
md5 = dict(line.split()[::-1] for line in fh if line.strip())
read = ["datafiles/meta_data_files.tar.gz"] + [f"datafiles/data_structure_files/data_structure_{a}.tar.gz" for a in alm.ANIMALS]
print("MD5 sums on the bucket now (compare with the header):")
for f in read:
print(f" {md5.get(f)} {f}")
T = pd.concat([s["trials"] for s in S], ignore_index=True)
units = [(s, u) for s in S for u in s["units"]]
meta["animal"] = meta.session.str[:9]
geno = meta.groupby("animal").agg(strain=("strain", "first"), gene=("gene", "first"), sessions=("session", "size"),
photostim_location=("photostim_location", "first"))
per_animal = pd.DataFrame({
"sessions": pd.Series(Counter(s["animal"] for s in S)),
"units": pd.Series(Counter(s["animal"] for s, u in units)),
"trials": T.groupby("animal").size()})
print(per_animal.join(geno[["strain", "gene", "photostim_location"]]).to_string())
print(f"\nAnimals {len(per_animal)}, sessions {len(S)}, units {len(units)} (data description: 19 animals, 99 sessions, 1,408 units)")
print("Meta data files:", len(meta), "; sessions with a meta data file:", len(set(meta.session) & {s['session'] for s in S}))
print("Strains (paper, Methods: 9 Sim1_KJ18-Cre, 3 Rbp4-Cre, 4 Tlx_PL56-Cre injected; 1 Sim1 x Ai32, 2 Tlx x Ai32):")
print(geno.groupby(["strain", "gene"]).size().to_string())
MD5 sums on the bucket now (compare with the header):
cfacee06a26e5252ff22c922cab6e728 datafiles/meta_data_files.tar.gz
ffc4cd8784c52d59509dec395f4dca6c datafiles/data_structure_files/data_structure_ANM210861.tar.gz
455903de0b4efbbe3b6702d096001fd0 datafiles/data_structure_files/data_structure_ANM210862.tar.gz
a7ff42aed79240ce6522decd5a378bcc datafiles/data_structure_files/data_structure_ANM210863.tar.gz
6506e8e3e5426af5e6aae2a7d4be020f datafiles/data_structure_files/data_structure_ANM214427.tar.gz
72e04c6020096fc38de13b4e34d9a2f2 datafiles/data_structure_files/data_structure_ANM214429.tar.gz
52747848292c53270f69093dd0aa72be datafiles/data_structure_files/data_structure_ANM214430.tar.gz
dbec672edde54c4fdf15a57ec1153deb datafiles/data_structure_files/data_structure_ANM218453.tar.gz
4ab95446cc36e12debe2c85b86ec6ecc datafiles/data_structure_files/data_structure_ANM218457.tar.gz
62ff3d44e9fd34c094d7e16cc27d14ad datafiles/data_structure_files/data_structure_ANM218693.tar.gz
8d71cd3922820875730d56946e39f2be datafiles/data_structure_files/data_structure_ANM219030.tar.gz
ef87eff90c4ed2aff67f5260acd0cc8c datafiles/data_structure_files/data_structure_ANM219031.tar.gz
29493ad8cce197c3f01c1ee117bedd26 datafiles/data_structure_files/data_structure_ANM219033.tar.gz
146b101d61fa9628cd3da54f279664c4 datafiles/data_structure_files/data_structure_ANM219036.tar.gz
73f788942ec903eebd048001b2f4db6f datafiles/data_structure_files/data_structure_ANM219037.tar.gz
5aca92550f1707fa5c0a82fe80b2ab4f datafiles/data_structure_files/data_structure_ANM219038.tar.gz
234db2241f25af06233ad58fcf101c73 datafiles/data_structure_files/data_structure_ANM219247.tar.gz
e2cae036a2b333cb3a06eeb691093468 datafiles/data_structure_files/data_structure_ANM219248.tar.gz
4f118c0085d3011a7ff6d0f35f298bf9 datafiles/data_structure_files/data_structure_ANM219253.tar.gz
44ceb341033227f98693e39c7103527a datafiles/data_structure_files/data_structure_ANM221977.tar.gz
sessions units trials strain gene photostim_location
ANM210861 3 58 1290 kj18 sim1-cre PONS/ALM
ANM210862 3 53 971 kj18 sim1-cre PONS/ALM
ANM210863 3 90 1031 kj18 sim1-cre PONS/ALM
ANM214427 4 26 1485 kl100 rbp4-cre ALM/PONS/ALM
ANM214429 4 48 2051 kl100 rbp4-cre ALM/PONS/ALM
ANM214430 4 42 1245 kl100 rbp4-cre ALM/PONS/ALM
ANM218453 5 54 1566 pl56/ai32 tlx-cre/chr2-eyfp
ANM218457 6 118 1906 pl56/ai32 tlx-cre/chr2-eyfp
ANM218693 3 59 1022 kj18/ai32 sim1-cre/chr2-eyfp
ANM219030 5 57 1676 kj18 sim1-cre PONS/ALM
ANM219031 5 93 1487 kj18 sim1-cre PONS/ALM
ANM219033 7 57 2069 kj18 sim1-cre PONS/ALM
ANM219036 7 97 1840 kj18 sim1-cre PONS/ALM
ANM219037 7 100 2209 kj18 sim1-cre PONS/ALM
ANM219038 8 119 2420 kj18 sim1-cre PONS/ALM
ANM219247 5 60 1690 pl56 tlx-cre ALM/ALM
ANM219248 7 148 2740 pl56 tlx-cre ALM/ALM
ANM219253 10 93 1811 pl56 tlx-cre ALM/ALM
ANM221977 3 36 930 pl56 tlx-cre ALM/ALM
Animals 19, sessions 99, units 1408 (data description: 19 animals, 99 sessions, 1,408 units)
Meta data files: 99 ; sessions with a meta data file: 99
Strains (paper, Methods: 9 Sim1_KJ18-Cre, 3 Rbp4-Cre, 4 Tlx_PL56-Cre injected; 1 Sim1 x Ai32, 2 Tlx x Ai32):
strain gene
kj18 sim1-cre 9
kj18/ai32 sim1-cre/chr2-eyfp 1
kl100 rbp4-cre 3
pl56 tlx-cre 4
pl56/ai32 tlx-cre/chr2-eyfp 2
# The lines of the data set's own MATLAB scripts that the notebook cites, streamed from the bucket.
cite = {"matlab_scripts/analyses_scripts/analysis_compile_all_data.m": [(124, 127), (132, 137), (217, 221), (299, 300), (352, 352), (485, 485)],
"matlab_scripts/analyses_scripts/analysis_ALM_IT_PT_selectivity.m": [(25, 25), (170, 170), (195, 195)],
"matlab_scripts/analyses_scripts/analysis_ALM_error_trial_selectivity.m": [(99, 100)],
"matlab_scripts/demos/Demo_get_performance.m": [(70, 73)]}
for f, spans in cite.items():
with fsspec.open(alm.BASE + f, "rt", encoding="latin-1") as fh:
lines = fh.read().splitlines()
print(f"== {f}")
for a, b in spans:
for i in range(a, b + 1):
print(f"{i:4d}: {lines[i - 1].strip()[:150]}")
== matlab_scripts/analyses_scripts/analysis_compile_all_data.m 124: % index stable trials 125: unit_stable_trials_tmp = zeros(trialID(end),1); 126: i_stable_trials = min(unit.eventTrials):min([max(unit.eventTrials) trialID(end)]); 127: unit_stable_trials_tmp(i_stable_trials) = 1; 132: i_yes_trial_correct = find(HitR==1 & Photostim_type==0 & unit_stable_trials_tmp==1 & LickEarly==0 & GoodTrials==1); 133: i_no_trial_correct = find(HitL==1 & Photostim_type==0 & unit_stable_trials_tmp==1 & LickEarly==0 & GoodTrials==1); 134: i_yes_trial_error = find((ErrR==1) & Photostim_type==0 & unit_stable_trials_tmp==1 & LickEarly==0 & GoodTrials==1); 135: i_no_trial_error = find((ErrL==1) & Photostim_type==0 & unit_stable_trials_tmp==1 & LickEarly==0 & GoodTrials==1); 136: 137: i_stim_tagging = find((Photostim_type==1 | Photostim_type==2 | Photostim_type==3 | Photostim_type==4 | Photostim_type==5) & unit_stable_trials_tmp==1 217: spk_count_yes(n_trial,1) = sum(spike_times_iTrial>Pole_in_Time(i_trial,1) & spike_times_iTrial<Pole_out_Time(i_trial,1))/(Pole_out_Time(i_trial,1)-Pol 218: spk_count_yes(n_trial,2) = sum(spike_times_iTrial>Pole_out_Time(i_trial,1) & spike_times_iTrial<Cue_Time(i_trial,1))/(Cue_Time(i_trial,1)-Pole_out_Tim 219: spk_count_yes(n_trial,3) = sum(spike_times_iTrial>Cue_Time(i_trial,1) & spike_times_iTrial<Cue_Time(i_trial,1)+1.3)/(1.3); 220: spk_count_yes(n_trial,4) = sum(spike_times_iTrial>Pole_in_Time(i_trial,1) & spike_times_iTrial<Cue_Time(i_trial,1)+1.3)/(Cue_Time(i_trial,1)+1.3-Pole_ 221: spk_count_yes(n_trial,5) = sum(spike_times_iTrial>Pole_in_Time(i_trial,1)-.5 & spike_times_iTrial<Pole_in_Time(i_trial,1))/(.5); 299: if ~isempty(spk_count_yes) & ~isempty(spk_count_no) 300: sample_selective = ttest2(spk_count_yes,spk_count_no); 352: if length(i_yes_trial_correct)>15 & length(i_no_trial_correct)>15 485: waveform_all(n_unit,:) = mean(unit.waveforms);
== matlab_scripts/analyses_scripts/analysis_ALM_IT_PT_selectivity.m 25: i_select_cell = (sig_selective(:,1) | sig_selective(:,2) | sig_selective(:,3)) & cellType_all(:,1)==1 & N_trials_all(:,1)>15 & N_trials_all(:,2)>15; 170: i_sel_cell = find(sum(sig_selective,2)>0 & cellType_all(:,2)==1); 195: i_sel_cell = find(sum(sig_selective,2)>0 & cellType_all(:,2)==3);
== matlab_scripts/analyses_scripts/analysis_ALM_error_trial_selectivity.m 99: i_selective = (sig_selective(:,1)|sig_selective(:,2)|sig_selective(:,3)) & cellType_all(:,1)==1; 100: i_n_trial = N_trials_all(:,1)>10 & N_trials_all(:,2)>10 & N_trials_all(:,3)>5 & N_trials_all(:,4)>5;
== matlab_scripts/demos/Demo_get_performance.m 70: fracCorrect = sum((HitR|HitL) & ~StimTrials & ~LickEarly & GoodTrials)/sum((HitR|ErrR|HitL|ErrL) & ~StimTrials & ~LickEarly & GoodTrials); 71: fracCorrectR = sum(HitR & ~StimTrials & ~LickEarly & GoodTrials)/sum((HitR|ErrR) & ~StimTrials & ~LickEarly & GoodTrials); 72: fracCorrectL = sum(HitL & ~StimTrials & ~LickEarly & GoodTrials)/sum((HitL|ErrL) & ~StimTrials & ~LickEarly & GoodTrials); 73: fracEarlyLick = sum(LickEarly & ~StimTrials & GoodTrials)/sum((HitR|ErrR|HitL|ErrL|LickEarly|i_NoLickR|i_NoLickL) & ~StimTrials & GoodTrials);
print("Trials:", len(T))
print("\nPhotostimulationType (description: 0 none, 1 PT axonal, 2 IT axonal, NaN do not analyse):")
print(T.ptype.value_counts(dropna=False).sort_index().to_string())
print("\nGoodTrials:", T.good.value_counts().to_dict())
T["has_light"] = T.aom_max > alm.AOM_MIN
print("\nLight pulses by photostimulation type (per trial medians):")
print(T.groupby(T.ptype.fillna(-1)).agg(trials=("has_light", "size"), with_light=("has_light", "sum"),
pulses=("n_pulses", "median"), pulse_ms=("pulse_ms", "median"), power_mW=("power_max", "median"),
first_onset_s=("stim_on", "median")).rename_axis("ptype (-1 = NaN)").round(2).to_string())
bad0 = T[(T.ptype == 0) & T.has_light]
print("\nTrials of type 0 (no stimulation) with light pulses:", len(bad0), "in sessions", bad0.session.value_counts().to_dict())
print("Those trials, per trial:")
print(bad0[["n_pulses", "pulse_ms", "power_max", "stim_on"]].describe().loc[["count", "min", "50%", "max"]].round(3).to_string())
t35 = T[T.ptype.isin([3, 4, 5])]
print("\nTypes 3 to 5 by mouse:")
print(t35.groupby(["animal", "ptype"]).agg(trials=("stim_on", "size"), with_light=("has_light", "sum"), pulses=("n_pulses", "median"),
pulse_ms=("pulse_ms", "median"), power_mW=("power_max", "median"), onset_s_min=("stim_on", "min"),
onset_s_max=("stim_on", "max")).round(2).to_string())
print("Strain of these mice:", geno.loc[sorted(t35.animal.unique()), "strain"].to_dict())
print("StimTrials flag against PhotostimulationType:")
print(pd.crosstab(T.StimTrials, T.ptype.fillna(-1)).to_string())
Trials: 31439
PhotostimulationType (description: 0 none, 1 PT axonal, 2 IT axonal, NaN do not analyse):
ptype
0.0 19492
1.0 4029
2.0 3162
3.0 160
4.0 171
5.0 164
NaN 4261
GoodTrials: {1.0: 28465, 0.0: 2974}
Light pulses by photostimulation type (per trial medians):
trials with_light pulses pulse_ms power_mW first_onset_s
ptype (-1 = NaN)
-1.0 4261 3756 18.0 49.9 22.69 0.97
0.0 19492 43 16.0 50.0 0.01 3.20
1.0 4029 4010 20.0 1.0 82.00 0.30
2.0 3162 3151 20.0 1.0 47.10 0.30
3.0 160 160 8.0 1.0 22.69 1.80
4.0 171 171 8.0 1.0 22.69 2.30
5.0 164 163 8.0 1.0 22.69 2.80
Trials of type 0 (no stimulation) with light pulses: 43 in sessions {'ANM210862_20130627': 43}
Those trials, per trial:
n_pulses pulse_ms power_max stim_on
count 43.0 42.0 43.0 43.000
min 8.0 49.8 47.1 1.897
50% 16.0 50.0 47.1 3.198
max 22.0 50.0 47.1 4.351
Types 3 to 5 by mouse:
trials with_light pulses pulse_ms power_mW onset_s_min onset_s_max
animal ptype
ANM218453 3.0 100 100 8.0 1.0 22.68 1.8 1.8
4.0 104 104 8.0 1.0 22.69 2.3 2.3
5.0 97 97 8.0 1.0 22.68 2.8 2.8
ANM218457 3.0 60 60 8.0 1.0 22.69 1.8 1.8
4.0 67 67 8.0 1.0 22.69 2.3 2.3
5.0 67 66 8.0 1.0 22.69 2.8 2.8
Strain of these mice: {'ANM218453': 'pl56/ai32', 'ANM218457': 'pl56/ai32'}
StimTrials flag against PhotostimulationType:
ptype -1.0 0.0 1.0 2.0 3.0 4.0 5.0
StimTrials
False 806 19492 65 93 11 12 9
True 3455 0 3964 3069 149 159 155
# Trials of type NaN ("do not analyse") that carry light, by mouse and session: when the light
# starts relative to the epochs, pulse count and width, and power.
nanl = T[T.ptype.isna() & T.has_light].copy()
nanl["onset_epoch"] = np.select([nanl.cue.isna(), nanl.stim_on < nanl.pole_in, nanl.stim_on < nanl.pole_out, nanl.stim_on < nanl.cue],
["no cue (not performing)", "pre-sample", "sample", "delay"], "response or later")
print("NaN-type trials:", int(T.ptype.isna().sum()), "; with light:", len(nanl))
print(nanl.groupby(["animal", "session"]).agg(trials=("stim_on", "size"), onset_s_min=("stim_on", "min"),
onset_s_median=("stim_on", "median"), onset_s_max=("stim_on", "max"), pulses=("n_pulses", "median"),
pulse_ms=("pulse_ms", "median"), power_mW=("power_max", "median"),
performing=("good", "sum")).round(2).to_string())
print("\nOnset epoch of the light in NaN-type trials, by mouse:")
print(pd.crosstab(nanl.animal, nanl.onset_epoch).to_string())
print("\nStrain of the mice with NaN-type light trials:", geno.loc[sorted(nanl.animal.unique()), "strain"].to_dict())
samp = nanl[nanl.onset_epoch == "sample"]
print("\nNaN-type light trials starting in the sample epoch, by mouse and per-trial configuration "
"(pulses, pulse width rounded to 0.1 ms, power rounded to 1 mW):")
print(samp.assign(pulse_ms=samp.pulse_ms.round(1), power_mW=samp.power_max.round(0))
.groupby(["animal", "n_pulses", "pulse_ms", "power_mW"]).size().rename("trials").to_string())
print("\nANM218693 (Sim1_KJ18-Cre x Ai32), trials with light by photostimulation type:",
T[(T.animal == "ANM218693") & T.has_light].ptype.value_counts(dropna=False).to_dict())
NaN-type trials: 4261 ; with light: 3756
trials onset_s_min onset_s_median onset_s_max pulses pulse_ms power_mW performing
animal session
ANM210861 ANM210861_20130701 90 1.88 3.20 4.98 14.0 50.00 47.10 89.0
ANM210861_20130702 76 1.86 3.20 4.92 14.0 50.00 47.10 74.0
ANM210861_20130703 101 1.86 3.20 4.57 15.0 50.00 47.10 100.0
ANM210862 ANM210862_20130626 53 1.90 3.20 4.72 15.0 50.00 47.10 52.0
ANM210862_20130627 16 1.90 2.55 3.29 17.0 50.00 47.10 16.0
ANM210862_20130628 93 0.70 2.58 4.92 16.0 50.00 47.10 87.0
ANM210863 ANM210863_20130626 70 1.90 3.20 4.35 16.0 50.00 47.10 68.0
ANM210863_20130627 66 1.90 1.90 4.15 15.0 50.00 47.10 63.0
ANM210863_20130628 80 1.90 2.31 4.84 16.0 50.00 47.10 79.0
ANM214427 ANM214427_20130806 22 0.22 0.70 0.70 57.0 49.85 6.21 0.0
ANM214427_20130807 117 0.22 0.70 0.70 26.0 49.90 22.65 0.0
ANM214427_20130808 109 0.22 0.70 1.61 26.0 49.90 22.65 0.0
ANM214429 ANM214429_20130806 128 0.19 0.70 3.80 22.0 49.70 22.65 9.0
ANM214429_20130807 117 0.19 0.67 0.70 10.0 1.00 22.65 0.0
ANM214429_20130808 122 0.22 0.70 0.70 24.0 49.90 22.65 0.0
ANM214430 ANM214430_20130820 50 0.22 0.70 0.70 26.0 49.90 22.64 0.0
ANM214430_20130821 50 0.22 0.70 2.92 25.0 50.00 22.70 0.0
ANM214430_20130822 55 0.22 0.70 0.70 25.0 49.95 22.65 0.0
ANM214430_20130823 25 0.70 0.70 0.70 25.0 49.90 22.66 0.0
ANM218453 ANM218453_20131014 87 1.80 2.30 2.80 8.0 1.00 22.69 74.0
ANM218453_20131015 91 1.80 2.30 2.80 8.0 1.00 22.67 84.0
ANM218453_20131016 81 1.80 2.30 2.80 8.0 1.00 22.69 76.0
ANM218453_20131017 79 1.80 2.30 2.80 8.0 1.00 22.69 76.0
ANM218453_20131018 81 1.80 2.30 2.80 8.0 1.00 22.69 77.0
ANM218457 ANM218457_20131004 20 1.80 2.30 2.80 8.0 1.00 22.70 19.0
ANM218457_20131005 27 1.80 2.30 2.80 8.0 1.00 22.69 21.0
ANM218457_20131006 39 1.80 2.30 2.80 8.0 1.00 22.69 37.0
ANM218457_20131007 17 1.80 2.30 2.80 8.0 1.00 22.70 17.0
ANM218457_20131008 82 1.80 2.30 2.80 8.0 1.00 22.69 75.0
ANM218693 ANM218693_20131203 180 0.97 2.30 2.80 8.0 1.00 22.70 151.0
ANM218693_20131204 159 0.49 2.30 2.80 8.0 1.00 22.70 126.0
ANM218693_20131205 181 0.49 2.30 2.80 8.0 1.00 22.69 149.0
ANM219030 ANM219030_20130829 34 0.22 0.70 0.70 25.0 49.90 22.64 0.0
ANM219030_20130830 33 0.22 0.70 0.70 24.0 50.00 22.71 0.0
ANM219030_20130831 36 0.70 0.70 0.70 26.5 49.85 22.66 0.0
ANM219030_20130901 21 0.70 0.70 0.70 26.0 50.00 22.72 0.0
ANM219030_20130903 22 0.21 0.70 0.70 26.5 50.00 22.72 0.0
ANM219031 ANM219031_20131021 34 0.22 0.70 0.70 26.0 49.90 22.65 0.0
ANM219031_20131022 36 0.22 0.70 0.70 29.0 49.90 6.21 0.0
ANM219031_20131023 32 0.70 0.70 0.70 26.0 49.90 22.62 0.0
ANM219031_20131024 21 0.70 0.70 0.70 24.0 49.90 22.63 0.0
ANM219031_20131025 31 0.70 0.70 0.70 26.0 49.95 22.63 0.0
ANM219033 ANM219033_20131116 23 0.49 0.97 0.97 18.0 1.00 47.10 1.0
ANM219033_20131118 21 0.97 0.97 0.97 18.0 1.00 47.10 0.0
ANM219033_20131119 9 0.97 0.97 0.97 18.0 1.00 47.10 0.0
ANM219033_20131120 11 0.97 0.97 0.97 18.0 1.00 47.10 0.0
ANM219033_20131121 10 0.97 0.97 0.97 18.0 1.00 47.10 0.0
ANM219036 ANM219036_20131116 12 0.97 0.97 0.97 18.0 1.00 47.10 0.0
ANM219036_20131117 11 0.97 0.97 0.97 18.0 1.00 47.10 0.0
ANM219036_20131118 10 0.97 0.97 0.97 18.0 1.00 47.10 0.0
ANM219036_20131121 10 0.97 0.97 0.97 18.0 1.00 47.10 0.0
ANM219037 ANM219037_20131116 9 0.97 0.97 0.97 18.0 1.00 47.10 0.0
ANM219037_20131119 13 0.97 0.97 0.97 18.0 1.00 47.10 0.0
ANM219037_20131120 11 0.97 0.97 0.97 18.0 1.00 47.10 0.0
ANM219037_20131121 12 0.97 0.97 0.97 18.0 1.00 47.10 0.0
ANM219037_20131122 14 0.97 0.97 0.97 18.0 1.00 47.10 0.0
ANM219038 ANM219038_20131021 33 0.22 0.70 0.70 27.0 50.00 22.70 0.0
ANM219038_20131022 36 0.22 0.70 0.70 27.0 50.00 22.71 0.0
ANM219038_20131023 36 0.22 0.70 0.70 26.0 50.00 22.68 0.0
ANM219038_20131024 34 0.22 0.70 0.70 27.5 50.00 22.69 0.0
ANM219038_20131025 13 0.49 0.70 0.97 25.0 50.00 22.69 0.0
ANM219038_20131026 12 0.70 0.70 0.97 26.0 49.97 34.89 0.0
ANM219038_20131027 12 0.70 0.70 0.70 23.5 50.00 47.10 0.0
ANM219038_20131028 12 0.70 0.70 0.70 25.0 50.00 22.69 0.0
ANM219247 ANM219247_20130919 36 0.22 0.70 1.92 25.0 49.90 22.63 0.0
ANM219247_20130920 34 0.22 0.70 0.70 26.0 50.00 22.71 0.0
ANM219247_20130921 37 0.70 0.70 0.70 24.0 50.00 22.71 0.0
ANM219247_20130922 44 0.22 0.70 0.70 26.0 50.00 47.10 0.0
ANM219247_20130923 47 0.09 0.70 0.70 26.0 50.00 22.71 3.0
ANM219248 ANM219248_20130919 35 0.22 0.70 0.70 27.0 50.00 22.70 0.0
ANM219248_20130920 38 0.22 0.70 0.70 26.0 50.00 22.71 0.0
ANM219248_20130921 38 0.22 0.70 0.70 26.0 50.00 34.92 0.0
ANM219248_20130922 36 0.22 0.70 0.70 26.0 50.00 22.70 0.0
ANM219248_20130923 39 0.70 0.70 0.70 27.0 50.00 22.69 0.0
ANM219248_20130924 36 0.70 0.70 0.70 25.5 50.00 22.70 0.0
ANM219248_20130925 43 0.22 0.70 0.70 25.0 50.00 22.70 0.0
ANM219253 ANM219253_20140117 11 0.97 0.97 0.97 18.0 1.00 47.10 0.0
ANM221977 ANM221977_20140115 35 0.97 0.97 0.97 18.0 1.00 47.10 0.0
ANM221977_20140116 11 0.97 0.97 0.97 18.0 1.00 47.10 0.0
ANM221977_20140118 8 0.70 0.70 0.70 28.0 49.95 22.72 0.0
Onset epoch of the light in NaN-type trials, by mouse:
onset_epoch delay no cue (not performing) response or later sample
animal
ANM210861 136 4 124 3
ANM210862 70 7 81 4
ANM210863 114 6 96 0
ANM214427 0 248 0 0
ANM214429 0 358 0 9
ANM214430 0 180 0 0
ANM218453 238 32 0 149
ANM218457 106 16 0 63
ANM218693 291 94 0 135
ANM219030 0 146 0 0
ANM219031 0 154 0 0
ANM219033 0 73 0 1
ANM219036 0 43 0 0
ANM219037 0 59 0 0
ANM219038 0 188 0 0
ANM219247 0 195 0 3
ANM219248 0 265 0 0
ANM219253 0 11 0 0
ANM221977 0 54 0 0
Strain of the mice with NaN-type light trials: {'ANM210861': 'kj18', 'ANM210862': 'kj18', 'ANM210863': 'kj18', 'ANM214427': 'kl100', 'ANM214429': 'kl100', 'ANM214430': 'kl100', 'ANM218453': 'pl56/ai32', 'ANM218457': 'pl56/ai32', 'ANM218693': 'kj18/ai32', 'ANM219030': 'kj18', 'ANM219031': 'kj18', 'ANM219033': 'kj18', 'ANM219036': 'kj18', 'ANM219037': 'kj18', 'ANM219038': 'kj18', 'ANM219247': 'pl56', 'ANM219248': 'pl56', 'ANM219253': 'pl56', 'ANM221977': 'pl56'}
NaN-type light trials starting in the sample epoch, by mouse and per-trial configuration (pulses, pulse width rounded to 0.1 ms, power rounded to 1 mW):
animal n_pulses pulse_ms power_mW
ANM210861 13.0 50.0 47.0 2
16.0 50.0 47.0 1
ANM210862 17.0 50.0 47.0 1
18.0 50.0 47.0 1
19.0 49.9 47.0 1
50.0 47.0 1
ANM214429 26.0 2.0 47.0 9
ANM218453 8.0 1.0 23.0 149
ANM218457 8.0 1.0 23.0 61
47.0 2
ANM218693 8.0 1.0 23.0 135
ANM219033 26.0 2.0 47.0 1
ANM219247 26.0 2.0 47.0 3
ANM218693 (Sim1_KJ18-Cre x Ai32), trials with light by photostimulation type: {nan: 520}
g = T[(T.good == 1) & T.cue.notna()]
ep = pd.DataFrame({"sample_s": g.pole_out - g.pole_in, "delay_s": g.cue - g.pole_out, "pole_in_s": g.pole_in, "cue_s": g.cue,
"timeseries_start_s": g.ts_offset, "timeseries_len_s": g.ts_len})
print("Epoch times in performing trials (seconds; Methods: sample 1.3 s to 0.1 s after pole retraction onset, delay 1.3 s):")
print(ep.describe(percentiles=[0.01, 0.5, 0.99]).round(3).to_string())
outcome = g[["HitR", "HitL", "ErrR", "ErrL", "NoLickR", "NoLickL"]].sum(axis=1)
print("\nPerforming trials with exactly one outcome flag:", int((outcome == 1).sum()), "of", len(g), "; lick early:", int(g.LickEarly.sum()))
print("Trial type counts in performing trials:", g[alm.TRIAL_TYPES].sum().to_dict())
odd = g[(abs(g.pole_out - g.pole_in - 1.3) > 0.05) | (abs(g.cue - g.pole_out - 1.3) > 0.05)]
print("Performing trials whose sample or delay epoch differs from 1.3 s by more than 50 ms:", len(odd), "of", len(g),
"; of these correct non-stimulation trials:", int((odd.ptype.eq(0) & (odd.HitR | odd.HitL)).sum()))
Epoch times in performing trials (seconds; Methods: sample 1.3 s to 0.1 s after pole retraction onset, delay 1.3 s):
sample_s delay_s pole_in_s cue_s timeseries_start_s timeseries_len_s
count 28465.000 28465.000 28465.000 28465.000 28353.0 28353.0
mean 1.384 1.344 0.568 3.297 0.0 5.0
std 0.479 0.284 0.045 0.600 0.0 0.0
min 0.100 -0.100 0.000 0.000 0.0 5.0
1% 1.300 1.300 0.571 3.172 0.0 5.0
50% 1.300 1.300 0.572 3.173 0.0 5.0
99% 3.266 2.547 0.573 5.739 0.0 5.0
max 14.316 13.618 0.944 17.914 0.0 5.0
Performing trials with exactly one outcome flag: 28391 of 28465 ; lick early: 3676
Trial type counts in performing trials: {'HitR': 10743, 'HitL': 10729, 'ErrR': 3031, 'ErrL': 3431, 'NoLickR': 233, 'NoLickL': 224, 'LickEarly': 3676, 'StimTrials': 9557}
Performing trials whose sample or delay epoch differs from 1.3 s by more than 50 ms: 3707 of 28465 ; of these correct non-stimulation trials: 1859
Two things in the trial tables are not in the description. Photostimulation types 3, 4 and 5 occur in the two Tlx_PL56-Cre x Ai32 mice: eight 1 ms pulses at about 23 mW starting 1.8, 2.3 or 2.8 s into the trial (table by mouse above); the description lists only 0, 1, 2 and NaN. The authors' compile script counts types 1 to 5 as tagging trials. And in one session of ANM210862, 43 trials of type 0 ("non-stimulation") carry 50 ms light pulses at 47.1 mW starting 1.9 to 4.35 s into the trial (above). Trials of type 0 with light are kept as the data label them, as the paper's analysis would have; how many enter is printed. The NaN-type trials ("photostimulation configurations for testing purposes, these trials should not be analyze", data description) carry light in 3,756 trials of all 19 mice. Light starting in the sample epoch occurs in 367 of them: 347 in the two Tlx_PL56-Cre x Ai32 mice (IT neurons) and the one Sim1_KJ18-Cre x Ai32 mouse ANM218693 (3 sessions, 59 units), as eight 1 ms pulses, at about 23 mW in all but 2 (47 mW), and 20 in five other mice (table above). None of this matches the sample-epoch PT photostimulation of ED Fig. 7 (two mice, eight sessions, 91 neurons), and the NaN-type trials are left out everywhere. The epoch lengths fit the Methods' 1.3 s sample and delay epochs.
# Units: labels, widths, spikes, and recordings deposited twice.
lab = Counter(u["cell_types"] for s, u in units)
print("cellType labels:", dict(lab))
width = np.array([alm.spike_width_ms(u["waveform"]) for s, u in units])
print("Trough-to-peak widths take the values (ms):", np.unique(np.round(width, 3)).tolist(),
"; sampling interval", round(1e3 / alm.FS_WAVEFORM, 4), "ms")
nsp = np.array([u["n_spikes"] for s, u in units])
print("Spikes per unit: min", nsp.min(), "median", int(np.median(nsp)), "max", nsp.max())
unsorted = sum(int(np.any(np.diff(u["spike_t_session"]) < 0)) for s, u in units)
print("Units whose spike times are not sorted:", unsorted, [f"{s['session']}/{u['unit']}" for s, u in units if np.any(np.diff(u["spike_t_session"]) < 0)])
sig = {}
for s, u in units:
key = (len(u["spike_t_session"]), round(float(u["spike_t_session"][:20].sum()), 6) if len(u["spike_t_session"]) else 0)
sig.setdefault(key, []).append(f"{s['session']}/{u['unit']}")
dups = [v for v in sig.values() if len(v) > 1]
print("Units with identical spike trains (count and first 20 times):", dups)
sess_sig = Counter((len(s["trials"]), round(float(s["trials"].start.sum()), 3)) for s in S)
print("Sessions with identical trial start times:", [k for k, v in sess_sig.items() if v > 1])
print("Mean waveform amplitude range (V):", np.round(np.percentile([np.ptp(u['waveform']) for s, u in units], [0, 50, 100]), 6).tolist())
cellType labels: {('FS',): 124, ('pyramidal',): 1173, (): 39, ('pyramidal', 'IT'): 27, ('pyramidal', 'PT'): 45}
Trough-to-peak widths take the values (ms): [0.154, 0.205, 0.256, 0.307, 0.41, 0.461, 0.512, 0.563, 0.614, 0.666] ; sampling interval 0.0512 ms
Spikes per unit: min 17 median 3030 max 87313
Units whose spike times are not sorted: 10 ['ANM214429_20130806/1', 'ANM214429_20130806/2', 'ANM214429_20130806/4', 'ANM214429_20130806/5', 'ANM214429_20130806/6', 'ANM214429_20130806/8', 'ANM214429_20130806/10', 'ANM219030_20130829/12', 'ANM219030_20130831/5', 'ANM219247_20130920/5']
Units with identical spike trains (count and first 20 times): []
Sessions with identical trial start times: []
Mean waveform amplitude range (V): [5.5e-05, 0.000247, 0.001052]
In 3,707 of 28,465 performing trials the sample or delay epoch differs from 1.3 s by more than 50 ms (1,859 of them correct trials without stimulation); epoch rates divide by each trial's own epoch length, so these trials are kept. 10 units, 7 of them from one session, have spike times out of order; every measure here bins or sorts spikes, so this does not change them.
The labels give 1,173 pyramidal, 45 pyramidal and PT, 27 pyramidal and IT, 124 FS and 39 units without a label: 1,245 pyramidal in all, as the paper says. Waveforms are sampled every 0.0512 ms, so trough-to-peak widths come in steps of that size; the claim on unit counts compares both the labels and widths recomputed from the waveforms.
Clocks. Three checks show the streams share the trial clock. Spikes and trial times: the number of pyramidal neurons that distinguish lick right from lick left trials, in 200 ms windows, is near the 5% expected by chance before the sample epoch and rises after it (claim fig2c-selectivity-time-course, printed there with the same count when the trial labels are shuffled). Spikes and the AOM trace: antidromic spikes follow the light pulses at a fixed latency, with a jitter near 0.1 ms (claim antidromic-latency-jitter). Lick trace and cue: an onset of the lick trace is found in the 1 s after the cue in 96.6% of correct trials, and in 90% of those it falls 34 to 173 ms after the cue (printed next; example traces under reaction-time). The lick counts printed next cross a fixed 1 V, although session baselines run from 0.07 to 4.83 V; they serve only as this clock check.
gc = T[(T.good == 1) & (T.ptype == 0) & (T.HitR | T.HitL) & ~T.LickEarly]
print("Correct non-stimulation trials without early licks:", len(gc))
print("Fraction with a lick trace onset in the 1 s after the cue (noise rule, 5 x noise, 5 mV):", round(gc["rtn_5_0.005"].notna().mean(), 3))
print("Onset after the cue, percentiles 5, 25, 50, 75, 95 (ms):", np.round(np.nanpercentile(gc["rtn_5_0.005"] * 1e3, [5, 25, 50, 75, 95]), 1).tolist())
print("Licks (crossings of 1 V) between sample onset and cue in correct non-lick-early trials, mean per trial:",
round(gc.n_lick_pre.mean(), 3), "; in lick early trials:", round(T[(T.good == 1) & T.LickEarly].n_lick_pre.mean(), 3))
print("Per session median lick trace baseline (V), range:", np.round(gc.groupby('session').lick_base.median().agg(['min', 'max']).values, 2).tolist(),
"; median peak excursion after the cue (V), range:", np.round(gc.groupby('session').lick_peak.median().agg(['min', 'max']).values, 2).tolist())
Correct non-stimulation trials without early licks: 12639 Fraction with a lick trace onset in the 1 s after the cue (noise rule, 5 x noise, 5 mV): 0.966 Onset after the cue, percentiles 5, 25, 50, 75, 95 (ms): [34.3, 51.7, 69.3, 87.3, 173.4] Licks (crossings of 1 V) between sample onset and cue in correct non-lick-early trials, mean per trial: 0.838 ; in lick early trials: 1.716 Per session median lick trace baseline (V), range: [0.07, 4.83] ; median peak excursion after the cue (V), range: [-3.76, 4.64]
# Unit tables under the readings of the shared methods: lick early trials dropped (a) or
# kept (b); response epoch 1.3 s (a) or 1.5 s (b).
UT = {}
for le in ("drop", "keep"):
for resp in (1.3, 1.5):
UT[(le, resp)] = alm.unit_table(S, lick_early=le, response_s=resp)
D = UT[("drop", 1.3)]
pyr = D[D.label == "pyramidal"]
print("Units:", len(D), "; pyramidal:", len(pyr))
print("Correct trials per pyramidal neuron (drop lick early), R:", pyr.n_R.describe()[["min", "50%", "max"]].to_dict(),
"L:", pyr.n_L.describe()[["min", "50%", "max"]].to_dict())
print("Pyramidal neurons with fewer than 2 trials of a type (no test):", int(((pyr.n_R < 2) | (pyr.n_L < 2)).sum()))
print("Trials of type 0 with light used by any unit:", int(((T.ptype == 0) & T.has_light & (T.good == 1) & (T.HitR | T.HitL)).sum()))
Units: 1408 ; pyramidal: 1245
Correct trials per pyramidal neuron (drop lick early), R: {'min': 0.0, '50%': 47.0, 'max': 117.0} L: {'min': 0.0, '50%': 46.0, 'max': 117.0}
Pyramidal neurons with fewer than 2 trials of a type (no test): 3
Trials of type 0 with light used by any unit: 27
task-performance¶
Mice performed the task at 78.4% correct on average, with responses before the go cue on fewer than 13% of trials (n = 42 mice).
Only the 19 electrophysiology mice are in the data set, against 42 in the paper. Per cent
correct is hits over hits and errors, lick early trials excluded (Methods); no-lick trials are
left out, as the data set's Demo_get_performance.m does. Lick early fraction is over all
performing trials of the same set. Readings from the criterion: mean over sessions (a), over
mice (b), pooled trials (c); control trials (type 0, no StimTrials flag) or all performing trials except the NaN-type test
trials, which the data description says are not to be analysed.
rows = []
for trials_name, sel in (("control", (T.ptype == 0) & ~T.StimTrials), ("all but NaN-type", T.ptype.notna())):
d = T[(T.good == 1) & sel & T.cue.notna()]
d = d.assign(hit=d.HitR | d.HitL, resp=d.HitR | d.HitL | d.ErrR | d.ErrL)
ne = d[~d.LickEarly & d.resp]
ps = ne.groupby("session").hit.mean() * 100
le_s = d.groupby("session").LickEarly.mean() * 100
pm = ne.groupby("animal").hit.mean() * 100
le_m = d.groupby("animal").LickEarly.mean() * 100
for how, pc, le in (("a sessions", ps.mean(), le_s.mean()), ("b mice", ne.assign(s=ne.session).groupby("animal").apply(lambda x: x.groupby("session").hit.mean().mean()).mean() * 100, d.groupby("animal").apply(lambda x: x.groupby("session").LickEarly.mean().mean()).mean() * 100),
("c pooled", ne.hit.mean() * 100, d.LickEarly.mean() * 100)):
rows.append({"trials": trials_name, "mean": how, "per_cent_correct": pc, "lick_early_pct": le,
"within_tolerance": abs(pc - 78.4) <= 7.84, "lick_early_below_14.3": le < 14.3, "n_trials": len(d)})
perf = pd.DataFrame(rows)
print(perf.round(2).to_string(index=False))
print("\nPer mouse (control trials):")
d = T[(T.good == 1) & (T.ptype == 0) & ~T.StimTrials & T.cue.notna()]
print(pd.DataFrame({"pct_correct": d[~d.LickEarly & (d.HitR | d.HitL | d.ErrR | d.ErrL)].groupby("animal").apply(lambda x: (x.HitR | x.HitL).mean() * 100),
"lick_early_pct": d.groupby("animal").LickEarly.mean() * 100}).round(1).T.to_string())
trials mean per_cent_correct lick_early_pct within_tolerance lick_early_below_14.3 n_trials
control a sessions 76.84 10.88 True True 18908
control b mice 76.37 14.06 True True 18908
control c pooled 77.28 12.59 True True 18908
all but NaN-type a sessions 76.59 11.64 True True 26404
all but NaN-type b mice 76.09 14.69 True False 26404
all but NaN-type c pooled 76.52 11.95 True True 26404
Per mouse (control trials):
animal ANM210861 ANM210862 ANM210863 ANM214427 ANM214429 ANM214430 ANM218453 ANM218457 ANM218693 ANM219030 ANM219031 ANM219033 ANM219036 ANM219037 ANM219038 ANM219247 ANM219248 ANM219253 ANM221977
pct_correct 74.7 73.9 76.0 77.3 87.0 65.4 81.4 85.1 86.1 61.6 77.5 82.6 76.5 83.6 65.7 60.4 86.9 80.3 69.0
lick_early_pct 73.1 37.4 19.0 3.3 23.0 16.0 22.6 9.1 2.6 8.5 3.4 8.7 2.2 4.9 3.2 13.9 2.4 2.3 11.0
Result: reproduced, on 19 of the 42 mice. On control trials the mean per cent correct is 76.84% over sessions (reading a), 76.37% over mice and 77.28% over pooled trials, all within 78.4 ± 7.84%; lick early trials are 10.88% of control trials over sessions and 12.59% pooled, below 13%. Over mice the lick early fraction is 14.06%, above 13% but below 14.3%. With all trials except the NaN-type test trials the per cent correct is 76.09% to 76.59% and the lick early fraction 11.64% to 14.69%. Only the 19 electrophysiology mice are in the data set; per mouse the per cent correct ranges from 60.4% to 87.0%.
unit-counts¶
1,408 single units were recorded in left ALM from 19 mice in 99 sessions; by spike width, 1,245 are putative pyramidal neurons (> 0.45 ms), 124 fast-spiking neurons (< 0.35 ms) and 39 intermediate units excluded.
print("From the cellType labels: units", len(D), "; pyramidal", int((D.label == "pyramidal").sum()),
"; FS", int((D.label == "FS").sum()), "; unlabelled", int((D.label == "unclassified").sum()))
w = D.width_ms
print("From the trough-to-peak width of the mean waveform (sampled at 19531.25 Hz): >0.45 ms", int((w > 0.45).sum()),
"; <0.35 ms", int((w < 0.35).sum()), "; 0.35 to 0.45 ms", int(((w >= 0.35) & (w <= 0.45)).sum()))
print(pd.crosstab(D.label, pd.cut(w, [0, 0.35, 0.45, 2], labels=["<0.35", "0.35-0.45", ">0.45"])).to_string())
# variant: the width on a waveform interpolated to 1 us (cubic spline)
from scipy.interpolate import CubicSpline
def width_interp(wf):
x = np.arange(len(wf)) / alm.FS_WAVEFORM * 1e3
xs = np.arange(0, x[-1], 0.001)
ys = CubicSpline(x, wf)(xs)
i = int(np.argmin(ys)); j = i + int(np.argmax(ys[i:]))
return xs[j] - xs[i]
wi = np.array([width_interp(u["waveform"]) for s, u in units])
print("Variant, spline-interpolated widths: >0.45 ms", int((wi > 0.45).sum()), "; <0.35 ms", int((wi < 0.35).sum()),
"; 0.35 to 0.45 ms", int(((wi >= 0.35) & (wi <= 0.45)).sum()))
print(pd.crosstab(D.label.values, pd.cut(wi, [0, 0.35, 0.45, 2], labels=["<0.35", "0.35-0.45", ">0.45"])).to_string())
print("Mice:", D.animal.nunique(), "; sessions:", D.session.nunique())
print("Units per mouse:", D.groupby("animal").size().to_dict())
shapes = Counter(u["waveform_shape"][1] for s, u in units)
print("Waveform arrays: samples per spike", dict(shapes), "; rows equal to the unit's spike count for",
sum(u["waveform_shape"][0] == u["n_spikes"] for s, u in units), "of", len(units), "units")
troughs = Counter(int(np.argmin(u["waveform"])) for s, u in units)
print("Sample of the trough of the mean waveform:", dict(troughs))
print("\nExact trough-to-peak widths by cellType label (ms; units):")
print(pd.crosstab(D.width_ms.round(3), D.label).to_string())
last = [int(np.argmin(u["waveform"])) + int(np.argmax(u["waveform"][int(np.argmin(u["waveform"])):])) == len(u["waveform"]) - 1 for s, u in units]
print("Units whose peak after the trough is the last sample of the snippet (width capped there):", int(np.sum(last)), "; their labels:", Counter(D.label[np.array(last)]))
amp = pd.Series([float(-u["waveform"].min()) * 1e6 for s, u in units], index=D.index)
print("Trough amplitude (uV), median by label:", amp.groupby(D.label).median().round(1).to_dict())
fig, ax = plt.subplots(1, 3, figsize=(12, 3), sharey=True)
x = np.arange(29) / alm.FS_WAVEFORM * 1e3
for a, lab in zip(ax, ("FS", "unclassified", "pyramidal")):
for (s, u), l in zip(units, D.label):
if l == lab:
w = u["waveform"]
a.plot(x, w / -w.min(), lw=0.4, color="k", alpha=0.3)
a.set_title(f"{lab} ({int((D.label == lab).sum())})"); a.set_xlabel("ms")
ax[0].set_ylabel("mean waveform / trough depth")
plt.tight_layout(); plt.show()
print("Normalised waveforms span", round(min(float((u['waveform'] / -u['waveform'].min()).min()) for s, u in units), 2), "to",
round(max(float((u['waveform'] / -u['waveform'].min()).max()) for s, u in units), 2))
From the cellType labels: units 1408 ; pyramidal 1245 ; FS 124 ; unlabelled 39 From the trough-to-peak width of the mean waveform (sampled at 19531.25 Hz): >0.45 ms 1245 ; <0.35 ms 158 ; 0.35 to 0.45 ms 5 width_ms <0.35 0.35-0.45 >0.45 label FS 124 0 0 pyramidal 0 0 1245 unclassified 34 5 0
Variant, spline-interpolated widths: >0.45 ms 1241 ; <0.35 ms 158 ; 0.35 to 0.45 ms 9
col_0 <0.35 0.35-0.45 >0.45
row_0
FS 124 0 0
pyramidal 0 4 1241
unclassified 34 5 0
Mice: 19 ; sessions: 99
Units per mouse: {'ANM210861': 58, 'ANM210862': 53, 'ANM210863': 90, 'ANM214427': 26, 'ANM214429': 48, 'ANM214430': 42, 'ANM218453': 54, 'ANM218457': 118, 'ANM218693': 59, 'ANM219030': 57, 'ANM219031': 93, 'ANM219033': 57, 'ANM219036': 97, 'ANM219037': 100, 'ANM219038': 119, 'ANM219247': 60, 'ANM219248': 148, 'ANM219253': 93, 'ANM221977': 36}
Waveform arrays: samples per spike {29: 1408} ; rows equal to the unit's spike count for 1408 of 1408 units
Sample of the trough of the mean waveform: {15: 1408}
Exact trough-to-peak widths by cellType label (ms; units):
label FS pyramidal unclassified
width_ms
0.154 34 0 0
0.205 8 0 0
0.256 82 0 0
0.307 0 0 34
0.410 0 0 5
0.461 0 30 0
0.512 0 8 0
0.563 0 84 0
0.614 0 404 0
0.666 0 719 0
Units whose peak after the trough is the last sample of the snippet (width capped there): 719 ; their labels: Counter({'pyramidal': 719})
Trough amplitude (uV), median by label: {'FS': 131.9, 'pyramidal': 204.0, 'unclassified': 119.6}
Normalised waveforms span -1.0 to 2.1
Result: partially reproduced. The data set holds 1,408 units from 19 mice in 99 sessions, and its cell type labels give exactly 1,245 pyramidal, 124 FS and 39 unclassified units. Recomputed as the criterion says, from the trough-to-peak interval of the deposited mean waveforms, 1,245 units are above 0.45 ms, as the paper has, but 158 are below 0.35 ms and 5 in between, against 124 and 39: 34 of the 39 unlabelled units have widths below 0.35 ms. The spline-interpolated variant gives 1,241, 158 and 9. The waveform arrays are read the right way round (29 samples per spike, one row per spike for all 1,408 units, trough at sample 15 in every unit). The labels are a clean function of the deposited width: every FS unit measures 0.154 to 0.256 ms, every unlabelled unit 0.307 (34) or 0.410 ms (5), every pyramidal unit 0.461 to 0.666 ms, so the labels put the FS boundary between 0.256 and 0.307 ms (5 and 6 samples), not at the Methods' 0.35 ms. The unlabelled units' waveforms are as small as the FS units' (median trough 120 against 132 µV; pyramidal 204 µV). How the paper's widths map onto these samples is not stated; the labels hold its classification, the stated thresholds applied to the deposited waveforms do not.
fig2-selective-fraction¶
73% (912 of 1,245) of putative pyramidal neurons distinguish the trial types in at least one epoch.
Two-tailed t-test (pooled variance) of spike rates on lick right against lick left correct trials, in the sample, delay or response epoch, P < 0.05 uncorrected (Methods). Under each reading of the response epoch and of lick early trials. The test is on rates, as the data set's compile script runs it (lines 217 to 221 and 300, printed in the data check); the Methods say spike counts, which differ from rates where an epoch is not 1.3 s, so a test on counts and Welch's test are variants.
rows = []
for (le, resp), d in UT.items():
p = d[d.label == "pyramidal"]
for test, col in (("pooled", "selective"), ("Welch", "selective_welch"), ("pooled, counts", "selective_count")):
rows.append({"lick_early": le, "response_s": resp, "test": test, "selective": int(p[col].sum()),
"of": len(p), "fraction": p[col].mean()})
sel_tab = pd.DataFrame(rows)
sel_tab["within_tolerance"] = (abs(sel_tab.selective - 912) <= 91.2) & (abs(sel_tab.fraction - 0.73) <= 0.073)
print(sel_tab.round(4).to_string(index=False))
print("\nPer mouse (reading a, a, pooled): fraction selective")
print(pyr.groupby("animal").selective.agg(["sum", "size", "mean"]).round(3).T.to_string())
print("Per epoch, pyramidal neurons significant: sample", int((pyr.p_sample < .05).sum()), "delay", int((pyr.p_delay < .05).sum()),
"response", int((pyr.p_response < .05).sum()), "; chance at P < 0.05 for one epoch is about", round(0.05 * len(pyr)))
lick_early response_s test selective of fraction within_tolerance
drop 1.3 pooled 912 1245 0.7325 True
drop 1.3 Welch 906 1245 0.7277 True
drop 1.3 pooled, counts 912 1245 0.7325 True
drop 1.5 pooled 910 1245 0.7309 True
drop 1.5 Welch 903 1245 0.7253 True
drop 1.5 pooled, counts 910 1245 0.7309 True
keep 1.3 pooled 950 1245 0.7631 True
keep 1.3 Welch 947 1245 0.7606 True
keep 1.3 pooled, counts 944 1245 0.7582 True
keep 1.5 pooled 948 1245 0.7614 True
keep 1.5 Welch 946 1245 0.7598 True
keep 1.5 pooled, counts 939 1245 0.7542 True
Per mouse (reading a, a, pooled): fraction selective
animal ANM210861 ANM210862 ANM210863 ANM214427 ANM214429 ANM214430 ANM218453 ANM218457 ANM218693 ANM219030 ANM219031 ANM219033 ANM219036 ANM219037 ANM219038 ANM219247 ANM219248 ANM219253 ANM221977
sum 20.000 29.000 52.000 18.000 30.000 31.000 29.000 80.0 42.000 33.000 69.000 41.000 69.000 72.000 72.000 36.000 106.000 61.000 22.000
size 48.000 47.000 78.000 23.000 44.000 37.000 45.000 100.0 51.000 47.000 81.000 49.000 90.000 95.000 110.000 56.000 129.000 83.000 32.000
mean 0.417 0.617 0.667 0.783 0.682 0.838 0.644 0.8 0.824 0.702 0.852 0.837 0.767 0.758 0.655 0.643 0.822 0.735 0.688
Per epoch, pyramidal neurons significant: sample 319 delay 481 response 693 ; chance at P < 0.05 for one epoch is about 62
Result: reproduced. With lick early trials dropped and a 1.3 s response epoch, 912 of 1,245 pyramidal neurons (73.25%) are selective, the paper's numbers exactly. The other readings give 910 to 950 (73.1% to 76.3%) and Welch's test 903 to 947. The t-test on spike counts, the Methods' wording, gives 912 again under the main readings and 910 to 944 under the others (the data set's compile script tests rates, lines 217 to 221 and 300 printed above). All are within tolerance. Per mouse the fraction ranges from 0.417 to 0.852.
fig2d-response-categories¶
Of the selective neurons, 219 have selectivity only in the sample or delay epochs (preparatory only), and the rest have peri-movement selectivity in the response epoch, alone or together with preparatory selectivity (389 and 304 of 912).
rows = []
for (le, resp), d in UT.items():
c = alm.categories(d[d.label == "pyramidal"])
rows.append({"lick_early": le, "response_s": resp, **c})
cat = pd.DataFrame(rows)
cat["text_reading_ok"] = (abs(cat.prep_only - 219) <= 21.9) & (abs(cat.peri_only - 389) <= 38.9) & (abs(cat.both - 304) <= 30.4)
cat["figure_reading_ok"] = (abs(cat.prep_only - 219) <= 21.9) & (abs(cat.both - 389) <= 38.9) & (abs(cat.peri_only - 304) <= 30.4)
for k in ("prep_only", "both", "peri_only"):
cat[f"frac_{k}"] = (cat[k] / cat.n).round(3)
print(cat.to_string(index=False))
print("\nPaper, as fractions of 912: preparatory only", round(219 / 912, 3), "; 389/912 =", round(389 / 912, 3), "; 304/912 =", round(304 / 912, 3))
print("Per mouse (reading a, a):")
print(pyr[pyr.selective].groupby("animal").apply(lambda x: pd.Series(alm.categories(x.assign(selective=True)))).T.to_string())
lick_early response_s prep_only both peri_only n text_reading_ok figure_reading_ok frac_prep_only frac_both frac_peri_only
drop 1.3 219 389 304 912 False True 0.240 0.427 0.333
drop 1.5 221 387 302 910 False True 0.243 0.425 0.332
keep 1.3 226 407 317 950 False True 0.238 0.428 0.334
keep 1.5 227 406 315 948 False True 0.239 0.428 0.332
Paper, as fractions of 912: preparatory only 0.24 ; 389/912 = 0.427 ; 304/912 = 0.333
Per mouse (reading a, a):
animal ANM210861 ANM210862 ANM210863 ANM214427 ANM214429 ANM214430 ANM218453 ANM218457 ANM218693 ANM219030 ANM219031 ANM219033 ANM219036 ANM219037 ANM219038 ANM219247 ANM219248 ANM219253 ANM221977
prep_only 6 6 20 4 3 9 9 25 14 3 11 12 13 14 13 9 30 14 4
both 11 8 18 7 11 10 8 31 24 14 27 21 24 34 31 11 50 35 14
peri_only 3 15 14 7 16 12 12 24 4 16 31 8 32 24 28 16 26 12 4
n 20 29 52 18 30 31 29 80 42 33 69 41 69 72 72 36 106 61 22
Result: reproduced, under the figure's reading of the labels. With lick early trials dropped and a 1.3 s response epoch the 912 selective neurons split into 219 preparatory only, 389 with both and 304 peri-movement only. This matches Fig. 2d (reading b) exactly and the text (reading a, 389 peri-movement only and 304 both) not at all, under every reading of the response epoch and of lick early trials. The text has the two larger counts the wrong way round.
fig2c-selectivity-time-course¶
Selectivity emerges in the sample epoch, increases through the delay epoch and is largest at the beginning of the response epoch.
Measure 1 (ED Fig. 1f): the number of pyramidal neurons significant (two-tailed t-test on spike counts, P < 0.05) in 200 ms windows, stepped by 10 ms. Measure 2 (Fig. 2c): the population selectivity of the selective neurons, preferred minus non-preferred rate, with the preference set from 10 random trials of each type (by spike count from sample onset to the end of the response epoch, as the data set's compile script does) and the rate difference taken on the remaining trials. Neurons need at least 11 trials of each type for the split; the data set's script requires more than 15, a variant. The epoch boundaries relative to the cue are the medians over trials. Seeds are fixed.
rng = np.random.default_rng(20150305)
t_sample = -float(np.median(g.cue - g.pole_in))
t_delay = -float(np.median(g.cue - g.pole_out))
print(f"Median sample onset {t_sample:.3f} s and delay onset {t_delay:.3f} s relative to the cue")
cnt_sig, cnt_sig_shuf, popsel, popsel15, n_pop = None, None, [], [], 0
sel_keys = set(map(tuple, pyr[pyr.selective][["session", "unit"]].values))
pyr_keys = set(map(tuple, pyr[["session", "unit"]].values))
for s, u in units:
key = (s["session"], u["unit"])
if key not in pyr_keys:
continue
tr = s["trials"]
r, l = alm.trial_mask(tr, u)
if r.sum() < 2 or l.sum() < 2:
continue
br, bl = alm.cue_binned(u, tr, r), alm.cue_binned(u, tr, l)
wr, centers = alm.window_sums(br)
wl, _ = alm.window_sums(bl)
p = stats.ttest_ind(wr, wl, axis=0).pvalue
p = np.where(np.isnan(p), 1, p)
allw = np.vstack([wr, wl])
perm = rng.permutation(len(allw))
ps = stats.ttest_ind(allw[perm[:len(wr)]], allw[perm[len(wr):]], axis=0).pvalue
ps = np.where(np.isnan(ps), 1, ps)
cnt_sig = (p < 0.05).astype(int) if cnt_sig is None else cnt_sig + (p < 0.05)
cnt_sig_shuf = (ps < 0.05).astype(int) if cnt_sig_shuf is None else cnt_sig_shuf + (ps < 0.05)
if key in sel_keys and r.sum() >= 11 and l.sum() >= 11:
ir, il = rng.permutation(r.sum()), rng.permutation(l.sum())
whole = lambda b: b[:, (alm.CUE_EDGES[:-1] >= t_sample) & (alm.CUE_EDGES[:-1] < alm.RESPONSE_S)].sum(axis=1)
pref_r = whole(br)[ir[:10]].mean() >= whole(bl)[il[:10]].mean()
diff = (wr[ir[10:]].mean(axis=0) - wl[il[10:]].mean(axis=0)) / alm.WIN_S
popsel.append(diff if pref_r else -diff)
if r.sum() > 15 and l.sum() > 15:
popsel15.append(popsel[-1])
popsel, popsel15 = np.array(popsel), np.array(popsel15)
print("Neurons in measure 1:", None if cnt_sig is None else "pyramidal with >= 2 trials of each type",
"; in measure 2:", len(popsel), "(>15 trials each:", len(popsel15), ")")
def at(x, t):
return float(x[np.argmin(np.abs(centers - t))])
def check(x, name):
rng_t = (centers >= -3.4) & (centers <= 1.9)
tmax = float(centers[rng_t][np.argmax(x[rng_t])])
v = {"measure": name, "pre_sample": at(x, t_sample - 0.1), "sample_end": at(x, t_delay - 0.1),
"delay_start": at(x, t_delay + 0.1), "delay_end": at(x, -0.1), "max_value": float(x[rng_t].max()), "t_max_s": tmax}
v["emerges"] = v["sample_end"] > v["pre_sample"]
v["increases_in_delay"] = v["delay_end"] > v["delay_start"]
v["max_within_0.5s"] = 0 < tmax <= 0.5
v["max_within_0.2s"] = 0 < tmax <= 0.2
return v
res = pd.DataFrame([check(cnt_sig.astype(float), "1 significant neurons"), check(popsel.mean(axis=0), "2 population selectivity"),
check(popsel15.mean(axis=0), "2 variant, >15 trials")])
print(res.round(3).to_string(index=False))
print("\nShuffled labels, significant neurons: median", int(np.median(cnt_sig_shuf)), "max", int(cnt_sig_shuf.max()),
"; true labels before sample onset (window centred 0.1 s before):", int(at(cnt_sig, t_sample - 0.1)),
"; 5% of the neurons tested:", round(0.05 * len(pyr)))
fig, ax = plt.subplots(1, 2, figsize=(11, 3.2))
ax[0].plot(centers, cnt_sig, "k"); ax[0].plot(centers, cnt_sig_shuf, color="0.6")
ax[1].plot(centers, popsel.mean(axis=0), "k")
for a in ax:
for x in (t_sample, t_delay, 0):
a.axvline(x, color="0.7", ls=":")
a.set_xlabel("time from cue (s)")
ax[0].set_ylabel("significant neurons"); ax[1].set_ylabel("pref - nonpref (spikes/s)")
plt.tight_layout(); plt.show()
print("Plotted ranges: significant neurons", int(cnt_sig.min()), "to", int(cnt_sig.max()), "; population selectivity",
round(float(popsel.mean(axis=0).min()), 2), "to", round(float(popsel.mean(axis=0).max()), 2), "spikes/s")
Median sample onset -2.601 s and delay onset -1.300 s relative to the cue
Neurons in measure 1: pyramidal with >= 2 trials of each type ; in measure 2: 880 (>15 trials each: 848 )
measure pre_sample sample_end delay_start delay_end max_value t_max_s emerges increases_in_delay max_within_0.5s max_within_0.2s
1 significant neurons 60.000 246.00 298.000 379.000 554.000 0.19 True True True True
2 population selectivity 0.005 1.19 1.460 2.284 3.379 0.20 True True True True
2 variant, >15 trials 0.016 1.15 1.409 2.284 3.409 0.19 True True True True
Shuffled labels, significant neurons: median 54 max 76 ; true labels before sample onset (window centred 0.1 s before): 60 ; 5% of the neurons tested: 62
Plotted ranges: significant neurons 0 to 554 ; population selectivity -0.04 to 3.38 spikes/s
Result: reproduced. The number of significant pyramidal neurons is 60 in the window before sample onset (shuffled labels: median 54, 5% of neurons 62), 246 at the end of the sample epoch, 298 at the start and 379 at the end of the delay, and peaks at 554 in the window centred 0.19 s after the cue. The population selectivity of 880 selective neurons is 0.005 spikes/s before the sample, 1.19 at the end of the sample, 1.46 and 2.28 at the start and end of the delay, and peaks at 3.38 spikes/s 0.20 s after the cue. Both measures meet all three conditions under both readings (maximum within 0.2 s of the cue).
fig2c-dynamic-single-neurons¶
Individual neuron responses are dynamic while selectivity at the population level is stable.
Population response correlation (Methods): for the selective neurons, each neuron's cue-aligned rate (200 ms window, 10 ms step, correct trials) is mean-subtracted and divided by the variance of its response across the trial (as the Methods say; the data set's script does the same; division by the s.d. is a variant). Pearson's r between the population vector at each time and at the cue. Readings (a) the vector of selectivities (R minus L) and (b) the R and L rates concatenated. The population selectivity is measure 2 of the previous claim.
PR, PL = [], []
for s, u in units:
if (s["session"], u["unit"]) not in sel_keys:
continue
tr = s["trials"]
r, l = alm.trial_mask(tr, u)
if r.sum() < 2 or l.sum() < 2:
continue
PR.append(alm.window_sums(alm.cue_binned(u, tr, r))[0].mean(axis=0) / alm.WIN_S)
PL.append(alm.window_sums(alm.cue_binned(u, tr, l))[0].mean(axis=0) / alm.WIN_S)
PR, PL = np.array(PR), np.array(PL)
span = (centers >= -3.4) & (centers <= 1.9)
def norm(x, how):
x = x[:, span]
x = x - x.mean(axis=1, keepdims=True)
d = x.var(axis=1, keepdims=True) if how == "var" else x.std(axis=1, keepdims=True)
return x / np.where(d == 0, np.nan, d)
cs = centers[span]
i0 = np.argmin(np.abs(cs))
win_early = (cs >= t_sample) & (cs <= t_delay + 0.5)
rows, curves = [], {}
for how in ("var", "sd"):
nr, nl = norm(PR, how), norm(PL, how)
for reading, M in (("a selectivity", nr - nl), ("b concatenated", np.vstack([nr, nl]))):
ok = ~np.isnan(M).any(axis=1)
M = M[ok]
rc = np.array([np.corrcoef(M[:, j], M[:, i0])[0, 1] for j in range(M.shape[1])])
curves[(how, reading)] = rc
rows.append({"normalised_by": how, "reading": reading, "neurons_rows": int(ok.sum()),
"mean_r_sample_to_delay+0.5": rc[win_early].mean(), "max_r_in_that_window": rc[win_early].max(),
"r_at_delay_end_-0.1s": rc[np.argmin(np.abs(cs + 0.1))]})
dyn = pd.DataFrame(rows)
dyn["below_0.5"] = dyn["mean_r_sample_to_delay+0.5"] < 0.5
print(dyn.round(3).to_string(index=False))
ps_curve = popsel.mean(axis=0)
stable = (centers >= t_delay - 0.1) & (centers <= -0.1)
print("\nPopulation selectivity from the end of the sample epoch through the delay: min", round(float(ps_curve[stable].min()), 3),
"spikes/s; all above 0:", bool((ps_curve[stable] > 0).all()))
normalised_by reading neurons_rows mean_r_sample_to_delay+0.5 max_r_in_that_window r_at_delay_end_-0.1s below_0.5
var a selectivity 912 -0.168 -0.024 0.279 True
var b concatenated 1824 -0.159 -0.042 0.349 True
sd a selectivity 912 -0.041 0.239 0.737 True
sd b concatenated 1824 -0.084 0.254 0.720 True
Population selectivity from the end of the sample epoch through the delay: min 1.19 spikes/s; all above 0: True
Result: reproduced, resting on the claims file's 0.5 bound. The mean population response correlation with the cue-time vector over the sample epoch and the first 0.5 s of the delay is -0.168 (reading a) and -0.159 (reading b), with maxima of -0.024 and -0.042 in that span; with division by the s.d. it is -0.041 and -0.084. All are below 0.5, while the population selectivity stays above 0 from the end of the sample epoch through the delay (minimum 1.19 spikes/s).
ed2-error-trials-predict-choice¶
On error trials, when mice lick opposite to the instructed direction, ALM activity predicts the licking direction; most selective neurons switch their trial type preference.
Error trials are labelled by the instructed side (ErrR: pole for lick right, mouse licked left). Per selective pyramidal neuron and epoch, correct selectivity R minus L and error selectivity ErrR minus ErrL. Readings: at least 1 or at least 5 error trials of each type; the data set's script uses more than 10 correct and more than 5 error trials of each type (variant).
rows = []
sp = pyr[pyr.selective]
for name, m in (("min 1 error each", (sp.n_errR >= 1) & (sp.n_errL >= 1)), ("min 5 error each", (sp.n_errR >= 5) & (sp.n_errL >= 5)),
("script: >10 correct, >5 error", (sp.n_R > 10) & (sp.n_L > 10) & (sp.n_errR > 5) & (sp.n_errL > 5))):
d = sp[m]
for e in ("sample", "delay", "response"):
c = d[f"{e}_R"] - d[f"{e}_L"]
er = d[f"{e}_errR"] - d[f"{e}_errL"]
r, p = stats.pearsonr(c, er)
nz = (c != 0) & (er != 0)
rows.append({"reading": name, "epoch": e, "neurons": len(d), "r": r, "p": p,
"fraction_switched": float((np.sign(c[nz]) != np.sign(er[nz])).mean()), "n_nonzero": int(nz.sum())})
err = pd.DataFrame(rows)
err["holds"] = (err.r < 0) & (err.p < 0.05) & (err.fraction_switched > 0.5)
print(err.round(4).to_string(index=False))
print("\nSelective pyramidal neurons without error trials of both types:", int(((sp.n_errR < 1) | (sp.n_errL < 1)).sum()), "of", len(sp))
print("\nUnder the four readings of the shared methods (selection 'min 1 error each'):")
rows = []
for (le, resp), d in UT.items():
sp_ = d[(d.label == "pyramidal") & d.selective & (d.n_errR >= 1) & (d.n_errL >= 1)]
for e in ("sample", "delay", "response"):
c, er = sp_[f"{e}_R"] - sp_[f"{e}_L"], sp_[f"{e}_errR"] - sp_[f"{e}_errL"]
nz = (c != 0) & (er != 0)
r, p = stats.pearsonr(c, er)
rows.append({"lick_early": le, "response_s": resp, "epoch": e, "neurons": len(sp_), "r": r, "p": p,
"fraction_switched": float((np.sign(c[nz]) != np.sign(er[nz])).mean())})
er4 = pd.DataFrame(rows)
er4["holds"] = (er4.r < 0) & (er4.p < 0.05) & (er4.fraction_switched > 0.5)
print(er4.round(4).to_string(index=False))
reading epoch neurons r p fraction_switched n_nonzero holds
min 1 error each sample 843 -0.0848 0.0138 0.5072 830 True
min 1 error each delay 843 -0.4345 0.0000 0.5713 828 True
min 1 error each response 843 -0.5020 0.0000 0.6267 833 True
min 5 error each sample 592 -0.0981 0.0170 0.5239 586 True
min 5 error each delay 592 -0.4796 0.0000 0.5873 584 True
min 5 error each response 592 -0.4428 0.0000 0.6444 585 True
script: >10 correct, >5 error sample 496 -0.1227 0.0062 0.5244 492 True
script: >10 correct, >5 error delay 496 -0.4595 0.0000 0.6041 490 True
script: >10 correct, >5 error response 496 -0.4410 0.0000 0.6517 491 True
Selective pyramidal neurons without error trials of both types: 69 of 912
Under the four readings of the shared methods (selection 'min 1 error each'):
lick_early response_s epoch neurons r p fraction_switched holds
drop 1.3 sample 843 -0.0848 0.0138 0.5072 True
drop 1.3 delay 843 -0.4345 0.0000 0.5713 True
drop 1.3 response 843 -0.5020 0.0000 0.6267 True
drop 1.5 sample 841 -0.0816 0.0179 0.5042 True
drop 1.5 delay 841 -0.4342 0.0000 0.5738 True
drop 1.5 response 841 -0.4727 0.0000 0.6157 True
keep 1.3 sample 885 -0.0968 0.0040 0.5023 True
keep 1.3 delay 885 -0.4228 0.0000 0.5865 True
keep 1.3 response 885 -0.4508 0.0000 0.6137 True
keep 1.5 sample 883 -0.0972 0.0039 0.5017 True
keep 1.5 delay 883 -0.4238 0.0000 0.5913 True
keep 1.5 response 883 -0.4175 0.0000 0.5968 True
Result: reproduced. Under both readings and the script's selection, correct and error selectivity are negatively correlated in all three epochs (sample r = -0.085 to -0.123, P 0.006 to 0.017; delay r = -0.43 to -0.48; response r = -0.44 to -0.50, printed P < 0.0001), and the fraction of neurons whose error selectivity has the opposite sign exceeds one half in every epoch (0.507 to 0.652). The four readings of the shared methods give the same (sample r = -0.082 to -0.097, P 0.004 to 0.018; switched fractions 0.502 to 0.627). In the sample epoch the correlation is weak and the fraction just above one half (0.502 to 0.507 with at least one error trial of each type).
fig2e-equal-contra-ipsi¶
Among selective putative pyramidal neurons, contra-preferring and ipsi-preferring neurons are present in equal proportions (427 contra-preferring and 485 ipsi-preferring in Fig. 2c).
Preference from the spike rates from sample onset to the end of the response epoch, R against L (reading a, all correct trials; Methods), or from the 10-trial split of the previous claims (reading b). The test is the Methods' bootstrap over neurons, one-tailed, 10^4 resamples.
rng = np.random.default_rng(2)
sp = pyr[pyr.selective]
ca = sp.contra.values
pb = popsel # sign convention: the 10-trial split's preference is in the sign of R-L on held-out trials below
rows = [{"reading": "a total counts", "contra": int(ca.sum()), "ipsi": int((~ca).sum()), "fraction_contra": ca.mean(),
"P_more_contra": alm.bootstrap_more_ipsi(ca, rng=rng)}]
# reading b: preference from 10 random trials of each type
rng_b = np.random.default_rng(3)
cb = []
for s, u in units:
if (s["session"], u["unit"]) not in sel_keys:
continue
tr = s["trials"]
r, l = alm.trial_mask(tr, u)
if r.sum() < 11 or l.sum() < 11:
continue
a, b = alm.epoch_bounds(tr)["trial"]
cr, cl = alm.counts_in(u, tr, r, a, b), alm.counts_in(u, tr, l, a, b)
cb.append(cr[rng_b.permutation(len(cr))[:10]].mean() > cl[rng_b.permutation(len(cl))[:10]].mean())
cb = np.array(cb)
rows.append({"reading": "b 10-trial split", "contra": int(cb.sum()), "ipsi": int((~cb).sum()), "fraction_contra": cb.mean(),
"P_more_contra": alm.bootstrap_more_ipsi(cb, rng=rng)})
pref = pd.DataFrame(rows)
pref["counts_ok"] = (abs(pref.contra - 427) <= 42.7) & (abs(pref.ipsi - 485) <= 48.5)
pref["no_more_contra"] = pref.P_more_contra >= 0.05
print(pref.round(4).to_string(index=False))
print("\nPer mouse, reading a, fraction contra-preferring:", sp.groupby("animal").contra.mean().round(2).to_dict())
print("Binomial test against 0.5 (variant), reading a: p =", round(stats.binomtest(int(ca.sum()), len(ca)).pvalue, 4))
print("\nReading a under the four readings of the shared methods:")
rows = []
for (le, resp), d in UT.items():
c = d[(d.label == "pyramidal") & d.selective].contra.values
rows.append({"lick_early": le, "response_s": resp, "contra": int(c.sum()), "ipsi": int((~c).sum()),
"P_more_contra": alm.bootstrap_more_ipsi(c, rng=np.random.default_rng(5))})
print(pd.DataFrame(rows).round(4).to_string(index=False))
reading contra ipsi fraction_contra P_more_contra counts_ok no_more_contra
a total counts 427 485 0.4682 0.9695 True True
b 10-trial split 436 444 0.4955 0.6036 True True
Per mouse, reading a, fraction contra-preferring: {'ANM210861': 0.1, 'ANM210862': 0.52, 'ANM210863': 0.42, 'ANM214427': 0.28, 'ANM214429': 0.5, 'ANM214430': 0.52, 'ANM218453': 0.48, 'ANM218457': 0.42, 'ANM218693': 0.38, 'ANM219030': 0.36, 'ANM219031': 0.51, 'ANM219033': 0.49, 'ANM219036': 0.45, 'ANM219037': 0.53, 'ANM219038': 0.39, 'ANM219247': 0.67, 'ANM219248': 0.55, 'ANM219253': 0.49, 'ANM221977': 0.55}
Binomial test against 0.5 (variant), reading a: p = 0.059
Reading a under the four readings of the shared methods:
lick_early response_s contra ipsi P_more_contra
drop 1.3 427 485 0.9707
drop 1.5 431 479 0.9440
keep 1.3 458 492 0.8590
keep 1.5 456 492 0.8738
Result: reproduced. By total counts 427 selective pyramidal neurons prefer contra and 485 ipsi, the counts of Fig. 2c exactly (fraction contra 0.468); the Methods' bootstrap finds no excess of contra-preferring neurons (P = 0.97). With the 10-trial split, 436 and 444 (P = 0.60). The four readings of the shared methods give 427 to 458 contra and 479 to 492 ipsi (P 0.86 to 0.97). A binomial test of reading a against 0.5 gives p = 0.059, so ipsi-preferring neurons are slightly more common, short of significance.
ed1-no-population-contra-bias¶
The overall spike count of the recorded population shows no significant contralateral bias (P = 0.13, two-tailed t-test against 0).
Per neuron, the difference between its mean spike rate on R and L trials from sample onset to the end of the response epoch; two-tailed one-sample t-test against 0. Readings (a) selective pyramidal neurons, (b) all pyramidal neurons, (c) all units.
rows = []
for name, d in (("a selective pyramidal", pyr[pyr.selective]), ("b all pyramidal", pyr), ("c all units", D)):
x = (d.trial_R - d.trial_L).dropna()
t_, p_ = stats.ttest_1samp(x, 0)
rows.append({"reading": name, "neurons": len(x), "mean_R_minus_L_spk_s": x.mean(), "median": x.median(), "t": t_, "p": p_})
bias = pd.DataFrame(rows)
bias["significant"] = bias.p < 0.05
print(bias.round(4).to_string(index=False))
for le_resp in [("keep", 1.3), ("drop", 1.5)]:
d = UT[le_resp]; x = (d[d.label == "pyramidal"].trial_R - d[d.label == "pyramidal"].trial_L).dropna()
print("Variant", le_resp, "all pyramidal: mean", round(x.mean(), 3), "p", round(stats.ttest_1samp(x, 0).pvalue, 4))
print("\nUnder the four readings of the shared methods:")
rows = []
for (le, resp), d in UT.items():
for name, x in (("a selective pyramidal", d[(d.label == "pyramidal") & d.selective]), ("b all pyramidal", d[d.label == "pyramidal"]), ("c all units", d)):
y = (x.trial_R - x.trial_L).dropna()
rows.append({"lick_early": le, "response_s": resp, "reading": name, "neurons": len(y), "mean": y.mean(), "p": stats.ttest_1samp(y, 0).pvalue})
print(pd.DataFrame(rows).round(4).to_string(index=False))
reading neurons mean_R_minus_L_spk_s median t p significant
a selective pyramidal 912 0.0903 -0.0949 0.7776 0.4370 False
b all pyramidal 1243 0.0611 -0.0358 0.7130 0.4760 False
c all units 1405 0.0711 -0.0312 0.8573 0.3914 False
Variant ('keep', 1.3) all pyramidal: mean 0.078 p 0.3567
Variant ('drop', 1.5) all pyramidal: mean 0.043 p 0.6153
Under the four readings of the shared methods:
lick_early response_s reading neurons mean p
drop 1.3 a selective pyramidal 912 0.0903 0.4370
drop 1.3 b all pyramidal 1243 0.0611 0.4760
drop 1.3 c all units 1405 0.0711 0.3914
drop 1.5 a selective pyramidal 910 0.0759 0.5093
drop 1.5 b all pyramidal 1243 0.0426 0.6153
drop 1.5 c all units 1405 0.0502 0.5419
keep 1.3 a selective pyramidal 950 0.1151 0.2980
keep 1.3 b all pyramidal 1244 0.0781 0.3567
keep 1.3 c all units 1407 0.1095 0.1802
keep 1.5 a selective pyramidal 948 0.0980 0.3700
keep 1.5 b all pyramidal 1244 0.0616 0.4615
keep 1.5 c all units 1407 0.0904 0.2634
Result: reproduced. The mean lick right minus lick left rate is 0.090 spikes/s for the selective pyramidal neurons (P = 0.44), 0.061 for all pyramidal neurons (P = 0.48) and 0.071 for all units (P = 0.39); none is significant, as the paper's P = 0.13 is not. Under the four readings of the shared methods the three neuron sets give P = 0.18 to 0.62, none significant.
ed1-fast-spiking-properties¶
Fast-spiking neurons have higher baseline firing rates and are less selective than putative pyramidal neurons.
Baseline readings: (a) the rate before sample onset (from the start of the trial), (b) the 0.5 s before sample onset; the average of the R and L trial means. Selectivity readings: (a) the fraction selective by the shared test, (b) the absolute rate difference over the three epochs.
fs = D[D.label == "FS"]
rows = []
for name, col in (("a whole pre-sample", "pre_all"), ("b 0.5 s pre-sample", "pre")):
bf, bp = (fs[f"{col}_R"] + fs[f"{col}_L"]) / 2, (pyr[f"{col}_R"] + pyr[f"{col}_L"]) / 2
rows.append({"measure": "baseline " + name, "FS_mean": bf.mean(), "pyr_mean": bp.mean(), "FS_median": bf.median(),
"pyr_median": bp.median(), "FS_higher": bf.mean() > bp.mean() and bf.median() > bp.median(),
"ranksum_p": stats.mannwhitneyu(bf.dropna(), bp.dropna()).pvalue})
rows.append({"measure": "selectivity a fraction selective", "FS_mean": fs.selective.mean(), "pyr_mean": pyr.selective.mean(),
"FS_less_selective": fs.selective.mean() < pyr.selective.mean()})
af, ap = (fs.trial_R - fs.trial_L).abs(), (pyr.trial_R - pyr.trial_L).abs()
rows.append({"measure": "selectivity b |R-L| (spk/s)", "FS_mean": af.mean(), "pyr_mean": ap.mean(), "FS_median": af.median(),
"pyr_median": ap.median(), "FS_less_selective": af.mean() < ap.mean(), "ranksum_p": stats.mannwhitneyu(af.dropna(), ap.dropna()).pvalue})
afn, apn = af / ((fs.trial_R + fs.trial_L) / 2), ap / ((pyr.trial_R + pyr.trial_L) / 2)
rows.append({"measure": "variant |R-L| / mean rate", "FS_mean": afn.mean(), "pyr_mean": apn.mean(), "FS_median": afn.median(),
"pyr_median": apn.median(), "FS_less_selective": afn.median() < apn.median(), "ranksum_p": stats.mannwhitneyu(afn.dropna(), apn.dropna()).pvalue})
print(pd.DataFrame(rows).round(4).to_string(index=False))
print("\nFS neurons:", len(fs), "; pyramidal:", len(pyr), "; FS per mouse:", fs.groupby("animal").size().to_dict())
print("\nUnder the four readings of the shared methods:")
rows = []
for (le, resp), d in UT.items():
f_, p_ = d[d.label == "FS"], d[d.label == "pyramidal"]
rows.append({"lick_early": le, "response_s": resp, "FS_baseline_0.5s": ((f_.pre_R + f_.pre_L) / 2).mean(),
"pyr_baseline_0.5s": ((p_.pre_R + p_.pre_L) / 2).mean(),
"FS_frac_selective": f_.selective.mean(), "pyr_frac_selective": p_.selective.mean(),
"FS_abs_diff": (f_.trial_R - f_.trial_L).abs().mean(), "pyr_abs_diff": (p_.trial_R - p_.trial_L).abs().mean()})
fsr = pd.DataFrame(rows)
fsr["FS_less_selective_any"] = (fsr.FS_frac_selective < fsr.pyr_frac_selective) | (fsr.FS_abs_diff < fsr.pyr_abs_diff)
print(fsr.round(4).to_string(index=False))
measure FS_mean pyr_mean FS_median pyr_median FS_higher ranksum_p FS_less_selective
baseline a whole pre-sample 9.0304 3.9658 6.3971 2.3694 True 0.0 NaN
baseline b 0.5 s pre-sample 9.0581 3.9804 6.5900 2.3781 True 0.0 NaN
selectivity a fraction selective 0.7984 0.7325 NaN NaN NaN NaN False
selectivity b |R-L| (spk/s) 2.2856 1.5266 1.2458 0.6059 NaN 0.0 False
variant |R-L| / mean rate 0.2755 0.4598 0.2109 0.3310 NaN 0.0 True
FS neurons: 124 ; pyramidal: 1245 ; FS per mouse: {'ANM210861': 6, 'ANM210862': 6, 'ANM210863': 9, 'ANM214427': 3, 'ANM214429': 3, 'ANM214430': 3, 'ANM218453': 8, 'ANM218457': 11, 'ANM218693': 6, 'ANM219030': 9, 'ANM219031': 11, 'ANM219033': 5, 'ANM219036': 7, 'ANM219037': 4, 'ANM219038': 8, 'ANM219247': 4, 'ANM219248': 13, 'ANM219253': 6, 'ANM221977': 2}
Under the four readings of the shared methods:
lick_early response_s FS_baseline_0.5s pyr_baseline_0.5s FS_frac_selective pyr_frac_selective FS_abs_diff pyr_abs_diff FS_less_selective_any
drop 1.3 9.0581 3.9804 0.7984 0.7325 2.2856 1.5266 False
drop 1.5 9.0581 3.9804 0.7984 0.7309 2.2723 1.5191 False
keep 1.3 9.1777 3.9797 0.8387 0.7631 2.2795 1.4964 False
keep 1.5 9.1777 3.9797 0.8468 0.7614 2.2539 1.4841 False
Result: partially reproduced. FS neurons have higher baseline rates than pyramidal neurons under both readings (mean 9.03 against 3.97 spikes/s, median 6.40 against 2.37, rank-sum p printed as 0.0). They are not less selective under either of the criterion's readings: 79.8% of FS neurons are selective against 73.3% of pyramidal neurons, and their mean absolute rate difference is larger (2.29 against 1.53 spikes/s). The four readings of the shared methods give the same (FS 79.8% to 84.7% selective against 73.1% to 76.3%; 2.25 to 2.29 against 1.48 to 1.53 spikes/s). Only relative to their rate (a variant the criterion does not name) are FS neurons less selective (median 0.21 against 0.33). The baseline half of the claim holds and the selectivity half does not.
tagging-counts¶
73 neurons were antidromically activated from PT axons and 134 from IT axons; 45 and 27 passed the collision test (PT and IT neurons), 22 and 106 failed it, and 6 and 1 could not be tested and were excluded.
print("Units labelled PT:", int((D.tag == "PT").sum()), "; IT:", int((D.tag == "IT").sum()))
print("PT per mouse:", D[D.tag == "PT"].groupby("animal").size().to_dict())
print("IT per mouse:", D[D.tag == "IT"].groupby("animal").size().to_dict())
print("Labels other than pyramidal, FS, PT, IT:", sorted({c for s, u in units for c in u['cell_types']} - {"pyramidal", "FS", "PT", "IT"}))
print("Sessions with PT (type 1) tagging trials:", T[T.ptype == 1].session.nunique(), "; with IT (types 2 to 5):", T[T.ptype.isin([2, 3, 4, 5])].session.nunique())
Units labelled PT: 45 ; IT: 27
PT per mouse: {'ANM214427': 1, 'ANM214429': 4, 'ANM219030': 4, 'ANM219031': 1, 'ANM219033': 3, 'ANM219036': 8, 'ANM219037': 12, 'ANM219038': 12}
IT per mouse: {'ANM214427': 3, 'ANM218453': 5, 'ANM218457': 3, 'ANM219247': 5, 'ANM219248': 7, 'ANM219253': 3, 'ANM221977': 1}
Labels other than pyramidal, FS, PT, IT: []
Sessions with PT (type 1) tagging trials: 49 ; with IT (types 2 to 5): 47
Result: reproduced for the PT and IT counts. The labels give 45 PT neurons in 8 mice and 27 IT neurons in 7 mice, the paper's numbers. The pyramidal-tract-activated and intratelencephalic-activated neurons and the untestable ones have no label, so those counts cannot be reported.
The data set labels only the neurons that passed the collision test. The pyramidal-tract- and intratelencephalic-activated neurons (22 and 106) and the 7 that could not be tested carry no label, so their counts cannot be read from the data set.
antidromic-latency-jitter¶
PT neurons have shorter antidromic latencies than IT neurons (mean 2.7 against 4.6 ms) and both have small jitter (mean s.d. 0.1 and 0.2 ms) ...; the mean jitter of tagged neurons is 0.15 ms.
Pulse onsets are read from the AOM input trace (10 kHz, so 0.1 ms steps); spike times are at the 19531.25 Hz sampling of the recording. For each PT neuron, the PT axonal stimulation trials (type 1); for each IT neuron, the IT trials (type 2, and in a variant also the undocumented types 3 to 5). Latency is the first spike within 10 ms of a pulse onset (before the second pulse). The paper does not say how antidromic spikes are told from spontaneous ones; here they are the spikes within ±1 ms of the neuron's modal latency (0.2 ms bins), with ±0.5 ms and a robust s.d. (1.4826 times the median absolute deviation within ±1 ms) as variants (an assumption). The second cell counts, per neuron, the spikes observed between 0.5 and 1 ms from the mode against those expected from the spontaneous background, and draws the latency histograms of the IT neurons with both windows marked. The third gives readings that need no window: a per-neuron fit of a Gaussian peak plus a uniform background, the same with a broad Gaussian added for broad stimulus-locked humps, and the ±1 ms jitter without the four IT neurons whose histograms show such humps. Readings: (a) first pulse of each pair, (b) both pulses pooled.
def lat_table(it_types, hw):
rows = []
for s, u in units:
tag = "PT" if "PT" in u["cell_types"] else "IT" if "IT" in u["cell_types"] else ""
if not tag:
continue
types = {1.0} if tag == "PT" else it_types
l0 = alm.antidromic_latencies(s, u, types, order=0)
l1 = alm.antidromic_latencies(s, u, types, order=1)
for reading, lat in (("a first pulse", l0), ("b both pulses", np.r_[l0, l1])):
m, sd, n, nr = alm.latency_mode_stats(lat, hw)
rows.append({"session": s["session"], "unit": u["unit"], "animal": s["animal"], "tag": tag, "reading": reading,
"latency_ms": m, "jitter_ms": sd, "n_resp": n, "n_pulses": len(lat), "p_resp": n / max(len(lat), 1)})
return pd.DataFrame(rows)
LT = {}
summ = []
for it_types, it_name in (({2.0}, "IT type 2"), ({2.0, 3.0, 4.0, 5.0}, "IT types 2-5")):
for hw in (1.0, 0.5):
lt = lat_table(it_types, hw)
LT[(it_name, hw)] = lt
for reading, d in lt.groupby("reading"):
ok = d[d.n_resp >= 3]
pt, it = ok[ok.tag == "PT"], ok[ok.tag == "IT"]
summ.append({"IT trials": it_name, "window_ms": hw, "reading": reading, "PT_n": len(pt), "IT_n": len(it),
"PT_latency": pt.latency_ms.mean(), "IT_latency": it.latency_ms.mean(),
"PT_jitter": pt.jitter_ms.mean(), "IT_jitter": it.jitter_ms.mean(), "tagged_jitter": ok.jitter_ms.mean(),
"PT_latency_median": pt.latency_ms.median(), "IT_latency_median": it.latency_ms.median()})
lat = pd.DataFrame(summ)
lat["PT_ok"] = (abs(lat.PT_latency - 2.7) <= 0.27) & (abs(lat.PT_jitter - 0.1) <= 0.05)
lat["IT_ok"] = (abs(lat.IT_latency - 4.6) <= 0.46) & (abs(lat.IT_jitter - 0.2) <= 0.05)
lat["tagged_jitter_ok"] = abs(lat.tagged_jitter - 0.15) <= 0.015
lat["PT_shorter"] = lat.PT_latency < lat.IT_latency
print(lat.round(3).to_string(index=False))
main_lt = LT[("IT type 2", 1.0)]
print("\nPer neuron (IT type 2, ±1 ms, first pulse):")
print(main_lt[main_lt.reading == "a first pulse"].round(3).to_string(index=False))
IT trials window_ms reading PT_n IT_n PT_latency IT_latency PT_jitter IT_jitter tagged_jitter PT_latency_median IT_latency_median PT_ok IT_ok tagged_jitter_ok PT_shorter
IT type 2 1.0 a first pulse 45 21 2.672 4.979 0.126 0.310 0.184 2.712 4.570 True False False True
IT type 2 1.0 b both pulses 45 21 2.736 4.335 0.151 0.317 0.204 2.743 3.668 False False False True
IT type 2 0.5 a first pulse 45 21 2.675 5.002 0.113 0.198 0.140 2.714 4.570 True True True True
IT type 2 0.5 b both pulses 45 21 2.731 4.292 0.131 0.190 0.150 2.758 3.562 True True True True
IT types 2-5 1.0 a first pulse 45 27 2.672 4.561 0.126 0.265 0.178 2.712 4.257 True False False True
IT types 2-5 1.0 b both pulses 45 27 2.736 4.052 0.151 0.276 0.198 2.743 3.604 False False False True
IT types 2-5 0.5 a first pulse 45 27 2.675 4.578 0.113 0.177 0.137 2.714 4.284 True True True True
IT types 2-5 0.5 b both pulses 45 27 2.731 4.018 0.131 0.175 0.148 2.758 3.541 True False True True
Per neuron (IT type 2, ±1 ms, first pulse):
session unit animal tag reading latency_ms jitter_ms n_resp n_pulses p_resp
ANM214427_20130806 2 ANM214427 IT a first pulse 3.278 0.198 79.0 200 0.395
ANM214427_20130806 3 ANM214427 PT a first pulse 2.949 0.110 133.0 270 0.493
ANM214427_20130808 1 ANM214427 IT a first pulse 4.451 0.408 73.0 610 0.120
ANM214427_20130808 2 ANM214427 IT a first pulse 3.474 0.490 93.0 600 0.155
ANM214429_20130806 1 ANM214429 PT a first pulse 2.806 0.057 107.0 250 0.428
ANM214429_20130806 7 ANM214429 PT a first pulse 2.714 0.058 189.0 320 0.591
ANM214429_20130807 7 ANM214429 PT a first pulse 3.662 0.201 540.0 670 0.806
ANM214429_20130808 1 ANM214429 PT a first pulse 2.934 0.119 429.0 540 0.794
ANM218453_20131014 9 ANM218453 IT a first pulse 4.570 0.075 3.0 10 0.300
ANM218453_20131014 16 ANM218453 IT a first pulse NaN NaN 0.0 0 0.000
ANM218453_20131015 10 ANM218453 IT a first pulse NaN NaN 0.0 0 0.000
ANM218453_20131017 8 ANM218453 IT a first pulse NaN NaN 0.0 0 0.000
ANM218453_20131018 5 ANM218453 IT a first pulse NaN NaN 0.0 0 0.000
ANM218457_20131006 14 ANM218457 IT a first pulse NaN NaN 0.0 0 0.000
ANM218457_20131006 15 ANM218457 IT a first pulse NaN NaN 0.0 0 0.000
ANM218457_20131007 23 ANM218457 IT a first pulse 2.905 0.109 61.0 200 0.305
ANM219030_20130829 1 ANM219030 PT a first pulse 2.027 0.072 82.0 330 0.248
ANM219030_20130831 1 ANM219030 PT a first pulse 2.445 0.092 166.0 680 0.244
ANM219030_20130903 1 ANM219030 PT a first pulse 3.193 0.112 186.0 420 0.443
ANM219030_20130903 2 ANM219030 PT a first pulse 2.592 0.097 100.0 420 0.238
ANM219031_20131022 1 ANM219031 PT a first pulse 3.051 0.164 23.0 90 0.256
ANM219033_20131119 1 ANM219033 PT a first pulse 2.658 0.112 389.0 580 0.671
ANM219033_20131120 1 ANM219033 PT a first pulse 2.421 0.115 723.0 809 0.894
ANM219033_20131121 1 ANM219033 PT a first pulse 2.784 0.172 703.0 750 0.937
ANM219036_20131116 1 ANM219036 PT a first pulse 2.305 0.093 538.0 650 0.828
ANM219036_20131116 2 ANM219036 PT a first pulse 4.355 0.299 270.0 660 0.409
ANM219036_20131116 3 ANM219036 PT a first pulse 3.286 0.192 259.0 760 0.341
ANM219036_20131117 1 ANM219036 PT a first pulse 2.384 0.094 238.0 420 0.567
ANM219036_20131118 3 ANM219036 PT a first pulse 2.833 0.184 399.0 550 0.725
ANM219036_20131119 2 ANM219036 PT a first pulse 2.730 0.153 439.0 720 0.610
ANM219036_20131121 1 ANM219036 PT a first pulse 2.755 0.155 77.0 290 0.266
ANM219036_20131122 1 ANM219036 PT a first pulse 2.730 0.220 328.0 470 0.698
ANM219037_20131116 1 ANM219037 PT a first pulse 1.862 0.045 83.0 210 0.395
ANM219037_20131117 1 ANM219037 PT a first pulse 2.013 0.064 906.0 920 0.985
ANM219037_20131117 5 ANM219037 PT a first pulse 1.772 0.084 717.0 920 0.779
ANM219037_20131118 1 ANM219037 PT a first pulse 2.409 0.083 62.0 140 0.443
ANM219037_20131118 2 ANM219037 PT a first pulse 3.499 0.119 152.0 610 0.249
ANM219037_20131119 1 ANM219037 PT a first pulse 2.712 0.071 357.0 410 0.871
ANM219037_20131120 4 ANM219037 PT a first pulse 2.323 0.075 212.0 240 0.883
ANM219037_20131121 1 ANM219037 PT a first pulse 2.837 0.138 555.0 710 0.782
ANM219037_20131122 1 ANM219037 PT a first pulse 2.705 0.270 13.0 180 0.072
ANM219037_20131122 4 ANM219037 PT a first pulse 2.893 0.106 196.0 380 0.516
ANM219037_20131122 6 ANM219037 PT a first pulse 2.558 0.085 167.0 500 0.334
ANM219037_20131122 7 ANM219037 PT a first pulse 2.910 0.091 435.0 500 0.870
ANM219038_20131021 2 ANM219038 PT a first pulse 1.850 0.097 663.0 820 0.809
ANM219038_20131021 5 ANM219038 PT a first pulse 2.775 0.110 489.0 790 0.619
ANM219038_20131022 2 ANM219038 PT a first pulse 2.856 0.220 16.0 280 0.057
ANM219038_20131023 1 ANM219038 PT a first pulse 2.352 0.134 219.0 540 0.406
ANM219038_20131023 2 ANM219038 PT a first pulse 2.825 0.146 300.0 610 0.492
ANM219038_20131024 1 ANM219038 PT a first pulse 2.874 0.108 158.0 300 0.527
ANM219038_20131025 1 ANM219038 PT a first pulse 2.569 0.138 614.0 710 0.865
ANM219038_20131025 4 ANM219038 PT a first pulse 2.348 0.164 15.0 820 0.018
ANM219038_20131026 2 ANM219038 PT a first pulse 2.468 0.106 683.0 760 0.899
ANM219038_20131027 1 ANM219038 PT a first pulse 2.298 0.105 80.0 190 0.421
ANM219038_20131028 1 ANM219038 PT a first pulse 2.691 0.139 252.0 530 0.475
ANM219038_20131028 2 ANM219038 PT a first pulse 2.237 0.091 778.0 830 0.937
ANM219247_20130919 10 ANM219247 IT a first pulse 3.982 0.250 330.0 740 0.446
ANM219247_20130920 3 ANM219247 IT a first pulse 9.209 0.376 163.0 610 0.267
ANM219247_20130920 8 ANM219247 IT a first pulse 4.990 0.311 201.0 380 0.529
ANM219247_20130921 1 ANM219247 IT a first pulse 5.683 0.379 71.0 216 0.329
ANM219247_20130922 1 ANM219247 IT a first pulse 5.654 0.286 288.0 530 0.543
ANM219248_20130921 1 ANM219248 IT a first pulse 3.386 0.231 577.0 959 0.602
ANM219248_20130921 2 ANM219248 IT a first pulse 4.724 0.363 388.0 550 0.705
ANM219248_20130923 1 ANM219248 IT a first pulse 4.661 0.371 77.0 280 0.275
ANM219248_20130923 2 ANM219248 IT a first pulse 3.111 0.143 219.0 310 0.706
ANM219248_20130923 3 ANM219248 IT a first pulse 3.600 0.227 74.0 300 0.247
ANM219248_20130924 1 ANM219248 IT a first pulse 8.040 0.419 200.0 360 0.556
ANM219248_20130924 2 ANM219248 IT a first pulse 5.241 0.210 215.0 490 0.439
ANM219253_20140117 1 ANM219253 IT a first pulse 4.363 0.396 272.0 1040 0.262
ANM219253_20140118a 1 ANM219253 IT a first pulse 6.230 0.318 373.0 630 0.592
ANM219253_20140122 4 ANM219253 IT a first pulse 4.180 0.509 507.0 1320 0.384
ANM221977_20140116 1 ANM221977 IT a first pulse 8.834 0.446 195.0 870 0.224
# Which window fits: for each tagged neuron (first pulses; IT type 2 trials), the first-spike
# latencies far from the mode (more than 2 ms) give the spontaneous background, and so the
# number of spikes expected by chance within ±0.5 and ±1 ms of the mode, against those observed.
# The spikes between 0.5 and 1 ms from the mode are antidromic when they far exceed chance.
# A robust jitter (1.4826 x median absolute deviation, within ±1 ms) is a third reading.
rows = []
for s, u in units:
tag = "PT" if "PT" in u["cell_types"] else "IT" if "IT" in u["cell_types"] else ""
if not tag:
continue
lat = alm.antidromic_latencies(s, u, {1.0} if tag == "PT" else {2.0}, order=0)
f = lat[np.isfinite(lat)]
if len(f) < 3:
continue
mode = alm.latency_mode(f)
e05, o05 = alm.latency_background(f, mode, 0.5)
e10, o10 = alm.latency_background(f, mode, 1.0)
near = f[np.abs(f - mode) <= 1.0]
rows.append({"tag": tag, "unit": f"{s['session']}/{u['unit']}", "pulses": len(lat), "mode_ms": mode,
"obs_0.5": o05, "chance_0.5": e05, "obs_0.5_to_1": o10 - o05, "chance_0.5_to_1": e10 - e05,
"jitter_0.5": f[np.abs(f - mode) <= 0.5].std(ddof=1), "jitter_1": near.std(ddof=1),
"jitter_mad_1": 1.4826 * np.median(np.abs(near - np.median(near)))})
bg = pd.DataFrame(rows)
print(bg[bg.tag == "IT"].round(3).to_string(index=False))
for tag, d in bg.groupby("tag"):
print(f"\n{tag}: {len(d)} neurons; spikes 0.5 to 1 ms from the mode, observed {int(d['obs_0.5_to_1'].sum())}, expected by chance "
f"{d['chance_0.5_to_1'].sum():.1f}; spikes within ±1 ms expected by chance as a fraction of those observed "
f"{(d['chance_0.5_to_1'].sum() + d['chance_0.5'].sum()) / (d['obs_0.5'].sum() + d['obs_0.5_to_1'].sum()):.3f}")
print(f" mean jitter ±0.5 ms {d['jitter_0.5'].mean():.3f}, ±1 ms {d['jitter_1'].mean():.3f}, robust (MAD) {d['jitter_mad_1'].mean():.3f} ms")
print("\nTagged neurons, mean robust jitter:", round(bg.jitter_mad_1.mean(), 3), "ms;",
"IT within 0.2 ± 0.05 ms:", bool(abs(bg[bg.tag == 'IT'].jitter_mad_1.mean() - 0.2) <= 0.05))
its = [(s, u) for s, u in units if "IT" in u["cell_types"]]
fig, axs = plt.subplots(4, 7, figsize=(16, 8)); axs = axs.ravel()
for ax, (s, u) in zip(axs, its):
f = alm.antidromic_latencies(s, u, {2.0}, order=0)
f = f[np.isfinite(f)]
if len(f) >= 3:
mode = alm.latency_mode(f)
ax.hist(f, bins=np.arange(0, 10.01, 0.1), color="k")
for hw, c in ((0.5, "tab:blue"), (1.0, "tab:red")):
ax.axvline(mode - hw, color=c, lw=0.8); ax.axvline(mode + hw, color=c, lw=0.8)
ax.set_title(f"{s['session'][3:]}/{u['unit']} n={len(f)}", fontsize=7); ax.tick_params(labelsize=6)
for ax in axs[len(its):]:
ax.axis("off")
fig.suptitle("IT neurons, first-spike latency after the first pulse (ms; 0.1 ms bins), ±0.5 ms (blue) and ±1 ms (red) around the mode")
plt.tight_layout(); plt.show()
print("Histograms span 0 to 10 ms, the whole latency window; IT neurons without type 2 responses are empty panels.")
tag unit pulses mode_ms obs_0.5 chance_0.5 obs_0.5_to_1 chance_0.5_to_1 jitter_0.5 jitter_1 jitter_mad_1 IT ANM214427_20130806/2 200 3.3 77 0.833 2 0.833 0.146 0.198 0.145 IT ANM214427_20130808/1 610 4.5 57 0.000 16 0.000 0.269 0.408 0.428 IT ANM214427_20130808/2 600 3.1 40 11.500 53 11.500 0.176 0.490 0.601 IT ANM218453_20131014/9 10 4.5 3 0.333 0 0.333 0.075 0.075 0.081 IT ANM218457_20131007/23 200 2.9 61 0.167 0 0.167 0.109 0.109 0.074 IT ANM219247_20130919/10 740 4.1 297 2.000 33 2.000 0.198 0.250 0.242 IT ANM219247_20130920/3 610 9.3 130 4.795 33 4.795 0.267 0.376 0.384 IT ANM219247_20130920/8 380 5.1 173 0.500 28 0.500 0.227 0.311 0.303 IT ANM219247_20130921/1 216 5.5 54 0.500 17 0.500 0.217 0.379 0.272 IT ANM219247_20130922/1 530 5.7 265 4.000 23 4.000 0.155 0.286 0.140 IT ANM219248_20130921/1 959 3.5 519 0.000 58 0.000 0.167 0.231 0.166 IT ANM219248_20130921/2 550 4.9 304 1.167 84 1.167 0.217 0.363 0.361 IT ANM219248_20130923/1 280 4.7 64 0.333 13 0.333 0.217 0.371 0.292 IT ANM219248_20130923/2 310 3.1 219 0.333 0 0.333 0.143 0.143 0.138 IT ANM219248_20130923/3 300 3.7 68 1.500 6 1.500 0.190 0.227 0.210 IT ANM219248_20130924/1 360 8.1 147 2.623 53 2.623 0.262 0.419 0.454 IT ANM219248_20130924/2 490 5.3 206 5.000 9 5.000 0.131 0.210 0.129 IT ANM219253_20140117/1 1040 4.3 221 12.000 51 12.000 0.239 0.396 0.326 IT ANM219253_20140118a/1 630 6.3 325 3.667 48 3.667 0.226 0.318 0.293 IT ANM219253_20140122/4 1320 4.3 304 12.833 203 12.833 0.289 0.509 0.609 IT ANM221977_20140116/1 870 8.9 142 5.652 53 5.652 0.244 0.446 0.414 IT: 21 neurons; spikes 0.5 to 1 ms from the mode, observed 783, expected by chance 69.7; spikes within ±1 ms expected by chance as a fraction of those observed 0.031 mean jitter ±0.5 ms 0.198, ±1 ms 0.310, robust (MAD) 0.289 ms PT: 45 neurons; spikes 0.5 to 1 ms from the mode, observed 110, expected by chance 46.1; spikes within ±1 ms expected by chance as a fraction of those observed 0.006 mean jitter ±0.5 ms 0.113, ±1 ms 0.126, robust (MAD) 0.109 ms Tagged neurons, mean robust jitter: 0.166 ms; IT within 0.2 ± 0.05 ms: False
Histograms span 0 to 10 ms, the whole latency window; IT neurons without type 2 responses are empty panels.
# Readings without the window. (1) Per neuron, a maximum-likelihood fit to all first-spike
# latencies (0 to 10 ms) of a Gaussian peak plus a uniform background; (2) the same with a broad
# Gaussian (s.d. 1 to 5 ms) added to take up broad stimulus-locked humps; the jitter is the
# narrow peak's s.d. (3) The ±1 ms jitter without the four IT neurons whose histograms above show
# humps several ms wide (named in the round-2 verification).
rows = []
for s, u in units:
tag = "PT" if "PT" in u["cell_types"] else "IT" if "IT" in u["cell_types"] else ""
if not tag:
continue
lat = alm.antidromic_latencies(s, u, {1.0} if tag == "PT" else {2.0}, order=0)
if np.isfinite(lat).sum() < 3:
continue
mu, sd, w, n = alm.latency_peak_fit(lat)
mub, sdb, wb, _ = alm.latency_peak_fit(lat, broad=True)
rows.append({"tag": tag, "unit": f"{s['session']}/{u['unit']}", "latencies": n, "peak_ms": mu, "jitter_fit": sd,
"peak_weight": w, "jitter_fit_broad": sdb, "peak_weight_broad": wb,
"jitter_1": alm.latency_mode_stats(lat, 1.0)[1], "jitter_0.5": alm.latency_mode_stats(lat, 0.5)[1]})
pf = pd.DataFrame(rows)
print(pf[pf.tag == "IT"].round(3).to_string(index=False))
hump = ["ANM219253_20140122/4", "ANM219253_20140117/1", "ANM214427_20130808/2", "ANM219248_20130924/2"]
pf["broad_hump"] = pf.unit.isin(hump)
summ = []
for name, col, d in (("±1 ms window", "jitter_1", pf), ("±0.5 ms window", "jitter_0.5", pf),
("peak + background fit", "jitter_fit", pf), ("peak + broad + background fit", "jitter_fit_broad", pf),
("±1 ms, without the 4 broad-hump IT neurons", "jitter_1", pf[~pf.broad_hump])):
summ.append({"reading": name, "PT_n": int((d.tag == "PT").sum()), "IT_n": int((d.tag == "IT").sum()),
"PT_jitter": d[d.tag == "PT"][col].mean(), "IT_jitter": d[d.tag == "IT"][col].mean(), "tagged_jitter": d[col].mean()})
summ = pd.DataFrame(summ)
summ["PT_within_0.1"] = abs(summ.PT_jitter - 0.1) <= 0.05
summ["IT_within_0.2"] = abs(summ.IT_jitter - 0.2) <= 0.05
summ["tagged_within_0.15"] = abs(summ.tagged_jitter - 0.15) <= 0.015
print("\nFirst pulses, IT type 2 trials; neurons with at least 3 latencies:")
print(summ.round(3).to_string(index=False))
print("\nSpikes of the 4 broad-hump neurons within 0.5 to 1 ms of the mode:",
int(bg[bg.unit.isin(hump)]["obs_0.5_to_1"].sum()), "of", int(bg[bg.tag == "IT"]["obs_0.5_to_1"].sum()), "for all IT neurons")
tag unit latencies peak_ms jitter_fit peak_weight jitter_fit_broad peak_weight_broad jitter_1 jitter_0.5
IT ANM214427_20130806/2 84 3.302 0.142 0.906 0.142 0.904 0.198 0.146
IT ANM214427_20130808/1 76 4.476 0.444 0.971 0.388 0.902 0.408 0.269
IT ANM214427_20130808/2 202 3.738 0.516 0.449 0.501 0.420 0.490 0.176
IT ANM218453_20131014/9 5 4.570 0.061 0.589 0.061 0.599 0.075 0.075
IT ANM218457_20131007/23 64 2.917 0.089 0.919 0.082 0.901 0.109 0.109
IT ANM219247_20130919/10 350 3.980 0.244 0.931 0.241 0.922 0.250 0.198
IT ANM219247_20130920/3 207 9.231 0.414 0.752 0.390 0.734 0.376 0.267
IT ANM219247_20130920/8 211 4.962 0.347 0.976 0.313 0.930 0.311 0.227
IT ANM219247_20130921/1 77 5.720 0.414 0.948 0.414 0.948 0.379 0.217
IT ANM219247_20130922/1 316 5.716 0.140 0.808 0.119 0.754 0.286 0.155
IT ANM219248_20130921/1 579 3.384 0.227 0.994 0.226 0.992 0.231 0.167
IT ANM219248_20130921/2 418 4.680 0.411 0.977 0.404 0.965 0.363 0.217
IT ANM219248_20130923/1 87 4.563 0.468 0.970 0.216 0.651 0.371 0.217
IT ANM219248_20130923/2 221 3.111 0.142 0.990 0.142 0.990 0.143 0.143
IT ANM219248_20130923/3 86 3.604 0.222 0.841 0.225 0.855 0.227 0.190
IT ANM219248_20130924/1 249 7.882 0.576 0.905 0.440 0.700 0.419 0.262
IT ANM219248_20130924/2 322 5.281 0.121 0.607 0.117 0.591 0.210 0.131
IT ANM219253_20140117/1 412 4.422 0.305 0.546 0.231 0.439 0.396 0.239
IT ANM219253_20140118a/1 491 6.246 0.294 0.704 0.241 0.612 0.318 0.226
IT ANM219253_20140122/4 810 3.851 1.074 0.983 0.717 0.564 0.509 0.289
IT ANM221977_20140116/1 250 8.814 0.499 0.769 0.313 0.521 0.446 0.244
First pulses, IT type 2 trials; neurons with at least 3 latencies:
reading PT_n IT_n PT_jitter IT_jitter tagged_jitter PT_within_0.1 IT_within_0.2 tagged_within_0.15
±1 ms window 45 21 0.126 0.310 0.184 True False False
±0.5 ms window 45 21 0.113 0.198 0.140 True True True
peak + background fit 45 21 0.113 0.341 0.185 True False False
peak + broad + background fit 45 21 0.112 0.282 0.166 True False False
±1 ms, without the 4 broad-hump IT neurons 45 17 0.126 0.289 0.170 True False False
Spikes of the 4 broad-hump neurons within 0.5 to 1 ms of the mode: 316 of 783 for all IT neurons
Result: partially reproduced, resting on the assumed ±1 ms window. With antidromic spikes taken within ±1 ms of each neuron's modal latency, first pulses, PT neurons have a mean latency of 2.672 ms and jitter 0.126 ms (45 neurons), within tolerance, and IT neurons 4.98 ms (21 neurons with type 2 trials; 4.56 ms with types 2 to 5, 27 neurons), within tolerance and longer than PT. The IT jitter is 0.310 ms (0.265 with types 2 to 5), outside 0.2 ± 0.05 ms, and the mean jitter of tagged neurons 0.184 ms (0.178), outside 0.15 ± 0.015 ms. Between 0.5 and 1 ms from the mode the IT neurons have 783 spikes where the spontaneous background predicts 69.7. This shows that those spikes are locked to the light pulse, not that they are antidromic: several IT histograms show humps several milliseconds wide, and the four neurons with the broadest humps hold 316 of the 783 spikes. The readings that need no window agree with ±1 ms: a fit of a peak plus background gives IT jitter 0.341 ms and a tagged mean of 0.185 ms, a fit with a broad component added 0.282 and 0.166 ms, and the ±1 ms window without the four broad-hump neurons 0.289 and 0.170 ms; the robust s.d. gives 0.289 and 0.166 ms. Only the ±0.5 ms window gives values that match the paper (IT 0.198 ms, 0.177 with types 2 to 5; tagged mean 0.140 ms). The PT values (jitter 0.112 to 0.126 ms), the latencies and their order hold under every reading; the IT jitter and the tagged mean hold only under the ±0.5 ms window. The activated neurons are not labelled, so their values cannot be computed.
ed5g-it-second-pulse-jitter¶
After a conditioning pulse, IT neurons respond to a second light pulse 10 ms later with less temporal jitter.
rows = []
for it_types, it_name in (({2.0}, "IT type 2"), ({2.0, 3.0, 4.0, 5.0}, "IT types 2-5")):
for hw in (1.0, 0.5):
for s, u in units:
if "IT" not in u["cell_types"]:
continue
j = []
for order in (0, 1):
m, sd, n, nr = alm.latency_mode_stats(alm.antidromic_latencies(s, u, it_types, order=order), hw)
j += [sd, n]
rows.append({"IT trials": it_name, "window_ms": hw, "session": s["session"], "unit": u["unit"], "jitter_1": j[0], "n_1": j[1], "jitter_2": j[2], "n_2": j[3]})
j2 = pd.DataFrame(rows)
out = []
for (it_name, hw), d in j2.groupby(["IT trials", "window_ms"]):
ok = d[(d.n_1 >= 3) & (d.n_2 >= 3)].dropna()
out.append({"IT trials": it_name, "window_ms": hw, "neurons": len(ok), "mean_jitter_first": ok.jitter_1.mean(), "mean_jitter_second": ok.jitter_2.mean(),
"fraction_decrease": (ok.jitter_2 < ok.jitter_1).mean(), "wilcoxon_p": stats.wilcoxon(ok.jitter_1, ok.jitter_2).pvalue if len(ok) > 1 else np.nan,
"dropped_few_responses": len(d) - len(ok)})
j2s = pd.DataFrame(out)
j2s["holds"] = (j2s.mean_jitter_second < j2s.mean_jitter_first) & (j2s.fraction_decrease > 0.5)
print(j2s.round(4).to_string(index=False))
IT trials window_ms neurons mean_jitter_first mean_jitter_second fraction_decrease wilcoxon_p dropped_few_responses holds IT type 2 0.5 19 0.2038 0.1562 0.8421 0.0124 8 True IT type 2 1.0 19 0.3190 0.2549 0.6842 0.0663 8 True IT types 2-5 0.5 23 0.1842 0.1416 0.8696 0.0039 4 True IT types 2-5 1.0 23 0.2798 0.2316 0.6522 0.0980 4 True
Result: reproduced. In every variant the mean jitter of IT neurons is lower for the second pulse than for the first (0.156 against 0.204 ms with type 2 trials and ±0.5 ms; 0.232 against 0.280 ms with types 2 to 5 and ±1 ms), and 65% to 87% of IT neurons show the decrease (Wilcoxon p 0.004 to 0.098). 4 to 8 IT neurons with fewer than three responses to either pulse are left out.
fig3ei-both-types-preparatory-and-movement¶
Both IT and PT neurons display preparatory and movement-related activity.
rows = []
for (le, resp), d in UT.items():
for tag in ("PT", "IT"):
c = alm.categories(d[d.tag == tag])
rows.append({"lick_early": le, "response_s": resp, "type": tag, "neurons": int((d.tag == tag).sum()), **c,
"frac_prep_only": c["prep_only"] / max(c["n"], 1), "frac_both": c["both"] / max(c["n"], 1), "frac_peri_only": c["peri_only"] / max(c["n"], 1)})
c3 = pd.DataFrame(rows)
c3["has_prep_and_peri"] = (c3.prep_only + c3.both > 0) & (c3.peri_only + c3.both > 0)
print(c3.round(3).to_string(index=False))
print("Paper, read from Fig. 3e, i: PT about 0.18, 0.43, 0.40; IT about 0.22, 0.56, 0.22 (preparatory only, both, movement only)")
lick_early response_s type neurons prep_only both peri_only n frac_prep_only frac_both frac_peri_only has_prep_and_peri
drop 1.3 PT 45 7 16 15 38 0.184 0.421 0.395 True
drop 1.3 IT 27 5 13 5 23 0.217 0.565 0.217 True
drop 1.5 PT 45 7 16 16 39 0.179 0.410 0.410 True
drop 1.5 IT 27 6 12 5 23 0.261 0.522 0.217 True
keep 1.3 PT 45 7 16 15 38 0.184 0.421 0.395 True
keep 1.3 IT 27 4 15 5 24 0.167 0.625 0.208 True
keep 1.5 PT 45 6 17 16 39 0.154 0.436 0.410 True
keep 1.5 IT 27 5 14 6 25 0.200 0.560 0.240 True
Paper, read from Fig. 3e, i: PT about 0.18, 0.43, 0.40; IT about 0.22, 0.56, 0.22 (preparatory only, both, movement only)
Result: reproduced. Under every reading both populations hold neurons with preparatory and with peri-movement selectivity. With lick early trials dropped and a 1.3 s response epoch, of 38 selective PT neurons 7 are preparatory only, 16 both and 15 peri-movement only (0.184, 0.421, 0.395; Fig. 3e reads about 0.18, 0.43, 0.40), and of 23 selective IT neurons 5, 13 and 5 (0.217, 0.565, 0.217; Fig. 3i about 0.22, 0.56, 0.22).
fig3fj-contra-preferring-pt-not-it¶
Contra-preferring neurons outnumber ipsi-preferring neurons among PT neurons but not among IT neurons.
rng = np.random.default_rng(4)
rows = []
for (le, resp), d in UT.items():
for reading, base in (("a all", d), ("b selective", d[d.selective]),
("c selective, >15 correct trials each", d[d.selective & (d.n_R > 15) & (d.n_L > 15)])):
for tag in ("PT", "IT"):
x = base[base.tag == tag].contra.values
rows.append({"lick_early": le, "response_s": resp, "reading": reading, "type": tag, "neurons": len(x),
"contra": int(x.sum()), "fraction_contra": x.mean(), "P": alm.bootstrap_more_ipsi(x, rng=rng)})
f3 = pd.DataFrame(rows)
print(f3.round(4).to_string(index=False))
piv = f3.pivot_table(index=["lick_early", "response_s", "reading"], columns="type", values="P")
piv["PT_sig_IT_not"] = (piv.PT < 0.05) & (piv.IT >= 0.05)
print("\n", piv.round(4).to_string())
lick_early response_s reading type neurons contra fraction_contra P
drop 1.3 a all PT 45 27 0.6000 0.0886
drop 1.3 a all IT 27 13 0.4815 0.5799
drop 1.3 b selective PT 38 24 0.6316 0.0333
drop 1.3 b selective IT 23 10 0.4348 0.7416
drop 1.3 c selective, >15 correct trials each PT 32 19 0.5938 0.1099
drop 1.3 c selective, >15 correct trials each IT 19 8 0.4211 0.7581
drop 1.5 a all PT 45 25 0.5556 0.2251
drop 1.5 a all IT 27 12 0.4444 0.7210
drop 1.5 b selective PT 39 24 0.6154 0.0679
drop 1.5 b selective IT 23 10 0.4348 0.7443
drop 1.5 c selective, >15 correct trials each PT 34 19 0.5588 0.1966
drop 1.5 c selective, >15 correct trials each IT 19 8 0.4211 0.7633
keep 1.3 a all PT 45 27 0.6000 0.0908
keep 1.3 a all IT 27 12 0.4444 0.7159
keep 1.3 b selective PT 38 25 0.6579 0.0167
keep 1.3 b selective IT 24 9 0.3750 0.8551
keep 1.3 c selective, >15 correct trials each PT 33 21 0.6364 0.0542
keep 1.3 c selective, >15 correct trials each IT 21 8 0.3810 0.8720
keep 1.5 a all PT 45 26 0.5778 0.1469
keep 1.5 a all IT 27 12 0.4444 0.7167
keep 1.5 b selective PT 39 25 0.6410 0.0365
keep 1.5 b selective IT 25 10 0.4000 0.8489
keep 1.5 c selective, >15 correct trials each PT 35 21 0.6000 0.1167
keep 1.5 c selective, >15 correct trials each IT 21 8 0.3810 0.8614
type IT PT PT_sig_IT_not
lick_early response_s reading
drop 1.3 a all 0.5799 0.0886 False
b selective 0.7416 0.0333 True
c selective, >15 correct trials each 0.7581 0.1099 False
1.5 a all 0.7210 0.2251 False
b selective 0.7443 0.0679 False
c selective, >15 correct trials each 0.7633 0.1966 False
keep 1.3 a all 0.7159 0.0908 False
b selective 0.8551 0.0167 True
c selective, >15 correct trials each 0.8720 0.0542 False
1.5 a all 0.7167 0.1469 False
b selective 0.8489 0.0365 True
c selective, >15 correct trials each 0.8614 0.1167 False
Result: reproduced, under the reading of selective neurons. Among selective neurons (reading b, lick early dropped, 1.3 s response) 24 of 38 PT neurons prefer contra (0.632, P = 0.033) and 10 of 23 IT neurons (0.435, P = 0.74, the paper's value). With lick early trials kept the PT P is 0.017 (1.3 s) and 0.037 (1.5 s); with a 1.5 s response epoch and lick early dropped it is 0.068. Among all tagged neurons (reading a) PT is not significant under any reading (0.556 to 0.600, P = 0.089 to 0.23) while IT stays far from it (P = 0.58 to 0.72). Keeping only the selective neurons with more than 15 correct trials of each type (reading c, not one of the criterion's readings) PT is not significant either: 19 of 32 contra-preferring (0.594, P = 0.11) with lick early dropped and a 1.3 s response epoch, P = 0.054 to 0.20 over the four readings. The data set's IT_PT script applies that filter to the curve of all selective pyramidal neurons in Fig. 3f (line 25), and takes the PT and IT fractions from the selective neurons with no trial filter (lines 170 and 195, printed above). The outcome depends on which neurons enter, which the paper does not say.
fig3f-late-contra-selectivity-pt¶
Robust contralateral selectivity emerges in PT neurons starting 570 ms before the response epoch (34% spike rate modulation, P < 0.05), but not in IT neurons (-19%, P = 0.40) nor in all task-selective neurons (8%, P = 0.13).
Contra-selectivity is R minus L rate per neuron (correct trials, 200 ms windows, 10 ms step). Onset readings (a) the earliest window centre from which the PT mean stays significantly above 0 (t-test across neurons, P < 0.05) through the window centred 0.1 s before the cue, (b) the first significant window after sample onset. Modulation windows (a) 570 ms before the cue to the cue, (b) to the end of the response epoch; percentage of (a) the mean rate over both trial types in the window, (b) the mean rate in the 0.5 s before sample onset. Neurons (a) all PT (IT), (b) the selective ones; "all task-selective" is the selective pyramidal neurons. Every combination is run under the four readings of the shared methods (lick early trials dropped or kept, response epoch 1.3 or 1.5 s), with the selective neurons taken under the same reading.
def cs_curve(keys, le="drop"):
out = []
for s, u in units:
if (s["session"], u["unit"]) not in keys:
continue
tr = s["trials"]
r, l = alm.trial_mask(tr, u, lick_early=le)
if r.sum() < 2 or l.sum() < 2:
continue
out.append((alm.window_sums(alm.cue_binned(u, tr, r))[0].mean(axis=0) - alm.window_sums(alm.cue_binned(u, tr, l))[0].mean(axis=0)) / alm.WIN_S)
return np.array(out)
def win_rates(keys, a_rel, b_rel, le="drop"):
rows = []
for s, u in units:
if (s["session"], u["unit"]) not in keys:
continue
tr = s["trials"]
r, l = alm.trial_mask(tr, u, lick_early=le)
if r.sum() < 2 or l.sum() < 2:
continue
a, b = tr.cue.values + a_rel, tr.cue.values + b_rel
pa, pb_ = tr.pole_in.values - 0.5, tr.pole_in.values
R = alm.counts_in(u, tr, r, a, b).mean() / (b_rel - a_rel)
L = alm.counts_in(u, tr, l, a, b).mean() / (b_rel - a_rel)
base = (alm.counts_in(u, tr, r, pa, pb_).mean() + alm.counts_in(u, tr, l, pa, pb_).mean()) / 2 / 0.5
rows.append((R, L, base))
return np.array(rows)
keyset = lambda d: set(map(tuple, d[["session", "unit"]].values))
def fig3f(le, resp):
d = UT[(le, resp)]
groups = {"PT a all": keyset(d[d.tag == "PT"]), "PT b selective": keyset(d[(d.tag == "PT") & d.selective]),
"IT a all": keyset(d[d.tag == "IT"]), "IT b selective": keyset(d[(d.tag == "IT") & d.selective]),
"all task-selective": keyset(d[(d.label == "pyramidal") & d.selective])}
onsets = []
for name in ("PT a all", "PT b selective"):
C = cs_curve(groups[name], le)
p = stats.ttest_1samp(C, 0, axis=0).pvalue
sigpos = (p < 0.05) & (C.mean(axis=0) > 0)
idx = np.flatnonzero((centers >= t_sample) & (centers <= -0.1))
stay = None
for i in idx[::-1]:
if sigpos[i]:
stay = centers[i]
else:
break
first = centers[idx][sigpos[idx]][0] if sigpos[idx].any() else np.nan
onsets.append({"lick_early": le, "response_s": resp, "neurons": name, "n": len(C),
"onset_a_stays_ms_before_cue": -1e3 * stay if stay is not None else np.nan,
"onset_b_first_ms_before_cue": -1e3 * first})
rows = []
for wname, (a_rel, b_rel) in (("a -0.57 to cue", (-0.57, 0.0)), ("b -0.57 to response end", (-0.57, resp))):
for name, keys in groups.items():
X = win_rates(keys, a_rel, b_rel, le)
dlt = X[:, 0] - X[:, 1]
rows.append({"lick_early": le, "response_s": resp, "window": wname, "neurons": name, "n": len(X),
"mean_R_minus_L": dlt.mean(), "p": stats.ttest_1samp(dlt, 0).pvalue,
"mod_pct_a_window_rate": 100 * dlt.mean() / ((X[:, 0] + X[:, 1]) / 2).mean(),
"mod_pct_b_baseline": 100 * dlt.mean() / X[:, 2].mean()})
return pd.DataFrame(onsets), pd.DataFrame(rows)
ons_l, mod_l = [], []
for le, resp in UT:
o, m = fig3f(le, resp)
ons_l.append(o); mod_l.append(m)
ons, mod = pd.concat(ons_l, ignore_index=True), pd.concat(mod_l, ignore_index=True)
ons["a_ok"] = abs(ons.onset_a_stays_ms_before_cue - 570) <= 100
ons["b_ok"] = abs(ons.onset_b_first_ms_before_cue - 570) <= 100
print("Onsets under the four readings of the shared methods (lick early trials, response epoch):")
print(ons.round(1).to_string(index=False))
print("\nModulation and t-tests, lick early dropped, 1.3 s response epoch:")
print(mod[(mod.lick_early == "drop") & (mod.response_s == 1.3)].round(4).to_string(index=False))
combos = []
for (le, resp, w), m in mod.groupby(["lick_early", "response_s", "window"]):
m = m.set_index("neurons")
for nr in ("a all", "b selective"):
for pct in ("mod_pct_a_window_rate", "mod_pct_b_baseline"):
pt_, it_, al_ = m.loc[f"PT {nr}"], m.loc[f"IT {nr}"], m.loc["all task-selective"]
combos.append({"lick_early": le, "response_s": resp, "window": w, "neurons": nr, "percent_of": pct[8:],
"PT_p": pt_.p, "IT_p": it_.p, "all_p": al_.p, "PT_pct": pt_[pct], "IT_pct": it_[pct], "all_pct": al_[pct],
"values_ok": abs(pt_[pct] - 34) <= 3.4 and abs(it_[pct] + 19) <= 1.9 and abs(al_[pct] - 8) <= 0.8})
cmb = pd.DataFrame(combos)
cmb["pattern_ok"] = (cmb.PT_p < 0.05) & (cmb.IT_p >= 0.05) & (cmb.all_p >= 0.05)
print("\nEvery combination of readings (P values of the t-tests against 0; percentages):")
print(cmb.round(3).to_string(index=False))
print("\nCombinations with the paper's pattern of significance:", int(cmb.pattern_ok.sum()), "of", len(cmb),
"; with the pattern and all values within tolerance:", int((cmb.pattern_ok & cmb.values_ok).sum()))
print("All task-selective neurons, window a: P under the four readings:",
mod[(mod.neurons == "all task-selective") & (mod.window == "a -0.57 to cue")][["lick_early", "response_s", "n", "p"]].round(4).to_dict("records"))
Onsets under the four readings of the shared methods (lick early trials, response epoch):
lick_early response_s neurons n onset_a_stays_ms_before_cue onset_b_first_ms_before_cue a_ok b_ok
drop 1.3 PT a all 45 310.0 2480.0 False False
drop 1.3 PT b selective 38 310.0 2480.0 False False
drop 1.5 PT a all 45 310.0 2480.0 False False
drop 1.5 PT b selective 39 190.0 2490.0 False False
keep 1.3 PT a all 45 270.0 2470.0 False False
keep 1.3 PT b selective 38 190.0 2470.0 False False
keep 1.5 PT a all 45 270.0 2470.0 False False
keep 1.5 PT b selective 39 190.0 2470.0 False False
Modulation and t-tests, lick early dropped, 1.3 s response epoch:
lick_early response_s window neurons n mean_R_minus_L p mod_pct_a_window_rate mod_pct_b_baseline
drop 1.3 a -0.57 to cue PT a all 45 2.0023 0.0266 34.4016 31.1241
drop 1.3 a -0.57 to cue PT b selective 38 2.3588 0.0270 37.4029 33.4684
drop 1.3 a -0.57 to cue IT a all 27 -0.6826 0.1134 -16.4354 -15.4458
drop 1.3 a -0.57 to cue IT b selective 23 -0.9200 0.0548 -22.1559 -21.9750
drop 1.3 a -0.57 to cue all task-selective 912 0.4638 0.0240 9.1961 10.2620
drop 1.3 b -0.57 to response end PT a all 45 1.3084 0.0683 20.5637 20.3375
drop 1.3 b -0.57 to response end PT b selective 38 1.5514 0.0677 22.1920 22.0118
drop 1.3 b -0.57 to response end IT a all 27 -0.7869 0.5096 -15.9920 -17.8052
drop 1.3 b -0.57 to response end IT b selective 23 -0.8680 0.5365 -16.8604 -20.7320
drop 1.3 b -0.57 to response end all task-selective 912 0.0090 0.9578 0.1818 0.1989
Every combination of readings (P values of the t-tests against 0; percentages):
lick_early response_s window neurons percent_of PT_p IT_p all_p PT_pct IT_pct all_pct values_ok pattern_ok
drop 1.3 a -0.57 to cue a all a_window_rate 0.027 0.113 0.024 34.402 -16.435 9.196 False False
drop 1.3 a -0.57 to cue a all b_baseline 0.027 0.113 0.024 31.124 -15.446 10.262 False False
drop 1.3 a -0.57 to cue b selective a_window_rate 0.027 0.055 0.024 37.403 -22.156 9.196 False False
drop 1.3 a -0.57 to cue b selective b_baseline 0.027 0.055 0.024 33.468 -21.975 10.262 False False
drop 1.3 b -0.57 to response end a all a_window_rate 0.068 0.510 0.958 20.564 -15.992 0.182 False False
drop 1.3 b -0.57 to response end a all b_baseline 0.068 0.510 0.958 20.337 -17.805 0.199 False False
drop 1.3 b -0.57 to response end b selective a_window_rate 0.068 0.536 0.958 22.192 -16.860 0.182 False False
drop 1.3 b -0.57 to response end b selective b_baseline 0.068 0.536 0.958 22.012 -20.732 0.199 False False
drop 1.5 a -0.57 to cue a all a_window_rate 0.027 0.113 0.023 34.402 -16.435 9.280 False False
drop 1.5 a -0.57 to cue a all b_baseline 0.027 0.113 0.023 31.124 -15.446 10.418 False False
drop 1.5 a -0.57 to cue b selective a_window_rate 0.034 0.055 0.023 35.381 -22.156 9.280 False False
drop 1.5 a -0.57 to cue b selective b_baseline 0.034 0.055 0.023 32.141 -21.975 10.418 False False
drop 1.5 b -0.57 to response end a all a_window_rate 0.106 0.513 0.926 17.315 -16.138 -0.317 False False
drop 1.5 b -0.57 to response end a all b_baseline 0.106 0.513 0.926 17.230 -17.777 -0.344 False False
drop 1.5 b -0.57 to response end b selective a_window_rate 0.092 0.546 0.926 19.413 -16.750 -0.317 False False
drop 1.5 b -0.57 to response end b selective b_baseline 0.092 0.546 0.926 19.532 -20.392 -0.344 False False
keep 1.3 a -0.57 to cue a all a_window_rate 0.031 0.193 0.023 33.473 -13.745 9.113 False False
keep 1.3 a -0.57 to cue a all b_baseline 0.031 0.193 0.023 29.892 -13.041 10.003 False False
keep 1.3 a -0.57 to cue b selective a_window_rate 0.032 0.079 0.023 36.421 -20.033 9.113 False False
keep 1.3 a -0.57 to cue b selective b_baseline 0.032 0.079 0.023 32.162 -18.849 10.003 False False
keep 1.3 b -0.57 to response end a all a_window_rate 0.073 0.570 0.808 19.964 -13.890 0.822 False False
keep 1.3 b -0.57 to response end a all b_baseline 0.073 0.570 0.808 19.462 -15.397 0.882 False False
keep 1.3 b -0.57 to response end b selective a_window_rate 0.072 0.543 0.808 21.635 -16.263 0.822 False False
keep 1.3 b -0.57 to response end b selective b_baseline 0.072 0.543 0.808 21.132 -18.670 0.882 False False
keep 1.5 a -0.57 to cue a all a_window_rate 0.031 0.193 0.022 33.473 -13.745 9.132 False False
keep 1.5 a -0.57 to cue a all b_baseline 0.031 0.193 0.022 29.892 -13.041 10.025 False False
keep 1.5 a -0.57 to cue b selective a_window_rate 0.042 0.157 0.022 33.982 -16.095 9.132 False False
keep 1.5 a -0.57 to cue b selective b_baseline 0.042 0.157 0.022 30.076 -15.444 10.025 False False
keep 1.5 b -0.57 to response end a all a_window_rate 0.114 0.569 0.948 16.735 -14.164 0.218 False False
keep 1.5 b -0.57 to response end a all b_baseline 0.114 0.569 0.948 16.406 -15.506 0.230 False False
keep 1.5 b -0.57 to response end b selective a_window_rate 0.094 0.559 0.948 18.973 -15.622 0.218 False False
keep 1.5 b -0.57 to response end b selective b_baseline 0.094 0.559 0.948 18.582 -17.505 0.230 False False
Combinations with the paper's pattern of significance: 0 of 32 ; with the pattern and all values within tolerance: 0
All task-selective neurons, window a: P under the four readings: [{'lick_early': 'drop', 'response_s': 1.3, 'n': 912, 'p': 0.024}, {'lick_early': 'drop', 'response_s': 1.5, 'n': 910, 'p': 0.0229}, {'lick_early': 'keep', 'response_s': 1.3, 'n': 950, 'p': 0.0231}, {'lick_early': 'keep', 'response_s': 1.5, 'n': 948, 'p': 0.0221}]
Result: not reproduced. Over the 570 ms before the cue, the PT spike rate modulation is 34.4% of the window rate (P = 0.027), the paper's value, and the IT modulation -16.4% (P = 0.11, not significant; the paper has -19%). But all task-selective neurons show 9.2% (P = 0.024), significant where the paper has 8% with P = 0.13, so the pattern of significance does not hold in this window. Over the window to the end of the response epoch, all task-selective neurons are not significant (0.18%, P = 0.96) but neither is PT (20.6%, P = 0.068). The four readings of the shared methods change none of this: all task-selective neurons give P = 0.022 to 0.024 in the pre-cue window, PT gives P = 0.068 to 0.114 in the longer window, and none of the 32 combinations has the paper's pattern of significance. The PT contra-selectivity stays significant only from 190 to 310 ms before the cue (onset reading a) and is first significant 2,470 to 2,490 ms before it (reading b), against the paper's 570 ms.
reaction-time¶
The reaction time after go cue onset is 61.1 +/- 10.5 ms across mice (mean +/- s.d.).
First movement of the lick trace after the cue. The paper gives no detection rule; two rules are run (helper docstring). The noise rule takes the first sample from which the trace stays, for 5 ms, further from its pre-cue baseline than k times the baseline noise and at least a floor (k = 3, 5, 10; floor 2 or 5 mV). The peak rule takes the first sample at which the trace has moved by a fraction (5% to 50%) of its largest excursion in the 1 s after the cue. Trials (a) correct trials without early licks, (b) all performing trials with a response (hit or error); both only trials of type 0, without axonal stimulation or the NaN-type test stimulation. Per mouse the mean, then mean and s.d. across mice; per-mouse medians are a variant. Example traces with the onsets marked, and per-mouse histograms of the onsets, follow the table.
rows = []
base_sel = (T.good == 1) & T.cue.notna() & (T.ptype == 0)
sels = (("a correct", base_sel & (T.HitR | T.HitL) & ~T.LickEarly), ("b all responses", base_sel & (T.HitR | T.HitL | T.ErrR | T.ErrL)))
cols = [(f"rtn_{k}_{f}", f"noise rule, {k} x noise, floor {f * 1e3:g} mV") for k in alm.LICK_NOISE_K for f in alm.LICK_FLOOR] + \
[(f"rt_{r}", f"peak rule, {r:g} of peak") for r in alm.LICK_RISE]
for tname, sel in sels:
for col, rule in cols:
d = T[sel]
pm = d.groupby("animal")[col].mean() * 1e3
pmed = d.groupby("animal")[col].median() * 1e3
rows.append({"trials": tname, "rule": rule, "mice": int(pm.notna().sum()), "mean_ms": pm.mean(), "sd_ms": pm.std(),
"min_mouse": pm.min(), "max_mouse": pm.max(), "mean_of_medians_ms": pmed.mean(), "trials_without_onset": float(d[col].isna().mean())})
rt = pd.DataFrame(rows)
rt["within_tolerance"] = abs(rt.mean_ms - 61.1) <= 10.5
print("Trials of type 0 only (no axonal stimulation, no NaN-type trials).")
print(rt.round(2).to_string(index=False))
d = T[sels[0][1]]
print("\nPer mouse, reading a, mean (ms):")
print(pd.DataFrame({c: d.groupby("animal")[c].mean() * 1e3 for c in ("rtn_3_0.002", "rtn_5_0.005", "rtn_10_0.005", "rt_0.05")}).round(1).T.to_string())
print("Per session, reading a, noise rule 5 x noise, 5 mV: session means range",
np.round((d.groupby("session")["rtn_5_0.005"].mean() * 1e3).agg(["min", "median", "max"]).values, 1).tolist(), "ms")
print("\nControl: the noise rule applied before the cue (baseline 0.3 to 0.1 s before it, detection in the last 0.1 s), reading a.")
print("Fraction of trials in which it fires before the cue, against the fraction with an onset in the first 0.1 s after it:")
print(pd.DataFrame({f"{k} x noise, {f * 1e3:g} mV": {"before_cue_0.1s": d[f"rtfa_{k}_{f}"].mean(), "after_cue_0.1s": (d[f"rtn_{k}_{f}"] <= 0.1).mean()}
for k in alm.LICK_NOISE_K for f in alm.LICK_FLOOR}).round(3).to_string())
Trials of type 0 only (no axonal stimulation, no NaN-type trials).
trials rule mice mean_ms sd_ms min_mouse max_mouse mean_of_medians_ms trials_without_onset within_tolerance
a correct noise rule, 3 x noise, floor 2 mV 19 64.97 21.06 41.89 120.30 60.56 0.01 True
a correct noise rule, 3 x noise, floor 5 mV 19 71.70 23.61 47.00 134.34 65.20 0.02 False
a correct noise rule, 5 x noise, floor 2 mV 19 77.73 21.50 46.62 132.56 67.68 0.03 False
a correct noise rule, 5 x noise, floor 5 mV 19 82.11 23.12 50.21 146.39 71.29 0.03 False
a correct noise rule, 10 x noise, floor 2 mV 19 103.37 35.67 59.35 187.29 84.77 0.08 False
a correct noise rule, 10 x noise, floor 5 mV 19 103.70 35.41 59.77 186.14 85.00 0.08 False
a correct peak rule, 0.05 of peak 19 81.66 56.88 16.41 277.30 68.24 0.04 False
a correct peak rule, 0.1 of peak 19 99.88 57.05 22.08 287.63 84.54 0.04 False
a correct peak rule, 0.25 of peak 19 133.95 61.61 39.69 300.62 112.02 0.04 False
a correct peak rule, 0.5 of peak 19 176.78 64.66 67.76 319.50 142.83 0.04 False
b all responses noise rule, 3 x noise, floor 2 mV 19 64.97 20.88 42.69 118.36 60.68 0.04 True
b all responses noise rule, 3 x noise, floor 5 mV 19 71.32 22.87 47.61 131.03 65.38 0.04 True
b all responses noise rule, 5 x noise, floor 2 mV 19 76.92 21.42 47.84 134.19 67.42 0.06 False
b all responses noise rule, 5 x noise, floor 5 mV 19 81.04 22.85 51.46 145.91 70.84 0.06 False
b all responses noise rule, 10 x noise, floor 2 mV 19 101.99 34.50 60.53 181.30 83.93 0.11 False
b all responses noise rule, 10 x noise, floor 5 mV 19 102.39 34.45 60.87 181.77 84.29 0.11 False
b all responses peak rule, 0.05 of peak 19 99.99 51.34 44.74 260.26 68.93 0.06 False
b all responses peak rule, 0.1 of peak 19 117.04 50.28 53.36 270.02 82.92 0.06 False
b all responses peak rule, 0.25 of peak 19 148.02 52.38 68.08 280.80 108.06 0.06 False
b all responses peak rule, 0.5 of peak 19 187.00 54.28 101.43 296.83 140.30 0.06 False
Per mouse, reading a, mean (ms):
animal ANM210861 ANM210862 ANM210863 ANM214427 ANM214429 ANM214430 ANM218453 ANM218457 ANM218693 ANM219030 ANM219031 ANM219033 ANM219036 ANM219037 ANM219038 ANM219247 ANM219248 ANM219253 ANM221977
rtn_3_0.002 43.8 60.8 64.9 44.2 54.5 120.3 57.7 46.0 68.5 100.5 92.2 77.7 82.1 62.4 50.8 53.4 53.9 41.9 58.9
rtn_5_0.005 53.5 78.1 72.6 55.5 83.2 146.4 94.7 60.6 90.5 105.5 112.1 93.3 89.8 72.8 64.3 77.2 73.8 50.2 86.0
rtn_10_0.005 59.8 106.0 67.8 73.0 134.6 186.1 174.5 82.2 104.5 118.4 129.9 94.4 90.6 76.6 74.5 107.9 97.2 62.5 129.8
rt_0.05 132.9 20.1 16.4 101.8 33.6 101.1 88.3 49.2 60.1 117.4 277.3 73.4 85.4 59.5 53.3 84.8 81.8 37.5 77.7
Per session, reading a, noise rule 5 x noise, 5 mV: session means range [34.2, 73.2, 212.0] ms
Control: the noise rule applied before the cue (baseline 0.3 to 0.1 s before it, detection in the last 0.1 s), reading a.
Fraction of trials in which it fires before the cue, against the fraction with an onset in the first 0.1 s after it:
3 x noise, 2 mV 3 x noise, 5 mV 5 x noise, 2 mV 5 x noise, 5 mV 10 x noise, 2 mV 10 x noise, 5 mV
before_cue_0.1s 0.16 0.116 0.082 0.065 0.029 0.028
after_cue_0.1s 0.89 0.858 0.827 0.803 0.680 0.676
# The traces with the detected onsets: six correct trials of each mouse's first session, with
# the noise rule (5 x noise, 5 mV; solid) and the peak rule (5% of the peak; dotted).
fig, axs = plt.subplots(4, 5, figsize=(17, 11)); axs = axs.ravel()
ymin, ymax = [], []
for ax, a in zip(axs, alm.ANIMALS):
s = next(s for s in S if s["animal"] == a)
tr = s["trials"]
for k, (t, v) in s["lick_examples"].items():
ln, = ax.plot(t * 1e3, v, lw=0.7)
for col, ls in (("rtn_5_0.005", "-"), ("rt_0.05", ":")):
if np.isfinite(tr[col].iat[k]):
ax.axvline(tr[col].iat[k] * 1e3, color=ln.get_color(), ls=ls, lw=0.8)
ymin.append(v.min()); ymax.append(v.max())
ax.set_title(s["session"], fontsize=8); ax.tick_params(labelsize=7); ax.set_xlim(-100, 300)
for ax in axs[len(alm.ANIMALS):]:
ax.axis("off")
fig.suptitle("Lick trace (V) from 0.1 s before to 0.3 s after the cue (ms); onsets: noise rule solid, peak rule dotted")
plt.tight_layout(); plt.show()
print("Each panel has its own y range; over all panels the traces span", round(min(ymin), 2), "to", round(max(ymax), 2), "V")
fig, axs = plt.subplots(4, 5, figsize=(17, 9), sharex=True); axs = axs.ravel()
d = T[sels[0][1]]
for ax, (a, x) in zip(axs, d.groupby("animal")):
ax.hist(x["rtn_5_0.005"].dropna() * 1e3, bins=np.arange(0, 400, 10), color="k")
ax.hist(x["rt_0.05"].dropna() * 1e3, bins=np.arange(0, 400, 10), histtype="step", color="tab:red")
ax.set_title(a, fontsize=8); ax.tick_params(labelsize=7)
for ax in axs[d.animal.nunique():]:
ax.axis("off")
fig.suptitle("Onsets per mouse, correct trials (ms after the cue, 10 ms bins); black noise rule (5 x noise, 5 mV), red peak rule (5%)")
plt.tight_layout(); plt.show()
print("Onsets beyond 400 ms (not shown): noise rule", int((d["rtn_5_0.005"] > 0.4).sum()), "; peak rule", int((d["rt_0.05"] > 0.4).sum()),
"of", len(d), "trials")
Each panel has its own y range; over all panels the traces span 0.07 to 4.95 V
Onsets beyond 400 ms (not shown): noise rule 54 ; peak rule 192 of 12639 trials
Result: blocked, methods underspecified. The paper does not say how the first mouth movement is found in the photodiode trace, and the outcome turns on that choice. On correct trials, the noise rule gives a mean over the 19 mice of 65.0 ms (s.d. 21.1) at 3 times the noise with a 2 mV floor, within 61.1 ± 10.5 ms, 71.7 ms with a 5 mV floor, just outside, and 77.7 to 103.7 ms at 5 and 10 times the noise; on all responses 3 times the noise gives 65.0 and 71.3 ms, both within. The peak rule gives 81.7 to 176.8 ms (s.d. 57 to 65 ms), with per-mouse means from 16 to 320 ms. Neither threshold has a better basis: before the cue the noise rule fires within 0.1 s in 11.6% to 16.0% of trials at 3 times the noise and 6.5% to 8.2% at 5 times, so the lower threshold is more sensitive to the first movement and more prone to early triggers. The spread across mice is 21 to 36 ms under the noise rule, two to three times the paper's 10.5 ms, which also points to a different procedure or set of mice. Per-session means under the noise rule (5 times the noise, 5 mV) range from 34 to 212 ms; the example traces show sessions where the trace is a two-level signal or carries brief cue-locked deflections.
contra-ipsi-selectivity-forms¶
Contra-preferring neurons include most of the neurons with large spike count differences between trial types, while ipsi-preferring neurons more often express their selectivity through suppression of activity on contra trials.
Per selective pyramidal neuron, the absolute difference of R and L rates from sample onset to the end of the response epoch. Contra-suppression: the rate on R trials (same span) below the rate in the 0.5 s before sample onset, with the rate on L trials not below it; ipsi-suppression is the same with the trial types swapped. The whole pre-sample period is a variant baseline.
sp = pyr[pyr.selective].copy()
sp["absdiff"] = (sp.trial_R - sp.trial_L).abs()
rows = []
for q, name in ((0.75, "a top quarter"), (0.90, "b top tenth")):
big = sp[sp.absdiff >= sp.absdiff.quantile(q)]
rows.append({"reading": name, "neurons": len(big), "fraction_contra": big.contra.mean(), "binomial_p": stats.binomtest(int(big.contra.sum()), len(big)).pvalue})
large = pd.DataFrame(rows)
large["contra_majority"] = large.fraction_contra > 0.5
print(large.round(4).to_string(index=False))
rows = []
for bname, bcol in (("0.5 s pre-sample", "pre"), ("whole pre-sample (variant)", "pre_all")):
base = (sp[f"{bcol}_R"] + sp[f"{bcol}_L"]) / 2
csup = (sp.trial_R < base) & ~(sp.trial_L < base)
isup = (sp.trial_L < base) & ~(sp.trial_R < base)
ip, cp = sp[~sp.contra], sp[sp.contra]
rows.append({"baseline": bname, "ipsi_pref_n": len(ip), "ipsi_pref_with_contra_suppression": float(csup[~sp.contra].mean()),
"contra_pref_n": len(cp), "contra_pref_with_ipsi_suppression": float(isup[sp.contra].mean()),
"fisher_p": stats.fisher_exact([[int(csup[~sp.contra].sum()), len(ip) - int(csup[~sp.contra].sum())],
[int(isup[sp.contra].sum()), len(cp) - int(isup[sp.contra].sum())]])[1]})
sup = pd.DataFrame(rows)
sup["ipsi_more"] = sup.ipsi_pref_with_contra_suppression > sup.contra_pref_with_ipsi_suppression
print(sup.round(4).to_string(index=False))
print("\nUnder the four readings of the shared methods (0.5 s baseline):")
rows = []
for (le, resp), d in UT.items():
x = d[(d.label == "pyramidal") & d.selective].copy()
x["absdiff"] = (x.trial_R - x.trial_L).abs()
base = (x.pre_R + x.pre_L) / 2
csup = (x.trial_R < base) & ~(x.trial_L < base)
isup = (x.trial_L < base) & ~(x.trial_R < base)
rows.append({"lick_early": le, "response_s": resp,
"contra_frac_top_quarter": x[x.absdiff >= x.absdiff.quantile(0.75)].contra.mean(),
"contra_frac_top_tenth": x[x.absdiff >= x.absdiff.quantile(0.9)].contra.mean(),
"ipsi_pref_contra_supp": float(csup[~x.contra].mean()), "contra_pref_ipsi_supp": float(isup[x.contra].mean())})
ci4 = pd.DataFrame(rows)
ci4["both_parts"] = (ci4[["contra_frac_top_quarter", "contra_frac_top_tenth"]].max(axis=1) > 0.5) & (ci4.ipsi_pref_contra_supp > ci4.contra_pref_ipsi_supp)
print(ci4.round(4).to_string(index=False))
reading neurons fraction_contra binomial_p contra_majority
a top quarter 228 0.5351 0.3205 True
b top tenth 92 0.5217 0.7547 True
baseline ipsi_pref_n ipsi_pref_with_contra_suppression contra_pref_n contra_pref_with_ipsi_suppression fisher_p ipsi_more
0.5 s pre-sample 485 0.3649 427 0.3888 0.4934 False
whole pre-sample (variant) 485 0.3670 427 0.3911 0.4939 False
Under the four readings of the shared methods (0.5 s baseline):
lick_early response_s contra_frac_top_quarter contra_frac_top_tenth ipsi_pref_contra_supp contra_pref_ipsi_supp both_parts
drop 1.3 0.5351 0.5217 0.3649 0.3888 False
drop 1.5 0.5395 0.5275 0.3883 0.4176 False
keep 1.3 0.5378 0.5579 0.3598 0.3908 False
keep 1.5 0.5485 0.5474 0.3679 0.4123 False
Result: partially reproduced. Contra-preferring neurons are a slight majority of the neurons with the largest rate differences (0.535 of the top quarter, 228 neurons, binomial p = 0.32; 0.522 of the top tenth, p = 0.75). Contra-suppression in ipsi-preferring neurons (0.365) is not more common than ipsi-suppression in contra-preferring neurons (0.389, Fisher p = 0.49); the whole pre-sample baseline gives the same (0.367 against 0.391). The four readings of the shared methods give the same: contra fractions 0.522 to 0.558 of the large groups, contra-suppression 0.360 to 0.388 against ipsi-suppression 0.389 to 0.418. The first part holds weakly and the second does not.
Summary¶
| claim | outcome |
|---|---|
| fig1d-photoinhibition-ipsilateral-bias | blocked, data missing |
| fig1d-sample-epoch-smaller-bias | blocked, data missing |
| task-performance | reproduced (19 of 42 mice) |
| unit-counts | partially reproduced |
| fig2-selective-fraction | reproduced |
| fig2d-response-categories | reproduced (figure reading) |
| fig2c-selectivity-time-course | reproduced |
| fig2c-dynamic-single-neurons | reproduced (assumed 0.5 bound) |
| ed2-error-trials-predict-choice | reproduced |
| fig2e-equal-contra-ipsi | reproduced |
| ed1-no-population-contra-bias | reproduced |
| ed1-fast-spiking-properties | partially reproduced |
| tagging-counts | reproduced |
| antidromic-latency-jitter | partially reproduced (assumed window) |
| ed5g-it-second-pulse-jitter | reproduced |
| fig3ei-both-types-preparatory-and-movement | reproduced |
| fig3fj-contra-preferring-pt-not-it | reproduced (selective neurons) |
| fig3f-late-contra-selectivity-pt | not reproduced |
| reaction-time | blocked, methods underspecified |
| fig4-imaging-intermingled | blocked, data missing |
| fig4h-imaging-pt-contra-bias | blocked, data missing |
| imaging-overall-counts | blocked, data missing |
| contra-ipsi-selectivity-forms | partially reproduced |
| fig5-pt-activation-contralateral-bias | blocked, data missing |
| ed6b-pt-dose-response | blocked, data missing |
| ed6d-it-activation-inconsistent | blocked, data missing |
| ed3-high-power-contralateral-licking | blocked, data missing |
| ed3d-non-overlapping-it-pt | blocked, data missing |
| ed7-pt-stimulation-persistent-activity | blocked, data missing |
A failure to reproduce here may be a failure of this attempt, not of the paper: see the reasoning and the differences from the paper's method.
How the analysis differs from the paper's. Only the 19 electrophysiology mice are in the data set, so task performance and reaction time are measured on them alone. Where the paper leaves a detail open, the data set's own MATLAB scripts were followed and the choice is stated: the response epoch of 1.3 s, the exclusion of lick early and axonal stimulation trials, each unit's trials limited to its recorded span, preference from the counts from sample onset to the end of the response epoch. The paper gives no rule for telling antidromic from spontaneous spikes; the ±1 ms window is an assumption, and readings without a window (fits of a peak plus background) agree with it, while only a ±0.5 ms window gives the paper's IT jitter. Nor does it give a rule for detecting the first mouth movement in the lick trace; on correct trials the reaction time is within tolerance only at 3 times the noise with a 2 mV floor and outside it under every other rule, so that claim is blocked as underspecified. Spike widths are recomputed from the deposited 29-sample waveforms.
What was found about the data set. The electrophysiology matches the paper closely: 1,408 units,
19 mice, 99 sessions, the labels' 1,245 pyramidal, 124 FS, 45 PT and 27 IT neurons, and the
paper's 912 selective neurons, response categories and contra and ipsi counts are recovered
exactly. The data set's description lists photostimulation types 0, 1, 2 and NaN; types 3, 4
and 5 also occur (IT tagging in the Tlx x Ai32 mice). 43 trials of type 0 in session
ANM210862_20130627 carry light pulses. The trough-to-peak widths of the deposited waveforms put
34 of the 39 unlabelled units below 0.35 ms, so the "intermediate" class cannot be recomputed
with the stated thresholds; the labels split the deposited widths at 0.256 to 0.307 ms and 0.410
to 0.461 ms.
The activated (non-collision) neurons are not labelled. The lick trace differs in baseline,
scale and sign between sessions and is not described beyond "licking movement from
photodiode". The NaN-type test trials carry light in all 19 mice, at onsets and powers the
description does not give. 10 units have spike times out of order. The NWB copies omit the photostimulation
type, the AOM and laser traces and GoodTrials. The behaviour, imaging and anatomy of
Figs 1, 4 and 5 and ED Figs 3, 6 and 7 are not in the data set.