> For the complete documentation index, see [llms.txt](https://bakingtray.mouse.vision/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bakingtray.mouse.vision/getting-started/finishing-the-install/calibration/basic-calibrating-procedures.md).

# Basic calibrating procedures

### Theory

BakingTray performs a tile scan over the sample. The individual tiles are later assembled into a single image by [StitchIt](https://github.com/SWC-Advanced-Microscopy/StitchIt). In order to place the tiles accurately and produce a good quality stitched image you will need to ensure that the following are true.

* The X and Y scanners must displace the beam along orthogonal directions.
* The X and Y stages must displace the sample along orthogonal axes.
* The X scanner should move the beam along the direction of motion of the X stage and the Y scanner along the direction of motion of the Y stage.
* The scanning plane (imaging plane) should be parallel with the plane of motion of the X and Y stages.
* The blade must be parallel to the Y stage such that the cuts it produces cause the surface of the sample to remain the same distance from the objective as it is translated in Y.

### Practice

This is what you must do to achieve the above. Read through the whole document before starting.

#### Before starting

You should set the X and Y stages to middle of their travel ranges, mount the water bath, raise it a bit, and manually translate the whole stage assembly until the objective is roughly in the middle of the imagable area. This is just to ensure that you will not run out of travel range on any of the axes.

#### Ensuring the X and Y scanners are orthogonal

Recall that *the X and Y scanners must displace the beam along orthogonal directions and the beam must leave the scanhead at 90 degrees to the angle with which it entered.* The alignment needs to be done once when the microscope is built.

If you have a close-coupled scanner pair you can place it on the table, feed the beam going into it parallel with the table and orthogonal to the scan head box. The scan head should be clamped to the table. Rotate the scanners in their mounts such that the beam exits the scan head parallel with the table and at right angles to the angle at which it came in. You can use the table hole pattern to guide you. Remember to set galvos to their mid-point by feeding in a zero command voltage. Now apply a sinusoidal command voltage to each axis in turn, project the beam onto the wall and ensure the two motion directions are orthogonal.

If the above alignment isn't possible (e.g. you don't want to dismantle your microscope) then you could opt to image [an EM grid](https://github.com/SWC-Advanced-Microscopy/multiphoton-qc) and check whether the grid lines are orthogonal.

If you find the scanners aren't orthogonal to each other then this can only be corrected by altering relative angle of the shafts. Depending on how the scanners are mounted this may or may not be possible. If you can't correct this, it can be done [in software, later](/getting-started/finishing-the-install/calibration/achieving-high-stitching-accuracy.md).

#### Ensuring the X and Y axes displace the sample along orthogonal directions

The X and Y stages should displace the sample along orthogonal axes. This can be quite hard to measure. It might be best done by imaging with a camera, where you know you are dealing with a square pixel grid. If this step is hard to measure, then skip it for now and only come back to it if you have problems with stitching images that you can't correct.

#### Calibrating the number of microns per pixel

At this point it is helpful to [calibrate the number of microns per pixel](/getting-started/finishing-the-install/calibration/calibrating-the-number-of-microns-per-pixel-with-scanimage.md) in ScanImage and to ensure that the pixels are square.

#### Ensuring the scan axes are aligned with the stage axes

Recall that *the X scanner should move the beam along the direction of motion of the X stage and the Y scanner along the direction of motion of the Y stage*.

To achieve this, image pollen grains in ScanImage. Right-click on the image window and enable the cross-hairs. Translate a pollen grain along the cross hair of one axis. It should follow it perfectly. If not, rotate the stage assembly about its centre to achieve perfect tracking. You want to get this as accurately as possible. Within a micron if you can.

Then check the other axis. If the scanners and stages are both orthogonal, then you should also get perfect tracking along this axis. If not, as mentioned above, small differences can be corrected at stitching time by introducing a shear to the images.

#### Ensuring the imaging plane is parallel with the motion plane

The scanning plane (imaging plane) should be parallel with the plane of motion of the X and Y stages. You will need to mount the stages on three points of contact with at least two being height adjustable. Image a thin fluorescein layer (we are hoping for something under about 5 microns thick) under a coverslip. Assuming the image plane is not curved, the whole FOV should snap into view at once as you focus through it. However, the objectives we typically use have field curvature and so in perfectly aligned system you will see the centre appear first and as you move the objective further down you will see a donut. If the stages are aligned with the image plane, the donut should be symmetric and touch the four edges of the image at the same time.

![Stage tilt visualised with a fluorescent slide before and after correction](/files/GusxGfkUVAbQoRGIPTsG)

First you will check in the slide is parallel to the stage motion axes. Set ScanImage to Zoom 1 and find the sample. Once you have an image, translate the stages two or three mm: the image should not obviously change or indicate that the sample moved away from focus. If it does, the slide is tilted with respect to the stage motion axes and you should re-mount the slide. **Note**: the image remaining in focus when the slide is translated does not tell you that the image plane is parallel to the stage.

Now you should focus up and down. If you see the fluorescent layer sweeping into focus left/right then that means there is a tilt in the stage along that axis. Apply opposite tilt by adjusting the stage feet. Re-measure. Keep going until you have a centralised donut or uniform plane (in the unlikely even your objective is corrected for field curvature).

Tighten down the feet uniformly. It is a good idea at this point to check that the stage is roughly level with the air table with a spirit level. It might not be perfect, but if it's very far off then you should look into whether the objective itself is tilted.

#### Ensuring the blade is parallel with the Y axis

The blade must be parallel to the Y stage such that the surface of the sample remains the same distance from the objective as it is translated in Y. Adjust the blade angle to achieve this. The blade angle is adjusted by rotating the vibratome about its central mounting screw on the 90 degree bracket. Precision is obtained via an ThorLabs positioner: a 1/4 turn will produce a roughly 25 micron change in height across the width of the slide. The easiest way to do this is to make a block of fluorescent agar and cut it and image:

![Vibratome mount showing fine positioner (arrowed). In this image the 90 degree mount has been modified to allow for easier adjustment, as only the one screw at the brass bushing needs to be loosened. Unmodified brackets also work, but two screws need to be loosened.](/files/lCYEPYQpcJ2KGjCxV0xO)

* Cut open a fluorescent marker pen and pour the fluid into a Falcon tube.
* Make up some 5% agar and add a small quantity if your fluorescent dye into it. It will not diffuse out as the dye is composed of small plastic fluorescent particles.
* Cut the agar into a block that is about 10 mm wide by 25 mm long. Glue it to a slide such that you are cutting through the 10 mm width.
* Slice it under the microscope using roughly the thickness and speed you do in practice.
* Find the surface of the agar on the near side to you. Zero the Z drive in ScanImage. Then navigate to the far side (i.e. move the Y stage toward you) and see how far off it is.
* You might find it helpful to take a preview scan of the agar, in which case the near side will be on the left and far side will be on the right.
* Alter blade angle to compensate for a tilt. Cut again. Measure. Repeat.
* If the agar is not well glued down then it will move and the surface will not be very flat. A loose agar block is very hard to work with.

### Safety first!

The above alignments should be made in the order listed above. Once done, **ensure that no out of bounds motions are possible** by setting the min/max position values for each axis in the `componentSettings.m` file. To do this you should move the axes and manually find how far they can be moved along each axis. Take care with the X direction that move the edge of the bath near to the blade holder: the maximum safe position might vary with Z. This is important to check these limits so the hardware can't be damaged.

#### See also

* [Fine tuning positioning accuracy](/getting-started/finishing-the-install/calibration/fine-tuning-positioning-accuracy.md)
