DOI: 10.5061/dryad.mpg4f4r73
title: Miniature linear and split-belt treadmills reveal mechanisms of adaptive motor control in walking Drosophila

description: To navigate complex environments, walking animals must detect and overcome
 unexpected perturbations. One technical challenge when investigating
 adaptive locomotion is measuring behavioral responses to precise
 perturbations during naturalistic walking; another is that experimentally
 silencing neurons in sensorimotor circuits often reduces spontaneous
 locomotion. To overcome these obstacles, we introduce miniature treadmill
 systems for coercing locomotion and tracking 3D kinematics of walking
 Drosophila. By systematically comparing walking in three experimental
 setups, we show that flies compelled to walk on the linear treadmill have
 similar stepping kinematics to freely walking flies, while kinematics of
 tethered walking flies are subtly different. Genetically silencing
 mechanosensory neurons alters step kinematics of flies walking on the
 linear treadmill across all speeds, while inter-leg coordination remains
 intact. We also found that flies can maintain a forward heading on a
 split-belt treadmill by adapting the step distance of their middle legs.
 Overall, these insights demonstrate the utility of miniature treadmills
 for studying insect locomotion.
description: The datasets within this repository were collected by recording
 flies with high-speed cameras walking on a mini treadmill (linear or
 split-belt treadmill), freely in a featureless arena, or on a ball
 suspended in air while tethered. Flies on the linear treadmill and
 split-belt treadmills were recorded with 5 high-speed cameras at 180 and
 200 fps, respectively. Flies walking in the arena were recorded at 150 fps
 with a top-down camera. Lastly, tethered flies walking on the ball were
 recorded with 6 high-speed cameras at 300 fps. We then used modern pose
 estimation tools (DeepLabCut and Anipose for treadmill and tethered
 walking flies, and SLEAP for freely walking flies) to extract 2D or 3D
 positions for labeled key points (i.e. points on the body and leg tips).
 We then computed walking kinematics from these positions using Python.
 Please refer to the corresponding paper for more details on data
 collection and processing. 
description: # Kinematic datasets of treadmill, freely, and tethered walking flies ###
 [https://doi.org/10.5061/dryad.mpg4f4r73](https://doi.org/10.5061/dryad.mpg4f4r73) #### Overview The datasets within this repository contain the tracked keypoints of treadmill (linear and split-belt), freely, and tethered walking flies. In figures 1-3 of the paper, wild-type berlin flies were used in linear treadmill, freely walking, and tethered experiments. Experiments consisted of recording flies walking in those setups with high-speed cameras and extracting 2D (freely walking flies) or 3D (treadmill and tethered walking flies) positions using modern pose estimation tools (DeepLabCut and Anipose, and SLEAP, respectively). Walking kinematics were then calculated from these positions in Python. The Python scripts were designed to run the data files located in this repository and are located in the following GitHub repo: [https://github.com/Prattbuw/Treadmill*Paper*](https://github.com/Prattbuw/Treadmill_Paper)*. The same data collection and processing steps were used for the subsequent parts of the paper. Figures 4 and S2 contain kinematic data of control (*iav-GAL4 control, UAS-Kir 2.1 control, R52A01 DBD &gt; Kir2.1*) and experimental (*iav-GAL4 &gt; Kir2.1, R93D09 AD: VT061711 DBD &gt; Kir 2.1) flies walking on the linear treadmill and freely in an arena. Note that experimental flies had the mechanosensory neurons labeled by the iav-GAL4  and R93D09 AD: VT061711 DBD drivers silenced with the inward rectifying potassium channel Kir 2.1. Finally, figure 5 shows kinematic data of control flies (R48A07 AD &gt; Kir2.1 and R39B11 &gt; Kir2.1) walking on the split-belt treadmill. During this experiment, flies were recorded while the left and right belts moved at the same or different speeds. We then assessed the kinematic changes that enabled flies to walk straight when the left and right belts moved at different speeds. Note that the names of the data files contain the genotype of the flies and the setup used (treadmill, freely, or tethered), or the relevant figure the data is associated with in the paper. #### Linear Treadmill Experiments (Figures 1-4, Figure S1, Figure S2) Wild-type Berlin filename: "wt_berlin_linear_treadmill_dataset.csv" UAS-Kir 2.1 control filename: "W1118_kir_LB_linear_treadmill_dataset.csv" iav-GAL4 control filename: "DL_IAV_linear_treadmill_dataset.csv" iav-GAL4 &gt; Kir 2.1 filename: "iav_kir_linear_treadmill_dataset.csv" R52A01 DBD &gt; Kir 2.1 filename: "52A01_DBD_kir_linear_treadmill_dataset.csv" R93D09 AD: VT061711 DBD &gt; Kir 2.1 filename: "HP_CS_kir_linear_treadmill_dataset.csv" These datasets contain kinematics of wild-type Berlin, iav-GAL4 control, UAS-Kir 2.1 control, iav-GAL4 &gt; Kir2.1, R52A01 DBD &gt; Kir 2.1, and R93D09 AD: VT061711 DBD &gt; Kir 2.1 male fruit flies walking on a linear treadmill across a variety of belt speeds (See paper for further detail). 5 high-speed cameras recorded flies walking on the treadmill at 180 fps. DeepLabCut (Mathis et al., 2018) and Anipose (Karashchuk et al., 2021) were used to reconstruct the positions of the keypoints below in 3D. Custom Python scripts were used to analyze and visualize walking kinematics (See GitHub [https://github.com/Prattbuw/Treadmill_Paper](https://github.com/Prattbuw/Treadmill_Paper)). Data contained here can be processed with these scripts to obtain the results published in the present paper. The columns of the data files above correspond to the bullet points below. Each row within the data files represents a recording time point. #### Metadata Within the data files above, the following variables were added: * genotype - the genotype of the fly [string] * filename - trial filename that contains information about the fly identity, trial number, and belt speed [string] * fly number - identity of the fly [#] * trial number - trial number within an experiment [#] * belt speed - steady-state belt speed (mm/s) after ramping the speed from the baseline speed of 3.9 mm/s. [mm/s] * frame start of steady-state belt speed - the frame within the trial in which the steady-state belt speed was reached. [#] #### Keypoints We tracked the following keypoints first in 2D (DeepLabCut) and then reconstructed in 3D (Anipose) resulting in 3D x,y,z positions (A.U.): * head - between antennae * thorax - on the scutelum * abdomen - most distal point * r1 - distal tip of right front leg * r2 - distal tip of right middle leg * r3 - distal tip of right hind leg * l1 - distal tip of left front leg * l2 - distal tip of left middle leg * l3 - distal tip of left hind leg * top front of the chamber * top back of the chamber * back center of the chamber Note that the chamber keypoints defined the 3D reference frame, which was sometimes rotated to ensure left-right symmetry of fly leg movement (i.e. make it so the reference is aligned with the surface of the treadmill belt). Also, the units of the data will be converted to millimeters from "arbitrary units" when the data is processed with the Python script described above. #### Split-Belt Treadmill Experiments (Figure 5) R48A07 AD &gt; Kir2.1 filename: "R48A07AD_kir_splitbelt_treadmill_dataset.csv" R39B11 AD &gt; Kir2.1 filename: "R39B11_kir_splitbelt_treadmill_dataset.csv" These datasets contain kinematics of R48A07 AD &gt; Kir2.1 and R39B11 AD &gt; Kir2.1 male fruit flies walking on a split-belt treadmill when the belts were tied in speed (10 mm/s) or split in speed (8 and 12 mm/s, respectively) (See paper for further detail). Only forward walking bouts in which the right and left legs moved along the right and left treadmill belts, respectively, were analyzed. 5 high-speed cameras recorded flies walking on the treadmill at 200 fps. DeepLabCut (Mathis et al., 2018) and Anipose (Karashchuk et al., 2021) were used to reconstruct the 3D positions of the same keypoints described above in the linear treadmill section. Custom Python scripts were used to analyze and visualize walking kinematics (See GitHub [https://github.com/Prattbuw/Treadmill_Paper](https://github.com/Prattbuw/Treadmill_Paper). Data contained here can be processed with these scripts to obtain the results published in the paper. #### Metadata Within the data files above, the following variables were added: * genotype - the genotype of the fly [string] * filename - trial filename that contains information about the fly identity, trial number within the presplit, split, or post-split period of the task, whether the left or right belt was moving faster during the split period (i.e. RS_H: right belt moving faster; RS_L: right belt moving slower), and the speed of each belt in mm/s. [string] * fly number - identity of the fly [#] * trial number - trial number within an experiment [#] * split period -presplit (period before the split period where the belts moved at the same speed), split (belts moved at different speeds), and post-split (period after the split period where the belts moved at the same speed) [string] * left belt speed (mm/s) - speed of the left belt during the trial [mm/s] * right belt speed (mm/s) - speed of the right belt during the trial [mm/s] #### Freely Walking Experiments (Figures 2-3, Figure S1) Filename: "wt_berlin_freely_walking_dataset.csv" This dataset contains kinematics of wild-type Berlin male fruit flies walking freely in a featureless arena (See paper for further detail). 1 high-speed camera recorded flies walking from the top-down in a region of the arena at 150 fps. SLEAP (Pereira et al., 2022) was used to reconstruct the positions of the keypoints below in 2D. Custom Python scripts were used to analyze and visualize walking kinematics (See GitHub [https://github.com/Prattbuw/Treadmill_Paper](https://github.com/Prattbuw/Treadmill_Paper). Data contained here can be processed with these scripts to obtain the results published in the paper. The columns of the data files above correspond to the bullet points below. Each row within the data files represents a recording time point. #### Metadata Within the data file above, the following variables were added: * genotype - the genotype of the fly [string] * trajectories - the unique trajectory during the recording. Note that individual flies could not be identified across trajectories [#] * frame idx - the frames within the 10 second recording that corresponded to the trajectory [#] #### Keypoints We tracked the following keypoints in 2D (SLEAP) resulting in x,y positions (units are in pixels): * head - between antennae * thorax - on the scutelum * abdomen - most distal point * r1 - distal tip of right front leg * r2 - distal tip of right middle leg * r3 - distal tip of right hind leg * l1 - distal tip of left front leg * l2 - distal tip of left middle leg * l3 - distal tip of left hind leg * wingL - distal tip of the left wing * wingR - distal tip of the right wing #### Tethered Walking Experiments (Figures 2-3, Figure S1) Filename: "wt_berlin_tethered_dataset.csv" This dataset contains kinematics of wild-type Berlin fruit flies walking on an air-cushioned ball (N=12 flies). Videos from 6 different camera angles were recorded at 300 FPS, with tracked 2D keypoints on each joint for each leg, and then triangulated into 3D kinematics using Anipose. However, analysis of joint kinematics is still ongoing work and not included in this manuscript. The behavioral classifier from the Anipose paper (Karashchuk et. al, 2021) was used to distinguish bouts of walking (and of other behaviors). We also tracked the movement of the ball using FicTrac (Moore et. al, 2014), which serves as a readout for the forward and rotational walking velocity of the fly. Experiments were performed by Grant Chou on 09/14/2023 and 09/19/2023. The columns of the data files above correspond to the bullet points below. Each row within the data files represents a recording time point. #### Keypoints ##### Body points We tracked the following keypoints along the body of the fly (A.U.): * abdomen-tip: the tip of the abdomen * stripe-3: 3rd abdomen stripe from the top * stripe-1: 1st abdomen stripe from the top * thorax-abdomen: thorax-abdomen connective * head-thorax: head-thorax (neck) connective * l-eye-t: top of the left eye * l-eye-b: bottom of the left eye * r-eye-t: top of the right eye * r-eye-b: bottom of the right eye The 3D positions of these body points are stored as follows: * x y z - the relevant coordinate axis (e.g. "abdomen-tip_x" is the position of abdomen-tip along x-axis) The body lengths of each fly were calculated by summing the 3D distances between abdomen-tip to thorax-abdomen, thorax-abdomen to head-thorax, and head-thorax to the midpoint between l-eye-t and r-eye-t. ##### Leg joints Flies have 6 legs, denoted as follows: * L1 - front left leg * L2 - mid left leg * L3 - hind left leg * R1 - front right leg * R2 - mid right leg * R3 - hind right leg We track 5 points on each leg (units are in degrees), denoted A-E: * A - body-coxa joint * B - coxa-femur joint (this point is roughly positioned at the trochanter) * C - femur-tibia joint * D - tibia-tarsus joint * E - tarsus tip Each joint is uniquely specified by the leg and joint name. For instance, L1A would be the left front leg body-coxa joint. The 3D positions of the legs are stored for each joint leg combination as follows: * x y z - the relevant coordinate axis (e.g. "L1A_x" is the position of L1A along x-axis) Note also that due to the way we perform camera calibration, the scale of the x y z coordinates is in arbitrary units. If you want to get units of mm, we recommend scaling the coordinates such that the length of the left leg coxa ||L1A - L1B|| is 0.456 mm, our empirical measurement of the average coxa length for these flies. The x y z axes are not arbitrary. We rotate the coordinate frame according to the following orthogonal axes: * x axis goes L1A -&gt; R1A * y axis roughly goes L3A -&gt; L1A, but orthogonalized with x axis * z axis is cross product of x and y axes, roughly down -&gt; up #### Angles (not analyzed in this manuscript) There are three types of angles: * {leg}{joint}_rot: rotation about the axis of the leg * {leg}{joint}_flex: flexion of the joint * {leg}A_abduct: abduction of the joint (only for the body-coxa joint) For example the L2B_rot column is the middle left leg femur rotation angle and the R1C_flex column is the front right leg femur-tibia flexion angle. We've also computed Hilbert transform phases for each joint angle and tarsus tip, as well as the 1st and 2nd-order derivatives of each joint angle, denoted respectively as: * {leg}{joint}_{angle or tarsus tip coordinate}_phase * {leg}{joint}_{angle}_d1 * {leg}{joint}_{angle}_d2 (e.g. R3E_y_phase = phase of the hind right tarsus tip y-coordinate, L1A_flex_d1 = 1st derivative of the front left leg body-coxa flexion angle) We use the 3D positions of the legs to infer the angles of the fly legs. In order to identify the angles in a unique way, we use a simple model for the leg, with the following assumptions: 1. only the body-coxa joint can abduct 2. all limbs can rotate, except the tarsus 3. all joints except body-coxa are restricted with up to 180 degrees of flexion Refer to the attached diagram (leg_angles.png) to see the possible angles. The angles are then encoded, in degrees, according to each joint and angle type. A rotation of a limb (e.g. femur) is thought of as a rotation of the preceding joint (e.g. coxa-femur or B joint). The rotation (and abduction) angles wrap around 180 degrees, which can add discontinuities to the data. We found we can get them to be continuous most of the time with this simple code: r[r &lt; 0] += 360 .. where r is an array containing a rotation angle. The raw, uncorrected angles in the dataset, are denoted as \* {leg}{joint}_{angle}_raw #### FicTrac FicTrac calculates 3 axes of velocity of the ball in mm/s or deg/s. * fictrac_delta_rot_lab_x_mms: sideslip velocity in millimeters per second (i.e. sidestepping) * fictrac_delta_rot_lab_y_mms: forward velocity in millimeters per second (i.e. forward walking) * fictrac_delta_rot_lab_z_mms: rotational velocity in millimeters per second (i.e. turning) * fictrac_delta_rot_lab_x_deg/s: sideslip velocity in degrees per second * fictrac_delta_rot_lab_y_deg/s: forward velocity in degrees per second * fictrac_delta_rot_lab_z_deg/s: rotational velocity in degrees per second (I usually analyze forward velocity in mm/s and turning in deg/s) as well as the integrated path (i.e. a flatmap of the fly's fictive path) * fictrac_int_x_mm * fictrac_int_y_mm #### Other data Other leg parameters * {leg}_swing_stance, where swing = 0 and stance = 1 * {leg}_smoothed_velo: the 3d velocity of the tarsus tip (this was used as a thresholding parameter for the swing/stance classifier) Behavioral classification is denoted as * {behavior}_bout_number: a number identifying each bout of the behavior * {behavior}_prob: the probability of the behavior (only one behavior classified per frame, so highest probabilty "wins") We're most interested in walking (i.e. 'walking_bout_number'), but other behaviors include standing, different types of grooming, and ball pushes. Experimental variables * fullfile: the file name of the video (which can be viewed on flyviz.biz) * fnum: the frame number from the video * flyid: a unique identifier for the fly (formatted as '{mm}.{dd}.{yy} Fly {flynum}_{trialnum}', where the fly number is 1-indexed and the trial number is 0-indexed) #### KL divergence analysis determined if the stepping kinematics of freely walking flies were more similar to flies walking of the treadmill or those that were tethered (Figure S1). Filename: "figure_S1_data.zip" - contains the data for figure S1. This ZIP file contains the folder called "figure2_data", which is named such because that is the figure within the paper that figure S1 supports. Within that folder are three folders called, "ball", "bowl", and "treadmill", which correspond to the tethered, freely, and treadmill walking datasets, respectively. Within each of those folders are four numpy (.npy) files (named according to the step metric they are associated with) that contain the step frequencies (1/s), stance durations (seconds), swing durations (seconds), and step lengths (body length) for each leg pair (front, middle, and hind legs) and speed range (Slow: 0-6 BL/s, Intermediate: 6-10 BL/s, and Fast: 10+ BL/s). These numpy flies can be loaded into Python using the "np.load()" function. The first row of the numpy file contains the measured step kinematic variable (i.e. step frequency) and the second row contains the categorical identifier of leg pair and speed range (i.e. 0-8). The categorical identifiers are described below: * 0: Front legs and slow walking speed range. * 1: Front legs and intermediate walking speed range. * 2: Front legs and fast walking speed range. * 3: Middle legs and slow walking speed range. * 4: Middle legs and intermediate walking speed range. * 5: Middle legs and fast walking speed range. * 6: Hind legs and slow walking speed range. * 7: Hind legs and intermediate walking speed range. * 8: Hind legs and fast walking speed range. Therefore, step metric data can be isolated for each of these conditions by specifying the appropriate id number. Moreover, each column represents a single step. These numpy arrays were used in the KL divergence analysis (See paper for further detail on how the analysis was performed), which assessed whether a step metric of freely walking flies was more similar to that of treadmill or tethered walking flies. Note that these step metrics are only associated with forward walking bouts. Custom Python scripts were used to run the KL Divergence analysis (See GitHub [https://github.com/Prattbuw/Treadmill_Paper](https://github.com/Prattbuw/Treadmill_Paper). The numpy files can be loaded in these Python scripts to recapitulate the results shown in Figure S1.