Huszar et al. (2022): the earlier attempt's findings, checked on DANDI:000552¶

Attempt huszar-2022-02, made blind, is compared with huszar-2022-01 in the reconciliation block of attempts/huszar-2022-02.yaml (docs/protocol.md, "Repeat attempts"). huszar-2022-01 was made on version 0.230630.2304. Findings 12 and 14 of huszar-2022-01 are reported again by huszar-2022-02 and are not checked here; findings 7 and 13 are also reported again, and are looked at here only for the part that may have changed. This notebook checks the others directly on DANDI:000552, version 0.261113.1035, streaming the 104 processed files and the raw files' metadata with remfile. It uses the entry's helper module huszar.py for the asset list and for the metadata of each processed file.

In [1]:
import collections

import numpy as np
import pandas as pd
import requests

import huszar as h

pd.set_option("display.width", 200)
pd.set_option("display.max_rows", 200)
print("dandiset", h.DANDISET, "version", h.VERSION)
S = h.survey(workers=12)
print(len(S), "processed files")
dandiset 000552 version 0.261113.1035
104 processed files

Data check¶

In [2]:
D = pd.DataFrame([dict(subject=m["subject_id"], session=m["session_id"], units=m["n_units"],
                       sex=m["sex"], age=m["age"]) for m in S])
print(D.groupby("subject").agg(files=("session", "size"), units=("units", "sum")).to_string())
print("subjects", D.subject.nunique(), "files", len(D), "units", D.units.sum())
          files  units
subject               
e13_16f1      9   1213
e13_1f1       5    360
e13_1m1      12   1432
e13_26m1      4    853
e14_1m1      12    853
e14_2m2       4    583
e14_2m3       8    452
e15_10m1      7    704
e15_13f1      4   1385
e15_4m1       3    202
e15_4m2       4    375
e15_5m1       3    233
e15_9f1       7    610
e16_1f1       9    604
e16_2m1       5    301
e16_3m1       4    697
e16_3m2       4    799
subjects 17 files 104 units 11656

Earlier finding 1: light-responsive labels and pulse times¶

No unit is labelled light-responsive (birthdated), and no optogenetic pulse times are stored in the processed or the raw files, so the paper's comparisons of same- and different-birthdate neurons and its birthdate profiles (22 of the 35 claims listed here) cannot be tested. The labels exist in the lab's CellExplorer files (optoTag, putativeCellType), which are not public at a pinned identifier.

In [3]:
lr = sum(int(np.sum(m.get("u_light_responsive", []))) for m in S)
print("files with a light_responsive column:", sum("light_responsive" in m["u_columns"] for m in S), "of", len(S))
print("files with opto_p_salt and opto_h_reliable:",
      sum({"opto_p_salt", "opto_h_reliable"} <= set(m["u_columns"]) for m in S))
print("units labelled light-responsive, all files:", lr)
lr96 = sum(int(np.sum(m.get("u_light_responsive", []))) for m in S
           if m["subject_id"] not in h.HOMECAGE_EXCLUDED)
print("units labelled light-responsive, the 15 homecage mice:", lr96)
print("files with OptogeneticPulses:", sum(m["n_pulses"] > 0 for m in S), "; pulses in all:", sum(m["n_pulses"] for m in S))
files with a light_responsive column: 104 of 104
files with opto_p_salt and opto_h_reliable: 104
units labelled light-responsive, all files: 786
units labelled light-responsive, the 15 homecage mice: 664
files with OptogeneticPulses: 104 ; pulses in all: 477092

Every processed file now has a light_responsive column, with the lab's statistics (opto_p_salt, opto_h_reliable) beside it, and an OptogeneticPulses table. The problem is gone.

Earlier finding 2: cell types and waveforms¶

Units carry no putative cell type and no waveforms, though the paper classifies 7,411 pyramidal cells and 2,060 interneurons.

In [4]:
ct = collections.Counter(x for m in S for x in m.get("u_putative_cell_type", []))
print("putative_cell_type over all units:", dict(ct))
ct96 = collections.Counter(x for m in S if m["subject_id"] not in h.HOMECAGE_EXCLUDED
                           for x in m.get("u_putative_cell_type", []))
print("in the 15 homecage mice:", dict(ct96))
print("files with waveform_mean:", sum(m["wf_shape"] is not None for m in S), "of", len(S))
putative_cell_type over all units: {'Pyramidal Cell': 9243, 'Narrow Interneuron': 1850, 'Wide Interneuron': 560, 'Unknown': 3}
in the 15 homecage mice: {'Pyramidal Cell': 7411, 'Narrow Interneuron': 1556, 'Wide Interneuron': 504, 'Unknown': 1}
files with waveform_mean: 104 of 104

Units now carry a putative cell type and a mean waveform in every file. The problem is gone.

Earlier finding 3: mice without units or position¶

Six of the 17 mice (e13_1f1, e13_1m1, e14_1m1, e15_4m1, e15_4m2, e15_5m1; 39 files) have sleep states and ripples but no units and no position. The dandiset holds 8,201 units where the paper reports 9,471.

In [5]:
six = ["e13_1f1", "e13_1m1", "e14_1m1", "e15_4m1", "e15_4m2", "e15_5m1"]
print(D[D.subject.isin(six)].groupby("subject").agg(files=("session", "size"), units=("units", "sum")).to_string())
print("files with units:", int((D.units > 0).sum()), "of", len(D), "; units in all:", D.units.sum())
print("units in the 15 homecage mice:", D[~D.subject.isin(h.HOMECAGE_EXCLUDED)].units.sum())
pos = {m["subject_id"] for m in S if m["series"]}
print("mice of the six with position:", sorted(pos & set(six)))
         files  units
subject              
e13_1f1      5    360
e13_1m1     12   1432
e14_1m1     12    853
e15_4m1      3    202
e15_4m2      4    375
e15_5m1      3    233
files with units: 104 of 104 ; units in all: 11656
units in the 15 homecage mice: 9472
mice of the six with position: []

The six mice now have units in all of their files. They have no position, which the paper does not lead one to expect (they are not among the maze mice of Supplementary Table 1), so that half of the statement was not a problem of the files. The units of the problem are back, so it is gone.

Earlier finding 4: novel explorations without position¶

Of the 16 novel environment explorations, only 9 have position and trials, and no open field has position. The novel-cohort sessions hold 7 further epochs of 10 to 50 min without position or video that may be the missing explorations.

In [6]:
rows = []
for m in S:
    if m["subject_id"] not in h.NOVEL_MICE:
        continue
    for k, v in m["series"].items():
        if k.startswith("SubjectPosition/") and "tmaze_familiar" not in k:
            rows.append(dict(session=m["session_id"], series=k.split("/")[1], unit=v["unit"], n=v["n"],
                             t0=round(v["t0"]), t1=round(v["t1"])))
N = pd.DataFrame(rows)
N["environment"] = N.series.str.split("_", n=1).str[1]
print(N.to_string(index=False))
print("novel-environment position series:", len(N), "; open fields:", int(N.environment.str.startswith("openField").sum()))
print("environments:", sorted(N.environment.unique()))
        session                           series unit     n    t0    t1       environment
e13_26m1_211019     SpatialSeries2_tmaze_ipshita n.a. 48056 15103 16749     tmaze_ipshita
e13_26m1_211116     SpatialSeries2_linear_thomas n.a.  8608 13595 13939     linear_thomas
e13_26m1_211119       SpatialSeries2_linear_manu n.a. 46166 14907 16446       linear_manu
e13_26m1_211124   SpatialSeries2_openField_gergo n.a. 55182 14555 16395   openField_gergo
e15_13f1_220117 SpatialSeries2_openField_coolbox n.a. 59136 14079 16447 openField_coolbox
e15_13f1_220118       SpatialSeries2_linear_manu n.a. 57452 13131 15046       linear_manu
e15_13f1_220118  SpatialSeries3_openField_thomas n.a. 61456 19159 21618  openField_thomas
e15_13f1_220119   SpatialSeries2_openField_gergo n.a. 72825 12662 15089   openField_gergo
e15_13f1_220119     SpatialSeries3_tmaze_ipshita n.a. 44732 21209 22700     tmaze_ipshita
e15_13f1_220120     SpatialSeries2_linear_thomas n.a. 44805 18009 19801     linear_thomas
 e16_3m2_211210 SpatialSeries2_openField_coolbox n.a. 65055 16625 19231 openField_coolbox
 e16_3m2_211211  SpatialSeries2_openField_thomas n.a. 60613  9571 11996  openField_thomas
 e16_3m2_211211       SpatialSeries3_linear_manu n.a. 48818  9575 11203       linear_manu
 e16_3m2_211212   SpatialSeries2_openField_gergo n.a. 54303 11548 13359   openField_gergo
 e16_3m2_211212     SpatialSeries3_linear_thomas n.a. 33205 16403 17731     linear_thomas
 e16_3m2_211213     SpatialSeries2_tmaze_ipshita n.a. 61076 13287 15323     tmaze_ipshita
novel-environment position series: 16 ; open fields: 7
environments: ['linear_manu', 'linear_thomas', 'openField_coolbox', 'openField_gergo', 'openField_thomas', 'tmaze_ipshita']

The novel-cohort sessions hold 16 position series outside the familiar maze, 7 of them in the three open fields, so every one of the 16 explorations now has position. The problem is gone. (One of them, the linear_manu series of e16_3m2_211211, has timestamps inside the open-field epoch; huszar-2022-02 reports that as its finding 2.)

Earlier finding 5: subject sex differs between files¶

The subject sex differs between files of the same mouse. e13_1f1 is Female in 3 files and Male in 2; e13_1m1 is Male in 9 and Female in 3. The value in most of each mouse's files gives the paper's 12 males and 5 females.

In [7]:
sx = D.groupby("subject").sex.agg(lambda s: dict(collections.Counter(s)))
print(sx.to_string())
print("mice whose files disagree on sex:", int((D.groupby("subject").sex.nunique() > 1).sum()))
by_mouse = D.groupby("subject").sex.first()
print("males", int((by_mouse == "M").sum()), "females", int((by_mouse == "F").sum()))
subject
e13_16f1     {'F': 9}
e13_1f1      {'F': 5}
e13_1m1     {'M': 12}
e13_26m1     {'M': 4}
e14_1m1     {'M': 12}
e14_2m2      {'M': 4}
e14_2m3      {'M': 8}
e15_10m1     {'M': 7}
e15_13f1     {'F': 4}
e15_4m1      {'M': 3}
e15_4m2      {'M': 4}
e15_5m1      {'M': 3}
e15_9f1      {'F': 7}
e16_1f1      {'F': 9}
e16_2m1      {'M': 5}
e16_3m1      {'M': 4}
e16_3m2      {'M': 4}
mice whose files disagree on sex: 0
males 12 females 5

Every mouse now has one sex in all of its files, and they give 12 males and 5 females. The problem is gone.

Earlier finding 6: is_familiar_maze¶

The trials column is_familiar_maze is True only for the first two trials of sessions with a single maze recording, where every trial is on the familiar maze (112 True, 1,182 False).

In [8]:
T = []
for m in S:
    if m["trials"]:
        t = pd.DataFrame(m["trials"])
        t["session"] = m["session_id"]
        T.append(t)
T = pd.concat(T, ignore_index=True)
T["single_recording_session"] = T.session.map(T.groupby("session").recordings.nunique() == 1)
print(pd.crosstab(T.single_recording_session, T.is_familiar_maze).to_string())
first = T.groupby("session").recordings.transform("min")
print(pd.crosstab(T.recordings == first, T.is_familiar_maze, rownames=["first recording"]).to_string())
is_familiar_maze          False  True 
single_recording_session              
False                       362    286
True                          0   1294
is_familiar_maze  False  True 
first recording               
False               362      0
True                  0   1580

In sessions with a single maze recording every trial is now is_familiar_maze True, and the column is True on the first recording of every session. The problem is gone.

Earlier finding 7: novel positions in 0 to 1 labelled cm¶

In several novel recordings (e13_26m1 211019, 211116, 211119; e15_13f1 220120; e16_3m2 211213) x and y lie between 0 and 1 though stated in cm.

huszar-2022-02 reports the missing scale of these positions as its finding 3; this section looks only at the unit they are labelled with.

In [9]:
print(N[N.session.isin(["e13_26m1_211019", "e13_26m1_211116", "e13_26m1_211119", "e15_13f1_220120",
                        "e16_3m2_211213"])][["session", "series", "unit"]].to_string(index=False))
print("units of the novel position series:", dict(collections.Counter(N.unit)))
m = next(m for m in S if m["session_id"] == "e13_26m1_211019")
print(m["series"]["SubjectPosition/SpatialSeries2_tmaze_ipshita"]["desc"])
        session                       series unit
e13_26m1_211019 SpatialSeries2_tmaze_ipshita n.a.
e13_26m1_211116 SpatialSeries2_linear_thomas n.a.
e13_26m1_211119   SpatialSeries2_linear_manu n.a.
e15_13f1_220120 SpatialSeries2_linear_thomas n.a.
 e16_3m2_211213 SpatialSeries2_tmaze_ipshita n.a.
units of the novel position series: {'n.a.': 16}
(x, y) of the head-mounted LEDs in sub-session 2 (e13_26m1_211019_145847), environment tmaze_ipshita (maze_info.mat), from the lab's Behavior.mat, in the lab's units: x 0.01 to 0.73, y 0.06 to 0.98, with no scale given in the source

The series are no longer labelled cm: their unit is "n.a." and their descriptions say they are in the lab's units with no scale given. The mislabelling is fixed; the scale itself is still missing, as huszar-2022-02 reports.

Earlier finding 8: session start of the raw files¶

Twelve of the 13 raw files give a session start of 2011-08-18 for sessions recorded in 2021 and 2022.

In [10]:
out, url = [], f"{h.API}/dandisets/{h.DANDISET}/versions/{h.VERSION}/assets/?page_size=200"
while url:
    r = requests.get(url, timeout=60).json()
    out += r["results"]
    url = r["next"]
raw = sorted([a for a in out if not a["path"].endswith("behavior+ecephys.nwb")], key=lambda a: a["path"])
rows = []
for a in raw:
    with h.open_nwb(a) as f:
        rows.append(dict(file=a["path"].split("/")[-1], session_start=h._s(f["session_start_time"][()]),
                         acquisition=",".join(f["acquisition"].keys())))
R = pd.DataFrame(rows)
print(R.to_string(index=False))
R["date_in_name"] = R.file.str.extract(r"-(\d{6})-raw")[0]
R["date_in_start"] = R.session_start.str[2:10].str.replace("-", "")
print("raw files:", len(R), "; start date matching the file name:", int((R.date_in_name == R.date_in_start).sum()))
                                            file             session_start      acquisition
sub-e13-26m1_ses-e13-26m1-211019-raw_ecephys.nwb 2021-10-19T00:00:00-04:00 ElectricalSeries
sub-e13-26m1_ses-e13-26m1-211116-raw_ecephys.nwb 2021-11-16T00:00:00-05:00 ElectricalSeries
sub-e13-26m1_ses-e13-26m1-211124-raw_ecephys.nwb 2021-11-24T00:00:00-05:00 ElectricalSeries
sub-e15-13f1_ses-e15-13f1-220118-raw_ecephys.nwb 2022-01-18T00:00:00-05:00 ElectricalSeries
sub-e15-13f1_ses-e15-13f1-220119-raw_ecephys.nwb 2022-01-19T00:00:00-05:00 ElectricalSeries
sub-e15-13f1_ses-e15-13f1-220120-raw_ecephys.nwb 2022-01-20T00:00:00-05:00 ElectricalSeries
  sub-e16-3m1_ses-e16-3m1-210201-raw_ecephys.nwb 2021-02-01T00:00:00-05:00 ElectricalSeries
  sub-e16-3m1_ses-e16-3m1-210203-raw_ecephys.nwb 2021-02-03T00:00:00-05:00 ElectricalSeries
  sub-e16-3m2_ses-e16-3m2-211210-raw_ecephys.nwb 2021-12-10T00:00:00-05:00 ElectricalSeries
  sub-e16-3m2_ses-e16-3m2-211212-raw_ecephys.nwb 2021-12-12T00:00:00-05:00 ElectricalSeries
  sub-e16-3m2_ses-e16-3m2-211213-raw_ecephys.nwb 2021-12-13T00:00:00-05:00 ElectricalSeries
raw files: 11 ; start date matching the file name: 11

The version holds 11 raw files, and each gives the date of its file name as its session start. The problem is gone.

Earlier finding 9: the LFP of e16_3m1_210201¶

The processed file of e16_3m1_210201 holds a copy of the 1250 Hz LFP of the raw file, labelled with a rate of 30,000 Hz and a conversion factor of 3.05e-13 V.

In [11]:
m = next(m for m in S if m["session_id"] == "e16_3m1_210201")
a = next(a for a in h.assets() if "e16-3m1-210201" in a["path"])
with h.open_nwb(a) as f:
    lfp = f["processing/ecephys/LFP/LFP"]
    print("rate", float(lfp["starting_time"].attrs["rate"]), "Hz; conversion",
          float(lfp["data"].attrs["conversion"]), lfp["data"].attrs["unit"], "; shape", lfp["data"].shape)
rates = collections.Counter(m.get("lfp_rate") for m in S)
print("LFP rates over the processed files:", dict(rates))
rate 1250.0 Hz; conversion 1.9499999999999999e-07 volts ; shape (21939280, 64)
LFP rates over the processed files: {1250.0: 104}

The LFP of this file is labelled 1250 Hz with a conversion factor of 1.95e-07 V, as in the other files. The problem is gone.

Earlier finding 10: units without a link to the electrodes¶

Units have no link to the electrodes table, and their group_id values ("Group3") do not match the electrode group names ("Group 3") in 64 of 65 files, so a unit's shank and position on the probe cannot be recovered.

In [12]:
rows = []
for a in h.assets():
    with h.open_nwb(a) as f:
        u = f["units"]
        el = f["general/extracellular_ephys/electrodes"]
        n_el = el["id"].shape[0]
        has_link = "electrodes" in u and "electrodes_index" in u
        ok_idx = has_link and int(u["electrodes"][:].max()) < n_el
        groups = set(k for k in f["general/extracellular_ephys"].keys() if k != "electrodes")
        refs = {f[r].name.split("/")[-1] for r in u["electrode_group"][:]} if "electrode_group" in u else set()
        rows.append(dict(file=a["path"].split("/")[-1], electrodes_link=has_link, index_in_range=ok_idx,
                         group_refs_resolve=bool(refs) and refs <= groups))
L = pd.DataFrame(rows)
print(L[["electrodes_link", "index_in_range", "group_refs_resolve"]].sum().to_string(), "of", len(L))
electrodes_link       104
index_in_range        104
group_refs_resolve    104 of 104

Every units table now has an electrodes column into the electrodes table and an electrode_group that refers to the file's electrode groups, so a unit's shank and place on the probe can be recovered. The problem is gone.

Earlier finding 11: the embryonic day¶

The embryonic day of electroporation, the variable the paper is about, is stored only as the prefix of each subject id (e13 for E13.5); the age is given as P3M/P6M for every mouse.

In [13]:
a = h.assets()[0]
with h.open_nwb(a) as f:
    sub = f["general/subject"]
    for k in sub:
        print(k, ":", h._s(sub[k][()]))
print("ages over the files:", dict(collections.Counter(m["age"] for m in S)))
age : P3M/P6M
description : CA1 pyramidal neurons birthdated by in utero electroporation at E13.5 (the e-number of the subject id; the source has no other record of the electroporation day). Sex from the m or f of the subject id. Age: 3 to 6 months, the range the paper gives for the implanted mice as a group; no source file gives each mouse's age.
genotype : Wild type
sex : F
species : Mus musculus
strain : C57BL/6
subject_id : e13_16f1
ages over the files: {'P3M/P6M': 104}

The embryonic day is still held only in the subject id, and the age is still P3M/P6M in every file, but the subject description now gives the mapping (the e-number of the id is the electroporation day) and says that the source has no other record of the day or of each mouse's age. What the finding asked for, a stated meaning for the prefix, is now in the files, so the problem is gone.

Earlier finding 13: trial counts and missing trial times¶

Only 38 of 65 familiar-maze sessions have ten or more trials on each visited arm, and 6 have fewer than 20 trials, where the Methods require ten per arm in every session; 19 of 1,942 trials have no start or stop time.

huszar-2022-02 reports the trial counts as its finding 6; this section looks at the missing times.

In [14]:
print("trials:", len(T), "in", T.session.nunique(), "sessions; with no start or stop time:",
      int((T.start_time.isna() | T.stop_time.isna()).sum()))
trials: 1942 in 65 sessions; with no start or stop time: 19

The 19 trials with no start or stop time are still there.

Earlier finding 15: the novel-environment cohort¶

The paper calls the novel-environment cohort of three mice separate, but one of them (e13_26m1) is also among the nine figure-eight mice, in the dandiset and in the paper's code.

In [15]:
rows = []
for m in S:
    if m["subject_id"] not in h.NOVEL_MICE:
        continue
    keys = list(m["series"])
    rows.append(dict(session=m["session_id"], familiar_maze=any("tmaze_familiar" in k for k in keys),
                     novel=any(k.startswith("SubjectPosition/") and "tmaze_familiar" not in k for k in keys)))
C = pd.DataFrame(rows)
C["mouse"] = C.session.str.rsplit("_", n=1).str[0]
print(C.groupby("mouse")[["familiar_maze", "novel"]].sum().to_string())
fam = {m["subject_id"] for m in S
       if any("tmaze_familiar" in k or "figure-8" in v["desc"] for k, v in m["series"].items())}
print("mice with a familiar figure-eight subsession:", sorted(fam))
print("novel-cohort mice among the nine of the familiar-maze analyses (huszar.FAMILIAR_MICE):",
      sorted(h.NOVEL_MICE & h.FAMILIAR_MICE))
          familiar_maze  novel
mouse                         
e13_26m1              4      4
e15_13f1              4      4
e16_3m2               4      4
mice with a familiar figure-eight subsession: ['e13_16f1', 'e13_26m1', 'e14_2m2', 'e14_2m3', 'e15_10m1', 'e15_13f1', 'e15_9f1', 'e16_1f1', 'e16_2m1', 'e16_3m1', 'e16_3m2']
novel-cohort mice among the nine of the familiar-maze analyses (huszar.FAMILIAR_MICE): ['e13_26m1']

All three novel-cohort mice run the familiar figure-eight first in each session. e13_26m1 is also one of the nine mice of the familiar-maze analyses (the Figure 5 column of Supplementary Table 1), so the cohort the paper calls separate shares a mouse with the figure-eight cohort; the inconsistency is still there.