Two-Photon Mesoscope
Comments
A home-built two-photon laser-scanning mesoscope for imaging whole small specimens in 3D: cleared and stained fish, frogs and mice, plants.
A femtosecond 1064 nm laser is scanned by an XY2-100 galvo head, focused through a scan lens, and the fluorescence is collected by a PMT. A Teensy 3.2 drives the galvos, the Z stage and the laser blanking, and digitises the PMT.
Everything is run from a browser page over Web Serial, and the 3D volumes can be explored in a standalone viewer page. No installation and no microscope are needed. Everything runs locally in your browser.
- Download the viewer. Save
volume_viewer.htmlto your computer: open it on GitHub and click the "Download raw file" button. - Download one volume. From the raw data folder on Google Drive, download one matching pair of files:
volume_.json, the scan metadata, andvolume__ch0.u16, the raw 16-bit voxel data. Both files must have the same name stem. The.u16files are large (often 100 MB or more). - Open the viewer. Double-click
volume_viewer.html. It opens in your web browser; a recent Chrome or Edge is recommended. - Load the volume. Click Open files⦠and select both the
.jsonand the.u16file together (Ctrl-click or Shift-click). You can also drag both files onto the page. - Explore:
- Move through the volume: click or drag in any of the three orthogonal views to move the crosshair, and use the mouse wheel over a view to step through slices.
- Animate the depth: press Play (or the space bar) to loop through the depth (Z) planes.
- Adjust brightness and contrast: drag the black and white handles on the histogram, and use the gamma slider. Try the verdigris colour map.
- Clean up the image: turn on Denoise and Hot pixels to suppress noise and bright speckles.
- Deconvolve: Axial deconvolution sharpens the depth (Z) direction; the result appears as a new channel you can switch to.
Fish, through the 50 mm camera lens
Two-photon image of the head of a cleared and stained fish, taken with the reversed Nikon 50 mm f/2 as the scan lens. The jaws and teeth, eye, gill arches, pectoral fin, vertebrae and individual scales are visible.
System overview
The optical table, with the femtosecond laser at lower left, the beam expander, the XY2-100 galvo scanner at lower right, the PMT detector housing in the centre, the specimen cuvette on the Z stage, and the Teensy and driver electronics.
Optical path: femtosecond laser (1064 nm) β electromechanical shutter β attenuator (a rotating polarizing beam splitter inside a beam dump) β beam expander (10 mm beam) β XY2-100 galvo scanner β scan lens β specimen. Fluorescence is collected by a PMT above the specimen.
- Laser. An Oscillate Photonics Kyma femtosecond 1064 nm laser.
- Detector. A used (eBay) Hamamatsu R3896-05 photomultiplier tube (datasheet). The PMT anode feeds a transimpedance amplifier with a gain of 1 kΞ© (1 V per mA), whose output goes to the Teensy ADC input.
- Scan lens. The system started with a 63 mm f-theta laser-marking lens. A Nikon 50 mm f/2 camera lens works much better. Mount it with the camera-body (rear) end facing the specimen and the front element facing the galvos.
- Z stage. A stepper-driven stage moves the specimen through focus to build up a 3D stack.
Laser safety. This instrument uses an invisible, high-peak-power infrared laser. Use appropriate laser safety eyewear, beam blocks and enclosures.
Volume viewer: volume_viewer.html
This is a standalone, single-file viewer for saved volumes. It needs no server and no installation.
- Large orthogonal views (axial XY, coronal XZ, sagittal YZ) with a linked crosshair, physical aspect ratio, flip X/Y and Z stretch.
- A histogram of the whole volume with draggable black and white levels, gamma, and colour maps: gray, verdigris, green, hot and inverted.
- Denoising: Gaussian smoothing of the displayed slices, scaled to the voxel spacing.
- Hot-pixel filtering: pixels above a fixed threshold, or much brighter than their neighbours, are replaced by the neighbour mean.
- Playback through the Z planes at an adjustable speed.
- Axial deconvolution, Richardson-Lucy along Z, with three PSF options:
- a model PSF (Lorentzian or Gaussian);
- a PSF measured from a scan of a thin fluorescent sheet;
- a PSF loaded from file.
It runs in parallel Web Workers, and the result can be saved as a new volume.
Femtosecond pulse demo: femtosecond_pulses.html
An interactive, single-file demo that shows visually how femtosecond pulses work: why a short pulse in time needs a broad spectrum. Download it and open it in a browser.
Acquisition app: mesoscope.html
This controls the instrument over Web Serial. It needs Chrome or Edge and a Teensy running the firmware. Volumes are saved as volume_.json plus volume__chN.u16, one .u16 file per PMT channel.
- Firmware:
TwoPhotonFirmware/TwoPhotonFirmware.ino, for a Teensy 3.2. Build with the Arduino IDE and Teensyduino, with Board: Teensy 3.2 / 3.1 and USB Type: Serial. It handles:- XY2-100 galvo output, as differential pairs from GPIO with 330 Ξ© series resistors;
- DMA-timed raster scans with synchronous ADC sampling;
- stepper control for the Z stage, with acceleration and soft limits;
- laser blanking.
- Serial protocol:
PROTOCOL.mddescribes the binary packet format between the browser app and the firmware. - Wiring:
wiring_diagram.svgshows how to connect the Teensy 3.2 to the galvo controller's DB15 (XY2-100) connector, the Z stage driver, laser blanking and the PMT input.
Each volume is a pair of files: volume_.json holds the metadata:
- the scan configuration: galvo corners
x0, y0, x1, y1in galvo counts, pixel countsnx, ny, dwell time, settle times, pattern and channel mask; - the Z position of each plane in Β΅m (
zUm); - the calibration (
mmPerCount,originCounts); - the ADC full-scale voltage.
- the scan configuration: galvo corners
volume__chN.u16holds the raw voxels as unsigned 16-bit little-endian integers, ordered[z][y][x]with X varying fastest:planes Γ ny Γ nxvalues.
MIT; see LICENSE.
Comments
No comments yet. Start the discussion.