Exemplo n.º 1
0
 def setup():
     it.r1 = Region(Point(1, 1), Point(2, 2), 1, "region 1")
     it.r2 = Region(Point(1, 1), Point(2, 2), 1, "region 2")
     it.r3 = Region(Point(1, 1), Point(2, 2), 1, "region 3")
     it.fix1 = Fixation(Point(1, 2), 3, 4, 0, "region")
     it.fix2 = Fixation(Point(1, 2), 5, 6, 1, "region")
     it.fixations = [
         Fixation(Point(1, 2), 10, 20, 0, "region"),
         Fixation(Point(2, 2), 30, 40, 1, "region"),
         Fixation(Point(3, 2), 50, 60, 2, "region"),
         Fixation(Point(4, 2), 70, 80, 3, "region", excluded=True),
         Fixation(Point(1, 2), 90, 100, 4, "region"),
         Fixation(Point(2, 2), 110, 120, 5, "region", excluded=True),
         Fixation(Point(3, 2), 130, 140, 6, "region", excluded=True),
         Fixation(Point(4, 2), 150, 160, 7, "region"),
         Fixation(Point(5, 2), 170, 180, 8, "region", excluded=True),
     ]
     it.item = Item(2, 1, [it.r1, it.r2, it.r3])
     it.trial = Trial(1, 5, it.item, it.fixations)
     it.trial_include_fixations = Trial(1,
                                        5,
                                        it.item,
                                        it.fixations,
                                        include_fixation=True)
     it.trial_include_saccades = Trial(1,
                                       5,
                                       it.item,
                                       it.fixations,
                                       include_saccades=True)
     it.trial_include_both = Trial(1,
                                   5,
                                   it.item,
                                   it.fixations,
                                   include_fixation=True,
                                   include_saccades=True)
Exemplo n.º 2
0
 def test_trial_equality():
     it.assertTrue(
         Trial(1, 5, it.item, it.fixations) == Trial(
             1, 5, it.item, it.fixations))
     it.assertTrue(
         Trial(1, 5, it.item, it.fixations) != Trial(
             1, 5, it.item, [it.fix1, it.fix2]))
Exemplo n.º 3
0
 def setup():
     it.r1 = Region(Point(1, 1), Point(2, 2), 1, "region 1")
     it.r2 = Region(Point(1, 1), Point(2, 2), 1, "region 2")
     it.r3 = Region(Point(1, 1), Point(2, 2), 1, "region 3")
     it.fix1 = Fixation(Point(1, 2), 3, 4, 0, "region")
     it.fix2 = Fixation(Point(1, 2), 5, 6, 1, "region")
     it.fix3 = Fixation(Point(1, 3), 8, 9, 2, "region")
     it.item = Item(1, 1, [it.r1, it.r2, it.r3])
     it.item2 = Item(2, 1, [it.r1, it.r3])
     it.trial = Trial(1, 4, it.item, [it.fix1, it.fix2, it.fix3])
     it.trial2 = Trial(2, 4, it.item2, [it.fix1, it.fix3])
     it.experiment = Experiment("ex1", [it.trial, it.trial2],
                                filename="ex1.da1")
Exemplo n.º 4
0
 def test_d0_d1():
     trial_1 = it.asc_header + "EFIX R 2000 2010 10 12 105 0" + it.asc_end
     trial_2 = """
     MSG 20000 SYNCTIME
     MSG 20000 TRIALID E1I1D1
     MSG 20001 REGION CHAR 1 1 A 10 100 20 110
     MSG 20002 REGION CHAR 1 1 a 20 100 30 110
     MSG 20003 REGION CHAR 1 1 a 30 100 40 110
     MSG 20004 REGION CHAR 1 1 a 40 100 50 110
     EFIX R 30000 30010 10 12 105 0
     MSG 40000 TRIAL_RESULT 7
     MSG 40001 TRIAL OK
     """
     parsed_experiment = parser.asc.get_trials(trial_1 + trial_2, it.items)
     it.assertEqual(len(parsed_experiment), 1)
     it.assertEqual(
         parsed_experiment[0],
         Trial(
             0,
             10000,
             it.items["1"]["1"],
             [
                 Fixation(Point(0, 0), 0, 10, 0,
                          it.items["1"]["1"].regions[0])
             ],
         ),
     )
Exemplo n.º 5
0
 def test_2_asc():
     trial_1 = it.asc_header + "EFIX R 2000 2010 10 12 105 0" + it.asc_end
     trial_2 = """
     MSG 20000 SYNCTIME
     MSG 20000 TRIALID E1I1D0
     MSG 20001 REGION CHAR 1 1 T 10 100 20 110
     MSG 20002 REGION CHAR 1 1 e 20 100 30 110
     MSG 20003 REGION CHAR 1 1 s 30 100 40 110
     MSG 20004 REGION CHAR 1 1 t 40 100 50 110
     MSG 20005 REGION CHAR 1 1   50 100 60 110
     MSG 20006 REGION CHAR 1 1 i 60 100 70 110
     MSG 20007 REGION CHAR 1 1 t 70 100 80 110
     MSG 20008 REGION CHAR 1 1 e 80 100 90 110
     MSG 20009 REGION CHAR 1 1 m 90 100 100 110
     EFIX R 30000 30010 10 12 105 0
     MSG 40000 TRIAL_RESULT 7
     MSG 40001 TRIAL OK
     """
     parsed_experiment = parser.asc.get_trials(trial_1 + trial_2, it.items)
     it.assertEqual(len(parsed_experiment), 2)
     it.assertEqual(
         parsed_experiment[0],
         Trial(
             0,
             10000,
             it.items["1"]["1"],
             [
                 Fixation(Point(0, 0), 0, 10, 0,
                          it.items["1"]["1"].regions[0])
             ],
         ),
     )
     it.assertEqual(
         parsed_experiment[1],
         Trial(
             1,
             20000,
             it.items["1"]["1"],
             [
                 Fixation(Point(0, 0), 0, 10, 0,
                          it.items["1"]["1"].regions[0])
             ],
         ),
     )
Exemplo n.º 6
0
 def test_da1():
     it.timdrop_fixations = [
         Fixation(
             Point(-1, -1),
             0,
             170,
             0,
             Region(Point(0, 0), Point(20, 0), label=0, number=0),
         ),
         Fixation(
             Point(7, 0),
             195,
             587,
             1,
             Region(Point(0, 0), Point(20, 0), label=0, number=0),
         ),
         Fixation(
             Point(24, 0),
             627,
             841,
             2,
             Region(Point(20, 0), Point(26, 0), label=1, number=1),
         ),
         Fixation(
             Point(46, 0),
             892,
             1157,
             3,
             Region(Point(38, 0), Point(75, 0), label=4, number=4),
         ),
         Fixation(
             Point(58, 0),
             1184,
             1424,
             4,
             Region(Point(38, 0), Point(75, 0), label=4, number=4),
         ),
         Fixation(
             Point(70, 0),
             1452,
             1779,
             5,
             Region(Point(38, 0), Point(75, 0), label=4, number=4),
         ),
     ]
     it.trial1 = Trial(1, 1779, it.timdrop_items["286"]["2"],
                       it.timdrop_fixations)
     it.assertEqual(it.timdrop_DA1.trials[("286", "2")], it.trial1)
Exemplo n.º 7
0
 def test_asc():
     fixation = "EFIX R 2000 2010 10 12 105 0"
     parsed_experiment = parser.asc.get_trials(
         it.asc_header + fixation + it.asc_end, it.items)
     it.assertEqual(len(parsed_experiment), 1)
     it.assertEqual(
         parsed_experiment[0],
         Trial(
             0,
             10000,
             it.items["1"]["1"],
             [
                 Fixation(Point(0, 0), 0, 10, 0,
                          it.items["1"]["1"].regions[0])
             ],
         ),
     )
Exemplo n.º 8
0
 def test_multifix_da1():
     fixation = "EFIX R 2000 2010 10 12 105 0\nEFIX R 2010 2030 20 72 105 0"
     parsed_experiment = parser.asc.get_trials(
         it.asc_header + fixation + it.asc_end, it.items)
     it.assertEqual(
         parsed_experiment[0],
         Trial(
             0,
             10000,
             it.items["1"]["1"],
             [
                 Fixation(Point(0, 0), 0, 10, 0,
                          it.items["1"]["1"].regions[0]),
                 Fixation(Point(6, 0), 10, 30, 1,
                          it.items["1"]["1"].regions[1]),
             ],
         ),
     )
Exemplo n.º 9
0
 def test_fix_before_synctime():
     fixations = """
     MSG 1000 TRIALID E1I1D0
     MSG 1001 REGION CHAR 1 1 T 10 100 20 110
     MSG 1002 REGION CHAR 1 1 e 20 100 30 110
     MSG 1003 REGION CHAR 1 1 s 30 100 40 110
     MSG 1004 REGION CHAR 1 1 t 40 100 50 110
     MSG 1005 REGION CHAR 1 1   50 100 60 110
     MSG 1006 REGION CHAR 1 1 i 60 100 70 110
     MSG 1007 REGION CHAR 1 1 t 70 100 80 110
     MSG 1008 REGION CHAR 1 1 e 80 100 90 110
     MSG 1009 REGION CHAR 1 1 m 90 100 100 110
     EFIX R 2000 2005 5 12 105 0
     MSG 2001 SYNCTIME
     EFIX R 2005 2020 15 33 105 0
     """
     parsed_experiment = parser.asc.get_trials(
         fixations + it.asc_end,
         it.items,
         config.ASCParsingConfig({
             "blink_max_dur": False,
             "blink_max_count": False,
             "max_saccade_dur": False,
             "fixation_min_cutoff": 10,
         }),
     )
     it.assertEqual(
         parsed_experiment[0],
         Trial(
             0,
             8000,
             it.items["1"]["1"],
             [
                 Fixation(Point(2, 0), 0, 15, 0,
                          it.items["1"]["1"].regions[0])
             ],
         ),
     )
Exemplo n.º 10
0
 def test_first_fix_merge():
     fixations = "EFIX R 2000 2005 5 12 105 0\nEFIX R 2005 2020 15 33 105 0"
     parsed_experiment = parser.asc.get_trials(
         it.asc_header + fixations + it.asc_end,
         it.items,
         config.ASCParsingConfig({
             "blink_max_dur": False,
             "blink_max_count": False,
             "max_saccade_dur": False,
             "fixation_min_cutoff": 10,
         }),
     )
     it.assertEqual(
         parsed_experiment[0],
         Trial(
             0,
             10000,
             it.items["1"]["1"],
             [
                 Fixation(Point(2, 0), 0, 20, 0,
                          it.items["1"]["1"].regions[0])
             ],
         ),
     )
Exemplo n.º 11
0
 def test_short_blinks():
     fixation = "EFIX R 2000 2010 10 12 105 0\nEBLINK R 2010 2015 5"
     parsed_experiment = parser.asc.get_trials(
         it.asc_header + fixation + it.asc_end,
         it.items,
         config.ASCParsingConfig({
             "blink_max_dur": 20,
             "blink_max_count": False,
             "max_saccade_dur": False,
             "fixation_min_cutoff": False,
         }),
     )
     it.assertEqual(
         parsed_experiment[0],
         Trial(
             0,
             10000,
             it.items["1"]["1"],
             [
                 Fixation(Point(0, 0), 0, 10, 0,
                          it.items["1"]["1"].regions[0])
             ],
         ),
     )
Exemplo n.º 12
0
 def test_da1_robodoc():
     it.robodoc_fixations = [
         Fixation(
             Point(6, 0),
             1241,
             1410,
             0,
             Region(Point(0, 0), Point(17, 0), label=0, number=0),
         ),
         Fixation(
             Point(4, 0),
             1429,
             1796,
             1,
             Region(Point(0, 0), Point(17, 0), label=0, number=0),
         ),
         Fixation(
             Point(16, 0),
             1822,
             2223,
             2,
             Region(Point(0, 0), Point(17, 0), label=0, number=0),
         ),
         Fixation(
             Point(6, 0),
             2245,
             2471,
             3,
             Region(Point(0, 0), Point(17, 0), label=0, number=0),
         ),
         Fixation(
             Point(24, 0),
             2504,
             3232,
             4,
             Region(Point(17, 0), Point(29, 0), label=1, number=1),
         ),
         Fixation(
             Point(32, 0),
             3262,
             3520,
             5,
             Region(Point(29, 0), Point(40, 0), label=2, number=2),
         ),
         Fixation(
             Point(39, 0),
             3552,
             3894,
             6,
             Region(Point(29, 0), Point(40, 0), label=2, number=2),
         ),
         Fixation(
             Point(44, 0),
             3924,
             4164,
             7,
             Region(Point(40, 0), Point(52, 0), label=3, number=3),
         ),
         Fixation(
             Point(55, 0),
             4189,
             4671,
             8,
             Region(Point(52, 0), Point(65, 0), label=4, number=4),
         ),
         Fixation(
             Point(49, 0),
             4696,
             4931,
             9,
             Region(Point(40, 0), Point(52, 0), label=3, number=3),
         ),
         Fixation(
             Point(69, 0),
             4959,
             5250,
             10,
             Region(Point(65, 0), Point(77, 0), label=5, number=5),
         ),
         Fixation(
             Point(65, 0),
             5271,
             5633,
             11,
             Region(Point(65, 0), Point(77, 0), label=5, number=5),
         ),
         Fixation(
             Point(72, 0),
             5656,
             5885,
             12,
             Region(Point(65, 0), Point(77, 0), label=5, number=5),
         ),
         Fixation(
             Point(81, 0),
             5910,
             6278,
             13,
             Region(Point(77, 0), Point(95, 0), label=6, number=6),
         ),
         Fixation(
             Point(87, 0),
             6300,
             6625,
             14,
             Region(Point(77, 0), Point(95, 0), label=6, number=6),
         ),
         Fixation(
             Point(81, 0),
             6647,
             6851,
             15,
             Region(Point(77, 0), Point(95, 0), label=6, number=6),
         ),
         Fixation(
             Point(78, 0),
             6873,
             7231,
             16,
             Region(Point(77, 0), Point(95, 0), label=6, number=6),
         ),
         Fixation(
             Point(87, 0),
             7256,
             7768,
             17,
             Region(Point(77, 0), Point(95, 0), label=6, number=6),
         ),
     ]
     it.trial7 = Trial(7, 7792, it.robodoc_items["58"]["12"],
                       it.robodoc_fixations)
     it.assertEqual(it.robodoc_DA1.trials[("58", "12")], it.trial7)
Exemplo n.º 13
0
 def test_trial_index():
     with it.assertRaises(ValueError):
         Trial(-1, 5, it.item, it.fixations)
Exemplo n.º 14
0
 def test_trial_validation():
     with it.assertRaises(ValueError):
         Trial(1, 5, None, it.fixations)