ljcamp1624 / FlowClusterTracking

Optical-flow based algorithm for analysis and processing of dynamics in time-series of images.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OpticalFlowAnalysis

Introduction

This code is adapted from the manuscript "Quantifying topography-guided actin dynamics across scales using optical flow" by Lee*, Campanello*, Hourwitz, Alvarez, Omidvar, Fourkas and Losert. The original code used in the manuscript is posted by @LosertLab at https://github.com/losertlab/flowclustertracking.

The current version of the code is written in MATLAB and only applicable to 2-D data. A Python version is in the works.

Workflow

The workflow is managed by ControlScript.m (ControlScript_sample.m for the example data). Detailed explanations of all predefined parameters in the control script can be found in Parameters.txt.

"MainAnalysisScript.m"

"MainAnalysisScript.m" receives the parameters from ControlScript.m and performs all of the main functions of the analysis workflow.

Importing data

Data must be saved in a single-channel multistack .tif such that "imread('FILENAME.tif', n)" loads frame "n" of the time series.

Calculating optical flow

Optical flow is calculated using the Lucas-Kanade method. The Lucas-Kanade method assumes that local spatial and temporal image gradients can be modeled as a linear translation of intensity between two adjacent frames.

The optical-flow calculation here uses a derivative-of-Gaussian (DoG) kernel to calculate spatial and temporal image gradients, and solves for the best estimate of optical flow using least-squares criteria. The DoG kernel assures that pixel noise does not result in overly noise optical flow.

The Lucas-Kanade method prescribes that local spatial and temporal gradients be accumulated in the calculation step using a window of a predefined size. Here, we applied an additional gaussian weight matrix to ensure that optical-flow vectors indicated by pixels at the center of the window carried more information than those far away from the central pixel.

Optical-flow reliability is a measure of certaintly in the flow calculation. Low reliability indicates that the optical-flow calculation has encountered the aperture problem. Here, we define the reliability as the smaller eigenvalue of the Lucas-Kanade structure tensor. Alternatively, one may use optical-flow coherence as a measure of quality (defined as the absolute value of the difference of the eigenvalues divided by their sum), which is included as a currently unused output of LKxOpticalFlow_allFrames.m.

Clustering images

Optical-flow clusters were calculated by superimposing optical-flow alignment on regions of protruding dynamic behavior.

Optical-flow alignment was calculated by taking the weighted sum of the dot product between optical-flow vectors with neighboring vectors. The alignment metric uses a gaussian weight matrix so that alignment in a central pixel is largely comprised of information from nearby pixels.

Protruding regions were defined as areas where the difference image of overly smoothed images is positive. Thus, the workflow first calculates the "SmoothImages" and then the "DifferenceImages."

Tracking of clusters

Tracking was performed using the Crocker-Grier particle-tracking algorithm translated to MATLAB. Tracking is performed on peak optical-flow alignment within optical flow clusters, but can be alternatively performed on binary images by thresholding the '''clusterIm*''' variables before tracking.

About

Optical-flow based algorithm for analysis and processing of dynamics in time-series of images.


Languages

Language:MATLAB 100.0%