Skip to content
This repository has been archived by the owner on Jun 30, 2024. It is now read-only.

Draft: update concatenate #43

Open
wants to merge 37 commits into
base: concatenate
Choose a base branch
from

Conversation

fjhheras
Copy link
Owner

@fjhheras fjhheras commented Nov 16, 2021

Contributions from @antortjim to concatenation of tracjectories

@@ -58,20 +61,60 @@ def _concatenate_idtrackerai_dicts(traj_dicts):
"""
traj_dict_cat = traj_dicts[0].copy()
traj_cat = _concatenate_np(
[traj_dict["trajectories"] for traj_dict in traj_dicts]
[traj_dict["trajectories"] for traj_dict in traj_dicts], **kwargs
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you send **kwargs to _concatenate_np? _concatenate_np only has one positional argument

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm indeed, I think I put it there to be able to change the shape without changing the code. I removed the argument from the function's signature, but the kwargs lived on. Should be removed

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dealt with here e8e3f81

elif os.path.exists(trajectories):
return trajectories
else:
warnings.warn(f"No trajectory found in {session_folder}")
Copy link
Owner Author

@fjhheras fjhheras Nov 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should raise an exception in this point (otherwise it would fail outside due to the lack of returned value)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected here 49df26b

@antortjim
Copy link

The tests are now passing on my side, but the CI workflow still fails I think

pytest.log

@@ -6,8 +6,7 @@ name: Test and coverage
on:
push:
branches: [ master, develop ]
pull_request:
branches: [ master, develop ]
pull request
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are missing the underscore here (pull_request)

@fjhheras
Copy link
Owner Author

The tests are now passing on my side, but the CI workflow still fails I think

pytest.log

I think this is because the CI file is not OK (there is an underscore missing #43 (comment))

@antortjim
Copy link

My bad, fixed!

@@ -6,8 +6,7 @@ name: Test and coverage
on:
push:
branches: [ master, develop ]
pull_request:
branches: [ master, develop ]
pull_request
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pull_request
pull_request:
branches: ['*']

@fjhheras
Copy link
Owner Author

My bad, fixed!

Sorry, it seems that this did not do the trick. I suggested a change to see if we can make the tests work and get this merged. Sorry for the confusion!

Copy link
Collaborator

@pacorofe pacorofe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! But I left a couple of comments regarding some details of idtracker.ai that can help making some functions more robust.

@@ -64,14 +66,54 @@ def _concatenate_idtrackerai_dicts(traj_dicts):
return traj_dict_cat


def from_several_idtracker_files(trajectories_paths, **kwargs):
def pick_trajectory_file(session_folder):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that during the validation of idtracker.ai trajectories using the validation GUI a trajectory files with a timestamp suffix can be generated (https://github.com/video-annotator/pythonvideoannotator-module-idtrackerai/blob/24866ee28a514a8f1b0a3186800e84280c1d4cd4/pythonvideoannotator_module_idtrackerai/models/video/objects/idtrackerai_object_io.py#L56).
These files won't be considered by this function.
I believe that to make it more general we should check if there are trajectory files with timestamps and take the latest one.

raise Exception(f"Session {session_folder} has no trajectories")


def is_idtrackerai_session(path):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it would be more robust to check if it contains a file called video_object.npy.
the pattern session_ could be also used for sessions of experiments and you can end up checking for trajectories in folders that are not needed.

return re.search("session_.*", path) and os.path.isdir(path)

def get_trajectories(idtrackerai_collection_folder):
"""Return a list of all trajectory files available in an idtrackerai collection folder
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe be more specific about what an idtrackerai collection folder is:

Is this a folder that contains subfolders with videos and other session_ subfolders?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is how I am organizing my data. In other words, it is an imgstore.VideoImgStore where several session_ folders are also present.

@antortjim
Copy link

#38 (comment)

@fjhheras
Copy link
Owner Author

fjhheras commented Nov 29, 2021

Hi, it seems that black is failing. It can be the same issue of having old versions. I recommend installing using pip or conda in your environment.

Please note that you can always see the versions installed during the tests in the test log:
"Collecting black
Downloading black-21.11b1-py3-none-any.whl (155 kB)
Collecting flake8
Downloading flake8-4.0.1-py2.py3-none-any.whl (64 kB)"

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants