-
Notifications
You must be signed in to change notification settings - Fork 7
Draft: update concatenate #43
base: concatenate
Are you sure you want to change the base?
Conversation
…when passing several idtrackerai sessions
…s is (frames, individuals, 2) and not (individuals, frames, 2)
@@ -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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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}") |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected here 49df26b
The tests are now passing on my side, but the CI workflow still fails I think |
@@ -6,8 +6,7 @@ name: Test and coverage | |||
on: | |||
push: | |||
branches: [ master, develop ] | |||
pull_request: | |||
branches: [ master, develop ] | |||
pull request |
There was a problem hiding this comment.
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)
I think this is because the CI file is not OK (there is an underscore missing #43 (comment)) |
My bad, fixed! |
@@ -6,8 +6,7 @@ name: Test and coverage | |||
on: | |||
push: | |||
branches: [ master, develop ] | |||
pull_request: | |||
branches: [ master, develop ] | |||
pull_request |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pull_request | |
pull_request: | |
branches: ['*'] |
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! |
There was a problem hiding this 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): |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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: |
f6b622a
to
30b520a
Compare
Contributions from @antortjim to concatenation of tracjectories