Companion Data PageRecovery of locomotion after injury in Drosophila melanogaster depends on proprioceptionAlexander Isakov ^{1,2,*},
Sean M. Buchanan^{3,*},
Brian Sullivan^{2,4},
Akshitha Ramachandran^{2,4},
Joshua K. S. Chapman^{3},
Edward S. Lu^{2,4},
L. Mahadevan^{1,2,4,5,**} and
Benjamin de Bivort^{2,3,4,**}^{1} Department of Physics, Harvard University, Cambridge, MA 02138, USA.^{2} Center for Brain Science, Harvard University, Cambridge, MA 02138, USA.^{3} Rowland Institute at Harvard, Cambridge, MA 02142, USA. ^{4} Department of Organismic and Evolutionary Biology, Harvard University, Cambridge, MA 02138, USA. ^{5} School of Engineering and Applied Sciences, Harvard University, Cambridge, MA 02138, USA. ^{*} These authors contributed equally. ^{**} Corresponding authors: debivort@oeb.harvard.edu, lm@seas.harvard.edu
| |

## Data files (MATLAB 2014b and R format)Download a .zip of all these data files. | |

Fly_Data.RData | Contains three data frames. Columns V1, V2, V3, V4, V5, V6 correspond to legs labeled
as in Figure 1 in the main text (after amputation, V4 is all zeros). Column day corresponds
to experimentation day (-1 is pre-amputation, 0 is immediately post-amputation, 1-3 are
days 1-3 post-amputation). The column strain can take on the values "cs", "iav", "nan",
corresponding to wild type, inactive, and nanchung mutants in the paper. The column
flynum is a unique individual identifier for the flies. |

HMM_Data.RData | Contains one data frame, "df.hmm.data". Columns that share names with "Fly Data.RData" have the same description. Columns of the form [Gait]To[Number], where Gait can take the values {"Wave", "Tetrapod", "Tripod"} and Number can take the values {0,1,2,3} represent emission probabilities. Columns of the form [Gait]To[Gait] are transition probabilities. See paper for description. The column HiddenState represents the likeliest hidden state given the corresponding emission and transition probability matrix. The column NumLegsMoving is the observed "ground truth" number of legs moving (after binarizing leg motion). |

allPlastData.mat | Individual fly theta-delta histograms from arena circling experiments. Columns in cell array respectively indicate arena position number in 3x3 arena array, experiment ID, experimenter ID, imaging rig ID, experimental group, theta-d histogram values (cols 7-31). This file contains the binning used for figures in the manuscript. |

allPlastDataStatusSummary.mat | Contains a struct with two objects, respectively containing (in cols 4-16) the mean or standard deviation of the individual theta-d histogram values for flies belonging to the experimental groups indicated in column 1, with sample sizes indicated in column 2 and the mean mu score (or standard error of the mean of the mu score) in column 3. |

## Analysis and simulation functions and scripts (MATLAB 2014b)Download a .zip of all these scripts and functions. | |

automated movie annotation | |

Main_Movie_Correction_Script.m | Instructions, including input and output, are in the files. A schematic of logic flow
is in the paper. In brief, this script runs, cell by cell, the functions:
RemoveBeginningFramesByTimeFunction (cropping by time), RemoveFramesFunction
(cropping by frame-by-frame), AutomaticTrackingFunction (auto-tracker),
ErrorCorrectionFunction (hand-by-hand leg endpoint correction),
MotionDetectionFunction (to detect how far leg moved), and ShowFinalMovieFunction
(to see the final output of movies in one place).Important Note: Some of the files listed below (such as cropping) overwrite the
original movie. The script default is set to look at all movie files in the prescribed
folder. Please put a copy of the originals in a separate folder.Important Note: If the script is run as a batch on a large number of movies, a large
number of output files can be generated in the folder. Outputs (including file types) are
given in top-line comments in each cell of this script. |

RemoveBeginningFramesByTimeFunction.m, RemoveFramesFunction.m, AutomaticTrackingFunction.m, ErrorCorrectionFunction.m, MotionDetectionFunction.m, ShowFinalMovieFunction.m | Functions for cropping movies, tracking leg motion, and showing output. A schematic of logic flow is provided in the paper. Functions have numerous inputs, including some that switch between algorithms (with set defaults). All descriptions, including inputs and outputs, are given in top-level comments within each function. |

walking simulation | |

ArenaPathsSim.m | Simulation of fly body movement in arena for calibration (see: calibration curve description in Materials and methods section in paper). Inputs: numSims (number of simulations to run), numSteps (number of steps in one simulation – reasonable default is 10,000), headingDrift (heading drift – described in paper), bias (described in paper), visualizationFlag (can take value 0 or 1, with 0 meaning no visualization and 1 meaning show final theta-delta histogram and plot arena paths). Several parameters can be set inside the function (e.g. body length, arena radius), with defaults provided. |

walking_diff_eq_function.m | Function for simulating fly walking. A number of parameters are set and explained via comments in the code. Inputs: numStrides (number of strides to take -- 3 or more is reasonable, as described in paper), h (solver time-step, 0.001 is reasonable), deltaVec, phiVec, omega, (leg parameter vectors, as described in paper -- reasonable values for canonical tripod gait are delta = [.5,.5,.5,.5,.5,.5], omega = 1, phi = [0,.5,0,.5,0,.5]), p (sets maximum/minimum leg stretch), c_2_vec (forces), visualization_flag (1 displays movie after solving, 0 does not). |

energy_function.m | Energy calculation for simulated annealing optimization algorithm. Takes output of walking_diff_eq_function (theta_vector = body angle vector, centroid_vector = centroid vector; both at each time-step in the differential equation solver), h (number of time- steps used in equation solver), omega (step frequency), numStrides (number of strides used in equation solver), targetabsoluteBias (the observed bias in experiment to try to match). Descriptions of inner workings are in function comments. |