portugueslab / stytra

A modular package to control stimulation and track behaviour
http://www.portugueslab.com/stytra/
GNU General Public License v3.0
41 stars 26 forks source link

Problems with offline tracking #17

Closed rjain24 closed 4 years ago

rjain24 commented 4 years ago

Hi! I'm interested in using this software for offline tracking of larval fish behavior. I've successfully installed Stytra on my Mac through Anaconda (OS 10.13.6), and I have been able to load in videos for free behaving fish (selecting "fish" for tracking). At this point though, I've run into a few problems:

1) it only sometimes will play through the video, and with no apparent progress bar or way to pause it or move to a period of interest. Am I missing something? If the movie plays, once it gets to the end of the movie is there a way to restart it? 2) I've opened the Tracking Controls menu, but I'm not clear on what all the parameters are to optimize the tracking - is this listed/described somewhere? For example, I have a video where the fish is tracked reasonably well when in the middle of the frame, but near the edges it is sometimes lost - I can't figure out how to focus on these time periods and then to optimize the tracking (if possible) 3) None of the plots in the GUI Plot panel seem to display anything ever, even when a fish seems to be identified with a red dot and blue tail and is moving.
4) I can see information on the csv file - is there a clear description of what each parameter is somewhere? For example, is the fish head orientation one of these parameters? Cumulative tail curvature? What does "biggest area" mean? It seems like the csv file gets generated starting right as the video has been loaded - is there a way to make the entire csv file info match tracking of the entire video if I adjust some of the tracking controls "midstream" to optimize the tracking while the video is actively playing?

I apologize if these are basic questions. Thank you for your help and clarification! ~Roshan

vilim commented 4 years ago

Hi Roshan,

1) The video playing is only there to assist with adjusting the tracking parameters. It is assumed by now that you would want to track the whole video, which is what happens when you press the track_video button. The video might not be looping, which is a bug I will fix in the next few days.

2) Regarding the parameters, they are described here: http://www.portugueslab.com/stytra/userguide/3_tracking.html#freely-swimming-fish but it could be described in more detail, I will put up a video tutorial soon. Basically you need to adjust all the diagnostic images to be reasonable (also using the auto-levels button underneath the camera display if you can't see anything or the images are too dim), by first adjusting the background difference threshold, so a large part of the fish is displayed as white in the thresholded background difference image. Then you have you have to select the thresholded for eye and swim bladder image and adjust the corresponding threshold until at least the eyes are always visible. After that you adjust the fish area range (the biggest area diagnostic plot should help with that). For adjusting of specific parts of the video we don't have the tool (there is a replay function, but only for the camera), it might come in a future release, but before that I am afraid you can either wait for the fish to move or cut parts of the video in a video editor, such as iMovie

3) The plots might not appear if the video framerate is very low or there are long tracking delays. Try adjusting the video framerate and the plot past period.

4) The biggest area is just a diagnostic parameter. We will document the outputs, for now: the f0_x and f0_y are coordinates _vx, _vy velocities (in px/timestep), and _theta the angle of the tail (add pi to get the heading angle), vtheta the angular velocity. The further theta_x columns are angles of individual segments, you can add up the differences (the same as first-last angle) to get the total curvature.

Adjusting the tracking parameters after you have clicked the Track video button have no effect, you have to find a set of parameters that works for the whole video.

Some things might be cleared up by: http://www.portugueslab.com/stytra/userguide/7_offline.html

Thanks for your patience, Stytra is primarily meant for online experiments, so the offline tracking part is rather unpolished.

rjain24 commented 4 years ago

Great, thanks for the quick clarifications! I will give this a try.

Best, ~Roshan

On Wed, Jul 31, 2019 at 3:11 AM Vilim Štih notifications@github.com wrote:

Hi Roshan,

1.

The video playing is only there to assist with adjusting the tracking parameters. It is assumed by now that you would want to track the whole video, which is what happens when you press the track_video button. The video might not be looping, which is a bug I will fix in the next few days. 2.

Regarding the parameters, they are described here:

http://www.portugueslab.com/stytra/userguide/3_tracking.html#freely-swimming-fish but it could be described in more detail, I will put up a video tutorial soon. Basically you need to adjust all the diagnostic images to be reasonable (also using the auto-levels button underneath the camera display if you can't see anything or the images are too dim), by first adjusting the background difference threshold, so a large part of the fish is displayed as white in the thresholded background difference image. Then you have you have to select the thresholded for eye and swim bladder image and adjust the corresponding threshold until at least the eyes are always visible. After that you adjust the fish area range (the biggest area diagnostic plot should help with that). For adjusting of specific parts of the video we don't have the tool (there is a replay function, but only for the camera), it might come in a future release, but before that I am afraid you can either wait for the fish to move or cut parts of the video in a video editor, such as iMovie 3.

The plots might not appear if the video framerate is very low or there are long tracking delays. Try adjusting the video framerate and the plot past period. 4.

The biggest area is just a diagnostic parameter. We will document the outputs, for now: the f0_x and f0_y are coordinates _vx, _vy velocities (in px/timestep), and _theta the angle of the tail (add pi to get the heading angle), vtheta the angular velocity. The further theta_x columns are angles of individual segments, you can add up the differences (the same as first-last angle) to get the total curvature.

Adjusting the tracking parameters after you have clicked the Track video button have no effect, you have to find a set of parameters that works for the whole video.

Some things might be cleared up by: http://www.portugueslab.com/stytra/userguide/7_offline.html

Thanks for your patience, Stytra is primarily meant for online experiments, so the offline tracking part is rather unpolished.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/portugueslab/stytra/issues/17?email_source=notifications&email_token=AKLGWIGXTZ37YXWTZ6QXHILQCDRERA5CNFSM4IHFELR2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3FYAUI#issuecomment-516653137, or mute the thread https://github.com/notifications/unsubscribe-auth/AKLGWIFZT76B3LDPZ24TQO3QCDRERANCNFSM4IHFELRQ .

--

Roshan Jain

(he/his)

Assistant Professor of Biology

Haverford College http://www.haverford.edu

370 Lancaster Avenue • Haverford, PA 19041 S108 Sharpless Hall • (610) 896-4907 https://www.haverford.edu/users/rjain1

Website https://www.haverford.edu/users/rjain1 • @JainNeuroLab https://twitter.com/JainNeuroLab

vilim commented 4 years ago

Closing this issue now as the separate questions go into their own issues

findingdory12 commented 2 years ago

Hi @vilim , would really appreciate a video tutorial!