From b17d9b1df964a47c3b161ac6b90dbd403f666bcf Mon Sep 17 00:00:00 2001 From: Pariterre Date: Fri, 16 Feb 2024 18:06:59 -0500 Subject: [PATCH 1/4] Fixed showing of scale in muscle --- bioviz/__init__.py | 6 ++---- bioviz/analyses/muscle_analyses.py | 24 ++++++++++++++++++++---- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/bioviz/__init__.py b/bioviz/__init__.py index 8f03927..eb11480 100644 --- a/bioviz/__init__.py +++ b/bioviz/__init__.py @@ -331,9 +331,7 @@ def __init__( self.n_max_events = 100 self.last_event_index = -1 - self.events: list[ - dict[str:RectangleOnSlider, str:int, str:str], ... - ] = [] # event list of [marker/frame/event_name] + self.events: list[dict[str:RectangleOnSlider, str:int, str:str]] = [] # events [marker/frame/event_name] self.active_analyses: AnalysePanel | None = None self.column_stretch = 0 @@ -1039,7 +1037,7 @@ def load_experimental_markers( data, auto_start=True, ignore_animation_warning=True, - experimental_markers_mapping_to_virtual: list[int, ...] = None, + experimental_markers_mapping_to_virtual: list[int] = None, ): if isinstance(data, str): self.experimental_markers = Markers.from_c3d(data) diff --git a/bioviz/analyses/muscle_analyses.py b/bioviz/analyses/muscle_analyses.py index 97c2b42..7d03dc4 100644 --- a/bioviz/analyses/muscle_analyses.py +++ b/bioviz/analyses/muscle_analyses.py @@ -90,6 +90,7 @@ def __init__(self, main_window, parent: QWidget = None, background_color=(0.5, 0 self.ax_passive_forces.set_facecolor(background_color) self.ax_passive_forces.set_title("Passive forces") self.ax_passive_forces.set_ylabel("Passive forces coeff") + self.ax_passive_forces.set_ylim((0, 1)) # Add active forces self.canvas_active_forces = FigureCanvasQTAgg(plt.figure(facecolor=background_color)) @@ -100,6 +101,7 @@ def __init__(self, main_window, parent: QWidget = None, background_color=(0.5, 0 self.ax_active_forces.set_facecolor(background_color) self.ax_active_forces.set_title("Active forces") self.ax_active_forces.set_ylabel("Active forces coeff") + self.ax_active_forces.set_ylim((0, 1)) self.active_forces_slider = QSlider() active_forces_layout.addWidget(self.active_forces_slider) self.active_forces_slider.setPalette(self.main_window.palette_active) @@ -170,11 +172,21 @@ def update_all_graphs(self, skip_muscle_length, skip_moment_arm, skip_passive_fo self.__update_specific_plot(self.canvas_moment_arm, self.ax_moment_arm, x_axis, moment_arm, skip_moment_arm) self.__update_specific_plot( - self.canvas_passive_forces, self.ax_passive_forces, x_axis, passive_forces, skip_passive_forces + self.canvas_passive_forces, + self.ax_passive_forces, + x_axis, + passive_forces, + skip_passive_forces, + autoscale_y=False, ) self.__update_specific_plot( - self.canvas_active_forces, self.ax_active_forces, x_axis, active_forces, skip_active_forces + self.canvas_active_forces, + self.ax_active_forces, + x_axis, + active_forces, + skip_active_forces, + autoscale_y=False, ) self.__update_graph_size() @@ -216,11 +228,11 @@ def __compute_all_values(self): if mus.type() != biorbd.IDEALIZED_ACTUATOR: active_forces[i, m] = biorbd.HillType(mus).FlCE(emg) else: - active_forces[i, m] = 0 + active_forces[i, m] = emg.activation() return x_axis, length, moment_arm, passive_forces, active_forces - def __update_specific_plot(self, canvas, ax, x, y, skip=False): + def __update_specific_plot(self, canvas, ax, x, y, skip=False, autoscale_y=True): # Plot all active muscles number_of_active = 0 for m in range(self.n_mus): @@ -237,8 +249,12 @@ def __update_specific_plot(self, canvas, ax, x, y, skip=False): # If there is no data skip relim and vertical bar adjustment if number_of_active != 0: # relim so the plot looks nice + if not autoscale_y: + y_lim = ax.get_ylim() ax.relim() ax.autoscale(enable=True) + if not autoscale_y: + ax.set_ylim(y_lim) # Adjust axis label (give a generic name) if self.animation_checkbox.isChecked(): From 64c467322c3af0f62dd55256a702d7a7e85694a9 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Tue, 2 Apr 2024 17:21:23 -0400 Subject: [PATCH 2/4] Fixed allGlobalJCS --- bioviz/interfaces_collection.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bioviz/interfaces_collection.py b/bioviz/interfaces_collection.py index c6b8419..5099701 100644 --- a/bioviz/interfaces_collection.py +++ b/bioviz/interfaces_collection.py @@ -281,10 +281,7 @@ def _prepare_function_for_casadi(self): def _get_data_from_eigen(self, Q=None, compute_kin=True): self.data = [] - if compute_kin: - allJCS = self.m.allGlobalJCS(Q) - else: - allJCS = self.m.allGlobalJCS() + allJCS = self.m.allGlobalJCS(Q, compute_kin) for jcs in allJCS: self.data.append(jcs.to_array()) From 05c17de18879518b048a97ffe8ba0c145d4e9b53 Mon Sep 17 00:00:00 2001 From: Pariterre Date: Wed, 3 Apr 2024 10:32:16 -0400 Subject: [PATCH 3/4] Fixed mamba --- .github/workflows/run_tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 9a03572..50f3560 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -34,7 +34,6 @@ jobs: - name: Print mamba info run: | - mamba config --show mamba info mamba list From 1167f5c662a3c8b2ab131136f18b387cd81c1c8f Mon Sep 17 00:00:00 2001 From: Pariterre Date: Wed, 3 Apr 2024 10:35:29 -0400 Subject: [PATCH 4/4] Blacked --- .vscode/settings.json | 13 +++++++++++++ bioviz/biorbd_vtk.py | 1 + 2 files changed, 14 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..8db5695 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,13 @@ +{ + "python.testing.pytestArgs": ["tests"], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true, + "python.analysis.extraPaths": ["./external/pyScienceMode"], + "python.envFile": "${workspaceFolder}/.vscode/.env", + "[python]": { + "editor.defaultFormatter": "ms-python.black-formatter", + "editor.formatOnSave": true, + "editor.rulers": [120] + }, + "cmake.configureOnOpen": false +} \ No newline at end of file diff --git a/bioviz/biorbd_vtk.py b/bioviz/biorbd_vtk.py index 512a25e..c0695d8 100644 --- a/bioviz/biorbd_vtk.py +++ b/bioviz/biorbd_vtk.py @@ -1,6 +1,7 @@ """ Visualization toolkit in pyomeca """ + from dataclasses import dataclass import os import time