### Gaussian beams and paraxial approximation

Gaussian beams
is a beautiful phenomenon in optics. As they propagate through space they retain their Gaussian shape, and only get broader or narrower. They are symmetric along the optical axis. No matter how many lenses you use to focus and defocus your laser beam, it will remain Gaussian. And it's shape is described by a few simple formulas, which define their thinnest section (w0, 'waist'), radius of wavefront (R), and divergence angle (Theta). Some immediate applications include fiber coupling, confocal microscopy, and light-sheet microscopy.

The formulas describing Gaussian beams were derived in the 1960-s, soon after the invention of lasers, by solving the wave equation for electromagnetic waves, and were analysed exhaustively in paraxial approximation (Kogelnik and Li, 1966).

Paraxial approximation means that angle of beam divergence angle is small (theta ~ tan(theta)). However, modern microscopy pushes limits to high-NA objectives and laser beams for higher resolution.

How good is the paraxial approximation? What if you focus a Gaussian beam to a really small spot of an order of a wavelength? Do these formulas still apply?
The short answer is yes, they apply quite well. As shown in (Agrawal and Pattanayak, 1979), non-paraxial description adds a lot of math, but not so much difference in the beam shape:
The beam profiles shown in (a) are cross-sections simulated about 1 wavelength from the waist (really close), with effective NA(air) about 1.0. The difference between paraxial and exact formulas is mostly over-estimation of peak intensity in paraxial case. The side lobes, and hence the width of beams, look remarkably similar. As you go farther from the waist, the paraxial approximation gets more accurate, too.

So if you are doing microscopy with high-NA Gaussian beams, stay cool - the old formulas from textbooks are good.

Here is an excellent review on Gaussian beams in light-sheet microscopy (Power & Huisken, Nature Methods, 2017)

References

### Programming NI DAQmx board in Python: easier than you think!

For my DIY microscope I had a task - generate a train of digital pulses which simulate camera trigger, so that other devices (galvo and laser) are synched. I wanted to do it in Python, so that it seamlessly integrates in my data acquisition and analysis Jupyter notebook.

After some quick search I found a PyDAQmx library which seemed mature and had good examples to begin with.

python setup.py install

After only 30 min fiddling, I was able to solve my problem in just a few lines of code:

Holy crap, it just works, out of the box. Oscilloscope shows nice digital pulses every 100 ms, each 1 ms long. The code is much shorter and cleaner than would be in C, C#, or LabView.

PyDAQmx appears to be a full-power wrapper around native NI DAQmx drivers (yes, they need to be installed), so presumably it can do all that can be done in C or even LabView (this statement needs to be tested).

One can use PyDAQmx to control galvos with fast ana…

### Programming of DIY microscopes: MicroManager vs LabVIEW

In the flourishing field of DIY light microscopy, a decision of choosing the programming language to control the microscope is critically important. Modern microscopes are becoming increasingly intelligent. They orchestrate multiple devices (lasers, cameras, shutters, pockel cells) with ever increasing temporal precision, collect data semi-automatically following user-defined scenarios, adjust focus and illumination to follow the motion (or development) of a living organism.
So, the programming language must seamlessly communicate with hardware, allow devices be easily added or removed, have rich libraries for device drivers and image processing, and allow coding of good-looking and smooth GUIs for end users. This is a long list of requirements! So, what are the  options for DIY microscope programming?

There are currently two large schools of microscope programming - Labviewers and Micromanagers. (update: Matlab for microscope control also has a strong community, comparable to labview…

### Shack-Hartmann sensor resolution - how much is good?

If you are new to adaptive optics (AO) like me, the selection of right hardware can be daunting. Starting with a wavefront sensor - they range in price, resolution, and many options which are not obvious. By practical trial and error I learned something about resolution, which wasn't obvious to me a year ago.

The Shack-Hartmann wavefront sensor (WFS) is essentially a camera with a lenslet array instead of an objective.
There are sensors with 15x15 lenses, 30x30 and higher. Naively, you might think "the more the better" - we are digital age kids used to get high-res for cheap.

However, there is a catch. High-res sensor, say, 30x30 lenslets, divides your photon count by 900 per spot. Roughly speaking, when you image a fluorescent bead (or another point source) by a camera with "normal lens" (not a lenslet array), and your peak intensity is 2000, this makes a very nice, high SNR bead image. However, is you switch to Fourier (pupil) plane and image the wavefront u…