Skip to content

Latest commit

 

History

History
91 lines (60 loc) · 10.1 KB

TrackingTroubleshooting.md

File metadata and controls

91 lines (60 loc) · 10.1 KB

ZebraZoom Tracking Troubleshooting Tips

In order to run the tracking of ZebraZoom, you should start by creating a configuration file by clicking on "Prepare configuration file for tracking" in the main menu of ZebraZoom. Once your configuration file is ready, click on "Run ZebraZoom's Tracking on a video" and then before clicking on "Choose file", check the box "Run in debug mode": this will allow you to check if it looks like the tracking is working for your video with the configuration file you created or not. If it looks like it's not working, try following the tips below to improve the configuration file you initially created: you should iteratively try to adjust the configuration file with the tips below and try running the tracking with the "debug mode" until the tracking looks good enough.
Once the tracking seems to be working well in "debug mode", you can also try testing the tracking on a larger section of your video (but not all of the video, if it's a long video), by adding the parameters "firstFrame": frameNumberToStartTracking, "lastFrame": frameNumberToStopTheTracking, "backgroundExtractionForceUseAllVideoFrames": 1.
If none of this works, then click on "Troubleshoot" in the main menu of ZebraZoom and follow the instructions to send us a sub-video by email and we can try to help.

Center of mass tracking issues:

Problems on borders
Animals not detected
Post-processing of trajectories

Freely swimming zebrafish tracking issues:

Problems on borders
Animals not detected
Post-processing of trajectories
Zebrafish tail not tracked accurately
Bout detection issues
Tail angle parameters calculation issues
Eye Tracking

Head-embedded zebrafish tracking issues:

Head embedded tracking issues

You can solve this problem by adding a filter to the extracted background of the video. To do this add in the configuration file:
"backgroundPreProcessMethod": ["erodeThenMin"], "backgroundPreProcessParameters": [[3]]
The value "3" above is just an example. You can put any value you want: higher values will lead to filtering for a higher number of pixels.

When running the tracking in "debug mode" as adviced above, you will see a visualization window called "Tracked frame: Click on any key to proceed": on this visualization window, you should in theory see non-white pixels on and only on pixels that are part of an animal. If it looks like there are too many non-white pixels, then:
If "adjustMinPixelDiffForBackExtract_nbBlackPixelsMax" is inside your configuration file and has a value different than zero, then you can try decreasing the value of that parameter.
If "adjustMinPixelDiffForBackExtract_nbBlackPixelsMax" is not inside your configuration file then you can try decreasing the value of the parameter "minPixelDiffForBackExtract" instead.
If on the other hand it looks like there are not enough non-white pixels, then you can try increasing the values of those two parameters.

If it looks like only the small areas (made of non-white pixels) representing an animal are the areas that are not being detected, you can try decreasing the values of the parameters "minArea" and "minAreaBody". If on the other hand it looks like it's only large areas (made of non-white pixels) representing an animal that are the areas that are not being detected, then you can try increasing the values of the parameters "maxArea" and "maxAreaBody".

If it looks like too many non-white pixels are found close to the edge of the wells then add a filter on the background extracted as explained in the previous section.

NB: after extracting the background of the video, ZebraZoom extracts the foreground of a video (previously refered to as "non-white pixels") by finding the pixels of an image that have a value more than "minPixelDiffForBackExtract" different from the background. And when "adjustMinPixelDiffForBackExtract_nbBlackPixelsMax" is set to a value different than 0, then ZebraZoom will iteratively adjust the value of "minPixelDiffForBackExtract" in order to make the number of non-white pixels found as close as possible to the value of "adjustMinPixelDiffForBackExtract_nbBlackPixelsMax".

If some animals are sometimes not being detected at all no matter what, you can add some post-processing of trajectories to solve the problem. In order to do this, you will need to add the following parameters to your configuration file:
"postProcessMultipleTrajectories": 1, "postProcessMaxDistanceAuthorized" : 250, "postProcessMaxDisapearanceFrames" : 10
The values 250 and 10 are just examples here, you will need to further adjust those. "postProcessMaxDistanceAuthorized" is the maximum distance accepted (in pixels) above which it is considered that an animal was detected incorrectly (and thus the trajectory post-processing will be applied), and "postProcessMaxDisapearanceFrames" is the maximum number of frames for which the post-processing will consider that an animal can be incorrectly detected.
You also have the option of putting the parameter "postProcessMaxDistanceAuthorized" to a very high value which will have the effect of only modifying the values (x, y) for frames for which no detection occured at all.
Additionnally, when adding this post-processing of trajectories, it's also usually better to also set the parameter "multipleHeadTrackingIterativelyRelaxAreaCriteria" to 0.

If "adjustMinPixelDiffForBackExtract_nbBlackPixelsMax" is inside your configuration file and if it has a value different than zero, then:
if "recalculateForegroundImageBasedOnBodyArea" is set to 0, then you can try setting it to 1 instead. If after making that change the tail tip is being detected "too soon", you can try increasing the value of "adjustMinPixelDiffForBackExtract_nbBlackPixelsMax". If on the other hand the tail tip is being detected at the right place but the tail tracking is sometimes innacurate, you can try decreasing the value of "adjustMinPixelDiffForBackExtract_nbBlackPixelsMax".

If "adjustMinPixelDiffForBackExtract_nbBlackPixelsMax" is not inside your configuration file, then if the tail tip is detected "too soon", you could try increasing the value of the parameter "minPixelDiffForBackExtract". If on the other hand the tip of the tail is being detected at the right place but the tracking of the tail is sometimes incorrect, then you can try decreasing the value of this parameter "minPixelDiffForBackExtract".

The default bout detection method relies on the amount of pixel intensity changes between subsequent frames. This method relies on four parameters that can be adjusted in the configuration file: "thresForDetectMovementWithRawVideo", "minNbPixelForDetectMovementWithRawVideo", "frameGapComparision" and "halfDiameterRoiBoutDetect".

If after creating an initial configuration file and running the tracking of ZebraZoom on it you noticed some false negative and/or false positive detection of bouts for freely swimming fish, you can go back to the configuration file creation system in the GUI and choose the "Alternative method: Manual Parameter Setting". Then, when asked "Do you want to detect bouts of movements and/or further adjust tracking parameters?", you must answer "Yes". You will then be able to adjust the parameters related to the detection of bouts, and you will be able to do so while deciding on which well and which frames to visualize bouts (thus you can adjust those parameters taking all the frames/well into account). When you think you found a good set of parameters, save your configuration file, and then copy and paste the four parameters "thresForDetectMovementWithRawVideo", "minNbPixelForDetectMovementWithRawVideo", "frameGapComparision" and "halfDiameterRoiBoutDetect" from the configuration file you just created into your original configuration file where the bouts detection was suboptimal (this whole procedure enables you to find good parameters for bout detection in order to copy and paste them into the original configuration file where you initially saw bout detection related errors).

Importantly, another important parameter is "fillGapFrameNb", which controls the merging of bouts that are close to each other (in number of frames). Increasing the value of this parameter "fillGapFrameNb" will lead to more merging of bouts and decreasing it will lead to less merging.

Read this. It may be possible in some situations to track the eyes of the fish: for instance, this will only work if there are enough pixels per eye and if the eyes are much darker than the rest of the body of the zebrafish (swim bladder excluded): read this to learn more. Read this.