def test_nexus_reader(): """Test basic data reading and Trial instance creation""" start_nexus() vicon = nexus.viconnexus() # from old Helsinki lab trialname = '2015_10_22_girl6v_IN13' subject = 'girl6v' trialpath = _trial_path(subject, trialname) nexus._open_trial(trialpath) tr = Trial(vicon) # XXX: probably with pytest, there is no benefit in using assert_equal assert_equal(tr.analograte, 1000.0) assert_equal(tr.framerate, 100.0) # assert_equal(tr.bodymass, 24.0) assert_equal(tr.subject_name, 'Iiris') assert_equal(tr.n_forceplates, 1) assert_equal(tr.samplesperframe, 10.0) assert_equal(tr.length, 488) assert_equal(tr.trialname, trialname) assert_equal(tr.ncycles, 5) assert_equal(tr.offset, 1) cycs = tr.get_cycles({'R': 'all'}) cyc = cycs[1] assert_equal(cyc.start, 230) assert_equal(cyc.end, 321) assert_equal(cyc.context, 'R') assert_equal(cyc.on_forceplate, True) assert_equal(cyc.toeoff, 282) cyc = cycs[0] assert_equal(cyc.start, 145) assert_equal(cyc.context, 'R') assert_equal(cyc.on_forceplate, False) # from Trondheim trialname = 'astrid_080515_02' subject = 'adult_3fp' trialpath = _trial_path(subject, trialname) nexus._open_trial(trialpath) tr = Trial(vicon) assert_equal(tr.analograte, 1000.0) assert_equal(tr.framerate, 200.0) # assert_equal(tr.bodymass, 70.0) assert_equal(tr.subject_name, 'Astrid') assert_equal(tr.n_forceplates, 3) assert_equal(tr.samplesperframe, 5.0) assert_equal(tr.length, 1986) assert_equal(tr.trialname, trialname) assert_equal(tr.ncycles, 4) assert_equal(tr.offset, 1) cycs = tr.get_cycles({'L': 'all'}) cyc = cycs[1] assert_equal(cyc.start, 1161) assert_equal(cyc.end, 1387) assert_equal(cyc.context, 'L') assert_equal(cyc.on_forceplate, True) assert_equal(cyc.toeoff, 1303)
def test_get_cycles(): """Test cycle getter""" c3dfile = _trial_path('girl6v', '2015_10_22_girl6v_IN02.c3d') tr = Trial(c3dfile) cycs = tr.get_cycles('forceplate') assert len(cycs) == 1 assert cycs[0].on_forceplate cycs = tr.get_cycles('all') assert len(cycs) == 4 cycs = tr.get_cycles('all', max_cycles_per_context=1) assert len(cycs) == 2