Fig. 2.
Automated detection of leg movements in freely walking flies. (A) Fly body contour is autoselected and shrunk by 5 px. The contour selection is grown back by 5 px, as a result of which only the torso gets selected, leaving the legs out. The fly contour selection and the fly torso selection are combined through a XOR function. This gives a composite selection containing all six legs. (B) Temporal z projection of leg-tip trajectories allows rapid extraction of individual leg tips by drawing ROI selections around six clusters. The color-coded heat map with respect to time is a record of the trajectory of the leg tip during the entire walking bout and aids in demarcating adjacent legs. The darker the color, the more past it is, and the lighter the color, the more recent it is. The leg tips and the body centroid are annotated in every frame of the video to aid in assessing the quality of their detection. (C) Swing phase and stance phase classification are performed based on the sign of change in the x coordinate of the leg tip with respect to time. A positive change implies swing phase of the leg, while a negative change implies stance phase of the leg. A swinging leg was annotated by overlaying a green filled circle on its tip; a stancing leg was annotated by overlaying a red filled circle on its tip. No leg was annotated if it was stationary. In Right, the color-coded legs indicate the leg motion state. Red color indicates the leg stance phase, and green color indicates leg swing phase. (D) The swing, stance, or steady phase of each of the six legs with respect to time is represented as a series of colored ticks in a gait diagram. A representative gait diagram is shown in which each tick is 5 ms (-t- axis) in duration; red tick implies swing, and turquoise tick implies stance phase. (E) Three legs swinging concurrently defines a concurrency state of 3, two legs swinging concurrently defines a concurrency state of 2, one leg swinging alone defines a concurrency state of 1, while state 0 implies no leg was swinging.