mlfpm / deepof

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

Arena detection issue #25

Closed lisadiez closed 1 year ago

lisadiez commented 1 year ago

Hello!

Thank you so much for your quick Sleap integration :)

I'm trying to create the project and ran into the following error after selecting the polygonal arena corners:

>>> my_project = my_project.create(verbose=True)
Setting up project directories...
Loading trajectories...
Smoothing trajectories...
Interpolating outliers...
Iterative imputation of ocluded bodyparts...
Detecting arena...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/lisadiez/deepof-development/deepof/data.py", line 686, in create
    self.scales, self.arena_params, self.video_resolution = self.get_arena(
  File "/Users/lisadiez/deepof-development/deepof/data.py", line 317, in get_arena
    return deepof.utils.get_arenas(
  File "/Users/lisadiez/deepof-development/deepof/utils.py", line 1423, in get_arenas
    arena_parameters, h, w = automatically_recognize_arena(
  File "/Users/lisadiez/deepof-development/deepof/utils.py", line 1577, in automatically_recognize_arena
    get_close_matches(
IndexError: list index out of range

Thanks for your help! Lisa

lucasmiranda42 commented 1 year ago

Hi, Lisa!

This seems like a problem with the automatic arena segmentation. Could you post your deepof.data.Project() definition and a screenshot of one of your videos?

That will surely help us debug :)

Best! Lucas

lisadiez commented 1 year ago

Hi Lucas,

Here is the definition:

my_project = deepof.data.Project(
                project_path=os.path.join("/Users/lisadiez/Downloads/deepof"),
                video_path=os.path.join("/Users/lisadiez/Downloads/deepof/Videos/"),
                table_path=os.path.join("/Users/lisadiez/Downloads/deepof/Tables/"), # Where your .npy files are stored
                project_name="deepof_project",
                arena="polygonal-autodetect",
                rename_bodyparts=['nose', 'spine1', 'spine2', 'spine3', 'spine4', 'spine5'],
                animal_ids=['female', 'male', 'pup1', 'pup2', 'pup3', 'pup4'],
                table_format=".npy",
                video_scale=380, # Set to the arena
                )

And here is a screenshot of a video (and the area I selected):

arena

Thank you!! Let me know if you need anything else

lucasmiranda42 commented 1 year ago

Hi! The call seems correct, but I think this is unfortunately a bad edge case for the automatic detection pipeline as currently implemented (I would bet DeepOF is recognizing the object in the center instead of the blurrier arena surroundings in this case). A tedious solution would be to set arena to "polygonal-autodetect", but you'll need to draw it for all videos. We'll add a function to just copy and paste the selected arena across videos in a few days, which should hopefully be of use here :)

We'll let you know!

Best! Lucas

2909ft commented 1 year ago

Hello!

Just wondering whether this function has been implemented yet, as I am facing a similar issue (wrong arena being detected when using polygonal-autodetect).

lucasmiranda42 commented 1 year ago

Hi, @2909ft, hi @lisadiez!

It took a bit longer than expected, but we finally released a new version incorporating several novelties, among which is the requested option. When detecting arenas, now you can carry the first manual tag to the rest of the videos pressing just one button :) the details are in the new documentation (under arena detection). Hope this helps! Feel free to reopen if you have any further issues :)

Best, Lucas