Пример #1
0
def test_markers(idx, names, expected_shape, expected_values, extension):
    """Assert markers shape."""
    if extension == "csv":
        arr = Markers3d.from_csv(
            MARKERS_CSV,
            first_row=5,
            first_column=2,
            header=2,
            prefix=":",
            idx=idx,
            names=names,
        )
    elif extension == "xlsx":
        arr = Markers3d.from_excel(
            MARKERS_XLSX,
            sheet_name=0,
            first_row=5,
            first_column=2,
            header=2,
            prefix=":",
            idx=idx,
            names=names,
        )
    elif extension == "c3d":
        arr = Markers3d.from_c3d(MARKERS_ANALOGS_C3D,
                                 prefix=":",
                                 idx=idx,
                                 names=names)

    else:
        raise ValueError(
            f'extension should be "csv", "c3d" or "xlsx". You provided {extension}'
        )
    # test shape
    np.testing.assert_equal(arr.shape, expected_shape)
    # test values
    d = arr[:, 0, int(arr.shape[2] / 2)]
    np.testing.assert_almost_equal(d, expected_values, decimal=2)
Пример #2
0
"""
Example script for file IO
"""

from pathlib import Path

from pyomeca import Markers3d, Analogs3d

# Path to data
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'

# read 11 first markers of a csv file
markers_1 = Markers3d.from_csv(MARKERS_CSV, first_row=5, first_column=2, header=2,
                               idx=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], prefix=':')

# mean of 1st and 4th markers of a csv file
markers_2 = Markers3d.from_csv(MARKERS_CSV, first_row=5, first_column=2, header=2,
                               idx=[[0, 1, 2], [0, 4, 2]], prefix=':')

# get markers by names in a csv file
markers_3 = Markers3d.from_csv(MARKERS_CSV, first_row=5, first_column=2, header=2,
                               names=['CLAV_post', 'PSISl', 'STERr', 'CLAV_post'], prefix=':')

# write a csv file from a Markers3d types
markers_3.to_csv('../Misc/mtest.csv', header=False)

# read 4 first markers of a c3d file
markers_4 = Markers3d.from_c3d(MARKERS_ANALOGS_C3D, idx=[0, 1, 2, 3])
Пример #3
0
from pathlib import Path

from pyomeca import Markers3d, Analogs3d

# Path to data
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"

# read 11 first markers of a csv file
markers_1 = Markers3d.from_csv(
    MARKERS_CSV,
    first_row=5,
    first_column=2,
    header=2,
    idx=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
    prefix=":",
)

# mean of 1st and 4th markers of a csv file
markers_2 = Markers3d.from_csv(
    MARKERS_CSV,
    first_row=5,
    first_column=2,
    header=2,
    idx=[[0, 1, 2], [0, 4, 2]],
    prefix=":",
)

# get markers by names in a csv file