nclack / whisk

Fully automated tracking of single rows of whiskers in high-speed video.
https://openwiki.janelia.org/wiki/display/MyersLab/Whisker+Tracking
Other
9 stars 13 forks source link

Parameterized line detector #50

Closed arashfassihi closed 4 years ago

arashfassihi commented 4 years ago

Dear Nathan,

I am working in David Kleinfeld's lab and collaborating with Karel Svoboda's group. I am trying to implement a part of your algorithm on my dataset. From your paper, I could implement the whisker detection part up to the point of using the line detector to achieve the subpixel resolution of the whiskers. I am copying the line detector part of the paper here:

"The line detector is designed based on modeling the intensity profile of a whisker as a rectangular valley in the image with variable position, width and angle. The center of the whisker is estimated with sub-pixel precision by finding a position that minimizes the Laplacian of the correlation between the model and the image ."

basically you have sets of templates ( I would like to know how do you create them) and perform template matching between the whisker image (with zeros and ones that are produced by the first step of the detection?) and the templates? do you perform template matching on each pixel of the whisker? would you please guide me to the part of the python code that performs this operation? I am trying to implement this in Matlab.

Best, Arash

nclack commented 4 years ago

The code you're looking for is in trace.c. It starts in trace_whisker and the main subroutines to look at are eval_line and adjust_line_start.

eval_line serves as the objective function. If I recall correctly, adjust_line_start does a greedy optimization to find the best angle, subpixel offset and width (in that order).

These parameters (angle, offset, and width) are searched over a discrete space. At each discrete setting of the parameters a "line detector" is pre-computed. The eval_line function just computes the dot product between the detector selected by a particular setting of the parameters and the local image.

The line detector is computed by Build_Line_Detectors in eval.c

Hope that helps and good luck!