BSSE: An open-source image processing tool for miniaturized microscopy

: Single-photon-excitation-based miniaturized microscope, or miniscope, has recently emerged as a powerful tool for imaging neural ensemble activities in freely moving animals. In the meanwhile, this highly flexible and implantable technology promises great potential for studying a broad range of cells, tissues and organs. To date, however, applications have been largely limited by the properties of the imaging modality. It is therefore highly desirable for a method generally applicable for processing miniscopy images, enabling and extending the applications to diverse anatomical and functional traits, spanning various cell types in the brain and other organs. We report an image processing approach, termed BSSE, for background suppression and signal enhancement for miniscope image processing. The BSSE method provides a simple, automatic solution to the intrinsic challenges of overlapping signals, high background and artifacts in miniscopy images. We validated the method by imaging synthetic structures and various biological samples of brain, tumor, and kidney tissues. The work represents a generally applicable tool for miniscopy technology, suggesting broader applications of the miniaturized, implantable and flexible technology for biomedical research.

In practice, the miniscope technique mainly uses gradient-index (GRIN) rod lenses that offer several advantages compared to compound objective lenses, including low cost, light weight (<1 g), small diameters (<1 mm), long relay lengths (>1 cm), and relatively high numerical aperture (NA, >0.45). These features of the miniscope thus enable minimally invasive imaging of a significant volume of the brain with a cellular-level resolution in freely moving animals. However, broader applications have thus far been largely limited by the properties of the imaging modality. Specifically, unlike compound objectives, GRIN lenses suffer from severe optical aberrations such as distortions and spherical aberrations, mainly due to the radially-distributed parabolic (or non-aplantic) refractive index. These aberrations inherently deteriorate image quality, image resolution, contrast and effective field-of view Although such aberrations can be compensated using additional optical elements [16][17][18], these methods either require special design for different GRIN lenses or are incompatible with a miniaturized system. Computational methods have thereby been developed as an alternative, efficient strategy to separate the background and denoise and extract the signals. Unlike previous assays for processing optically-sectioned (thus high-SNR) data resulted from two-photon or light-sheet microscopy [19][20][21][22], these computational methods are designed to handle typical miniscope imaging conditions with high fluctuating background, movements, distortions, and low SNR. Specifically, current methods mainly rely on region of interest (ROI) analysis [7,11,12,23], principal-component analysis/independent component analysis (PCA/ICA) [22,24] or constrained nonnegative matrix factorization (CNMF_E) approaches [25,26].
However, all existing methods are solely developed for extracting neuronal calcium imaging signals. This is mainly due to the fact that current miniscopy applications have remained almost exclusively focused on functional brain imaging, despite the promising potential for imaging a broader range of cells, tissues and organs. It is therefore highly desirable for a method generally applicable for processing miniscopy images, extending the applications to diverse anatomical and functional studies on various cell types in the brain and other organs.
Here, we develop a computational approach, termed BSSE, allows for automatic processing, background suppression and signal enhancement of single-photon-excitationbased miniscopy images. The approach provides a simple solution to the intrinsic challenges to separate the high background and denoise the overlapping signals. We demonstrated the method using synthetic structures, in vitro brain and kidney sections in mice, and in vivo calcium imaging data. We validated the method on both the lab-built and commercially available miniscopes. We expect this new algorithm to enable miniscopes for broader applications in biomedical research.
To characterize the miniscope, we imaged water-immersed 200-nm fluorescent beads (FSDG002, Bangs Laboratories) and measured the point-spread function (PSF) of the system at varying depths, as shown in Fig. 1(c). The PSF images were Gaussian-fitted and exhibited FWHM values of ~3 µm and ~30 µm in the lateral and axial dimensions, respectively. Notably, the axial PSF is substantially extended due to the strong spherical and other aberrations in the system, which lead to severe spatial overlaps of signals while imaging thick samples. Furthermore, a negative USAF target (R1DS1N, Thorlabs), attached to fluorescent tapes and immersed in water, was used to determine the magnification (~6x) and effective pixel size (1 μm) of the system, as shown in Figs. 1(d) and 1(e).

Animal and tissue sample preparation
For brain tumor tissue, C57BL/6 mice (wild type, WT) were purchased from Jackson Laboratory. GL261 cells were stably transfected with EGFP and stereo-tactically injected into the striatum of the brain, near the ventricles [27][28][29].
For the kidney tissue, the transgenic mouse line with enhanced GFP (EGFP) cDNA under the control of a beta-actin promoter and cytomegalovirus enhancer was purchased from Jackson Laboratory [30].
For the brain tissue, the Macgreen transgenic mouse line with EGFP under the control of the mouse Csf1r promoter was purchased from Jackson Laboratory. The EGFP is expressed in macrophages and trophoblast cells, and specifically in microglia cells in the brain [31].
All animal procedures were approved by the Stony Brook University Institutional Animal Care and Use Committee (IACUC). Mice were bred in-house under maximum isolation conditions on a 12:12 hour light: dark cycle with food ad libitum. ter were obta were placed on uments) and tra ata and behavio drive.google.co sed the first su / recording_201 demonstration s to address the ithm contains two cally, the raw imag on (standard devia ominant low-frequ g, obtaining the im pplied to generate of the signal I B2 i zed, smoothed and I B1 with the weigh ng background, ob ule is used to enh I G1 is generated a = I BF -σ · I G1 , wh mulated Gaussian to zero negative p entify and segmen obtaining the fin 5 μm. kground and t ed in Fig. 2  first, the algorithm separates and suppresses different frequency components of the background. The predominant low-frequency background is initially rejected from the raw image using morphological image processing [33]. The resulting image was then modulated by a weight mask [34,35] to remove the frequency components primarily responsible for the fluctuating background (inhomogeneous background due to the sample or the evolution of background over time). Next, the algorithm enhances the resolution of the background-suppressed image by exploiting the gradient information of the overlapping signals [36,37]. Specifically, we considered the radial symmetry of the 2D PSF of a single emitter or a sub-diffraction-limited point source, as well as its gradient distribution, in the background-suppressed miniscopy image. The signals are initially sharpened by subtracting the weighted first derivative of the image. To ensure the signals are narrowed at a moderate and constant ratio, we selected the scale factor σ for the sharpened signal image I S = I BF -σ · I G1 , where σ is determined as the ratio between the values of the simulated Gaussian PSF and its first derivative at the inflection point. To enhance the resolution between the overlapping signals, we combined the second derivative of the image to identify and segment the crossings of the overlapping regions by zero-concavity analysis. The removal of the background in the first module circumvents artifacts generated by the sensitive response of the image gradients to the fluctuating background. The outcome image of the algorithm exhibits both substantially suppressed background and enhanced signals, as shown in Fig. 2 and Appendix B. For tissue images, a post-smoothing step using a Gaussian filter is included to maintain the continuity of biological structures [33,38]. The BSSE algorithm works with the proprietary software package MATLAB R2015a and above. The source code is available from the authors and on Github (https://github.com/shujialab/BSSE). The method was first demonstrated using synthetic caliber patterns with various spacing, SNRs and intensity, as shown in Appendix C and Figs. 9-13. As seen, using BSSE, we noticed that the method can improve the image quality of the diffraction-limited images. It was also shown that the high background at varying levels was suppressed, and the close-by, low-SNR structures were enhanced and better resolved. Also, as illustrated in Appendix C, the original intensity relationship can be retained for most of the intensity levels and gradually deviates from the linear manner when it reaches noticeably strong or weak intensity regime, considering the fact that the denoising step of the method is intrinsically nonlinear. In addition, in Appendix C, we demonstrated our strategy to process highly dense structure to maintain high-resolution structures while avoiding the loss of weak signals.
Next, we imaged and measured the profiles of fluorescent beads (FSDG, Bangs Laboratories) attached to the surface of a cover slide, as shown in Fig. 3. It is shown that the method not only suppressed the fluctuating background, but also enhanced the signals from single emitters across a FOV of ~300 µm × 300 µm, as shown in Figs. 3(a)-3(d). Because BSSE considers the gradient symmetry of the PSFs, the image degradation caused by the intrinsic aberrations in the system can also be reduced due to their lack of radial symmetry, recovering the Gaussian-like PSFs, as shown in Figs. 3(e)-3(h). It should be addressed that BSSE improves the image quality mainly through enhancing the SNR. We observed that the relatively high SNR of Fig. 3(h) can be further improved, mainly by rejecting the background, thus making the nearby dim bead resolvable as shown in the right peak of Fig. 3(i). It should be noted that here the improvement was demonstrated for the fluorescent beads located on a 2D surface, where the background is mainly resulted from any floating beads or the CMOS camera sensor. In Results, we demonstrated the method by imaging 3D, thick biological samples.

Imaging mouse brain tumor tissue
We first imaged orthotopic mouse brain tumor sections, where EGFP-expressing GL261 cells (GL261-EGFP) were stereo-tactically injected into the striatum of the brain near the ventricles. As seen in Fig. 4(a), the GL261-EGFP cells that were out-of-focus of the miniscope resulted in high background, deteriorating the in-focus signals detected. The signals were further diminished due to the stronger aberrations near the outer range of the FOV. In contrast, the use of BSSE substantially removed the background and enhanced the SNR by more than two orders of magnitude, as shown in Figs. 4(b)-4(g). The in-focus information from the previously overlapping signals can now be well sectioned and resolved, as shown in Figs. 4(h) and 4(i). By extracting the signals out of the high background and reducing the influence of aberrations, the method also effectively enlarged the FOV by >1.5 times (>300 µm × 300 µm). It should also be noted that the dynamic range of the images has been varied due to the improved SNR, so some existing dim structures become less visible, but they can be well displayed by adjusting the contrast of the BSSE-processed images. For the brain tissue images, a good correlation (>0.75) was shown between the raw and processed images by the Resolution Scaled Pearson's coefficient (RSP), which scores the image quality with a normalized value between [-1, 1] [39].

Imaging transgenetic mouse tissue
We next imaged mouse kidneys expressing EGFP driven by the beta-actin promoter using the miniscope, as shown in Fig. 5. The image of the mouse kidney cortex exhibited both highly overlapping signals and out-of-focus background from the convoluted tubules and glomerulus, as shown in Fig. 5(a). After BSSE processing, the image revealed substantially improved lining of tubular structures, as shown in Figs. 5(b) and 5(c). Furthermore, compared to the cortex, lower SNR was observed near the kidney medulla, where the kidney cells were barely visible, as shown in Fig. 5(d). The use of BSSE demonstrated improvement in this region, allowing enhanced resolution of the kidney medullar structures separated as close as ~3 µm, consistent with the measurement from the PSF, as shown in Fig. 1(c) and Figs. 5(e)-5(l). In addition, compared to deconvolution, BSSE can more effectively reduce the background and enhance the signals, as shown in Appendix D and Fig. 14.
Furthermore, healthy brains from mice in which cells express GFP under the Csf1r promoter [31] were also imaged, as shown in Appendix E and Fig. 15. Csf1r-driven GFP fluorescence primarily labels microglial cells in the brain. Using BSSE, the miniscope can detect GFP signal at the single cell level, where the nearby cellular structures as close as a few micrometers were resolved from the high background of the tissue and blood vessels after processing with BSSE.

Calcium imaging
We next validated the performance of BSSE for in vivo calcium imaging of neural ensembles in freely behaving mice. The images were recorded using a commercially available singlephoton based miniscope (Inscopix) at a frame rate of 20 Hz [32]. Due to the strong aberrations and background in the awake brain, the images were initially processed by BSSE using both Gaussian filtering and block-matching and 3D filtering [40] (the step I Raw to I 0 in Fig. 2). As a result, the BSSE algorithm efficiently denoised the calcium transient activity of each cell and removed the strong, uneven background in the time-lapse data. With the BSSE processed image data, we were able to improve the maximum projection that allowed accurate manual identification of ROI components. In contrast, the identification became considerably restrictive using the raw images because of the highly overlapping signals and strongly fluctuating background, as shown in Fig. 6(a). Using the contours determined in the BSSE-processed image, we extracted normalized fluorescence traces ΔF/F from ROI components in both the raw and BSSE-processed images, as shown in Fig. 6(b). As seen, without processing, the raw data generated false positives or failed to identify neurons from overlapping ROIs, as shown in Figs. 6(c)-6(n). It should be mentioned that due to the intrinsic nonlinearity in the denoising process, the ΔF/F values may not be accurately preserved, though the more essential correlations or mutual information between the neurons can be correctly retained.
In Fig. 6, we also confirmed our results using MIN1PIPE [26], an automatic, state-of-theart method for processing calcium imaging data of miniscopes. MIN1PIPE contains several stand-alone modules to accurately separate spatially localized neural activity signals. For nonbiased comparison, we used all suggested and optimized parameters in [26] and excluded automatic movement correction and post-extraction refinement steps for manually adding or removing neurons. Notably, the BSSE-processed calcium data provided comparable image quality that can facilitate identification with very few visually apparent false positives, as shown in Figs. 6(c)-6(n). It should be emphasized that the presentation of BSSE is not to compare with the cutting edge methods like CNMF [25] or MIN1PIPE [26]. On the other hand, we aimed to demonstrate its simplicity as a generic tool to improve wide-field miniscopy images for various tissue studies beyond functional brain imaging. The purpose of Fig. 6 is mainly to show that the method is compatible with calcium image processing, but we admit that the method has not been specialized to achieve many functions obtained with CNMF or MIN1PIPE such as accuracy and automation, though it can be readily compatible and implemented as a module in the automatized pipelines.

Conclusion
In summary, we demonstrated an image processing approach, termed BSSE, for singlephoton-excitation-based, wide-field miniscopy images. It provides a simple, automatic solution to the challenges of overlapping signals, high background and artifacts in miniscopy images. We validated the method by imaging synthetic caliber patterns and biological samples of brain, tumor, and kidney tissues, as well as extracting neural functional signals. In addition, the method was demonstrated on both lab-built and commercial miniscopes, and the algorithmic framework can be readily integrated with many miniscopy control and processing modules, allowing for addressing a wide range of problems. Furthermore, the presented imaging results beyond neural activity suggests broader applications of the miniaturized, implantable and flexible technology.  Appendix B: Illustration of the BSSE algorithm using beta-actin EGFP mouse kidney tissue. Fig. 8. Illustration of the BSSE algorithm using beta-actin-EGFP mouse kidney tissue. (a-c) Architecture of the BSSE algorithm and BSSE-processed images of the kidney cortex of betaactin-EGFP mice. As described in detail in Fig. 2, the results illustrate that the two main modules of the algorithm suppress the background (b) in the image I Raw , obtaining the image I BF , and enhance the signals (c), thus to obtain the final image I BSSE . (d) Cross-sectional profiles in the image I BF and its first-derivative image I G1 along the corresponding solid line in I G1 . (e) Cross-sectional profiles along the solid color lines in I S and I G2 , where I S represents the difference image between I BF and I G1 , and I G2 is the second-derivative image of I BF . Concavity analysis is conducted to identify and segment the crossings of the overlapping signals (e.g. the shaded regions in (e)), obtaining the final image I BSSE . (f) Cross-sectional profiles in the images I Raw and I BSSE along the corresponding solid line in I BSSE . Scale bars: 100 µm (a, top row), 50 µm (a, left of the second row), 10 µm (a, right of the second row).
Appendix C: BSSE processing of synthetic caliber patterns.    (h) BSSE processing of the same synthetic caliber pattern without noise. (i) Average peak intensity of BSSE-processed images (bottom panels in (b,d,f)) (green dots and error bars) and the peak intensity of the profile corresponding to the red line in (h) (gray dots). The green dots represent the mean value of BSSE-processed profiles of each row of pixels in (b,d,f) and the error bars stand for the standard deviation of these pixel values at each peak. The solid black line shows the linear relationship. Although the linear trend is largely retained, deviations from the linear relationship within the pattern can be observed for the BSSE-processed images with noisy raw data when the intensity becomes strong or weak. In contrast, the BSSE-processed image with noise-free raw data maintains acceptable linear relationship.   Fig. 5(a). Right panels, zoomed-in images of the corresponding color boxed regions. It can be observed that although deconvolution (10 iterations) sharpens the images, BSSE further reduces the background and enhances the signals. Scale bars: 100 µm (a, left), 15 µm (a, right).