Automated Remote Focusing, Drift Correction, and Photostimulation to Evaluate Structural Plasticity in Dendritic Spines

Long-term structural plasticity of dendritic spines plays a key role in synaptic plasticity, the cellular basis for learning and memory. The biochemical step is mediated by a complex network of signaling proteins in spines. Two-photon imaging techniques combined with two-photon glutamate uncaging allows researchers to induce and quantify structural plasticity in single dendritic spines. However, this method is laborious and slow, making it unsuitable for high throughput screening of factors necessary for structural plasticity. Here we introduce a MATLAB-based module built for Scanimage to automatically track, image, and stimulate multiple dendritic spines. We implemented an electrically tunable lens in combination with a drift correction algorithm to rapidly and continuously track targeted spines and correct sample movements. With a straightforward user interface to design custom multi-position experiments, we were able to adequately image and produce targeted plasticity in multiple dendritic spines using glutamate uncaging. Our methods are inexpensive, open source, and provides up to a five-fold increase in throughput for quantifying structural plasticity of dendritic spines.


Introduction
Structural changes in dendritic spines, tiny postsynaptic protrusions on the dendritic surface of neurons, are considered to be the basis of synaptic plasticity, learning, and memory [1][2][3][4][5]. Among several forms of spine structural plasticity, structural long-term potentiation (sLTP) of single dendritic spines has been extensively examined as a structural correlate of functional LTP (fLTP), an electrophysiological model of learning and memory [3,5,6]. Applying twophoton glutamate uncaging at a single dendritic spine induces a rapid and long lasting spine enlargement at the stimulated spine, but not the surrounding spines [3]. The signaling cascades necessary for sLTP have been studied by combining sLTP imaging with pharmacological and genetic manipulation. Both sLTP and fLTP depend on NMDA-type glutamate receptors (NDMAR), Ca2+/Calmodulin-dependent kinase II (CaMKII) and several small GTPase proteins including Ras, Cdc42, Rac1 and RhoA [4,[7][8][9][10][11]. However, due to the low-throughput nature of the measurement, the study of sLTP has been limited to only a few proteins, and among more than 1000 proteins expressed in spines [12][13][14], it is largely unknown which ones are necessary for spine structural plasticity. The quantification of long-term structural plasticity of dendritic spines requires imaging single spines over extended periods of time (typically~1 h), and it is necessary to continuously refocus to the target spines. Moreover, in general, imaging and stimulating multiple dendrites over long periods of time has been difficult with regular two-photon microscopy, limiting the throughput of the quantification of spine structural plasticity. Thus, it was necessary to develop a system that allows for 1) automatic focus and drift correction for long-term tracking of dendritic spines and 2) imaging and stimulation of several regions of interests (ROIs).
Although automated focusing for microscopy is a well-studied topic in literature [15][16][17][18][19][20][21][22], most algorithms are designed for highly specific imaging modes and preparations. These techniques have been tested under well-defined parameters, therefore, their application in a novel paradigm often results in an overwhelming amount of trial-and-error. Algorithms tend to be uniquely suited to either bright-field, phase, or fluorescence microscopy [23]. A lack of functional specificity for software focusing has led some groups to development more inclusive algorithms [20], but the wide variety of imaging setups and biological preparations leaves these attempts incomplete. Hardware focusing systems that correct focus by tracking coverslip location are also commercially available [24], but are incapable of correcting focus drift due to sample deformation which occurs in soft neuronal tissue such as brain slices. In order to optimize software focusing for dendritic spine imaging, an automated algorithm selection tool is necessary to best adapt to the optical parameters and tissue characteristics in the experiment. In addition, since live neuronal tissue can be highly sensitive to objective movements, it is necessary to use a focusing system without objective movements, e.g. an electro-tunable lens (ETL) [25][26][27].
Based on the open-source MATLAB imaging suite Scanimage [28] and an ETL, we have developed an automated system to stimulate and image several individual spines over extended periods of time. With the implementation of an ETL and custom tracking software, our system avoids any artifacts caused by objective or stage movement. We demonstrate that this system allows us to rapidly quantify sLTP in large number of spines.

Results
In order to achieve rapid and reliable focusing required for auto-focusing system, we employed ETL to our two-photon microscope by placing it at a conjugate plane of the back-focal plane of the objective (Fig 1A). A pre-ETL lens resizes the beam to fit the full aperture of the ETL, while two more lenses serve to resize the beam to fit the galvanometers. In this setup, regardless of ETL shape, the beam size is constant at the galvanometers and the back aperture plane of the objective. This setup minimizes the loss of beam intensity and spherical aberration.
Initial tuning of the ETL is accomplished by stepwise movement of a Z motor combined with an autofocusing step using solely the ETL. The resulting voltages used to control the ETL are automatically associated with Z displacement values, while a conversion function is set using either a linear constant or polynomial fitted curve (Fig 1B and 1C). ETL focal length is controlled by changing current passing through the lens using a custom interface built into Scanimage using MATLAB (Fig 1C). A 3D preview of the imaging plane shows the relative position of the Z plane as a result of ETL offset. Finally, by varying the ETL current in phase with the galvanometer scanning cycle, we were able to tilt the imaging plane up to 90˚, thus allowing users to capture objects which would otherwise require multiple Z slices [27] ( Fig 1D).
In order to make long-term imaging possible, we added an interface to compensate for both axial and lateral drift ( Fig 2B). Before the start of imaging, users define the range, step size, and frequency parameters for an autofocus routine. When Z-stacks are collected, images are automatically used for auto-focusing. A region of interest (ROI) is defined around the dendritic spine to be stimulated. In order to expand the applicability of our autofocus module to various imaging setups, we have included 30 different autofocusing algorithms, previously described by Pertuz et al. [29]. To test the appropriate algorithm for our purpose, we designed an additional application which tests each algorithm against a set of pre-acquired Z stack images, comparing both accuracy and computation time (Fig 2A). In order to ensure that the autofocus algorithm is running normally and using the appropriate part of an image, each collected slice is displayed along with its respective ROI and Z position ( Fig 2D). Finally, lateral drift is measured by comparing the imaged position with a reference image by calculating cross-correlation (8), and corrected by immediately shifting the galvanometer scanning angle. While both autofocus and lateral drift correction speeds are dependent on the pixel count of an image, the speed of calculation for a 128x128 pixel image is consistently less than 10 ms ( Fig  2C), far exceeding the speed required for most imaging setups.
In addition, we designed a user-friendly interface to rapidly find, store, image, and photostimulate multiple positions (Fig 3). Either motor or scanning controls are used to identify dendritic spines for photostimulation (glutamate uncaging). A central GUI allows users to manage multiple positions and set multiple experimental parameters ( Fig 3B). As positions are defined, reference images are automatically collected (Fig 3D). Once all positions are defined, all motor positions are mapped to galvanometer scanning angles relative to a single motor coordinate which defines the field of view (Fig 3A). A separate window allows users to design a timeline for their experiment (Fig 3C). The timeline allows users to control imaging frequency, duration, and define when glutamate uncaging will occur to stimulate dendritic spines. Timeline events can be staggered between positions to avoid conflict between successive uncaging or exclusive imaging events. If the amount of defined positons exceeds the maximum which could be concurrently imaged within a given time constraint, new positions are rotated into the imaging sessions as imaging for other positions is completed ( Fig 3C). As imaging proceeds, each position is continuously updated using its reference image (Fig 3D), while an automatic re-alignment of the photoactivation ROI to the cell membrane immediately precedes photoactivation ( Fig 3E).
To test and further optimize the efficacy of our non-motor multi-position imaging system, we measured structural plasticity of dendritic spines in hippocampal CA1 neurons transfected with enhanced green fluorescent protein (EGFP) in organotypic hippocampal slice prepared from mice (Fig 4). The lateral and axial drift corrections were successful at tracking most spines over an hour-long imaging session. Out of 60 spines which were randomly chosen for analysis, only four drifted out of the field of view over a period of 50 minutes. Of the four cases, two involved drastic morphological changes in the dendrite resulting from cell death, while the other two suffered from unusually low fluorescence and high background noise.
Although drift correction was effective at keeping the general dendritic region in place, the spine set to be stimulated sometimes moves relative to the dendrite. Since glutamate uncaging had to be precisely targeted to the surface of the spine, we added a secondary drift correction method which would relocate the uncaging target to the surface of the spine immediately prior to uncaging (Fig 3E). Correction of the uncaging target was achieved by binarizing the image, locating the perimeter of the resulting objects, and moving the uncaging target to the closest spot on the perimeter. This allowed automated glutamate uncaging on multiple spines at  [29]. Abbreviations expanded in Table 1. Percent relative accuracy (gray bars) indicates standardized mean distance of Z position selected by algorithm vs target. 100% = no distance, 0% = maximum distance, 50% = distance if position is picked at random. Blue lines indicate average time to calculate focus value for each slice. (B) Parameters for focus and drift correction are controlled through a GUI. Users identify an algorithm, Z range and amount of steps, and whether extra images are collected for autofocus. Drift correction can be enabled to use galvanometers (scan shift) or motor repositioning. Users also have the option to enable or disable the ETL. (C) Reference-based drift correction speed is correlated with pixel size. Image resolution indicates pixel count for one dimension of a square image. (D) Live updates inform users of the selected focus position (red box) and spine ROI (white box) used to determine relative focus value. consistent locations at the spine surface. We found that glutamate uncaging induced a rapid increase in volume within few minutes (transient phase) followed by long lasting enlargement (sustained phase), consistent with previous studies [3,10,41]. During the entire imaging session, the user did not need to be present at the microscope, demonstrating the capability of the automated tracking and stimulating software.

Discussion
We have designed an easily implementable module for Scanimage to allow for multi-position scanning and photoactivation of dendritic spines to study postsynaptic plasticity. Furthermore, we described an implementation of an ETL in the excitation path which minimizes the signal loss and distortion. The ETL served both to increase imaging speed and remove sample drift caused by rapid stage or objective movements when changing focus. Our optical implementation of the ETL as a remote focusing element is combined with a straightforward user interface which is able to align and control the ETL current, and as a result, the axial focus. Furthermore, our software interface allows users to tilt the imaging plane in 3D by rapidly modulating the axial focus position in phase with the Y-scanning galvanometer. We expect this feature to be particularly useful in neuroscience, where long, straight neuronal projections can be scanned along their own axis, resulting in a significant increase in scanning efficiency. We found that an ETL-based system is relatively low price and easily implemented in any two-photon microscope. While the focusing speed of an ETL (15 ms) is sufficient for multi-position imaging, tilted-plane imaging needs to be performed fairly slowly, at around 1Hz, to allow the ETL sufficient refocusing time along the imaging plane.
It should be noted that there are faster (but more expensive and potentially more complicated) focusing devices which could be used with our software. For example, spatial light modulators (SLMs) can create 3D holograms within 2-4 ms, and have adaptive optics capabilities to potentially decrease distortion and aberration [42][43][44]. A focusing device using a secondary objective and a galvanic mirror [45] provides even faster focus movement (~1 ms). Perhaps the most well-established remote focusing element is the acoustic optic deflector (AOD), which can provide high-performance volume imaging in tissue [46,47].
As for controlling software, we implemented a highly capable and customizable focus and drift correction system in order to broaden biological applications. Previously, dozens of autofocus algorithms have been made available through primary literature and open source code [20]. However, these algorithms were not widely implemented. Since imaging conditions may be drastically different for many users, we designed a tool capable of narrowing down the optimal algorithm based on accuracy and speed (Fig 2A), allowing us to optimize our autofocusing algorithm to spine imaging experiments. Since the benefits of most of the 27 autofocus algorithm have been described in previous literature (Table 1), we did not feel it necessary to identify the ideal imaging conditions which would necessitate their respective use. Regardless, we felt that their implementation stands as a clear benefit to future users whose experimental designs might differ from ours.
Finally, in order to allow the software to optimize experiments for biological events occurring at multiple time scales, we introduced a modular timeline scheduling feature which allows users to designate custom timeframes for imaging and photo-stimulation. This feature was especially important for studying sLTP, which has two distinct phases at different time scales (Fig 4). During transient phase (first~5 min following stimulation), it is crucial to acquire images with higher frequency (typically~10-60 s per image) since the volume change is rapid. However, during the steady state (~10-60 min), spine volume is stable and fast acquisition is unnecessary and rather damaging to the sample. The typical sampling time for the steady state is~2-20 min. We demonstrated that this implementation allows us to measure the time course of sLTP in several spines (so far up to~5 spines) with high efficiency.

Conclusion
We successfully designed and implemented an automated system capable of reliably measuring sLTP in multiple dendritic spines. The implementation of an ETL in the excitation path, combined with galvanoic mirror scanning, allowed us to quickly switch between imaging positions with minimum perturbation to the sample. The customizable autofocus and drift correction system allows our software to track and stimulate individual dendritic spines over extended imaging sessions. By dramatically increasing the throughput of spine imaging and stimulation experiments, our system will accelerate studies to understand molecular basis of spine structural plasticity. In addition, the flexible implementation of software would allow researchers to use it for many imaging/photostimulation experiments.

ETL Implementation
An EL-10-30 ETL (Optotune) was implemented in the excitation pathway (Fig 1). The light path was designed in OpticStudio (Zemax) and optimized during setup so the ETL is

ACMO
Absolute central moment [30] BREN Brenner's focus measure [21] CONT Image contrast [31] CURV Image curvature [32] DCTE DCT Energy measure [18] DCTR DCT Energy ratio [33] GDER Gaussian derivative [20] GLVA Gray-level variance [34] GLLV Gray-level local variance [35] GLVN Gray-level variance normalized [21] GRAE Energy of gradient [36] GRAT conjugated to the back aperture of the objective. Lens L1 shapes the beam to fill the ETL. L2 and L3 are used to conjugate the ETL to the back aperture of the objective. A typical scan lens and tube lens setup passes the beam to the objective. The ETL is controlled by a current range of 0-300mA as indicated in the manual. A custom lens holder was designed to hold the ETL in place, and fine positioning in X, Y, and tilt was achieved using a 30 mm-Cage-Compatible SM1-Threaded Kinematic Mount with Slip Plate (Thorlabs). ETL shape was actively oscillated by a 10Hz sinusoidal wave during alignment, ensuring that the resulting beam did not stray from its target during axial shifts in imaging.

Software Design
All programming was done in MATLAB to be compatible with Scanimage 3.8, available online for free (http://scanimage.vidriotechnologies.com). Autofocus and drift correction functions were implemented based on published code [29,48]. Abbreviations for focus measure operators are listed in Table 1. Maximum Brightness (BRGT) assigns focus values based on the maximum pixel intensity within the image. Maximum Brightness Gradient (MGRD) assigns focus values based on the maximum gradient magnitude value of the image. Drift correction. Drift correction in XY is calculated using an adapted 2D Fourier transform algorithm [48]. First, a two-dimensional discrete Fourier transform is calculated for each image. Element-wise multiplication is then performed between the Fourier transform of the reference image and the complex conjugate of the newly acquired image. The result undergoes a 2D inverse fast Fourier transform, and the zero-frequency components (corners) are moved to the center of the array. At this point, the X,Y coordinates of the largest element of the matrix minus half of the width and height of the image indicate the relative X and Y shift which needs to be corrected.
Timeline behavior. In order to maximize the flexibility in timeline design (Fig 3C), a timer object is created for each imaging position. Each timer runs for the duration of an imaging/uncaging step, and fires once every imaging period (only once for an uncaging event). Firing of the timer adds an action to the timeline event queue, e.g., 'Move to position XYZ and collect a Z stack". Another timer activates actions in the event queue, and fires once every 0.1 seconds. If an action is present in front of the event queue, it is immediately activated and deleted from the queue, while the event queue activation timer is temporarily paused. Once the action is completed, the event queue activation timer is resumed. The event queue setup ensures that multiple events are not in conflict due to simultaneous activation, and that any position can be deleted during an imaging session. Implementation. We have made the source code for our module freely available at https://github.com/mikeusru/mdia. A detailed help file is included, providing a step-by-step illustrated tutorial to installation and operation of the module. Our code has been designed to function as an add-on rather than a replacement for existing MATLAB functions, so there is minimal overlap with existing Scanimage files.

Evaluation of Plasticity
Mouse pups were euthanized by deep anesthesia by isofluorane followed by decapitation. Organotypic hippocampal slice cultures were prepared as described previously [49] from p4-p6 wild-type mice and were cultured for 10-12 days before transfection. A biolostic particle delivery system (Helios 1 Gene Gun System, Bio-Rad) was used to introduce fluorescent GFP labels to obtain sparse transfection of neurons. Two to six days after transfection, neurons in sparsely GFP-labeled CA1 hippocampal regions were chosen for imaging. Individual spines in the striatum radiatum on secondary apical dendrites were chosen for observation. MNI-caged L-glutamate (4-methoxy-7-nitroindolinyl-caged L-glutamate, Tocris) was uncaged with a train of 820-nm laser pulses (3.5-4 mW under the objective, 30 times at 1 Hz) near a spine of interest. Pulse duration was varied 4-8ms based on depth of the spine in tissue, allowing for reliable uncaging without excess light exposure. Experiments were performed at room temperature in ACSF solution containing (in mM): 127 NaCl, 2.5 KCl, 25 NaHCO3, 1.25 NaH2PO4, 4 CaCl2, 25 glucose, 0.001 tetrodotoxin (Tocris) and 4 MNI-caged L-glutamate, bubbled with 95% O2 and 5% CO2.

Animals
Wild-type C57BL/6J mice used in the study were purchased from Charles River Laboratories. P4-p6 pups were taken from mothers housed individually in Tecniplast 1 ventilated cages. Animals were housed on a 12 hour light cycle with a room temperature of 74˚F, 50% humidity, with Harlan 7092 ¼" corn cob bedding. All animal procedures were approved by the Max Planck Florida Institute for Neuroscience Animal Care and Use Committee, in accordance with guidelines by the US National Institutes of Health. Max Planck Florida Institute has been AAALAC Accredited since June, 2014.

Quantification and Statistics
Spine volume was quantified using custom software written in MATLAB; all Z slices were summed together and oval and polygonal ROIs were drawn to select spines and dendrites, respectively. Volumes for each object were standardized to their average pre-uncaging values. Statistical significance was obtained using unpaired t-tests comparing the stimulated spine and adjacent spine averages to the dendrite as a control. Raw data used in quantification for Fig 4 is available online [50].