> For the complete documentation index, see [llms.txt](https://mpqc.swcmicroscopy.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mpqc.swcmicroscopy.com/analysis-and-summaries/point-spread-function.md). Agents can also search and read this documentation through its [MCP server](https://mpqc.swcmicroscopy.com/~gitbook/mcp).

# Point Spread Function

Recording and Measuring PSFs

### Obtaining a PSF in ScanImage with averaging and fastZ

To get a good image of a sub-micron bead:

* Use image sizes of about 256x256 to 512x512 pixels.
* Once a bead is found, zoom to about 20x or 25x.
* Take a z-plane every 0.25 microns and average about 25 to 40 images per per plane. It's not worth doing more because we'll be fitting a curve to z-intensity profile.

To measure the PSF you can either use the included `mpqc.record.PSF` function or manually set up ScanImage (see `documentation` folder if you need to do that).

### Using `mpqc.record.PSF` to obtain a PSF

* Find a bead, zoom in.
* Select only one channel to save in the [CHANNELS window](https://docs.scanimage.org/Windows%2BReference%2BGuide/Channels.html).
* Set the averaging to the quantity you wish to use in the [Image Controls](https://docs.scanimage.org/Windows%2BReference%2BGuide/Image%2BControls.html) window.
* Move the focus *down* to the lowest point you wish to image and press press "Zero Z" in MOTOR CONTROLS
* Now focus back up to where you want to start the stack and press "Read Pos" in MOTOR CONTROLS. This is the number of microns you will acquire (ignore the negative sign if present).
* Run `mpqc.record.PSF` with number of microns obtained above as the first input argument. This will obtain the stack with a 0.25 micron resolution using the averaging you have set. e.g. `record.PSF('depthMicrons',12)` for a 12 micron stack. The save location is reported to screen. You can define a different z resolution using the second input argument.
* Optional inputs  &#x20;\- All inputs are optional parameter/value pairs.&#x20;  \
  &#x20;'depthMicrons' - Total depth to image in microns  \
  &#x20;'stepSizeInMicrons' - Number of microns between each z step  \
  &#x20;'wavelength' - Excitation wavelength in nm  \
  &#x20;'power' - Excitation power at the sample in mW

### Manual PSF measurements

These instructions explain how to set up ScanImage to obtain an averaged fast z stack. These instructions are pretty much what `record.PSF` does, so if that's not working for you just follow the steps below.

* Using the slow-z device and reading its position, determine the depth at which you wish to start imaging and note how far below it you wish to go.
* Place objective at the top of the stack you wish to acquire with the slow-z motor.
* Un-check the `Enable` box for the fast-z under `FAST Z CONTROLS`.
* In the same window set `# Slices` and `Step/Slice` (microns per step) to cover the range of depths you need. Sampling every 0.25 microns is nice for a 2-photon z-stack.
* In the same window set the `Scan Type` to `Step`.
* Check `Sec Z` in `MOTOR CONTROLS`.
* Set the `Frame Rolling Average Factor` in `IMAGE CONTROLS` to the number of frames you wish to average. 40 frames is probably good enough.
* Check `Save` in `MAIN CONTROLS` and set `# Avg` to the same number of frames (e.g. 40).
* Set the right-hand box in the `Frames Done` line in `MAIN CONTROLS` to the number of images you are averaging.
* Press `GRAB` in `MAIN CONTROLS` to acquire a stack
* If the shutter opening and closing is annoying then set `hSI.hStackManager.shutterCloseMinZStepSize` to a value larger than you step size.

### Measuring the PSF

To view the PSF run `measurePSF` and load the saved stack using the GUI. For more info type `help measurePSF`. If loading ScanImage TIFFs the voxel size is extracted automatically from the header information in the file. Otherwise, this information can be provided using the second and third input arguments (see `help measurePSF`).

<figure><img src="https://1521207187-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3zmCqXEmICTAPZjyGAIY%2Fuploads%2F2Lvy1gSNxQOKFhugjFWX%2FrealBead.png?alt=media&amp;token=d00976ca-96e9-45ca-8a83-fcf86035dde0" alt=""><figcaption></figcaption></figure>

### Tips for finding beads

* Place slide under objective with no water. Look from the front and side to ensure bead well is under objective. Then add water.
* Set power to 30 mW, zoom 2 or 3, average 2 to 4 frames.
* If it's helpful to have higher FPS, use 256 by 256 for searching.
* Look both red and green channels.
* Usually there is a global increase in background when you are in the bead plane.
* Zero the z motor when you find the beads or think you are getting there. This stop you from getting lost.
* Set power to 10 mW before zooming in or you will melt the larger beads. Molten beads will start to slowly expand, which will mean you can no longer image them. Often they will develop strange shapes.
