Back to ObjectJ examples

Align Fluorescence Channels

Author: Norbert Vischer (vischer (at) uva . nl)
History: 2017-07-24: Version 17 (fixed 'out-of-range' bug after 'second run')
2015-10-26: Version 16 (works with ImageJ 1.50d)
2014-07-18: Version 15
2014-02-03: Version 14
2012-11-22: First version
Source: Align_Fluor_Channels_17.txt
A demo stack is available.

Older versions
Description: Repairs displacement of fluorescence channels in bacterial images.
Channel #1 (phase contrast) is used as reference.
Features
  • Manual operation: drag cell outlines to match fluorescence pattern
  • Automatic operation via FFT correlation
  • Supports multi-frame hyperstacks
  • Batch proceccing: process all hyperstacks in a folder
  • Displacements are recorded in a table

Fig 1: before alignment

Fig 2: after alignment

Macro Commands:
Show PhC Outlines [1]

Derives cell outlines from channel 1 (PhC) and shows them in the current channel. This selection can manually be dragged so it matches the fluorescence pattern, but alignment is not performed yet. Use Edit> Select None (shift-A) to remove selection.

Apply Manual Alignment [2]

Shifts (translates) content of current channel by the amount the user has dragged the cell outlines

Remove Outlines [3]

Removes current selection and overlay

Create Offsets Table... [5]

You are asked to choose a folder containing hyperstacks. Then the misalignment of all images in that folder is calculated and stored in the same folder as table "Offsets.txt". Any old offsets file will be overwritten.

Apply Offsets Table [6]

You are asked to choose a folder containing "Offsets.txt" with the corresponding stacks, which then will be aligned and saved. Note that the non-aligned images will be overwritten with the aligned ones, so make sure you have a back-up in case the result is not satisfactory. You can keep the Caps Lock down to observe or abort the alignment. For safety, "Offsets.txt" will be renamed to "AppliedOffset.txt" so it will not be used twice. In case of premature abortion, "Offsets.txt" may not be correct anymore.


Notes for hyperstacks:

Either multiple slices or multiple frames are allowed, not both (i.e. no 5D stack) If stack has multiple slices, they are converted to multiple frames. First channel must be used for phase contrast, followed by one or more fluorescent channels. If in doubt, choose: Image>Color>Arrange Channels... If required absolute shift is > 30 pixels, user is asked for confirmation.

Notes for automatic FFT alignment:

Phase contrast channel is converted to a mask, so objects have intensity = 1 and background has intensity 0. This mask is multiplied with the underlying fluorescence channel, and the total fluorescence of the product is measured. By shifting the mask in x and y direction, this value will change. Those offsets that yield the maximum result will be used for alignment. Using FFT correlation, this process can be done in a single step.

Alignment is performed via a 1024 * 1024 FFT image. This also defines precision of alignment, independent of the image size. Increasing fftSize=1024 by factors of 2 will improve resolution but process slower.

Limitations:

The automatic method works best if there is statistically enough material, i.e. if there are many cells, and if fluorescence is evenly distributed inside the cell (which is the case in the demo file). Conversely, it may fail in other cases.

Back to ObjectJ examples