Figures and data

Zapit system overview.
A. System schematic. The unexpanded laser beam (cyan) is directed onto the galvos and then targeted to the sample via a dichroic mirror. A lens focuses the laser beam onto the sample. The sample is imaged onto a camera (green) using this same ‘scan lens’ as an objective, combined with a tube lens in front of the camera. B. Our Zapit design is low-cost and largely consists of commercially available parts (custom parts shown in purple). This design can be modified to meet user needs, such as component orientation. A full parts list is available on Github. C. User-friendly control software. The software guides the user through sequential scanner and sample calibration steps (top left and right, respectively). From here, the user can define stimulus locations (bottom right), to then deliver stimulation (bottom left) to said locations. The end result is that calibrated stimuli are projected onto the imaged brain surface for real-time visualization. D. Full usage documentation and troubleshoot support. A dedicated website (http://zapit.gitbook.io/) is available for setting up Zapit hardware and software, usage instructions and troubleshooting steps. Further support is available from the creators and wider community for user-specific implementation needs and issues.

Hardware components of Zapit.
All parts, except for the laser and laser adaptor, are available from Thorlabs, with appropriate part numbers. Dashed arrows indicate where sections should be joined. A comprehensive parts list and assembly instructions with visual aids are available on Github. A. Left side, middle and right side views of a fully-constructed Zapit system. Smaller letters correspond to individual sections below. B. Laser attached to custom adaptor connected to associated right angled-mirror. C. Galvo mirrors with attached connector parts. D. Dichroic filter in cage cube with objective lens in lens tube and emission filter in cage plate. E. Camera attached to connecting tubes, with one lens tube containing tube lens.

Scanner calibration using the Zapit GUI.
A. (i) The Zapit GUI displays a live image feed from the camera. This example shows the dorsal surface of the skull with the two blue arrows indicating the location of bregma and a position 3 mm anterior from bregma. The panel below shows an close-up view of the GUI control panel, highlighting options for calibration, controlling laser stimulation and camera imaging. (ii) In ‘Point Mode’, the user can manually click locations in the image FoV, and Zapit will target light to this location. However, when ‘Uncalibrated’, the actual beam location (bright point) does not match with the desired target location (red circle). The green ‘+’ indicates the automatic detection of the beam location on the sample. (iii) ‘Run Calibration’ initiates an automatic calibration routine to correct this targeting error. Zapit systematically moves the beam over a grid of points and conducts an affine transform between the camera-measured and intended beam positions. (iv) Once calibrated, the user can click on locations in the image and beam goes to the intended target position with minimal error.

Sample calibration using the Zapit GUI.
A. (i-ii) Sample calibration. The user defines the position of the skull in the FoV using two landmarks, such as bregma and bregma +3 mm. These coordinates can be marked onto the skull during a previous surgery using a stereotaxic frame. Whilst clicking these coordinates, a brain outline (blue) is dynamically positioned, scaled, and rotated, providing instant feedback on the calibration. (iii) When both reference points have been selected, the use will be prompted to confirm the calibration. Once confirmed, the brain outline will turn green. (iv) The user can then load in target points defined in coordinate space, and confirm correct targeting by stimulating the target locations (‘Zap Site’). There are additional scanning options that allow for the outline of the dorsal brain mask, or specific cortical area masks, to be continuously traced by the laser on the sample (as shown by the two example photos). These can be useful for visual alignment checks.

Generating photostimulation conditions using the interactive stimulus editor.
A. Screenshot of the stimulus config editor. The user adds or modifies stimulus locations by clicking on the top-down view of the brain. Points can be added either freely (‘unilateral’ mode) or symmetrically on the left and right sides (‘bilateral’ mode). The laser power, stimulation frequency, and ramp-down time are set to default values for all stimuli using this GUI. The stimulus set is saved as a human-readable text file. Laser power, ramp-down, and stimulation frequency can be altered on a trial by trial basis by editing this file. B. A stimulus set superimposed onto the dorsal brain surface. All squares with the same number are associated with a single trial and will be stimulated together. C. Close-up of the GUI control panel showing stimulation parameters: laser power, ramp-down duration, and stimulation frequency. The stimulus set can be saved and loaded as a human-readable text file. D. The corresponding stimulus configuration file (YAML) from the stimulus-set in B. Note that the file is abbreviated to highlight conditions 6-8 in the set. E. Results when targeting the individual trial patterns shown in panel B. Note these images show stimulation results on a 3D-printed mouse brain. The green brain outline shows the sample alignment result in the Zapit calibration GUI.

Reliable and precise photostimulation.
A.MATLAB code snippet to run a stimulation paradigm with TTL input, with users being able to adjust trial type, power, duration, and delay from TTL trigger, as well as logging information B. Same as A, but configured to communicate over TCP/IP for multi-language support and broader experimental integration. C. Communication schematic for inputs and outputs. Solid lines indicate necessary connections, dashed lines indicate optional connections to and from a data acquisition device (DAQ). Analog outputs (AO, pink) to hardware, and hardware input (red) to PFI0. Zapit PC is directly connected to the DAQ, and can be separate to behavior PC via TCP/IP connection. D. The system was programmed to deliver a specific optogenetic stimulus (800 ms with 200 ms rampdown, 40 Hz). A photodiode was positioned at the sample plane to measure photostimulation output (black traces). We also measured the analog input signal sent to the laser (magenta). The inset shows a close up of the photodiode response and analog input signal aligned to the detected onset of the laser input signal (overlay of 50 repetitions). E. Low latency and reliable hardware-triggered photostimulation. Optogenetic stimulation (800 ms + 200 ms rampdown, 40 Hz) was triggered using a 100 ms hardware trigger (red trace). Data for each repetition were aligned to the hardware trigger onset. The inset on the right shows a close-up overlay of hardware (red) and photodiode (black) traces aligned to the hardware trigger onset (overlay of 50 repetitions). F. Same as E, but showing the photostimulation response when a 1000 ms onset delay was added to the stimulation design. Samples were recorded at 100 kS/s using an oscilloscope (PicoScope)

Beam blanking and pointing reproducibility.
A. photostimulation of three points with the beam blanked (switched off) as it travels between them. The imaged laser spots are saturated so their size does not reflect stimulation area. B. photostimulation of the same three points but with beam blanking disabled. This leads to visible lines traced over the skull linking the three stimulation points. Blanking avoids this and lowers the risk of off-target stimulation. C. Shows the time course and reproducibility of beam pointing and blanking. The beam is cycled back and forth over a 10 mm distance while pointing at a photodiode. The beam is blanked while traveling. We record actual scanner position (black traces) and the photodiode signal (blue traces) displaying negative-going (+5 to −5 mm) transitions. There are 160 overlaid trials. The beam is blanked for about 0.4 ms during the scanner motion epoch. Blanking is consistently perfectly synchronized to scanner motion. The blanking period parameters can easily be tuned for any set of scanners via Zapit’s configuration file. D. Example galvanometric mirror scanning patterns for each stimulation paradigm on each axis. Laser onset and offset times are artificially adjusted to emphasize blanking during mirror movement. Blanking periods can be adjusted by the user in system settings. E. Theoretical power output by Zapit, calculated by need for target power per site and number of sites, up to 100 mW. F. Linear relationship between command voltage and power output for the laser. Linear fit models were applied to the data. Inset: Zoom (red square) to show nonlinearity at ~0 V, with linear model fit from the full data.

Electrophysiological validation.
A. Left, neural activity was recorded in awake in VGAT-ChR2-EYFP mice using Cambridge Neurotech silicon probes. Optogenetic effects were characterized as a function of lateral distance (targeting the laser at 0-3 mm away from the recording site). Right, Example image from the Zapit GUI showing a calibration experiment. Red points indicate target sites. A small craniotomy can be seen as the dark patch in the anterior portion of the left hemisphere. B. A half-sinusoid stimulation waveform can mitigate opto-electric artefacts during ephys experiments. This waveform option can be implemented by setting the ‘ephysWaveform’ attribute to ‘true’ in the stimulus config file. C. Spike raster (top) and peristimulus time histogram (PSTH, bottom) from a putative excitatory neuron in secondary motor cortex (M2) on Zapit and control trials. Zapit trials are sorted according to different lateral distances between the laser target site and the probe location. Photostimulation comprised 800 ms with additional 200 ms linear rampdown. D. Suppression of spiking activity as a function of laser beam proximity to the recording site from calibration experiments in M2 (black) and visual cortex (V1, gray). Data show mean and 95% CI. across n = 117 M2 putative excitatory cells and n = 23 V1 putative excitatory cells during 2 mW laser trials. Data are from the same VGAT-ChR2-EYFP mouse. E. Suppression of spiking activity across cortical depths and lateral distances for different laser powers. Data show mean across n = 354 putative excitatory cells recorded in M2 (n = 2 VGAT-ChR2-EYFP mice). F. Distribution of rebound in firing rates across the M2 excitatory neuron population at different laser powers. We only analysed trials where the laser spot was targeted 0 - 1 mm from the recording site. Rebound was calculated as percentage of firing rate change during the 500 ms following laser offset, relative to pre-laser baseline period. This metric was also calculated for control trials for comparison (black). Arrows indicate the median of each distribution. Data reanalysed from Gauld et al. 2025.

Behavioral validation experiments.
A. Whisker discrimination (i) Overview of task and trial design. Mice discriminated bilateral whisker input and reported decisions with directional licking following a delay. A motorized lickport moves in/out on each trial to cue the response window. (ii) Summary of bilateral Zapit target sites. (iii) Results from photoinhibition experiments in expert mice. The maps show the mean effect (color) and statistical significance (circle size) of site-specific photoinhibition on choice accuracy (top) and reaction time (bottom), during the stimulus (left) and delay (right) epochs. ‘X’ indicates non-significant effects (P > 0.05). N = 76 sessions, 4 VGAT-ChR2-EYFP mice. (iv) Results from unilateral anterolateral motor cortex photoinhibition experiments. Unilateral inactivation resulted in ipsilateral choice biases, as seen by vertical shifts of the psychometric curve. Psychometric curves are shown for control trials (black) and left (red) and right (blue) ALM photoinhibition trials. Data points show the mean and error bars show 95% CI across sessions. N = 11 sessions, 3 mice. (v) Dependence of behavioral impairment on laser power. B. Visual change detection. (ii) Overview of task design. Mice viewed a drifting visual stimulus and reported sustained increases in temporal frequency with licking. (ii) Overview of trial design and optogenetic stimulus timing. (iii) Summary of Zapit target sites. (iv) Effect of V1 photoinhibition on task performance. Data show mean and 95% CI across mice (N = 5 mice). Control trials (black), 2 mW (light blue) and 4 mW (dark blue) photoinhibition trials. (v) Same as (iv) but for S1 photoinhibition trials. C. Visual discrimination. (i) Overview of task design. Mice discriminated the spatial location of a visual stimulus and turned a wheel to translate the stimulus to the center of the screen. (ii) Overview of trial design and optogenetic stimulus timing. (iii) Results from a photoinhibition mapping experiment comprising a grid of 52 bilateral stimulation sites positioned at 0.5 mm intervals. The map shows the mean reaction time on Zapit trials (color), and statistical significance as tested against control trials (circle size). ‘X’ indicates non-significant effects (P > 0.05).

Comparison of Zapit to related systems.
‘Code available’ indicates whether readers can download code capable of running the author’s random-access optostimulation paradigm. Only Pinto et al. 2019 provide code. Also, while all previous systems are of high quality, they are very specific to the published experimental protocol and so do not have a ‘Flexible configuration’. No published study has an associated CAD model or build instructions. Not all studies specify coordinates to be stimulated in stereotaxic space. As far as we know, only Zapit has a GUI for building stimulus sets in sterotaxic space.

Resolution of the scanning system.
A. Theoretical and measured X/Y PSF based on a f=150 mm objective lens, a 0.8 mm beam and a Coherent Obis 473 nm 75 mW laser. The empirical data were obtained by translating the focused laser spot over the edge of a razor blade and measuring light intensity with a photodiode placed under the blade. This procedure yields an intensity curve resembling a cumulative Gaussian, which can be fitted as such and converted to a probability density function. While we measure a beam size of under 100 µm FWHM, the true size of the spot on the brain surface is likely to be much larger. The beam will scatter as it goes through the cleared skull and then will scatter further as it enters the brain. B. Beam spot size across the field of view. Focusing the beam on a piece of paper elicits fluorescence which can be imaged with the camera. We acquired many such images while moving the beam over a grid of positions spanning an area roughly the size of a mouse brain (14.0 mm by 10.5 mm, leading to a 1.75 mm separation between points). The image is a composite showing zoomed-in details of the laser spot over all 48 beam locations. The image tiles are discontinuous so the scale bar refers to the beam shape and does not provide information about the separation between adjacent tiles. The size and shape of the beam is very similar across all positions, showing there is no change in the resolution of optical stimulation over the field of view.

Dual-laser configuration for multiple opsin stimulation and real-time imaging.
A. The Zapit system can be assembled to mount two lasers, both of which can be controlled within one experiment. An additional dichroic (Thorlabs) is needed to merge the two beams before the scanners. Resulting fluorescence passes through the chosen emission filter (Chroma). Ongoing changes to Zapit will allow for dual-laser control in the future.

In vivo surgical procedures for Zapit-based experiments.
All steps should be performed under sterile conditions with appropriate pre- and post-operative care procedures in place. A. An anesthetized mouse is installed in a cranial stereotax via bite and ear bars. Inhalation anesthesia is provided via a nose cone. Prior to this step, the scalp is shaved and cleaned to prevent fur contaminating the surgery area during incision. B. An incision is made along the midline of the scalp and a small section of scalp is removed bilaterally using surgical scissors. C. The edges of the scalp can be gently moved to the sides using sterile swabs to expose the dorsal surface of the skull. Sterile saline and swabs can be used to clean the skull and any areas of bleeding. A bone-scraping tool can be used to remove periosteum/membrane on the surface of the skull. This is critical to ensure good adhesion of bone cement to secure the headplate. D. The edges of the scalp are gently fixed to outer edges of the skull using tissue adhesive, ensuring a large area of skull remains exposed. E. A custom metal headplate is then positioned at the back of the animal’s skull. This headplate is designed to provide unobstructed optical access to dorsal cortex. F. The headplate is secured with transparent bone cement. A thin layer of cement is applied across the dorsal skull surface to seal the area and prevent infection. G. Two structural references points are marked in the cement once cured using a small drill. The points correspond to bregma and a position 3 mm anterior from bregma. H. Visibility of the reference points is increased with marker pen to ensure clear identification when viewing the sample through the Zapit system camera. This is critical for accurate sample calibration and alignment.

Laser tests for linearity, stability and onset responses.
We tested Zapit with multiple lasers across a range of price points (3000 GBP - 10,000 GBP) with various wavelengths (450 nm to 594 nm). We also used a cheaper, less stable laser, for comparison (Changchun 473 nm). A. Power vs voltage plots for stable lasers (left, Obis 473 nm, Obis 594 nm, Oxxius 450 nm) and the unstable laser compared to stable lasers. Linear model fits were applied to the data. Inset: Zoom (black square) to show nonlinearity near 0 V, with linear model fit from the full data. B. Stability plots on short timescale for stable lasers (left) and all lasers (right). Top: raw power vs time. Bottom: drift analysis with a rolling average of data points within one window, each window 0.5 ms long from a 10 kHz sampling rate. Note the difference in y-axes between left and right. C. Stability plots on long timescale for stable lasers (left) and all lasers (right). Top: raw power vs time. Bottom: drift analysis with a rolling average of data points within one window, each window 10 minutes long from a 1 kHz sampling rate. D. Onset response plots for individual trials measuring latency of photodiode response relative to analog input for Oxxius 450 nm (left) and Obis 594 nm (right). Inset: 50 trials overlaid. Samples were acquired with a NI-DAQ USB-6453.
