Study S00 · generated 2026-10-13T21:06:11+00:00 · 80.1 s

Data provenance, quality control and session mapping

Recovering session boundaries from concatenated recordings and validating them against behavior.

Question

How are the calcium recordings organised in time, and can each imaging block be assigned to its behavioral session with evidence rather than assumption?

Background & rationale

Acquisition and preprocessing (as reported by the lab). Six male C57BL/6N mice (6–7 weeks at arrival) were imaged in prelimbic mPFC (AP +1.80 mm, ML +0.35 mm, DV −2.30 mm, no angle) with a Doric 2-color fluorescence miniscope (0.5 mm lens SICL_D_500_80) and AAV2/9-Syn-GCaMP6f. Frame rate is 6.666 frames/s. Imaging days are CSDS days 1, 2, 3, 5, 7 and 9, plus day 11. Each defeat day is a 15-min recording split into baseline (BL), social defeat (SD) and sensory stress (SS). Epoch length is nominally 2,000 frames and varies from 1,998 to 2,001. Raw frames (630 × 630 px) had black frames replaced by the mean of neighbouring frames and were spatially downsampled by a factor of 3 (210 × 210 px). Slow baseline drift in mean frame intensity was removed with a rubberband (convex-hull) baseline fitted by piecewise-linear and smoothing splines. Minian could not reliably detect neurons in the defeat data, so ROIs were drawn manually on a maximum projection after epochs were merged within each day and fields of view were checked across days, then aligned by hand across days: 848 neurons in total. ΔF/F was computed on the full concatenated recording (F₀ = 10th percentile in each 12-s window; the memoir approximated the frame rate as 7 Hz, about 84 frames). CASCADE converted each ΔF/F sample to a spike probability (Rupprecht et al. 2021; model and noise level not recorded). ANY-maze triggered the miniscope, so behavior and calcium start together. Annotation files of about 305 s (155 s for each SIT half) use a clock that is 5 s ahead of calcium time.

Why a QC study. The exported TS_{id}.xlsx workbooks hold one long neuron × frame matrix per animal with no session markers. Every downstream contrast depends on assigning each ~2,000-frame block to the right session. The lab's description fixes the order within a day, and this study verifies it from the data. Day 11 (BL → SIT → POST) is in the workbooks; the SIT block is two halves of about 1,000 frames (empty enclosure, then CD-1) and was not used in the previous article.

Day 7 and incomplete epochs. Day 7 was not recorded for mouse 6597, and sensory stress on day 9 was not included for that mouse. Mouse 6669 has no SIT imaging block. Day-7 data exist for the other five mice. Primary analyses still omit day 7 so that every animal is compared on the same days.

Methodology

Data format. Each workbook holds two signal families, dff_mc (motion-corrected ΔF/F) and predictions_dff_mc (inferred spike probability). Rows are neurons (row 0 is the frame index) and columns are frames; time is split into part1/2/3 sheets only because Excel limits a sheet to 16,384 columns. Parts were concatenated in order. The first and last 33 frames of each recording are constant. CASCADE was used only to write the spike-probability columns, so those samples are excluded as unusable frames rather than as documented CASCADE padding.

Block structure. Behavioral sessions last ≈300 s. Each SIT half lasts ≈150 s of calcium time inside one block (annotation files read ≈155 s because of the 5 s clock). We tested whether the recording is composed of fixed 2,000-frame blocks (300 s at 6.666 Hz). The lab reports that epoch length can be 1,998–2,001 frames, so a boundary can sit a few frames off this grid. For every candidate boundary t = 2,000·k, a boundary score was computed as the Euclidean distance between the population mean ΔF/F vectors in the 30 frames before and after t. This was compared with the same score at 400 random time points per animal, and each boundary is reported as a percentile of that null distribution. True session boundaries should sit in the upper tail, because focal plane, baseline fluorescence and behavioral context change between sessions. This test uses the nominal grid, so it is not biased by the correction below.

Epoch-length correction. Around each nominal cut k (frame 2,000·k), the step score (20 frames each side) was computed at every frame within ±15 frames. A step was reliable if it exceeded the 95th percentile of step scores at 400 random times and did not sit at the edge of the search window. Because offsets accumulate from frame 0, offset_k = k·δ, where δ is the mean deviation of epoch length from 2,000 frames. δ was estimated per animal as the median of offset_k / k over reliable cuts (≥ 4 required; otherwise δ = 0), limited to the lab's reported 1,998–2,001-frame range. All analyses cut epoch k at round(k·(2,000 + δ)). One parameter per animal is estimated, so individual noisy detections do not move individual boundaries.

Session order hypothesis. The protocol implies, for each of days 1–9, BL → SD → SS. On day 11 it implies BL → SIT (empty enclosure, then CD1 target, ≈1,000 frames each) → POST. The lab identified the missing epoch for the two short recordings (6597: SS on day 9; 6669: SIT). Every single-slot deletion is still scored below as a check on that assignment.

Behavior-encoding alignment test. If block b truly corresponds to session s, neural activity in b should be better explained by the ethogram of s than by the ethogram of any other session. For every (block, session) pair we: 1. Binned inferred spikes in 1-s bins and z-scored each neuron. 2. Assigned each bin the annotated behavior of the candidate session. 3. Computed η², the fraction of each neuron's variance explained by behavior labels, averaged over neurons. 4. Expressed η² as a z-score against 40 circular shifts of the label sequence, which preserves bout structure and destroys alignment.

The mean z on the hypothesised diagonal was compared with 5,000 random block→session permutations, per animal and pooled across animals with complete mappings. For animals with one block too few, the mean diagonal z was computed for each possible missing slot, giving a likelihood ranking of candidate mappings.

Frame-to-video timing. Calcium and behavior start together. Frame i of a block maps to annotation time i/6.666 s, plus 5 s when that file's duration is ≈305 s or ≈155 s.

Parameters

ParameterValue
block_frames2000
fs_hz6.666
boundary_window30
alignment_bin_s1.0
alignment_null_shifts40
permutations5000

Highlights

info

Cohort

6 mice · 848 neurons

95–187 neurons per animal tracked across 126 mapped sessions (111 analysed after excluding day 7).

info

Epoch length

2000.24–2000.62 frames

Estimated from 86 reliable boundary steps. Correcting the fixed 2,000-frame grid shifts late cuts by up to 11 frames (1.7 s).

significant

Session boundaries

65% of boundaries > 90th pct

Population activity changes abruptly every 2,000 frames (binomial vs 10% chance, p < 0.001).

significant

Session order validated

pooled p < 0.001

Neural blocks are better explained by their own session's ethogram than by shuffled assignments (mean diagonal z = 0.96, 4 animals).

info

Missing epochs

6597 SS9, 6669 SIT11

Identified by the lab and omitted from the session map. Figure 4 ranks every other single-slot deletion as a check.

Results

Recording structure. The 6 animals contributed 848 neurons in total (95–187 per animal), each tracked continuously for 84.8–104.8 min of imaging. Recordings split into ≈2,000-frame blocks. 65% of nominal block edges exceeded the 90th percentile of random-time boundary scores (expected 10%; binomial p < 0.001). Figure 1 shows the abrupt population-level steps at block edges.

Epoch length. Reliable boundary steps (86 of 115 cuts) sat progressively later than the 2,000-frame grid, which means epochs are slightly longer than 2,000 frames. The estimated length was 2000.24–2000.62 frames per animal, inside the lab's reported 1,998–2,001 range (Table 2, Figure 2). The median absolute residual of detected cuts around the drift model was 0.5 frames. Using the corrected cuts moves the last session boundary by up to 11 frames (1.7 s), which would otherwise misalign late sessions with their behavior annotations. The final epoch of every recording is short (1914–1923 frames), consistent with a truncated last epoch.

Session order. Under the protocol order (BL → SD → SS on days 1–9; BL → SIT → POST on day 11), the behavior-encoding alignment z on the hypothesised diagonal averaged 0.96 across the 4 animals with complete mappings, versus 0.45 for 5,000 random block assignments (pooled permutation p < 0.001; per-animal values in Table 4, Figure 3). Individually significant animals: 4703, 6675. Not individually significant: 6672, 6445.

Incomplete recordings. The lab identified the missing epochs: mouse 6597 has no day-7 recording and no sensory-stress block on day 9; mouse 6669 has no SIT imaging block. Alignment rankings of single-slot deletions were 6597: SIT11 (1.98), POST11 (1.91), BL11 (1.51), SS9 (1.44); 6669: BL9 (3.42), SS7 (3.37), BL7 (3.21), SD7 (3.19). Deleting an early slot fits clearly worse (Figure 4). The map uses the lab's assignment, not the top-scoring candidate.

Figures

Population activity and recovered sessions
Figure 1. Population activity and recovered sessions. Population-mean ΔF/F (25-frame smoothing) for each animal across the full concatenated recording. Shading marks the recovered sessions, coloured by condition. Steps in baseline fluorescence coincide with 2,000-frame block edges.
Epoch boundaries drift from the 2,000-frame grid
Figure 2. Epoch boundaries drift from the 2,000-frame grid. Offset of the largest population ΔF/F step within ±15 frames of each nominal cut. Filled points are reliable steps (> 95th percentile of random-time steps, not at the window edge); open points are not. Red line: drift model k·δ used to place the cuts.
Behavior-encoding alignment matrices
Figure 3. Behavior-encoding alignment matrices. z-scored variance in neural activity explained by each session's ethogram (columns) for each imaging block (rows). Black dots mark the hypothesised protocol order; positive values along the diagonal support the mapping.
Which session is missing?
Figure 4. Which session is missing?. Mean alignment z of the remaining mapping when each protocol slot is assumed missing. Early deletions fit worse. Red marks the epoch the lab identified as absent (6597: SS day 9; 6669: SIT).
Example day: inferred spikes with the ethogram
Figure 5. Example day: inferred spikes with the ethogram. Inferred spike probability for every neuron of animal 6675 on CSDS day 5 (baseline, defeat, post-defeat sensory contact), with the aligned behavioral annotation below each raster.

Tables

Table 1. Recording summary per animal

Neurons, frames and the number of 2,000-frame blocks versus protocol slots. Download CSV

subjectneuronsframesminutesblocksprotocol_slotssessions_mappedmapping
470310541922105212122supported
64459541922105212122supported
65971563392484.8171818supported
66691873992999.8202120supported
667216641924105212122supported
667513941929105212122supported

Table 2. Estimated epoch length per animal

Per-epoch length from the drift of reliable boundary steps away from the 2,000-frame grid; max shift = correction applied at the last cut. Download CSV

subjectcutsreliable_cutsepoch_framesmax_shift_vs_fixed_gridmedian_abs_residuallast_epoch_frames
470320122e+0360.6361916
644520102e+0350.4241917
659716152e+03100.51914
666919142e+0360.4751923
667220162e+0350.51919
667520192e+03110.3751918

Table 3. Detected boundary offsets

Offset (frames) of the largest population ΔF/F step within ±15 frames of each nominal cut. Showing 20 of 115 rows. Download CSV

subjectcutoffsetscorereliablepredicted_offset
47031016.2True0.31
47032-157.84False0.62
47033-414.4True0.94
47034-129.86False1.25
47035-118.7True1.56
4703638.97False1.87
47037-18.68False2.18
4703835.16False2.49
47039423.3True2.81
470310423.5True3.12
47031118.59False3.43
470312416.6True3.74
470313425.8True4.05
470314-37.04False4.36
470315315.5True4.68
470316614True4.99
4703171210.1False5.3
470318628.2True5.61
470319615.3True5.92
470320619.3True6.23

Table 4. Behavior-encoding alignment (complete mappings)

Mean z of the hypothesised block→session diagonal vs 5,000 random assignments. Download CSV

subjectdiagonal_zshuffled_z_meanp_perm
47031.630.1790.0004
64450.4380.4330.428
66720.8730.8360.421
66750.8920.3270.0254

Table 5. Candidate missing sessions (animals with one block too few)

Higher diagonal z = better behavioral fit of the remaining mapping. Showing 12 of 39 rows. Download CSV

subjectmissing_slotdiagonal_z
6597SIT111.98
6597POST111.91
6597BL111.51
6597SS91.44
6597BL91.22
6597SD91.16
6597SS50.986
6597SD50.962
6597BL50.899
6597SS30.685
6597SD30.633
6597BL30.444

Table 6. Session map used by all studies

Frame ranges (in the concatenated recording) for every session. Showing 30 of 126 rows. Download CSV

subjectconditiondayblockstartstopn_framesobs_idmappingincluded
4703BL1033200019674703_BL_Day1_08-05-23supportedTrue
4703SD112000400120014703_SD_Day1_08-05-23supportedTrue
4703SS124001600120004703_SS_Day1_08-05-23supportedTrue
4703BL236001800120004703_BL_Day2_09-05-23supportedTrue
4703SD2480011000220014703_SD_Day2_09-05-23supportedTrue
4703SS25100021200220004703_SS_Day2_09-05-23supportedTrue
4703BL36120021400220004703_BL_Day3_10-05-23supportedTrue
4703SD37140021600220004703_SD_Day3_10-05-23supportedTrue
4703SS38160021800320014703_SS_Day3_10-05-23supportedTrue
4703BL59180032000320004703_BL_Day5_12-05-23supportedTrue
4703SD510200032200320004703_SD_Day5_12-05-23supportedTrue
4703SS511220032400420014703_SS_Day5_12-05-23supportedTrue
4703BL712240042600420004703_BL_Day7_14-05-23supportedFalse
4703SD713260042800420004703_SD_Day7_14-05-23supportedFalse
4703SS714280043000520014703_SS_Day7_14-05-23supportedFalse
4703BL915300053200520004703_BL_Day9_16-05-23supportedTrue
4703SD916320053400520004703_SD_Day9_16-05-23supportedTrue
4703SS917340053600620014703_SS_Day9_16-05-23supportedTrue
4703BL1118360063800620004703_BL_Day11_18-05-23supportedTrue
4703SIT_NoCD11119380063900610004703_SIT_NoCD1_Day11_18-05-23supportedTrue
4703SIT_CD11119390064000610004703_SIT_CD1_Day11_18-05-23supportedTrue
4703POST1120400064188918834703_POST_SIT_Day11_18-05-23supportedTrue
6445BL1033200019676445_BL_Day1_04-03-24supportedTrue
6445SD112000400020006445_SD_Day1_04-03-24supportedTrue
6445SS124000600120016445_SS_Day1_04-03-24supportedTrue
6445BL236001800120006445_BL_Day2_05-03-24supportedTrue
6445SD2480011000120006445_SD_Day2_05-03-24supportedTrue
6445SS25100011200120006445_SS_Day2_05-03-24supportedTrue
6445BL36120011400220016445_BL_Day3_06-03-24supportedTrue
6445SD37140021600220006445_SD_Day3_06-03-24supportedTrue

Limitations

  • The drift model assumes a constant mean epoch length per animal. Individual epochs vary by 1–2 frames (≈ 0.2 s) around it, which the model does not recover.
  • ΔF/F baselines were estimated on the concatenated recording, so the 12-s F₀ window can cross an epoch boundary.
  • The 33 constant frames at each end of a workbook are excluded. Their origin is not documented.
  • CASCADE model and noise level were not recorded. Spike probability is paired one-to-one with ΔF/F.
  • Mouse 6597 has no day-9 sensory-stress block, and mouse 6669 has no SIT imaging block.

References

  1. Rupprecht P. et al. (2021) A database and deep learning toolbox for noise-optimized, generalized spike inference from calcium imaging. Nat Neurosci 24:1324–1337.
  2. Dong Z. et al. (2022) Minian, an open-source miniscope analysis pipeline. eLife 11:e70661.
  3. Optimal choice of baseline correction for multivariate calibration of spectra (rubberband baseline method; cited by the lab).
  4. Golden S.A. et al. (2011) A standardized protocol for repeated social defeat stress in mice. Nat Protoc 6:1183–1191.