Automated recording of walking behavior of freely moving flies. (A) Leg movements of freely walking flies were recorded with a 200-fps camera; flies were placed in the rectangular-shaped arena that has a square-shaped flat bottom of 20 mm width and 10 mm height with two opposing inclined (45°) surfaces and that is surrounded by teflon-coated walls at a height of 30 mm to discourage climbing; the arena is illuminated from below with an LED light source. (B) Dorsal view of the fly captured at a high resolution of 2,500 μm to 67.5 px. (Scale bar: 37 μm to 1 px.) (C) To obtain linear walking sequences, each frame is thresholded such that only the torso is visible. A watershed filter cuts the torso into three sections—the head, the thorax, and the abdomen. The centroids of the head and the body define the orientation vector. Enforcing a maximum angular deviation of 10° as a chief criterion, contiguous frames that constitute a linear walking bout are selected. (D) A minimum bounding box that encloses the fly body is used as a mask to crop each frame, and rotational transformation is applied so that the fly’s linear motion occurs along the positive direction of the new x axis. The centroid of the fly was computed in each frame, and the origin of the new coordinated axis was shifted to the centroid. This transforms the noninertial frame of reference to the inertial frame of reference such that the fly appears to be walking on a treadmill.