diff options
Diffstat (limited to 'src/argaze.test/GazeAnalysis')
-rw-r--r-- | src/argaze.test/GazeAnalysis/VelocityThresholdIdentification.py | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/src/argaze.test/GazeAnalysis/VelocityThresholdIdentification.py b/src/argaze.test/GazeAnalysis/VelocityThresholdIdentification.py index 239bf45..425d592 100644 --- a/src/argaze.test/GazeAnalysis/VelocityThresholdIdentification.py +++ b/src/argaze.test/GazeAnalysis/VelocityThresholdIdentification.py @@ -110,7 +110,7 @@ class TestVelocityThresholdIdentificationClass(unittest.TestCase): deviation_max = 10 min_time = 0.05 max_time = 0.1 - velocity_max = math.sqrt(2) * deviation_max / min_time + velocity_max = deviation_max / min_time ts_gaze_positions = build_gaze_fixation(size, center, deviation_max, min_time, max_time) gaze_movement_identifier = VelocityThresholdIdentification.GazeMovementIdentifier(velocity_max_threshold=velocity_max, duration_min_threshold=max_time*2) @@ -221,7 +221,7 @@ class TestVelocityThresholdIdentificationClass(unittest.TestCase): # Check first fixation ts, fixation = ts_fixations.pop_first() - self.assertEqual(len(fixation.positions.keys()), size - 1) + self.assertEqual(len(fixation.positions.keys()), size - 1) # BUG: NOT ALWAYS TRUE !!! self.assertGreaterEqual(fixation.duration, (size - 2) * min_time) self.assertLessEqual(fixation.duration, (size - 2) * max_time) self.assertLessEqual(fixation.finished, True) @@ -264,7 +264,7 @@ class TestVelocityThresholdIdentificationClass(unittest.TestCase): deviation_max = 10 min_time = 0.05 max_time = 0.1 - velocity_max = math.sqrt(2) * deviation_max / min_time + velocity_max = deviation_max / min_time validity = [True, True, True, True, True, True, True, False, False, False, True, True, True, True, True] ts_gaze_positions = build_gaze_fixation(size, center, deviation_max, min_time, max_time, validity=validity) @@ -293,6 +293,47 @@ class TestVelocityThresholdIdentificationClass(unittest.TestCase): self.assertLessEqual(fixation.duration, 3 * max_time) self.assertLessEqual(fixation.finished, True) + def test_identification_browsing(self): + """Test VelocityThresholdIdentification identification browsing.""" + + size = 10 + center_A = (0, 0) + center_B = (50, 50) + deviation_max = 10 + min_time = 0.01 + max_time = 0.1 + velocity_max = deviation_max / min_time + + ts_gaze_positions_A = build_gaze_fixation(size, center_A, deviation_max, min_time, max_time) + ts_gaze_positions_B = build_gaze_fixation(size, center_B, deviation_max, min_time, max_time, start_ts=ts_gaze_positions_A.last[0]) + + ts_gaze_positions = ts_gaze_positions_A.append(ts_gaze_positions_B) + + gaze_movement_identifier = VelocityThresholdIdentification.GazeMovementIdentifier(velocity_max_threshold=velocity_max, duration_min_threshold=max_time*2) + + # Get last ts to terminate identification on last gaze position + last_ts, _ = ts_gaze_positions.last + + # Iterate on gaze positions + for ts, gaze_position in ts_gaze_positions.items(): + + finished_gaze_movement = gaze_movement_identifier.identify(ts, gaze_position, terminate=(ts == last_ts)) + + # Check that last gaze position date is not equal to given gaze position date + if finished_gaze_movement.valid: + + last_ts, _ = finished_gaze_movement.positions.last + + self.assertNotEqual(last_ts, ts) + + # Check that last gaze position date of current movement is equal to given gaze position date + current_gaze_movement = gaze_movement_identifier.current_gaze_movement + if current_gaze_movement.valid: + + last_ts, _ = current_gaze_movement.positions.last + + self.assertEqual(last_ts, ts) + if __name__ == '__main__': unittest.main()
\ No newline at end of file |