def test_c3d_analysis_data(): """Test analysis var reads from c3d""" c3dfile = _c3d_path('double_contact.c3d') an_ = read_data.get_analysis(c3dfile, 'c3dtest') assert 'c3dtest' in an_ an = an_['c3dtest'] an_vars = [ 'Stride Time', 'Opposite Foot Off', 'Double Support', 'Step Time', 'Single Support', 'Step Length', 'Foot Off', 'Walking Speed', 'Stride Length', 'Opposite Foot Contact', 'Cadence', ] assert all([var in an for var in an_vars]) assert all(['Left' in an[var] for var in an_vars]) assert all(['Right' in an[var] for var in an_vars]) an_file = _file_path('analysis_testdata.p') an_g = pickle.load(open(an_file, 'rb')) for var in an_vars: for context in ['Left', 'Right']: assert_allclose(an_g['unknown'][var][context], an[var][context])
def test_c3d_marker_data(): """Test marker data reads from c3d""" # lowerbody PiG marker set c3dfile = _c3d_path('double_contact.c3d') mkrset = list(utils._pig_markerset().keys()) mkrdata = read_data.get_marker_data(c3dfile, mkrset) assert utils.is_plugingait_set(mkrdata) assert len(mkrdata) == 5 * len(mkrset) # vars = P*2, V, A & gaps # check array dimensions for all markers (gap data has different dims) for mkr in mkrdata: if '_gaps' not in mkr: assert mkrdata[mkr].shape == (442, 3) # LHEE gaps from 360 to 388 assert_equal(mkrdata['LHEE_gaps'], np.arange(360, 389)) lhee_file = _file_path('lhee_data.npy') lhee_data = np.load(lhee_file) # allow some deviation from saved reference data (was read using btk) assert_allclose(mkrdata['LHEE'], lhee_data, rtol=1e-4)
import pytest import numpy as np import logging import tempfile import os import os.path as op from gaitutils.report import pdf, web from utils import _file_path, cfg logger = logging.getLogger(__name__) # test session sessiondir_ = 'test_subjects/D0063_RR/2018_12_17_preOp_RR' sessiondir_abs = _file_path(sessiondir_) sessiondir2_ = 'test_subjects/D0063_RR/2018_12_17_preOp_tuet_RR' sessiondir2_abs = _file_path(sessiondir2_) sessiondir__ = op.split(sessiondir_)[-1] tmpdir = tempfile.gettempdir() def test_pdf_report(): """Test creation of pdf report + time-distance text report""" pdfname = sessiondir__ + '.pdf' pdfpath = op.join(tmpdir, pdfname) timedist_name = sessiondir__ + '_time_distance.txt' timedist_path = op.join(tmpdir, timedist_name) if op.isfile(pdfpath): os.remove(pdfpath) if op.isfile(timedist_path):
import logging import pytest from numpy.testing import assert_allclose from gaitutils.utils import ( is_plugingait_set, _point_in_poly, _pig_markerset, _check_markers_flipped, marker_gaps, ) from utils import _file_path logger = logging.getLogger(__name__) trial_enf = _file_path('anon.Trial.enf') trial_enf_write = _file_path('writetest.enf') def test_marker_gaps(): """Test marker_gaps""" mdata = np.random.randn(1000, 3) assert not marker_gaps(mdata) mdata[100:200, :] = 0 gaps = marker_gaps(mdata) assert_allclose(gaps, np.arange(100, 200)) mdata[0, :] = 0 gaps = marker_gaps(mdata) assert 0 not in gaps gaps = marker_gaps(mdata, ignore_edge_gaps=False) assert 0 in gaps
""" Normaldata unit tests @author: jussi ([email protected]) """ from numpy.testing import assert_allclose import logging from gaitutils import normaldata, models from utils import _file_path logger = logging.getLogger(__name__) fn_xlsx = _file_path('normaldata.xlsx') def test_read_xlsx_normaldata(): """Test read of default xlsx normaldata""" ndata = normaldata._read_xlsx(fn_xlsx) normaldata._check_normaldata(ndata) ndata_vars = ndata.keys() pigvars = models.pig_lowerbody.varlabels_nocontext.keys() # no normaldata for following vars not_in_normal = { 'AnkleAnglesY', 'ForeFootAnglesX', 'ForeFootAnglesY', 'ForeFootAnglesZ', }
@author: Jussi ([email protected]) """ import logging import tempfile from gaitutils import videos, sessionutils import time from utils import _file_path, cfg logger = logging.getLogger(__name__) # test session sessiondir_ = 'test_subjects/D0063_RR/2018_12_17_preOp_RR' # rel path sessiondir_abs = _file_path(sessiondir_) # absolute path tmpdir = tempfile.gettempdir() def test_convert_videos(): c3d_file = sessionutils.get_c3ds( sessiondir_abs, tags=None, trial_type='dynamic', check_if_exists=False )[0] original_vids = videos.get_trial_videos(c3d_file, vid_ext='.avi', overlay=False) assert len(original_vids) == 3 target_vids = videos.get_trial_videos(c3d_file, vid_ext='.ogv', overlay=False) # remove target videos if they exist for vidfile in target_vids: vidfile.unlink() # check should not find target videos any more assert not videos.convert_videos(original_vids, check_only=True)