Textarea Decoration

Matlab-Script for DualView beadscans

Note: There is now also a plugin implementing this PSF determination method inside QuickFit 3.0

This script allows to evalue a beadscan, as typically done in a SPIM microscope to characterize the PSF (and possibly the alignment of a DualView optics).


Pepare a gel containing a low concentration of sub-diffractive beads. We use:

  1. Prepare a few 1ml syringes by cutting off the top, where the syringe gets thinner (see image (A) below).
  2. 0.5% PhytaGel (P8169, Sigma-Aldrich) mixed with deionized water (shake thoroughly). Then heat in the microwave until the gellant dissolves completely.
    We use 40ml water and 200g PhytaGel.
  3. Add MgSO4 to an end concentration of 0.1%
    We use 400l of a 10% MgSO4 stock solution.
  4. While still >40C, fill 1 ml of the solution into an Epi and add 5-10l of 100nm TetraSpec beads (T-7279 from Invitrogen) directly from stock. Vortex shortly. You can also use any other type of bead, as long as the concentration is so low, that the beads are well separated in the gel!
  5. pull up ~300-400l from one Epi into a syringe (see image (C-D)) and refrigerate for 5min. at 4C until the gel solidifies
  6. Measure a beadscan with 1000-2000 frames, displaced by ~200nm. Take care to measure in the front part of the gel, so it does not alter the optical properties of the microscope too much!

preparation of gel for beadscan
preparation of gel for beadscan


The matlab script that can be downloaded below, will do the following (all Gaussian widths are measured as 1/e half width, i.e. exp(-2*x/w), a new subdirectory is created that stores all the results!):

  1. it runs through the stack and finds separated beads (in the left color channel on a DualView).
  2. around each bead it cuts a certain Rregion of interest (ROI)
  3. to 1D-cuts along the x-, y- and z-axis through the brightest pixel in the ROI, it fits 1D-Gaussian functions.
  4. along the z-axis it fits to several x- and y-cuts a separate 1D-Gaussian, to see how they extend away from the focal point
  5. a 3D-Gaussian fit is performed
  6. An image of the fits of every showeveryNthSinglebeadPlot-th bead is saved as .fig and .pdf file
  7. Histograms of all fit results (histogrammed over all fitted beads) are saved as .fig and .pdf files:
    • *_sub1_.psfhistogram.pdf/fig for 1D-fit histograms
    • (*_sub2_.psfhistogram.pdf/fig for 1D-fit histograms from DualView rhs)
    • *_sub1_.psfhistogram3D.pdf/fig for 3D-fit histograms
    • (*_sub2_.psfhistogram3D.pdf/fig for 3D-fit histograms from DualView rhs)
    • *_sub1_.psfhistogram_xzcol.pdf/fig for 1D-fits along z-axis histograms
    • (*_sub2_.psfhistogram_xzcol.pdf/fig for 1D-fit along z-axis histograms from DualView rhs)
  8. Histograms, comparing the two color channels are created, if the DualView mode was selected:
    • *_dualcolor_comparewidpos.pdf/fig compares the 1D fit results
    • (*_ldualcolor_pos.pdf/fig shows correlations on the 1D-fit data
In order to run the data evaluation, follow these steps:
  1. Download the script package and unzip it somewhere on your harddisk, e.g. D:\Matlab\spim.
  2. copy the DualView template or single template to the directory of the image stack and open it in the MatLab editor.
  3. at the top, set in addpath('D:\Matlab\spim'); the path (here D:\Matlab\spim) to the path where you saved the scripts (see step 1)
  4. set the variable datafile to the filesname of your stack, e.g. datafile = 'stack.tif';
  5. set the variable deltaz to the step-size of your beadscan in nanometers, e.g. deltaz=200; for 200nm steps.
  6. set the variable deltaxy to the pixel-size of your beadscan in nanometers, e.g. deltaxy=400; for 400nm pixelsize (=24m camera pixels @ 60x magnification).
  7. set the variable datarange=[] to evaluate all z-setps or e.g. datarange=1:500 to evaluate only the first 500 frames.
  8. set the variable datarangeX=[] and datarangeY=[] to evaluate all pixels, or e.g. datarangeX=32:96; datarangeY=32:96; to evaluate only the central 64x64 pixels of a 128x128 camera.
  9. set any of the other variables, if you want to.
  10. run the script
You can also download an example bead stack farther down, which comes with example output data!

Download & License

See also




Textarea Decoration
last updated: 06/28/16 12:27:23 - Imprint