Fine Tuning Optical Flow calculation

*Parameters of the Optical
Flow algorithm*

The parametering of the Optical Flow function strictly follows
the equations and algorithms published by Gerencser & Nicholls^{1}.
The table below refers to the
paper.

Name |
Default |
Description |

Select dx kernel: | [Savitzky-Golay first derivative] | Row kernel for differentiation in x. Kernel defined in Preferences or set parameters of the Savitzky-Golay kernel below. To be used in Eq.2. |

Select dy kernel: | [Savitzky-Golay first derivative] | Column kernel for differentiation in y. Kernel defined in Preferences or set parameters of the Savitzky-Golay kernel below. To be used in Eq.2. |

Select dt kernel: | [1,-1] | Column kernel for differentiation in t. Kernel defined in Preferences. Use the [1,-1] preset or set parameters of the Savitzky-Golay kernel below. To be used in Eq.2. |

Average OF for dt width | Yes | Calculate OF using spatial derivatives of each frame, and then the average, to prevent biasing by leading and trailing edges. This is demonstrated by Fig.4. |

Block mode | No | See block mode here. |

SG kernel for dx,dy width | 3 | Width of spatial Savitzky-Golay 1st derivative kernel. Applied only if [Savitzky-Golay first derivative] is selected above. This was optimized in the paper (Fig.3). |

SG kernel for dx,dy order | 2 | Order of spatial Savitzky-Golay 1st derivative kernel |

SG kernel for smooth width | 7 | Width of smooth Savitzky-Golay 0th derivative kernel. Applied only if [Savitzky-Golay first derivative] is selected above. This was optimized in the paper (Fig.3). |

SG kernel for smooth order | 2 | Order of smooth Savitzky-Golay 0th derivative kernel |

SG kernel for dt width | 3 | Width of temporal Savitzky-Golay 1st derivative kernel. Applied only if [Savitzky-Golay first derivative] is selected above. The [1,-1] kernel was found to be ideal, so this parameter is not applied normally. |

SG kernel for dt order | 2 | Order of temporal Savitzky-Golay 1st derivative kernel |

Aperture kernel size | 5 | Aperture kernel is a matrix of ones. See Eq.3. |

Aperture kernel shape | Box | Box or Disc. The paper used Box kernel. |

Correct for bias by noise | Yes | Performs masking with Eq.6. |

Correct low noisy gradients in time | Yes | Performs masking with Eq.5. |

Enforce constraints on gradients in space | Yes | Performs masking with Eq.7 & 8. |

Variance factor for time constraint | 1.5 | k-value defied in Eq.9. to be used in Eq.5. |

Variance factor for bias | 1.5 | k-value defied in Eq.9. to be used in Eq.6. |

Variance factor for constraint 1 | 4 | k-value defied in Eq.9. to be used in Eq.7. |

Variance factor for constraint 2 | 0.45 | k-value defied in Eq.9. to be used in Eq.8. |

Detector offset | equipment specific | Intensity measured in darkness, see "Sensor Noise Characteristics" |

Detector variance vs. intensity Slope | equipment specific | Slope of noise diagram, see "Sensor Noise Characteristics" |

Detector Read out Variance | equipment specific | Variance measured in darkness, see "Sensor Noise Characteristics" |

Pixel size | 1 | Results are multiplied with this value (typically mm/pixel) . |

Output as Absolute value of vectors | Yes | Pixel intensities in the output image mean absolute mm/s (or pixel/s if the above value is 1) |

Output as X and Y components of vectors | No | Pixel intensities in the output image mean ±mm/s (or pixel/s if the above value is 1) |

Output as Absolute value of Projected Vectors | No | Results Radial - anterograde/retrograde velocity image. Needs a projection point ROI below.' |

Projection ROI | 1 | Center point ROI for radial projection. |

*Changing/optimizing
parameters of the Optical
Flow algorithm*

The above default parameters have been optimized for detection of
motion of small (couple of pixels wide) objects/edges, the size that
mitochondria typically show up in ~0.2-0.3
mm/pixel images. Parameters other than the equipment
specific * noise parameters*,

**Setting up Optical Flow calculation for a given
microscope / detector setting**

The parameters below are calculated from the intensity-variance
diagram calculated from evenly illuminated fields. Calculation and
image acquisition with different image acquisition softwares are
given in the following protocol pages:
Elements,
Metamorph,
Zeiss LSM.

Noise
parameters:

**Detector offset****Detector variance vs. intensity****Slope Detector Read out Variance**

The * Pixel size* is typically stored by
the image acquisition software in the image file, and can be viewed
by Image Analyst MKII by using the
context menu

The ** Block mode **is always set to

**Using more than 2 frames for Optical Flow calculation**

Recording of two frames is sufficient to determine velocity vectors. If Optical Flow is calculated more than 3, e.g 5 or 7 (considering only odd numbers) of images, the temporal derivatives can be more accurately determined. However due to increased phototoxicity this is not advised. The dynamic range of the Optical Flow is calculated for the time span of the acquisition of all frames. Thus to keep the same dynamic range, when the number of frames is increased the acquisition interval has to be reciprocally decreased.

To calculate Optical Flow from larger number of frames set:

*Select dt kernel:*[Savitzky-Golay first derivative]*SG kernel for dt width:*the number of framesif the number of frames is odd (should be odd)**Average OF for dt width: No**

During continuous acquisition of Optical Flow this is a viable option to set the dynamic range of the Optical Flow calculation to lower velocities. In block mode or Multi-Dimensionalacquisition increasing number of frames leads to unecessarily phototoxicity. However recording more frames enables to adjust the dynamic range during data analysis.

The number of frames recorded in each short time lapse has to
match the value of * Select dt kernel *(when
using [1,-1] kernel, it is automatically 2). If more frames were
recorded, the frames to be passed for Optical Flow can be selected
in the

- Specifying frames separated by commas in Settings
*/Load Specified frames only of each stack*(for short time lapses recorded as zero-step z-stacks, see Metamorph) - Splitting blocks in block mode (see Zeiss LSM)
- Selecting only the proper channels (see Elements ND2)

**Working with different resolution or gradient/object size**

Using larger spatial differentiation and smooth kernels when
working in large, dull objects or less sharp edges increases the
dynamic range. However it will lead to inaccurate velocity
determination over sharp edges. See Fig.3. of the paper^{1}.

**Tuning masking**

The default variance factors were determined on modeled data, not on a specific microscopy system, therefore are assumed to be universal. Larger variance factors provide stronger masking (the Optical Flow algorithm is more conservative, and only edges most distinguishable from noise are passed)

**Variance factor for time constraint**(k-value defied in Eq.9. to be used in Eq.5; to enable set): Increase this value if measuring velocity over stationary objects e.g. fixed cells or beads (that do not perform Brownian motion). Decrease this value is the algorithm clips low velocities to zero*Correct low noisy gradients in time:*Yes-
**Variance factor for bias**(k-value defied in Eq.9. to be used in Eq.6; to enable set): This value shouldn't be changed. Tuning this value requires a calibration image sequence showing moving objects with a range known velocities.*Correct for bias by noise:*Yes -
**Variance factor for constraint**(k-value defied in Eq.9. to be used in Eq.7; to enable set): Set this value larger to suppress background, or smaller to allow processing of dimmer details.*Enforce constraints on gradients in space:*Yes **Variance factor for constraint 2**(k-value defied in Eq.9. to be used in Eq.8; to enable set): Increase this value if objects like rods or spheres show smaller Optical Flow in their middle than at their edges. Decrease this value if middle of spheres or rods are overly masked.*Enforce constraints on gradients in space:*Yes

* *

**References**

1. Gerencser A. A. and Nicholls D. G. (2008) Measurement of Instantaneous Velocity Vectors of Organelle Transport: Mitochondrial Transport and Bioenergetics in Hippocampal Neurons. Biophys J. 2008 Sep 15;95(6):3079-99.