(a) Schematic of the procedure for in silico simulation of imaging data. Neuronal activity was simulated within spheres located in a 3D volume, integrated over an elliptical PSF (blue) that was scanned on a curved FOV, projected on a 2D plane to generate artificial frames, and modulated through an intensity mask. Only voxels falling within the PSF contributed to the pixel signal (black trace). (b) Segmentation of in silico data for uncorrected (left, red lines indicate identified ROIs) and corrected (right, blue lines indicate identified ROIs) endoscopes. (c) Number of ROIs segmented in simulated FOVs for uncorrected (Unc.) and corrected (Cor.) microendoscopes. n = 54 segmentations from nine simulated FOVs, Wilcoxon signed-rank test, p=0.037. In this as well as in other figures, values from individual experiments are shown in gray, the average of all experiments in black and error bars indicate sem, unless otherwise stated. In this as well as in other figures: *p<0.05; **p<0.01; ***p<0.001; NS, not significant. (d) Number of segmented ROIs as a function of the peak-SNR threshold in artificial data from n = 9 simulated experiments. A two-way ANOVA with interactions showed a significant effect of peak-SNR threshold (p=1E-50) and of the interaction between peak-SNR threshold and probe type (p=1E-5) on the number of segmented ROIs, while the effect of probe type was not significant (p=0.096). (e) Average SNR of calcium signals under the different experimental conditions (peak-SNR threshold = 20 for the segmentation). n = 987 and 1603 ROIs for nine simulated experiments with uncorrected and corrected microendoscopes, respectively. Mann-Whitney test, p=5E-52. (f) Schematic representation of how radial distance (distr) and pairwise distance (distp) were calculated. (g), Pairwise correlation as a function of radial distance for simulated experiments with uncorrected (left) and corrected (right) microendoscopes. In this as well as other figures, lines show the linear regression of data. Shaded areas represent 95% confidence intervals. n = 738 and n = 869 pairwise correlations for uncorrected and corrected microendoscopes, respectively, from the n = 9 simulated experiments shown in (e). Linear regression fit of data: slope = 0.002, permutation test, p=0 and slope = −2E-4, permutation test, p=0.27 for uncorrected and corrected microendoscopes, respectively. (h) Distribution of the correlation of calcium signals with the first (left) or second (right) component of the ground truth for experiments with uncorrected and corrected microendoscopes. First component: n = 987 and 1603 ROIs for uncorrected and corrected microendoscopes, respectively, from n = 9 simulated experiments. Second component: n = 62 and 85 ROIs for uncorrected and corrected microendoscopes, respectively, from n = 9 experiments. (i) Schematic of the experimental configuration in awake animals. (j) Two-photon images of VPM neurons expressing GCaMP7f showing manually identified ROIs for uncorrected (left, red lines) and corrected (right, blue lines) type II microendoscopes. (k) Spatial density of ROIs identified in in vivo experiments. n = 9 FOVs and 6 FOVs from three animals with uncorrected and corrected microendoscopes, respectively. Student’s t-test, p=0.92. (l) SNR of segmented ROIs in in vivo recordings. n = 557 ROIs from 9 FOVs for uncorrected microendoscopes; n = 306 from 6 FOVs for corrected microendoscopes. Mann-Whitney test, p=0.0011. (m) Pairwise correlation as a function of radial distance for in vivo experiments. Number of pairwise correlations: n = 168 from 9 FOVs, n = 36 from 6 FOVs, and n = 92 from 24 FOVs for uncorrected, corrected (dataset 1), and corrected (dataset 2), respectively. Dataset two was obtained from experimental sessions performed during behavioral state monitoring as in Figure 6. Linear regression fit of data: slope = 0.0002, permutation test p=0.006 for uncorrected; slope = −0.0005, permutation test p=0.05 for dataset 1; slope = −0.0007, permutation test p=0.05 for dataset 2. See also Figure 4—figure supplements 1–2.