Skip to content

SLAP2 glutamate QC: Figure 7 panels C/G/K with archive-wide event-based metrics - #171

Open
ido4848 wants to merge 3 commits into
mainfrom
aizenbud-slap2-snr
Open

SLAP2 glutamate QC: Figure 7 panels C/G/K with archive-wide event-based metrics#171
ido4848 wants to merge 3 commits into
mainfrom
aizenbud-slap2-snr

Conversation

@ido4848

@ido4848 ido4848 commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Adds the SLAP2-glutamate column of Figure 7 (panels C, G, K) together with the event-based QC pipeline behind it, mirroring the mesoscope scheme of #156: events are detected on the matched-filtered ΔF/F at 3 SD of the noise, each event's amplitude is measured on the raw trace in noise SDs and binned < 2 / 2–4 / > 4 SD, and each synapse is classified (k-means, k = 3) by the fractions of its events in the three bins (slap2_glutamate_qc_events.py).

slap2_glutamate_qc_batch.py runs this over all 20 sessions of DANDI 001424 (8 mice, 2,540 synapses) and the resulting per-synapse, per-context and per-session tables are committed under docs/notebooks/plots_figure7_slap2_glutamate/, so panels G and K (slap2_glutamate_figure7_panels.py) re-render in seconds without any NWB; only panel C and the example trace in G read one session (sub-794237_ses-20250508T145040, downloaded by the notebook, not committed).

Panel C shows both imaging planes of the example session with one synapse's footprint and 20 s of ΔF/F with events; G shows how signal and noise are measured on a trace, the class definition by example, and every synapse of the archive in the event-amplitude feature space; K shows event rate by stimulus context per class and class composition by dendritic compartment and per neuron.

Two choices worth a look: classes are fitted per acquisition cohort (the 12 glutamate-only sessions ship two-sided ΔF/F, the 8 glutamate + calcium sessions non-negative NMF-denoised traces, so one fit over all 20 mostly sorts by pipeline, the tables carry both quality_class and a per-session quality_class_session), and context rates use each source's own recorded seconds because the two DMDs of a session can run for different spans.

The walkthrough notebook docs/notebooks/slap2_glutamate_figure7_panels.ipynb (added to the mkdocs Analysis nav) runs the per-session QC on the example session, loads the archive tables, and renders the panels.

… notebook

Event-based signal/noise QC for the SLAP2 glutamate (iGluSnFR4f) sessions of
DANDI 001424, mirroring the mesoscope scheme of discussion #156:

- slap2_glutamate_qc_events.py: per-session QC library + CLI (matched-filter
  detection at 3 SD, raw-sigma event amplitudes binned <2 / 2-4 / >4 SD,
  k-means quality classes, layout-agnostic NWB loading)
- slap2_glutamate_qc_batch.py: runs all 20 sessions (8 mice, 2,540 synapses)
  into per-synapse, per-context and per-session tables; classes fitted per
  acquisition cohort; per-source context seconds from valid samples
- slap2_glutamate_figure7_panels.py: renders panel C (example session) and
  panels G and K (all sessions)
- docs/notebooks/slap2_glutamate_figure7_panels.ipynb + the rendered panels
  (PNG/SVG) and tables under docs/notebooks/plots_figure7_slap2_glutamate/;
  notebook added to the mkdocs Analysis nav

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ido4848 ido4848 self-assigned this Aug 19, 2026
Ido Aizenbud and others added 2 commits August 24, 2026 14:59
…lasses

Review feedback on the QC figures: "instead of Low SNR / Intermediate / High
SNR, maybe use a colour gradient that maps to the actual SNR values?"

Panels C and G are the two that can carry a colourbar instead of a legend (an
ROI map and a scatter), so `render_panel_c` / `render_panel_g` take an opt-in
`color_by` (`--color-by` on the CLI) and write `*_gradient.{png,svg}` next to
the defaults. Panel K keeps the classes: a stacked or grouped bar needs a
categorical variable, and the three-class scheme is what keeps this column
comparable to the mesoscope column of #156.

Default behaviour is unchanged — re-rendering C/G/K without the flag gives
PNGs byte-identical to the committed ones.

The scalar is `median_event_raw_sd`, the synapse's median event amplitude in
SD of its own noise: same unit as the rest of panel G, and spearman 0.99 with
the > 4 SD fraction the classes are ordered by. `robust_snr` is accepted too
but is a poor gradient — its class medians (2.32 / 2.65 / 2.70 archive-wide)
overlap almost completely and every synapse above 10 is in the glutamate +
calcium cohort, whose non-negative dF/F shrinks sigma.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant