diff options
Diffstat (limited to 'src/argaze.test/GazeAnalysis/DispersionThresholdIdentification.py')
-rw-r--r-- | src/argaze.test/GazeAnalysis/DispersionThresholdIdentification.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/argaze.test/GazeAnalysis/DispersionThresholdIdentification.py b/src/argaze.test/GazeAnalysis/DispersionThresholdIdentification.py index 712308a..eba80c8 100644 --- a/src/argaze.test/GazeAnalysis/DispersionThresholdIdentification.py +++ b/src/argaze.test/GazeAnalysis/DispersionThresholdIdentification.py @@ -311,6 +311,42 @@ class TestDispersionThresholdIdentificationClass(unittest.TestCase): self.assertGreaterEqual(fixation.duration, 2 * size * min_time) self.assertLessEqual(fixation.duration, 2 * size * max_time) + def test_identification_generator(self): + """Test DispersionThresholdIdentification identification using generator.""" + + size = 10 + center_A = (0, 0) + center_B = (50, 50) + deviation_max = 10 + min_time = 0.01 + max_time = 0.1 + + 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 = DispersionThresholdIdentification.GazeMovementIdentifier(deviation_max_threshold=deviation_max, duration_min_threshold=max_time*2) + + fixation_count = 0 + + for ts, gaze_movement in gaze_movement_identifier(ts_gaze_positions): + + if GazeFeatures.is_fixation(gaze_movement): + + self.assertEqual(len(gaze_movement.positions.keys()), size-fixation_count) + self.assertLessEqual(gaze_movement.deviation_max, deviation_max) + self.assertGreaterEqual(gaze_movement.duration, size * min_time) + self.assertLessEqual(gaze_movement.duration, size * max_time) + + fixation_count += 1 + + elif GazeFeatures.is_saccade(gaze_movement): + + self.assertEqual(len(gaze_movement.positions.keys()), 1) + self.assertGreaterEqual(gaze_movement.duration, 0.) + self.assertLessEqual(gaze_movement.duration, 0.) + if __name__ == '__main__': unittest.main()
\ No newline at end of file |