Code for analyzing the results of simultaneous recording of behavioral and neural responses of free-moving nematodes.
1. Worm body tracker (Body_Tracker_6.ijm) An ImageJ macro to detect the direction of the animal's head. When you register the macro in the ImageJ, two buttons, "B" and "p", will be generated in the toolbar. Load the image (sequential tif file) and press the "B" button to detect the direction of the animal's head. The results will be exported as Log.text and ~blurred.tif file. In the blurred.tif image, a white dot is present on the head of the nematode, from which a line extends. The direction of the line indicates the direction of the nematode's head. If this direction is opposite to the actual direction of the head, the calculated velocity should be reversed. The "p" button is for setting various parameters. 2. MATLAB code to calculate the velocity of animal movement (subpixalgintest5) Run the code and select the folder containing the images (sequential tif files) to analyze. For each image, the shift from the image in the previous frame (in the X and Y directions) is exported as pixels. The results will be exported as ~raw.csv file. By converting the pixels to distances and combining them with the head direction obtained from the code in 1, it calculates whether the animal is moving forward or backward, and how fast (See also "How to calculate the speed in Excel.txt" ).