Daste, Pierré et al. (2025), passive odor experiments, from dandiset 000785¶

Paper: Daste, Pierré et al., "Projection-specific Routing of Odor Information in the Olfactory Cortex", bioRxiv preprint doi:10.64898/2025.12.12.694045 (version 1). The claims file (claims/000785/10.64898-2025.12.12.694045.yaml) was written from the preprint's full text flattened from its JATS XML: main text, Methods and supplementary legends, without the contents of Tables 2 to 8.

Dataset: DANDI:000785, version 0.260520.1603 (doi:10.48324/dandi.000785/0.260520.1603). The paper cites no version. Two versions are published, 0.260519.1753 and 0.260520.1603; they hold the same 61 files with the same blobs (checked by asset path and blob id through the DANDI API before the analysis), so the most recent one is pinned. The files are streamed, never downloaded.

This notebook covers the counts of neurons and the passive experiments (identity, concentration and 30 Hz datasets). The Go/NoGo experiment and the tracked neurons are in reproduce_daste_2025_gng.ipynb.

Claim Tested here
dataset-neuron-counts tested
fast-dataset-counts tested
figs2b-labeling-similar tested
mlp-projection-f1, transformer-projection-f1, fig1g-attention-timing, fig1f-latent-separation blocked: the hyperparameters (Tables 5, 6, 8) are missing from the paper's text
fig2b-lifetime-sparseness-similar, fig2c-mutual-information, fig2d-population-sparseness, fig2-proportion-responding, fig2e-reliability tested (identity dataset)
fig2f-latency, fig2g-early-peaks tested (30 Hz dataset)
fig2h-identity-decoding-5s, fig2i-identity-decoding-early, fig2j-identity-decoding-peaks-earlier, fig2k-mpfc-late-identity tested (identity dataset)
fig3bc-concentration-tuning, fig3de-concentration-decoding, figs5g-pairwise-concentration, figs5-sparseness-concentration tested (concentration dataset)
In [1]:
import os
os.environ.setdefault("OMP_NUM_THREADS", "1")
os.environ.setdefault("OPENBLAS_NUM_THREADS", "1")
import numpy as np
import pandas as pd
from scipy import stats, signal
from joblib import Parallel, delayed
import matplotlib.pyplot as plt
import pcx

pd.set_option("display.width", 200)
pd.set_option("display.max_columns", 40)
S = pcx.survey_all()
print("dandiset", pcx.DANDISET, "version", pcx.VERSION, "files", len(S))
dandiset 000785 version 0.260520.1603 files 61

Data check¶

Every file's metadata, counts and timing, read without the traces. The imaging rate stated in the metadata is compared with the rate from the plane-0 timestamps.

In [2]:
S["subject"] = S.subject.astype(str)
cols = ["experiment_name", "projection_area", "subject", "date", "n_planes", "n_planes_without_red",
        "n_cells", "n_cells_kept_planes", "n_red", "n_red_not_cell", "n_trials", "n_bad",
        "imaging_rate_meta", "fs_timestamps", "n_frames", "has_muse"]
print(S.sort_values(["experiment_name", "subject", "date"])[cols].to_string(index=False))
print()
print(S.groupby("experiment_name").agg(files=("path", "size"), mice=("subject", "nunique"),
                                       OB_mice=("projection_area", lambda x: x.eq("OB").sum())).to_string())
print("subjects in the dandiset:", S.subject.nunique(),
      "| OB-tagged mice:", S[S.projection_area == "OB"].subject.nunique(),
      "| mPFC-tagged mice:", S[S.projection_area == "mPFC"].subject.nunique())
bad_rate = S[(S.imaging_rate_meta - S.fs_timestamps).abs() > 0.5]
print(f"files whose stated imaging rate differs from the timestamps by > 0.5 Hz: {len(bad_rate)}")
print(bad_rate[["path", "imaging_rate_meta", "fs_timestamps"]].to_string(index=False))
print("red cells that are not suite2p cells:", int(S.n_red_not_cell.sum()))
print("red-cell table rows equal to red suite2p cells in every file:", bool((S.n_redcell_table == S.n_red).all()))
           experiment_name projection_area subject       date  n_planes  n_planes_without_red  n_cells  n_cells_kept_planes  n_red  n_red_not_cell  n_trials  n_bad  imaging_rate_meta  fs_timestamps  n_frames  has_muse
          GNG_2021_dataset              OB     513 2021-08-16         3                     0      131                  131     17               0       100      0               4.53       4.520928     10000      True
          GNG_2021_dataset              OB     513 2021-08-17         3                     0       98                   98     20               0       100      0               4.53       4.520929     10000      True
          GNG_2021_dataset              OB     513 2021-08-18         3                     0      126                  126     19               0       100      2               4.53       4.520929     10000      True
          GNG_2021_dataset              OB     513 2021-08-19         3                     0      138                  138     20               0       100      0               4.53       4.520931     10000      True
          GNG_2021_dataset            mPFC     644 2021-08-16         3                     0      430                  430     48               0       100      0               4.53       4.520923     10000      True
          GNG_2021_dataset            mPFC     644 2021-08-17         3                     0      342                  342     32               0       100      1               4.53       4.520928     10000      True
          GNG_2021_dataset            mPFC     644 2021-08-18         3                     0      352                  352     28               0       100      0               4.53       4.520928     10000      True
          GNG_2021_dataset            mPFC     644 2021-08-19         3                     0      260                  260     32               0       100      0               4.53       4.520929     10000      True
          GNG_2021_dataset              OB     664 2021-08-16         3                     0      352                  352     30               0       100      1               4.53       4.520928     10000      True
          GNG_2021_dataset              OB     664 2021-08-17         3                     0      361                  361     25               0       100      0               4.53       4.520929     10000      True
          GNG_2021_dataset              OB     664 2021-08-18         3                     0      306                  306     20               0       100      0               4.53       4.520928     10000      True
          GNG_2021_dataset              OB     664 2021-08-19         3                     0      349                  349     21               0       100      0               4.53       4.520930     10000      True
          GNG_2021_dataset            mPFC     668 2021-08-16         3                     2       60                   43      3               0       100      0               4.53       4.520928     10000     False
          GNG_2021_dataset            mPFC     668 2021-08-17         3                     1       62                   58      5               0       100      0               4.53       4.520928     10000     False
          GNG_2021_dataset            mPFC     668 2021-08-18         3                     1       39                   24      3               0       100      1               4.53       4.520929     10000     False
          GNG_2021_dataset            mPFC     668 2021-08-19         3                     1       44                   25      4               0       100      0               4.53       4.520931     10000     False
         GNG_2023b_dataset              OB    2400 2023-08-22         3                     0      235                  235     37               0       105      0              50.00       4.520928     10500      True
         GNG_2023b_dataset              OB    2400 2023-08-23         3                     0      236                  236     36               0       100      0              50.00       4.520928     10000      True
         GNG_2023b_dataset              OB    2400 2023-08-24         3                     0      222                  222     30               0       100      1              50.00       4.520929     10000      True
         GNG_2023b_dataset              OB    2400 2023-08-25         3                     0      222                  222     31               0       100      1             100.00       4.520929     10000      True
         GNG_2023b_dataset              OB    2400 2023-08-26         3                     0      199                  199     32               0       100      0             100.00       4.520929     10000      True
         GNG_2023b_dataset              OB    2401 2023-08-22         3                     0      247                  247     36               0       105      0              50.00       4.520928     10500      True
         GNG_2023b_dataset              OB    2401 2023-08-23         3                     0      190                  190     26               0       100      1              50.00       4.520930     10000      True
         GNG_2023b_dataset              OB    2401 2023-08-24         3                     0      227                  227     28               0       100      2              50.00       4.520928     10000      True
         GNG_2023b_dataset              OB    2401 2023-08-25         3                     0      275                  275     34               0       100      0             100.00       4.520928     10000      True
         GNG_2023b_dataset              OB    2401 2023-08-26         3                     0      249                  249     30               0       100      0              50.00       4.520930     10000      True
         GNG_2023b_dataset            mPFC    2456 2023-08-22         3                     0      315                  315     26               0       105      1              50.00       4.513077     10500      True
         GNG_2023b_dataset            mPFC    2456 2023-08-23         3                     0      304                  304     28               0       100      0              50.00       4.513077     10000      True
         GNG_2023b_dataset            mPFC    2456 2023-08-24         3                     0      315                  315     23               0       100      1              50.00       4.513077     10000      True
         GNG_2023b_dataset            mPFC    2456 2023-08-25         3                     0      288                  288     30               0       100      0             100.00       4.513077     10000      True
         GNG_2023b_dataset            mPFC    2456 2023-08-26         3                     0      283                  283     28               0       100      0              50.00       4.513077     10000      True
         GNG_2023b_dataset            mPFC    2457 2023-08-22         3                     0      268                  268     29               0       105      0              50.00       4.513078     10500      True
         GNG_2023b_dataset            mPFC    2457 2023-08-23         3                     0      255                  255     32               0       100      1              50.00       4.513073     10000      True
         GNG_2023b_dataset            mPFC    2457 2023-08-24         3                     0      312                  312     39               0       100      0             100.00       4.513075     10000      True
         GNG_2023b_dataset            mPFC    2457 2023-08-25         3                     0      277                  277     31               0       100      0             100.00       4.513075     10000      True
         GNG_2023b_dataset            mPFC    2457 2023-08-26         3                     0      249                  249     24               0       100      0              50.00       4.513078     10000      True
     concentration_dataset              OB    2372 2023-08-16         3                     0       75                   75     11               0       100      1               4.53       4.513074     10000     False
     concentration_dataset              OB    2400 2023-08-16         3                     0      234                  234     21               0       100      1              30.00       4.520929     10000     False
     concentration_dataset              OB    2401 2023-08-16         3                     0      207                  207     19               0       100      0               4.53       4.520928     10000     False
     concentration_dataset            mPFC    2456 2023-08-16         3                     0      209                  209     18               0       100      0               4.53       4.513077     10000     False
     concentration_dataset            mPFC    2457 2023-08-16         3                     0      175                  175     19               0       100      0               4.53       4.513083     10000     False
     concentration_dataset            mPFC     443 2021-04-28         3                     0      206                  206     18               0       100      0               4.53       4.513078     10000     False
     concentration_dataset            mPFC     512 2021-04-27         3                     0      245                  245     17               0       100      0               4.53       4.513078     10000     False
     concentration_dataset              OB     513 2021-04-28         3                     0      310                  310     20               0       100      1               4.53       4.513078     10000     False
     concentration_dataset              OB     514 2021-04-27         3                     0      225                  225     16               0       100      1               4.53       4.513078     10000     False
     concentration_dataset            mPFC     644 2021-04-27         3                     0      435                  435     30               0       100      0               4.53       4.513077     10000     False
fast_hz_sniff_trig_dataset              OB    2372 2023-08-19         1                     0       46                   46      6               0       100      1              30.00      29.646384     65500     False
fast_hz_sniff_trig_dataset              OB    2400 2023-08-18         1                     0      118                  118     10               0       100      0              30.00      29.646395     65500     False
fast_hz_sniff_trig_dataset              OB    2401 2023-08-18         1                     0       78                   78      8               0       100      0              30.00      29.759544     65500     False
fast_hz_sniff_trig_dataset            mPFC    2456 2023-08-19         1                     0      120                  120     14               0       100      1              30.00      29.646393     65500     False
fast_hz_sniff_trig_dataset            mPFC    2457 2023-08-19         1                     0      113                  113     13               0       100      0              30.00      29.646390     65500     False
          identity_dataset              OB     163 2020-02-27         3                     0      407                  407     22               0        80      0               4.53       4.513085     10880     False
          identity_dataset              OB     164 2020-06-24         3                     1      378                  237     15               0        80      0               4.53       4.520937     10880     False
          identity_dataset            mPFC     443 2021-03-19         3                     0      146                  146     14               0       100      0               4.53       4.513079     10000     False
          identity_dataset            mPFC     448 2021-03-18         3                     0      146                  146     17               0       100      0               4.53       4.513077     10000     False
          identity_dataset            mPFC     512 2021-05-11         3                     1      218                  156     14               0       100      0               4.53       4.513078     10000     False
          identity_dataset              OB     513 2021-05-11         3                     0      267                  267     22               0       100      1               4.53       4.513077     10000     False
          identity_dataset            mPFC     533 2021-03-18         3                     0       88                   88      8               0       100      0               4.53       4.513079     10000     False
          identity_dataset            mPFC     644 2021-05-11         3                     0      440                  440     31               0       100      1               4.53       4.513077     10000     False
          identity_dataset              OB       8 2020-06-24         3                     1      172                   92     10               0        80      0               4.53       4.520935     10880     False
          identity_dataset              OB       9 2020-03-18         3                     1      231                  123     12               0        80      0               4.53       4.513084     10880     False

                            files  mice  OB_mice
experiment_name                                 
GNG_2021_dataset               16     4        8
GNG_2023b_dataset              20     4       10
concentration_dataset          10    10        5
fast_hz_sniff_trig_dataset      5     5        3
identity_dataset               10    10        5
subjects in the dandiset: 18 | OB-tagged mice: 10 | mPFC-tagged mice: 8
files whose stated imaging rate differs from the timestamps by > 0.5 Hz: 21
                                           path  imaging_rate_meta  fs_timestamps
sub-2400/sub-2400_ses-20230816T142346_ophys.nwb               30.0       4.520929
sub-2400/sub-2400_ses-20230822T121452_ophys.nwb               50.0       4.520928
sub-2400/sub-2400_ses-20230823T130342_ophys.nwb               50.0       4.520928
sub-2400/sub-2400_ses-20230824T102239_ophys.nwb               50.0       4.520929
sub-2400/sub-2400_ses-20230825T110227_ophys.nwb              100.0       4.520929
sub-2400/sub-2400_ses-20230826T124242_ophys.nwb              100.0       4.520929
sub-2401/sub-2401_ses-20230822T140359_ophys.nwb               50.0       4.520928
sub-2401/sub-2401_ses-20230823T143508_ophys.nwb               50.0       4.520930
sub-2401/sub-2401_ses-20230824T114334_ophys.nwb               50.0       4.520928
sub-2401/sub-2401_ses-20230825T121614_ophys.nwb              100.0       4.520928
sub-2401/sub-2401_ses-20230826T135242_ophys.nwb               50.0       4.520930
sub-2456/sub-2456_ses-20230822T154656_ophys.nwb               50.0       4.513077
sub-2456/sub-2456_ses-20230823T165925_ophys.nwb               50.0       4.513077
sub-2456/sub-2456_ses-20230824T130452_ophys.nwb               50.0       4.513077
sub-2456/sub-2456_ses-20230825T135732_ophys.nwb              100.0       4.513077
sub-2456/sub-2456_ses-20230826T150436_ophys.nwb               50.0       4.513077
sub-2457/sub-2457_ses-20230822T173339_ophys.nwb               50.0       4.513078
sub-2457/sub-2457_ses-20230823T181317_ophys.nwb               50.0       4.513073
sub-2457/sub-2457_ses-20230824T142131_ophys.nwb              100.0       4.513075
sub-2457/sub-2457_ses-20230825T153206_ophys.nwb              100.0       4.513075
sub-2457/sub-2457_ses-20230826T161537_ophys.nwb               50.0       4.513078
red cells that are not suite2p cells: 0
red-cell table rows equal to red suite2p cells in every file: True

dataset-neuron-counts¶

The passive identity dataset holds 81 OB-p, 84 mPFC-p and 1978 untagged neurons from 10 mice; the concentration dataset 87 OB-p, 102 mPFC-p and 2232 untagged neurons from 10 mice; the Go/NoGo dataset 7 mice (4 OB-p, 3 mPFC-p tagged) with, per session, 95 +/- 2 OB-p, 87 +/- 8 mPFC-p and 1690 +/- 35 untagged neurons.

Counts of suite2p cells by tag, as the code's load_experiment builds them: planes without a red cell are skipped (compute_dFF0). The count over all planes is shown beside it. For Go/NoGo the day of a session is its rank among the experiment's dates (the code's day_num), day 0 the passive day; "per session" is read as (a) the total over the mice of one task day, averaged over days 1 to 3, or (b) over days 0 to 3. The paper has 3 mPFC-p Go/NoGo mice and the dandiset 4, so the counts are given with all mice and without sub-668, the mPFC mouse without tracking identifiers.

In [3]:
def counts(df, cellcol):
    g = df.groupby("projection_area").agg(red=("n_red", "sum"), cells=(cellcol, "sum"), mice=("subject", "nunique"))
    return dict(OB=int(g.loc["OB", "red"]), mPFC=int(g.loc["mPFC", "red"]),
                untagged=int(g.cells.sum() - g.red.sum()), mice=int(g.mice.sum()))

rows = []
for exp in ["identity_dataset", "concentration_dataset"]:
    d = S[S.experiment_name == exp]
    for cc, lab in [("n_cells_kept_planes", "code rule (planes with red cells)"), ("n_cells", "all planes")]:
        rows.append(dict(experiment=exp, rule=lab, **counts(d, cc)))
print(pd.DataFrame(rows).to_string(index=False))
print("paper: identity 81 / 84 / 1978 (10 mice); concentration 87 / 102 / 2232 (10 mice)")

G = S[S.experiment_name.str.startswith("GNG")].copy()
G["day"] = G.groupby("experiment_name").date.rank(method="dense").astype(int) - 1
G["untagged"] = G.n_cells_kept_planes - G.n_red
print("\nGo/NoGo sessions per mouse and day")
print(G.pivot_table(index=["projection_area", "subject"], columns="day", values="n_red", aggfunc="sum").to_string())
gng_rows = []
for excl in [False, True]:
    d = G[G.subject != "668"] if excl else G
    per_day = d.groupby(["day", "projection_area"]).n_red.sum().unstack()
    per_day["untagged"] = d.groupby("day").untagged.sum()
    for reading, days in [("a: days 1-3", [1, 2, 3]), ("b: days 0-3", [0, 1, 2, 3])]:
        x = per_day.loc[days]
        gng_rows.append(dict(mice="without sub-668" if excl else "all 8", reading=reading,
                             OB_mean=x.OB.mean(), OB_sd=x.OB.std(), mPFC_mean=x.mPFC.mean(), mPFC_sd=x.mPFC.std(),
                             untagged_mean=x.untagged.mean(), untagged_sd=x.untagged.std(),
                             n_mice=d.subject.nunique()))
gng_counts = pd.DataFrame(gng_rows)
print(gng_counts.round(1).to_string(index=False))
print("paper: 95 +/- 2 OB-p, 87 +/- 8 mPFC-p, 1690 +/- 35 untagged per session, 7 mice")
exp_vals = [81, 84, 1978, 87, 102, 2232, 95, 87, 1690]
tols = [8.1, 8.4, 197.8, 8.7, 10.2, 223.2, 2, 8, 35]
code = pd.DataFrame(rows)
code = code[code.rule.str.startswith("code")]
for _, r in gng_counts.iterrows():
    vals = list(code.iloc[0][["OB", "mPFC", "untagged"]]) + list(code.iloc[1][["OB", "mPFC", "untagged"]]) + \
        [r.OB_mean, r.mPFC_mean, r.untagged_mean]
    within = [abs(v - e) <= t for v, e, t in zip(vals, exp_vals, tols)]
    print(r.mice, r.reading, "within tolerance:", within)
           experiment                              rule  OB  mPFC  untagged  mice
     identity_dataset code rule (planes with red cells)  81    84      1937    10
     identity_dataset                        all planes  81    84      2328    10
concentration_dataset code rule (planes with red cells)  87   102      2132    10
concentration_dataset                        all planes  87   102      2132    10
paper: identity 81 / 84 / 1978 (10 mice); concentration 87 / 102 / 2232 (10 mice)

Go/NoGo sessions per mouse and day
day                         0     1     2     3     4
projection_area subject                              
OB              2400     37.0  36.0  30.0  31.0  32.0
                2401     36.0  26.0  28.0  34.0  30.0
                513      17.0  20.0  19.0  20.0   NaN
                664      30.0  25.0  20.0  21.0   NaN
mPFC            2456     26.0  28.0  23.0  30.0  28.0
                2457     29.0  32.0  39.0  31.0  24.0
                644      48.0  32.0  28.0  32.0   NaN
                668       3.0   5.0   3.0   4.0   NaN
           mice     reading  OB_mean  OB_sd  mPFC_mean  mPFC_sd  untagged_mean  untagged_sd  n_mice
          all 8 a: days 1-3    103.3    5.5       95.7      2.3         1655.0         34.1       8
          all 8 b: days 0-3    107.5    9.5       98.2      5.5         1690.0         75.3       8
without sub-668 a: days 1-3    103.3    5.5       91.7      1.5         1623.3         44.5       7
without sub-668 b: days 0-3    107.5    9.5       94.5      5.8         1656.2         75.2       7
paper: 95 +/- 2 OB-p, 87 +/- 8 mPFC-p, 1690 +/- 35 untagged per session, 7 mice
all 8 a: days 1-3 within tolerance: [np.True_, np.True_, np.True_, np.True_, np.True_, np.True_, False, False, True]
all 8 b: days 0-3 within tolerance: [np.True_, np.True_, np.True_, np.True_, np.True_, np.True_, False, False, True]
without sub-668 a: days 1-3 within tolerance: [np.True_, np.True_, np.True_, np.True_, np.True_, np.True_, False, True, False]
without sub-668 b: days 0-3 within tolerance: [np.True_, np.True_, np.True_, np.True_, np.True_, np.True_, False, True, True]

Result: partially reproduced. With the code's rule (planes without a red cell skipped), the identity dataset has 81 OB-p, 84 mPFC-p and 1937 untagged neurons from 10 mice, and the concentration dataset 87, 102 and 2132 from 10 mice, all within tolerance (over all planes the identity untagged count would be 2328). The Go/NoGo per-session mean of OB-p neurons is 103.3 (days 1 to 3) or 107.5 (days 0 to 3), outside 95 +/- 2 under every reading. The mPFC-p mean is within 87 +/- 8 only without sub-668 (91.7 and 94.5; 95.7 and 98.2 with it). The untagged mean is 1623.3 per session without sub-668 (days 1 to 3), outside 1690 +/- 35; it is within under the other readings (1656.2 for days 0 to 3, 1655.0 and 1690.0 with sub-668). The dandiset has 8 Go/NoGo mice, 4 of them mPFC-tagged, where the paper has 7.

fast-dataset-counts¶

The 30 Hz subset holds 24 OB-p, 27 mPFC-p and 424 untagged neurons from 5 mice.

In [4]:
d = S[S.experiment_name == "fast_hz_sniff_trig_dataset"]
print(d[["subject", "projection_area", "n_cells", "n_red", "fs_timestamps"]].to_string(index=False))
print(counts(d, "n_cells_kept_planes"), "| paper: OB 24, mPFC 27, untagged 424, 5 mice")
subject projection_area  n_cells  n_red  fs_timestamps
   2372              OB       46      6      29.646384
   2400              OB      118     10      29.646395
   2401              OB       78      8      29.759544
   2456            mPFC      120     14      29.646393
   2457            mPFC      113     13      29.646390
{'OB': 24, 'mPFC': 27, 'untagged': 424, 'mice': 5} | paper: OB 24, mPFC 27, untagged 424, 5 mice

Result: reproduced. 24 OB-p, 27 mPFC-p and 424 untagged neurons from 5 mice, exactly the paper's counts. The traces are sampled at 29.6 to 29.8 Hz.

figs2b-labeling-similar¶

OB-p and mPFC-p mice do not differ in the number of jGCaMP7f neurons or of co-labeled jGCaMP7f/tdTomato neurons.

Per mouse, suite2p cells (all planes) and red cells; unpaired two-tailed Student t-tests of OB-p against mPFC-p mice. Readings: a mouse's count from (a) its first imaging session or (b) its mean over sessions; the co-labeled measure as (c) a count or (d) a percentage of its jGCaMP7f neurons.

In [5]:
S["pct_red"] = 100 * S.n_red / S.n_cells
first = S.sort_values("date").groupby("subject").first()
mean = S.groupby("subject").agg(projection_area=("projection_area", "first"), n_cells=("n_cells", "mean"),
                                n_red=("n_red", "mean"), pct_red=("pct_red", "mean"))
res = []
for rname, df in [("a: first session", first), ("b: mean over sessions", mean)]:
    ob, mp = df[df.projection_area == "OB"], df[df.projection_area == "mPFC"]
    for col, lab in [("n_cells", "jGCaMP7f neurons"), ("n_red", "c: co-labeled count"), ("pct_red", "d: co-labeled %")]:
        tt = stats.ttest_ind(ob[col], mp[col])
        res.append(dict(reading=rname, measure=lab, n_OB=len(ob), n_mPFC=len(mp), OB_mean=ob[col].mean(),
                        mPFC_mean=mp[col].mean(), t=tt.statistic, p=tt.pvalue))
res = pd.DataFrame(res)
print(res.round(4).to_string(index=False))
print("paper: N = 9 OB-p and 10 mPFC-p mice, p = 0.555 (jGCaMP7f) and 0.455 (co-labeled)")
print("any p < 0.05:", bool((res.p < 0.05).any()))
              reading             measure  n_OB  n_mPFC  OB_mean  mPFC_mean       t      p
     a: first session    jGCaMP7f neurons    10       8 259.1000   188.0000  1.3799 0.1866
     a: first session c: co-labeled count    10       8  17.6000    15.7500  0.5579 0.5846
     a: first session     d: co-labeled %    10       8   7.5288     8.5786 -0.8155 0.4268
b: mean over sessions    jGCaMP7f neurons    10       8 241.3690   195.8527  0.9166 0.3730
b: mean over sessions c: co-labeled count    10       8  18.1167    18.0402  0.0196 0.9846
b: mean over sessions     d: co-labeled %    10       8   8.6497     9.2240 -0.3895 0.7021
paper: N = 9 OB-p and 10 mPFC-p mice, p = 0.555 (jGCaMP7f) and 0.455 (co-labeled)
any p < 0.05: False

Result: reproduced. No t-test reaches p < 0.05 under any reading: jGCaMP7f neurons p = 0.187 (first session) and 0.373 (mean over sessions), co-labeled count p = 0.585 and 0.985, co-labeled percentage p = 0.427 and 0.702. The dandiset has 10 OB-p and 8 mPFC-p mice, where the legend has 9 and 10.

Identity dataset: binarized responses¶

The identity sessions are loaded and each trace normalized as the code does. Each cell's binary activity on each trial is computed for the window 0 to 5 s after onset, under the two readings of the window placement ("start", the main reading, and "centre"). Bad trials are left out of everything; the baseline sample uses all good trials, odor and control. The 8 odors are the non-control stimuli.

In [6]:
ID = pcx.load_experiment(S, "identity_dataset")
for s in ID:
    tr = s["trials"]
    s["keep"] = (~tr.is_bad_trial.astype(bool) & ~tr.is_control).to_numpy()
    s["good"] = (~tr.is_bad_trial.astype(bool)).to_numpy()
rows = []
for s in ID:
    m, tr = s["meta"], s["trials"]
    rows.append(dict(subject=m["subject"], proj=m["projection_area"], cells=len(s["cells"]),
                     red=int(s["cells"].red.sum()), trials=len(tr), bad=int(tr.is_bad_trial.sum()),
                     odor_trials=int(s["keep"].sum()), odors=tr[s["keep"]].stim_name.nunique(),
                     min_trials_per_odor=int(tr[s["keep"]].stim_name.value_counts().min()),
                     fs=round(s["fs"], 3), onset_s=round(float(tr.stim_onset_timestamp.iloc[0] - tr.start_time.iloc[0]), 2),
                     X_min=float(s["X"].min()), X_max=float(s["X"].max())))
print(pd.DataFrame(rows).to_string(index=False))
print("odors:", sorted(set.intersection(*[set(s["trials"][s["keep"]].stim_name) for s in ID])))
print("trials whose -5 to 15 s window runs past the recording's ends (edge frames repeated):", sum(s["n_clipped"] for s in ID),
      "of", sum(len(s["trials"]) for s in ID), "| largest onset-to-frame distance (s):", round(max(s["onset_error_s"] for s in ID), 3))
subject proj  cells  red  trials  bad  odor_trials  odors  min_trials_per_odor    fs  onset_s      X_min     X_max
    163   OB    407   22      80    0           64      8                    8 4.513     9.97  -3.033178 18.353514
    164   OB    237   15      80    0           64      8                    8 4.521     9.95  -2.816784 20.510349
    443 mPFC    146   14     100    0           80      8                   10 4.513     5.10  -3.049156 20.568623
    448 mPFC    146   17     100    0           80      8                   10 4.513     5.10  -3.221033 19.517624
    512 mPFC    156   14     100    0           80      8                   10 4.513     5.10  -3.893013 15.262107
    513   OB    267   22     100    1           80      8                   10 4.513     5.10 -23.960529 17.569078
    533 mPFC     88    8     100    0           80      8                   10 4.513     5.10  -3.430858 18.975775
    644 mPFC    440   31     100    1           79      8                    9 4.513     5.10 -22.112314 15.736376
      8   OB     92   10      80    0           64      8                    8 4.521     9.95  -1.631688 16.628345
      9   OB    123   12      80    0           64      8                    8 4.513     9.97  -1.721349 15.743855
odors: ['2,3-Pentanedione', '2-isobutyl-3-methoxypyrazine', 'Acetophenone', 'Amylamine', 'Butyl Acetate', 'Ethyl Hexanoate', 'Valeric Acid', 'β-Ionone']
trials whose -5 to 15 s window runs past the recording's ends (edge frames repeated): 0 of 920 | largest onset-to-frame distance (s): 0.0
In [7]:
def binarize_sessions(sessions, win, starts_at_onset, seed, reading="start"):
    rng = np.random.default_rng(seed)
    return [pcx.binarize(s["X"], s["t"], s["fs"], win, starts_at_onset, rng, reading=reading,
                         trial_mask=s["good"]) for s in sessions]

B_ID = {rd: binarize_sessions(ID, (0, 5), True, 11, rd) for rd in ["start", "centre"]}
for rd, Bs in B_ID.items():
    print(rd, "mean active fraction on odor trials:",
          round(float(np.mean(np.concatenate([B[:, s["keep"]].ravel() for B, s in zip(Bs, ID)]))), 4))

def per_cell_table(sessions, Bs):
    out = []
    for s, B in zip(sessions, Bs):
        tr = s["trials"][s["keep"]]
        b = B[:, s["keep"]]
        odors = tr.stim_name.to_numpy()
        names = sorted(set(odors))
        r = np.stack([b[:, odors == o].mean(1) for o in names], 1)
        ls = pcx.vinje_gallant(r, 1)
        mi = np.array([pcx.mutual_info_bits(bi, odors) for bi in b])
        out.append(pd.DataFrame(dict(subject=s["meta"]["subject"], group=s["cells"].projection.values,
                                     lifetime_sparseness=ls, mutual_info=mi, mean_activity=b.mean(1))))
    return pd.concat(out, ignore_index=True)

CELL = {rd: per_cell_table(ID, B_ID[rd]) for rd in B_ID}
print(CELL["start"].groupby("group").agg(n=("subject", "size"), never_active=("mean_activity", lambda x: int((x == 0).sum()))).to_string())

GROUPS = ["OB", "mPFC", "untagged"]
PAIRS = [("OB", "mPFC"), ("OB", "untagged"), ("mPFC", "untagged")]

def pair_tests(values_by_group, m=3):
    rows = []
    for a, b in PAIRS:
        p = pcx.mwu(values_by_group[a], values_by_group[b])
        rows.append(dict(pair=f"{a} vs {b}", median_a=np.nanmedian(values_by_group[a]), median_b=np.nanmedian(values_by_group[b]),
                         mean_a=np.nanmean(values_by_group[a]), mean_b=np.nanmean(values_by_group[b]),
                         p=p, p_bonferroni=min(1.0, p * m)))
    return pd.DataFrame(rows)
start mean active fraction on odor trials: 0.1167
centre mean active fraction on odor trials: 0.1141
             n  never_active
group                       
OB          81            21
mPFC        84            11
untagged  1937           230

fig2b-lifetime-sparseness-similar¶

Lifetime sparseness does not differ significantly between OB-p, mPFC-p and untagged neurons in the identity dataset.

Lifetime sparseness over the 8 odors of each cell's trial-averaged binary activity. A cell never active on any odor trial has no defined sparseness and is left out (counts printed). Two-sided Mann-Whitney U tests, Bonferroni over the 3 pairs.

In [8]:
for rd, C in CELL.items():
    v = {g: C.loc[C.group == g, "lifetime_sparseness"].to_numpy() for g in GROUPS}
    print(f"reading {rd}: defined / total:", {g: f"{np.isfinite(v[g]).sum()}/{len(v[g])}" for g in GROUPS})
    print(pair_tests(v).round(4).to_string(index=False))
    if rd == "start":
        # by animal
        print(C.groupby(["group", "subject"]).lifetime_sparseness.median().unstack(0).round(3).to_string())
# Variants: the paper's n (81, 84, 1978) counts every neuron, so never-active neurons may have been kept with some value.
print("\nvariants keeping every neuron, undefined sparseness set to 0 or to 1 (Bonferroni over 3 pairs):")
for rd, C in CELL.items():
    for fill in [0.0, 1.0]:
        v = {g: np.nan_to_num(C.loc[C.group == g, "lifetime_sparseness"].to_numpy(), nan=fill) for g in GROUPS}
        T = pair_tests(v)
        print(f"   {rd}, set to {fill:.0f}: " + "; ".join(f"{r.pair} medians {r.median_a:.3f} and {r.median_b:.3f}, p = {r.p_bonferroni:.2g}" for r in T.itertuples()))
# Whether the claim's condition (no pair differs) holds under each treatment of never-active neurons.
print("\nno pair differs (every corrected p >= 0.05), as the claim has it:")
for rd, C in CELL.items():
    for name, fill in [("left out", None), ("set to 0", 0.0), ("set to 1", 1.0)]:
        v = {g: C.loc[C.group == g, "lifetime_sparseness"].to_numpy() for g in GROUPS}
        if fill is not None:
            v = {g: np.nan_to_num(a, nan=fill) for g, a in v.items()}
        T = pair_tests(v)
        print(f"   {rd}, never-active neurons {name}: {bool((T.p_bonferroni >= 0.05).all())} (smallest corrected p {T.p_bonferroni.min():.2g})")
reading start: defined / total: {'OB': '60/81', 'mPFC': '73/84', 'untagged': '1707/1937'}
            pair  median_a  median_b  mean_a  mean_b      p  p_bonferroni
      OB vs mPFC    0.7619    0.7744  0.7092  0.7593 0.4094        1.0000
  OB vs untagged    0.7619    0.7143  0.7092  0.6601 0.1275        0.3826
mPFC vs untagged    0.7744    0.7143  0.7593  0.6601 0.0022        0.0067
group       OB   mPFC  untagged
subject                        
163      0.721    NaN     0.500
164      0.738    NaN     0.714
443        NaN  1.000     0.857
448        NaN  0.884     0.762
512        NaN  0.774     0.757
513      0.818    NaN     0.762
533        NaN  0.659     0.629
644        NaN  0.715     0.585
8        0.762    NaN     0.762
9        0.667    NaN     0.816
reading centre: defined / total: {'OB': '59/81', 'mPFC': '72/84', 'untagged': '1677/1937'}
            pair  median_a  median_b  mean_a  mean_b      p  p_bonferroni
      OB vs mPFC    0.7619    0.7750  0.7100  0.7558 0.4689        1.0000
  OB vs untagged    0.7619    0.7143  0.7100  0.6631 0.1394        0.4182
mPFC vs untagged    0.7750    0.7143  0.7558  0.6631 0.0049        0.0147

variants keeping every neuron, undefined sparseness set to 0 or to 1 (Bonferroni over 3 pairs):
   start, set to 0: OB vs mPFC medians 0.676 and 0.754, p = 0.13; OB vs untagged medians 0.676 and 0.633, p = 0.95; mPFC vs untagged medians 0.754 and 0.633, p = 0.061
   start, set to 1: OB vs mPFC medians 0.857 and 0.857, p = 1; OB vs untagged medians 0.857 and 0.746, p = 0.0079; mPFC vs untagged medians 0.857 and 0.746, p = 0.019
   centre, set to 0: OB vs mPFC medians 0.629 and 0.754, p = 0.15; OB vs untagged medians 0.629 and 0.633, p = 0.93; mPFC vs untagged medians 0.754 and 0.633, p = 0.1
   centre, set to 1: OB vs mPFC medians 0.857 and 0.857, p = 1; OB vs untagged medians 0.857 and 0.756, p = 0.011; mPFC vs untagged medians 0.857 and 0.756, p = 0.04

no pair differs (every corrected p >= 0.05), as the claim has it:
   start, never-active neurons left out: False (smallest corrected p 0.0067)
   start, never-active neurons set to 0: True (smallest corrected p 0.061)
   start, never-active neurons set to 1: False (smallest corrected p 0.0079)
   centre, never-active neurons left out: False (smallest corrected p 0.015)
   centre, never-active neurons set to 0: True (smallest corrected p 0.1)
   centre, never-active neurons set to 1: False (smallest corrected p 0.011)

Result: blocked, methods underspecified (the treatment of neurons never active on an odor trial decides the outcome, and the paper does not give it). Under the start reading 21 OB-p, 11 mPFC-p and 230 untagged neurons are never active on an odor trial and have no defined sparseness. Left out, mPFC-p and untagged neurons differ (medians 0.774 and 0.714, Bonferroni p = 0.0067 under the start reading and 0.015 under the centre reading), while OB-p against mPFC-p (corrected p = 1.0) and OB-p against untagged (0.38 and 0.42) do not. Kept with sparseness set to 0, no pair differs (smallest corrected p = 0.061 start, 0.10 centre), which would reproduce the claim; set to 1, OB-p and mPFC-p each differ from untagged (corrected p = 0.0079 and 0.019 start, 0.011 and 0.040 centre). The paper's formula and its handling of an all-zero response are lost from the text, so none of the three treatments has a basis in the paper, and the two that keep every neuron give opposite outcomes. The criterion's n (81, 84 and 1978) is also the n of Figures 2C and 2E, so it may be the group sizes and not evidence that never-active neurons were kept in 2B. The first record gave not reproduced with them left out; the third verification round agreed with blocking the claim.

fig2c-mutual-information¶

Mutual information between binarized activity and odor identity does not differ between OB-p and mPFC-p neurons, but is lower for OB-p than untagged neurons (p = 0.012).

In [9]:
for rd, C in CELL.items():
    v = {g: C.loc[C.group == g, "mutual_info"].to_numpy() for g in GROUPS}
    print(f"reading {rd}")
    print(pair_tests(v).round(5).to_string(index=False))
print(CELL["start"].groupby(["group", "subject"]).mutual_info.median().unstack(0).round(4).to_string())
reading start
            pair  median_a  median_b  mean_a  mean_b       p  p_bonferroni
      OB vs mPFC   0.06913   0.05914 0.08094 0.08603 0.79224       1.00000
  OB vs untagged   0.06913   0.07891 0.08094 0.10161 0.06337       0.19011
mPFC vs untagged   0.05914   0.07891 0.08603 0.10161 0.11308       0.33923
reading centre
            pair  median_a  median_b  mean_a  mean_b       p  p_bonferroni
      OB vs mPFC   0.06551   0.05585 0.07919 0.08413 0.71871       1.00000
  OB vs untagged   0.06551   0.07705 0.07919 0.10041 0.05605       0.16815
mPFC vs untagged   0.05585   0.07705 0.08413 0.10041 0.10388       0.31164
group        OB    mPFC  untagged
subject                          
163      0.0948     NaN    0.1034
164      0.0655     NaN    0.0691
443         NaN  0.0383    0.0383
448         NaN  0.0514    0.0519
512         NaN  0.1043    0.0818
513      0.0561     NaN    0.0712
533         NaN  0.0548    0.0748
644         NaN  0.0822    0.1068
8        0.0878     NaN    0.0672
9        0.0733     NaN    0.0647

Result: not reproduced. OB-p and mPFC-p do not differ (corrected p = 1.0), as the paper says, but OB-p is not significantly lower than untagged: medians 0.069 and 0.079 bits, corrected p = 0.19 (start) and 0.17 (centre).

Pseudo-population trials¶

The identity pseudo-population: cells of all mice of a group, trials matched by odor and by the order of that odor's presentation, truncated to the smallest count across mice.

In [10]:
def group_masks(sessions, g):
    return [(s["cells"].projection == g).to_numpy() for s in sessions]

def pseudo(sessions, g, arrays=None, key="stim_name"):
    return pcx.pseudo_population(sessions, group_masks(sessions, g), key, [s["keep"] for s in sessions],
                                 arrays=arrays)

PB = {}
for rd in B_ID:
    for g in GROUPS:
        tab, Pb = pseudo(ID, g, arrays=B_ID[rd])
        PB[rd, g] = Pb
print("pseudo-population trials:", len(tab), "| per odor:", tab.stim_name.value_counts().to_dict())
print("cells per group:", {g: PB["start", g].shape[0] for g in GROUPS})
pseudo-population trials: 64 | per odor: {'2,3-Pentanedione': 8, '2-isobutyl-3-methoxypyrazine': 8, 'Acetophenone': 8, 'Amylamine': 8, 'Butyl Acetate': 8, 'Ethyl Hexanoate': 8, 'Valeric Acid': 8, 'β-Ionone': 8}
cells per group: {'OB': 81, 'mPFC': 84, 'untagged': 1937}

fig2d-population-sparseness¶

Population sparseness per trial differs only between OB-p and untagged populations (p = 1.26 x 10^-5).

Per pseudo-population trial, population sparseness over all cells of the group from their binary activity on that trial. With binary values this equals (1 - q) / (1 - 1/N) for a fraction q of active cells.

In [11]:
for rd in B_ID:
    v = {g: pcx.vinje_gallant(PB[rd, g].T.astype(float), 1) for g in GROUPS}
    print(f"reading {rd}: undefined trials (no cell active):", {g: int(np.isnan(v[g]).sum()) for g in GROUPS})
    t2d = pair_tests(v)
    print(t2d.round(7).to_string(index=False))
    print("significant pairs (corrected p < 0.05):", list(t2d.pair[t2d.p_bonferroni < 0.05]))
reading start: undefined trials (no cell active): {'OB': 0, 'mPFC': 0, 'untagged': 0}
            pair  median_a  median_b   mean_a   mean_b        p  p_bonferroni
      OB vs mPFC  0.925000  0.951807 0.916406 0.941830 0.000003  8.700000e-06
  OB vs untagged  0.925000  0.886105 0.916406 0.877809 0.000000  1.000000e-07
mPFC vs untagged  0.951807  0.886105 0.941830 0.877809 0.000000  0.000000e+00
significant pairs (corrected p < 0.05): ['OB vs mPFC', 'OB vs untagged', 'mPFC vs untagged']
reading centre: undefined trials (no cell active): {'OB': 0, 'mPFC': 0, 'untagged': 0}
            pair  median_a  median_b   mean_a   mean_b            p  p_bonferroni
      OB vs mPFC  0.925000  0.951807 0.918164 0.942018 1.560000e-05      0.000047
  OB vs untagged  0.925000  0.889721 0.918164 0.880432 5.000000e-07      0.000002
mPFC vs untagged  0.951807  0.889721 0.942018 0.880432 0.000000e+00      0.000000
significant pairs (corrected p < 0.05): ['OB vs mPFC', 'OB vs untagged', 'mPFC vs untagged']

Result: not reproduced. All three pairs differ, not only OB-p against untagged: OB-p against mPFC-p corrected p = 8.7e-06 (start) and 4.7e-05 (centre), OB-p against untagged 1e-07 and 2e-06, mPFC-p against untagged below 1e-07. OB-p population sparseness (median 0.925) lies between untagged (0.886) and mPFC-p (0.952).

fig2-proportion-responding¶

A higher proportion of OB-p than mPFC-p neurons responds to odorants.

Readings: (a) per pseudo-population trial, the fraction of the group's cells active (64 values per group); (b) per neuron, the fraction of its odor trials on which it is active.

In [12]:
for rd in B_ID:
    va = {g: PB[rd, g].mean(0) for g in GROUPS}
    C = CELL[rd]
    vb = {g: C.loc[C.group == g, "mean_activity"].to_numpy() for g in GROUPS}
    print(f"reading {rd}, (a) per pseudo-population trial")
    print(pair_tests(va).round(8).to_string(index=False))
    print(f"reading {rd}, (b) per neuron")
    print(pair_tests(vb).round(8).to_string(index=False))
print("per mouse, mean fraction active on odor trials (start reading):")
print(CELL["start"].groupby(["group", "subject"]).mean_activity.mean().unstack(0).round(3).to_string())
reading start, (a) per pseudo-population trial
            pair  median_a  median_b   mean_a   mean_b        p  p_bonferroni
      OB vs mPFC  0.086420  0.059524 0.094907 0.069382 0.000003      0.000009
  OB vs untagged  0.086420  0.114352 0.094907 0.122645 0.000056      0.000168
mPFC vs untagged  0.059524  0.114352 0.069382 0.122645 0.000000      0.000000
reading start, (b) per neuron
            pair  median_a  median_b   mean_a   mean_b        p  p_bonferroni
      OB vs mPFC  0.046875  0.037975 0.093441 0.071986 0.718785      1.000000
  OB vs untagged  0.046875  0.062500 0.093441 0.122727 0.003747      0.011241
mPFC vs untagged  0.037975  0.062500 0.071986 0.122727 0.005214      0.015641
reading centre, (a) per pseudo-population trial
            pair  median_a  median_b   mean_a   mean_b        p  p_bonferroni
      OB vs mPFC  0.086420  0.059524 0.093171 0.069196 0.000016      0.000047
  OB vs untagged  0.086420  0.110738 0.093171 0.120023 0.000179      0.000536
mPFC vs untagged  0.059524  0.110738 0.069196 0.120023 0.000000      0.000000
reading centre, (b) per neuron
            pair  median_a  median_b   mean_a   mean_b        p  p_bonferroni
      OB vs mPFC  0.037500  0.043987 0.091667 0.071086 0.583166      1.000000
  OB vs untagged  0.037500  0.062500 0.091667 0.119998 0.004391      0.013174
mPFC vs untagged  0.043987  0.062500 0.071086 0.119998 0.009819      0.029456
per mouse, mean fraction active on odor trials (start reading):
group       OB   mPFC  untagged
subject                        
163      0.128    NaN     0.203
164      0.099    NaN     0.125
443        NaN  0.024     0.027
448        NaN  0.027     0.047
512        NaN  0.068     0.094
513      0.050    NaN     0.075
533        NaN  0.069     0.087
644        NaN  0.121     0.163
8        0.072    NaN     0.086
9        0.121    NaN     0.088

Result: reproduced. Under reading (a), per pseudo-population trial, 9.49% of OB-p and 6.94% of mPFC-p neurons are active (medians 8.6% and 6.0%), corrected p = 9e-06 (start) and 4.7e-05 (centre). Under reading (b), per neuron, the difference is not significant (corrected p = 1.0).

fig2e-reliability¶

OB-p populations contain higher fractions of both unreliable and reliable responsive cells per trial (10.97% and 1.54%) than mPFC-p populations (8.71% and 0.25%).

Methods, Reliability analysis: a cell responds on a trial when its mean normalized fluorescence 0 to 5 s after onset exceeds its baseline mean plus 2.33 baseline SDs; reliable when it responds on more than half of its trials. Readings: baseline (a) the 4 s before onset or (b) the 5 s before; mean and SD (c) per trial or (d) pooled over the cell's odor trials; "more than half" over (e) all odor trials or (f) the trials of any one odor; samples (g) pseudo-population trials or (h) each mouse's own odor trials, pooled by group.

In [13]:
def reliability(s, base, per_trial, rule):
    X, t = s["X"][:, s["keep"]], s["t"]
    bm = (t >= -base) & (t < 0)
    resp = X[:, :, (t >= 0) & (t < 5)].mean(-1)
    if per_trial:
        mu, sd = X[:, :, bm].mean(-1), X[:, :, bm].std(-1, ddof=1)
    else:
        B = X[:, :, bm].reshape(X.shape[0], -1)
        mu, sd = B.mean(1)[:, None], B.std(1, ddof=1)[:, None]
    r = resp > mu + 2.33 * sd
    odors = s["trials"][s["keep"]].stim_name.to_numpy()
    if rule == "e":
        rel = r.mean(1) > 0.5
    else:
        rel = np.stack([r[:, odors == o].mean(1) > 0.5 for o in np.unique(odors)], 1).any(1)
    full = np.zeros((X.shape[0], len(s["trials"])), np.int8)
    full[:, s["keep"]] = r * (1 + rel[:, None])         # 0 none, 1 responsive unreliable, 2 responsive reliable
    return full

rel_rows = []
for base, bl in [(4, "a"), (5, "b")]:
    for per_trial, pl in [(True, "c"), (False, "d")]:
        for rule in ["e", "f"]:
            R = [reliability(s, base, per_trial, rule) for s in ID]
            for samp in ["g", "h"]:
                vals = {}
                for g in ["OB", "mPFC"]:
                    if samp == "g":
                        _, P = pseudo(ID, g, arrays=R)
                    else:
                        P = None
                    out = {}
                    for kind, code in [("unreliable", 1), ("reliable", 2)]:
                        if samp == "g":
                            out[kind] = 100 * (P == code).mean(0)
                        else:
                            out[kind] = np.concatenate([100 * (Ri[(s["cells"].projection == g).to_numpy()][:, s["keep"]] == code).mean(0)
                                                        for Ri, s in zip(R, ID) if (s["cells"].projection == g).any()])
                    vals[g] = out
                pu = pcx.mwu(vals["OB"]["unreliable"], vals["mPFC"]["unreliable"])
                pr = pcx.mwu(vals["OB"]["reliable"], vals["mPFC"]["reliable"])
                rel_rows.append(dict(reading=bl + pl + rule + samp,
                                     OB_unrel=vals["OB"]["unreliable"].mean(), OB_rel=vals["OB"]["reliable"].mean(),
                                     mPFC_unrel=vals["mPFC"]["unreliable"].mean(), mPFC_rel=vals["mPFC"]["reliable"].mean(),
                                     p_unrel=pu, p_rel=pr, p_unrel_bonf=min(1, 3 * pu), p_rel_bonf=min(1, 3 * pr), n_trials=len(vals["OB"]["reliable"])))
REL = pd.DataFrame(rel_rows)
exp4, tol4 = np.array([10.97, 1.54, 8.71, 0.25]), np.array([1.097, 0.154, 0.871, 0.025])
REL["values_within"] = REL.apply(lambda r: int((np.abs(np.array([r.OB_unrel, r.OB_rel, r.mPFC_unrel, r.mPFC_rel]) - exp4) <= tol4).sum()), axis=1)
REL["tests_hold"] = (REL.p_unrel_bonf < 0.05) & (REL.p_rel_bonf < 0.05) & (REL.OB_unrel > REL.mPFC_unrel) & (REL.OB_rel > REL.mPFC_rel)
# the correction count is not stated for this panel: Bonferroni over the 2 tests is shown as a second reading
REL["tests_hold_m2"] = (2 * REL.p_unrel < 0.05) & (2 * REL.p_rel < 0.05) & (REL.OB_unrel > REL.mPFC_unrel) & (REL.OB_rel > REL.mPFC_rel)
print("Bonferroni over the 3 group pairs, as for the other Figure 2 comparisons; values_within counts the 4 percentages within tolerance")
print(REL.round(4).to_string(index=False))
print("combinations where both tests hold, Bonferroni over 3 pairs:", list(REL.reading[REL.tests_hold]),
      "| over 2 tests:", list(REL.reading[REL.tests_hold_m2]))
Bonferroni over the 3 group pairs, as for the other Figure 2 comparisons; values_within counts the 4 percentages within tolerance
reading  OB_unrel  OB_rel  mPFC_unrel  mPFC_rel  p_unrel  p_rel  p_unrel_bonf  p_rel_bonf  n_trials  values_within  tests_hold  tests_hold_m2
   aceg   18.3256  5.5170     18.8058    1.8973   0.7224 0.0000        1.0000      0.0000        64              0       False          False
   aceh   18.6882  4.7912     17.3909    1.0025   0.0918 0.0000        0.2753      0.0000       336              0       False          False
   acfg    7.6389 16.2037      8.6868   12.0164   0.2118 0.0001        0.6354      0.0003        64              1       False          False
   acfh    7.5708 15.9086      9.8294    8.5640   0.0668 0.0000        0.2003      0.0000       336              0       False          False
   adeg    3.6651  1.0031      3.7202    0.0000   0.1587 0.0000        0.4762      0.0000        64              0       False          False
   adeh    3.7676  0.7035      3.5765    0.0000   0.3746 0.0000        1.0000      0.0000       336              0       False          False
   adfg    2.5849  2.0833      3.0134    0.7068   0.7139 0.0000        1.0000      0.0000        64              0       False          False
   adfh    2.6263  1.8448      3.0233    0.5532   0.4542 0.0000        1.0000      0.0000       336              0       False          False
   bceg   17.0139  5.3819     18.2106    0.0000   0.4217 0.0000        1.0000      0.0000        64              0       False          False
   bceh   17.2258  4.6852     15.9316    0.0000   0.0211 0.0000        0.0633      0.0000       336              0       False           True
   bcfg    7.6389 14.7569      8.3333    9.8772   0.6078 0.0000        1.0000      0.0000        64              1       False          False
   bcfh    7.5523 14.3588      9.0045    6.9272   0.3309 0.0000        0.9928      0.0000       336              1       False          False
   bdeg    3.7809  1.0031      3.4970    0.0000   0.0276 0.0000        0.0827      0.0000        64              0       False          False
   bdeh    3.8605  0.7035      3.3315    0.0000   0.0930 0.0000        0.2790      0.0000       336              0       False          False
   bdfg    2.6042  2.1798      2.8832    0.6138   0.4234 0.0000        1.0000      0.0000        64              0       False          False
   bdfh    2.6199  1.9440      2.8285    0.5030   0.7741 0.0000        1.0000      0.0000       336              0       False          False
combinations where both tests hold, Bonferroni over 3 pairs: [] | over 2 tests: ['bceh']

Result: not reproduced, resting on an assumption. With Bonferroni over the 3 group pairs, as for the other Figure 2 comparisons, both tests hold under no combination of readings. OB-p has more reliable responsive cells per trial than mPFC-p under all 16 combinations (corrected p <= 0.0003), but not more unreliable ones (smallest corrected p = 0.063, under b, c, e, h). Bonferroni over the 2 tests is a further reading this attempt added, not one the criterion names: under it both tests hold under b, c, e, h (unreliable 17.23% against 15.93%, raw p = 0.0211), which would make the claim partially reproduced. At most one of the four percentages is within tolerance under any combination; for example under a, c, f, g OB-p has 7.64% unreliable and 16.20% reliable cells against 8.69% and 12.02% for mPFC-p.

Identity decoding¶

Pseudo-populations of normalized fluorescence, matched as above; a linear SVM (SVC(kernel='linear')) decodes the 8 odors from each cell's mean in a window, with 5-fold stratified cross-validation; each repeat draws 75 cells of the group without replacement and a new fold split, and its accuracy is the mean over folds.

In [14]:
PX = {g: pseudo(ID, g)[1] for g in GROUPS}
tabX, _ = pseudo(ID, "OB")
y_id = tabX.stim_name.to_numpy()
# the sessions share the onset-aligned frame grid (same frame count before and after onset)
print("frames per trial:", {len(s["t"]) for s in ID}, "| pre-onset frames:", {s["n_pre"] for s in ID})
t_id = ID[0]["t"]
print({g: PX[g].shape for g in GROUPS}, "| chance 12.5%")
frames per trial: {91} | pre-onset frames: {23}
{'OB': (81, 64, 91), 'mPFC': (84, 64, 91), 'untagged': (1937, 64, 91)} | chance 12.5%

fig2h-identity-decoding-5s¶

Odor identity decoded from 5 s windows reaches similar accuracy in size-matched OB-p and mPFC-p pseudo-populations, above chance and slightly below untagged.

200 repeats of 75 cells, windows (a) 0 to 5 s (legend) and (b) 1 to 5 s (Methods).

In [15]:
rng_h = np.random.default_rng(2008)
ACC5 = {}
for wname, win in [("a: 0-5 s", (0, 5)), ("b: 1-5 s", (1, 5))]:
    for g in GROUPS:
        ACC5[wname, g] = pcx.decode_windows(PX[g], y_id, t_id, [win], 75, 200, rng_h)[:, 0]
    print(wname, {g: round(100 * ACC5[wname, g].mean(), 2) for g in GROUPS},
          "| OB vs mPFC p =", f"{pcx.mwu(ACC5[wname, 'OB'], ACC5[wname, 'mPFC']):.4g}",
          "| OB vs untagged p =", f"{pcx.mwu(ACC5[wname, 'OB'], ACC5[wname, 'untagged']):.3g}",
          "| mPFC vs untagged p =", f"{pcx.mwu(ACC5[wname, 'mPFC'], ACC5[wname, 'untagged']):.3g}")
    for g in GROUPS:
        tt = stats.ttest_1samp(ACC5[wname, g], 0.125, alternative="greater")
        print(f"   {g}: min {ACC5[wname, g].min():.3f}, max {ACC5[wname, g].max():.3f}, one-sided t-test against 12.5% p = {tt.pvalue:.3g}")
a: 0-5 s {'OB': np.float64(25.66), 'mPFC': np.float64(25.59), 'untagged': np.float64(41.86)} | OB vs mPFC p = 0.6751 | OB vs untagged p = 3.67e-53 | mPFC vs untagged p = 4.56e-53
   OB: min 0.123, max 0.358, one-sided t-test against 12.5% p = 5.04e-107
   mPFC: min 0.124, max 0.360, one-sided t-test against 12.5% p = 5.84e-103
   untagged: min 0.171, max 0.747, one-sided t-test against 12.5% p = 1.14e-101
b: 1-5 s {'OB': np.float64(28.49), 'mPFC': np.float64(31.07), 'untagged': np.float64(49.04)} | OB vs mPFC p = 9.739e-09 | OB vs untagged p = 2.81e-61 | mPFC vs untagged p = 1.32e-56
   OB: min 0.156, max 0.392, one-sided t-test against 12.5% p = 1.77e-126
   mPFC: min 0.172, max 0.423, one-sided t-test against 12.5% p = 9.52e-128
   untagged: min 0.249, max 0.751, one-sided t-test against 12.5% p = 4.15e-120

Result: blocked (methods underspecified). The two windows disagree. With 0 to 5 s (legend) OB-p and mPFC-p reach 25.7% and 25.6%, p = 0.675, no difference; with 1 to 5 s (Methods) 28.5% and 31.1%, p = 9.7e-09. Under both, every group is above 12.5% (p < 1e-100) and below untagged (41.9% and 49.0%). The criterion blocks the claim when the windows disagree.

fig2i-identity-decoding-early¶

In an early window (0 to 2 s) OB-p pseudo-populations decode odor identity better than mPFC-p pseudo-populations.

In [16]:
rng_i = np.random.default_rng(2009)
ACC2 = {g: pcx.decode_windows(PX[g], y_id, t_id, [(0, 2)], 75, 200, rng_i)[:, 0] for g in GROUPS}
print({g: round(100 * ACC2[g].mean(), 2) for g in GROUPS},
      "| OB vs mPFC two-sided MWU p =", f"{pcx.mwu(ACC2['OB'], ACC2['mPFC']):.3g}")
print({g: (round(ACC2[g].min(), 3), round(ACC2[g].max(), 3)) for g in GROUPS})
{'OB': np.float64(17.76), 'mPFC': np.float64(16.33), 'untagged': np.float64(25.09)} | OB vs mPFC two-sided MWU p = 5.04e-05
{'OB': (np.float64(0.092), np.float64(0.264)), 'mPFC': (np.float64(0.077), np.float64(0.265)), 'untagged': (np.float64(0.094), np.float64(0.471))}

Result: reproduced. In 0 to 2 s OB-p reaches 17.76% and mPFC-p 16.33% (untagged 25.09%), two-sided Mann-Whitney p = 5.0e-05 over the 200 repeats. The difference is 1.4 points.

fig2j-identity-decoding-peaks-earlier¶

With a sliding window, odor identity decoding accuracy peaks earlier for OB-p than for mPFC-p pseudo-populations.

Non-overlapping windows from 5 s before to 15 s after onset, (a) 250 ms and (b) 500 ms wide, trained and tested on the same window, 75 cells, 100 repeats. At 4.51 Hz a 250 ms window holds one frame (sometimes two, sometimes none; empty windows are dropped, count printed). The peak time is the start of the window with the highest mean accuracy; its 95% interval is that of the per-repeat peak times.

In [17]:
def windows_of(width, t, a=-5.0, b=15.0):
    edges = np.arange(a, b + 1e-9, width)
    wins = [(lo, lo + width) for lo in edges[:-1]]
    keep = [w for w in wins if ((t >= w[0]) & (t < w[1])).any()]
    return keep, len(wins) - len(keep)

SLIDE = {}
for wi, (wname, width) in enumerate([("a: 250 ms", 0.25), ("b: 500 ms", 0.5)]):
    wins, n_empty = windows_of(width, t_id)
    starts = np.array([w[0] for w in wins])
    print(f"{wname}: {len(wins)} windows, {n_empty} empty windows dropped")
    # each group has its own generator (2010 + 10 * window reading + group index); groups run in parallel
    res = Parallel(n_jobs=3)(delayed(pcx.decode_windows)(PX[g], y_id, t_id, wins, 75, 100, np.random.default_rng(2010 + 10 * wi + i))
                             for i, g in enumerate(GROUPS))
    for g, A in zip(GROUPS, res):
        SLIDE[wname, g] = (starts, A)
    for g in GROUPS:
        A = SLIDE[wname, g][1]
        m = A.mean(0)
        pk = starts[np.argmax(m)]
        per = starts[np.argmax(A, 1)]
        print(f"   {g}: peak mean accuracy {100 * m.max():.2f}% at {pk:.2f} s; per-repeat peak times 95% interval "
              f"{np.percentile(per, 2.5):.2f} to {np.percentile(per, 97.5):.2f} s; median {np.median(per):.2f} s")
    print("   OB peak earlier than mPFC:", SLIDE[wname, "OB"][0][np.argmax(SLIDE[wname, "OB"][1].mean(0))] <
          SLIDE[wname, "mPFC"][0][np.argmax(SLIDE[wname, "mPFC"][1].mean(0))])

print("clock check (identity decoding before and after onset, 500 ms windows):")
st, _ = SLIDE["b: 500 ms", "OB"]
for g in GROUPS:
    A = SLIDE["b: 500 ms", g][1]
    print(f"   {g}: mean accuracy over windows starting -5 to 0 s {100 * A[:, st < 0].mean():.2f}%, 0 to 2 s {100 * A[:, (st >= 0) & (st < 2)].mean():.2f}% (chance 12.5%)")
fig, axs = plt.subplots(1, 2, figsize=(11, 3.5))
for ax, wname in zip(axs, ["a: 250 ms", "b: 500 ms"]):
    for g, c in zip(GROUPS, ["tab:cyan", "tab:pink", "gray"]):
        st, A = SLIDE[wname, g]
        ax.plot(st, 100 * A.mean(0), color=c, label=g)
    ax.axhline(12.5, ls="--", color="k"); ax.set_title(wname); ax.set_xlabel("window start (s from onset)")
    ax.set_ylabel("accuracy (%)"); ax.legend()
plt.show()
print("plotted mean accuracies range:", {k: (round(100 * v[1].mean(0).min(), 1), round(100 * v[1].mean(0).max(), 1)) for k, v in SLIDE.items()})
a: 250 ms: 80 windows, 0 empty windows dropped
   OB: peak mean accuracy 41.58% at 5.75 s; per-repeat peak times 95% interval 3.87 to 7.00 s; median 5.75 s
   mPFC: peak mean accuracy 38.58% at 9.25 s; per-repeat peak times 95% interval 2.12 to 12.17 s; median 7.62 s
   untagged: peak mean accuracy 51.42% at 2.50 s; per-repeat peak times 95% interval 2.00 to 8.41 s; median 3.25 s
   OB peak earlier than mPFC: True
b: 500 ms: 40 windows, 0 empty windows dropped
   OB: peak mean accuracy 40.12% at 5.50 s; per-repeat peak times 95% interval 3.50 to 7.00 s; median 5.50 s
   mPFC: peak mean accuracy 37.50% at 9.00 s; per-repeat peak times 95% interval 2.00 to 10.76 s; median 7.00 s
   untagged: peak mean accuracy 50.51% at 3.50 s; per-repeat peak times 95% interval 2.00 to 12.00 s; median 3.50 s
   OB peak earlier than mPFC: True
clock check (identity decoding before and after onset, 500 ms windows):
   OB: mean accuracy over windows starting -5 to 0 s 11.98%, 0 to 2 s 19.28% (chance 12.5%)
   mPFC: mean accuracy over windows starting -5 to 0 s 9.27%, 0 to 2 s 18.81% (chance 12.5%)
   untagged: mean accuracy over windows starting -5 to 0 s 12.01%, 0 to 2 s 26.18% (chance 12.5%)
No description has been provided for this image
plotted mean accuracies range: {('a: 250 ms', 'OB'): (np.float64(8.9), np.float64(41.6)), ('a: 250 ms', 'mPFC'): (np.float64(6.9), np.float64(38.6)), ('a: 250 ms', 'untagged'): (np.float64(11.5), np.float64(51.4)), ('b: 500 ms', 'OB'): (np.float64(9.3), np.float64(40.1)), ('b: 500 ms', 'mPFC'): (np.float64(7.0), np.float64(37.5)), ('b: 500 ms', 'untagged'): (np.float64(11.3), np.float64(50.5))}

Result: reproduced. The mean curve peaks at 5.75 s for OB-p and 9.25 s for mPFC-p (250 ms windows), and at 5.50 and 9.00 s (500 ms windows). The per-repeat peak times overlap widely (250 ms: OB-p 3.87 to 7.00 s, mPFC-p 2.12 to 12.17 s; medians 5.75 and 7.62 s), so the mPFC-p peak time is poorly determined. Untagged peaks earliest (2.50 and 3.50 s). The clock check holds: before onset all groups are at or below chance (9.3 to 12.0%), and 0 to 2 s after onset they are above it (18.8 to 26.2%).

fig2k-mpfc-late-identity¶

Late in the trial, mPFC-p pseudo-populations keep low but above-chance identity decoding that exceeds OB-p decoding.

From the same-window accuracies above: per repeat, the mean over windows starting within (a) 2 to 15 s or (b) 5 to 15 s after onset. One-sample one-sided t-test of mPFC-p against 12.5% and two-sided Mann-Whitney U of mPFC-p against OB-p.

In [18]:
for wname in SLIDE.keys() if False else ["a: 250 ms", "b: 500 ms"]:
    for lname, (lo, hi) in [("a: 2-15 s", (2, 15)), ("b: 5-15 s", (5, 15))]:
        st = SLIDE[wname, "OB"][0]
        sel = (st >= lo) & (st < hi)
        mp = SLIDE[wname, "mPFC"][1][:, sel].mean(1)
        ob = SLIDE[wname, "OB"][1][:, sel].mean(1)
        un = SLIDE[wname, "untagged"][1][:, sel].mean(1)
        print(f"window {wname}, late {lname}: mPFC {100 * mp.mean():.2f}%, OB {100 * ob.mean():.2f}%, untagged {100 * un.mean():.2f}%; "
              f"mPFC > 12.5% p = {stats.ttest_1samp(mp, 0.125, alternative='greater').pvalue:.3g}; "
              f"mPFC vs OB p = {pcx.mwu(mp, ob):.3g}")
window a: 250 ms, late a: 2-15 s: mPFC 32.98%, OB 30.91%, untagged 41.30%; mPFC > 12.5% p = 1.9e-93; mPFC vs OB p = 9.39e-10
window a: 250 ms, late b: 5-15 s: mPFC 32.58%, OB 30.81%, untagged 38.77%; mPFC > 12.5% p = 6.27e-90; mPFC vs OB p = 2.51e-06
window b: 500 ms, late a: 2-15 s: mPFC 32.51%, OB 30.95%, untagged 41.67%; mPFC > 12.5% p = 1.8e-97; mPFC vs OB p = 3.19e-08
window b: 500 ms, late b: 5-15 s: mPFC 31.94%, OB 30.76%, untagged 39.45%; mPFC > 12.5% p = 1.66e-92; mPFC vs OB p = 3.8e-05

Result: reproduced. Late in the trial mPFC-p reaches 31.9 to 33.0% under the four combinations of readings, above 12.5% (p <= 1.7e-88) and above OB-p (30.8 to 31.0%, p <= 3.8e-05). The differences are 1.2 to 2.1 points, and untagged is higher than both (38.8 to 41.7%).

30 Hz dataset: calcium peaks¶

Peaks are found per trial on normalized fluorescence with scipy.signal.find_peaks, using the Methods' minimum criteria as its arguments: width 100 ms, distance 1 s, height 0.5, prominence 0.25. The first second of each trial is left out (the trace starts 4 s before onset; trials start about 5.1 s before onset), and the trace ends 15 s after onset, more than a second before each trial's end. Odor trials only (bad and control trials left out).

In [19]:
FAST = pcx.load_experiment(S, "fast_hz_sniff_trig_dataset")
print([(s["meta"]["subject"], s["meta"]["projection_area"], s["X"].shape, round(s["fs"], 2),
        int(s["trials"].is_bad_trial.sum())) for s in FAST])
print("trials whose -5 to 15 s window runs past the recording's ends:", sum(s["n_clipped"] for s in FAST), "of", sum(len(s["trials"]) for s in FAST))
# what the onset is in these files: the trials table's columns and one trial
tf = FAST[0]["trials"]
print("trials-table columns of the 30 Hz files:", sorted(set.union(*[set(s["trials"].columns) for s in FAST])))
print(f"one trial (sub-{FAST[0]['meta']['subject']}, trial 1):")
print(tf.drop(columns=[c for c in tf.columns if tf[c].dtype == object and c not in ("stim_name",)]).iloc[[1]].T.to_string())
# The files also hold acquisition/sniff_on (0/1 at 1 kHz) and the flow signal: the onset is checked against the sniff
# signal's rising edges.
for s, aid in zip(FAST, S[S.experiment_name == "fast_hz_sniff_trig_dataset"].asset_id):
    g = pcx.open_h5(aid)["acquisition/sniff_on"]
    d, ts = g["data"][:], g["timestamps"][:]
    up = ts[1:][(d[1:] > 0.5) & (d[:-1] <= 0.5)]
    on = s["trials"].stim_onset_timestamp.to_numpy()
    lag = on - up[np.searchsorted(up, on + 1e-9, side="right") - 1]
    print(f"   sub-{s['meta']['subject']}: sniff_on values {np.unique(d).tolist()}, {len(up)} rising edges (median interval {np.median(np.diff(up)):.3f} s); "
          f"odor onset minus the last rising edge: {1000 * lag.min():.0f} to {1000 * lag.max():.0f} ms over {len(on)} trials")
peak_rows = []
for s in FAST:
    tr = s["trials"]
    keep = (~tr.is_bad_trial.astype(bool) & ~tr.is_control).to_numpy()
    fs, t = s["fs"], s["t"]
    seg = t >= -4.0
    ts = t[seg]
    for c in range(s["X"].shape[0]):
        for k in np.where(keep)[0]:
            pk, _ = signal.find_peaks(s["X"][c, k, seg], width=0.1 * fs, distance=1.0 * fs, height=0.5, prominence=0.25)
            peak_rows.append(dict(subject=s["meta"]["subject"], cell=c, trial=k,
                                  group=s["cells"].projection.iloc[c], peaks=ts[pk]))
PK = pd.DataFrame(peak_rows)
PK["first_after"] = PK.peaks.apply(lambda p: p[p >= 0][0] if (p >= 0).any() else np.nan)
print("cell-trials:", len(PK), "| with a peak after onset:", int(PK.first_after.notna().sum()))
print(PK.groupby("group").agg(cells=("cell", lambda x: 0), cell_trials=("trial", "size"),
                              with_peak=("first_after", lambda x: int(x.notna().sum()))).drop(columns="cells").to_string())
[('2372', 'OB', (46, 100, 593), np.float64(29.65), 1), ('2400', 'OB', (118, 100, 593), np.float64(29.65), 0), ('2401', 'OB', (78, 100, 595), np.float64(29.76), 0), ('2456', 'mPFC', (120, 100, 593), np.float64(29.65), 1), ('2457', 'mPFC', (113, 100, 593), np.float64(29.65), 0)]
trials whose -5 to 15 s window runs past the recording's ends: 0 of 500
trials-table columns of the 30 Hz files: ['conc', 'is_bad_trial', 'is_control', 'odor_raw_id', 'start_time', 'stim_name', 'stim_offset_frame', 'stim_offset_timestamp', 'stim_onset_frame', 'stim_onset_timestamp', 'stim_types', 'stop_time']
one trial (sub-2372, trial 1):
                                  1
start_time                   37.001
stop_time                      60.0
stim_onset_frame                150
stim_offset_frame               209
stim_onset_timestamp         42.051
stim_offset_timestamp         44.05
is_bad_trial                  False
odor_raw_id                       2
stim_name              Acetophenone
conc                           0.01
is_control                    False
   sub-2372: sniff_on values [0.0, 1.0], 10378 rising edges (median interval 0.141 s); odor onset minus the last rising edge: 1 to 9 ms over 100 trials
   sub-2400: sniff_on values [0.0, 1.0], 8901 rising edges (median interval 0.251 s); odor onset minus the last rising edge: 1 to 8 ms over 100 trials
   sub-2401: sniff_on values [0.0, 1.0], 8920 rising edges (median interval 0.221 s); odor onset minus the last rising edge: 1 to 10 ms over 100 trials
   sub-2456: sniff_on values [0.0, 1.0], 7009 rising edges (median interval 0.322 s); odor onset minus the last rising edge: 1 to 10 ms over 100 trials
   sub-2457: sniff_on values [0.0, 1.0], 7136 rising edges (median interval 0.322 s); odor onset minus the last rising edge: 1 to 8 ms over 100 trials
cell-trials: 37954 | with a peak after onset: 29433
          cell_trials  with_peak
group                           
OB               1914       1557
mPFC             2160       1492
untagged        33880      26384

fig2f-latency¶

In the 30 Hz data OB-p neurons reach their first calcium peak after odor onset sooner than mPFC-p neurons; OB-p and untagged neurons do not differ.

Latency of the first peak after onset, (a) per trial (every trial with a peak) and (b) per neuron (median over its trials with a peak). Two-sided Mann-Whitney U, Bonferroni over the 3 pairs.

In [20]:
lat_a = {g: PK.loc[PK.group == g, "first_after"].dropna().to_numpy() for g in GROUPS}
nb = PK.dropna(subset=["first_after"]).groupby(["group", "subject", "cell"]).first_after.median().reset_index()
lat_b = {g: nb.loc[nb.group == g, "first_after"].to_numpy() for g in GROUPS}
for name, v in [("a: per trial", lat_a), ("b: per neuron", lat_b)]:
    print(name, {g: len(v[g]) for g in GROUPS})
    print(pair_tests(v).to_string(index=False))
print("per mouse median latency per trial (s):")
print(PK.dropna(subset=["first_after"]).groupby(["group", "subject"]).first_after.median().round(2).to_string())
# Projection is confounded with mouse here: each mouse holds one projection group and untagged cells.
print("\nwithin each mouse, projection neurons against the same mouse's untagged neurons (per trial, two-sided Mann-Whitney):")
lat = PK.dropna(subset=["first_after"])
for subj in sorted(lat.subject.unique()):
    d = lat[lat.subject == subj]
    tag, unt = d[d.group != "untagged"], d[d.group == "untagged"]
    print(f"   sub-{subj} ({tag.group.iloc[0]}-p): median {tag.first_after.median():.2f} s (n = {len(tag)}), "
          f"untagged {unt.first_after.median():.2f} s (n = {len(unt)}), p = {pcx.mwu(tag.first_after, unt.first_after):.2g}")
a: per trial {'OB': 1557, 'mPFC': 1492, 'untagged': 26384}
            pair  median_a  median_b   mean_a   mean_b            p  p_bonferroni
      OB vs mPFC  3.575478  4.654866 4.159209 5.140370 1.020518e-16  3.061553e-16
  OB vs untagged  3.575478  3.609208 4.159209 4.334303 5.702398e-01  1.000000e+00
mPFC vs untagged  4.654866  3.609208 5.140370 4.334303 9.071524e-23  2.721457e-22
b: per neuron {'OB': 24, 'mPFC': 27, 'untagged': 424}
            pair  median_a  median_b   mean_a   mean_b        p  p_bonferroni
      OB vs mPFC  3.836891  4.621135 3.925110 4.720455 0.009995      0.029986
  OB vs untagged  3.836891  3.998717 3.925110 4.065697 0.639528      1.000000
mPFC vs untagged  4.621135  3.998717 4.720455 4.065697 0.005927      0.017781
per mouse median latency per trial (s):
group     subject
OB        2372       2.70
          2400       3.51
          2401       4.96
mPFC      2456       4.59
          2457       4.79
untagged  2372       2.70
          2400       2.97
          2401       3.73
          2456       4.82
          2457       4.12

within each mouse, projection neurons against the same mouse's untagged neurons (per trial, two-sided Mann-Whitney):
   sub-2372 (OB-p): median 2.70 s (n = 451), untagged 2.70 s (n = 2401), p = 0.55
   sub-2400 (OB-p): median 3.51 s (n = 676), untagged 2.97 s (n = 7736), p = 0.00034
   sub-2401 (OB-p): median 4.96 s (n = 430), untagged 3.73 s (n = 4073), p = 8e-16
   sub-2456 (mPFC-p): median 4.59 s (n = 762), untagged 4.82 s (n = 5945), p = 0.46
   sub-2457 (mPFC-p): median 4.79 s (n = 730), untagged 4.12 s (n = 6229), p = 0.00065

Result: reproduced. (a) Per trial, the median latency is 3.58 s for OB-p and 4.65 s for mPFC-p, corrected p = 3.1e-16; OB-p against untagged (3.61 s) has corrected p = 1.0. (b) Per neuron, 3.84 against 4.62 s, corrected p = 0.030, and OB-p against untagged p = 1.0. By mouse, the OB-p medians are 2.70 to 4.96 s and the mPFC-p medians 4.59 to 4.79 s. The odor onset of the 30 Hz files falls 1 to 10 ms after a rising edge of the files' sniff signal (acquisition/sniff_on) in every trial, so the latencies are measured from a sniff-aligned onset, as the paper describes. Projection is confounded with mouse: sub-2456 and sub-2457 are the only mPFC mice of this dataset, and their untagged neurons are slow too (medians 4.82 and 4.12 s, against 2.70 to 3.73 s in the three OB mice). Within each mouse OB-p is not faster than the untagged neurons: 2.70 against 2.70 s (p = 0.55), and slower in the other two, 3.51 against 2.97 s (p = 0.00034) and 4.96 against 3.73 s (p = 8e-16). mPFC-p is as slow as its own mouse's untagged neurons or slower: 4.59 against 4.82 s (p = 0.46) and 4.79 against 4.12 s (p = 0.00065). The criterion pools neurons, so the outcome stands, but the latency difference follows the mouse at least as much as the projection.

fig2g-early-peaks¶

OB-p neurons have more calcium peaks at early time points after odor onset than mPFC-p neurons.

Peaks per trial in (a) 0 to 2 s and (b) 0 to 3 s after onset, averaged per neuron. The two-sided Mann-Whitney U test of the per-neuron means is shown as a reference; the claim is judged on the means.

In [21]:
for name, (lo, hi) in [("a: 0-2 s", (0, 2)), ("b: 0-3 s", (0, 3))]:
    PK["n_early"] = PK.peaks.apply(lambda p: int(((p >= lo) & (p < hi)).sum()))
    per = PK.groupby(["group", "subject", "cell"]).n_early.mean().reset_index()
    v = {g: per.loc[per.group == g, "n_early"].to_numpy() for g in GROUPS}
    print(name, "mean peaks per trial per neuron:", {g: round(v[g].mean(), 4) for g in GROUPS},
          "| OB vs mPFC p =", f"{pcx.mwu(v['OB'], v['mPFC']):.3g}")
    print("   per mouse:", per.groupby(["group", "subject"]).n_early.mean().round(3).to_dict())
bins = np.arange(-4, 15.01, 0.5)
hist = {g: np.histogram(np.concatenate(PK.loc[PK.group == g, "peaks"].to_list()), bins)[0] /
        PK.loc[PK.group == g].shape[0] for g in GROUPS}
fig, ax = plt.subplots(figsize=(6, 3))
for g, c in zip(GROUPS, ["tab:cyan", "tab:pink", "gray"]):
    ax.plot(bins[:-1], hist[g], color=c, label=g)
ax.set_xlabel("time from onset (s), 0.5 s bins"); ax.set_ylabel("peaks per trial"); ax.legend(); plt.show()
print("plotted range:", {g: (round(h.min(), 4), round(h.max(), 4)) for g, h in hist.items()})
a: 0-2 s mean peaks per trial per neuron: {'OB': np.float64(0.1983), 'mPFC': np.float64(0.138), 'untagged': np.float64(0.2152)} | OB vs mPFC p = 0.168
   per mouse: {('OB', '2372'): 0.291, ('OB', '2400'): 0.242, ('OB', '2401'): 0.073, ('mPFC', '2456'): 0.117, ('mPFC', '2457'): 0.161, ('untagged', '2372'): 0.242, ('untagged', '2400'): 0.289, ('untagged', '2401'): 0.191, ('untagged', '2456'): 0.166, ('untagged', '2457'): 0.194}
b: 0-3 s mean peaks per trial per neuron: {'OB': np.float64(0.3487), 'mPFC': np.float64(0.2032), 'untagged': np.float64(0.3448)} | OB vs mPFC p = 0.0258
   per mouse: {('OB', '2372'): 0.58, ('OB', '2400'): 0.391, ('OB', '2401'): 0.122, ('mPFC', '2456'): 0.165, ('mPFC', '2457'): 0.244, ('untagged', '2372'): 0.464, ('untagged', '2400'): 0.491, ('untagged', '2401'): 0.307, ('untagged', '2456'): 0.216, ('untagged', '2457'): 0.302}
No description has been provided for this image
plotted range: {'OB': (np.float64(0.0084), np.float64(0.092)), 'mPFC': (np.float64(0.0028), np.float64(0.0792)), 'untagged': (np.float64(0.0074), np.float64(0.0755))}

Result: reproduced. Mean peaks per trial per neuron, 0 to 2 s: OB-p 0.198, mPFC-p 0.138 (Mann-Whitney p = 0.17); 0 to 3 s: 0.349 and 0.203 (p = 0.026). The difference rests on two of the three OB-p mice: sub-2401 has fewer early peaks (0.073 and 0.122) than either mPFC-p mouse. As for the latencies, the groups are confounded with mouse: in 0 to 3 s the untagged neurons of the two mPFC mice also have few early peaks (0.216 and 0.302), against 0.464 and 0.491 in sub-2372 and sub-2400 and 0.307 in sub-2401.

Concentration dataset¶

Three odorants at three concentrations (stored as fractions 0.001, 0.01 and 0.1, the 0.1%, 1% and 10% of the Figure 3 and S5 legends) and a control.

In [22]:
CO = pcx.load_experiment(S, "concentration_dataset")
for s in CO:
    tr = s["trials"]
    s["keep"] = (~tr.is_bad_trial.astype(bool) & ~tr.is_control).to_numpy()
    s["good"] = (~tr.is_bad_trial.astype(bool)).to_numpy()
    tr["stim"] = tr.stim_name + " " + tr.conc.astype(str)
print(pd.DataFrame([dict(subject=s["meta"]["subject"], proj=s["meta"]["projection_area"], cells=len(s["cells"]),
                         red=int(s["cells"].red.sum()), bad=int(s["trials"].is_bad_trial.sum()),
                         stimuli=s["trials"][s["keep"]].stim.nunique(),
                         min_trials=int(s["trials"][s["keep"]].stim.value_counts().min()),
                         fs=round(s["fs"], 3)) for s in CO]).to_string(index=False))
print("concentrations:", sorted(CO[0]["trials"].conc.dropna().unique()))
print("trials whose -5 to 15 s window runs past the recording's ends:", sum(s["n_clipped"] for s in CO), "of", sum(len(s["trials"]) for s in CO))
for s in CO:
    tr = s["trials"][s["keep"]]
    rho = stats.spearmanr(tr.index, tr.conc)
    print(f"   sub-{s['meta']['subject']}: Spearman correlation of trial number with concentration {rho.statistic:+.2f} (p = {rho.pvalue:.2g}); "
          f"mean trial number at 0.1%, 1%, 10%: {tr.groupby('conc').apply(lambda d: d.index.to_series().mean()).round(1).tolist()}")
subject proj  cells  red  bad  stimuli  min_trials    fs
   2372   OB     75   11    1        9           9 4.513
   2400   OB    234   21    1        9           9 4.521
   2401   OB    207   19    0        9          10 4.521
   2456 mPFC    209   18    0        9          10 4.513
   2457 mPFC    175   19    0        9          10 4.513
    443 mPFC    206   18    0        9          10 4.513
    512 mPFC    245   17    0        9          10 4.513
    513   OB    310   20    1        9           9 4.513
    514   OB    225   16    1        9           9 4.513
    644 mPFC    435   30    0        9          10 4.513
concentrations: [np.float64(0.001), np.float64(0.01), np.float64(0.1)]
trials whose -5 to 15 s window runs past the recording's ends: 0 of 1000
   sub-2372: Spearman correlation of trial number with concentration -0.01 (p = 0.95); mean trial number at 0.1%, 1%, 10%: [49.7, 51.5, 49.1]
   sub-2400: Spearman correlation of trial number with concentration -0.00 (p = 0.98); mean trial number at 0.1%, 1%, 10%: [49.9, 49.6, 49.6]
   sub-2401: Spearman correlation of trial number with concentration +0.02 (p = 0.85); mean trial number at 0.1%, 1%, 10%: [48.8, 49.4, 50.2]
   sub-2456: Spearman correlation of trial number with concentration +0.00 (p = 1); mean trial number at 0.1%, 1%, 10%: [50.3, 48.0, 50.4]
   sub-2457: Spearman correlation of trial number with concentration +0.01 (p = 0.93); mean trial number at 0.1%, 1%, 10%: [48.4, 50.0, 49.0]
   sub-443: Spearman correlation of trial number with concentration -0.01 (p = 0.91); mean trial number at 0.1%, 1%, 10%: [49.7, 49.8, 48.9]
   sub-512: Spearman correlation of trial number with concentration -0.01 (p = 0.9); mean trial number at 0.1%, 1%, 10%: [49.8, 50.1, 48.8]
   sub-513: Spearman correlation of trial number with concentration +0.00 (p = 0.96); mean trial number at 0.1%, 1%, 10%: [49.9, 48.6, 50.3]
   sub-514: Spearman correlation of trial number with concentration -0.01 (p = 0.9); mean trial number at 0.1%, 1%, 10%: [50.3, 49.5, 49.1]
   sub-644: Spearman correlation of trial number with concentration -0.01 (p = 0.96); mean trial number at 0.1%, 1%, 10%: [49.7, 49.9, 49.3]

fig3bc-concentration-tuning¶

Similar fractions of OB-p and mPFC-p neurons are tuned to odor identity, but OB-p neurons more often show significant effects of concentration and identity by concentration interactions, which are rare in mPFC-p neurons.

Per neuron, a two-way ANOVA (identity by concentration, with interaction; type II sums of squares, the same as any type for a balanced design) on mean normalized fluorescence 0 to 5 s after onset, p < 0.05 per term. Time-resolved version in non-overlapping windows of (a) 500 ms and (b) 1 s.

In [23]:
def anova2(Y, A, B):
    """Type II two-way ANOVA with interaction for every column of Y (trials x cells)."""
    a = pd.get_dummies(pd.Categorical(A), drop_first=True).to_numpy(float)
    b = pd.get_dummies(pd.Categorical(B), drop_first=True).to_numpy(float)
    ab = np.einsum("ti,tj->tij", a, b).reshape(len(A), -1)
    one = np.ones((len(A), 1))
    def rss(M):
        beta, *_ = np.linalg.lstsq(M, Y, rcond=None)
        return ((Y - M @ beta) ** 2).sum(0)
    r_a, r_b = rss(np.hstack([one, a])), rss(np.hstack([one, b]))
    r_ab = rss(np.hstack([one, a, b]))
    full = np.hstack([one, a, b, ab])
    r_full = rss(full)
    df_res = len(A) - np.linalg.matrix_rank(full)
    out = {}
    for name, ss, df in [("identity", r_b - r_ab, a.shape[1]), ("concentration", r_a - r_ab, b.shape[1]),
                         ("interaction", r_ab - r_full, ab.shape[1])]:
        F = (ss / df) / (r_full / df_res)
        out[name] = stats.f.sf(F, df, df_res)
    return out

def tuning_fractions(win):
    rows = []
    for s in CO:
        tr = s["trials"][s["keep"]]
        Y = pcx.window_mean(s["X"][:, s["keep"]], s["t"], *win).T
        P = anova2(Y, tr.stim_name.to_numpy(), tr.conc.to_numpy())
        rows.append(pd.DataFrame(dict(group=s["cells"].projection.values, **{k: v < 0.05 for k, v in P.items()})))
    D = pd.concat(rows)
    return 100 * D.groupby("group")[["identity", "concentration", "interaction"]].mean()

F05 = tuning_fractions((0, 5))
print("percent of neurons with p < 0.05, 0 to 5 s:")
print(F05.round(2).to_string())
d_id = abs(F05.loc["OB", "identity"] - F05.loc["mPFC", "identity"])
d_conc = abs(F05.loc["OB", "concentration"] - F05.loc["mPFC", "concentration"])
print(f"OB > mPFC for concentration: {F05.loc['OB', 'concentration'] > F05.loc['mPFC', 'concentration']}; "
      f"for interaction: {F05.loc['OB', 'interaction'] > F05.loc['mPFC', 'interaction']}; "
      f"|OB - mPFC| identity {d_id:.2f} < concentration {d_conc:.2f}: {d_id < d_conc}")
for wname, width in [("a: 500 ms", 0.5), ("b: 1 s", 1.0)]:
    edges = np.arange(-2, 15 + 1e-9, width)
    tc = {lo: tuning_fractions((lo, lo + width)) for lo in edges[:-1]}
    tcd = pd.concat(tc, names=["start"]).unstack("group")
    print(f"\n{wname}: time course of percent significant (rows: window start, s)")
    print(tcd.round(1).to_string())
    post = tcd[tcd.index >= 0]
    print("mean over windows 0 to 15 s:", post.mean().round(2).to_dict())
percent of neurons with p < 0.05, 0 to 5 s:
          identity  concentration  interaction
group                                         
OB           17.24          10.34         9.20
mPFC         15.69           6.86         6.86
untagged     22.19          11.26        10.46
OB > mPFC for concentration: True; for interaction: True; |OB - mPFC| identity 1.56 < concentration 3.48: True
a: 500 ms: time course of percent significant (rows: window start, s)
      identity                concentration                interaction               
group       OB  mPFC untagged            OB  mPFC untagged          OB  mPFC untagged
start                                                                                
-2.0       3.4   3.9      4.1           3.4   6.9      4.2         3.4   4.9      4.9
-1.5       3.4   2.9      4.4           5.7   5.9      4.6         3.4   3.9      4.6
-1.0       1.1   4.9      4.1           6.9   7.8      4.9         3.4   2.9      4.9
-0.5       2.3   3.9      4.2           8.0   9.8      5.2         3.4   2.9      4.3
 0.0       2.3   6.9      4.6           4.6   6.9      5.5         4.6   2.0      3.9
 0.5       6.9  13.7     10.0           5.7   7.8      6.9         6.9   4.9      5.3
 1.0       9.2  13.7     15.8          10.3   8.8      9.0        10.3   7.8      7.8
 1.5      17.2  11.8     22.1          12.6   4.9     10.3        13.8   7.8     10.4
 2.0      25.3  12.7     25.5          14.9   6.9     11.1        11.5   6.9     10.2
 2.5      21.8  14.7     26.8          16.1   8.8     13.2        17.2   7.8     11.1
 3.0      17.2  18.6     27.3          11.5   8.8     14.4        12.6   8.8     12.3
 3.5      23.0  22.5     28.7          12.6   6.9     15.4        12.6   6.9     15.7
 4.0      26.4  20.6     30.0          13.8   8.8     15.8        12.6   8.8     16.4
 4.5      26.4  22.5     31.2          14.9   9.8     15.3        12.6   7.8     16.8
 5.0      26.4  24.5     31.7          10.3  11.8     15.7        14.9  10.8     16.2
 5.5      24.1  24.5     31.3           6.9  13.7     15.6        12.6  11.8     16.2
 6.0      23.0  26.5     29.9           6.9  12.7     16.3        12.6  14.7     15.4
 6.5      20.7  23.5     28.3           9.2  12.7     15.6         9.2  12.7     15.8
 7.0      17.2  23.5     28.1           8.0  10.8     15.2         6.9   8.8     15.2
 7.5      16.1  25.5     27.4           6.9   8.8     15.7         8.0   8.8     15.0
 8.0      17.2  24.5     27.4           9.2  11.8     16.7        10.3   8.8     14.3
 8.5      17.2  26.5     26.4           8.0   9.8     15.5        11.5   7.8     13.6
 9.0      17.2  23.5     25.7           6.9  10.8     15.1        11.5   9.8     13.5
 9.5      18.4  22.5     25.1          10.3  14.7     13.7        11.5  11.8     13.9
 10.0     16.1  23.5     24.1           9.2  11.8     12.4         9.2  10.8     14.1
 10.5     16.1  24.5     22.7           9.2   9.8     12.2        10.3  11.8     13.5
 11.0     17.2  23.5     22.6           9.2  10.8     12.1         9.2  11.8     12.9
 11.5     17.2  26.5     21.9          11.5   9.8     12.3         6.9  12.7     12.3
 12.0     18.4  23.5     21.7          13.8   9.8     11.6         8.0  12.7     10.9
 12.5     16.1  22.5     20.3          10.3   8.8     11.1         8.0  12.7     10.3
 13.0     13.8  26.5     18.9          10.3   5.9     10.3         8.0  11.8      9.7
 13.5     16.1  25.5     18.1          12.6   7.8     10.0         6.9  14.7      9.1
 14.0     17.2  22.5     17.4          11.5   7.8      9.8         6.9  13.7      9.5
 14.5     18.4  22.5     17.7          10.3   7.8      8.9         6.9  11.8      9.6
mean over windows 0 to 15 s: {('identity', 'OB'): 18.01, ('identity', 'mPFC'): 21.47, ('identity', 'untagged'): 23.62, ('concentration', 'OB'): 10.27, ('concentration', 'mPFC'): 9.54, ('concentration', 'untagged'): 12.76, ('interaction', 'OB'): 10.15, ('interaction', 'mPFC'): 10.0, ('interaction', 'untagged'): 12.36}
b: 1 s: time course of percent significant (rows: window start, s)
      identity                concentration                interaction               
group       OB  mPFC untagged            OB  mPFC untagged          OB  mPFC untagged
start                                                                                
-2.0       3.4   2.9      4.0           5.7   7.8      4.4         3.4   3.9      4.8
-1.0       1.1   4.9      4.2           8.0   8.8      5.1         3.4   2.0      4.8
 0.0       3.4  10.8      6.2           3.4   7.8      6.0         4.6   2.9      4.5
 1.0      14.9  11.8     20.4          10.3   4.9      9.3        13.8   8.8      9.1
 2.0      25.3  10.8     26.6          14.9   6.9     12.1        14.9   8.8     10.9
 3.0      18.4  19.6     28.8          12.6   7.8     15.0        12.6   8.8     14.9
 4.0      26.4  20.6     30.9          13.8   9.8     15.8        13.8   7.8     16.8
 5.0      24.1  25.5     32.0           9.2  13.7     16.0        13.8  12.7     16.4
 6.0      23.0  24.5     29.1           8.0  12.7     16.2        10.3  12.7     15.7
 7.0      17.2  24.5     27.8           6.9   9.8     15.6         9.2   7.8     15.4
 8.0      18.4  24.5     26.8           6.9  10.8     15.9        11.5   7.8     14.3
 9.0      18.4  24.5     25.5           8.0  13.7     14.5        11.5  11.8     14.4
 10.0     16.1  23.5     23.5          10.3  10.8     12.4        10.3  10.8     13.8
 11.0     18.4  26.5     22.5           9.2  11.8     12.4         8.0  10.8     12.5
 12.0     16.1  22.5     21.1          11.5   9.8     11.6         8.0  11.8     10.6
 13.0     16.1  24.5     18.9          10.3   7.8     10.2         9.2  13.7      9.3
 14.0     17.2  22.5     18.0          11.5   8.8      9.5         8.0  13.7      9.5
mean over windows 0 to 15 s: {('identity', 'OB'): 18.24, ('identity', 'mPFC'): 21.11, ('identity', 'untagged'): 23.88, ('concentration', 'OB'): 9.81, ('concentration', 'mPFC'): 9.8, ('concentration', 'untagged'): 12.83, ('interaction', 'OB'): 10.65, ('interaction', 'mPFC'): 10.07, ('interaction', 'untagged'): 12.54}

Result: reproduced. In 0 to 5 s, 17.2% of OB-p and 15.7% of mPFC-p neurons are tuned to identity, 10.3% and 6.9% to concentration, and 9.2% and 6.9% show an interaction. OB-p exceeds mPFC-p for concentration and interaction, and the identity difference (1.6 points) is smaller than the concentration difference (3.5 points). Over the time course OB-p is higher for concentration mainly 1.5 to 4.5 s after onset (11.5 to 16.1% against 4.9 to 9.8% in 500 ms windows), while the means over 0 to 15 s are close (10.3 and 9.5%; 9.8 and 9.8% in 1 s windows). The mPFC-p interaction fraction (6.9%) is near the 5% expected by chance. Untagged neurons have the highest fractions on all three terms (22.2, 11.3 and 10.5%).

fig3de-concentration-decoding¶

OB-p pseudo-populations decode odor concentration more accurately and earlier than mPFC-p and untagged pseudo-populations, while mPFC-p decoding stays close to chance.

Per odor, a linear SVM decodes the 3 concentrations in non-overlapping windows of (a) 250 ms and (b) 500 ms from 2 s before to 15 s after onset, trained and tested on the same window, 75 cells, 100 repeats; accuracies averaged over the 3 odors; chance 33.3%. Pseudo-population trials are matched by odor and concentration. The same repeats and folds give the pairwise decoders of figs5g-pairwise-concentration.

In [24]:
PC = {}
for g in GROUPS:
    tab_c, P = pcx.pseudo_population(CO, group_masks(CO, g), "stim", [s["keep"] for s in CO])
    PC[g] = P
odor_c = tab_c.stim.str.rsplit(" ", n=1).str[0].to_numpy()
conc_c = tab_c.stim.str.rsplit(" ", n=1).str[1].astype(float).to_numpy()
conc_code = np.round(np.log10(conc_c)).astype(int)   # -3, -2, -1 for 0.1%, 1%, 10%
t_co = CO[0]["t"]
print("pseudo-population trials:", len(tab_c), tab_c.stim.value_counts().min(), "to", tab_c.stim.value_counts().max(), "per stimulus;",
      {g: PC[g].shape[0] for g in GROUPS}, "cells")

def conc_decoding_group(P, width, n_rep, seed):
    wins, _ = windows_of(width, t_co, -2.0, 15.0)
    rng = np.random.default_rng(seed)
    three = np.zeros((n_rep, len(wins)))
    pairs = {pr: np.zeros((n_rep, len(wins))) for pr in [(-3, -2), (-2, -1), (-3, -1)]}
    for o in np.unique(odor_c):
        sel = odor_c == o
        three += pcx.decode_windows(P[:, sel], conc_code[sel], t_co, wins, 75, n_rep, rng) / 3
        for pr in pairs:
            sel2 = sel & np.isin(conc_code, pr)
            pairs[pr] += pcx.decode_windows(P[:, sel2], conc_code[sel2], t_co, wins, 75, n_rep, rng) / 3
    return np.array([w[0] for w in wins]), dict(three=three, pairs=pairs)

def conc_decoding(width, n_rep, seed):
    """Each group has its own generator (seed + group index); the groups run in parallel."""
    res = Parallel(n_jobs=3)(delayed(conc_decoding_group)(PC[g], width, n_rep, seed + i) for i, g in enumerate(GROUPS))
    return res[0][0], {g: r[1] for g, r in zip(GROUPS, res)}

CD = {wname: conc_decoding(width, 100, seed) for wname, width, seed in [("a: 250 ms", 0.25, 3001), ("b: 500 ms", 0.5, 3002)]}
pseudo-population trials: 87 9 to 10 per stimulus; {'OB': 87, 'mPFC': 102, 'untagged': 2132} cells
In [25]:
for wname, (st, out) in CD.items():
    pk = {g: (100 * out[g]["three"].mean(0).max(), st[np.argmax(out[g]["three"].mean(0))]) for g in GROUPS}
    print(wname, "peak mean accuracy (%) and its window start (s):", {g: (round(a, 2), round(b, 2)) for g, (a, b) in pk.items()})
    for g in GROUPS:
        per = st[np.argmax(out[g]["three"], 1)]
        print(f"   {g}: per-repeat peak time 95% interval {np.percentile(per, 2.5):.2f} to {np.percentile(per, 97.5):.2f} s; "
              f"pre-onset mean accuracy {100 * out[g]['three'][:, st < 0].mean():.2f}%")
    mid = (100 / 3 + pk["OB"][0]) / 2
    print(f"   OB peak > mPFC and untagged: {pk['OB'][0] > pk['mPFC'][0] and pk['OB'][0] > pk['untagged'][0]}; "
          f"OB earlier than both: {pk['OB'][1] < pk['mPFC'][1] and pk['OB'][1] < pk['untagged'][1]}; "
          f"mPFC peak {pk['mPFC'][0]:.2f} below midpoint {mid:.2f}: {pk['mPFC'][0] < mid}")
fig, axs = plt.subplots(1, 2, figsize=(11, 3.5))
for ax, (wname, (st, out)) in zip(axs, CD.items()):
    for g, c in zip(GROUPS, ["tab:cyan", "tab:pink", "gray"]):
        ax.plot(st, 100 * out[g]["three"].mean(0), color=c, label=g)
    ax.axhline(100 / 3, ls="--", color="k"); ax.set_title(wname); ax.set_xlabel("window start (s)"); ax.legend()
plt.show()
# The peak of a mean curve over many windows is biased upward. Cross-validated peak: the window is chosen on one half of
# the repeats and its accuracy read on the other half, both ways, averaged.
for wname, (st, out) in CD.items():
    cvp = {}
    for g in GROUPS:
        A = 100 * out[g]["three"]
        h1, h2 = A[:50].mean(0), A[50:].mean(0)
        cvp[g] = ((h2[np.argmax(h1)] + h1[np.argmax(h2)]) / 2, st[np.argmax(h1)], st[np.argmax(h2)])
    mid = (100 / 3 + cvp["OB"][0]) / 2
    print(f"{wname}, cross-validated peak (%), window starts chosen on each half: "
          + "; ".join(f"{g} {a:.2f} ({b:.2f}, {c:.2f} s)" for g, (a, b, c) in cvp.items())
          + f" | mPFC below the midpoint {mid:.2f}: {cvp['mPFC'][0] < mid}")
# Chance of this procedure: concentration labels shuffled within odor, 20 repeats, 500 ms windows before onset and at the
# mPFC-p peak.
rng_cn = np.random.default_rng(3010)
st_b, out_b = CD["b: 500 ms"]
w_pk = st_b[np.argmax(out_b["mPFC"]["three"].mean(0))]
wins_n = [(-2.0, -1.5), (-1.0, -0.5), (w_pk, w_pk + 0.5)]
for g in GROUPS:
    acc = np.zeros((20, len(wins_n)))
    for o in np.unique(odor_c):
        sel = np.where(odor_c == o)[0]
        y_sh = conc_code[sel].copy()
        for r in range(20):
            acc[r] += pcx.decode_windows(PC[g][:, sel], rng_cn.permutation(y_sh), t_co, wins_n, 75, 1, rng_cn)[0] / 3
    print(f"shuffled-label concentration accuracy, {g}: " + ", ".join(f"{a:.1f} to {b:.1f} s {100 * m:.1f}%" for (a, b), m in zip(wins_n, acc.mean(0)))
          + f" (95th percentile {100 * np.percentile(acc, 95):.1f}%)")
a: 250 ms peak mean accuracy (%) and its window start (s): {'OB': (np.float64(61.91), np.float64(3.75)), 'mPFC': (np.float64(53.56), np.float64(9.75)), 'untagged': (np.float64(55.7), np.float64(4.75))}
   OB: per-repeat peak time 95% interval 2.75 to 5.14 s; pre-onset mean accuracy 31.82%
   mPFC: per-repeat peak time 95% interval 2.12 to 13.50 s; pre-onset mean accuracy 37.21%
   untagged: per-repeat peak time 95% interval 2.12 to 13.76 s; pre-onset mean accuracy 34.02%
   OB peak > mPFC and untagged: True; OB earlier than both: True; mPFC peak 53.56 below midpoint 47.62: False
b: 500 ms peak mean accuracy (%) and its window start (s): {'OB': (np.float64(61.96), np.float64(3.5)), 'mPFC': (np.float64(52.36), np.float64(9.5)), 'untagged': (np.float64(53.95), np.float64(4.5))}
   OB: per-repeat peak time 95% interval 2.50 to 4.50 s; pre-onset mean accuracy 31.30%
   mPFC: per-repeat peak time 95% interval 1.74 to 13.00 s; pre-onset mean accuracy 37.60%
   untagged: per-repeat peak time 95% interval 2.24 to 10.76 s; pre-onset mean accuracy 34.13%
   OB peak > mPFC and untagged: True; OB earlier than both: True; mPFC peak 52.36 below midpoint 47.65: False
No description has been provided for this image
a: 250 ms, cross-validated peak (%), window starts chosen on each half: OB 61.91 (3.75, 3.75 s); mPFC 53.56 (9.75, 9.75 s); untagged 55.14 (5.00, 4.75 s) | mPFC below the midpoint 47.62: False
b: 500 ms, cross-validated peak (%), window starts chosen on each half: OB 61.96 (3.50, 3.50 s); mPFC 51.84 (10.00, 9.50 s); untagged 52.92 (4.50, 3.50 s) | mPFC below the midpoint 47.65: False
shuffled-label concentration accuracy, OB: -2.0 to -1.5 s 33.3%, -1.0 to -0.5 s 32.1%, 9.5 to 10.0 s 35.0% (95th percentile 41.4%)
shuffled-label concentration accuracy, mPFC: -2.0 to -1.5 s 33.3%, -1.0 to -0.5 s 35.2%, 9.5 to 10.0 s 32.9% (95th percentile 41.6%)
shuffled-label concentration accuracy, untagged: -2.0 to -1.5 s 34.0%, -1.0 to -0.5 s 35.1%, 9.5 to 10.0 s 32.8% (95th percentile 43.1%)

Result: not reproduced. OB-p peaks highest (61.9% with 250 ms windows, 62.0% with 500 ms) and earliest (3.75 and 3.50 s), ahead of untagged (55.7% at 4.75 s; 54.0% at 4.50 s) and mPFC-p (53.6% at 9.75 s; 52.4% at 9.50 s). mPFC-p is not close to chance by the criterion's bound: its peak exceeds the midpoint between chance and the OB-p peak (47.6% under both readings), so the criterion's third condition fails under both window readings. Choosing the peak window on one half of the repeats and reading it on the other removes the upward bias of a maximum and changes little (mPFC-p 53.56 and 51.84%, OB-p 61.91 and 61.96%). With concentration labels shuffled, accuracy is 32.1 to 35.2% (95th percentile 41.4 to 43.1%), so chance is 33.3% for this procedure. Before onset mPFC-p already decodes concentration at 37.2 to 37.6%, above that level, and trial order is not correlated with concentration in any session (|Spearman rho| <= 0.02); this offset is not explained here.

figs5g-pairwise-concentration¶

Pairwise concentration decoding (low against medium, medium against high, low against high) is strongest and most sustained in OB-p ensembles, intermediate in untagged neurons and weakest in mPFC-p neurons.

Binary SVMs for each pair of concentrations per odor (chance 50%), averaged over odors; the mean same-window accuracy over windows starting 0 to 15 s after onset, per group.

In [26]:
for wname, (st, out) in CD.items():
    sel = st >= 0
    for pr, lab in [((-3, -2), "0.1% vs 1%"), ((-2, -1), "1% vs 10%"), ((-3, -1), "0.1% vs 10%")]:
        m = {g: 100 * out[g]["pairs"][pr][:, sel].mean() for g in GROUPS}
        print(f"{wname} {lab}: " + ", ".join(f"{g} {m[g]:.2f}%" for g in GROUPS) +
              f" | order OB > untagged > mPFC: {m['OB'] > m['untagged'] > m['mPFC']}")
a: 250 ms 0.1% vs 1%: OB 62.26%, mPFC 56.20%, untagged 62.09% | order OB > untagged > mPFC: True
a: 250 ms 1% vs 10%: OB 59.90%, mPFC 60.38%, untagged 60.41% | order OB > untagged > mPFC: False
a: 250 ms 0.1% vs 10%: OB 70.82%, mPFC 71.48%, untagged 72.97% | order OB > untagged > mPFC: False
b: 500 ms 0.1% vs 1%: OB 62.37%, mPFC 56.70%, untagged 61.44% | order OB > untagged > mPFC: True
b: 500 ms 1% vs 10%: OB 59.91%, mPFC 59.82%, untagged 61.34% | order OB > untagged > mPFC: False
b: 500 ms 0.1% vs 10%: OB 71.25%, mPFC 71.42%, untagged 72.86% | order OB > untagged > mPFC: False

Result: not reproduced. The order OB-p > untagged > mPFC-p holds only for 0.1% against 1% (OB-p 62.3 and 62.4%, untagged 62.1 and 61.4%, mPFC-p 56.2 and 56.7%). For 1% against 10% and for 0.1% against 10% the three groups are within 2.2 points of each other and untagged is highest under both window readings.

figs5-sparseness-concentration¶

Across the three concentrations, response sparseness and the fraction of active cells change only modestly in all three populations.

Binarized activity 0 to 5 s ("start" reading). Per concentration: the percentage of active cells per trial (over each group's cells, each mouse's trials), lifetime sparseness per neuron over the 3 odors at that concentration (mean over neurons with a defined value), and population sparseness per subject (over the subject's cells of the group, per trial, averaged over trials). "Only modestly" is judged as no population showing a monotonic change of more than half its value at 0.1% across the range.

In [27]:
rows = []
for rd in ["start", "centre"]:
    B_CO = binarize_sessions(CO, (0, 5), True, 12, rd)
    for s, B in zip(CO, B_CO):
        tr = s["trials"]
        for g in GROUPS:
            m = (s["cells"].projection == g).to_numpy()
            if not m.any():
                continue
            for c in [0.001, 0.01, 0.1]:
                sel = s["keep"] & (tr.conc == c).to_numpy()
                b = B[m][:, sel]
                odors = tr[sel].stim_name.to_numpy()
                r = np.stack([b[:, odors == o].mean(1) for o in np.unique(odors)], 1)
                ls = pcx.vinje_gallant(r, 1)
                ps_ = pcx.vinje_gallant(b.T.astype(float), 1)
                rows.append(dict(reading=rd, subject=s["meta"]["subject"], group=g, conc=c, pct_active=100 * b.mean(),
                               lifetime_sparseness=np.nanmean(ls), n_ls=int(np.isfinite(ls).sum()), n_cells=int(m.sum()),
                               pop_sparseness=np.nanmean(ps_)))
SP = pd.DataFrame(rows)
for rd in ["start", "centre"]:
    summ = SP[SP.reading == rd].groupby(["group", "conc"])[["pct_active", "lifetime_sparseness", "pop_sparseness"]].mean().unstack("conc")
    print(f"reading {rd}")
    print(summ.round(3).to_string())
    fails = []
    for meas in ["pct_active", "lifetime_sparseness", "pop_sparseness"]:
        for g in GROUPS:
            v = summ.loc[g, meas].to_numpy()
            mono = np.all(np.diff(v) > 0) or np.all(np.diff(v) < 0)
            big = abs(v[-1] - v[0]) > 0.5 * abs(v[0])
            print(f"   {meas:20s} {g:9s} values {np.round(v, 3)}, monotonic {mono}, change {100 * (v[-1] - v[0]) / v[0]:+.1f}% of 0.1% value")
            if mono and big:
                fails.append((meas, g))
    print("   populations with a monotonic change of more than half:", fails)
reading start
         pct_active                lifetime_sparseness               pop_sparseness              
conc          0.001  0.010   0.100               0.001  0.010  0.100          0.001  0.010  0.100
group                                                                                            
OB            6.042  7.361   8.113               0.812  0.750  0.715          0.971  0.946  0.936
mPFC          5.989  6.637   6.765               0.740  0.724  0.737          0.955  0.951  0.950
untagged      7.297  9.345  10.793               0.707  0.696  0.669          0.932  0.912  0.897
   pct_active           OB        values [6.042 7.361 8.113], monotonic True, change +34.3% of 0.1% value
   pct_active           mPFC      values [5.989 6.637 6.765], monotonic True, change +13.0% of 0.1% value
   pct_active           untagged  values [ 7.297  9.345 10.793], monotonic True, change +47.9% of 0.1% value
   lifetime_sparseness  OB        values [0.812 0.75  0.715], monotonic True, change -11.9% of 0.1% value
   lifetime_sparseness  mPFC      values [0.74  0.724 0.737], monotonic False, change -0.4% of 0.1% value
   lifetime_sparseness  untagged  values [0.707 0.696 0.669], monotonic True, change -5.4% of 0.1% value
   pop_sparseness       OB        values [0.971 0.946 0.936], monotonic True, change -3.6% of 0.1% value
   pop_sparseness       mPFC      values [0.955 0.951 0.95 ], monotonic True, change -0.5% of 0.1% value
   pop_sparseness       untagged  values [0.932 0.912 0.897], monotonic True, change -3.8% of 0.1% value
   populations with a monotonic change of more than half: []
reading centre
         pct_active                lifetime_sparseness               pop_sparseness              
conc          0.001  0.010   0.100               0.001  0.010  0.100          0.001  0.010  0.100
group                                                                                            
OB            5.739  7.154   7.888               0.814  0.739  0.758          0.972  0.951  0.936
mPFC          5.736  6.451   6.554               0.732  0.747  0.750          0.955  0.952  0.951
untagged      7.139  9.184  10.575               0.706  0.701  0.672          0.934  0.913  0.899
   pct_active           OB        values [5.739 7.154 7.888], monotonic True, change +37.4% of 0.1% value
   pct_active           mPFC      values [5.736 6.451 6.554], monotonic True, change +14.3% of 0.1% value
   pct_active           untagged  values [ 7.139  9.184 10.575], monotonic True, change +48.1% of 0.1% value
   lifetime_sparseness  OB        values [0.814 0.739 0.758], monotonic False, change -6.9% of 0.1% value
   lifetime_sparseness  mPFC      values [0.732 0.747 0.75 ], monotonic True, change +2.4% of 0.1% value
   lifetime_sparseness  untagged  values [0.706 0.701 0.672], monotonic True, change -4.8% of 0.1% value
   pop_sparseness       OB        values [0.972 0.951 0.936], monotonic True, change -3.8% of 0.1% value
   pop_sparseness       mPFC      values [0.955 0.952 0.951], monotonic True, change -0.4% of 0.1% value
   pop_sparseness       untagged  values [0.934 0.913 0.899], monotonic True, change -3.7% of 0.1% value
   populations with a monotonic change of more than half: []

Result: reproduced. Under the criterion's reading of "only modestly", no population shows a monotonic change of more than half its 0.1% value, under either window reading. The largest change is the untagged percentage of active cells, 7.3% to 10.8% (+47.9%, start reading) and 7.1% to 10.6% (+48.1%, centre); OB-p active cells rise by 34% and 37%, and lifetime and population sparseness change by 12% or less.

Summary¶

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

Claim Outcome
dataset-neuron-counts partially reproduced (Go/NoGo OB-p count per session 103 to 108, not 95 +/- 2)
fast-dataset-counts reproduced
figs2b-labeling-similar reproduced
mlp-projection-f1, transformer-projection-f1, fig1g-attention-timing, fig1f-latent-separation blocked: methods underspecified (Tables 5, 6 and 8 missing)
fig2b-lifetime-sparseness-similar blocked: methods underspecified (the treatment of never-active neurons decides the outcome)
fig2c-mutual-information not reproduced (OB-p not lower than untagged)
fig2d-population-sparseness not reproduced (all three pairs differ)
fig2-proportion-responding reproduced
fig2e-reliability not reproduced (reliable cells hold, unreliable do not)
fig2f-latency reproduced (projection confounded with mouse)
fig2g-early-peaks reproduced
fig2h-identity-decoding-5s blocked: methods underspecified (the two windows disagree)
fig2i-identity-decoding-early reproduced
fig2j-identity-decoding-peaks-earlier reproduced (peak times poorly determined)
fig2k-mpfc-late-identity reproduced
fig3bc-concentration-tuning reproduced
fig3de-concentration-decoding not reproduced (mPFC-p not close to chance)
figs5g-pairwise-concentration not reproduced
figs5-sparseness-concentration reproduced

How the analysis differs from the paper's. Normalization, cell selection and trial segmentation follow the paper's code; the figure analyses are not in the code and follow the Methods and the claims file's readings. The binarization was run under both readings of the window placement, which give the same outcomes here. The 2.33 SD reliability rule, the Vinje-Gallant sparseness and the mutual information are the claims file's readings of formulas lost from the text; for lifetime sparseness in Figure 2B the treatment of neurons without a defined value decides the outcome, so that claim is blocked (all three treatments shown). Decoding uses 5-fold stratified cross-validation with a new fold split and cell sample in each repeat. The transformer and MLP claims were not run.

What was found about the dataset. The stated imaging rate is wrong in 21 files (30, 50 or 100 Hz where the timestamps give 4.51 to 4.52 Hz). With the code's rule of skipping planes without red cells, the OB-p and mPFC-p counts of the identity and concentration experiments match the paper's exactly, the untagged counts are 2.1% (1937 against 1978) and 4.5% (2132 against 2232) lower, and the 30 Hz counts match exactly; over all planes the identity untagged count is 2328 against the paper's 1978. The dandiset has 18 subjects (10 OB-tagged, 8 mPFC-tagged); Figure S2B has 9 OB-p and 10 mPFC-p mice.