Exemplo n.º 1
0
def test_read_markers(
    usecols,
    shape_val,
    first_last_val,
    mean_val,
    median_val,
    sum_val,
    nans_val,
    extension,
):
    if extension == "csv":
        data = Markers.from_csv(**markers_csv_kwargs, usecols=usecols)
        decimal = 0
    elif extension == "c3d":
        data = Markers.from_c3d(MARKERS_ANALOGS_C3D,
                                prefix_delimiter=":",
                                usecols=usecols)
        decimal = 4
    else:
        raise ValueError("wrong extension provided")

    if usecols and isinstance(usecols[0], str):
        np.testing.assert_array_equal(x=data.channel, y=usecols)

    is_expected_array(
        data,
        shape_val,
        first_last_val,
        mean_val,
        median_val,
        sum_val,
        nans_val,
        decimal=decimal,
    )
Exemplo n.º 2
0
    DATA_FOLDER = Path("tests") / "data"

MARKERS_CSV = DATA_FOLDER / "markers.csv"
MARKERS_ANALOGS_C3D = DATA_FOLDER / "markers_analogs.c3d"
ANALOGS_CSV = DATA_FOLDER / "analogs.csv"
MARKERS_CSV_WITHOUT_HEADER = DATA_FOLDER / "markers_without_header.csv"
MARKERS_XLSX = DATA_FOLDER / "markers.xlsx"
MARKERS_TRC = DATA_FOLDER / "markers.trc"
ANALOGS_XLSX = DATA_FOLDER / "analogs.xlsx"
ANALOGS_STO = DATA_FOLDER / "inverse_dyn.sto"
ANALOGS_MOT = DATA_FOLDER / "inverse_kin.mot"
EXPECTED_VALUES_CSV = DATA_FOLDER / "is_expected_array_val.csv"

MARKERS_DATA = Markers.from_c3d(
    MARKERS_ANALOGS_C3D,
    usecols=["CLAV_post", "PSISl", "STERr", "CLAV_post"],
    prefix_delimiter=":",
)
ANALOGS_DATA = Analogs.from_c3d(
    MARKERS_ANALOGS_C3D,
    usecols=["EMG1", "EMG10", "EMG11", "EMG12"],
    prefix_delimiter=".",
)

EXPECTED_VALUES = pd.read_csv(
    EXPECTED_VALUES_CSV,
    index_col=[0],
    converters={
        "shape_val": eval,
        "first_last_val": eval
    },
# --- Markers --- #
markers_full_names = [
    "XIPH", "STER", "STERback", "CLAV_SC", "CLAV_AC", "SCAP_CP", "SCAP_AA",
    "SCAP_TS", "SCAP_IA", "DELT", "ARMl", "EPICl", "EPICm", "LARM_ant",
    "LARM_post", "LARM_elb", "LARM_dist"
]

# markers_full_names = ["ASISr","PSISr", "PSISl","ASISl","XIPH","STER","STERlat","STERback","XIPHback","ThL",
#            "CLAV_SC","CLAV_AC","SCAP_CP","SCAP_AA","SCAPspine","SCAP_TS","SCAP_IA","DELT","ARMl",
#            "EPICl","EPICm","LARM_ant","LARM_post","LARM_elb","LARM_dist","STYLrad","STYLrad_up","STYLulna_up",
#            "STYLulna","META2dist","META2prox","META5prox","META5dist","MAIN_opp"]
# markers_full_names = ["CLAV_SC","CLAV_AC","SCAP_CP","SCAP_AA","SCAP_TS","SCAP_IA","DELT","ARMl","EPICl",
#            "EPICm","LARM_ant","LARM_post","LARM_elb","LARM_dist"]

markers_full = Markers.from_c3d(data_path, usecols=markers_full_names)
marker_rate = int(markers_full.rate)
marker_exp = markers_full[:, :, :].data * 1e-3
n_mark = marker_exp.shape[1]
# t = 0.24
n_frames = marker_exp.shape[2]
t = markers_full.time.data
marker_treat = np.ndarray(
    (marker_exp.shape[0], marker_exp.shape[1], marker_exp.shape[2]))
for k in range(n_mark):
    a = pd.DataFrame(marker_exp[:, k, :])
    a = np.array(a.interpolate(method='polynomial', order=3, axis=1))
    marker_treat[:, k, :] = a
marker_treat[3, :, :] = [1]

plt.figure("Markers")
Exemplo n.º 4
0
# Rototrans_sym = RT(transX, transY, transZ, angleX, angleY, angleZ)
parent_dir_path = os.path.split(os.path.dirname(__file__))[0]
# biorbd_model = biorbd.Model(parent_dir_path +'/model_scaling/new_scal/Belaise_scaled_updated.bioMod')
biorbd_model = biorbd.Model(parent_dir_path +
                            '/models/arm_Belaise_real_v2.bioMod')
data = "flex"
data_path = f'./Sujet_5/{data}.c3d'

markers_names = [
    "CLAV_SC", "CLAV_AC", "SCAP_CP", "SCAP_AA", "SCAP_TS", "SCAP_IA", "DELT",
    "ARMl", "EPICl", "EPICm", "LARM_ant", "LARM_post", "LARM_elb", "LARM_dist"
]
# markers_names = ["XIPH", "STER", "CLAV_SC","CLAV_AC","SCAP_CP","SCAP_AA","SCAP_TS","SCAP_IA","DELT","ARMl","EPICl",
#            "EPICm","LARM_ant","LARM_post","LARM_elb","LARM_dist","STYLrad", "STYLulna"]

markers = Markers.from_c3d(data_path, usecols=markers_names)

mat_contents = sio.loadmat(f"{data}.mat")
mat_contents = mat_contents["mov_reel"]
val = mat_contents[0, 0]
integ = val['integ']
q = integ['Q_reel'][0, 0]
marker_exp = markers[:, :, :q.shape[1]].data * 1e-3
n_mark = len(markers_names)
n_q = q.shape[0]
t = integ['temps'][0, 0]  # 0.24s
n_frames = q.shape[1]

marker_model = np.ndarray((4, n_mark, n_frames))
symbolic_states = MX.sym("q", n_q, 1)
# markers_func = Function(
Exemplo n.º 5
0
from pathlib import Path

import numpy as np

from pyomeca import Markers, Rototrans, Angles
from bioviz.biorbd_vtk import VtkModel, VtkWindow, Mesh

# Path to data
DATA_FOLDER = Path(
    "/home/pariterre/Programmation/biorbd-viz") / "tests" / "data"
MARKERS_CSV = DATA_FOLDER / "markers.csv"
MARKERS_ANALOGS_C3D = DATA_FOLDER / "markers_analogs.c3d"

# Load data
d = Markers.from_c3d(MARKERS_ANALOGS_C3D,
                     usecols=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
                     prefix_delimiter=":")
d2 = Markers.from_c3d(MARKERS_ANALOGS_C3D,
                      usecols=["CLAV_post", "PSISl", "STERr", "CLAV_post"],
                      prefix_delimiter=":")
# mean of first 3 markers
d3 = Markers.from_c3d(MARKERS_ANALOGS_C3D,
                      usecols=[0, 1, 2],
                      prefix_delimiter=":").mean("channel", keepdims=True)

# Create a windows with a nice gray background
vtkWindow = VtkWindow(background_color=(0.5, 0.5, 0.5))

# Add marker holders to the window
vtkModelReal = VtkModel(vtkWindow,
                        markers_color=(1, 0, 0),