Skip to content

Fixed reordering of markers following PyoMarkers #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 16, 2025

Conversation

EveCharbie
Copy link
Collaborator

@EveCharbie EveCharbie commented Jul 10, 2025

I don't understand why it changed anything, but now it seems to work better...


This change is Reviewable

@EveCharbie EveCharbie changed the title Fixed reordering of markers following PyoMarkers [RTR] Fixed reordering of markers following PyoMarkers Jul 11, 2025
@EveCharbie
Copy link
Collaborator Author

@Ipuch verry small modifs to review :)

Copy link
Collaborator

@Ipuch Ipuch left a comment

Choose a reason for hiding this comment

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

Very small but still edgy, some comments to guarantee the code doesn't drift too much into something not maintainable for me.

Reviewed 4 of 4 files at r1, all commit messages.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @EveCharbie)


pyorerun/utils/markers_utils.py line 38 at r1 (raw file):

        for i_marker, marker in enumerate(model.marker_names):
            marker_index = tracked_marker_names.index(marker)
            reordered_markers[:, i_marker, :] = tracked_markers.to_numpy()[:, marker_index, :]

I want a function for this piece of code and a test:

def sort_markers_to_a_predefined_order(markers: np.ndarray, initial_name_list, wanted_name_list):
"""
try to have a precise doc
"""
reordered_markers = np.zeros_like(tracked_markers.to_numpy())             
for i_marker, wanted_name_list in enumerate(wanted_name_list):
                       name_index = initial_name_list.index(marker_name_wanted)
                       reordered_markers[:, i_marker, :] = markers[:, name_index, :]
            return reordered_markers

Code quote:

        reordered_markers = np.zeros_like(tracked_markers.to_numpy())
        for i_marker, marker in enumerate(model.marker_names):
            marker_index = tracked_marker_names.index(marker)
            reordered_markers[:, i_marker, :] = tracked_markers.to_numpy()[:, marker_index, :]

tests/test_not_all_markers_in_models_and_tracked_makers.py line 57 at r1 (raw file):

def test_tracked_makers_not_in_order():

typo : test_tracked_markers_not_in_order


pyorerun/phase_rerun.py line 125 at r1 (raw file):

        """Add the tracked markers to the phase."""

        tracked_markers = check_and_adjust_markers(model, tracked_markers)

It's okay to me to remove it, but It was indeed cleaner to keep it inside. I don't understand why this is need, we need more tests. We must have something wrong somewhere. I dislike it?


pyorerun/rrc3d.py line 70 at r1 (raw file):

    phase_rerun.add_xp_markers(filename, pyomarkers)

    lowest_corner = 0.0

remove


pyorerun/rrc3d.py line 73 at r1 (raw file):

    if show_force_plates:
        force_plates_corners = get_force_plates(c3d_file, units=units)
        lowest_corner = get_lowest_corner(c3d_file, units=units)

Move this under 'if show_floor'

Code quote:

lowest_corner = get_lowest_corner(c3d_file, units=units)

pyorerun/rrc3d.py line 102 at r1 (raw file):

    if show_floor:
        square_width = max_xy_coordinate_span_by_markers(pyomarkers)

add :
lowest_corner = 0 if not show_force_plates else lowest_corner


pyorerun/phase_rerun.py line 91 at r1 (raw file):

        if isinstance(tracked_markers, np.ndarray):
            tracked_markers = PyoMarkers(tracked_markers, channels=model.marker_names)

Do we have a problem here?
I've explicitly asked the user to fill in PyoMarkers in the past because I wanted him to order the markers correctly. Letting the user give a np.array is a bad idea; this was my initial thought.

Code quote:

        if isinstance(tracked_markers, np.ndarray):
            tracked_markers = PyoMarkers(tracked_markers, channels=model.marker_names)

pyorerun/phase_rerun.py line 100 at r1 (raw file):

        if tracked_markers is not None:
            tracked_markers = check_and_adjust_markers(model, tracked_markers)

I feel a unit test of this function would strengthen my trust about this PR.

Code quote:

check_and_adjust_markers(model, tracked_markers)

@EveCharbie EveCharbie requested a review from Ipuch July 13, 2025 04:18
Copy link
Collaborator Author

@EveCharbie EveCharbie left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 7 unresolved discussions (waiting on @Ipuch)


pyorerun/phase_rerun.py line 91 at r1 (raw file):

Previously, Ipuch (Pierre Puchaud) wrote…

Do we have a problem here?
I've explicitly asked the user to fill in PyoMarkers in the past because I wanted him to order the markers correctly. Letting the user give a np.array is a bad idea; this was my initial thought.

I didn't touch this logic in this PR, but I agree it would be better to only accept PyoMarkers and not np.array. Please let me know if you want me to change it.


pyorerun/phase_rerun.py line 100 at r1 (raw file):

Previously, Ipuch (Pierre Puchaud) wrote…

I feel a unit test of this function would strengthen my trust about this PR.

Done.


pyorerun/rrc3d.py line 70 at r1 (raw file):

Previously, Ipuch (Pierre Puchaud) wrote…

remove

Done.


pyorerun/rrc3d.py line 73 at r1 (raw file):

Previously, Ipuch (Pierre Puchaud) wrote…

Move this under 'if show_floor'

Done.


pyorerun/rrc3d.py line 102 at r1 (raw file):

Previously, Ipuch (Pierre Puchaud) wrote…

add :
lowest_corner = 0 if not show_force_plates else lowest_corner

Done.


pyorerun/utils/markers_utils.py line 38 at r1 (raw file):

Previously, Ipuch (Pierre Puchaud) wrote…

I want a function for this piece of code and a test:

def sort_markers_to_a_predefined_order(markers: np.ndarray, initial_name_list, wanted_name_list):
"""
try to have a precise doc
"""
reordered_markers = np.zeros_like(tracked_markers.to_numpy())             
for i_marker, wanted_name_list in enumerate(wanted_name_list):
                       name_index = initial_name_list.index(marker_name_wanted)
                       reordered_markers[:, i_marker, :] = markers[:, name_index, :]
            return reordered_markers

Done.


tests/test_not_all_markers_in_models_and_tracked_makers.py line 57 at r1 (raw file):

Previously, Ipuch (Pierre Puchaud) wrote…

typo : test_tracked_markers_not_in_order

Done.

Copy link

codeclimate bot commented Jul 13, 2025

Code Climate has analyzed commit 4594a13 and detected 0 issues on this pull request.

View more on Code Climate.

Copy link
Collaborator

@Ipuch Ipuch left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @EveCharbie)

@Ipuch Ipuch changed the title [RTR] Fixed reordering of markers following PyoMarkers Fixed reordering of markers following PyoMarkers Jul 16, 2025
@Ipuch Ipuch merged commit c758a3e into pyomeca:main Jul 16, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants