PySight: plug and play photon counting for fast continuous volumetric intravital microscopy: supplementary material

This document provides supplementary information to “PySight: plug and play photon counting for fast continuous volumetric intravital microscopy,” https://doi.org/10.1364/optica.5.00 1104 . It offers a detailed protocol for laser scanning microscopy using a MCS6A multiscaler. It further elaborates on the flowchart of PySight’s logic, the conversion of photon counts to neuronal calcium transients, and the volumetric imaging of nine distinct volumes of interest in a fruit fly’s brain. We provide a brief overview of PySight-compatible commercially available hardware, and conclude with a more detailed account of our experimental protocol, for the sake of reproducibility.


PROTOCOL FOR VOLUMETRIC TPLSM WITH A MCS6A MULTISCALER
This protocol guides the prospective user through the necessary steps towards laser scanning microscopy with a MCS6A multiscaler. For your convenience, we provide customized settings files tailored for planar and volumetric two-photon microscopy in Code 1 [1].
1. Follow the installation procedure detailed at section 2 of the multiscaler's user manual available at FAST website [2].
2. Conduct the first two introductory measurements described at the 'Getting Started' subsection of the multiscaler. The more advanced examples available in that subsection are not essential for ordinary two-photon imaging.
3. Download the provided settings files (https://github.com/PBLab/python-pysight) to the MPANT's folder, e.g. 'C:\MCS6A (x64)'. 4. Open the downloaded settings files with a text editor and replace the number 535 at their first line with the unit number of your particular MCS6A multiscaler. 5. Use the 'MCS6A Settings' dialogue box to load settings file 'pre_test_2d_a.set' (for planar imaging) or 'pre_test_3d_a.set' (for volumetric imaging). 6. Use the 'Data Operations' dialogue box to select the data taking folder and define an informative data file name, e.g. 'D:\Data\User\Preliminary_test.mpa'. Make sure that the 'Write Listfile' checkbox is checked.
7. Configure your microscopy scanning software to output a pulsatile signal once per line through its analog breakout module (e.g. NI BNC-2090A) . Use RF attenuators to attenuate the line synchronization signal to acceptable voltages, as specified in subsection 8.2 of the multiscaler's user manual. ! Critical Excessive voltages or currents may permanently damage the multiscaler, or cause suboptimal performance. Consult subsection 8.2 of the multiscaler's user manual for the acceptable voltage range of the analog (START and STOP) inputs. Measure your signals with an oscilloscope before connecting them to the multiscaler. 8. Connect the line synchronization signal to the analog 'START' channel of the multiscaler. 9. Click the 'Inputs...' button at the 'MCS6A Settings' dialogue box, in order to open the 'Input Thresholds' dialogue box. Tune the threshold level for the line signal to about half of the amplitude of the attenuated line synchronization signal. For example, if the attenuated line synchronization signal rises to +300 milliVolts when a line scan begins, select a discriminator threshold of +150 milliVolts and a rising edge detection.
! Troubleshooting Some analog breakout modules, such as NI BNC-2090A, output a line synchronization signal whose DC offset is negatively correlated with the number of scanning lines per frame. Particularly in our system, the logically high level of the line synchronization signal was 2.1 times higher when scanning 16 lines per frame than when scanning 512 lines per frame or more. Preferably pick a threshold level halfway between 0 and the minimal logically high level of the attenuated line synchronization signal. 20. The multiscaler is now optimized for data acquisition with your particular hardware. Use the 'MCS6A Settings' dialogue box to save settings file 'My_system_set-tings_A.SET', which you could load from now on before each imaging session.
21. Optional: For online monitoring of the acquired image through an existing data acquisition card, connect the fast 'SYNC 1' output from the front panel of the multiscaler to an input port of your data acquisition hardware. Use the 'Sync1' drop-down menu within the settings dialogue box to select which analog input channel to broadcast through the 'SYNC 1' output channel. Image as usual.

FLOWCHART OF PYSIGHT'S LOGIC
Supplementary Figure S1 illustrates the working principles of PySight's software. A small set of input parameters (Supplementary Figure S1a) is sufficient to generate multi-dimensional image stacks. The list of events generated by the multiscaler is demultiplexed back to its originating channels (START, STOP1 and STOP2) (Supplementary Figure S1b) and converted to time values (Supplementary Figure S1c). Each event representing a photon detection is assigned to its respective coordinates along each recorded dimension. For example, in a given experiment a photon could have corresponding start-of-frame, start-of-line, depth in the sample (z), time-since-laser-pulse (for fluorescence lifetime imaging) and a spectral channel, effectively producing a time-lapse stack of 5D images if all synchronization signal parameters are provided. The photons are binned into an n-dimensional array, such as xyztτC, with τ and C corresponding to fluorescence lifetime and spectral channel, respectively. PySight can also generate a multi-dimensional stack of images from other time-to-digital converters, provided that they comply with the input format (see Table S2 above) specified in the package's documentation. Lastly, PySight can be run by a cross-platform graphical user interface (GUI) depicted in Supplementary Figure S2. The GUI is used to choose the file for analysis, required output formats and image size, and to supply PySight with the acquisition system's parameters, like its scanning frequency and temporal fill fraction. A configuration file can be saved and loaded to hasten PySight's startup time. If the user is unsure of some of the parameters, PySight's DEBUG mode enables quick prototyping, generating a sub-stack of the data file to can be examined quickly, supporting an iterative process in which these parameters are optimized. Notably, the GUI is completely optional, making PySight suitable for "batch" running of multiple files on remote servers.

CONVERTING PHOTON COUNTS TO NEU-RONAL CALCIUM TRANSIENTS
We paid a closer look at the relationship between photon counts and calcium transients for neuronal somata. A linear relationship was found between the two metrics (see Supplementary Figure S3), but its slope varied from one neuron to another. The cell-specific ratio between photon counts and calcium transients (see Supplementary Figure S3b) may arise from differing concentrations of GCaMP6f, or slightly different light collection efficiency.
We verified that our time lapse recordings were indeed taken in a photon-depleted regime. To do so, we summed different numbers of consecutive frames taken at normal imaging conditions to simulate longer dwell times per pixel, in a similar  Fig. S1. Flowchart of PySight's logic. a) Input parameters for PySight. b) Demultiplexing of event detection times into their originating channels, some of which relate to beam steering elements and others to photodetectors. c) The list of photon arrival times is corroborated by the spatial location of each detected photon, which is used to populate an ndimensional histogram of photon counts, giving rise to imagery. a b Fig. S2. Images of PySight's cross-platform GUI. Panel (a) shows the main application screen, allowing the user to load either a raw data file created by the multiscaler or preprocessed data conforming to PySight's specification, for visualization purposes. In this screen the user should also specify the layout of the analog and digital channels used in the experiment, or load a pre-existing configuration file with these settings already set. The advanced settings screen shown in (b) enables more fine-grained control on PySight's internal logic and processing. For example, the "Mirror phase" value is the delay in microseconds between the pulse signifying "start-of-line" and the actual positioning of the mirror in place. This value, as well as most others, can be iteratively improved until a satisfactory result is achieved for a given acquisition system. The full explanation on the usage of PySight and its parameters can be found in the documentation of the Python package [1]. manner to [3]. We suspected that short dwell times, on the order of 40-80 ns per pixel, typical for resonant-galvo scanning systems, are beneficial when using photon counting, since each pixel will almost necessarily contain very few photons. Yet when dwell times increase to the order of a few microseconds, and during each pixel hundreds of laser pulses excite the sample, the high photon flux will not be as beneficial.

FULL VOLUMETRIC CALCIUM IMAGING FROM MULTIPLE BRAIN AREAS
For the sake of clarity, Figure 3 Figure S5 shows nine such volumes of interest, spanning the following olfactory brain areas: While the right antennal lobe (VOI 5, purple-colored) has exhibited strong odor response dynamics, no such responses were identified in a void volume of interest selected right on top of it (VOI 9, yellow-colored, Supplementary Figure S5b). These findings support the conclusion that PySight is capable of resolving distinct laminar dynamics simultaneously sampled by the ultrasonic variofocal TAG lens, rather than merely extending the effective depth of field using Bessel beams, as demonstrated earlier [4].
The dwell times for the volumetric imaging can be derived from two different metrics: either from the reconstructed volume properties (as one is free to choose the number of voxels in each scanned dimension) or tied to the scanning frequency of the fastest element and the choice of number of voxels in that particular axis. In the first case, the final number of voxels in the rendered volume is determined by the choice of voxel allocation in each of the scanned dimensions. In the volume presented in Figure 3, the PySight-rendered volume had 200 x 512 x 150 voxels in xyz with 73.4 volumes per second, or approximately 1.1 billion voxels per second, which corresponds to about 650 picoseconds per rendered voxel (including the fill fraction of the resonant mirror). In turn, the second metric considers the asynchronous manner in which our scanners work, a property that affects laser pulse deposition in the sample as not all voxels are visited in each period. The TAG lens traverses its axial range in 2.6 µs; given our choice to voxelize this scanned dimension into 150 voxels, we reach a voxel dwell time of 17.63 ns. We choose to use the second metric as it better correlates with the deposition of laser pulses in the sample.

PYSIGHT-COMPATIBLE HARDWARE
While PySight has been built around specific hardware (the MCS6A, top row of Table S2), its open-source code can handle any list of photon arrival times through a well-documented application interface (Supplementary Figure S1). Table S2 compares the key features of commercially-available time-todigital converters that could be used with PySight software.

A. Animals and Anesthesia
All imaging experiments and surgical procedures were approved by the Tel Aviv University ethics committees for animal use and welfare and followed pertinent IACUC and local guidelines. Adult male mice from the C57BL/6J-Tg(Thy1-GCaMP6f)GP5.5Dkim/J transgenic line were used. These mice constitutively express the GCaMP6f calcium indicator, mainly in L2/3 and L5 neurons [5]. Animals were housed under standard vivarium conditions (22±1 • C, 12h light/dark cycle, with ad libitum food and water). For cranial window implantation, anesthesia was first induced by 5% Isoflurane, and then maintained on 1.5-2% mixed in a gas mixture of oxygen and nitrous (analgesic) throughout the surgical procedures. When anesthetized, core body temperature of animals was maintained at 37 • C. Analgesic where also administered during and postoperation.

B. Surgical procedure
Prior to the surgeries we curve a 7 mm round glass using a similar method developed by Kim and coworkers [6]. Briefly, a paraffin-based ointment (Duratears, Alcon-Couvreur N.V.) is applied to the mouse's eyes to maintain their moisture during surgery. The skin over the skull was removed and the skull surface was cleaned with a scalpel over the surgical area. Next, a craniotomy was made to match the curved glass implant using a 0.5-mm-diameter drill (Fine Science Tools, 19007-05). Throughout the drilling the skull was perfused using artificial cerebrospinal fluid (aCSF) solution. Once the bone piece was disconnected from the skull we removed the bone and the curved glass was placed over the cranial window while taking care to avoid touching the brain surface and while taking extra care to leave the dura intact. We performed all steps under continuous perfusion of aCSF solution. Once the curved glass implant was in its final position, we dried its edges and glued the window to the skull with UV-light-cured adhesive (UV glue; Loctite, 4305). A stainless steel annular head plate was installed around the glass and the gap between the head plate and the skull was filled with the UV glue. After curing the glue, we cleaned the surface of the window and covered it with fast curing silicone to avoid braking of the window when the mouse is free in his cage . The mouse was transferred to a recovery cage and placed on a heating pad until it awoke. We subcutaneously administered the mice carprofen (5-10 mg/kg) for the first 3 days after surgery as analgesic. For the first 7 days after surgery, we checked all mice daily for signs of distress. We resumed feeding using a food hopper 14 days after surgery. Mice were left to recover for 3-4 weeks before imaging started. First, the skin atop the cranium was removed and the skull surface was cleaned with a scalpel while continuously perfusing ACSF solution over the surgical area. Next, a craniotomy matched in size and shape to the outline of the 7mm glass implant was performed as follows: i) creation of a groove along the perimeter of the 7 mm round glass using a 0.5 mm diameter drill, ii) removal of the round shaped bone piece from the surrounding skull and iii) placement of the curved glass on the exposed brain, carefully avoiding touching the dura, iv) fixation of the curved glass window with super-glue to attach its edges to the surrounding skull. As final step, the window was stabilized with a thin layer of dental cement on the surrounding skull. During the drilling and exposure of the brain, artificial cerebral spinal fluid (ACSF) was constantly perfused. In order to allow head fixation during optical brain imaging, we installed a custom made annular head plate (10 mm inner diameter) around the glass window and filled the gap between the head plate and the skull with dental cement. We transferred the mouse to a recovery cage and placed it on a heating pad until it awoke. We then returned the mouse to its home cage. During the first three days following surgery, mice were subcutaneously administered with carprofen (5-10 mg/kg). Mice were allowed to recover for a period of three weeks before imaging. All data presented here was obtained from awake, head-restrained animals that were allowed to run on a carousel during imaging sessions. Prior to imaging, animals were habituated to the imaging conditions across five consecutive days.
C. Fly preparation GH146-Gal4 driver line was used to drive expression of GCaMP6f for volumetric calcium imaging, or ASAP2f for planar voltage imaging. Cuticle and trachea were removed, and the exposed brain was superfused with carbogenated solution (95% O 2 , 5% CO 2 ) containing 103 mM NaCl, 3 mM KCl, 5 mM trehalose, 10 mM glucose, 26 mM NaHCO 3 , 1 mM NaH 2 PO 4 , 3 mM CaCl 2 , 4 mM MgCl 2 , 5 mM N-Tris (TES), pH 7.3. Odors at 10 −1 dilution were delivered by switching mass-flow controlled carrier and stimulus streams (CMOSense Performance Line, Sensirion) via software controlled solenoid valves (The Lee Company) or by a custom air puffer based on 2V025-08 solenoid valves. Flow rates at the exit port of the odor tube were 0.8l/min.

D. Planar intravital calcium imaging
The two-photon laser scanning microscopy setup is based on a custom-modified movable objective microscope (MOM, Sutter Instrument Company) sourced by an 80 MHz 140 fs Ti:Sapphire laser (Chameleon Ultra II, Coherent Inc.) tuned to 940 nm. The original MOM design [7] was modified by replacing its galvo-galvo with an 8 kHz resonant-galvo scanning system (RESSCAN-MOM, Sutter Instrument Company) for fast planar beam steering, and adding a beam path for photothrombotic occlusion (not used in the present study). Additional modifications for fast volumetric imaging are described in the following section. The on-board FIFO, where available, is filled as rapidly as specified by the burst rate, and drained as rapidly as specified by the sustained rate. b A peak count rate of 10 10 counts per second per channel can be sustained for 6.5 microseconds.
Laser beam power was adjusted using an electro-optic modulator (D7v-T3, Qubig GmbH) that was mounted on a multi-axis tilt platform (850-0010, EKSMA Optics) in between two polarizing beam splitters (PBS102, Thorlabs Inc.), and fed by a high voltage amplifier (A-304 customized to 200x gain, A.A. Lab Systems Ltd.). Since the scanning software (ScanImage, Vidrio Technologies, LLC.) outputs strictly positive voltages up to 2 Volts, an offset voltage of -200 Volts was added by the high voltage amplifier, to maintain a balanced dynamic range of ±200 Volts. An achromatic quarter wave plate (AQWP10M-980, Thorlabs Inc.) introduced a bias retardation so as to minimize the optical transmission for an input voltage of -200 Volts.
During the imaging experiment, a planar FOV spanning 440 × 440µm 2 was imaged at 15.24 Hz, 200 µm below the pia for 60 seconds.

E. Volumetric intravital calcium imaging
For volumetric imaging, a tunable acoustic gradient index of refraction lens (TAG Lens 2.5, TAG Optics Inc.) was inserted into the beam path upstream of the resonant-galvo system. An iris diaphragm (SM1D12CZ, Thorlabs Inc.) was used to reduce the beam diameter below 4 mm at the entrance to the TAG lens, in accordance with the effective clear aperture of the TAG lens at its 189 kHz resonance. A pair of achromatic doublet lenses with focal lengths of 45 and 60 mm (AC254-045-B and AC254-060-B, Thorlabs Inc.) were used as a relay system between the TAG lens and the resonant-galvo system. The TAG lens, its upstream iris and downstream relay system were mounted on top of a pair of manual linear translation stages (M-423, Newport Corporation) and a high load lab jack (281, Newport Corporation) for easy alignment.
Before each volumetric imaging session, the laser beam was first aligned with the microscope with the TAG lens turned off and its target. The aperture of the iris diaphragm was then reduced to 4 mm and the TAG lens driven to the maximally permitted amplitude for its 189 kHz resonant frequency (62% of its maximal driving voltage, corresponding to an optical power difference of 20 diopters). A fixated sample of 1000 nm fluorescent microspheres, prepared according to [8], was then imaged at high digital magnification for fine alignment of the TAG lens with the beam path. The TAG lens is known to introduce some spherical and comatic aberrations that degrade the lateral and axial resolution as the lens modulates the focal depth away from its nominal value, especially at high modulation intensities as used in the present study [9][10][11][12]. As long as the lens is misaligned with the beam, the image of the beads seems to drift laterally as the objective lens is translated up and down. The micrometers of the lens's translation stages were thus carefully driven until the said aberrations were minimized. Once aligned, the volumetric microscope was used to acquire a reference volumetric movie of a dilute solution of fluorescein in double distilled water, collapsed over time. Each acquired volumetric Drosophila movie could then be divided by the reference volume, to arrive at fairly accurate normalized brightness levels for each voxel. This normalization step is necessary due to the sinusoidal profile of the TAG lens focal oscillation, giving rise to uneven illumination conditions. In practice, given the 3× digital zoom used for Drosophila volumetric imaging, the reference volume could be collapsed to a one-dimensional axial intensity variation by which the acquired 4D volumetric Drosophila movie was divided. It should be emphasized that the usage of a clear fluorescein solution as a reference volume is only valid for weakly scattering tissues such as Drosophila brain.
The live mammalian brain is notorious for its high, nonisotropic turbidity, causing uneven exponential attenuation of oblique illumination angles [13][14][15][16][17]. An effective axial range of 330µm was consistently measured with our volumetric microscope when driving the TAG lens at the said maximally permitted amplitude for its 189 kHz resonant frequency (62% of its maximal driving voltage, corresponding to an optical power difference of 20 diopters). This axial range was measured first by acquiring two z-stacks of a fixated sample of 1000 nm fluorescent microspheres, with the TAG lens on and off. It was later confirmed by manually registering features resolved in PySight-generated volumes to the respective features in a conventionally acquired z-stack. Specifically, before the imaging session on which Figure 3 and Supplementary Figure S5 are based, conventional z-stacks of 1000 nm microspheres and of two other fruit flies were acquired, along with PySight-generated volumes of the same fields of view, thereby validating that an axial range of 330µm was available in this particular imaging session as well.
Adult female Drosophila melanogaster were prepared as detailed above. Each trial lasted 33.5 seconds (2462 volumes at 73.4 volumes per second). After five seconds of baseline imaging, a five-seconds long puff of 2-Pentanone or isoamyl acetate was delivered to the fly. After five additional seconds, an additional, identical, five-seconds long puff of the same odor was delivered to the fly. A proximal negative pressure air inlet continuously cleared the chamber from odor traces throughout the imaging session. Six trials were acquired for each odor, with an inter-trial interval of 2-4 minutes. We increased the volumetric imaging rate to 73.4 volumes per second by decreasing the number of scanned lines along the slow galvo axis to 200 lines (see Supplementary Figure S6). Using our 10× objective lens, a digital magnification of 3×, and the said 330µm axial range of our TAG lens, the resulting volumetric FOV spanned 234 × 600 × 330µm 3 . We then repeated the experiment while zooming in on the antennal lobes at a digital magnification of 7×, while scanning 220 lines along the slow galvo axis to maintain a volumetric imaging rate of 67.2 volumes per second. The resulting volumetric FOV spanned 110 × 257 × 330µm 3 using our 10× objective lens and TAG lens.

F. Planar intravital voltage imaging
Four adult female Drosophila melanogaster were prepared as detailed above. The lateral horn, mushroom body and antennal lobe were imaged by TPLSM using a Sutter Instrument Company's DF scope with resonant scanners (8 kHz, RESSCAN-MOM) based on an Olympus BX51WI microscope, Mai Tai HP DS laser. The imaging software used in the DF-scope was Sutter's MScan. We increased the imaging rate to 247 Hz by decreasing the number of scanned lines along the slow glavo axis to 64 lines. Using a 20× objective lens and a digital magnification of 6×, the resulting FOV spanned 10 × 50µm 2 .