mlfpm / deepof

DeepLabCut based data analysis package including pose estimation and representation learning mediated behavior recognition
MIT License
39 stars 6 forks source link

Threshold in supervised annotation #32

Closed rosalba3574 closed 11 months ago

rosalba3574 commented 11 months ago

Hello! I am using Deepof with 2 animal tracking and is working nicely but I have a question. The default thresholds used in the annotation pipeline for the supervised analysis can be accessed and modified? I would like to try to put a more strict threshold to see if that would make a difference in the analysis I am doing. Could you please tell me how I could do this?

Thank you very much and thanks for developing such a nice tool! Rosalba

lucasmiranda42 commented 11 months ago

Dear @rosalba3574,

Thank you for your interest in DeepOF! Some of the explicit thresholds for many detected traits can indeed be adjusted. Below a simple example on how to do so, by passing a params dictionary to the .supervised_annotation() method, where values are in millimeters. We'll make sure to incorporate this in future versions of the supervised tutorial!


my_deepof_project.supervised_annotation(
        params={
        "climb_tol": 10, # Distance between the nose of a given animal and the walls of the arena, used for climbing detection
        "close_contact_tol": 25, # Distance to call a close contact between body parts, used for nose to nose and similar behaviors
        "side_contact_tol": 45, # Same as above, but specifically for nose to tail contacts in reverse side interactions
        "follow_frames": 10, # Minimum duration of a following behavior to be annotated, in frames
        "huddle_speed": 2, # Minimum speed (in mm/s) to annotate that a given animal is moving
        }
)

I'm closing the issue for now, but feel free to reopen if you have any questions :) Best, and hope it helps! Lucas

rosalba3574 commented 9 months ago

Dear @lucasmiranda42 thanks for the help, I was trying it but it gives me a syntax error and I am not sure how to solve it, could you please help me? this is the code I tried to run:

proj2.supervised_annotation("close_contact_tol": 10, "side_contact_tol":20)

SyntaxError                               Traceback (most recent call last)
File ~\AppData\Local\anaconda3\envs\deepof\lib\site-packages\IPython\core\compilerop.py:86, in CachingCompiler.ast_parse(self, source, filename, symbol)
     81 def ast_parse(self, source, filename='<unknown>', symbol='exec'):
     82     """Parse code to an AST with the current compiler flags active.
     83
     84     Arguments are exactly the same as ast.parse (in the standard library),
     85     and are passed to the built-in compile function."""
---> 86     return compile(source, filename, symbol, self.flags | PyCF_ONLY_AST, 1)

SyntaxError: invalid syntax (<ipython-input-5-6080755f5e4a>, line 1)

thank you, Rosalba

lucasmiranda42 commented 9 months ago

Dear Rosalba,

thank you for your continuous interest! You're on the right track, but the syntax above is indeed slightly wrong (I just corrected the previous answer). The supervised_annotation method takes a single parameter called params, which should be a dictionary with all required thresholds.

The final command in your case would be:

proj2.supervised_annotation(params={"close_contact_tol": 10, "side_contact_tol":20})
rosalba3574 commented 9 months ago

I am sorry for the very basic question, I understand now. Thanks for the quick reply, now it runs!