Offline tracking - MobsLab/PreProcessing GitHub Wiki
This chapter of the wiki explains how to perform tracking on a video offline.
Go to your folder of interest and launch this line of code
OfflineTrackingFinal_CompNewTracking
If you need to make a ref
Sometimes there was a problem saving the data and you don't have the ref image or your camera moved and the ref image is not correct. In this cage we can build a ref from the video by using times at which the mouse was in different parts of the maze.
Press the "Create Ref" button. Choose your video. Press the play button. Watch the video and press the "Get Frame" button twice when the mouse is in different parts of the environment. For example when it is at the top of the environment and then at the bottom or on the left then the right. We are going to use this to recreate a ref by taking parts of both images with no mouse. In the two images the whole of the mouse must be in completely separate parts of the environment (be careful of the tail) You will be prompted to give the position of the mouse in the top image. Use a single capital letter (T / B / L / R) to say whether the mouse is on the top, bottom, left or right. (Fig1-top) Use the crosshairs to select the limit between the two images that will allow to make the ref. (Fig1-bottom) Check that the reference image on the bottom is mouse-free. The ref will be saved. Press Done.
Launch the re-tracking
Press the "Tracking" button. Answer the prompts. Choose your video / folder with frames saved in .mat files. If you chose a video, you will be prompted to give the full length of the video. The tracking will then assume a constant frame rate equal to number of frames / video length. Press play. You can choose between :
- Everything : this will track the whole video in order.
- Just the NaNs : this will track only the frames which on previous tracking sessions failed to locate the mouse. You can use this functionality after having run the tracking on 'Everything'. This will allow you to specifically correct the values for the frames that didn't work.
- Nothing : abort.
Adjust the values of the slider. Examples of the use of some of these values are given on the tracking page.
- video speed: increase / decrease the frame rate
- time of vid: jump to a specific portion of the video. If the video speed is too high the button is faulty. Slow the speed down if you want to jump.
- thr. : the black and white image is thresholded (mouse is dark on light background) according to this value. Everything dark enough is a potential location of the mouse.
- rat : only objects with a ratio of long to short axis smaller than this value are kept. This eliminates long objects such as the tail or the cable
- min sz : min size: only parts of the image obtained after thresholding which are larger than this size will be considered as a potential location for the mouse.
- strl sz : this allows you to erode and dilate the objects detected after thresholding. This typically allows to merge two objects that are often separated by a small distance. For example the tail of the mouse is sometimes seen as detached from the body because of changes in shadows. With this parameter you can dilate the two objects and make them join so that they are tracked as a single object.
- smooth : the parameter is the size of the box around the mouse's current position that is used to calculate the number of pixels changing. It should be adjusted so that the dark grey box contains the whole mouse.
- surround : this parameters smooths the original image taken from the camera. It should in general be set to 0, except when filming on a grid (for example in fear conditioning boxes).
When you are satisfied with the tracking (check that the fans since last change is close to 0), press "Stop". You can choose between :
- No : don't retrack this mouse. If you want to go and check the NaN frames, press no and then press play again to choose Just the NaNs.
- Track offline : will launch the offline tracking
- Add to batch : adds the parameters and filename to a list of files that will be processed at the end of the session. This way you can accumulate all the videos to track and launch them all together.
Missing mask
If there is no mask in your behav_resources file, the software will ask you to make one. This works the same as for the online tracking. If you want to redo the mask, after choosing your video hit the 'Get Mask' button before you press play.
Missing pixel to cm ratio
If there is no ratio of pixels to real measurements, the software will ask you to make one. This works the same as for the online tracking.
Launch batch
Once you have added all the files you want to retract to the list. Press "Done" and then press "Launch Batch".