Advanced Imaging Tutorials

The Advanced Imaging Unit provides support in imaging acquisition and analysis to help mo. Several plugins, tools, equipments and softwares are used in image acquisition and analysis, which can have complex protocols and procedures. In this webpage we will cover some of the more important and used plugins and tools used by users of the Advanced Imaging Unit.


Stitching - Grid/Collection stitching using Fiji

This tutorial will show you how you can quickly use the plugin provided by FIJI to do stitching of several images automatically. This plugin is specially useful when you have a long list of images from the same sample.

There are 3 tools available to do stitching:

Note: don't use the deprecated plugins, these are out of date and may not work.


In this tool you will have to manually place the images in the position where they should be merged and then run. It will merge images according to the position where they are, it is prone to bad stitching if put in incorrect positions. If you have a big number of images to merge, using this method can take longer and is not the best due to the need to put images in the position where they will be merged. Can be useful when the number of images is not high and the image position is known or easilly accessed. It will only do 2D stitching, won't allow stitching with different Z positions.

  1. Open MosaicJ.


  2. Import/Open images.
  3. Click one of the images in the bottom bar to add it the canvas.
  4. Drag and Drop images where you see fit. Use "ctrl"+ Arrow key to move slowly (nudge).

    MosaicJ window

  5. When you are satisfied with the image positions go to File > Creat Mosaic.

Note:This plugin does not work in 3D, which means you cannot stitch together Z-stacks.

Pairwise Stiching

This tool is more advised when stitching or merging 2 images together. You will have to select 2 images and the software will ask for some parameters before doing the stitching.

  1. Open two images.

    Images to stitch together

  2. Chose which images to stitch together.

    Chose images to chose

  3. Chose the stitching parameters. All these options may need some adjusting depending on the images to stitch. It is possible to stitch using 1 channel chosen by you or all of them in the Registration channel option.

    Pairwise options

  4. The final image should be something similar to the following example:

    Result of

Grid/Collection stitching

This Tool is the more complex of all 3 and it needs some adjusting and optimization. It has several options that can be changed depending on the direction of the acquisition and the amount of informations saved in the metadata file or the image itself. This is fully automated and can save a lot of time when stitching images together, but, has mentioned above, needs some optimization.

There are 8 types of Grid/Collection stitching that can be divided in 3 sub-groups:

    Acquisition order

  1. When you know the stage movement direction:
    • Grid: row-by-row.
    • Grid: column-by-column.
    • Grid: snake by row.
    • Grid: snake by column.

    Note: these stitching types require a selection of both the Order and the Direction of the acquisition, which makes these types the fastest. By chosing the direction, the image scheme will change and will allow for a better understanding of the change. If you incorrectly select the direction or the order, the stitching will be incorrectly done.

  2. When you have position information but not direction:
    • Position from file.
    • Filename defined position.
  3. When you don't have information about position or direction:

    Note: These tend to take much longer due to no prior information, comparing each image with the others.

    • Sequential Images.
    • Unknow Position.

After selecting the type of Grid/Collection stitching you will need to choose parameters according to 1 of 2 different procedures, depending on the Parameter window you will be presented.

Choosing parameters

Procedure 1

Procedure 1

  1. Grid size: specify the number of rows in "X" and the number of columns "Y" of the total grid size.
  2. Tile overlap: specify the tile overlap. Depending on the software, the overlap may be adjusted differently. You can specify an overlap in Pixels (px), Percentage (%) or Distances (mm, µm, nm, etc.). Since the plugin only accepts %, one needs to convert to %.
  3. "First file index i": stands for the first number in your pictures that identifies them. There may be more than one index (i or X and Y) depending on the type of stitching being chosen.

    Example: your first image of a sequence is named MAX_image_1.ome.tif. The first file index is 1. It it was named MAX_image_0.ome.tif, the first index is 0.

    Example 2:Micro-Manager saves images with the position in the filename (MAX_image_pos-00_00.ome.tif). In this case you would need to specifie X index as 0 and Y index as 0 as well.

  4. Directory: choose the folder where the images are in.
  5. File names for tiles: input the file name but replace the position variable numbers for the index specified above (i, X or Y) inside curved brackets ({}). In case the image has more than one character, just add more variables to the file name.

    Example: if the filename is "MAX_image_0.ome.tif", the settings filename should be "MAX_image_{i}.ome.tif". If it is "MAX_image_002.ome.tif", the settings filename should be "MAX_image_{iii}.ome.tif".

    Example 2: if image name is "MAX_image_pos-08_03.ome.tif", in the settgins should be "MAX_image_pos-{xx}_{yy}.ome.tif".

  6. Output textfile name: Everytime a Stitching protocol is done, a txt file with the position configuration will be saved. This option is to select a name for that file. Default name is "TileConfiguration.txt".
  7. Regression Threshold: this value is the minimum R value the software should use while fitting the images together.
  8. The remaining options are additional parameters for more specific stitching protocols. Only change these in case anything else failed to stitch properly before AND you know what you are doing.

Procedure 2

Procedure 2

  1. Directory: Choose the folder where the images are saved.
  2. Confirm files: check this options if you want to check which files to stitch together before starting.
  3. Output textfile name: Everytime a Stitching protocol is done, a txt file with the position configuration will be saved. This option is to select a name for that file. Default name is "TileConfiguration.txt".
  4. Regression Threshold: same as in the above procedure.
  5. The remaining options are additional parameters for more specific stitching protocols. Only change these in case anything else failed to stitch properly before AND you know what you are doing.

Stitching Example

For a better understanding of the stitching process, an example will be provided bellow.

  1. Image sequence.
  2. In the following example, image acquisition started in the Upper right corner towards the Lower left corner. Click image to enlarge.

    Since the image sequence is from the top right corner to the lower left. We could use more than one stitching types, "Grid: Column-by-Column"+"Down & Left" or "Position from file name", "Unknow Positions", "Sequential Positions", etc. Chosing the more direct one, may save computation time and avoid stitching errors or incorrect placement of images.

    Stitching example parameters

  3. Since the images have the position information in their filename, the type chosen was "Filename defined position".
  4. Choosing parameters:
    • Grid size x:5
    • Grid size y:5
    • Tile overlap[%]:10 - the overlap was calculated and chosen before acquisition.
    • First file index x:0
    • First file index y:0
    • Directory: C:\Data\...\image folder
    • File names for tiles:MAX_image_2_MMStack_1-Pos_00{x}_00{y}.ome.tif

      Be careful where the curved brackets are placed. A misspelled name may lead to incorrect stitching.

    • Output textfile name: you may leave the default name
    • The remaining options were not changed.
  5. Press Ok
  6. The result image should be something like the following:

    Click to enlarge.

    Final fused image

    Note: The images shown are only Max Intensity Z-projections of the original. The whole process was done in 25 image stacks with 11 Z-planes and 4 channels, what consisted of 44 total images per image stack, giving a total of 1100 images. A process like this may take a lot of RAM and computational time, in this case, it took less than 5 minutes.

Hardware Autofocus systems

One of the big problems while acquiring live images over long periods of time is the loss of focus due to drift. The sample focus can change due to temperature drift, mechanical drift, vibrations etc. Specially when doing live imaging at 37°C, temperature drift becomes a big problem when not stable. Some of our microscopes are prepared with Autofocus mechanisms, be it software based or hardware based.

Nikon - Perfect Focus System (PFS)

For a better explanation and visualization of how the system works, visit Nikon's website through the following link.

Nikon microscopes has an autofocus tool called Perfect Focus System which can be activated to correct for Z drifts over time. This quick tutorial will show you how to activate the PFS functionality and possible problems/mistakes.

  1. Place your sample at the stage and focus.
  2. Put the PFS dichroic in the "In" position
    • In old PFS versions, the dichroic is put in using a knob between the filter wheel and the objective turret:

      Old PFS version

    • In newer PFS versions, the dichroic position is changed in the Offset controller:

      New PFS version

      A yellow light will turn on once the dichroic is set in position.

  3. Activate PFS though the On button on in the microscope front panel
  4. PFS On button

  5. When PFS is active and a Focus has been found, a flowcytometry/yellow LED should turn on:
  6. PFS focus LED

  7. Check the PFS status in the LCD monitor.

    PFS focus LED

    There are several status possible, we will quickly cover most of them here:

    • On: PFS is locked and actively correcting focus.
    • Off: PFS is deactivated.
    • DIS: PFS out of focus and not working. This could be due to sample out of focus, ilumination problem or impossibility to maintain PFS active. These will be looked upon further bellow.
    • ERR: An error occurred with the PFS, speak with the UIC personnel to help you.
  8. Once the PFS is active, adjust the focus using the PFS offset control.

    Use the wheel to control sample focus and the blue button to control the movement speed.

    PFS offset control

  9. Activate or enable PFS autofocus in the acquisition software. Different softwares activate PFS differently, some during acquisition and some between acquisitions.

    • Micromanager

    • Open the Multi-D Acq window, activate Autofocus and edit the Autofocus options.

      Autofocus option in Micromanager

    • In the Autofocus properties window, select the microscope PFS with the name "TIPFSStatus" and set its status to "ON".

      Note: when using MicroManager, the PFS will activate between acquisitions and deactivate when the acquisition starts. Be careful when having more than one channel active, the PFS autofocus may present some problems.

      Andor iQ2.6

      When using this software for image acquisition, the autofocus options needs to be inserted into the protocol itself because we can change it's activation timings and periods.

    • Insert a "Autofocus" option inside a "Repeat T" sequence. And choose "Z Motor" option.

      Place holder for autofocus 1.

    • Insert a "Autofocus activate" option bellow the previous. Choose when to activate the autofocus through the number/repeats of cycles.

      Place holder for autofocus 2.

  10. Start acquisition.

Leica - Adaptive Focus Control (AFC)

For a better and easier compreension of how the system works, visit Leica's website through the following link.

Zeiss - Definite Focus

For a more thourough explanation of the system and the way it works, visit Zeiss' website through the following link.

Common autofocus/PFS/AFC/Definite Focus problems.

There are several reasons why the autofocus may not activate or function properly. One very important aspect of it is that it relies in the reflection of an Infra-red LED in the interface between the sample media and the sample holder (coverslip, petri-dish, well-plate, etc).

  • PFS focus LED constantly blinking, focus was not found and is trying to lock. Find focus of the sample and PFS should lock.
  • PFS activated all the time, Infrared Transmitted light filter not properly placed after the Transmitted light lamp house/LED.
  • PFS status ERR, the objective selected does not support autofocus or is not corrected for the infrared wavelength.
  • PFS status DIS, reflection is not beeing found, move the objective up and down until it finds a reflection focus to activate PFS.
  • Autofocus does not lock when using an Oil immersion objective. This may happens when the LED does not reflect properly in the interface of the sample and the holder. The Refractive Index (RI) is unchanged through the optical path. Ex.: Objective RI=1.515; Immersion Oil RI=1.515; glass bottom dishes, coverslips, etc RI=1.515; and sample media RI ~ 1.5.
  • Sample is focused but during the acquisition it got out of focus. If using XY positions, the PFS Offset needs to be saved as well, otherwise the focus will be changed when the PFS is activated. Whenever saving XY positions, be sure that the offset is changed and saved as well. Save position and activate PFS to check its positions.

Illumination correction

In microscope image acquisition, it is often common to have field illumination heterogeneity which may result in incorrect or wrong calibrations and it will greatly affect acquired images. There are several procedures that should be done prior to image acquisition to ensure proper field of view illumination, as well as some possible procedures to correct errors in lighting.

Regarding fluorescence imaging, most microscopes have a not homogeneous field fo view due to optics and the way light is focused into the objective back focal plane. For this reason, these images may need to be corrected to avoid fluorescence decay along the image borders. This problem is mostly seen in stitched images or images acquired in a Tile. Bellow are some tricks to correct this problem.


Phase Contrast


Flat Field Correction

  • As mentioned above, one of the most frequent and common problems with Tile/Grid/Mosaic images acquired at a microscope is the heterogeneity of the illumination, which tends to create a grid of "shadows" in the final image as the example shown in the right.

    Click on the image to zoom.

  • Stitched image with artifacts

  • There is a simple trick to correct for field homogeneity with simple operations and a reference image. This procedure is usualy referred as Flat Field Correction and a result image can be seen to the right side.

    We did a macro some time ago with a similar function in this link for a quick reference.

  • Corrected Stitched image

Some additional notes

To do a flat field correction you need a reference image to use as a template to correct the illumination. The best references are always prepared with special colored slides that are fluorescent throughout the whole sample and you should use these slides (ask the UIC personnel for the Chroma slides) when you need to do a correction. For transmitted light no special slide is needed, you only need to take an image in focus with no sample there. Avoid having any dust specs or any structure visible that is not from the light path!!

Note: reference images should always be acquired at the same day as the images themselves as the illumination can always vary and change slightly.

If you did not acquire a reference image for the correction, you could always use your sample for this correction.

  • A typical microscope has this tipe of field illumination with the corners darker.

    The drop in intensity may very from microscope to microscope and can vary over time.

  • Field Illumination with profile


  1. Open raw data and reference image. If you do no have a reference image, bellow these step are instructions to create an aproximated reference image based on your data.
  2. Open ImageJ/Fiji Image Calculator (Process > Image Calculator...)

  3. Image1: choose raw data image.
  4. Operation: Divide

    • Another operation besides this one will not correct the field properly because reference images tend to have much higher values per pixel and simply subtracting or adding the images will not work. This will simply increase or decrease intensity values without correcting images.

  5. Image2: chose ref image (flat field image)

  6. Tick Create new window

  7. Tick 32-bit (float) result

    • 8, 12 or 16 bit images work with integer numbers and dividing an image by another will create decimal values, therefore, this step is very important to avoid clipping of values and creating an erroneous correction and artifacts.

  8. You should have a corrected illumination in the resulting image. If this is not the case, please speak with the UIC personnel.

  9. Optional: converting a 32bit image to 16bit after the division operation.

    Because of the division operation, images will not have the same intensity values and they should not be used for quantification purposes! In addition to that, 32-bit images have 2x the size of 16-bit images which will occupy more disk space and directly converting 32-bit to 16-bit images will clip intensity/grayscale values and cannot be restored afterwards, first it is necessary to adjust the Minimum and Maximum gray values.

    • Select 32-bit image to be converted.
    • Do a Histogram of the image and check Min and Max values: Analyze > Histogram (H or ctrl+H)
    • Open Brightness & Contrast (Ctrl+Shift+C)
    • Press Set
    • Change Minimum displayed value and Maximum displayed value to the values checked earlier and press Ok.
    • Convert image to 16-bit: Image > Type > 16-bit

Generating Reference image

It is possible to generate a reference image by applying big filters to it and eleminating all the fine detail from the image while keeping the background mostly "unchanged".

  1. Duplicate image to be corrected. Image > Duplicate... (Ctrl+Shift+D)
  2. On the duplicated image, apply a Median filter with a big radius, > 40 px - Process > Filters > Median...
  3. Note: this filter can be very slow and the larger the radius the longer it takes, specially above 40px

  4. Apply a Gaussian filter bigger than 20px to remove "ladder like" intensity changes. Process > Filters > Gaussian Blur...
  5. Done