Mills, Lee, Howe, Li et al. (2026) on DANDI:001203¶
Paper: Mills et al., "Amygdalostriatal transition zone neurons encode sustained cue responses to guide
defensive behaviors", Neuron (2026), doi:10.1016/j.neuron.2026.08.012.
Claims: claims/mills-2026.yaml, written from the author-accepted manuscript (Europe PMC
PMC13592531) with the supplement's figure legends, and the paper's code at
github.com/Tyelab/Mills-et-al-2026, commit 1fee26d.
Dataset: DANDI:001203, version 0.261103.1719, doi:10.48324/dandi.001203/0.261103.1719. The paper cites the dandiset without a version. This is the only published version (released 2026-11-03, "Initial release following publication in Neuron"), and the draft has the same 706 assets, so it is pinned. Every file is streamed from the archive; nothing is written to disk.
What the dandiset holds, as the inventory below shows: 13 Open Ephys sessions (12 mice, one deposited twice) with spikes, trial events, port entries and SLEAP poses; 13 Neuropixels recordings with spikes but no trial events, no behavior and no per-unit region; 34 calcium imaging discrimination files (33 mice, one deposited twice) and 22 contextual fear imaging sessions (11 mice), with CNMF-E traces, cue events and poses. There are no snRNA-seq, RNAscope, optogenetic or unpredicted-US data.
| Claim | Tested here |
|---|---|
| fig2-recorded-neurons (link) | tested |
| figs9-sustained-only-cs-shock | tested, 10 of 15 paired ASt mice (Open Ephys) |
| figs10-no-reward-relationship | tested, the across-trials test only (paired mice) |
| fig2o-region-differs-cs-reward | tested, the ASt part only (no TS units) |
| fig2q-trajectories-diverge | tested, paired Open Ephys mice |
| figs8-single-trial-divergence | tested, paired part only |
| fig3h-cs-decoded-paired-only | tested, paired part only |
| figs13-imaging-mice-discriminate | tested |
| fig5j-drd2-cs-shock-responses | tested on all CNMF-E ROIs |
| fig5h-drd1-no-difference | tested on all CNMF-E ROIs |
| fig5k-drd2-cs-reward-no-difference | tested on all CNMF-E ROIs |
| fig5m-drd2-rich-clusters-cs-shock | tested on all CNMF-E ROIs |
| figs15-no-context-encoding | tested |
| figs5, figs10lm, fig3fg | blocked: pose of the Open Ephys sessions is not on the trial clock (a fixed offset is supported by two checks in 2 ASt mice only) |
| fig2e, fig2o-ast-greater, fig2p | blocked: no unit is labeled TS, and the Neuropixels files lack trial events; ASt against CeA is shown for the record |
| figs7 (four), figs10b, figs10-high-defensive, fig3h-behavior, fig3j to fig3m | blocked: no trial events or behavior for any unpaired ephys mouse |
| figs14, figs14q | blocked: no unpredicted-US imaging session in the dandiset |
| fig1l, figs4, fig3b, fig3c, fig4 (three), figs12gh, fig6 (three), figs16, figs17 | blocked: RNAscope and optogenetics not deposited |
| fig1b, fig1j, figs2 | blocked: the snRNA-seq data are at GEO GSE211437, outside the dandiset; the paper's pipeline (Seurat, Libra, edgeR in R) cannot be installed in the entry's locked Python environment |
import os
os.environ.setdefault("OMP_NUM_THREADS", "1")
import time, zlib, resource, collections
from concurrent.futures import ThreadPoolExecutor
import numpy as np, pandas as pd
import scipy.stats as ss
from scipy.cluster.hierarchy import linkage, fcluster
from scipy.signal import find_peaks
from statsmodels.stats.multicomp import pairwise_tukeyhsd
from sklearn.decomposition import PCA
from sklearn.linear_model import LogisticRegression
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import StratifiedKFold
import matplotlib.pyplot as plt
import mills as M
pd.set_option("display.width", 200); pd.set_option("display.max_columns", 30); pd.set_option("display.max_rows", 200)
T0 = time.time()
KEY = "mills-2026"
def seed(claim, k=0):
return zlib.crc32(f"{KEY}/{claim}".encode()) + k
print("dandiset", M.DANDISET, "version", M.VERSION)
dandiset 001203 version 0.261103.1719
Data check¶
Inventory of every NWB file: kind, subject, group and genotype as the files give them, units or ROIs, and which tables are present. Then the contents loaded for the analyses, duplicates, and the checks of the description against the values.
nwb = M.nwb_assets()
def kind(p):
if "ecephys+image" in p: return "openephys"
if "_ecephys.nwb" in p: return "neuropixels"
return "imaging"
def inv(a):
f = M.open_nwb(a["path"]); p = a["path"]
r = {"file": p.split("/")[-1][:58], "kind": kind(p), "GB": round(a["size"] / 1e9, 1)}
sub = f["general/subject"]
r["subject_description"] = M._s(sub["description"]) if "description" in sub else ""
r["genotype"] = M._s(sub["genotype"]) if "genotype" in sub else ""
r["session_description"] = M._s(f["session_description"])[:40]
r["trials"] = "intervals/trials" in f
r["pose"] = "processing/behavior/PoseEstimationTrack0" in f
if r["kind"] != "imaging":
loc = M._strs(f["general/extracellular_ephys/electrodes/location"])
r["electrode_locations"] = ",".join(sorted(set(loc)))
r["units"] = f["units/id"].shape[0]
r["unit_columns_with_region"] = any(c in f["units"] for c in ("location", "brain_area", "electrodes"))
r["units_below_50Hz"] = int((f["units/firing_rate"][:] < 50).sum()) if "firing_rate" in f["units"] else None
if "label" in f["units"] and "firing_rate" in f["units"]:
lab = M._strs(f["units/label"]); r["good_units_below_50Hz"] = int(((lab == "good") & (f["units/firing_rate"][:] < 50)).sum())
if "probe_depth" in f["units"]:
pdp = f["units/probe_depth"][:]; r["unit probe_depth um"] = f"{pdp.min():.0f}-{pdp.max():.0f}"
r["histology images"] = "acquisition/NeuropixelsHistologyImages" in f
else:
r["rois"] = f["processing/ophys/ImageSegmentation/PlaneSegmentation/id"].shape[0] if "processing/ophys" in f else 0
r["roi_columns"] = ",".join(c for c in f["processing/ophys/ImageSegmentation/PlaneSegmentation"] if c not in ("id", "image_mask", "reference_images")) if "processing/ophys" in f else ""
r["path"] = p
return r
with ThreadPoolExecutor(8) as ex:
INV = pd.DataFrame(list(ex.map(inv, nwb)))
print(INV.groupby("kind").size())
print(INV.drop(columns=["path"]).to_string())
kind
imaging 57
neuropixels 13
openephys 13
dtype: int64
file kind GB subject_description genotype session_description trials pose electrode_locations units unit_columns_with_region units_below_50Hz histology images good_units_below_50Hz unit probe_depth um rois roi_columns
0 sub-3012-20180810-innerpeaceDiscD4_ses-3012-2018-08-10-10- openephys 8.5 Wild type True True Central amygdalar nucleus 9.0 False NaN False NaN NaN NaN NaN
1 sub-3014-20180626-illidanDiscD4_ses-3014-2018-06-26-14-21- openephys 8.7 Wild type True True amygdalostriatal transition zone 5.0 False NaN False NaN NaN NaN NaN
2 sub-3016-20180810-donkeyDiscD4_ses-3016-2018-08-10-10-12-1 openephys 8.6 Wild type True True amygdalostriatal transition zone 14.0 False NaN False NaN NaN NaN NaN
3 sub-3024-20180810-ishmaelDiscD4_ses-3024-2018-08-10-13-45- openephys 9.3 Wild type True True amygdalostriatal transition zone 18.0 False NaN False NaN NaN NaN NaN
4 sub-3026-20181129-dengDiscD3_ses-3026-2018-11-29-10-35-46- openephys 8.9 Wild type True True amygdalostriatal transition zone 12.0 False NaN False NaN NaN NaN NaN
5 sub-3029-20181128-iouxioDiscD2_ses-3029-2018-11-28-09-30-1 openephys 9.2 Wild type True True amygdalostriatal transition zone 5.0 False NaN False NaN NaN NaN NaN
6 sub-6197-20190718-daijobuDiscD4_ecephys+image.nwb openephys 9.8 Wild type True True amygdalostriatal transition zone 11.0 False NaN False NaN NaN NaN NaN
7 sub-6197-20190718-daijobuDiscD4_ses-6197-2019-07-18-16-31- openephys 9.8 Wild type True True amygdalostriatal transition zone 11.0 False NaN False NaN NaN NaN NaN
8 sub-6253-20190913-daisyDISCD3_ses-6253-2019-09-13-15-57-32 openephys 9.2 Wild type True True amygdalostriatal transition zone 6.0 False NaN False NaN NaN NaN NaN
9 sub-6429-20191016-durianDiscD5_ses-6429-2019-10-16-17-03-0 openephys 9.0 Wild type True True amygdalostriatal transition zone 6.0 False NaN False NaN NaN NaN NaN
10 sub-7001-20190718-ichimokuDiscD4_ses-7001-2019-07-18-09-12 openephys 10.0 Wild type True True Central amygdalar nucleus 13.0 False NaN False NaN NaN NaN NaN
11 sub-7008-20190718-ikariDiscD4_ses-7008-2019-07-18-16-31-46 openephys 10.0 Wild type True True amygdalostriatal transition zone 19.0 False NaN False NaN NaN NaN NaN
12 sub-7049-20190914-ivyDiscD4_ses-7049-2019-09-14-12-12-10-i openephys 9.6 Wild type True True amygdalostriatal transition zone 17.0 False NaN False NaN NaN NaN NaN
13 sub-Ast-NPX-03_ses-Disc4-NPX3-NPX4-NPX5-g0-imec0_ecephys.n neuropixels 111.2 Neuropixels, tone and stimulus paired group, amygdalostriatal transition zone (ASt) region Wild type False False ASt 249.0 False 249.0 True 170.0 0-3820 NaN NaN
14 sub-Ast-NPX-04_ses-Disc4-NPX3-NPX4-NPX5-g0-imec1_ecephys.n neuropixels 108.3 Neuropixels, tone and stimulus paired group, amygdalostriatal transition zone (ASt) region Wild type False False ASt 130.0 False 130.0 True 94.0 0-3760 NaN NaN
15 sub-Ast-NPX-05_ses-Disc4-NPX3-NPX4-NPX5-g0-imec2_ecephys.n neuropixels 112.9 Neuropixels, tone and stimulus paired group, amygdalostriatal transition zone (ASt) region Wild type False False ASt 227.0 False 217.0 True 163.0 0-3800 NaN NaN
16 sub-Ast-NPX-06_ses-Disc4-NPX6-NPX7-g0-imec0_ecephys.nwb neuropixels 101.0 Neuropixels, tone and stimulus randomly presented (unpaired group), amygdalostriatal transition zone (ASt) region Wild type False False ASt 218.0 False 218.0 True 152.0 0-3820 NaN NaN
17 sub-Ast-NPX-07_ses-Disc4-NPX6-NPX7-g0-imec1_ecephys.nwb neuropixels 109.3 Neuropixels, tone and stimulus randomly presented (unpaired group), amygdalostriatal transition zone (ASt) region Wild type False False ASt 91.0 False 87.0 True 57.0 0-3620 NaN NaN
18 sub-Ast-NPX-08_ses-Disc6-NPX8-NPX9-g0-imec0_ecephys.nwb neuropixels 110.7 Neuropixels, tone and stimulus paired group, amygdalostriatal transition zone (ASt) region Wild type False False ASt 503.0 False 503.0 True 63.0 0-3820 NaN NaN
19 sub-Ast-NPX-09_ses-Disc6-NPX8-NPX9-g0-imec1_ecephys.nwb neuropixels 115.6 Neuropixels, tone and stimulus paired group, amygdalostriatal transition zone (ASt) region Wild type False False ASt 307.0 False 304.0 True 84.0 0-3820 NaN NaN
20 sub-Ast-NPX-10_ses-Disc5-NPX10-NPX11-g0-imec0_ecephys.nwb neuropixels 9.2 Neuropixels, tone and stimulus randomly presented (unpaired group), amygdalostriatal transition zone (ASt) region Wild type False False ASt 241.0 False 241.0 True 157.0 0-3620 NaN NaN
21 sub-Ast-NPX-11_ses-Disc5-NPX10-NPX11-g0-imec1_ecephys.nwb neuropixels 108.6 Neuropixels, tone and stimulus randomly presented (unpaired group), amygdalostriatal transition zone (ASt) region Wild type False False ASt 88.0 False 87.0 True 44.0 0-3780 NaN NaN
22 sub-C1-J642-Disc5_ses-C1-J642-Disc5_image+ophys.nwb imaging 3.6 Drd2 drd2-cre CS-tone paired with US delivery True True NaN NaN NaN NaN NaN NaN NaN 24.0 imaging_plane,roi_name
23 sub-C3-J670-Disc5Unp_ses-C3-J670-Disc5Unp_image+ophys.nwb imaging 3.5 Drd2 drd2-cre CS-tone an US delivery are unpaired True True NaN NaN NaN NaN NaN NaN NaN 43.0 imaging_plane,roi_name
24 sub-C3-J670-Disc7Unp_ses-20211013T000000_image.nwb imaging 0.0 Drd2 drd2-cre CS-tone an US delivery are unpaired True True NaN NaN NaN NaN NaN NaN NaN 0.0
25 sub-C6-J588-Disc5_ses-C6-J588-Disc5_image+ophys.nwb imaging 3.6 Drd2 drd2-cre CS-tone paired with US delivery True True NaN NaN NaN NaN NaN NaN NaN 84.0 imaging_plane,roi_name
26 sub-C6-J650-Disc5_ses-C6-J650-Disc5_image+ophys.nwb imaging 3.5 Drd2 drd2-cre CS-tone paired with US delivery True True NaN NaN NaN NaN NaN NaN NaN 77.0 imaging_plane,roi_name
27 sub-C8-J633-Disc5Unp_ses-C8-J633-Disc5Unp_image+ophys.nwb imaging 3.5 Drd2 drd2-cre CS-tone an US delivery are unpaired True True NaN NaN NaN NaN NaN NaN NaN 12.0 imaging_plane,roi_name
28 sub-C8-J634-Disc5Unp_ses-C8-J634-Disc5Unp_image+ophys.nwb imaging 3.6 Drd2 drd2-cre CS-tone an US delivery are unpaired True True NaN NaN NaN NaN NaN NaN NaN 80.0 imaging_plane,roi_name
29 sub-CeA-NPX-01_ses-20221220-Disc-NPX1-NPX2-g0-imec0_ecephy neuropixels 141.4 Neuropixels, tone and stimulus paired group, central amygdala region, no ASt cells Wild type False False CeA 144.0 False 138.0 True 35.0 0-3820 NaN NaN
30 sub-CeA-NPX-02_ses-20221220-Disc-NPX1-NPX2-g0-imec1_ecephy neuropixels 77.6 Neuropixels, tone and stimulus paired group, central amygdala region, no ASt cells Wild type False False CeA 237.0 False 235.0 True 64.0 0-3820 NaN NaN
31 sub-CeA-NPX-04_ses-20221222-Disc-NPX4-NPX5-g0-imec0_ecephy neuropixels 114.2 Neuropixels, tone and stimulus paired group, central amygdala region, no ASt cells Wild type False False CeA 154.0 False 154.0 True 42.0 0-3820 NaN NaN
32 sub-CeA-NPX-05_ses-20221222-Disc-NPX4-NPX5-g0-imec1_ecephy neuropixels 135.1 Neuropixels, tone and stimulus paired group, central amygdala region, no ASt cells Wild type False False CeA 336.0 False 336.0 True 14.0 0-3820 NaN NaN
33 sub-G1B1-C1-6868-L-quetzal-DISC6+TONES_ses-G1B1-C1-6868_im imaging 5.6 Drd1a drd1a-cre CS-tone paired with US delivery. True True NaN NaN NaN NaN NaN NaN NaN 206.0 imaging_plane,roi_name
34 sub-G1B1-J895-R-DISC4_ses-G1B1-J895_image+ophys.nwb imaging 4.1 Drd2 drd2-cre CS-tone paired with US delivery True True NaN NaN NaN NaN NaN NaN NaN 109.0 imaging_plane,roi_name
35 sub-G1B2-C1-6865-R-frogman-DISC5_ses-G1B2-C1-6865_image+op imaging 3.5 Drd1a drd1a-cre CS-tone paired with US delivery True True NaN NaN NaN NaN NaN NaN NaN 5.0 imaging_plane,roi_name
36 sub-G1B2-J904-L-DISC6_ses-G1B2-J904_image+ophys.nwb imaging 4.9 Drd2 drd2-cre CS-tone paired with US delivery True True NaN NaN NaN NaN NaN NaN NaN 110.0 imaging_plane,roi_name
37 sub-G1B3-C2-6882-R-kevin-DISC6+TONES_ses-G1B3-C2-6882_imag imaging 5.2 Drd1a drd1a-cre CS-tone paired with US delivery True True NaN NaN NaN NaN NaN NaN NaN 6.0 imaging_plane,roi_name
38 sub-G1B3-K033-R-DISC6_ses-G1B3-K033_image+ophys.nwb imaging 4.5 Drd1a drd1a-cre CS-tone paired with US delivery True True NaN NaN NaN NaN NaN NaN NaN 105.0 imaging_plane,roi_name
39 sub-G1B4-C3-6921-R-nessie-DISC6+TONES_ses-G1B4-C3-6921_ima imaging 4.3 Drd1a drd1a-cre CS-tone paired with US delivery True True NaN NaN NaN NaN NaN NaN NaN 7.0 imaging_plane,roi_name
40 sub-G1B4-K035-R-DISC4_ses-G1B4-K035_image+ophys.nwb imaging 4.0 Drd1a drd1a-cre CS-tone paired with US delivery True True NaN NaN NaN NaN NaN NaN NaN 216.0 imaging_plane,roi_name
41 sub-G2B1-C4-6886-L-jackalope-DISC6UNP+TONES_ses-G2B1-C4-68 imaging 5.2 Drd1a drd1a-cre CS-tone an US delivery are unpaired True True NaN NaN NaN NaN NaN NaN NaN 1.0 imaging_plane,roi_name
42 sub-G2B1-J915-R-DISC4_ses-G2B1-J915_image+ophys.nwb imaging 4.1 Drd2 drd2-cre CS-tone an US delivery are unpaired True True NaN NaN NaN NaN NaN NaN NaN 247.0 imaging_plane,roi_name
43 sub-G2B2-J917-R-DISC6_ses-G2B2-J917_image+ophys.nwb imaging 4.6 Drd2 drd2-cre CS-tone an US delivery are unpaired True True NaN NaN NaN NaN NaN NaN NaN 132.0 imaging_plane,roi_name
44 sub-G2B3-C4-6885-R-cyclops-DISC6UNP+TONES_ses-G2B3-C4-6885 imaging 5.1 Drd1a drd1a-cre CS-tone an US delivery are unpaired True True NaN NaN NaN NaN NaN NaN NaN 6.0 imaging_plane,roi_name
45 sub-G2B3-K036-L-DISC4_ses-G2B3-K036_image+ophys.nwb imaging 4.4 Drd1a drd1a-cre CS-tone an US delivery are unpaired True True NaN NaN NaN NaN NaN NaN NaN 51.0 imaging_plane,roi_name
46 sub-G2B4-K054-R-DISC5_ses-G2B4-K054_image+ophys.nwb imaging 4.6 Drd1a drd1a-cre CS-tone an US delivery are unpaired True True NaN NaN NaN NaN NaN NaN NaN 102.0 imaging_plane,roi_name
47 sub-G3B1-C5-6933-R-chupacabra-DISC5_ses-G3B1-C5-6933_image imaging 3.7 Drd1a drd1a-cre CS-tone paired with US delivery True True NaN NaN NaN NaN NaN NaN NaN 106.0 imaging_plane,roi_name
48 sub-G3B2-J908-R-DISC5_ses-G3B2-J908_image+ophys.nwb imaging 4.7 Drd2 drd2-cre CS-tone paired with US delivery True True NaN NaN NaN NaN NaN NaN NaN 141.0 imaging_plane,roi_name
49 sub-G3B3-K047-L-DISC5_ses-G3B3-K047_image+ophys.nwb imaging 3.7 Drd1a drd1a-cre CS-tone paired with US delivery True True NaN NaN NaN NaN NaN NaN NaN 63.0 imaging_plane,roi_name
50 sub-G3B4-C7-6915-R-mothman-DISC6+TONES_ses-G3B4-C7-6915_im imaging 5.1 Drd1a drd1a-cre CS-tone paired with US delivery True True NaN NaN NaN NaN NaN NaN NaN 6.0 imaging_plane,roi_name
51 sub-G3B4-J907-R-DISC4_ses-G3B4-J907_image+ophys.nwb imaging 3.9 Drd2 drd2-cre CS-tone paired with US delivery True True NaN NaN NaN NaN NaN NaN NaN 118.0 imaging_plane,roi_name
52 sub-G4B1-K010-R-DISC4_ses-G4B1-K010_image+ophys.nwb imaging 4.7 Drd1a drd1a-cre CS-tone an US delivery are unpaired True True NaN NaN NaN NaN NaN NaN NaN 145.0 imaging_plane,roi_name
53 sub-G4B2-C8-6860-L-carl-DISC6UNP+TONES_ses-G4B2-C8-6860_im imaging 4.5 Drd1a drd1a-cre CS-tone an US delivery are unpaired True True NaN NaN NaN NaN NaN NaN NaN 36.0 imaging_plane,roi_name
54 sub-G4B2-J919-L-DISC6_ses-G4B2-J919_image+ophys.nwb imaging 4.7 Drd2 drd2-cre CS-tone an US delivery are unpaired True True NaN NaN NaN NaN NaN NaN NaN 111.0 imaging_plane,roi_name
55 sub-G4B3-K029-L-DISC5_ses-G4B3-K029_image+ophys.nwb imaging 4.4 Drd1a drd1a-cre CS-tone an US delivery are unpaired True True NaN NaN NaN NaN NaN NaN NaN 153.0 imaging_plane,roi_name
56 sub-G4B4-C9-6891-R-mooneye-DISC7UNP+TONES_ses-G4B4-C9-6891 imaging 5.7 Drd1a drd1a-cre CS-tone an US delivery are unpaired True True NaN NaN NaN NaN NaN NaN NaN 114.0 imaging_plane,roi_name
57 sub-J895-Day4-RoomA-conditioned_ses-J895-Day4_image+ophys. imaging 3.5 Drd2 drd2-cre Context A (conditioned) True True NaN NaN NaN NaN NaN NaN NaN 91.0 imaging_plane,roi_name
58 sub-J895-Day4-RoomB-unconditioned_ses-J895-Day4_image+ophy imaging 3.8 Drd2 drd2-cre Context B (unconditioned) True True NaN NaN NaN NaN NaN NaN NaN 70.0 imaging_plane,roi_name
59 sub-J904-Day4-RoomA-conditioned_ses-J904-Day4_image+ophys. imaging 3.6 Drd2 drd2-cre Context A (conditioned) True True NaN NaN NaN NaN NaN NaN NaN 80.0 imaging_plane,roi_name
60 sub-J904-Day4-RoomB-unconditioned_ses-J904-Day4_image+ophy imaging 3.4 Drd2 drd2-cre Context B (unconditioned) True True NaN NaN NaN NaN NaN NaN NaN 70.0 imaging_plane,roi_name
61 sub-J907-Day4-RoomA-unconditioned_ses-J907-Day4_image+ophy imaging 4.3 Drd2 drd2-cre Context B (unconditioned) True True NaN NaN NaN NaN NaN NaN NaN 71.0 imaging_plane,roi_name
62 sub-J907-Day4-RoomB-conditioned_ses-J907-Day4_image+ophys. imaging 4.3 Drd2 drd2-cre Context A (conditioned) True True NaN NaN NaN NaN NaN NaN NaN 65.0 imaging_plane,roi_name
63 sub-J908-Day4-RoomA-unconditioned_ses-J908-Day4_image+ophy imaging 3.2 Drd2 drd2-cre Context B (unconditioned) True True NaN NaN NaN NaN NaN NaN NaN 167.0 imaging_plane,roi_name
64 sub-J908-Day4-RoomB-conditioned_ses-J908-Day4_image+ophys. imaging 3.0 Drd2 drd2-cre Context A (conditioned) True True NaN NaN NaN NaN NaN NaN NaN 103.0 imaging_plane,roi_name
65 sub-J917-Day4-RoomA-conditioned_ses-J917-Day4_image+ophys. imaging 3.4 Drd2 drd2-cre Context A (conditioned) True True NaN NaN NaN NaN NaN NaN NaN 83.0 imaging_plane,roi_name
66 sub-J917-Day4-RoomB-unconditioned_ses-J917-Day4_image+ophy imaging 3.2 Drd2 drd2-cre Context B (unconditioned) True True NaN NaN NaN NaN NaN NaN NaN 65.0 imaging_plane,roi_name
67 sub-J932-Disc6_ses-J932-Disc6_image+ophys.nwb imaging 4.8 Drd2 drd2-cre CS-tone paired with US delivery True True NaN NaN NaN NaN NaN NaN NaN 195.0 imaging_plane,roi_name
68 sub-J933-Disc4_image+ophys.nwb imaging 4.1 Drd2 drd2-cre CS-tone paired with US delivery True True NaN NaN NaN NaN NaN NaN NaN 331.0 imaging_plane,roi_name
69 sub-J933-Disc4_ses-J933-Disc4_image+ophys.nwb imaging 4.1 Drd2 drd2-cre CS-tone paired with US delivery True True NaN NaN NaN NaN NaN NaN NaN 331.0 imaging_plane,roi_name
70 sub-K008-CFCD4-A3-c-conditioned_ses-K008-CFCD4_image+ophys imaging 3.0 Drd1a drd1a-cre Context A (conditioned) True True NaN NaN NaN NaN NaN NaN NaN 68.0 imaging_plane,roi_name
71 sub-K008-CFCD4-B4-u-unconditioned_ses-K008-CFCD4_image+oph imaging 3.5 Drd1a drd1a-cre Context B (unconditioned) True True NaN NaN NaN NaN NaN NaN NaN 55.0 imaging_plane,roi_name
72 sub-K008-Disc4_ses-K008-Disc4_image+ophys.nwb imaging 3.9 Drd1a drd1a-cre CS-tone paired with US delivery True True NaN NaN NaN NaN NaN NaN NaN 127.0 imaging_plane,roi_name
73 sub-K010-Day4-RoomA-unconditioned_ses-K010-Day4_image+ophy imaging 3.2 Drd1a drd1a-cre Context B (unconditioned) True True NaN NaN NaN NaN NaN NaN NaN 107.0 imaging_plane,roi_name
74 sub-K010-Day4-RoomB-conditioned_ses-K010-Day4_image+ophys. imaging 4.0 Drd1a drd1a-cre Context A (conditioned) True True NaN NaN NaN NaN NaN NaN NaN 64.0 imaging_plane,roi_name
75 sub-K029-Day4-RoomA-unconditioned_ses-K029-Day4_image+ophy imaging 3.1 Drd1a drd1a-cre Context B (unconditioned) True True NaN NaN NaN NaN NaN NaN NaN 71.0 imaging_plane,roi_name
76 sub-K029-Day4-RoomB-conditioned_ses-K029-Day4_image+ophys. imaging 4.2 Drd1a drd1a-cre Context A (conditioned) True True NaN NaN NaN NaN NaN NaN NaN 73.0 imaging_plane,roi_name
77 sub-K035-Day4-RoomA-conditioned_ses-K035-Day4_image+ophys. imaging 4.1 Drd1a drd1a-cre Context A (conditioned) True True NaN NaN NaN NaN NaN NaN NaN 74.0 imaging_plane,roi_name
78 sub-K035-Day4-RoomB-unconditioned_ses-K035-Day4_image+ophy imaging 4.0 Drd1a drd1a-cre Context B (unconditioned) True True NaN NaN NaN NaN NaN NaN NaN 84.0 imaging_plane,roi_name
79 sub-K047-Day4-RoomA-unconditioned_ses-K047-Day4_image+ophy imaging 4.1 Drd1a drd1a-cre Context B (unconditioned) True True NaN NaN NaN NaN NaN NaN NaN 63.0 imaging_plane,roi_name
80 sub-K047-Day4-RoomB-conditioned_ses-K047-Day4_image+ophys. imaging 4.2 Drd1a drd1a-cre Context A (conditioned) True True NaN NaN NaN NaN NaN NaN NaN 53.0 imaging_plane,roi_name
81 sub-K054-Day4-RoomA-conditioned_ses-K054-Day4_image+ophys. imaging 3.3 Drd1a drd1a-cre Context A (conditioned) True True NaN NaN NaN NaN NaN NaN NaN 50.0 imaging_plane,roi_name
82 sub-K054-Day4-RoomB-unconditioned_ses-K054-Day4_image+ophy imaging 4.4 Drd1a drd1a-cre Context B (unconditioned) True True NaN NaN NaN NaN NaN NaN NaN 57.0 imaging_plane,roi_name
# Open Ephys sessions: spikes, trial events, port entries, poses. The Neuropixels files hold no
# trial events and no behavior (inventory above), so no cue response can be computed from them.
oe_paths = INV.loc[INV.kind == "openephys", "path"].tolist()
with ThreadPoolExecutor(4) as ex:
OE_ALL = list(ex.map(M.load_oe, oe_paths))
# one recording deposited twice: identical spikes and events
dup = [d for d in OE_ALL if d["subject_id"].startswith("6197")]
print("6197 files:", [d["path"].split("/")[-1] for d in dup])
print("identical spike trains:", all(np.array_equal(a, b) for a, b in zip(dup[0]["spikes"], dup[1]["spikes"])),
"identical CS onsets:", np.array_equal(dup[0]["shock_on"], dup[1]["shock_on"]) and np.array_equal(dup[0]["reward_on"], dup[1]["reward_on"]))
OE, seen = [], set()
for d in sorted(OE_ALL, key=lambda d: d["path"]):
if d["subject_id"] in seen: continue
seen.add(d["subject_id"]); OE.append(d)
for d in OE:
rate = np.array([len(s) / d["duration"] for s in d["spikes"]])
d["rates"] = rate
d["units"] = [s for s, r in zip(d["spikes"], rate) if r < 50] # code: discall.py, rate below 50 Hz
d["region"] = "ASt" if d["location"] == ["amygdalostriatal transition zone"] else "CeA"
lat = []
for o in d["reward_on"]:
pe = d["port_on"][d["port_on"] >= o]; lat.append(pe[0] - o if len(pe) else np.inf)
d["latency"] = np.array(lat) # reading: first port entry at or after onset
d["latency_tone"] = d["reward_off"] - d["reward_on"] # reading: tone duration (collection ends the tone)
AST = [d for d in OE if d["region"] == "ASt"]
tab = pd.DataFrame([{"subject": d["subject_id"], "region": d["region"], "units": len(d["spikes"]), "units<50Hz": len(d["units"]),
"max rate Hz": d["rates"].max().round(1), "CS-shock": len(d["shock_on"]), "CS-reward": len(d["reward_on"]),
"port entries": len(d["port_on"]), "session s": round(d["duration"]),
"shock tone s": np.round(np.median(d["shock_off"] - d["shock_on"]), 2),
"reward tone s (min-max)": f'{(d["reward_off"]-d["reward_on"]).min():.2f}-{(d["reward_off"]-d["reward_on"]).max():.2f}',
"pose frames": len(d["pose_t"]), "pose fps": round(1 / np.median(np.diff(d["pose_t"])), 2)} for d in OE])
print(tab.to_string())
print("ASt mice", len(AST), "ASt units below 50 Hz", sum(len(d["units"]) for d in AST))
6197 files: ['sub-6197-20190718-daijobuDiscD4_ecephys+image.nwb', 'sub-6197-20190718-daijobuDiscD4_ses-6197-2019-07-18-16-31-26-daijobuDiscD4_ecephys+image.nwb']
identical spike trains: True identical CS onsets: True
subject region units units<50Hz max rate Hz CS-shock CS-reward port entries session s shock tone s reward tone s (min-max) pose frames pose fps
0 3012_20180810_innerpeaceDiscD4 CeA 9 9 11.5 28 90 1374 12091 20.0 0.08-20.00 361940 30.0
1 3014_20180626_illidanDiscD4 ASt 5 5 1.8 30 90 375 12421 20.0 0.95-20.00 369125 30.0
2 3016_20180810_donkeyDiscD4 ASt 14 14 7.2 30 89 846 12093 20.0 0.03-13.47 351255 30.0
3 3024_20180810_ishmaelDiscD4 ASt 18 18 6.0 29 90 1236 12873 20.0 0.12-20.00 370935 30.0
4 3026_20181129_dengDiscD3 ASt 12 12 11.6 30 90 1210 12622 20.0 0.04-20.00 369897 30.0
5 3029_20181128_iouxioDiscD2 ASt 5 5 5.3 30 90 390 12493 20.0 0.06-20.00 373941 30.0
6 6197_20190718_daijobuDiscD4 ASt 11 11 15.3 30 90 2674 12103 20.0 0.02-16.41 177204 15.0
7 6253_20190913_daisyDISCD3 ASt 6 5 65.7 30 90 1423 12254 20.0 0.03-10.52 180288 15.0
8 6429_20191016_durianDiscD5 ASt 6 6 45.7 30 88 1878 11877 20.0 0.02-20.00 173578 15.0
9 7001_20190718_ichimokuDiscD4 CeA 13 13 21.9 30 90 1178 12277 20.0 0.01-11.47 179497 15.0
10 7008_20190718_ikariDiscD4 ASt 19 19 25.8 30 90 1357 12100 20.0 0.16-17.10 171252 15.0
11 7049_20190914_ivyDiscD4 ASt 17 17 17.0 30 89 1664 12836 20.0 0.01-14.58 188842 15.0
ASt mice 10 ASt units below 50 Hz 112
# Check: the reward tone ends when the reward is collected (STAR Methods). Tone stop minus first port entry after onset.
gap = np.concatenate([(d["reward_off"] - d["reward_on"]) - d["latency"] for d in OE])
gap = gap[np.isfinite(gap)]
print("tone stop minus first port entry, s: median %.3f, 5th-95th pct %.3f to %.3f, n=%d" % (np.median(gap), *np.percentile(gap, [5, 95]), len(gap)))
print(pd.DataFrame([{"subject": d["subject_id"][:12], "CS-reward": len(d["reward_on"]),
"in port at onset": int(sum(((d["port_on"] < o) & (d["port_off"] > o)).any() for o in d["reward_on"])),
"reward delivery s after onset (median)": np.median([d["reward_delivery"][d["reward_delivery"] >= o][0] - o for o in d["reward_on"] if (d["reward_delivery"] >= o).any()]),
"tone 20 s (not collected)": int((d["latency_tone"] > 19.9).sum()),
"latency>2 s, tone": int((d["latency_tone"] > 2).sum()), "latency>2 s, first entry": int((d["latency"] > 2).sum())} for d in OE]).to_string())
# Check: spikes share the clock of the trial table. Share of units with |mean z| > 2 over 0-1 s after the
# true CS onsets, and after the same onsets shifted 45 s back (inside the inter-trial interval).
rows = []
for d in OE:
def share(on):
out = []
for s in d["units"]:
z, c = M.cue_z(s, on, 0.1); out.append(abs(M.window_mean(z, c, (0, 1))) > 2)
return np.mean(out)
rows.append({"subject": d["subject_id"][:12], "shock true": share(d["shock_on"]), "shock -45 s": share(d["shock_on"] - 45),
"reward true": share(d["reward_on"]), "reward -45 s": share(d["reward_on"] - 45)})
print(pd.DataFrame(rows).round(2).to_string())
tone stop minus first port entry, s: median 0.400, 5th-95th pct -8.625 to 0.400, n=1076
subject CS-reward in port at onset reward delivery s after onset (median) tone 20 s (not collected) latency>2 s, tone latency>2 s, first entry
0 3012_2018081 90 27 1.000000 5 49 52
1 3014_2018062 90 0 0.999983 6 86 85
2 3016_2018081 89 2 0.999967 0 40 22
3 3024_2018081 90 23 0.999967 18 75 65
4 3026_2018112 90 28 0.999967 10 54 55
5 3029_2018112 90 5 1.000000 4 74 72
6 6197_2019071 90 19 0.999967 0 35 32
7 6253_2019091 90 14 1.000000 0 49 49
8 6429_2019101 88 16 0.999983 7 55 51
9 7001_2019071 90 8 0.999967 0 33 29
10 7008_2019071 90 14 0.999967 0 52 45
11 7049_2019091 89 20 0.999967 0 26 27
subject shock true shock -45 s reward true reward -45 s 0 3012_2018081 0.00 0.0 0.33 0.0 1 3014_2018062 0.40 0.0 0.00 0.0 2 3016_2018081 0.64 0.0 0.29 0.0 3 3024_2018081 0.83 0.0 0.28 0.0 4 3026_2018112 0.00 0.0 0.00 0.0 5 3029_2018112 0.00 0.0 0.60 0.0 6 6197_2019071 0.09 0.0 0.18 0.0 7 6253_2019091 0.40 0.0 0.00 0.0 8 6429_2019101 0.00 0.0 0.50 0.0 9 7001_2019071 0.62 0.0 0.08 0.0 10 7008_2019071 0.00 0.0 0.37 0.0 11 7049_2019091 0.41 0.0 0.24 0.0
The pose of the Open Ephys sessions is checked against the trial clock in two independent ways: the nose position at the port-entry times of the trial table (the nose is at the port then, so its positions cluster only when the clocks agree), and the speed of the haunch around the shock times (a 0.7 mA shock makes the mouse jump). Each is computed at lags from -300 to +300 s. The imaging files, whose port entries were detected from the same behavior video, are the control.
LAGS = np.arange(-300, 300.01, 0.2)
def port_lag(t, xy, pe):
nose = xy[:, M.NODES.index("Nose")]
spread = []
for L in LAGS:
i = np.clip(np.searchsorted(t, pe + L), 0, len(t) - 1)
p = nose[i]; ok = ~np.isnan(p[:, 0])
spread.append(np.median(np.linalg.norm(p[ok] - np.median(p[ok], 0), axis=1)))
spread = np.array(spread); k = np.argmin(spread)
return LAGS[k], spread[k], spread[np.argmin(abs(LAGS))], np.median(spread)
def shock_lag(d):
t, xy = d["pose_t"], d["pose"]; ppc = M.pixels_per_cm(xy); fps = 1 / np.median(np.diff(t))
sp = np.nan_to_num(np.linalg.norm(np.diff(xy[:, M.NODES.index("Haunch")], axis=0), axis=1) / ppc * fps)
g = np.arange(0, t[-1], 0.1); s = np.interp(g, t[1:], sp)
idx = np.clip(((d["shock_relay"][:, None] + LAGS[None, :]) / 0.1).astype(int), 0, len(s) - 1)
eta = s[idx].mean(0); k = np.argmax(eta)
return LAGS[k], (eta[k] - np.median(eta)) / eta.std()
rows = []
for d in OE:
L, best, at0, med = port_lag(d["pose_t"], d["pose"], d["port_on"])
Ls, zs = shock_lag(d)
rows.append({"subject": d["subject_id"][:12], "pose fps": round(1 / np.median(np.diff(d["pose_t"]))), "port: best lag s": round(L, 1),
"nose spread px at best": round(best, 1), "at lag 0": round(at0, 1), "median over lags": round(med, 1),
"shock: best lag s": round(Ls, 1), "shock peak z": round(zs, 1),
"pose span s": round(d["pose_t"][-1]), "ephys span s": round(d["duration"])})
POSE_CLOCK = pd.DataFrame(rows)
print(POSE_CLOCK.to_string())
subject pose fps port: best lag s nose spread px at best at lag 0 median over lags shock: best lag s shock peak z pose span s ephys span s 0 3012_2018081 30 -6.6 7.100000 31.600000 47.099998 -6.8 14.1 12090 12091 1 3014_2018062 30 -10.6 60.400002 217.800003 164.000000 -225.8 13.6 12388 12421 2 3016_2018081 30 -9.8 14.400000 246.600006 275.000000 -9.2 6.4 12090 12093 3 3024_2018081 30 -9.8 14.600000 43.200001 85.300003 -9.6 13.4 12936 12873 4 3026_2018112 30 287.4 38.700001 102.400002 104.599998 41.0 11.8 12506 12622 5 3029_2018112 30 6.6 10.100000 276.700012 256.299988 -101.2 5.4 12506 12493 6 6197_2019071 15 -91.6 81.400002 94.500000 96.300003 263.6 5.8 11920 12103 7 6253_2019091 15 -110.6 117.099998 160.199997 149.300003 -198.8 6.9 12100 12254 8 6429_2019101 15 -76.6 94.000000 210.500000 181.100006 -251.8 4.7 11727 11877 9 7001_2019071 15 162.8 112.900002 137.500000 132.100006 70.4 6.8 12110 12277 10 7008_2019071 15 -95.0 93.800003 124.300003 126.199997 155.2 6.0 11949 12100 11 7049_2019091 15 192.0 101.500000 121.000000 120.699997 -146.0 5.0 12687 12836
# Offset and drift: the best port-entry lag in each quarter of the session (port entries split into
# four equal groups by time). A constant lag with a small spread in all four quarters is a fixed offset.
rows = []
for d in OE:
pe = d["port_on"]; edges = np.quantile(pe, [0, 0.25, 0.5, 0.75, 1]); r = {"subject": d["subject_id"][:12]}
for k, (a, b) in enumerate(zip(edges[:-1], edges[1:])):
L, best, _, _ = port_lag(d["pose_t"], d["pose"], pe[(pe >= a) & (pe <= b)])
r[f"Q{k+1} lag s"] = round(L, 1); r[f"Q{k+1} spread px"] = round(best, 1)
rows.append(r)
POSE_DRIFT = pd.DataFrame(rows); print(POSE_DRIFT.to_string())
subject Q1 lag s Q1 spread px Q2 lag s Q2 spread px Q3 lag s Q3 spread px Q4 lag s Q4 spread px 0 3012_2018081 -6.6 6.700000 -6.6 4.900000 -6.8 5.200000 -6.8 7.600000 1 3014_2018062 -10.2 12.800000 -11.6 43.400002 -14.6 58.200001 -32.0 56.500000 2 3016_2018081 -9.6 11.800000 -9.8 14.600000 -9.8 14.000000 -9.8 15.400000 3 3024_2018081 -9.8 12.700000 -10.0 14.500000 -9.8 14.700000 -9.2 12.000000 4 3026_2018112 -15.8 22.799999 -209.8 20.000000 -164.8 74.699997 -183.0 10.800000 5 3029_2018112 6.6 10.700000 7.0 10.100000 6.4 10.000000 6.6 7.900000 6 6197_2019071 -34.2 72.599998 -89.0 61.000000 -12.2 45.599998 -247.8 73.000000 7 6253_2019091 -17.4 63.400002 -44.2 74.699997 -94.8 96.599998 -125.6 104.800003 8 6429_2019101 100.0 43.900002 -56.8 70.699997 -113.6 46.299999 -124.6 36.400002 9 7001_2019071 39.2 78.099998 -222.0 87.900002 288.0 91.300003 -241.2 116.099998 10 7008_2019071 90.6 105.500000 -80.4 67.000000 -106.4 58.299999 -142.0 59.500000 11 7049_2019091 242.2 42.299999 -47.2 70.599998 -228.0 99.900002 143.8 101.300003
# Calcium imaging sessions. The two J933 files hold identical traces; their port entries differ.
im_paths = INV.loc[(INV.kind == "imaging") & (INV.rois > 0), "path"].tolist()
with ThreadPoolExecutor(4) as ex:
IM_ALL = list(ex.map(M.load_ophys, im_paths))
j = [d for d in IM_ALL if "J933" in d["path"]]
print("J933 files:", [(d["path"].split("/")[-1], d["F"].shape, len(d["port_on"])) for d in j],
"identical traces:", np.array_equal(j[0]["F"], j[1]["F"]))
for d in IM_ALL:
d["file"] = d["path"].split("/")[-1][:45]
d["gen"] = "Drd2" if "drd2" in d["genotype"].lower() else "Drd1a"
d["dt"] = float(np.median(np.diff(d["t"])))
if "port_on" in d:
d["port_lag"] = port_lag(d["pose_t"], d["pose"], d["port_on"])
print(pd.DataFrame([{"file": d["file"], "port lag s": round(d["port_lag"][0], 1), "spread at best px": round(d["port_lag"][1], 1),
"at 0": round(d["port_lag"][2], 1), "median": round(d["port_lag"][3], 1)} for d in IM_ALL if "port_lag" in d]).to_string())
J933 files: [('sub-J933-Disc4_image+ophys.nwb', (13278, 331), 193), ('sub-J933-Disc4_ses-J933-Disc4_image+ophys.nwb', (13278, 331), 55)] identical traces: True
file port lag s spread at best px at 0 median 0 sub-C1-J642-Disc5_ses-C1-J642-Disc5_image+oph 0.4 3.6 21.100000 11.600000 1 sub-C3-J670-Disc5Unp_ses-C3-J670-Disc5Unp_ima 0.2 3.9 16.400000 240.699997 2 sub-C6-J588-Disc5_ses-C6-J588-Disc5_image+oph 89.0 3.0 15.900000 5.800000 3 sub-C6-J650-Disc5_ses-C6-J650-Disc5_image+oph 0.6 2.8 16.900000 29.799999 4 sub-C8-J633-Disc5Unp_ses-C8-J633-Disc5Unp_ima 0.4 6.4 18.700001 33.799999 5 sub-C8-J634-Disc5Unp_ses-C8-J634-Disc5Unp_ima 0.4 5.5 18.700001 64.000000 6 sub-G1B1-C1-6868-L-quetzal-DISC6+TONES_ses-G1 0.2 11.3 16.400000 88.800003 7 sub-G1B1-J895-R-DISC4_ses-G1B1-J895_image+oph 1.8 5.1 21.700001 117.599998 8 sub-G1B2-C1-6865-R-frogman-DISC5_ses-G1B2-C1- 0.6 6.3 21.200001 122.500000 9 sub-G1B2-J904-L-DISC6_ses-G1B2-J904_image+oph 0.6 2.5 5.100000 97.699997 10 sub-G1B3-C2-6882-R-kevin-DISC6+TONES_ses-G1B3 0.4 8.7 22.200001 100.099998 11 sub-G1B3-K033-R-DISC6_ses-G1B3-K033_image+oph 1.2 3.4 12.900000 46.299999 12 sub-G1B4-C3-6921-R-nessie-DISC6+TONES_ses-G1B 0.4 7.7 22.200001 93.199997 13 sub-G1B4-K035-R-DISC4_ses-G1B4-K035_image+oph 0.6 2.8 16.400000 123.000000 14 sub-G2B1-C4-6886-L-jackalope-DISC6UNP+TONES_s 0.4 14.4 23.799999 158.800003 15 sub-G2B1-J915-R-DISC4_ses-G2B1-J915_image+oph 1.6 3.8 12.100000 209.899994 16 sub-G2B2-J917-R-DISC6_ses-G2B2-J917_image+oph 4.0 3.0 7.700000 377.299988 17 sub-G2B3-C4-6885-R-cyclops-DISC6UNP+TONES_ses 0.4 7.1 22.500000 329.299988 18 sub-G2B3-K036-L-DISC4_ses-G2B3-K036_image+oph 1.6 5.6 13.300000 239.500000 19 sub-G2B4-K054-R-DISC5_ses-G2B4-K054_image+oph 1.2 7.9 25.500000 313.899994 20 sub-G3B1-C5-6933-R-chupacabra-DISC5_ses-G3B1- 0.6 3.6 21.100000 138.699997 21 sub-G3B2-J908-R-DISC5_ses-G3B2-J908_image+oph 0.2 10.8 10.900000 29.500000 22 sub-G3B3-K047-L-DISC5_ses-G3B3-K047_image+oph 1.4 2.8 9.000000 20.500000 23 sub-G3B4-C7-6915-R-mothman-DISC6+TONES_ses-G3 0.6 5.6 21.700001 96.199997 24 sub-G3B4-J907-R-DISC4_ses-G3B4-J907_image+oph 1.6 3.7 19.400000 49.900002 25 sub-G4B1-K010-R-DISC4_ses-G4B1-K010_image+oph 1.0 2.5 13.600000 123.000000 26 sub-G4B2-C8-6860-L-carl-DISC6UNP+TONES_ses-G4 0.2 12.3 23.700001 215.000000 27 sub-G4B2-J919-L-DISC6_ses-G4B2-J919_image+oph 0.8 3.9 13.600000 223.899994 28 sub-G4B3-K029-L-DISC5_ses-G4B3-K029_image+oph 2.0 7.2 9.700000 141.899994 29 sub-G4B4-C9-6891-R-mooneye-DISC7UNP+TONES_ses 0.6 5.9 18.600000 258.799988 30 sub-J932-Disc6_ses-J932-Disc6_image+ophys.nwb 1.0 3.9 16.900000 73.300003 31 sub-J933-Disc4_image+ophys.nwb 1.6 2.8 18.500000 66.800003 32 sub-J933-Disc4_ses-J933-Disc4_image+ophys.nwb -236.4 27.0 46.700001 63.299999 33 sub-K008-Disc4_ses-K008-Disc4_image+ophys.nwb 1.4 5.1 24.200001 122.300003
# Keep the J933 file whose port entries agree with its pose (lag near 0), drop the other.
bad = [d for d in IM_ALL if "J933" in d["path"] and abs(d["port_lag"][0]) > 5]
print("dropped:", [d["path"] for d in bad])
IM = [d for d in IM_ALL if d not in bad]
DISC = [d for d in IM if "cs_on" in d]
CTX = [d for d in IM if "Context" in d["session_description"]]
for d in DISC:
d["grp"] = "paired" if "paired with" in d["session_description"] else "unpaired"
for typ in ["Shock", "Reward"]:
on = d["cs_on"][(d["cs_type"] == typ) & d["cs_imaged"]]
d["n" + typ] = len(on)
d["z" + typ], d["grid"] = M.ca_cue_z(d["F"], d["t"], on)
tab = pd.DataFrame([{"file": d["file"], "genotype": d["gen"], "group": d["grp"], "ROIs": d["F"].shape[1], "frames": d["F"].shape[0],
"frame interval s": round(d["dt"], 4), "CS events": len(d["cs_on"]), "imaged CS-shock": d["nShock"],
"imaged CS-reward": d["nReward"], "F range": f'{d["F"].min():.1f} to {d["F"].max():.1f}'} for d in DISC])
print(tab.to_string())
print("CS event types per file:", collections.Counter(tuple(sorted(collections.Counter(d["cs_type"].tolist()).items())) for d in DISC))
# Imaged clips per session and how far each CS event is covered by a clip (from before onset to +1, +3, +10 s)
def covered(d, typ, post):
on = d["cs_on"][d["cs_type"] == typ]
return int(sum(((d["clip_start"] <= o) & (d["clip_stop"] >= o + post)).any() for o in on))
print(pd.DataFrame([{"file": d["file"], "clips": len(d["clip_start"]), **{f"{typ} to +{p} s": covered(d, typ, p) for typ in ["Shock", "Reward"] for p in [1, 3, 10]}}
for d in DISC]).to_string())
cnt = tab.groupby(["genotype", "group"]).agg(mice=("file", "size"), ROIs=("ROIs", "sum"))
cnt["paper neurons"] = [320, 237, 296, 257]; cnt["paper mice"] = [10, 8, 9, 6]
print(cnt)
print("context sessions:", len(CTX), pd.DataFrame([{"file": d["file"], "genotype": d["gen"], "context": d["session_description"], "ROIs": d["F"].shape[1],
"frame interval s": round(d["dt"], 4), "minutes": round((d["t"][-1] - d["t"][0]) / 60, 1)} for d in CTX]).to_string())
print("peak memory MB", resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1024, "elapsed s", round(time.time() - T0))
dropped: ['sub-J933-Disc4/sub-J933-Disc4_ses-J933-Disc4_image+ophys.nwb']
file genotype group ROIs frames frame interval s CS events imaged CS-shock imaged CS-reward F range
0 sub-C1-J642-Disc5_ses-C1-J642-Disc5_image+oph Drd2 paired 24 10301 0.0667 60 15 15 -82.7 to 324.2
1 sub-C3-J670-Disc5Unp_ses-C3-J670-Disc5Unp_ima Drd2 unpaired 43 10262 0.0667 60 15 15 -64.6 to 122.9
2 sub-C6-J588-Disc5_ses-C6-J588-Disc5_image+oph Drd2 paired 84 10262 0.0667 60 15 15 -41.3 to 502.2
3 sub-C6-J650-Disc5_ses-C6-J650-Disc5_image+oph Drd2 paired 77 10259 0.0667 60 15 15 -42.6 to 1263.3
4 sub-C8-J633-Disc5Unp_ses-C8-J633-Disc5Unp_ima Drd2 unpaired 12 10262 0.0667 60 15 15 -19.8 to 114.4
5 sub-C8-J634-Disc5Unp_ses-C8-J634-Disc5Unp_ima Drd2 unpaired 80 10262 0.0667 60 15 15 -116.2 to 279.0
6 sub-G1B1-C1-6868-L-quetzal-DISC6+TONES_ses-G1 Drd1a paired 206 15228 0.0667 60 15 18 -39.4 to 497.4
7 sub-G1B1-J895-R-DISC4_ses-G1B1-J895_image+oph Drd2 paired 109 13280 0.0673 60 15 15 -81.9 to 662.4
8 sub-G1B2-C1-6865-R-frogman-DISC5_ses-G1B2-C1- Drd1a paired 5 10262 0.0667 60 15 15 -5.3 to 45.4
9 sub-G1B2-J904-L-DISC6_ses-G1B2-J904_image+oph Drd2 paired 110 13281 0.0673 60 15 15 -91.6 to 766.6
10 sub-G1B3-C2-6882-R-kevin-DISC6+TONES_ses-G1B3 Drd1a paired 6 15224 0.0667 60 15 18 -6.7 to 161.8
11 sub-G1B3-K033-R-DISC6_ses-G1B3-K033_image+oph Drd1a paired 105 13285 0.0673 60 15 15 -69.7 to 879.1
12 sub-G1B4-C3-6921-R-nessie-DISC6+TONES_ses-G1B Drd1a paired 7 15217 0.0667 60 15 17 -10.0 to 51.5
13 sub-G1B4-K035-R-DISC4_ses-G1B4-K035_image+oph Drd1a paired 216 13279 0.0673 60 15 15 -48.6 to 547.6
14 sub-G2B1-C4-6886-L-jackalope-DISC6UNP+TONES_s Drd1a unpaired 1 15218 0.0667 60 15 19 -1.9 to 45.0
15 sub-G2B1-J915-R-DISC4_ses-G2B1-J915_image+oph Drd2 unpaired 247 13281 0.0673 60 15 15 -70.0 to 447.4
16 sub-G2B2-J917-R-DISC6_ses-G2B2-J917_image+oph Drd2 unpaired 132 13282 0.0673 60 15 15 -34.2 to 297.2
17 sub-G2B3-C4-6885-R-cyclops-DISC6UNP+TONES_ses Drd1a unpaired 6 15225 0.0667 60 15 19 -10.7 to 119.6
18 sub-G2B3-K036-L-DISC4_ses-G2B3-K036_image+oph Drd1a unpaired 51 13286 0.0673 60 15 15 -68.2 to 671.6
19 sub-G2B4-K054-R-DISC5_ses-G2B4-K054_image+oph Drd1a unpaired 102 13282 0.0673 60 15 15 -43.9 to 261.2
20 sub-G3B1-C5-6933-R-chupacabra-DISC5_ses-G3B1- Drd1a paired 106 10261 0.0667 60 15 15 -23.3 to 293.5
21 sub-G3B2-J908-R-DISC5_ses-G3B2-J908_image+oph Drd2 paired 141 13285 0.0673 60 15 15 -79.5 to 771.3
22 sub-G3B3-K047-L-DISC5_ses-G3B3-K047_image+oph Drd1a paired 63 13286 0.0673 60 15 15 -46.1 to 545.0
23 sub-G3B4-C7-6915-R-mothman-DISC6+TONES_ses-G3 Drd1a paired 6 15218 0.0667 60 15 18 -5.0 to 166.5
24 sub-G3B4-J907-R-DISC4_ses-G3B4-J907_image+oph Drd2 paired 118 13279 0.0673 60 15 15 -34.5 to 210.6
25 sub-G4B1-K010-R-DISC4_ses-G4B1-K010_image+oph Drd1a unpaired 145 13285 0.0673 60 15 15 -41.6 to 658.4
26 sub-G4B2-C8-6860-L-carl-DISC6UNP+TONES_ses-G4 Drd1a unpaired 36 7510 0.0668 60 1 4 -24.0 to 1417.7
27 sub-G4B2-J919-L-DISC6_ses-G4B2-J919_image+oph Drd2 unpaired 111 13279 0.0673 60 15 15 -41.9 to 248.3
28 sub-G4B3-K029-L-DISC5_ses-G4B3-K029_image+oph Drd1a unpaired 153 13283 0.0673 60 15 15 -36.7 to 222.1
29 sub-G4B4-C9-6891-R-mooneye-DISC7UNP+TONES_ses Drd1a unpaired 114 15210 0.0667 60 15 19 -51.8 to 631.1
30 sub-J932-Disc6_ses-J932-Disc6_image+ophys.nwb Drd2 paired 195 13277 0.0673 60 15 15 -57.7 to 407.3
31 sub-J933-Disc4_image+ophys.nwb Drd2 paired 331 13278 0.0673 60 15 15 -42.5 to 308.5
32 sub-K008-Disc4_ses-K008-Disc4_image+ophys.nwb Drd1a paired 127 13286 0.0673 60 15 15 -29.7 to 668.5
CS event types per file: Counter({(('Reward', 45), ('Shock', 15)): 33})
file clips Shock to +1 s Shock to +3 s Shock to +10 s Reward to +1 s Reward to +3 s Reward to +10 s
0 sub-C1-J642-Disc5_ses-C1-J642-Disc5_image+oph 30 15 15 15 15 15 15
1 sub-C3-J670-Disc5Unp_ses-C3-J670-Disc5Unp_ima 30 15 15 15 15 15 15
2 sub-C6-J588-Disc5_ses-C6-J588-Disc5_image+oph 30 15 15 15 15 15 15
3 sub-C6-J650-Disc5_ses-C6-J650-Disc5_image+oph 30 15 15 15 15 15 15
4 sub-C8-J633-Disc5Unp_ses-C8-J633-Disc5Unp_ima 30 15 15 15 15 15 15
5 sub-C8-J634-Disc5Unp_ses-C8-J634-Disc5Unp_ima 30 15 15 15 15 15 15
6 sub-G1B1-C1-6868-L-quetzal-DISC6+TONES_ses-G1 31 15 15 15 18 18 18
7 sub-G1B1-J895-R-DISC4_ses-G1B1-J895_image+oph 30 15 15 15 15 15 15
8 sub-G1B2-C1-6865-R-frogman-DISC5_ses-G1B2-C1- 30 15 15 15 15 15 15
9 sub-G1B2-J904-L-DISC6_ses-G1B2-J904_image+oph 30 15 15 15 15 15 15
10 sub-G1B3-C2-6882-R-kevin-DISC6+TONES_ses-G1B3 31 15 15 15 18 18 18
11 sub-G1B3-K033-R-DISC6_ses-G1B3-K033_image+oph 30 15 15 15 15 15 15
12 sub-G1B4-C3-6921-R-nessie-DISC6+TONES_ses-G1B 31 15 15 15 17 17 17
13 sub-G1B4-K035-R-DISC4_ses-G1B4-K035_image+oph 30 15 15 15 15 15 15
14 sub-G2B1-C4-6886-L-jackalope-DISC6UNP+TONES_s 31 15 15 15 19 19 19
15 sub-G2B1-J915-R-DISC4_ses-G2B1-J915_image+oph 30 15 15 15 15 15 15
16 sub-G2B2-J917-R-DISC6_ses-G2B2-J917_image+oph 30 15 15 15 15 15 15
17 sub-G2B3-C4-6885-R-cyclops-DISC6UNP+TONES_ses 31 15 15 15 19 19 19
18 sub-G2B3-K036-L-DISC4_ses-G2B3-K036_image+oph 30 15 15 15 15 15 15
19 sub-G2B4-K054-R-DISC5_ses-G2B4-K054_image+oph 30 15 15 15 15 15 15
20 sub-G3B1-C5-6933-R-chupacabra-DISC5_ses-G3B1- 30 15 15 15 15 15 15
21 sub-G3B2-J908-R-DISC5_ses-G3B2-J908_image+oph 30 15 15 15 15 15 15
22 sub-G3B3-K047-L-DISC5_ses-G3B3-K047_image+oph 30 15 15 15 15 15 15
23 sub-G3B4-C7-6915-R-mothman-DISC6+TONES_ses-G3 31 15 15 15 18 18 18
24 sub-G3B4-J907-R-DISC4_ses-G3B4-J907_image+oph 30 15 15 15 15 15 15
25 sub-G4B1-K010-R-DISC4_ses-G4B1-K010_image+oph 30 15 15 15 15 15 15
26 sub-G4B2-C8-6860-L-carl-DISC6UNP+TONES_ses-G4 22 1 1 1 5 5 4
27 sub-G4B2-J919-L-DISC6_ses-G4B2-J919_image+oph 30 15 15 15 15 15 15
28 sub-G4B3-K029-L-DISC5_ses-G4B3-K029_image+oph 30 15 15 15 15 15 15
29 sub-G4B4-C9-6891-R-mooneye-DISC7UNP+TONES_ses 31 15 15 15 19 19 19
30 sub-J932-Disc6_ses-J932-Disc6_image+ophys.nwb 30 15 15 15 15 15 15
31 sub-J933-Disc4_image+ophys.nwb 30 15 15 15 15 15 15
32 sub-K008-Disc4_ses-K008-Disc4_image+ophys.nwb 30 15 15 15 15 15 15
mice ROIs paper neurons paper mice
genotype group
Drd1a paired 10 847 320 10
unpaired 8 608 237 8
Drd2 paired 9 1189 296 9
unpaired 6 625 257 6
context sessions: 22 file genotype context ROIs frame interval s minutes
0 sub-J895-Day4-RoomA-conditioned_ses-J895-Day4 Drd2 Context A (conditioned) 91 0.0673 15.9
1 sub-J895-Day4-RoomB-unconditioned_ses-J895-Da Drd2 Context B (unconditioned) 70 0.0673 15.2
2 sub-J904-Day4-RoomA-conditioned_ses-J904-Day4 Drd2 Context A (conditioned) 80 0.0673 15.9
3 sub-J904-Day4-RoomB-unconditioned_ses-J904-Da Drd2 Context B (unconditioned) 70 0.0673 15.9
4 sub-J907-Day4-RoomA-unconditioned_ses-J907-Da Drd2 Context B (unconditioned) 71 0.0673 15.9
5 sub-J907-Day4-RoomB-conditioned_ses-J907-Day4 Drd2 Context A (conditioned) 65 0.0673 16.0
6 sub-J908-Day4-RoomA-unconditioned_ses-J908-Da Drd2 Context B (unconditioned) 167 0.0673 16.0
7 sub-J908-Day4-RoomB-conditioned_ses-J908-Day4 Drd2 Context A (conditioned) 103 0.0673 15.4
8 sub-J917-Day4-RoomA-conditioned_ses-J917-Day4 Drd2 Context A (conditioned) 83 0.0673 15.9
9 sub-J917-Day4-RoomB-unconditioned_ses-J917-Da Drd2 Context B (unconditioned) 65 0.0673 16.5
10 sub-K008-CFCD4-A3-c-conditioned_ses-K008-CFCD Drd1a Context A (conditioned) 68 0.0673 18.0
11 sub-K008-CFCD4-B4-u-unconditioned_ses-K008-CF Drd1a Context B (unconditioned) 55 0.0673 15.6
12 sub-K010-Day4-RoomA-unconditioned_ses-K010-Da Drd1a Context B (unconditioned) 107 0.0673 16.1
13 sub-K010-Day4-RoomB-conditioned_ses-K010-Day4 Drd1a Context A (conditioned) 64 0.0673 16.6
14 sub-K029-Day4-RoomA-unconditioned_ses-K029-Da Drd1a Context B (unconditioned) 71 0.0673 15.1
15 sub-K029-Day4-RoomB-conditioned_ses-K029-Day4 Drd1a Context A (conditioned) 73 0.0673 15.7
16 sub-K035-Day4-RoomA-conditioned_ses-K035-Day4 Drd1a Context A (conditioned) 74 0.0673 15.8
17 sub-K035-Day4-RoomB-unconditioned_ses-K035-Da Drd1a Context B (unconditioned) 84 0.0673 15.5
18 sub-K047-Day4-RoomA-unconditioned_ses-K047-Da Drd1a Context B (unconditioned) 63 0.0673 15.4
19 sub-K047-Day4-RoomB-conditioned_ses-K047-Day4 Drd1a Context A (conditioned) 53 0.0673 15.4
20 sub-K054-Day4-RoomA-conditioned_ses-K054-Day4 Drd1a Context A (conditioned) 50 0.0673 15.9
21 sub-K054-Day4-RoomB-unconditioned_ses-K054-Da Drd1a Context B (unconditioned) 57 0.0673 15.8
peak memory MB 2702.18359375 elapsed s 876
Checks of the description against the data.
- Groups. The Neuropixels files say paired or unpaired in the subject description; the Open Ephys files say neither. The paper's 4 unpaired ASt mice match the 4 Neuropixels files marked unpaired, so the 12 Open Ephys mice are taken as paired (consistent with the data, not shown).
- Regions. Open Ephys electrode groups say ASt (10 mice) or CeA (2). Every Neuropixels electrode
is labeled ASt or CeA by file, and the units have no region column. They do have
probe_depth(micrometers from the tip, 0 to 3620 in NPX-10), alabelcolumn (good or mua) and the files hold histology images of the probe track, which could support a region per unit; but no file maps depth to region, so the TS units the paper analyses cannot be found as the files stand. Units labeled good and below 50 Hz are still more than the paper's counts (fig2 cell). - Units. The Open Ephys units table is the curated set (its description gives quality and spike count rules); all its units are kept by the code's 50 Hz rule except where the table shows.
- Cue timing. The CS-shock tones last 20 s, and the CS-reward tones end about 0.4 s after the first port entry (median 0.40 s), as the Methods say collection ends the tone. The reward is delivered 1 s after onset. In 0 to 28 trials per session the mouse is already in the port at onset, so the first entry after onset can come long after the tone ended (5th percentile -8.6 s); the tone duration is therefore taken as the port latency, with the first entry as the other reading. Spikes respond at the true CS onsets and not 45 s earlier, so spikes and trial events share a clock.
- Pose clock. In the Open Ephys files the pose is not on the trial clock: in no session is the best port-entry lag within 5 s of zero. In four of the six 2018 sessions (3012, 3016, 3024, 3029) the nose clusters at port entry (spread 7 to 15 px) at a lag of -6.6 s in 3012, -9.8 s in 3016 and 3024 and +6.6 s in 3029, and in three of them the shock check agrees within 0.6 s; in 3014 and 3026 the best spread is 60 and 39 px; in the six 2019 sessions (pose at 15 frames/s) no lag brings the spread below 81 px. Fitted in each quarter of the session, the lag is constant (within 0.8 s, spread 5 to 15 px) in the same four 2018 sessions, so these have a fixed offset and no drift; in 3014, 3026 and every 2019 session it changes by 22 to 529 s between quarters, so no offset, or offset plus linear drift, maps them. The shock check agrees with the fixed offset in 3012, 3016 and 3024 only (2 ASt mice). In 32 of the 34 imaging files the same check finds lags of 0.2 to 4 s with a spread of 2.5 to 14 px, as expected from a port LED preceding the nose; the exceptions are C6-J588, whose nose stays near the port most of the session, and the J933 copy dropped below. The Open Ephys behavior is not used with the spikes or the cues.
- Imaging. Frame interval 1/15 s in every file; the Methods say 15 frames/s downsampled by two. ROI counts are 2.4 to 4.0 times the paper's neuron counts: the files hold every CNMF-E ROI, and the paper's manual curation is not recorded. Each session has 30 imaged clips (31 in the DISC6+TONES sessions, 22 in the truncated G4B2-C8-6860), covering 15 CS-shock and 15 CS-reward events (17 to 19 CS-reward in the DISC6+TONES sessions). The Methods say every shock trial and every other reward trial were imaged, which would be about 22 of the 45 CS-reward trials; the files hold 15. Every event a clip covers to 1 s after onset is covered to 10 s, except one CS-reward event of G4B2-C8-6860, so the 10 s requirement drops no trial elsewhere.
fig2-recorded-neurons (link)¶
The dandiset holds the electrophysiology units the paper analyses, with the counts per region and group it reports.
Counts of units below 50 Hz (Open Ephys: spike count over recording span; Neuropixels: the
firing_rate column), by the region and group the files give.
rows = []
for d in OE:
rows.append({"mouse": d["subject_id"], "system": "OE", "group": "paired (assumed)", "region": d["region"], "units<50Hz": len(d["units"]), "has events": True})
npx = INV[INV.kind == "neuropixels"]
for _, r in npx.iterrows():
rows.append({"mouse": r["file"].split("_ses")[0], "system": "NPX", "group": "unpaired" if "unpaired" in r["subject_description"] else "paired",
"region": r["electrode_locations"], "units<50Hz": r["units_below_50Hz"], "has events": bool(r["trials"])})
U = pd.DataFrame(rows); print(U.to_string())
def cnt(q):
s = U.query(q); return int(s["units<50Hz"].sum()), len(s)
res = {"paired ASt": cnt("group != 'unpaired' and region in ['ASt']"), "paired TS": (0, 0),
"paired CeA": cnt("region == 'CeA'"), "unpaired ASt": cnt("group == 'unpaired'")}
exp = {"paired ASt": (193, 15), "paired TS": (212, 7), "paired CeA": (145, 8), "unpaired ASt": (71, 4)}
for k in res:
print(f"{k}: dataset {res[k][0]} units in {res[k][1]} mice; paper {exp[k][0]} neurons in {exp[k][1]} mice")
ev = {k: cnt(q + " and `has events` == True") for k, q in [("paired ASt", "group != 'unpaired' and region in ['ASt']"), ("paired CeA", "region == 'CeA'"), ("unpaired ASt", "group == 'unpaired'")]}
print("usable with trial events:", ev)
gd = INV[INV.kind == "neuropixels"].assign(grp=lambda x: np.where(x.subject_description.str.contains("unpaired"), "unpaired", "paired"))
print("variant, Neuropixels units labeled 'good' below 50 Hz (the files' label column):",
gd.groupby(["grp", "electrode_locations"]).good_units_below_50Hz.agg(["sum", "size"]).rename(columns={"sum": "units", "size": "mice"}).to_dict("index"))
mouse system group region units<50Hz has events
0 3012_20180810_innerpeaceDiscD4 OE paired (assumed) CeA 9.0 True
1 3014_20180626_illidanDiscD4 OE paired (assumed) ASt 5.0 True
2 3016_20180810_donkeyDiscD4 OE paired (assumed) ASt 14.0 True
3 3024_20180810_ishmaelDiscD4 OE paired (assumed) ASt 18.0 True
4 3026_20181129_dengDiscD3 OE paired (assumed) ASt 12.0 True
5 3029_20181128_iouxioDiscD2 OE paired (assumed) ASt 5.0 True
6 6197_20190718_daijobuDiscD4 OE paired (assumed) ASt 11.0 True
7 6253_20190913_daisyDISCD3 OE paired (assumed) ASt 5.0 True
8 6429_20191016_durianDiscD5 OE paired (assumed) ASt 6.0 True
9 7001_20190718_ichimokuDiscD4 OE paired (assumed) CeA 13.0 True
10 7008_20190718_ikariDiscD4 OE paired (assumed) ASt 19.0 True
11 7049_20190914_ivyDiscD4 OE paired (assumed) ASt 17.0 True
12 sub-Ast-NPX-03 NPX paired ASt 249.0 False
13 sub-Ast-NPX-04 NPX paired ASt 130.0 False
14 sub-Ast-NPX-05 NPX paired ASt 217.0 False
15 sub-Ast-NPX-06 NPX unpaired ASt 218.0 False
16 sub-Ast-NPX-07 NPX unpaired ASt 87.0 False
17 sub-Ast-NPX-08 NPX paired ASt 503.0 False
18 sub-Ast-NPX-09 NPX paired ASt 304.0 False
19 sub-Ast-NPX-10 NPX unpaired ASt 241.0 False
20 sub-Ast-NPX-11 NPX unpaired ASt 87.0 False
21 sub-CeA-NPX-01 NPX paired CeA 138.0 False
22 sub-CeA-NPX-02 NPX paired CeA 235.0 False
23 sub-CeA-NPX-04 NPX paired CeA 154.0 False
24 sub-CeA-NPX-05 NPX paired CeA 336.0 False
paired ASt: dataset 1515 units in 15 mice; paper 193 neurons in 15 mice
paired TS: dataset 0 units in 0 mice; paper 212 neurons in 7 mice
paired CeA: dataset 885 units in 6 mice; paper 145 neurons in 8 mice
unpaired ASt: dataset 633 units in 4 mice; paper 71 neurons in 4 mice
usable with trial events: {'paired ASt': (112, 10), 'paired CeA': (22, 2), 'unpaired ASt': (0, 0)}
variant, Neuropixels units labeled 'good' below 50 Hz (the files' label column): {('paired', 'ASt'): {'units': 574.0, 'mice': 5}, ('paired', 'CeA'): {'units': 155.0, 'mice': 4}, ('unpaired', 'ASt'): {'units': 410.0, 'mice': 4}}
Result: not reproduced. No neuron count matches. The files give 1515 paired "ASt" units in 15 mice against the paper's 193, because each Neuropixels probe's units carry no region; no unit is labeled TS (paper 212 in 7 mice); 885 CeA units in 6 mice against 145 in 8; 633 unpaired units in 4 mice against 71. The paired ASt and unpaired mouse counts (15 and 4) match. Keeping only the Neuropixels units labeled good gives 574 paired ASt units (686 with the 112 Open Ephys units) against 193, 155 CeA (177 with Open Ephys) against 145, and 410 unpaired against 71, so the label column does not recover the paper's selection either. Only the Open Ephys sessions have trial events: 112 paired ASt units in 10 mice and 22 CeA units in 2 mice. The claims below that need paired ASt units are tested on those 10 mice; those that need TS, CeA or unpaired units are blocked.
figs9-sustained-only-cs-shock¶
Sustained ASt responses occur to CS-shock but not to CS-reward, including CS-reward trials in which the reward was not collected for at least 2 s; phasic responses do not differ.
Paired ASt units of the 10 Open Ephys mice (5 of the paper's 15 paired ASt mice are Neuropixels mice without events). Port latency has two readings: the tone duration, as the Methods say "Collection of the reward prior to the end of the tone resulted in termination of the tone" (adopted: the claim's statement is about trials "in which the reward was not collected for at least 2 s"), and the first port entry at or after CS-reward onset, which misses collections by a mouse already in the port at onset (data check). The slow group is each neuron's z from the CS-reward trials with latency over 2 s, in mice that have such trials. Readings: bin 100 ms or 10 ms; the 1 s and 2 s timepoints as (a) the bin at 1 s and 2 s, (b) the mean from 0.1 s to 1 s and to 2 s.
def figs9(width, lat_key):
G = {"CS-shock": [], "CS-reward": [], "CS-reward latency>2s": []}; mice = 0; neurons = 0; per_mouse = []
for d in AST:
slow = d["reward_on"][d[lat_key] > 2]
if len(slow): mice += 1; neurons += len(d["units"])
for s in d["units"]:
for k, on in [("CS-shock", d["shock_on"]), ("CS-reward", d["reward_on"]), ("CS-reward latency>2s", slow)]:
if len(on) == 0: continue
z, c = M.cue_z(s, on, width)
b1 = z[np.argmin(abs(c - 1.0 + width / 2))]; b2 = z[np.argmin(abs(c - 2.0 + width / 2))]
G[k].append([M.window_mean(z, c, M.PHASIC), b1, b2, M.window_mean(z, c, (0.1, 1)), M.window_mean(z, c, (0.1, 2)), d["subject_id"][:12]])
per_mouse.append((d["subject_id"][:12], len(d["units"]), int((d[lat_key] > 2).sum())))
return G, mice, neurons, per_mouse
FIGS9 = {}
for (lat_key, lname), width in [(k, w) for k in [("latency_tone", "tone duration"), ("latency", "first port entry")] for w in [0.1, 0.01]]:
G, mice, neurons, per_mouse = figs9(width, lat_key)
print(f"latency as {lname}, bin {width*1000:.0f} ms: mice with latency>2 s trials {mice}, neurons {neurons} (paper 9 mice, 96 neurons)")
if width == 0.1: print(" per mouse (units, slow trials):", per_mouse)
for j, name in enumerate(["phasic 0-0.1 s", "(a) bin at 1 s", "(a) bin at 2 s", "(b) mean 0.1-1 s", "(b) mean 0.1-2 s"]):
g = [np.array([r[j] for r in G[k]], float) for k in G]
F, p = ss.f_oneway(*g); dfw = sum(len(x) for x in g) - 3
line = f" {name}: means " + ", ".join(f"{k} {x.mean():.2f}" for k, x in zip(G, g)) + f"; F(2,{dfw}) = {F:.2f}, p = {p:.2g}"
if j > 0:
tk = pairwise_tukeyhsd(np.concatenate(g), np.repeat(list(G), [len(x) for x in g]))
line += "; Tukey " + "; ".join(f"{a} vs {b} diff {m:.2f} p {pp:.3g}" for (a, b), m, pp in zip(
[(tk.groupsunique[i], tk.groupsunique[k]) for i, k in zip(*tk._multicomp.pairindices)], tk.meandiffs, tk.pvalues))
print(line)
FIGS9[(lname, width, name)] = (F, p)
# by mouse, sustained mean 0.1-2 s
if width == 0.1 and lat_key == "latency_tone":
bym = pd.DataFrame([(r[5], k, r[4]) for k in G for r in G[k]], columns=["mouse", "group", "z"]).groupby(["mouse", "group"]).z.mean().unstack().round(2)
print(" mean z 0.1-2 s by mouse:\n", bym.to_string())
latency as tone duration, bin 100 ms: mice with latency>2 s trials 10, neurons 112 (paper 9 mice, 96 neurons)
per mouse (units, slow trials): [('3014_2018062', 5, 86), ('3016_2018081', 14, 40), ('3024_2018081', 18, 75), ('3026_2018112', 12, 54), ('3029_2018112', 5, 74), ('6197_2019071', 11, 35), ('6253_2019091', 5, 49), ('6429_2019101', 6, 55), ('7008_2019071', 19, 52), ('7049_2019091', 17, 26)]
phasic 0-0.1 s: means CS-shock 5.94, CS-reward 7.09, CS-reward latency>2s 5.47; F(2,333) = 0.98, p = 0.38
(a) bin at 1 s: means CS-shock 2.25, CS-reward 0.11, CS-reward latency>2s -0.10; F(2,333) = 19.56, p = 9.3e-09; Tukey CS-reward vs CS-reward latency>2s diff -0.21 p 0.87; CS-reward vs CS-shock diff 2.15 p 1.36e-06; CS-reward latency>2s vs CS-shock diff 2.36 p 1.03e-07
(a) bin at 2 s: means CS-shock 2.96, CS-reward 0.46, CS-reward latency>2s 0.55; F(2,333) = 12.89, p = 4.1e-06; Tukey CS-reward vs CS-reward latency>2s diff 0.09 p 0.987; CS-reward vs CS-shock diff 2.49 p 3.15e-05; CS-reward latency>2s vs CS-shock diff 2.41 p 6.18e-05 (b) mean 0.1-1 s: means CS-shock 2.27, CS-reward 0.28, CS-reward latency>2s 0.19; F(2,333) = 17.04, p = 9e-08; Tukey CS-reward vs CS-reward latency>2s diff -0.10 p 0.968; CS-reward vs CS-shock diff 1.99 p 3.87e-06; CS-reward latency>2s vs CS-shock diff 2.09 p 1.2e-06
(b) mean 0.1-2 s: means CS-shock 2.36, CS-reward 0.30, CS-reward latency>2s 0.16; F(2,333) = 18.10, p = 3.5e-08; Tukey CS-reward vs CS-reward latency>2s diff -0.14 p 0.938; CS-reward vs CS-shock diff 2.06 p 2.38e-06; CS-reward latency>2s vs CS-shock diff 2.20 p 4.4e-07 mean z 0.1-2 s by mouse: group CS-reward CS-reward latency>2s CS-shock mouse 3014_2018062 0.20 0.20 0.61 3016_2018081 -0.20 0.04 5.59 3024_2018081 0.60 0.60 7.88 3026_2018112 -0.03 -0.05 -0.06 3029_2018112 -0.78 -0.79 0.76 6197_2019071 -0.41 -0.24 0.53 6253_2019091 0.24 -0.08 0.90 6429_2019101 1.44 1.34 -0.61 7008_2019071 1.59 0.47 -0.04 7049_2019091 -0.41 -0.24 1.91
latency as tone duration, bin 10 ms: mice with latency>2 s trials 10, neurons 112 (paper 9 mice, 96 neurons) phasic 0-0.1 s: means CS-shock 2.05, CS-reward 2.56, CS-reward latency>2s 1.97; F(2,333) = 1.09, p = 0.34 (a) bin at 1 s: means CS-shock 0.75, CS-reward 0.07, CS-reward latency>2s 0.10; F(2,333) = 7.28, p = 0.00081; Tukey CS-reward vs CS-reward latency>2s diff 0.03 p 0.986; CS-reward vs CS-shock diff 0.68 p 0.00233; CS-reward latency>2s vs CS-shock diff 0.65 p 0.004
(a) bin at 2 s: means CS-shock 0.89, CS-reward 0.12, CS-reward latency>2s 0.17; F(2,333) = 6.75, p = 0.0013; Tukey CS-reward vs CS-reward latency>2s diff 0.05 p 0.97; CS-reward vs CS-shock diff 0.77 p 0.00314; CS-reward latency>2s vs CS-shock diff 0.72 p 0.00674 (b) mean 0.1-1 s: means CS-shock 0.79, CS-reward 0.11, CS-reward latency>2s 0.07; F(2,333) = 16.01, p = 2.3e-07; Tukey CS-reward vs CS-reward latency>2s diff -0.04 p 0.967; CS-reward vs CS-shock diff 0.68 p 8.16e-06; CS-reward latency>2s vs CS-shock diff 0.72 p 2.52e-06
(b) mean 0.1-2 s: means CS-shock 0.83, CS-reward 0.12, CS-reward latency>2s 0.06; F(2,333) = 16.79, p = 1.1e-07; Tukey CS-reward vs CS-reward latency>2s diff -0.06 p 0.899; CS-reward vs CS-shock diff 0.70 p 7.67e-06; CS-reward latency>2s vs CS-shock diff 0.77 p 9.24e-07
latency as first port entry, bin 100 ms: mice with latency>2 s trials 10, neurons 112 (paper 9 mice, 96 neurons)
per mouse (units, slow trials): [('3014_2018062', 5, 85), ('3016_2018081', 14, 22), ('3024_2018081', 18, 65), ('3026_2018112', 12, 55), ('3029_2018112', 5, 72), ('6197_2019071', 11, 32), ('6253_2019091', 5, 49), ('6429_2019101', 6, 51), ('7008_2019071', 19, 45), ('7049_2019091', 17, 27)]
phasic 0-0.1 s: means CS-shock 5.94, CS-reward 7.09, CS-reward latency>2s 5.14; F(2,333) = 1.42, p = 0.24
(a) bin at 1 s: means CS-shock 2.25, CS-reward 0.11, CS-reward latency>2s -0.02; F(2,333) = 18.79, p = 1.9e-08; Tukey CS-reward vs CS-reward latency>2s diff -0.13 p 0.951; CS-reward vs CS-shock diff 2.15 p 1.33e-06; CS-reward latency>2s vs CS-shock diff 2.27 p 2.88e-07
(a) bin at 2 s: means CS-shock 2.96, CS-reward 0.46, CS-reward latency>2s 0.39; F(2,333) = 15.42, p = 4e-07; Tukey CS-reward vs CS-reward latency>2s diff -0.07 p 0.989; CS-reward vs CS-shock diff 2.49 p 9.58e-06; CS-reward latency>2s vs CS-shock diff 2.57 p 4.99e-06 (b) mean 0.1-1 s: means CS-shock 2.27, CS-reward 0.28, CS-reward latency>2s 0.30; F(2,333) = 16.24, p = 1.9e-07; Tukey CS-reward vs CS-reward latency>2s diff 0.01 p 1; CS-reward vs CS-shock diff 1.99 p 3.55e-06; CS-reward latency>2s vs CS-shock diff 1.98 p 4.05e-06
(b) mean 0.1-2 s: means CS-shock 2.36, CS-reward 0.30, CS-reward latency>2s 0.24; F(2,333) = 17.71, p = 4.9e-08; Tukey CS-reward vs CS-reward latency>2s diff -0.06 p 0.987; CS-reward vs CS-shock diff 2.06 p 1.92e-06; CS-reward latency>2s vs CS-shock diff 2.13 p 9.09e-07
latency as first port entry, bin 10 ms: mice with latency>2 s trials 10, neurons 112 (paper 9 mice, 96 neurons) phasic 0-0.1 s: means CS-shock 2.05, CS-reward 2.56, CS-reward latency>2s 1.85; F(2,333) = 1.49, p = 0.23 (a) bin at 1 s: means CS-shock 0.75, CS-reward 0.07, CS-reward latency>2s 0.12; F(2,333) = 7.13, p = 0.00093; Tukey CS-reward vs CS-reward latency>2s diff 0.05 p 0.96; CS-reward vs CS-shock diff 0.68 p 0.00219; CS-reward latency>2s vs CS-shock diff 0.62 p 0.00549
(a) bin at 2 s: means CS-shock 0.89, CS-reward 0.12, CS-reward latency>2s 0.11; F(2,333) = 8.69, p = 0.00021; Tukey CS-reward vs CS-reward latency>2s diff -0.00 p 1; CS-reward vs CS-shock diff 0.77 p 0.00107; CS-reward latency>2s vs CS-shock diff 0.78 p 0.000987 (b) mean 0.1-1 s: means CS-shock 0.79, CS-reward 0.11, CS-reward latency>2s 0.12; F(2,333) = 14.85, p = 6.7e-07; Tukey CS-reward vs CS-reward latency>2s diff 0.01 p 0.996; CS-reward vs CS-shock diff 0.68 p 8.62e-06; CS-reward latency>2s vs CS-shock diff 0.67 p 1.26e-05
(b) mean 0.1-2 s: means CS-shock 0.83, CS-reward 0.12, CS-reward latency>2s 0.09; F(2,333) = 16.14, p = 2e-07; Tukey CS-reward vs CS-reward latency>2s diff -0.03 p 0.979; CS-reward vs CS-shock diff 0.70 p 6.59e-06; CS-reward latency>2s vs CS-shock diff 0.73 p 2.57e-06
Result: partially reproduced. With the port latency taken as the tone duration (adopted), under both bin sizes the phasic ANOVA is not significant (p 0.38 and 0.34). Under reading (b) of the timepoints every sustained ANOVA gives p < 0.001 (9.0e-8 to 3.5e-8 at 100 ms, 2.3e-7 and 1.1e-7 at 10 ms), and Tukey's test puts CS-shock above both CS-reward groups (p < 2e-5), while the two CS-reward groups do not differ (p > 0.89). Under reading (a) the 10 ms bin at 2 s gives p = 0.0013, so reading (b) is the one that meets the criterion at both bin sizes; at 100 ms both readings do. The first-entry latency gives the same (phasic p 0.24 and 0.23, sustained p < 0.001 in all eight). The slow-trial group does not match the paper's: every one of the 10 mice has CS-reward trials over 2 s (26 to 86 per mouse; expected 9 mice, within tolerance), giving 112 neurons against 96 from only 10 of the 15 mice, so the paper's selection of these trials must differ.
figs10-no-reward-relationship¶
ASt responses to CS-reward are not related to reward behavior, across mice or across trials grouped by port latency.
A claim of absence, judged on the paper's two tests at p < 0.05. The across-mice test is a one-way ANOVA over unpaired, low-reward and high-reward mice; no unpaired mouse has trial events, so it cannot be run (a paired-only comparison of low and high mice is shown as a variant). The across-trials test is run as the criterion gives it: each paired ASt mouse's CS-reward trials split into quartiles by port latency (Q1 the fastest), per neuron the phasic z (0 to 100 ms) from the trials of each quartile, and a repeated measures ANOVA over quartiles with neurons as subjects. Port latency has two readings: the tone duration (the Methods say collecting the reward ends the tone, so the tone stops at collection; adopted) and the first port entry at or after onset. Both bin sizes are run.
from statsmodels.stats.anova import AnovaRM
def latency_quartiles(lat_key, width):
rows = []
for d in AST:
lat = d[lat_key]; ok = np.isfinite(lat); on = d["reward_on"][ok]
q = pd.qcut(pd.Series(lat[ok]).rank(method="first"), 4, labels=False).values + 1
for u, s in enumerate(d["units"]):
for k in range(1, 5):
z, c = M.cue_z(s, on[q == k], width)
rows.append((d["subject_id"][:12], f"{d['subject_id'][:4]}-{u}", k, M.window_mean(z, c, M.PHASIC)))
df = pd.DataFrame(rows, columns=["mouse", "neuron", "quartile", "z"])
bad = df.groupby("neuron").z.apply(lambda v: v.isna().any())
return df[~df.neuron.isin(bad[bad].index)], int(bad.sum())
FIGS10 = {}
for lat_key, lname in [("latency_tone", "tone duration"), ("latency", "first port entry")]:
for width in [0.1, 0.01]:
df, dropped = latency_quartiles(lat_key, width)
a = AnovaRM(df, "z", "neuron", within=["quartile"]).fit().anova_table.iloc[0]
FIGS10[(lname, width)] = a["Pr > F"]
print(f"latency as {lname}, bin {width*1000:.0f} ms: neurons {df.neuron.nunique()} (dropped, no baseline variance in a quartile: {dropped}); "
f"mean phasic z Q1-Q4 {df.groupby('quartile').z.mean().round(2).tolist()}; F({a['Num DF']:.0f},{a['Den DF']:.0f}) = {a['F Value']:.2f}, p = {a['Pr > F']:.3g}")
if lat_key == "latency_tone" and width == 0.1:
print(" mean phasic z by mouse and quartile:\n", df.groupby(["mouse", "quartile"]).z.mean().unstack().round(2).to_string())
# Variant for the across-mice test, paired mice only: two clusters by mean latency (tone duration), mouse mean phasic CS-reward z.
mm = pd.DataFrame([{"mouse": d["subject_id"][:12], "mean latency s": d["latency_tone"].mean(),
"phasic z": np.nanmean([M.window_mean(*M.cue_z(s, d["reward_on"], 0.1), M.PHASIC) for s in d["units"]])} for d in AST])
for meth in ["average", "ward"]:
lab = fcluster(linkage(mm[["mean latency s"]].values, meth), 2, "maxclust")
lo = lab == lab[np.argmin(mm["mean latency s"].values)]
t = ss.ttest_ind(mm["phasic z"][lo], mm["phasic z"][~lo])
print(f"variant, {meth} linkage: low-latency mice {int(lo.sum())}, high-latency {int((~lo).sum())}; phasic z {mm['phasic z'][lo].mean():.2f} against {mm['phasic z'][~lo].mean():.2f}, t = {t.statistic:.2f}, p = {t.pvalue:.3g}")
print(mm.round(2).to_string())
latency as tone duration, bin 100 ms: neurons 111 (dropped, no baseline variance in a quartile: 1); mean phasic z Q1-Q4 [3.42, 3.73, 3.54, 4.06]; F(3,330) = 1.81, p = 0.144 mean phasic z by mouse and quartile: quartile 1 2 3 4 mouse 3014_2018062 0.10 0.65 0.75 0.42 3016_2018081 5.11 3.75 4.47 5.33 3024_2018081 5.82 7.24 5.28 8.46 3026_2018112 -0.45 0.55 0.14 0.02 3029_2018112 0.56 0.58 1.02 0.31 6197_2019071 2.73 3.64 4.26 3.46 6253_2019091 3.59 3.91 1.67 2.60 6429_2019101 3.09 2.98 2.86 2.54 7008_2019071 3.39 2.95 3.99 4.18 7049_2019091 4.64 5.32 4.82 4.64
latency as tone duration, bin 10 ms: neurons 111 (dropped, no baseline variance in a quartile: 1); mean phasic z Q1-Q4 [1.21, 1.31, 1.24, 1.47]; F(3,330) = 2.68, p = 0.0472
latency as first port entry, bin 100 ms: neurons 111 (dropped, no baseline variance in a quartile: 1); mean phasic z Q1-Q4 [3.39, 3.86, 3.52, 3.95]; F(3,330) = 1.62, p = 0.185
latency as first port entry, bin 10 ms: neurons 111 (dropped, no baseline variance in a quartile: 1); mean phasic z Q1-Q4 [1.21, 1.35, 1.24, 1.42]; F(3,330) = 1.64, p = 0.18
variant, average linkage: low-latency mice 7, high-latency 3; phasic z 6.34 against 4.71, t = 0.55, p = 0.596
variant, ward linkage: low-latency mice 7, high-latency 3; phasic z 6.34 against 4.71, t = 0.55, p = 0.596
mouse mean latency s phasic z
0 3014_2018062 9.45 0.96
1 3016_2018081 2.27 9.05
2 3024_2018081 8.97 13.04
3 3026_2018112 6.70 0.12
4 3029_2018112 4.78 1.25
5 6197_2019071 2.25 6.54
6 6253_2019091 2.84 5.62
7 6429_2019101 3.99 5.96
8 7008_2019071 3.55 6.88
9 7049_2019091 2.71 9.04
Result: partially reproduced. The across-trials test can be run and mostly finds no relationship: with the tone-duration latency and 100 ms bins, the repeated measures ANOVA of phasic CS-reward z over latency quartiles gives F(3,330) = 1.81, p = 0.14 (111 neurons, 1 dropped), and with the first-entry latency p = 0.185 and 0.18 at 100 and 10 ms. With the tone-duration latency and 10 ms bins it gives p = 0.047, just below 0.05, with the slowest quartile highest (1.47 against 1.21 to 1.31). The across-mice test needs the unpaired mice and cannot be run; among the paired mice, the low-latency and high-latency clusters (7 and 3 mice, both linkages) do not differ (p = 0.60). The claim holds in part: one of its two tests cannot be run, and the other is not significant under three of four readings.
fig2o-region-differs-cs-reward¶
Responses to CS-reward also differ between regions, and the ASt has robust phasic responses to CS-reward as well as to CS-shock.
The region ANOVAs need TS units, which no file labels, and the CeA units with trial events are 22 from 2 of the paper's 8 CeA mice; they are not run as the paper's test. The ASt part is run: the one-sample t-test of the ASt phasic CS-reward z against 0 (the criterion's choice), under both bin sizes, on the 112 paired ASt units. For the record, the ASt against CeA comparison is printed. The same per-neuron table (z per CS and window, and the responsive class under both readings of the signed-rank inputs) serves the blocked claims fig2o-ast-greater-cs-shock-responses and fig2p-ast-more-responsive at the end.
def trial_rates(s, on, win):
return np.array([((s >= o + win[0]) & (s < o + win[1])).sum() / (win[1] - win[0]) for o in on])
def response_class(s, on, win, z, reading):
"""Opening comment of the claims file: signed-rank test at 0.01 and mean z above +2 or below -2.
Reading (a) against the same trial's 20 s baseline, (b) against an equal-length window before onset."""
r = trial_rates(s, on, win)
b = trial_rates(s, on, (-20, 0) if reading == "a" else (-(win[1] - win[0]), 0))
p = 1.0 if np.all(r == b) else ss.wilcoxon(r, b).pvalue
return 1 if (p < 0.01 and z > 2) else (-1 if (p < 0.01 and z < -2) else 0)
rows = []
for width in [0.1, 0.01]:
for d in OE:
for u, s in enumerate(d["units"]):
r = {"width": width, "region": d["region"], "mouse": d["subject_id"][:12], "unit": u}
for cs, on in [("shock", d["shock_on"]), ("reward", d["reward_on"])]:
z, c = M.cue_z(s, on, width)
for wn, win in [("phasic", M.PHASIC), ("sustained", M.SUSTAINED)]:
r[f"{cs} {wn}"] = zz = M.window_mean(z, c, win)
for rd in "ab":
r[f"{cs} {wn} class {rd}"] = response_class(s, on, win, zz, rd)
rows.append(r)
R2O = pd.DataFrame(rows)
for width in [0.1, 0.01]:
g = R2O[R2O.width == width]
a = g[g.region == "ASt"]["reward phasic"].dropna(); t = ss.ttest_1samp(a, 0)
print(f"bin {width*1000:.0f} ms: ASt phasic CS-reward z mean {a.mean():.2f} (n {len(a)}, range {a.min():.1f} to {a.max():.1f}), one-sample t({len(a)-1}) = {t.statistic:.2f}, p = {t.pvalue:.2g}")
print(" by mouse:", g[g.region == "ASt"].groupby("mouse")["reward phasic"].mean().round(2).to_dict())
for col in ["reward phasic", "reward sustained"]:
x, y = g[g.region == "ASt"][col].dropna(), g[g.region == "CeA"][col].dropna(); tt = ss.ttest_ind(x, y)
print(f" for the record, ASt against CeA, CS-{col}: {x.mean():.2f} (n {len(x)}) against {y.mean():.2f} (n {len(y)}), F(1,{len(x)+len(y)-2}) = {tt.statistic**2:.2f}, p = {tt.pvalue:.2g}")
bin 100 ms: ASt phasic CS-reward z mean 7.09 (n 112, range -4.3 to 58.2), one-sample t(111) = 7.79, p = 3.9e-12
by mouse: {'3014_2018062': 0.96, '3016_2018081': 9.05, '3024_2018081': 13.04, '3026_2018112': 0.12, '3029_2018112': 1.25, '6197_2019071': 6.54, '6253_2019091': 5.62, '6429_2019101': 5.96, '7008_2019071': 6.88, '7049_2019091': 9.04}
for the record, ASt against CeA, CS-reward phasic: 7.09 (n 112) against 3.06 (n 22), F(1,132) = 3.58, p = 0.061
for the record, ASt against CeA, CS-reward sustained: 0.50 (n 112) against -0.24 (n 22), F(1,132) = 1.65, p = 0.2
bin 10 ms: ASt phasic CS-reward z mean 2.56 (n 112, range -1.6 to 18.7), one-sample t(111) = 7.66, p = 7.4e-12
by mouse: {'3014_2018062': 0.3, '3016_2018081': 3.12, '3024_2018081': 4.72, '3026_2018112': 0.04, '3029_2018112': 0.38, '6197_2019071': 2.49, '6253_2019091': 1.92, '6429_2019101': 2.41, '7008_2019071': 2.79, '7049_2019091': 2.91}
for the record, ASt against CeA, CS-reward phasic: 2.56 (n 112) against 0.95 (n 22), F(1,132) = 4.33, p = 0.039
for the record, ASt against CeA, CS-reward sustained: 0.22 (n 112) against -0.07 (n 22), F(1,132) = 1.22, p = 0.27
Result: partially reproduced. The ASt part holds: the ASt phasic CS-reward z is above 0 (mean 7.09, t(111) = 7.79, p = 3.9e-12 at 100 ms; 2.56, p = 7.4e-12 at 10 ms), in all 10 mice (mouse means 0.12 to 13.04). The region part cannot be run as the paper's test: there are no TS units and 22 CeA units from 2 of the 8 CeA mice. For the record, ASt against CeA gives p = 0.061 and 0.039 for the phasic and 0.20 and 0.27 for the sustained CS-reward z (100 and 10 ms), none near the criterion's p < 0.0001.
fig2q-trajectories-diverge¶
ASt population trajectories for CS-shock and CS-reward diverge from cue onset.
Code's procedure (trajectories_rev_2025.py): 100 ms bins, -20 to 40 s; each neuron z-scored over all its trials and bins; averaged per CS; neurons of all paired Open Ephys ASt mice stacked. The Methods' reading fits one PCA on paired and unpaired animals; no unpaired animal has events, so the PCA is fitted on the paired animals. In the complete PC space the PCA is a rotation of the centred neuron space, so the distance between the paired trajectories is the same whatever rows the PCA is fitted on: the complete-space value is the Methods' reading as well as the code's. The distance in the components that explain 90% of variance (code) depends on the fit.
W = 0.1; Ms, Mr = [], []
for d in AST:
for s in d["units"]:
cs, c = M.binned(s, d["shock_on"], -20, 40, W); cr, _ = M.binned(s, d["reward_on"], -20, 40, W)
a = np.concatenate([cs, cr]); mu, sd = a.mean(), a.std()
if sd == 0: continue
Ms.append(((cs - mu) / sd).mean(0)); Mr.append(((cr - mu) / sd).mean(0))
Ms, Mr = np.array(Ms), np.array(Mr)
pca = PCA().fit(np.concatenate([Ms.T, Mr.T])); Ps, Pr = pca.transform(Ms.T), pca.transform(Mr.T)
k90 = int(np.searchsorted(np.cumsum(pca.explained_variance_ratio_), 0.9) + 1)
for name, dist in [("complete PC space", np.linalg.norm(Ps - Pr, axis=1)), (f"first {k90} PCs (90% variance)", np.linalg.norm(Ps[:, :k90] - Pr[:, :k90], axis=1))]:
print(f"{name}: neurons {Ms.shape[0]}; mean distance 0-18 s {dist[(c > 0) & (c < 18)].mean():.2f}; "
f"baseline -20-0 s max {dist[c < 0].max():.2f}, mean {dist[c < 0].mean():.2f}; distance range {dist.min():.2f} to {dist.max():.2f}")
# by mouse, complete space (each mouse's own neurons)
i0 = 0
for d in AST:
n = len(d["units"]); A_, B_ = Ms[i0:i0 + n], Mr[i0:i0 + n]; i0 += n
dd = np.linalg.norm(A_ - B_, axis=0)
print(f" {d['subject_id'][:12]}: {n} neurons, cue mean {dd[(c > 0) & (c < 18)].mean():.2f}, baseline max {dd[c < 0].max():.2f}")
fig, ax = plt.subplots(figsize=(6, 3)); ax.plot(c, np.linalg.norm(Ps - Pr, axis=1)); ax.axvline(0, color="k", lw=0.5)
ax.set_xlabel("time from CS onset (s)"); ax.set_ylabel("shock-reward distance"); plt.show()
complete PC space: neurons 112; mean distance 0-18 s 7.36; baseline -20-0 s max 2.87, mean 2.05; distance range 1.62 to 24.76 first 41 PCs (90% variance): neurons 112; mean distance 0-18 s 7.16; baseline -20-0 s max 1.94, mean 1.42; distance range 0.96 to 24.72 3014_2018062: 5 neurons, cue mean 0.47, baseline max 1.16 3016_2018081: 14 neurons, cue mean 3.56, baseline max 1.14 3024_2018081: 18 neurons, cue mean 5.33, baseline max 1.50 3026_2018112: 12 neurons, cue mean 0.68, baseline max 1.25 3029_2018112: 5 neurons, cue mean 0.60, baseline max 0.92 6197_2019071: 11 neurons, cue mean 0.93, baseline max 1.25 6253_2019091: 5 neurons, cue mean 0.65, baseline max 1.28 6429_2019101: 6 neurons, cue mean 0.69, baseline max 0.82 7008_2019071: 19 neurons, cue mean 2.04, baseline max 1.63 7049_2019091: 17 neurons, cue mean 1.98, baseline max 2.02
Result: reproduced. In the complete PC space the mean CS-shock to CS-reward distance over 0 to 18 s is 7.36, above the largest baseline distance, 2.87; in the 41 components that explain 90% of the variance it is 7.16 against 1.94. Within single mice the cue mean exceeds the baseline maximum in 3 of the 10 (3016, 3024 and 7008); the claim, like the paper's figure, is on the stacked population. The complete-space distance does not depend on whether the PCA is fitted with or without unpaired animals, so it is the Methods' reading; the 90% variant is fitted on paired mice only.
figs8-single-trial-divergence¶
In single trial pairs from paired mice, CS-shock and CS-reward population trajectories are less similar during the cue than pairs of the same CS; unpaired mice do not show this.
Methods: per animal, 100 random draws of trial pairs; each trial's population vector (100 ms bins, standard choice from the code) minus its mean over -20 to 0 s; cosine similarity per bin, averaged over 0 to 18 s. Animals with at least 10 units and 30 trials per CS (code). Readings of the Wilcoxon test: (a) per-animal means, shock-reward against the mean of the same-CS pairs; (b) against each same-CS comparison; (c) iterations pooled. Unpaired animals have no events.
def cos_animal(d, rng):
S = np.stack([M.binned(s, d["shock_on"], -20, 40, 0.1)[0] for s in d["units"]], 2) / 0.1
R = np.stack([M.binned(s, d["reward_on"], -20, 40, 0.1)[0] for s in d["units"]], 2) / 0.1
c = M.binned(d["units"][0], d["shock_on"], -20, 40, 0.1)[1]
S = S - S[:, c < 0].mean(1, keepdims=True); R = R - R[:, c < 0].mean(1, keepdims=True)
w = (c > 0) & (c < 18)
def cs(a, b):
with np.errstate(invalid="ignore", divide="ignore"):
v = (a * b).sum(1) / (np.linalg.norm(a, axis=1) * np.linalg.norm(b, axis=1))
return np.nanmean(v[w])
out = []
for _ in range(100):
i, j = rng.choice(len(S), 2, replace=False); k, l = rng.choice(len(R), 2, replace=False)
out.append((cs(S[i], S[j]), cs(R[k], R[l]), cs(S[i], R[k])))
return np.array(out)
SEL8 = [d for d in AST if len(d["units"]) >= 10 and len(d["shock_on"]) >= 30 and len(d["reward_on"]) >= 30]
print("animals:", [(d["subject_id"][:12], len(d["units"])) for d in SEL8], "(excluded for <30 CS-shock trials:",
[d["subject_id"][:12] for d in AST if len(d["units"]) >= 10 and len(d["shock_on"]) < 30], ")")
print("smallest two-sided Wilcoxon signed-rank p with", len(SEL8), "animals:", ss.wilcoxon(np.arange(1, len(SEL8) + 1), np.zeros(len(SEL8))).pvalue)
for off in [0, 1000, 2000, 3000, 4000]:
rng = np.random.default_rng(seed("figs8-single-trial-divergence", off))
res = [cos_animal(d, rng) for d in SEL8]
m = np.array([r.mean(0) for r in res]); P = np.concatenate(res)
a = ss.wilcoxon(m[:, 2], m[:, :2].mean(1)); b1 = ss.wilcoxon(m[:, 2], m[:, 0]); b2 = ss.wilcoxon(m[:, 2], m[:, 1])
cpool = ss.wilcoxon(P[:, 2], P[:, :2].mean(1))
print(f"seed +{off}: pooled means SS {P[:,0].mean():.4f} RR {P[:,1].mean():.4f} SR {P[:,2].mean():.4f}; "
f"(a) p {a.pvalue:.3g}; (b) vs SS p {b1.pvalue:.3g}, vs RR p {b2.pvalue:.3g}; (c) pooled n={len(P)} W={cpool.statistic:.0f} p {cpool.pvalue:.3g}")
if off == 0:
print(pd.DataFrame(m, columns=["SS", "RR", "SR"], index=[d["subject_id"][:12] for d in SEL8]).round(3).to_string())
animals: [('3016_2018081', 14), ('3026_2018112', 12), ('6197_2019071', 11), ('7008_2019071', 19), ('7049_2019091', 17)] (excluded for <30 CS-shock trials: ['3024_2018081'] )
smallest two-sided Wilcoxon signed-rank p with 5 animals: 0.0625
seed +0: pooled means SS 0.0735 RR 0.0657 SR -0.0089; (a) p 0.125; (b) vs SS p 0.0625, vs RR p 0.125; (c) pooled n=500 W=13181 p 8.04e-53
SS RR SR
3016_2018081 0.200 0.100 -0.042
3026_2018112 0.020 0.015 0.020
6197_2019071 0.021 0.032 -0.003
7008_2019071 0.045 0.131 0.010
7049_2019091 0.082 0.051 -0.029
seed +1000: pooled means SS 0.0778 RR 0.0702 SR -0.0064; (a) p 0.0625; (b) vs SS p 0.0625, vs RR p 0.0625; (c) pooled n=500 W=12328 p 1.35e-54
seed +2000: pooled means SS 0.0690 RR 0.0638 SR -0.0108; (a) p 0.125; (b) vs SS p 0.0625, vs RR p 0.125; (c) pooled n=500 W=14765 p 1.33e-49
seed +3000: pooled means SS 0.0723 RR 0.0681 SR -0.0073; (a) p 0.125; (b) vs SS p 0.125, vs RR p 0.125; (c) pooled n=500 W=15341 p 1.85e-48
seed +4000: pooled means SS 0.0757 RR 0.0630 SR -0.0050; (a) p 0.125; (b) vs SS p 0.0625, vs RR p 0.125; (c) pooled n=500 W=14359 p 2.03e-50
Result: partially reproduced. In the five paired animals that meet the code's selection, shock-reward similarity (pooled mean about -0.01) is below shock-shock (0.07) and reward-reward (0.07); with the iterations pooled, reading (c), p is below 1e-47 under all five seeds. Reading (c) treats the 100 resamples of the same trials as independent, so its p overstates the evidence. With five animals the per-animal readings (a) and (b) cannot reach p < 0.01: the smallest two-sided Wilcoxon p for five pairs is 0.0625, and they give p 0.06 to 0.13. The unpaired half of the claim cannot be tested: no unpaired animal has trial events.
fig3h-cs-decoded-paired-only¶
CS identity can be decoded from ASt activity above chance during the cue in paired but not unpaired mice.
The code's decoder (fig4h_decoding_workflow.py), as the criterion gives it, on the paired Open Ephys mice with more than 10 units below 50 Hz. Mann-Whitney U test of the mice's accuracies against their chance values (legend), with the code's Wilcoxon signed-rank test as a variant.
def decode(d, rng, nshuf=20):
n = min(29, len(d["shock_on"]), len(d["reward_on"]))
so = np.sort(rng.choice(d["shock_on"], n, replace=False)); ro = np.sort(rng.choice(d["reward_on"], n, replace=False))
X = np.concatenate([np.stack([M.binned(s, on, -20, 40, 0.1)[0] for s in d["units"]], 2) for on in (so, ro)])
c = M.binned(d["units"][0], so, -20, 40, 0.1)[1]
y = np.r_[np.ones(n), np.zeros(n)]; nb = X.shape[1]
acc = np.zeros(nb); ch = np.zeros(nb)
for tr, te in StratifiedKFold(5, shuffle=True, random_state=int(rng.integers(2**31))).split(np.zeros(len(y)), y):
Xtr = X[tr].reshape(-1, X.shape[2]); sc = StandardScaler().fit(Xtr); Xtr = sc.transform(Xtr)
Xte = sc.transform(X[te].reshape(-1, X.shape[2]))
m = LogisticRegression(solver="liblinear").fit(Xtr, np.repeat(y[tr], nb))
acc += (m.predict(Xte).reshape(len(te), nb) == y[te][:, None]).sum(0)
for _ in range(nshuf):
m2 = LogisticRegression(solver="liblinear").fit(Xtr, np.repeat(rng.permutation(y[tr]), nb))
ch += (m2.predict(Xte).reshape(len(te), nb) == y[te][:, None]).sum(0) / nshuf
w = (c > 0) & (c < 18)
return (acc / len(y))[w].mean(), (ch / len(y))[w].mean()
SEL3H = [d for d in AST if len(d["units"]) > 10]
print("mice:", [(d["subject_id"][:12], len(d["units"])) for d in SEL3H])
for off in [0, 1000, 2000, 3000, 4000]:
rng = np.random.default_rng(seed("fig3h-cs-decoded-paired-only", off))
r = np.array([decode(d, rng) for d in SEL3H])
mw2 = ss.mannwhitneyu(r[:, 0], r[:, 1]); mw1 = ss.mannwhitneyu(r[:, 0], r[:, 1], alternative="greater"); wx = ss.wilcoxon(r[:, 0], r[:, 1])
print(f"seed +{off}: accuracy {np.round(r[:,0],3).tolist()} chance {np.round(r[:,1],3).tolist()}; "
f"MWU U={mw2.statistic:.0f} two-sided p {mw2.pvalue:.4f}, one-sided p {mw1.pvalue:.4f}; Wilcoxon W={wx.statistic:.0f} p {wx.pvalue:.4f}")
mice: [('3016_2018081', 14), ('3024_2018081', 18), ('3026_2018112', 12), ('6197_2019071', 11), ('7008_2019071', 19), ('7049_2019091', 17)]
seed +0: accuracy [0.825, 0.892, 0.494, 0.531, 0.677, 0.702] chance [0.477, 0.476, 0.495, 0.496, 0.504, 0.505]; MWU U=32 two-sided p 0.0260, one-sided p 0.0130; Wilcoxon W=1 p 0.0625
seed +1000: accuracy [0.831, 0.895, 0.492, 0.573, 0.665, 0.686] chance [0.511, 0.521, 0.495, 0.492, 0.49, 0.502]; MWU U=32 two-sided p 0.0260, one-sided p 0.0130; Wilcoxon W=1 p 0.0625
seed +2000: accuracy [0.837, 0.886, 0.471, 0.596, 0.671, 0.685] chance [0.488, 0.51, 0.491, 0.496, 0.495, 0.503]; MWU U=30 two-sided p 0.0649, one-sided p 0.0325; Wilcoxon W=1 p 0.0625
seed +3000: accuracy [0.841, 0.884, 0.494, 0.583, 0.672, 0.693] chance [0.517, 0.507, 0.497, 0.485, 0.492, 0.49]; MWU U=33 two-sided p 0.0152, one-sided p 0.0076; Wilcoxon W=1 p 0.0625
seed +4000: accuracy [0.831, 0.885, 0.481, 0.558, 0.657, 0.704] chance [0.497, 0.528, 0.495, 0.491, 0.5, 0.483]; MWU U=30 two-sided p 0.0649, one-sided p 0.0325; Wilcoxon W=1 p 0.0625
Result: not reproduced. Accuracy over 0 to 18 s is above shuffled chance (about 0.5) in four of the six paired mice (0.66 to 0.89) and near it in two, 3026 (0.47 to 0.49 over the five seeds) and 6197 (0.53 to 0.60), against shuffled chance of 0.49 to 0.50 in both; no per-mouse test was run. The Mann-Whitney U test of accuracies against chance gives p = 0.026 two-sided under the claim's seed and 0.015 to 0.065 under the four others, never below the criterion's 0.01 (one-sided 0.008 to 0.033). The code's Wilcoxon variant gives p = 0.0625. The unpaired half cannot be tested: no unpaired mouse has trial events.
figs13-imaging-mice-discriminate¶
Paired Drd1a-Cre and Drd2-Cre mice in the imaging experiments show more defensive behavior to CS-shock than to CS-reward, and unpaired mice do not.
Per frame, freezing and darting from the poses (helper behaviour_frames; freezing rule "max",
every body point moved less than 0.08 cm, or "sum", the summed displacement below 0.08 cm;
darting when the haunch reaches 45 cm/s). The pixel scale is taken from the extent of the body
points against the 30 x 40 cm chamber (assumption). Defensive behavior per trial is the share of
the 10 s tone spent freezing plus the share spent darting; all 60 CS events of each session.
BEH13 = []
for d in DISC:
ppc = M.pixels_per_cm(d["pose"]); fps = 1 / np.median(np.diff(d["pose_t"]))
r = {"file": d["file"], "genotype": d["gen"], "group": d["grp"], "px/cm": round(ppc, 1)}
for rule in ["max", "sum"]:
frz, dart = M.behaviour_frames(d["pose"], ppc, fps=fps, freeze_rule=rule)
for typ in ["Shock", "Reward"]:
on = d["cs_on"][d["cs_type"] == typ]
r[f"{rule} {typ}"] = np.nanmean(M.window_fraction(d["pose_t"], frz, on, 10) + M.window_fraction(d["pose_t"], dart, on, 10))
BEH13.append(r)
BEH13 = pd.DataFrame(BEH13); print(BEH13.round(3).to_string())
for rule in ["max", "sum"]:
for (gen, grp), g in BEH13.groupby(["genotype", "group"]):
t = ss.ttest_rel(g[f"{rule} Shock"], g[f"{rule} Reward"])
print(f"{rule}: {gen} {grp}, n={len(g)}: CS-shock {g[f'{rule} Shock'].mean():.3f}, CS-reward {g[f'{rule} Reward'].mean():.3f}, t({len(g)-1}) = {t.statistic:.2f}, p = {t.pvalue:.4f}")
# Structure of the frame-to-frame displacement: the largest displacement over body points, in pixels.
# The freezing threshold (0.08 cm) is about 1.6 px at the inferred scale.
mx = np.concatenate([M.max_displacement_px(d["pose"]) for d in DISC]); mx = mx[np.isfinite(mx)]
print("largest point displacement per frame, all discrimination sessions, share of frames:",
{k: round(float(v), 4) for k, v in zip(["<0.25 px", "0.25-0.5", "0.5-1", "1-1.6", "1.6-2", ">2"], np.histogram(mx, [0, 0.25, 0.5, 1, 1.6, 2, np.inf])[0] / len(mx))})
print("exactly repeated poses (all points equal to the previous frame):", round(float(np.mean(mx == 0)), 4))
# Freezing and darting separately, and the median-displacement variant (not the paper's rule).
rows = []
for d in DISC:
ppc = M.pixels_per_cm(d["pose"]); fps = 1 / np.median(np.diff(d["pose_t"]))
frz, dart = M.behaviour_frames(d["pose"], ppc, fps=fps)
frz_med = M.behaviour_frames(d["pose"], ppc, fps=fps, freeze_rule="median")[0]
r = {"file": d["file"], "genotype": d["gen"], "group": d["grp"]}
for typ in ["Shock", "Reward"]:
on = d["cs_on"][d["cs_type"] == typ]
r[f"freeze {typ}"] = np.nanmean(M.window_fraction(d["pose_t"], frz, on, 10))
r[f"dart {typ}"] = np.nanmean(M.window_fraction(d["pose_t"], dart, on, 10))
r[f"median rule {typ}"] = np.nanmean(M.window_fraction(d["pose_t"], frz_med, on, 10) + M.window_fraction(d["pose_t"], dart, on, 10))
rows.append(r)
B13 = pd.DataFrame(rows)
for m in ["freeze", "dart", "median rule"]:
for (gen, grp), g in B13.groupby(["genotype", "group"]):
t = ss.ttest_rel(g[f"{m} Shock"], g[f"{m} Reward"])
print(f"{m}: {gen} {grp}, n={len(g)}: CS-shock {g[f'{m} Shock'].mean():.3f}, CS-reward {g[f'{m} Reward'].mean():.3f}, t({len(g)-1}) = {t.statistic:.2f}, p = {t.pvalue:.4f}")
file genotype group px/cm max Shock max Reward sum Shock sum Reward 0 sub-C1-J642-Disc5_ses-C1-J642-Disc5_image+oph Drd2 paired 19.7 0.095 0.003 0.094 0.003 1 sub-C3-J670-Disc5Unp_ses-C3-J670-Disc5Unp_ima Drd2 unpaired 20.3 0.013 0.016 0.013 0.016 2 sub-C6-J588-Disc5_ses-C6-J588-Disc5_image+oph Drd2 paired 19.6 0.022 0.004 0.022 0.003 3 sub-C6-J650-Disc5_ses-C6-J650-Disc5_image+oph Drd2 paired 20.1 0.047 0.003 0.047 0.002 4 sub-C8-J633-Disc5Unp_ses-C8-J633-Disc5Unp_ima Drd2 unpaired 18.8 0.013 0.012 0.013 0.011 5 sub-C8-J634-Disc5Unp_ses-C8-J634-Disc5Unp_ima Drd2 unpaired 19.7 0.019 0.022 0.019 0.022 6 sub-G1B1-C1-6868-L-quetzal-DISC6+TONES_ses-G1 Drd1a paired 20.0 0.210 0.207 0.209 0.207 7 sub-G1B1-J895-R-DISC4_ses-G1B1-J895_image+oph Drd2 paired 19.3 0.209 0.074 0.209 0.073 8 sub-G1B2-C1-6865-R-frogman-DISC5_ses-G1B2-C1- Drd1a paired 20.0 0.256 0.221 0.256 0.221 9 sub-G1B2-J904-L-DISC6_ses-G1B2-J904_image+oph Drd2 paired 19.4 0.167 0.092 0.167 0.091 10 sub-G1B3-C2-6882-R-kevin-DISC6+TONES_ses-G1B3 Drd1a paired 20.0 0.138 0.115 0.138 0.115 11 sub-G1B3-K033-R-DISC6_ses-G1B3-K033_image+oph Drd1a paired 19.4 0.088 0.091 0.087 0.090 12 sub-G1B4-C3-6921-R-nessie-DISC6+TONES_ses-G1B Drd1a paired 20.6 0.242 0.223 0.242 0.222 13 sub-G1B4-K035-R-DISC4_ses-G1B4-K035_image+oph Drd1a paired 20.1 0.281 0.238 0.281 0.238 14 sub-G2B1-C4-6886-L-jackalope-DISC6UNP+TONES_s Drd1a unpaired 19.5 0.294 0.254 0.293 0.253 15 sub-G2B1-J915-R-DISC4_ses-G2B1-J915_image+oph Drd2 unpaired 20.1 0.056 0.091 0.056 0.091 16 sub-G2B2-J917-R-DISC6_ses-G2B2-J917_image+oph Drd2 unpaired 20.7 0.111 0.126 0.111 0.125 17 sub-G2B3-C4-6885-R-cyclops-DISC6UNP+TONES_ses Drd1a unpaired 19.9 0.094 0.105 0.094 0.105 18 sub-G2B3-K036-L-DISC4_ses-G2B3-K036_image+oph Drd1a unpaired 20.1 0.132 0.047 0.132 0.047 19 sub-G2B4-K054-R-DISC5_ses-G2B4-K054_image+oph Drd1a unpaired 20.2 0.153 0.170 0.153 0.170 20 sub-G3B1-C5-6933-R-chupacabra-DISC5_ses-G3B1- Drd1a paired 19.5 0.116 0.094 0.116 0.093 21 sub-G3B2-J908-R-DISC5_ses-G3B2-J908_image+oph Drd2 paired 20.3 0.201 0.205 0.201 0.204 22 sub-G3B3-K047-L-DISC5_ses-G3B3-K047_image+oph Drd1a paired 19.6 0.134 0.049 0.134 0.049 23 sub-G3B4-C7-6915-R-mothman-DISC6+TONES_ses-G3 Drd1a paired 19.9 0.150 0.098 0.150 0.098 24 sub-G3B4-J907-R-DISC4_ses-G3B4-J907_image+oph Drd2 paired 19.5 0.382 0.460 0.382 0.460 25 sub-G4B1-K010-R-DISC4_ses-G4B1-K010_image+oph Drd1a unpaired 19.8 0.078 0.105 0.078 0.105 26 sub-G4B2-C8-6860-L-carl-DISC6UNP+TONES_ses-G4 Drd1a unpaired 20.0 0.241 0.263 0.241 0.263 27 sub-G4B2-J919-L-DISC6_ses-G4B2-J919_image+oph Drd2 unpaired 20.5 0.150 0.128 0.150 0.127 28 sub-G4B3-K029-L-DISC5_ses-G4B3-K029_image+oph Drd1a unpaired 20.2 0.047 0.102 0.047 0.102 29 sub-G4B4-C9-6891-R-mooneye-DISC7UNP+TONES_ses Drd1a unpaired 19.3 0.088 0.113 0.088 0.113 30 sub-J932-Disc6_ses-J932-Disc6_image+ophys.nwb Drd2 paired 19.4 0.253 0.161 0.253 0.160 31 sub-J933-Disc4_image+ophys.nwb Drd2 paired 19.4 0.275 0.192 0.275 0.192 32 sub-K008-Disc4_ses-K008-Disc4_image+ophys.nwb Drd1a paired 19.6 0.295 0.197 0.294 0.197 max: Drd1a paired, n=10: CS-shock 0.191, CS-reward 0.153, t(9) = 3.61, p = 0.0057 max: Drd1a unpaired, n=8: CS-shock 0.141, CS-reward 0.145, t(7) = -0.27, p = 0.7969 max: Drd2 paired, n=9: CS-shock 0.183, CS-reward 0.133, t(8) = 2.37, p = 0.0456 max: Drd2 unpaired, n=6: CS-shock 0.060, CS-reward 0.066, t(5) = -0.71, p = 0.5070 sum: Drd1a paired, n=10: CS-shock 0.191, CS-reward 0.153, t(9) = 3.64, p = 0.0054 sum: Drd1a unpaired, n=8: CS-shock 0.141, CS-reward 0.145, t(7) = -0.26, p = 0.8025 sum: Drd2 paired, n=9: CS-shock 0.183, CS-reward 0.132, t(8) = 2.38, p = 0.0449 sum: Drd2 unpaired, n=6: CS-shock 0.060, CS-reward 0.066, t(5) = -0.69, p = 0.5218
largest point displacement per frame, all discrimination sessions, share of frames: {'<0.25 px': 0.1935, '0.25-0.5': 0.0021, '0.5-1': 0.0, '1-1.6': 0.0, '1.6-2': 0.0201, '>2': 0.7842}
exactly repeated poses (all points equal to the previous frame): 0.0019
freeze: Drd1a paired, n=10: CS-shock 0.159, CS-reward 0.146, t(9) = 1.62, p = 0.1394 freeze: Drd1a unpaired, n=8: CS-shock 0.130, CS-reward 0.133, t(7) = -0.17, p = 0.8720 freeze: Drd2 paired, n=9: CS-shock 0.153, CS-reward 0.132, t(8) = 0.95, p = 0.3684 freeze: Drd2 unpaired, n=6: CS-shock 0.052, CS-reward 0.059, t(5) = -0.88, p = 0.4214 dart: Drd1a paired, n=10: CS-shock 0.032, CS-reward 0.007, t(9) = 7.44, p = 0.0000 dart: Drd1a unpaired, n=8: CS-shock 0.011, CS-reward 0.012, t(7) = -0.83, p = 0.4340 dart: Drd2 paired, n=9: CS-shock 0.031, CS-reward 0.001, t(8) = 4.67, p = 0.0016 dart: Drd2 unpaired, n=6: CS-shock 0.008, CS-reward 0.007, t(5) = 1.01, p = 0.3581 median rule: Drd1a paired, n=10: CS-shock 0.513, CS-reward 0.555, t(9) = -1.34, p = 0.2143 median rule: Drd1a unpaired, n=8: CS-shock 0.461, CS-reward 0.450, t(7) = 0.39, p = 0.7067 median rule: Drd2 paired, n=9: CS-shock 0.474, CS-reward 0.525, t(8) = -1.25, p = 0.2474 median rule: Drd2 unpaired, n=6: CS-shock 0.230, CS-reward 0.272, t(5) = -1.98, p = 0.1050
Result: reproduced. Under both freezing rules, paired mice show more defensive behavior to CS-shock than to CS-reward (Drd1a-Cre, 10 mice, t(9) = 3.6, p = 0.006; Drd2-Cre, 9 mice, t(8) = 2.4, p = 0.045), and unpaired mice do not (Drd1a-Cre p = 0.80, Drd2-Cre p 0.51 to 0.52). The difference comes from darting (paired Drd1a-Cre 0.032 against 0.007, p < 0.0001; Drd2-Cre 0.031 against 0.001, p = 0.0016); freezing alone does not differ between the cues (p = 0.14 and 0.37). The paper's freezing rule counts only frames whose pose repeats the previous one: the largest point displacement is below 0.5 px in 19.6% of frames, above 1.6 px in the rest, and never between 0.5 and 1.6 px, so the threshold (about 1.6 px) and the pixel scale do not change which frames count. Whether those frames are still frames or repeated video frames the files do not say. The median-displacement variant, which also counts the mouse still at the port, finds no cue difference (p 0.105 to 0.71). The outcome rests on the paper's rule and on the assumed pixel scale (18.8 to 20.7 px/cm), which sets the darting threshold.
fig5j-drd2-cs-shock-responses, fig5h-drd1-no-difference, fig5k-drd2-cs-reward-no-difference¶
Calcium response per ROI (helper ca_cue_z): raw CNMF-E fluorescence averaged over the imaged
trials of a CS type, z-scored by the 10 s before onset; short window 0 to 1 s, long 1 to 10 s;
two-sample Student's t-tests of paired against unpaired ROIs. Every ROI in the files is used: the
paper's manual curation is not recorded in them. Variants: the deconvolved trace; the trace with
a linear trend over the baseline removed (helper baseline_detrend, not the paper's method), to
see whether a decay within the clips drives the differences; and, for fig5h, the unpaired group
without G4B2-C8-6860 (1 imaged CS-shock trial) and G2B1-C4-6886 (1 ROI). Mouse-level tests are
shown for each claim.
def ttests(gen, typ, key="z", skip=()):
out = {}
for win, wname in [(M.SHORT, "short"), (M.LONG, "long")]:
v = {grp: np.concatenate([M.window_mean(d[key + typ], d["grid"], win) for d in DISC if d["gen"] == gen and d["grp"] == grp and not any(s in d["file"] for s in skip)]) for grp in ["paired", "unpaired"]}
a, b = v["paired"][np.isfinite(v["paired"])], v["unpaired"][np.isfinite(v["unpaired"])]
t = ss.ttest_ind(a, b)
out[wname] = (len(a), len(b), a.mean(), b.mean(), t.statistic, t.pvalue)
print(f" {gen} CS-{typ.lower()} {wname}: paired n={len(a)} mean {a.mean():.3f} (range {a.min():.1f} to {a.max():.1f}), unpaired n={len(b)} mean {b.mean():.3f}; "
f"t({len(a)+len(b)-2}) = {t.statistic:.2f}, p = {t.pvalue:.3g}; dropped (no baseline) {np.sum(~np.isfinite(v['paired']))+np.sum(~np.isfinite(v['unpaired']))}")
return out
def by_mouse(gen, typ):
rows = [{"file": d["file"], "group": d["grp"], "ROIs": d["F"].shape[1], "short": np.nanmean(M.window_mean(d["z" + typ], d["grid"], M.SHORT)),
"long": np.nanmean(M.window_mean(d["z" + typ], d["grid"], M.LONG))} for d in DISC if d["gen"] == gen]
df = pd.DataFrame(rows); print(df.round(3).to_string())
for w in ["short", "long"]:
t = ss.ttest_ind(df[df.group == "paired"][w], df[df.group == "unpaired"][w])
print(f" mouse-level {w}: t = {t.statistic:.2f}, p = {t.pvalue:.3g}")
for d in DISC:
for typ in ["Shock", "Reward"]:
d["dz" + typ] = M.ca_cue_z(d["D"], d["t"], d["cs_on"][(d["cs_type"] == typ) & d["cs_imaged"]])[0]
d["tz" + typ] = M.baseline_detrend(d["z" + typ], d["grid"])
# Does fluorescence decay within the clips? Mean z over ROIs in windows of the baseline and the cue,
# by genotype, group and CS. A decay shows as baseline z falling from the start of the clip to onset.
rows = []
for d in DISC:
for typ in ["Shock", "Reward"]:
for wname, w in [("-10 to -7 s", (-10, -7)), ("-3 to 0 s", (-3, 0)), ("0 to 1 s", (0, 1)), ("1 to 5 s", (1, 5)), ("5 to 10 s", (5, 10))]:
v = M.window_mean(d["z" + typ], d["grid"], w)
rows.append({"genotype": d["gen"], "group": d["grp"], "CS": typ, "window": wname, "sum": np.nansum(v), "n": np.isfinite(v).sum()})
dec = pd.DataFrame(rows).groupby(["genotype", "group", "CS", "window"], sort=False)[["sum", "n"]].sum()
print("mean z over ROIs by window:\n", (dec["sum"] / dec["n"]).unstack().round(2).to_string())
mean z over ROIs by window:
window -10 to -7 s -3 to 0 s 0 to 1 s 1 to 5 s 5 to 10 s
genotype group CS
Drd2 paired Shock 0.29 -0.23 0.27 -0.16 -0.31
Reward 0.35 -0.27 -0.27 -0.57 -0.59
unpaired Shock 0.35 -0.28 -0.42 -0.76 -0.87
Reward 0.36 -0.24 -0.40 -0.57 -0.51
Drd1a paired Shock 0.27 -0.20 -0.08 -0.34 -0.35
Reward 0.30 -0.19 -0.15 -0.21 -0.26
unpaired Shock 0.30 -0.20 -0.34 -0.59 -0.84
Reward 0.27 -0.20 -0.35 -0.43 -0.47
print("Drd2 CS-shock (fig5j), raw fluorescence:"); T5J = ttests("Drd2", "Shock")
print("variant, deconvolved trace:"); ttests("Drd2", "Shock", "dz")
print("variant, baseline trend removed:"); ttests("Drd2", "Shock", "tz")
by_mouse("Drd2", "Shock")
Drd2 CS-shock (fig5j), raw fluorescence:
Drd2 CS-shock short: paired n=1189 mean 0.275 (range -8.3 to 33.7), unpaired n=625 mean -0.425; t(1812) = 6.23, p = 5.61e-10; dropped (no baseline) 0
Drd2 CS-shock long: paired n=1189 mean -0.241 (range -12.0 to 19.2), unpaired n=625 mean -0.819; t(1812) = 5.03, p = 5.3e-07; dropped (no baseline) 0
variant, deconvolved trace:
Drd2 CS-shock short: paired n=1189 mean 0.036 (range -2.1 to 15.4), unpaired n=625 mean -0.171; t(1812) = 5.48, p = 4.91e-08; dropped (no baseline) 0
Drd2 CS-shock long: paired n=1189 mean -0.077 (range -1.4 to 3.4), unpaired n=625 mean -0.178; t(1812) = 4.90, p = 1.04e-06; dropped (no baseline) 0
variant, baseline trend removed:
Drd2 CS-shock short: paired n=1189 mean 1.127 (range -8.9 to 34.5), unpaired n=625 mean 0.241; t(1812) = 5.88, p = 4.9e-09; dropped (no baseline) 0
Drd2 CS-shock long: paired n=1189 mean 1.197 (range -13.1 to 27.3), unpaired n=625 mean 0.597; t(1812) = 2.85, p = 0.0044; dropped (no baseline) 0
file group ROIs short long
0 sub-C1-J642-Disc5_ses-C1-J642-Disc5_image+oph paired 24 0.519 -0.296
1 sub-C3-J670-Disc5Unp_ses-C3-J670-Disc5Unp_ima unpaired 43 0.095 -0.080
2 sub-C6-J588-Disc5_ses-C6-J588-Disc5_image+oph paired 84 0.288 0.268
3 sub-C6-J650-Disc5_ses-C6-J650-Disc5_image+oph paired 77 3.789 0.846
4 sub-C8-J633-Disc5Unp_ses-C8-J633-Disc5Unp_ima unpaired 12 0.426 0.036
5 sub-C8-J634-Disc5Unp_ses-C8-J634-Disc5Unp_ima unpaired 80 -0.753 -0.882
6 sub-G1B1-J895-R-DISC4_ses-G1B1-J895_image+oph paired 109 0.212 -0.024
7 sub-G1B2-J904-L-DISC6_ses-G1B2-J904_image+oph paired 110 -0.378 -0.256
8 sub-G2B1-J915-R-DISC4_ses-G2B1-J915_image+oph unpaired 247 -0.305 -1.055
9 sub-G2B2-J917-R-DISC6_ses-G2B2-J917_image+oph unpaired 132 -0.375 -0.561
10 sub-G3B2-J908-R-DISC5_ses-G3B2-J908_image+oph paired 141 0.238 -0.625
11 sub-G3B4-J907-R-DISC4_ses-G3B4-J907_image+oph paired 118 -0.061 -0.840
12 sub-G4B2-J919-L-DISC6_ses-G4B2-J919_image+oph unpaired 111 -0.806 -0.932
13 sub-J932-Disc6_ses-J932-Disc6_image+ophys.nwb paired 195 -0.168 -0.681
14 sub-J933-Disc4_image+ophys.nwb paired 331 0.070 -0.051
mouse-level short: t = 1.45, p = 0.172
mouse-level long: t = 1.49, p = 0.159
Result: partially reproduced. Drd2+ ROIs of paired mice respond more to CS-shock than those of unpaired mice in both windows (short t(1812) = 6.2, p < 1e-9; long t(1812) = 5.0, p < 1e-6), but the counts are far outside tolerance: 1189 paired and 625 unpaired ROIs against the paper's 296 and 257, because the files hold every CNMF-E ROI and not the curated neurons. The deconvolved variant agrees (p < 1e-5), and so does the variant with the baseline trend removed (p = 4.9e-9 and 0.0044). The fluorescence decays within the clips in every group alike (mean baseline z falls from 0.27 to 0.36 at -10 to -7 s to -0.19 to -0.28 at -3 to 0 s), so the decay does not explain the group difference. Across mice (9 and 6) the difference is not significant (p 0.17 and 0.16).
print("Drd1a CS-shock and CS-reward (fig5h), raw fluorescence:"); T5H = {t: ttests("Drd1a", t) for t in ["Shock", "Reward"]}
print("variant, deconvolved trace:"); [ttests("Drd1a", t, "dz") for t in ["Shock", "Reward"]]
print("variant, baseline trend removed:"); [ttests("Drd1a", t, "tz") for t in ["Shock", "Reward"]]
SKIP = ("G4B2-C8-6860", "G2B1-C4-6886")
print("variant, without", SKIP, "(1 imaged CS-shock trial in a truncated session; 1 ROI):"); [ttests("Drd1a", t, skip=SKIP) for t in ["Shock", "Reward"]]
by_mouse("Drd1a", "Shock"); by_mouse("Drd1a", "Reward")
Drd1a CS-shock and CS-reward (fig5h), raw fluorescence:
Drd1a CS-shock short: paired n=847 mean -0.078 (range -4.6 to 6.7), unpaired n=608 mean -0.336; t(1453) = 3.16, p = 0.00159; dropped (no baseline) 0
Drd1a CS-shock long: paired n=847 mean -0.347 (range -5.9 to 12.2), unpaired n=608 mean -0.727; t(1453) = 4.15, p = 3.54e-05; dropped (no baseline) 0
Drd1a CS-reward short: paired n=847 mean -0.147 (range -6.5 to 5.7), unpaired n=608 mean -0.347; t(1453) = 3.13, p = 0.00178; dropped (no baseline) 0
Drd1a CS-reward long: paired n=847 mean -0.238 (range -12.7 to 5.8), unpaired n=608 mean -0.449; t(1453) = 2.95, p = 0.00321; dropped (no baseline) 0
variant, deconvolved trace:
Drd1a CS-shock short: paired n=847 mean -0.094 (range -1.5 to 1.6), unpaired n=608 mean -0.187; t(1453) = 4.42, p = 1.08e-05; dropped (no baseline) 0
Drd1a CS-shock long: paired n=847 mean -0.102 (range -1.0 to 3.3), unpaired n=608 mean -0.148; t(1453) = 2.46, p = 0.0138; dropped (no baseline) 0
Drd1a CS-reward short: paired n=847 mean -0.070 (range -1.4 to 1.4), unpaired n=608 mean -0.154; t(1453) = 4.37, p = 1.35e-05; dropped (no baseline) 0
Drd1a CS-reward long: paired n=847 mean -0.089 (range -1.1 to 1.2), unpaired n=608 mean -0.116; t(1453) = 1.74, p = 0.0819; dropped (no baseline) 0
variant, baseline trend removed:
Drd1a CS-shock short: paired n=847 mean 0.436 (range -4.2 to 9.0), unpaired n=608 mean 0.178; t(1453) = 2.51, p = 0.012; dropped (no baseline) 0
Drd1a CS-shock long: paired n=847 mean 0.697 (range -9.1 to 20.1), unpaired n=608 mean 0.335; t(1453) = 2.08, p = 0.0375; dropped (no baseline) 0
Drd1a CS-reward short: paired n=847 mean 0.399 (range -7.1 to 7.9), unpaired n=608 mean 0.173; t(1453) = 2.61, p = 0.00924; dropped (no baseline) 0
Drd1a CS-reward long: paired n=847 mean 0.980 (range -13.9 to 17.1), unpaired n=608 mean 0.736; t(1453) = 1.42, p = 0.157; dropped (no baseline) 0
variant, without ('G4B2-C8-6860', 'G2B1-C4-6886') (1 imaged CS-shock trial in a truncated session; 1 ROI):
Drd1a CS-shock short: paired n=847 mean -0.078 (range -4.6 to 6.7), unpaired n=571 mean -0.390; t(1416) = 3.74, p = 0.000192; dropped (no baseline) 0
Drd1a CS-shock long: paired n=847 mean -0.347 (range -5.9 to 12.2), unpaired n=571 mean -0.784; t(1416) = 4.64, p = 3.75e-06; dropped (no baseline) 0
Drd1a CS-reward short: paired n=847 mean -0.147 (range -6.5 to 5.7), unpaired n=571 mean -0.376; t(1416) = 3.52, p = 0.000451; dropped (no baseline) 0
Drd1a CS-reward long: paired n=847 mean -0.238 (range -12.7 to 5.8), unpaired n=571 mean -0.472; t(1416) = 3.19, p = 0.00146; dropped (no baseline) 0
file group ROIs short long
0 sub-G1B1-C1-6868-L-quetzal-DISC6+TONES_ses-G1 paired 206 -0.220 -0.161
1 sub-G1B2-C1-6865-R-frogman-DISC5_ses-G1B2-C1- paired 5 -0.409 -0.036
2 sub-G1B3-C2-6882-R-kevin-DISC6+TONES_ses-G1B3 paired 6 -0.089 -0.359
3 sub-G1B3-K033-R-DISC6_ses-G1B3-K033_image+oph paired 105 -0.025 -0.590
4 sub-G1B4-C3-6921-R-nessie-DISC6+TONES_ses-G1B paired 7 -0.215 0.116
5 sub-G1B4-K035-R-DISC4_ses-G1B4-K035_image+oph paired 216 -0.038 -0.520
6 sub-G2B1-C4-6886-L-jackalope-DISC6UNP+TONES_s unpaired 1 0.135 1.886
7 sub-G2B3-C4-6885-R-cyclops-DISC6UNP+TONES_ses unpaired 6 1.223 0.808
8 sub-G2B3-K036-L-DISC4_ses-G2B3-K036_image+oph unpaired 51 -0.803 -0.795
9 sub-G2B4-K054-R-DISC5_ses-G2B4-K054_image+oph unpaired 102 -0.795 -0.476
10 sub-G3B1-C5-6933-R-chupacabra-DISC5_ses-G3B1- paired 106 0.417 0.125
11 sub-G3B3-K047-L-DISC5_ses-G3B3-K047_image+oph paired 63 -0.021 0.046
12 sub-G3B4-C7-6915-R-mothman-DISC6+TONES_ses-G3 paired 6 0.552 0.462
13 sub-G4B1-K010-R-DISC4_ses-G4B1-K010_image+oph unpaired 145 -0.362 -0.433
14 sub-G4B2-C8-6860-L-carl-DISC6UNP+TONES_ses-G4 unpaired 36 0.501 0.094
15 sub-G4B3-K029-L-DISC5_ses-G4B3-K029_image+oph unpaired 153 0.151 -1.542
16 sub-G4B4-C9-6891-R-mooneye-DISC7UNP+TONES_ses unpaired 114 -0.687 -0.566
17 sub-K008-Disc4_ses-K008-Disc4_image+ophys.nwb paired 127 -0.409 -0.819
mouse-level short: t = 0.14, p = 0.894
mouse-level long: t = -0.13, p = 0.901
file group ROIs short long
0 sub-G1B1-C1-6868-L-quetzal-DISC6+TONES_ses-G1 paired 206 -0.037 0.036
1 sub-G1B2-C1-6865-R-frogman-DISC5_ses-G1B2-C1- paired 5 -0.357 0.079
2 sub-G1B3-C2-6882-R-kevin-DISC6+TONES_ses-G1B3 paired 6 -0.920 -1.170
3 sub-G1B3-K033-R-DISC6_ses-G1B3-K033_image+oph paired 105 0.365 -0.419
4 sub-G1B4-C3-6921-R-nessie-DISC6+TONES_ses-G1B paired 7 -0.225 -0.828
5 sub-G1B4-K035-R-DISC4_ses-G1B4-K035_image+oph paired 216 -0.300 -0.523
6 sub-G2B1-C4-6886-L-jackalope-DISC6UNP+TONES_s unpaired 1 -0.087 1.413
7 sub-G2B3-C4-6885-R-cyclops-DISC6UNP+TONES_ses unpaired 6 -0.242 0.275
8 sub-G2B3-K036-L-DISC4_ses-G2B3-K036_image+oph unpaired 51 -0.639 -0.570
9 sub-G2B4-K054-R-DISC5_ses-G2B4-K054_image+oph unpaired 102 -0.960 -1.113
10 sub-G3B1-C5-6933-R-chupacabra-DISC5_ses-G3B1- paired 106 -0.094 -0.206
11 sub-G3B3-K047-L-DISC5_ses-G3B3-K047_image+oph paired 63 -0.312 0.344
12 sub-G3B4-C7-6915-R-mothman-DISC6+TONES_ses-G3 paired 6 -0.206 -0.221
13 sub-G4B1-K010-R-DISC4_ses-G4B1-K010_image+oph unpaired 145 -0.267 -0.238
14 sub-G4B2-C8-6860-L-carl-DISC6UNP+TONES_ses-G4 unpaired 36 0.113 -0.131
15 sub-G4B3-K029-L-DISC5_ses-G4B3-K029_image+oph unpaired 153 -0.105 -0.624
16 sub-G4B4-C9-6891-R-mooneye-DISC7UNP+TONES_ses unpaired 114 -0.246 0.010
17 sub-K008-Disc4_ses-K008-Disc4_image+ophys.nwb paired 127 -0.400 -0.300
mouse-level short: t = 0.35, p = 0.729
mouse-level long: t = -0.70, p = 0.495
Result: not reproduced. All four of the paper's tests find a difference on the deposited ROIs: Drd1a+ paired ROIs (847) are above unpaired ones (608) for CS-shock short (p = 0.0016) and long (p < 1e-4) and for CS-reward short (p = 0.0018) and long (p = 0.0032), with mean z differences of 0.2 to 0.4. Without the two thin unpaired sessions all four remain (p 0.0015 to 3.8e-6), and with the baseline trend removed three of four remain (p 0.0092 to 0.038; CS-reward long p = 0.16). Across mice (10 and 8) nothing differs (CS-shock p 0.89 and 0.90, CS-reward p 0.73 and 0.50). The paper had 320 and 237 curated neurons; these are all CNMF-E ROIs, about 2.6 times as many, and the neuron-level test is judged as the paper ran it.
print("Drd2 CS-reward (fig5k), raw fluorescence:"); T5K = ttests("Drd2", "Reward")
print("variant, deconvolved trace:"); ttests("Drd2", "Reward", "dz")
print("variant, baseline trend removed:"); ttests("Drd2", "Reward", "tz")
by_mouse("Drd2", "Reward")
Drd2 CS-reward (fig5k), raw fluorescence:
Drd2 CS-reward short: paired n=1189 mean -0.269 (range -4.6 to 6.5), unpaired n=625 mean -0.398; t(1812) = 2.12, p = 0.0341; dropped (no baseline) 0
Drd2 CS-reward long: paired n=1189 mean -0.579 (range -7.2 to 10.7), unpaired n=625 mean -0.538; t(1812) = -0.51, p = 0.612; dropped (no baseline) 0
variant, deconvolved trace:
Drd2 CS-reward short: paired n=1189 mean -0.129 (range -1.5 to 2.2), unpaired n=625 mean -0.148; t(1812) = 1.01, p = 0.314; dropped (no baseline) 0
Drd2 CS-reward long: paired n=1189 mean -0.154 (range -1.3 to 2.0), unpaired n=625 mean -0.132; t(1812) = -1.44, p = 0.151; dropped (no baseline) 0
variant, baseline trend removed:
Drd2 CS-reward short: paired n=1189 mean 0.389 (range -4.3 to 8.7), unpaired n=625 mean 0.156; t(1812) = 3.05, p = 0.00233; dropped (no baseline) 0
Drd2 CS-reward long: paired n=1189 mean 0.847 (range -9.2 to 15.6), unpaired n=625 mean 0.750; t(1812) = 0.62, p = 0.535; dropped (no baseline) 0
file group ROIs short long
0 sub-C1-J642-Disc5_ses-C1-J642-Disc5_image+oph paired 24 -0.214 -0.129
1 sub-C3-J670-Disc5Unp_ses-C3-J670-Disc5Unp_ima unpaired 43 -0.315 0.115
2 sub-C6-J588-Disc5_ses-C6-J588-Disc5_image+oph paired 84 -0.327 -0.294
3 sub-C6-J650-Disc5_ses-C6-J650-Disc5_image+oph paired 77 0.303 0.158
4 sub-C8-J633-Disc5Unp_ses-C8-J633-Disc5Unp_ima unpaired 12 -0.153 0.163
5 sub-C8-J634-Disc5Unp_ses-C8-J634-Disc5Unp_ima unpaired 80 -0.157 -0.023
6 sub-G1B1-J895-R-DISC4_ses-G1B1-J895_image+oph paired 109 -0.297 -1.436
7 sub-G1B2-J904-L-DISC6_ses-G1B2-J904_image+oph paired 110 0.003 -0.624
8 sub-G2B1-J915-R-DISC4_ses-G2B1-J915_image+oph unpaired 247 -0.352 -0.800
9 sub-G2B2-J917-R-DISC6_ses-G2B2-J917_image+oph unpaired 132 -0.268 -0.319
10 sub-G3B2-J908-R-DISC5_ses-G3B2-J908_image+oph paired 141 -0.433 -0.758
11 sub-G3B4-J907-R-DISC4_ses-G3B4-J907_image+oph paired 118 -0.403 -0.806
12 sub-G4B2-J919-L-DISC6_ses-G4B2-J919_image+oph unpaired 111 -0.889 -0.916
13 sub-J932-Disc6_ses-J932-Disc6_image+ophys.nwb paired 195 -0.443 -0.586
14 sub-J933-Disc4_image+ophys.nwb paired 331 -0.252 -0.396
mouse-level short: t = 0.94, p = 0.363
mouse-level long: t = -1.01, p = 0.333
Result: not reproduced. The short-window test finds a difference (t(1812) = 2.1, p = 0.034, paired mean -0.27 against unpaired -0.40); the long window does not (p = 0.61). The effect is small (difference 0.13 in mean z) and depends on the trace: with the deconvolved trace neither window differs (p 0.31 and 0.15), with the baseline trend removed the short window does (p = 0.0023). Across mice (9 and 6) neither window differs (p 0.36 and 0.33). This is on all 1814 CNMF-E ROIs, against the paper's 553 curated neurons.
fig5m-drd2-rich-clusters-cs-shock¶
Clustering imaged neurons of paired Drd1a-Cre and Drd2-Cre mice, the clusters richest in Drd2+ neurons respond to CS-shock or are inhibited by CS-reward ...
Readings named by the criterion: linkage average or Ward; span the 10 s cue or the imaged window (-9.5 to 10 s, as the clips start about 9.6 s before onset). "Soft normalized to a maximum z of 10" has two readings: z / (max|z| + 10), and clipping at plus or minus 10. Nine clusters; Drd2 share normalized for the number of each type; Spearman correlation of that share with the cluster's mean CS-shock z over 0 to 10 s. In the window reading, bins before the latest clip start (-8.67 s) are dropped so that every ROI is kept; a variant that keeps the bins from -9.5 s and drops the ROIs whose clips start later is shown after it.
PD = [d for d in DISC if d["grp"] == "paired"]
def on_grid(d, typ, tg):
return np.array([np.interp(tg, d["grid"], r) for r in d["z" + typ]])
def cluster_rho(X, gen, tg_sh, nsh, norm, meth):
N2, N1 = (gen == "Drd2").sum(), (gen == "Drd1a").sum()
Xn = X / (np.abs(X).max(1, keepdims=True) + 10) if norm.startswith("z/") else np.clip(X, -10, 10)
lab = fcluster(linkage(Xn, meth), 9, "maxclust")
share, resp, sizes = [], [], []
for c in np.unique(lab):
m = lab == c; f2 = (gen[m] == "Drd2").sum() / N2; f1 = (gen[m] == "Drd1a").sum() / N1
share.append(f2 / (f1 + f2)); sizes.append(int(m.sum())); resp.append(X[m][:, :nsh][:, tg_sh > 0].mean())
r = ss.spearmanr(share, resp)
return sizes, r.statistic, r.pvalue
RES5M = []
for span, tg in [("cue 0-10 s", np.arange(0, 10, 1 / 15) + 1 / 30), ("window -9.5-10 s", np.arange(-9.5, 10, 1 / 15) + 1 / 30)]:
X = np.vstack([np.hstack([on_grid(d, "Shock", tg), on_grid(d, "Reward", tg)]) for d in PD])
gen = np.concatenate([[d["gen"]] * d["F"].shape[1] for d in PD])
# bins where some session's clips start later than the span hold no frame; drop those bins, keep every ROI
ok = np.tile(np.isfinite(np.vstack([on_grid(d, "Shock", tg) for d in PD])).all(0), 2) & np.isfinite(X).all(0)
keep_sh = ok[:len(tg)]; X = X[:, ok]; tg_sh = tg[keep_sh]; nsh = int(keep_sh.sum())
print(f"{span}: bins kept {nsh} of {len(tg)} per CS, from {tg_sh.min():.2f} s; ROIs with NaN left {int((~np.isfinite(X)).any(1).sum())}")
N2, N1 = (gen == "Drd2").sum(), (gen == "Drd1a").sum()
for norm in ["z/(max|z|+10)", "clip at 10"]:
for meth in ["average", "ward"]:
sizes, rho, pv = cluster_rho(X, gen, tg_sh, nsh, norm, meth)
RES5M.append((span, norm, meth, len(X), sizes, rho, pv))
print(f"{span}, {norm}, {meth}: ROIs {len(X)} (Drd2 {N2}, Drd1a {N1}), cluster sizes {sizes}, rho = {rho:.2f}, p = {pv:.3f}")
cue 0-10 s: bins kept 150 of 150 per CS, from 0.03 s; ROIs with NaN left 0
cue 0-10 s, z/(max|z|+10), average: ROIs 2036 (Drd2 1189, Drd1a 847), cluster sizes [2, 25, 1, 2, 1864, 130, 1, 8, 3], rho = 0.23, p = 0.558
cue 0-10 s, z/(max|z|+10), ward: ROIs 2036 (Drd2 1189, Drd1a 847), cluster sizes [130, 243, 305, 174, 51, 400, 201, 389, 143], rho = -0.02, p = 0.966
cue 0-10 s, clip at 10, average: ROIs 2036 (Drd2 1189, Drd1a 847), cluster sizes [7, 3, 9, 43, 15, 3, 4, 1951, 1], rho = 0.26, p = 0.507
cue 0-10 s, clip at 10, ward: ROIs 2036 (Drd2 1189, Drd1a 847), cluster sizes [93, 306, 51, 311, 108, 247, 679, 59, 182], rho = 0.30, p = 0.433 window -9.5-10 s: bins kept 281 of 293 per CS, from -8.67 s; ROIs with NaN left 0
window -9.5-10 s, z/(max|z|+10), average: ROIs 2036 (Drd2 1189, Drd1a 847), cluster sizes [2, 27, 1, 7, 6, 8, 1208, 776, 1], rho = 0.45, p = 0.221
window -9.5-10 s, z/(max|z|+10), ward: ROIs 2036 (Drd2 1189, Drd1a 847), cluster sizes [98, 195, 427, 177, 309, 362, 115, 117, 236], rho = 0.40, p = 0.286
window -9.5-10 s, clip at 10, average: ROIs 2036 (Drd2 1189, Drd1a 847), cluster sizes [8, 3, 9, 39, 1, 3, 4, 1968, 1], rho = 0.47, p = 0.197
window -9.5-10 s, clip at 10, ward: ROIs 2036 (Drd2 1189, Drd1a 847), cluster sizes [106, 234, 90, 80, 164, 216, 292, 411, 443], rho = -0.12, p = 0.765
# Variant (asked for in verification): the window from -9.5 s with every bin kept, dropping the ROIs whose
# clips start later and so hold no frame there. The start is then moved by 0.1 to 0.5 s to show how stable it is.
RES5M_DROP = []
for start in [-9.5, -9.4, -9.2, -9.0]:
tg = np.arange(start, 10, 1 / 15) + 1 / 30
late = [d for d in PD if not (np.isfinite(on_grid(d, "Shock", tg)).all() and np.isfinite(on_grid(d, "Reward", tg)).all())]
PK = [d for d in PD if d not in late]
X = np.vstack([np.hstack([on_grid(d, "Shock", tg), on_grid(d, "Reward", tg)]) for d in PK])
gen = np.concatenate([[d["gen"]] * d["F"].shape[1] for d in PK])
N2, N1 = (gen == "Drd2").sum(), (gen == "Drd1a").sum()
print(f"from {start} s: dropped {[(d['file'][:30], d['gen'], d['F'].shape[1]) for d in late]}; ROIs {len(X)} (Drd2 {N2}, Drd1a {N1}), NaN left {int((~np.isfinite(X)).sum())}")
for norm in ["z/(max|z|+10)", "clip at 10"]:
for meth in ["average", "ward"]:
sizes, rho, pv = cluster_rho(X, gen, tg, len(tg), norm, meth)
RES5M_DROP.append((start, norm, meth, len(X), sizes, rho, pv))
print(f" {norm}, {meth}: cluster sizes {sizes}, rho = {rho:.2f}, p = {pv:.3f}")
from -9.5 s: dropped [('sub-G3B1-C5-6933-R-chupacabra-', 'Drd1a', 106), ('sub-K008-Disc4_ses-K008-Disc4_', 'Drd1a', 127)]; ROIs 1803 (Drd2 1189, Drd1a 614), NaN left 0
z/(max|z|+10), average: cluster sizes [2, 28, 1, 3, 6, 9, 21, 1425, 308], rho = 0.76, p = 0.017
z/(max|z|+10), ward: cluster sizes [293, 273, 111, 83, 157, 220, 174, 140, 352], rho = -0.22, p = 0.576
clip at 10, average: cluster sizes [6, 1747, 1, 9, 36, 1, 1, 1, 1], rho = 0.34, p = 0.371
clip at 10, ward: cluster sizes [58, 245, 327, 314, 50, 385, 45, 297, 82], rho = 0.40, p = 0.286
from -9.4 s: dropped [('sub-G3B1-C5-6933-R-chupacabra-', 'Drd1a', 106), ('sub-K008-Disc4_ses-K008-Disc4_', 'Drd1a', 127)]; ROIs 1803 (Drd2 1189, Drd1a 614), NaN left 0
z/(max|z|+10), average: cluster sizes [2, 28, 1, 6, 3, 7, 10, 1745, 1], rho = 0.45, p = 0.221
z/(max|z|+10), ward: cluster sizes [43, 155, 73, 211, 270, 224, 306, 178, 343], rho = 0.28, p = 0.460
clip at 10, average: cluster sizes [5, 30, 1, 7, 4, 1753, 1, 1, 1], rho = 0.43, p = 0.243
clip at 10, ward: cluster sizes [509, 203, 98, 263, 104, 296, 34, 67, 229], rho = 0.37, p = 0.332
from -9.2 s: dropped [('sub-K008-Disc4_ses-K008-Disc4_', 'Drd1a', 127)]; ROIs 1909 (Drd2 1189, Drd1a 720), NaN left 0
z/(max|z|+10), average: cluster sizes [6, 7, 71, 1, 1792, 3, 27, 1, 1], rho = 0.45, p = 0.221
z/(max|z|+10), ward: cluster sizes [418, 43, 265, 143, 174, 217, 439, 93, 117], rho = -0.07, p = 0.865
clip at 10, average: cluster sizes [32, 1, 1, 3, 9, 1860, 1, 1, 1], rho = 0.31, p = 0.416
clip at 10, ward: cluster sizes [81, 188, 79, 620, 465, 51, 155, 32, 238], rho = -0.02, p = 0.966
from -9.0 s: dropped [('sub-K008-Disc4_ses-K008-Disc4_', 'Drd1a', 127)]; ROIs 1909 (Drd2 1189, Drd1a 720), NaN left 0
z/(max|z|+10), average: cluster sizes [6, 7, 2, 71, 1, 1791, 29, 1, 1], rho = 0.51, p = 0.160
z/(max|z|+10), ward: cluster sizes [299, 381, 63, 179, 265, 309, 45, 82, 286], rho = 0.27, p = 0.488
clip at 10, average: cluster sizes [6, 31, 1, 1, 3, 7, 1858, 1, 1], rho = 0.43, p = 0.252
clip at 10, ward: cluster sizes [283, 103, 108, 58, 281, 49, 398, 215, 414], rho = -0.18, p = 0.637
Result: not reproduced. Under none of the eight readings is the Spearman correlation between a cluster's normalized Drd2+ share and its mean CS-shock z positive at p < 0.05 (rho -0.12 to 0.47, p 0.20 to 0.97). Average linkage puts most ROIs in one or two clusters. This is on all CNMF-E ROIs of paired mice, not the curated neurons.
The variant that keeps the window from -9.5 s and drops the ROIs whose clips start later gives rho = 0.76, p = 0.017 under one combination (z/(max|z|+10), average linkage) and p 0.29 to 0.58 under the other three. It is not taken as a reading of the criterion, which asks for every neuron of paired mice: it drops 233 of the 847 Drd1a+ ROIs (C5-6933 and K008, 2 of the 10 Drd1a-Cre mice), which changes the Drd2+ share that ranks the clusters. The result also depends on the start: with the same ROIs dropped and the window starting at -9.4 s, the same combination gives p = 0.22, and from -9.2 or -9.0 s (only K008 dropped) the lowest p is 0.16. The outcome is kept.
figs15-no-context-encoding¶
After contextual fear conditioning, neither Drd1a+ nor Drd2+ ASt neurons change their activity in the conditioned context compared with an unconditioned one, although the mice freeze more in the conditioned context.
Per mouse and context: mean raw fluorescence over ROIs and frames; transient peak rate, peaks above the trace's mean plus 2 SD (scipy find_peaks), per ROI per second; estimated spike rate from the deconvolved trace, as frames with a nonzero value per second, and as the variant its mean value. Freezing share of the session from the poses as above. Paired t-tests across mice.
rows = []
for d in CTX:
mouse = d["path"].split("-Day4")[0].split("-CFCD4")[0].replace("sub-", "")
cond = "A" if "Context A" in d["session_description"] else "B"
dur = d["t"][-1] - d["t"][0]
pk = [len(find_peaks(r, height=r.mean() + 2 * r.std())[0]) / dur for r in d["F"].T]
ppc = M.pixels_per_cm(d["pose"]); fps = 1 / np.median(np.diff(d["pose_t"]))
r = {"mouse": mouse, "context": cond, "genotype": d["gen"], "ROIs": d["F"].shape[1], "minutes": round(dur / 60, 1),
"raw F": d["F"].mean(), "peaks/s": np.mean(pk), "deconv events/s": np.mean((d["D"] > 0).sum(0) / dur),
"deconv mean": d["D"].mean(), "px/cm": ppc}
for rule in ["max", "sum"]:
r[f"freeze {rule}"] = M.behaviour_frames(d["pose"], ppc, fps=fps, freeze_rule=rule)[0].mean()
r["freeze max, px/cm 14"] = M.behaviour_frames(d["pose"], 14.0, fps=fps, freeze_rule="max")[0].mean()
r["freeze median (variant)"] = M.behaviour_frames(d["pose"], ppc, fps=fps, freeze_rule="median")[0].mean()
r["dart"] = M.behaviour_frames(d["pose"], ppc, fps=fps)[1].mean()
mx = M.max_displacement_px(d["pose"])
r["frames <0.5 px"] = np.mean(mx < 0.5); r["frames 0.5-1.6 px"] = np.mean((mx >= 0.5) & (mx < 1.6))
rows.append(r)
CT = pd.DataFrame(rows).sort_values(["genotype", "mouse", "context"]); print(CT.round(3).to_string())
print("px/cm range in context sessions:", CT["px/cm"].min().round(1), "to", CT["px/cm"].max().round(1), "(the 30 x 40 cm assumption is less secure here)")
for gen in ["Drd1a", "Drd2"]:
a = CT[(CT.genotype == gen) & (CT.context == "A")].set_index("mouse"); b = CT[(CT.genotype == gen) & (CT.context == "B")].set_index("mouse").loc[a.index]
for m in ["raw F", "peaks/s", "deconv events/s", "deconv mean", "freeze max", "freeze sum", "freeze max, px/cm 14", "freeze median (variant)", "dart"]:
t = ss.ttest_rel(a[m], b[m])
print(f"{gen} (n={len(a)}) {m}: A {a[m].mean():.4f}, B {b[m].mean():.4f}, t({len(a)-1}) = {t.statistic:.2f}, p = {t.pvalue:.3f}")
mouse context genotype ROIs minutes raw F peaks/s deconv events/s deconv mean px/cm freeze max freeze sum freeze max, px/cm 14 freeze median (variant) dart frames <0.5 px frames 0.5-1.6 px 10 K008 A Drd1a 68 18.0 2.869 0.162 2.282 0.469 13.775 0.277 0.274 0.277 0.668 0.000 0.277 0.000 11 K008 B Drd1a 55 15.6 4.810 0.150 3.859 1.236 16.295 0.062 0.061 0.062 0.437 0.009 0.062 0.000 13 K010 A Drd1a 64 16.6 3.483 0.184 4.025 1.172 13.490 0.060 0.058 0.060 0.340 0.002 0.060 0.000 12 K010 B Drd1a 107 16.1 1.593 0.193 3.231 0.692 14.816 0.039 0.037 0.039 0.312 0.000 0.039 0.000 15 K029 A Drd1a 73 15.7 1.064 0.186 3.962 1.087 13.792 0.150 0.148 0.150 0.464 0.001 0.150 0.000 14 K029 B Drd1a 71 15.1 0.475 0.193 3.890 0.898 32.778 0.034 0.033 0.033 0.171 0.060 0.033 0.000 16 K035 A Drd1a 74 15.8 2.778 0.184 3.731 0.890 13.251 0.202 0.199 0.202 0.497 0.000 0.202 0.000 17 K035 B Drd1a 84 15.5 1.680 0.176 3.835 1.136 13.876 0.156 0.154 0.156 0.482 0.001 0.156 0.000 19 K047 A Drd1a 53 15.4 2.547 0.168 4.191 1.048 7.475 0.218 0.209 0.218 0.523 0.000 0.218 0.000 18 K047 B Drd1a 63 15.4 2.727 0.165 4.264 1.078 26.317 0.067 0.066 0.067 0.236 0.043 0.067 0.001 20 K054 A Drd1a 50 15.9 0.838 0.193 3.747 0.932 14.194 0.206 0.205 0.206 0.665 0.000 0.206 0.000 21 K054 B Drd1a 57 15.8 3.377 0.185 4.038 1.490 13.881 0.075 0.072 0.075 0.408 0.001 0.075 0.000 0 J895 A Drd2 91 15.9 0.470 0.183 3.128 0.907 14.090 0.004 0.004 0.004 0.054 0.001 0.004 0.000 1 J895 B Drd2 70 15.2 -1.502 0.165 4.280 1.458 13.910 0.058 0.054 0.058 0.437 0.001 0.058 0.000 2 J904 A Drd2 80 15.9 1.307 0.181 4.322 1.396 14.423 0.090 0.088 0.090 0.408 0.000 0.090 0.000 3 J904 B Drd2 70 15.9 1.972 0.177 4.399 1.388 14.007 0.020 0.018 0.020 0.281 0.002 0.020 0.000 5 J907 A Drd2 65 16.0 3.616 0.173 4.072 1.424 13.927 0.051 0.049 0.051 0.243 0.002 0.051 0.000 4 J907 B Drd2 71 15.9 0.772 0.164 4.162 1.510 14.554 0.110 0.108 0.110 0.441 0.001 0.110 0.000 7 J908 A Drd2 103 15.4 0.699 0.192 3.750 0.958 13.303 0.163 0.160 0.163 0.452 0.001 0.163 0.000 6 J908 B Drd2 167 16.0 0.232 0.177 2.906 0.671 14.700 0.157 0.155 0.157 0.550 0.000 0.157 0.000 8 J917 A Drd2 83 15.9 2.508 0.166 3.624 0.796 14.445 0.164 0.163 0.164 0.423 0.000 0.164 0.000 9 J917 B Drd2 65 16.5 2.933 0.166 3.558 0.750 13.770 0.028 0.025 0.028 0.375 0.000 0.028 0.000 px/cm range in context sessions: 7.5 to 32.8 (the 30 x 40 cm assumption is less secure here) Drd1a (n=6) raw F: A 2.2633, B 2.4436, t(5) = -0.25, p = 0.810 Drd1a (n=6) peaks/s: A 0.1793, B 0.1771, t(5) = 0.63, p = 0.559 Drd1a (n=6) deconv events/s: A 3.6563, B 3.8529, t(5) = -0.62, p = 0.561 Drd1a (n=6) deconv mean: A 0.9328, B 1.0883, t(5) = -0.82, p = 0.450 Drd1a (n=6) freeze max: A 0.1855, B 0.0722, t(5) = 3.92, p = 0.011 Drd1a (n=6) freeze sum: A 0.1820, B 0.0704, t(5) = 3.91, p = 0.011 Drd1a (n=6) freeze max, px/cm 14: A 0.1855, B 0.0721, t(5) = 3.93, p = 0.011 Drd1a (n=6) freeze median (variant): A 0.5261, B 0.3410, t(5) = 3.52, p = 0.017 Drd1a (n=6) dart: A 0.0006, B 0.0190, t(5) = -1.75, p = 0.140 Drd2 (n=5) raw F: A 1.7203, B 0.8813, t(4) = 1.23, p = 0.286 Drd2 (n=5) peaks/s: A 0.1788, B 0.1697, t(4) = 2.95, p = 0.042 Drd2 (n=5) deconv events/s: A 3.7792, B 3.8611, t(4) = -0.26, p = 0.810 Drd2 (n=5) deconv mean: A 1.0963, B 1.1553, t(4) = -0.43, p = 0.690 Drd2 (n=5) freeze max: A 0.0942, B 0.0746, t(4) = 0.53, p = 0.626 Drd2 (n=5) freeze sum: A 0.0927, B 0.0717, t(4) = 0.56, p = 0.604 Drd2 (n=5) freeze max, px/cm 14: A 0.0942, B 0.0746, t(4) = 0.53, p = 0.626 Drd2 (n=5) freeze median (variant): A 0.3161, B 0.4168, t(4) = -1.11, p = 0.328 Drd2 (n=5) dart: A 0.0007, B 0.0011, t(4) = -0.67, p = 0.541
Result: not reproduced. Five of the six activity tests find no difference, but the Drd2+ peak rate is higher in Context A (t(4) = 2.95, p = 0.042), and Drd2-Cre mice do not freeze more in Context A (p 0.60 to 0.63 under both rules and with a fixed 14 px/cm scale). Drd1a-Cre mice do freeze more in Context A (p = 0.011). The deconvolved measures and raw fluorescence show no difference for either type (p 0.29 to 0.81). As in the discrimination sessions, the freezing frames are those whose pose repeats the previous one within 0.5 px (at most 0.1% of frames fall between 0.5 and 1.6 px), which is why the scale does not change freezing; the median-displacement variant gives the same pattern (Drd1a-Cre p = 0.017, Drd2-Cre p = 0.33). The activity part already decides the outcome: the Drd2+ peak-rate test is significant whatever freezing measures.
Blocked claims: what was checked¶
- figs5-ephys-mice-discriminate, figs10lm-defensive-trials-greater-responses, fig3fg-no-motor-onset-response: the Open Ephys poses are not on the trial clock (data check). A fixed offset is supported by both checks in 2 ASt mice only (3016, 3024; 32 units), and only to within about 0.8 s (the spread of the quarter lags in 3024; the shock check agrees with the port lag within 0.6 s). fig3fg judges activity 0 to 1 s after bout onsets, so an error of that size would blur a response and bias the test toward the claim; figs10lm and figs5 also need the unpaired mice, which have no events or behavior. The port-entry half of figs5 uses only trial-table events and is printed below for the record; it does not decide the claim.
- fig2o-ast-greater-cs-shock-responses and fig2p-ast-more-responsive compare ASt with TS and CeA. No unit is labeled TS. For the record, ASt is printed below against the 22 CeA units of the 2 Open Ephys CeA mice (the paper has 145 CeA neurons from 8 mice); it does not decide the claims.
def port_measures(d, ons, dur=20):
tin = [np.clip(np.minimum(d["port_off"], o + dur) - np.maximum(d["port_on"], o), 0, None).sum() for o in ons]
n = [((d["port_on"] >= o) & (d["port_on"] < o + dur)).sum() for o in ons]
return np.mean(tin), np.mean(n)
pm = pd.DataFrame([{"mouse": d["subject_id"][:12], **dict(zip(["shock time in port", "shock entries"], port_measures(d, d["shock_on"]))),
**dict(zip(["reward time in port", "reward entries"], port_measures(d, d["reward_on"])))} for d in OE])
print(pm.round(2).to_string())
print("means:", pm.drop(columns="mouse").mean().round(2).to_dict())
print("time in port, CS-reward vs CS-shock:", ss.ttest_rel(pm["reward time in port"], pm["shock time in port"]))
print("entries, CS-reward vs CS-shock:", ss.ttest_rel(pm["reward entries"], pm["shock entries"]))
# fig2o-ast-greater-cs-shock-responses and fig2p-ast-more-responsive need TS units, which no file
# labels. ASt against the 22 CeA units of the two Open Ephys CeA mice, for the record only.
for width in [0.1, 0.01]:
g = R2O[R2O.width == width]
for col in ["shock phasic", "shock sustained"]:
a, b = g[g.region == "ASt"][col].dropna(), g[g.region == "CeA"][col].dropna()
t = ss.ttest_ind(a, b)
print(f"bin {width*1000:.0f} ms, CS-{col}: ASt {a.mean():.2f} (n {len(a)}), CeA {b.mean():.2f} (n {len(b)}); F(1,{len(a)+len(b)-2}) = {t.statistic**2:.2f}, p = {t.pvalue:.2g}")
for rd in "ab":
for col in ["shock phasic", "reward phasic", "shock sustained"]:
tab = pd.crosstab(g.region, g[f"{col} class {rd}"]).reindex(columns=[-1, 0, 1], fill_value=0)
tab = tab.loc[:, tab.sum() > 0]
share = (tab.drop(columns=0, errors="ignore").sum(axis=1) / tab.sum(axis=1)).round(2).to_dict()
print(f" bin {width*1000:.0f} ms, reading ({rd}), CS-{col}: classes (inhibited, none, excited) {pd.crosstab(g.region, g[f'{col} class {rd}']).reindex(columns=[-1, 0, 1], fill_value=0).values.tolist()}, "
f"share responsive {share}, chi-square p = {ss.chi2_contingency(tab).pvalue:.3g}")
mouse shock time in port shock entries reward time in port reward entries
0 3012_2018081 1.90 0.43 11.48 2.53
1 3014_2018062 0.01 0.07 2.47 2.29
2 3016_2018081 0.28 0.50 7.92 3.35
3 3024_2018081 2.21 1.38 7.95 3.21
4 3026_2018112 4.68 0.70 8.73 3.10
5 3029_2018112 0.43 0.40 8.90 1.84
6 6197_2019071 3.38 4.57 12.33 4.67
7 6253_2019091 0.68 0.70 4.47 3.11
8 6429_2019101 2.74 2.57 15.74 2.14
9 7001_2019071 1.09 1.67 7.11 2.67
10 7008_2019071 2.88 2.80 10.87 2.54
11 7049_2019091 4.38 1.93 10.43 3.19
means: {'shock time in port': 2.05, 'shock entries': 1.48, 'reward time in port': 9.03, 'reward entries': 2.89}
time in port, CS-reward vs CS-shock: TtestResult(statistic=np.float64(8.307434509226042), pvalue=np.float64(4.5558640554801944e-06), df=np.int64(11))
entries, CS-reward vs CS-shock: TtestResult(statistic=np.float64(4.4224782738127235), pvalue=np.float64(0.0010243000655507247), df=np.int64(11))
bin 100 ms, CS-shock phasic: ASt 5.94 (n 112), CeA 5.15 (n 22); F(1,132) = 0.13, p = 0.72
bin 100 ms, CS-shock sustained: ASt 2.38 (n 112), CeA 2.45 (n 22); F(1,132) = 0.00, p = 0.95
bin 100 ms, reading (a), CS-shock phasic: classes (inhibited, none, excited) [[0, 79, 33], [1, 15, 6]], share responsive {'ASt': 0.29, 'CeA': 0.32}, chi-square p = 0.0767
bin 100 ms, reading (a), CS-reward phasic: classes (inhibited, none, excited) [[2, 66, 44], [0, 19, 3]], share responsive {'ASt': 0.41, 'CeA': 0.14}, chi-square p = 0.0492
bin 100 ms, reading (a), CS-shock sustained: classes (inhibited, none, excited) [[0, 82, 30], [0, 15, 7]], share responsive {'ASt': 0.27, 'CeA': 0.32}, chi-square p = 0.824
bin 100 ms, reading (b), CS-shock phasic: classes (inhibited, none, excited) [[0, 79, 33], [0, 14, 8]], share responsive {'ASt': 0.29, 'CeA': 0.36}, chi-square p = 0.697
bin 100 ms, reading (b), CS-reward phasic: classes (inhibited, none, excited) [[1, 61, 50], [0, 14, 8]], share responsive {'ASt': 0.46, 'CeA': 0.36}, chi-square p = 0.682
bin 100 ms, reading (b), CS-shock sustained: classes (inhibited, none, excited) [[0, 82, 30], [0, 15, 7]], share responsive {'ASt': 0.27, 'CeA': 0.32}, chi-square p = 0.824
bin 10 ms, CS-shock phasic: ASt 2.05 (n 112), CeA 1.73 (n 22); F(1,132) = 0.18, p = 0.68
bin 10 ms, CS-shock sustained: ASt 0.85 (n 112), CeA 0.77 (n 22); F(1,132) = 0.04, p = 0.84
bin 10 ms, reading (a), CS-shock phasic: classes (inhibited, none, excited) [[0, 84, 28], [0, 16, 6]], share responsive {'ASt': 0.25, 'CeA': 0.27}, chi-square p = 1
bin 10 ms, reading (a), CS-reward phasic: classes (inhibited, none, excited) [[0, 80, 32], [0, 20, 2]], share responsive {'ASt': 0.29, 'CeA': 0.09}, chi-square p = 0.0986
bin 10 ms, reading (a), CS-shock sustained: classes (inhibited, none, excited) [[0, 95, 17], [0, 20, 2]], share responsive {'ASt': 0.15, 'CeA': 0.09}, chi-square p = 0.679
bin 10 ms, reading (b), CS-shock phasic: classes (inhibited, none, excited) [[0, 82, 30], [0, 14, 8]], share responsive {'ASt': 0.27, 'CeA': 0.36}, chi-square p = 0.514
bin 10 ms, reading (b), CS-reward phasic: classes (inhibited, none, excited) [[0, 71, 41], [0, 18, 4]], share responsive {'ASt': 0.37, 'CeA': 0.18}, chi-square p = 0.154
bin 10 ms, reading (b), CS-shock sustained: classes (inhibited, none, excited) [[0, 95, 17], [0, 20, 2]], share responsive {'ASt': 0.15, 'CeA': 0.09}, chi-square p = 0.679
Summary¶
| Claim | Outcome |
|---|---|
| fig2-recorded-neurons | not reproduced |
| figs9-sustained-only-cs-shock | partially reproduced |
| figs10-no-reward-relationship | partially reproduced |
| fig2o-region-differs-cs-reward | partially reproduced |
| fig2q-trajectories-diverge | reproduced |
| figs8-single-trial-divergence | partially reproduced |
| fig3h-cs-decoded-paired-only | not reproduced |
| figs13-imaging-mice-discriminate | reproduced |
| fig5j-drd2-cs-shock-responses | partially reproduced |
| fig5h-drd1-no-difference | not reproduced |
| fig5k-drd2-cs-reward-no-difference | not reproduced |
| fig5m-drd2-rich-clusters-cs-shock | not reproduced |
| figs15-no-context-encoding | not reproduced |
| 35 other claims | blocked (see the header) |
A failure to reproduce here may be a failure of this attempt, not of the paper: see the reasoning and the differences from the paper's method.
How the analysis differs from the paper's: the ephys claims use the 10 paired ASt mice recorded with Open Ephys, as the Neuropixels files have no trial events, and the claims that also need unpaired, TS or CeA neurons are tested on their paired ASt part only; port latency is the tone duration; the 90% variant of the fig2q PCA is fitted on paired mice only; the imaging claims use every CNMF-E ROI, as the paper's curation is not in the files; the pixel scale of the poses is inferred from the chamber size.
What was found about the dataset: the Neuropixels recordings lack trial events and behavior, and their units carry a probe depth but no region, so the TS units and all unpaired ephys mice cannot be analysed; the Open Ephys poses are on a clock offset from the spikes and trial events, by a constant -9.8 to +6.6 s in 4 of the 12 sessions and by a lag that changes within the other 8, and nothing in the files says so; the imaging ROI tables are not curated; one Open Ephys and one imaging recording are deposited twice, and one copy of the imaging recording has port entries 236 s off its video; in the imaging poses a fifth of the frames repeat the previous pose within 0.5 px, and the paper's freezing rule counts only those; the imaging files hold 15 imaged CS-reward clips per session (17 to 19 in seven), not the every-other-trial the Methods describe; the RNAscope, optogenetic and unpredicted-US data the paper says are in the dandiset are not there; the Open Ephys files do not state the group.
print("runtime minutes", round((time.time() - T0) / 60, 1), "peak memory MB", round(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1024))
runtime minutes 17.0 peak memory MB 2794