Esempio n. 1
0
    def testExistingSettingsFile(self):
        gui_mock = pgm.PsychoPyGuiMock()
        gui_mock.addFieldValues(
            ['Tóth Béla', 10, 'kontrol', 'nő', 30, '3rd', '2nd', 'Tóth Béla', 10, 'kontrol'])

        thispath = self.constructFilePath("NoSettingsFile")
        experiment = asrt.Experiment(thispath)
        experiment.settings = asrt.ExperimentSettings("", "")
        experiment.settings.groups = ["kontrol", "exp1"]
        experiment.settings.numsessions = 2
        experiment.settings.epochN = 2
        experiment.settings.epochs = [1, 1]
        experiment.settings.block_in_epochN = 2
        experiment.settings.blockprepN = 5
        experiment.settings.blocklengthN = 20
        experiment.settings.asrt_rcolor = "Orange"
        experiment.settings.asrt_pcolor = "Green"
        experiment.settings.asrt_types = {}
        experiment.settings.asrt_types[1] = "implicit"
        experiment.settings.asrt_types[2] = "implicit"

        asrt.ensure_dir(os.path.join(thispath, "settings"))

        # call once to get the participant settings
        experiment.participant_id()

        # let save participant settings after the first block
        experiment.last_N = 25
        experiment.person_data.save_person_settings(experiment)

        experiment.settings = asrt.ExperimentSettings("", "")
        experiment.settings.groups = ["kontrol", "exp1"]
        experiment.settings.epochN = 2
        experiment.settings.block_in_epochN = 2
        experiment.settings.blockprepN = 5
        experiment.settings.blocklengthN = 20

        # now load back the participant's settings with participant id function
        experiment.participant_id()

        self.assertEqual(experiment.subject_group, 'kontrol')
        self.assertEqual(experiment.subject_number, 10)
        self.assertEqual(experiment.subject_name, "toth-bela")
        self.assertEqual(experiment.PCodes, {1: '3rd - 1324', 2: '2nd - 1243'})
        self.assertEqual(experiment.stim_output_line, 0)
        self.assertEqual(experiment.stim_sessionN, {1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1, 12: 1, 13: 1, 14: 1, 15: 1, 16: 1, 17: 1, 18: 1, 19: 1, 20: 1, 21: 1, 22: 1, 23: 1, 24: 1, 25: 1, 26: 1, 27: 1, 28: 1, 29: 1, 30: 1, 31: 1, 32: 1, 33: 1, 34: 1, 35: 1, 36: 1, 37: 1, 38: 1, 39: 1, 40: 1, 41: 1, 42: 1, 43: 1, 44: 1, 45: 1, 46: 1, 47: 1, 48: 1,
                                                    49: 1, 50: 1, 51: 2, 52: 2, 53: 2, 54: 2, 55: 2, 56: 2, 57: 2, 58: 2, 59: 2, 60: 2, 61: 2, 62: 2, 63: 2, 64: 2, 65: 2, 66: 2, 67: 2, 68: 2, 69: 2, 70: 2, 71: 2, 72: 2, 73: 2, 74: 2, 75: 2, 76: 2, 77: 2, 78: 2, 79: 2, 80: 2, 81: 2, 82: 2, 83: 2, 84: 2, 85: 2, 86: 2, 87: 2, 88: 2, 89: 2, 90: 2, 91: 2, 92: 2, 93: 2, 94: 2, 95: 2, 96: 2, 97: 2, 98: 2, 99: 2, 100: 2})
        self.assertEqual(experiment.stimepoch, {1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1, 12: 1, 13: 1, 14: 1, 15: 1, 16: 1, 17: 1, 18: 1, 19: 1, 20: 1, 21: 1, 22: 1, 23: 1, 24: 1, 25: 1, 26: 1, 27: 1, 28: 1, 29: 1, 30: 1, 31: 1, 32: 1, 33: 1, 34: 1, 35: 1, 36: 1, 37: 1, 38: 1, 39: 1, 40: 1, 41: 1, 42: 1, 43: 1, 44: 1, 45: 1, 46: 1, 47: 1, 48: 1,
                                                49: 1, 50: 1, 51: 2, 52: 2, 53: 2, 54: 2, 55: 2, 56: 2, 57: 2, 58: 2, 59: 2, 60: 2, 61: 2, 62: 2, 63: 2, 64: 2, 65: 2, 66: 2, 67: 2, 68: 2, 69: 2, 70: 2, 71: 2, 72: 2, 73: 2, 74: 2, 75: 2, 76: 2, 77: 2, 78: 2, 79: 2, 80: 2, 81: 2, 82: 2, 83: 2, 84: 2, 85: 2, 86: 2, 87: 2, 88: 2, 89: 2, 90: 2, 91: 2, 92: 2, 93: 2, 94: 2, 95: 2, 96: 2, 97: 2, 98: 2, 99: 2, 100: 2})
        self.assertEqual(experiment.stimblock, {1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1, 12: 1, 13: 1, 14: 1, 15: 1, 16: 1, 17: 1, 18: 1, 19: 1, 20: 1, 21: 1, 22: 1, 23: 1, 24: 1, 25: 1, 26: 2, 27: 2, 28: 2, 29: 2, 30: 2, 31: 2, 32: 2, 33: 2, 34: 2, 35: 2, 36: 2, 37: 2, 38: 2, 39: 2, 40: 2, 41: 2, 42: 2, 43: 2, 44: 2, 45: 2, 46: 2, 47: 2, 48: 2,
                                                49: 2, 50: 2, 51: 3, 52: 3, 53: 3, 54: 3, 55: 3, 56: 3, 57: 3, 58: 3, 59: 3, 60: 3, 61: 3, 62: 3, 63: 3, 64: 3, 65: 3, 66: 3, 67: 3, 68: 3, 69: 3, 70: 3, 71: 3, 72: 3, 73: 3, 74: 3, 75: 3, 76: 4, 77: 4, 78: 4, 79: 4, 80: 4, 81: 4, 82: 4, 83: 4, 84: 4, 85: 4, 86: 4, 87: 4, 88: 4, 89: 4, 90: 4, 91: 4, 92: 4, 93: 4, 94: 4, 95: 4, 96: 4, 97: 4, 98: 4, 99: 4, 100: 4})
        self.assertEqual(experiment.stimtrial, {1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12, 13: 13, 14: 14, 15: 15, 16: 16, 17: 17, 18: 18, 19: 19, 20: 20, 21: 21, 22: 22, 23: 23, 24: 24, 25: 25, 26: 1, 27: 2, 28: 3, 29: 4, 30: 5, 31: 6, 32: 7, 33: 8, 34: 9, 35: 10, 36: 11, 37: 12, 38: 13, 39: 14, 40: 15, 41: 16, 42: 17, 43: 18, 44: 19, 45: 20, 46: 21, 47: 22, 48: 23,
                                                49: 24, 50: 25, 51: 1, 52: 2, 53: 3, 54: 4, 55: 5, 56: 6, 57: 7, 58: 8, 59: 9, 60: 10, 61: 11, 62: 12, 63: 13, 64: 14, 65: 15, 66: 16, 67: 17, 68: 18, 69: 19, 70: 20, 71: 21, 72: 22, 73: 23, 74: 24, 75: 25, 76: 1, 77: 2, 78: 3, 79: 4, 80: 5, 81: 6, 82: 7, 83: 8, 84: 9, 85: 10, 86: 11, 87: 12, 88: 13, 89: 14, 90: 15, 91: 16, 92: 17, 93: 18, 94: 19, 95: 20, 96: 21, 97: 22, 98: 23, 99: 24, 100: 25})
        self.assertEqual(len(experiment.stimlist), 100)
        self.assertEqual(experiment.last_N, 25)
        self.assertEqual(experiment.end_at, {1: 51, 2: 51, 3: 51, 4: 51, 5: 51, 6: 51, 7: 51, 8: 51, 9: 51, 10: 51, 11: 51, 12: 51, 13: 51, 14: 51, 15: 51, 16: 51, 17: 51, 18: 51, 19: 51, 20: 51, 21: 51, 22: 51, 23: 51, 24: 51, 25: 51, 26: 51, 27: 51, 28: 51, 29: 51, 30: 51, 31: 51, 32: 51, 33: 51, 34: 51, 35: 51, 36: 51, 37: 51, 38: 51, 39: 51, 40: 51, 41: 51, 42: 51, 43: 51, 44: 51, 45: 51, 46: 51, 47: 51, 48: 51, 49: 51, 50: 51, 51: 101, 52: 101,
                                             53: 101, 54: 101, 55: 101, 56: 101, 57: 101, 58: 101, 59: 101, 60: 101, 61: 101, 62: 101, 63: 101, 64: 101, 65: 101, 66: 101, 67: 101, 68: 101, 69: 101, 70: 101, 71: 101, 72: 101, 73: 101, 74: 101, 75: 101, 76: 101, 77: 101, 78: 101, 79: 101, 80: 101, 81: 101, 82: 101, 83: 101, 84: 101, 85: 101, 86: 101, 87: 101, 88: 101, 89: 101, 90: 101, 91: 101, 92: 101, 93: 101, 94: 101, 95: 101, 96: 101, 97: 101, 98: 101, 99: 101, 100: 101})
        self.assertEqual(experiment.stimpr, {1: 'random', 2: 'random', 3: 'random', 4: 'random', 5: 'random', 6: 'pattern', 7: 'random', 8: 'pattern', 9: 'random', 10: 'pattern', 11: 'random', 12: 'pattern', 13: 'random', 14: 'pattern', 15: 'random', 16: 'pattern', 17: 'random', 18: 'pattern', 19: 'random', 20: 'pattern', 21: 'random', 22: 'pattern', 23: 'random', 24: 'pattern', 25: 'random', 26: 'random', 27: 'random', 28: 'random', 29: 'random', 30: 'random', 31: 'pattern', 32: 'random', 33: 'pattern', 34: 'random', 35: 'pattern', 36: 'random', 37: 'pattern', 38: 'random', 39: 'pattern', 40: 'random', 41: 'pattern', 42: 'random', 43: 'pattern', 44: 'random', 45: 'pattern', 46: 'random', 47: 'pattern', 48: 'random', 49: 'pattern',
                                             50: 'random', 51: 'random', 52: 'random', 53: 'random', 54: 'random', 55: 'random', 56: 'pattern', 57: 'random', 58: 'pattern', 59: 'random', 60: 'pattern', 61: 'random', 62: 'pattern', 63: 'random', 64: 'pattern', 65: 'random', 66: 'pattern', 67: 'random', 68: 'pattern', 69: 'random', 70: 'pattern', 71: 'random', 72: 'pattern', 73: 'random', 74: 'pattern', 75: 'random', 76: 'random', 77: 'random', 78: 'random', 79: 'random', 80: 'random', 81: 'pattern', 82: 'random', 83: 'pattern', 84: 'random', 85: 'pattern', 86: 'random', 87: 'pattern', 88: 'random', 89: 'pattern', 90: 'random', 91: 'pattern', 92: 'random', 93: 'pattern', 94: 'random', 95: 'pattern', 96: 'random', 97: 'pattern', 98: 'random', 99: 'pattern', 100: 'random'})
Esempio n. 2
0
    def testSharedDataLock(self):
        experiment = asrt.Experiment("")
        experiment.person_data = asrt.PersonDataHandler("", "", "", "", "", "")
        experiment.settings = asrt.ExperimentSettings("", "")
        experiment.current_sampling_window = 24
        experiment.last_N = 10
        experiment.last_RSI = 400.0
        experiment.trial_phase = "before_stimulus"

        with experiment.shared_data_lock:
            gazeData = {}
            gazeData['left_gaze_point_on_display_area'] = (0.5, 0.5)
            gazeData['right_gaze_point_on_display_area'] = (0.5, 0.5)
            gazeData['left_gaze_point_validity'] = 1
            gazeData['right_gaze_point_validity'] = 1

            thread = threading.Thread(target=experiment.eye_data_callback,
                                      args=(gazeData, ))
            thread.start()

            thread.join(3.0)
            self.assertTrue(thread.is_alive())

        thread.join()
        self.assertTrue(not thread.is_alive())
Esempio n. 3
0
    def testDataListAppend(self):
        experiment = asrt.Experiment("")
        experiment.person_data = asrt.PersonDataHandler("", "", "", "", "", "")
        experiment.settings = asrt.ExperimentSettings("", "")
        experiment.current_sampling_window = 24
        experiment.last_N = 10
        experiment.last_RSI = 400.0
        experiment.trial_phase = "before_stimulus"

        gazeData = {}
        gazeData['left_gaze_point_validity'] = 1
        gazeData['right_gaze_point_validity'] = 1

        for i in range(0, experiment.current_sampling_window):
            gazeData['right_gaze_point_on_display_area'] = (0.02 * i, 0.02 * i)
            gazeData['left_gaze_point_on_display_area'] = (0.03 * i, 0.03 * i)
            experiment.eye_data_callback(gazeData)

        self.assertEqual(len(experiment.gaze_data_list),
                         experiment.current_sampling_window)
        for i in range(0, experiment.current_sampling_window):
            self.assertAlmostEqual(experiment.gaze_data_list[i][0],
                                   0.05 * i / 2.0,
                                   delta=0.0001)
            self.assertAlmostEqual(experiment.gaze_data_list[i][1],
                                   0.05 * i / 2.0,
                                   delta=0.0001)
Esempio n. 4
0
    def testInnerTrial(self):
        gui_mock = pgm.PsychoPyGuiMock()

        experiment = asrt.Experiment("")
        experiment.settings = asrt.ExperimentSettings("", "")
        experiment.settings.numsessions = 1
        experiment.settings.blockprepN = 5
        experiment.settings.blocklengthN = 80
        experiment.settings.block_in_epochN = 5
        experiment.settings.epochN = 5

        experiment.stim_sessionN = {}
        experiment.stimepoch = {}
        experiment.stimblock = {}
        experiment.stimtrial = {}
        experiment.last_N = experiment.settings.get_maxtrial() // 2
        for i in range(1, experiment.settings.get_maxtrial() + 1):
            experiment.stim_sessionN[i] = 1
            experiment.stimepoch[i] = i // (
                (experiment.settings.blockprepN +
                 experiment.settings.blocklengthN) *
                experiment.settings.block_in_epochN) + 1
            experiment.stimblock[i] = i // (
                experiment.settings.blockprepN +
                experiment.settings.blocklengthN) + 1

        experiment.show_subject_continuation_dialog()

        list_of_texts = gui_mock.getListOfTexts()
        self.assertEqual(len(list_of_texts), 5)
        self.assertEqual(list_of_texts[0], "A személy adatait beolvastam.")
        self.assertEqual(list_of_texts[1], "Folytatás innen...")
        self.assertEqual(list_of_texts[2], "Session: 1")
        self.assertEqual(list_of_texts[3], "Epoch: 3")
        self.assertEqual(list_of_texts[4], "Block: 13")
Esempio n. 5
0
    def testLotsOfInvalidData(self):
        experiment = asrt.Experiment("")
        experiment.person_data = asrt.PersonDataHandler("", "", "", "", "", "")
        experiment.settings = asrt.ExperimentSettings("", "")
        experiment.current_sampling_window = 24
        experiment.last_N = 10
        experiment.last_RSI = 400.0
        experiment.trial_phase = "before_stimulus"

        gazeData = {}
        gazeData['left_gaze_point_on_display_area'] = (0.5, 0.5)
        gazeData['right_gaze_point_on_display_area'] = (0.5, 0.5)
        gazeData['left_gaze_point_validity'] = 1
        gazeData['right_gaze_point_validity'] = 1

        clock = core.Clock()
        for i in range(100):
            experiment.eye_data_callback(gazeData)

        self.assertEqual(len(experiment.gaze_data_list),
                         experiment.current_sampling_window)

        gazeData = {}
        gazeData['left_gaze_point_on_display_area'] = (0.5, 0.5)
        gazeData['right_gaze_point_on_display_area'] = (0.5, 0.5)
        gazeData['left_gaze_point_validity'] = 0
        gazeData['right_gaze_point_validity'] = 0
        for i in range(100):
            experiment.eye_data_callback(gazeData)
        self.assertEqual(len(experiment.gaze_data_list),
                         experiment.current_sampling_window)
    def testDefaults(self):
        gui_mock = pgm.PsychoPyGuiMock()

        experiment = asrt.Experiment("")
        experiment.settings = asrt.ExperimentSettings("", "")

        experiment.settings.numsessions = 1
        experiment.settings.asrt_types = {}
        experiment.settings.asrt_types[1] = "implicit"

        experiment.show_subject_attributes_dialog()

        self.assertEqual(len(experiment.PCodes),
                         experiment.settings.numsessions)
        self.assertEqual(experiment.PCodes[1], "1st - 1234")
        self.assertEqual(experiment.subject_sex, "male")
        self.assertEqual(experiment.subject_age, "25")

        list_of_texts = gui_mock.getListOfTexts()
        self.assertEqual(len(list_of_texts), 1)
        self.assertEqual(list_of_texts[0], "")

        list_of_fields = gui_mock.getListOfFields()
        self.assertEqual(len(list_of_fields), 3)
        self.assertEqual(list_of_fields[0].label, "Nem")
        self.assertEqual(list_of_fields[0].initial, '')
        self.assertEqual(list_of_fields[1].label, "Életkor")
        self.assertEqual(list_of_fields[1].initial, '25')
        self.assertEqual(list_of_fields[2].label, "Session 1 PCode")
Esempio n. 7
0
    def testCancelDialog(self):

        gui_mock = pgm.PsychoPyGuiMock()
        gui_mock.setReturnValue(False)

        experiment = asrt.Experiment("")
        experiment.settings = asrt.ExperimentSettings("", "")
        experiment.settings.numsessions = 1
        experiment.settings.blockprepN = 5
        experiment.settings.blocklengthN = 80
        experiment.settings.block_in_epochN = 5
        experiment.settings.epochN = 5

        experiment.stim_sessionN = {}
        experiment.stimepoch = {}
        experiment.stimblock = {}
        experiment.stimtrial = {}
        experiment.last_N = 0
        for i in range(1, experiment.settings.get_maxtrial() + 1):
            experiment.stim_sessionN[i] = 1
            experiment.stimepoch[i] = i // 5 + 1
            experiment.stimblock[i] = i // (
                experiment.settings.blockprepN +
                experiment.settings.blocklengthN) + 1

        with self.assertRaises(SystemExit):
            experiment.show_subject_continuation_dialog()
    def testDefaults(self):
        gui_mock = pgm.PsychoPyGuiMock()

        experiment = asrt.Experiment("")
        experiment.settings = asrt.ExperimentSettings("", "")
        experiment.settings.groups = ["kontrol", "exp1"]
        experiment.show_subject_identification_dialog()

        self.assertEqual(experiment.subject_name, "alattomos-aladar")
        self.assertEqual(experiment.subject_number, 0)
        self.assertEqual(experiment.subject_group, 'kontrol')

        list_of_texts = gui_mock.getListOfTexts()
        self.assertEqual(len(list_of_texts), 2)
        self.assertEqual(list_of_texts[0], "")
        self.assertEqual(list_of_texts[1], "")

        list_of_fields = gui_mock.getListOfFields()
        self.assertEqual(len(list_of_fields), 3)
        self.assertEqual(list_of_fields[0].label, "Nev")
        self.assertEqual(list_of_fields[0].initial, 'Alattomos Aladar')
        self.assertEqual(list_of_fields[1].label, "Sorszam")
        self.assertEqual(list_of_fields[1].initial, '0')
        self.assertEqual(list_of_fields[2].label, "Csoport")
        self.assertEqual(list_of_fields[2].initial, '')
    def testNoSessions(self):
        gui_mock = pgm.PsychoPyGuiMock()

        exp_settings = asrt.ExperimentSettings("", "")
        exp_settings.numsessions = 0
        exp_settings.show_epoch_and_block_settings_dialog()

        self.assertEqual(exp_settings.blockprepN, 5)
        self.assertEqual(exp_settings.blocklengthN, 80)
        self.assertEqual(exp_settings.block_in_epochN, 5)
        self.assertEqual(exp_settings.epochN, 0)
        self.assertEqual(len(exp_settings.epochs), 0)
        self.assertEqual(len(exp_settings.asrt_types), 0)

        list_of_texts = gui_mock.getListOfTexts()
        self.assertEqual(len(list_of_texts), 1)
        self.assertEqual(list_of_texts[0], "Kísérlet felépítése ")

        list_of_fields = gui_mock.getListOfFields()
        self.assertEqual(len(list_of_fields), 3)
        self.assertEqual(list_of_fields[0].label,
                         "Randomok gyakorlaskent a blokk elejen (ennyi db):")
        self.assertEqual(list_of_fields[0].initial, 5)
        self.assertEqual(list_of_fields[1].label, "Eles probak a blokkban:")
        self.assertEqual(list_of_fields[1].initial, 80)
        self.assertEqual(list_of_fields[2].label,
                         "Blokkok szama egy epochban:")
        self.assertEqual(list_of_fields[2].initial, 5)
Esempio n. 10
0
    def testValidationMissingExplicitFeedback(self):
        inst_feedback_path = self.constructFilePath(
            "missing_explicit_feedback.txt")
        instruction_helper = asrt.InstructionHelper(inst_feedback_path)
        instruction_helper.read_insts_from_file()

        exp_settings = asrt.ExperimentSettings("", "")
        exp_settings.experiment_type = 'reaction-time'
        exp_settings.asrt_types = {}
        exp_settings.asrt_types[1] = "explicit"
        exp_settings.asrt_types[2] = "implicit"
        exp_settings.asrt_types[3] = "noASRT"

        with self.assertRaises(SystemExit):
            instruction_helper.validate_instructions(exp_settings)

        # no problem when there is no implicit asrt type
        exp_settings.asrt_types = {}
        exp_settings.asrt_types[1] = "implicit"
        exp_settings.asrt_types[2] = "noASRT"
        instruction_helper.validate_instructions(exp_settings)

        # no problem when we have eye-tracking version
        exp_settings.experiment_type = 'eye-tracking'
        exp_settings.asrt_types = {}
        exp_settings.asrt_types[1] = "explicit"
        exp_settings.asrt_types[2] = "implicit"
        exp_settings.asrt_types[3] = "noASRT"
        instruction_helper.validate_instructions(exp_settings)
Esempio n. 11
0
    def testCancel(self):
        gui_mock = pgm.PsychoPyGuiMock()
        gui_mock.setReturnValue(False)

        exp_settings = asrt.ExperimentSettings("", "")
        with self.assertRaises(SystemExit):
            exp_settings.show_basic_settings_dialog()
Esempio n. 12
0
    def testShowFeedbackETMoreRTData(self):
        inst_and_feedback_path = self.constructFilePath("default.txt")
        instruction_helper = asrt.InstructionHelper(inst_and_feedback_path)
        instruction_helper.read_insts_from_file()

        experiment = asrt.Experiment("")
        self.initWindow()
        experiment.mywindow = self.mywindow
        experiment.settings = asrt.ExperimentSettings("", "")
        experiment.person_data = asrt.PersonDataHandler(
            "", "", "", "", "", "eye-tracking")
        experiment.settings.experiment_type = 'eye-tracking'
        experiment.settings.key_quit = 'q'
        experiment.stimblock = {4: 10}
        experiment.last_N = 4
        experiment.last_block_RTs = [
            "0.512", "0.443", "0.335", "0.601", "0.213", "0.934", "0.912",
            "0.120"
        ]

        visual_mock = pvm.PsychoPyVisualMock()
        instruction_helper.feedback_ET(experiment)

        drawing_list = visual_mock.getListOfDrawings()
        self.assertEqual(len(drawing_list), 1)
        self.assertEqualWithEOL(
            drawing_list[0].text, "Most pihenhetsz egy kicsit.\n\n"
            "Az előző blokkokban mért átlagos reakcióidők:\n\n"
            "6. blokk: 0.601 másodperc.\n\n"
            "7. blokk: 0.213 másodperc.\n\n"
            "8. blokk: 0.934 másodperc.\n\n"
            "9. blokk: 0.912 másodperc.\n\n"
            "10. blokk: 0.120 másodperc.\n\n")
Esempio n. 13
0
    def testFinishedSession(self):
        gui_mock = pgm.PsychoPyGuiMock()

        experiment = asrt.Experiment("")
        experiment.settings = asrt.ExperimentSettings("", "")
        experiment.settings.numsessions = 1
        experiment.settings.blockprepN = 5
        experiment.settings.blocklengthN = 80
        experiment.settings.block_in_epochN = 5
        experiment.settings.epochN = 5

        experiment.stim_sessionN = {}
        experiment.stimepoch = {}
        experiment.stimblock = {}
        experiment.last_N = experiment.settings.get_maxtrial()
        for i in range(1, experiment.settings.get_maxtrial() + 1):
            experiment.stim_sessionN[i] = 1
            experiment.stimepoch[i] = i / 5
            experiment.stimblock[i] = i / (experiment.settings.blockprepN +
                                           experiment.settings.blocklengthN)

        with self.assertRaises(SystemExit):
            experiment.show_subject_continuation_dialog()

        list_of_texts = gui_mock.getListOfTexts()
        self.assertEqual(len(list_of_texts), 2)
        self.assertEqual(list_of_texts[0], "A személy adatait beolvastam.")
        self.assertEqual(list_of_texts[1],
                         "A személy végigcsinálta a feladatot.")
Esempio n. 14
0
    def testShowImplicitFeedbackQuit(self):
        inst_and_feedback_path = self.constructFilePath("default.txt")
        instruction_helper = asrt.InstructionHelper(inst_and_feedback_path)
        instruction_helper.read_insts_from_file()

        exp_settings = asrt.ExperimentSettings("", "")
        exp_settings.experiment_type = 'reaction-time'
        exp_settings.key1 = 'z'
        exp_settings.key2 = 'c'
        exp_settings.key3 = 'b'
        exp_settings.key4 = 'm'
        exp_settings.key_quit = 'q'
        exp_settings.whether_warning = True
        exp_settings.acc_warning = 90
        exp_settings.speed_warning = 94

        visual_mock = pvm.PsychoPyVisualMock()
        visual_mock.setReturnKeyList(['q'])
        self.initWindow()
        return_value = instruction_helper.feedback_implicit_RT(
            "450.2", 92.123, "92.123", self.mywindow, exp_settings)

        self.assertEqual(return_value, "quit")

        drawing_list = visual_mock.getListOfDrawings()
        self.assertEqual(len(drawing_list), 1)

        self.assertEqualWithEOL(
            drawing_list[0].text, "\r\n\r\nMost pihenhetsz egy kicsit.\r\n\r\n"
            "Pontosságod: 92.123 %\r\n"
            "Átlagos reakcióidőd: 450.2 másodperc\r\n\r\n\r\n")
Esempio n. 15
0
    def testShowExplicitFeedbackSpeedWarning(self):
        inst_and_feedback_path = self.constructFilePath("default.txt")
        instruction_helper = asrt.InstructionHelper(inst_and_feedback_path)
        instruction_helper.read_insts_from_file()

        exp_settings = asrt.ExperimentSettings("", "")
        exp_settings.experiment_type = 'reaction-time'
        exp_settings.key1 = 'z'
        exp_settings.key2 = 'c'
        exp_settings.key3 = 'b'
        exp_settings.key4 = 'm'
        exp_settings.key_quit = 'q'
        exp_settings.whether_warning = True
        exp_settings.acc_warning = 90
        exp_settings.speed_warning = 94

        visual_mock = pvm.PsychoPyVisualMock()
        self.initWindow()
        instruction_helper.feedback_explicit_RT("450.2", "410.2", "90.123",
                                                96.123, "96.123",
                                                self.mywindow, exp_settings)

        drawing_list = visual_mock.getListOfDrawings()
        self.assertEqual(len(drawing_list), 1)

        self.assertEqualWithEOL(
            drawing_list[0].text, "\r\n\r\nMost pihenhetsz egy kicsit.\r\n\r\n"
            "Pontosságod általában: 96.123 %\r\n"
            "Átlagos reakcióidőd: 450.2 másodperc\r\n"
            "Pontosságod a bejósolható elemeknél: 90.123 %\r\n"
            "Átlagos reakcióidőd a bejósolható elemeknél: 410.2 másodperc\r\n\r\n"
            "Legyél gyorsabb!\r\n\r\n\r\n\r\n")
Esempio n. 16
0
    def testShowEnding(self):
        inst_and_feedback_path = self.constructFilePath("default.txt")
        instruction_helper = asrt.InstructionHelper(inst_and_feedback_path)
        instruction_helper.read_insts_from_file()

        experiment = asrt.Experiment("")
        experiment.settings = asrt.ExperimentSettings("", "")
        experiment.settings.experiment_type = 'reaction-time'
        experiment.settings.key1 = 'z'
        experiment.settings.key2 = 'c'
        experiment.settings.key3 = 'b'
        experiment.settings.key4 = 'm'
        experiment.settings.key_quit = 'q'

        visual_mock = pvm.PsychoPyVisualMock()
        self.initWindow()
        experiment.mywindow = self.mywindow
        instruction_helper.show_ending(experiment)

        drawing_list = visual_mock.getListOfDrawings()
        self.assertEqual(len(drawing_list), 1)

        self.assertEqualWithEOL(
            drawing_list[0].text,
            "\r\n\r\nA feladat végetért. Köszönjük a részvételt!\r\n\r\n")
Esempio n. 17
0
    def testShowUnexpectedQuit(self):
        inst_and_feedback_path = self.constructFilePath("default.txt")
        instruction_helper = asrt.InstructionHelper(inst_and_feedback_path)
        instruction_helper.read_insts_from_file()

        experiment = asrt.Experiment("")
        experiment.settings = asrt.ExperimentSettings("", "")
        experiment.settings.experiment_type = 'reaction-time'
        experiment.settings.key1 = 'z'
        experiment.settings.key2 = 'c'
        experiment.settings.key3 = 'b'
        experiment.settings.key4 = 'm'
        experiment.settings.key_quit = 'q'

        visual_mock = pvm.PsychoPyVisualMock()
        self.initWindow()
        experiment.mywindow = self.mywindow
        instruction_helper.show_unexp_quit(experiment)

        drawing_list = visual_mock.getListOfDrawings()
        self.assertEqual(len(drawing_list), 1)

        self.assertEqualWithEOL(
            drawing_list[0].text,
            "\r\n\r\nVáratlan kilépés történt a feladatból. Folytatás. A feladat indításához nyomd meg valamelyik válaszbillentyűt."
        )
Esempio n. 18
0
    def testQuitDisplayET(self):
        inst_and_feedback_path = self.constructFilePath("default.txt")
        instruction_helper = asrt.InstructionHelper(inst_and_feedback_path)
        instruction_helper.read_insts_from_file()

        experiment = asrt.Experiment("")
        self.initWindow()
        experiment.mywindow = self.mywindow
        experiment.settings = asrt.ExperimentSettings("", "")
        experiment.settings.experiment_type = 'eye-tracking'
        experiment.settings.key_quit = 'q'
        experiment.fixation_cross_pos = (0.0, 0.0)
        experiment.fixation_cross = visual.TextStim(
            win=experiment.mywindow,
            text="+",
            height=3,
            units="cm",
            color='black',
            pos=experiment.fixation_cross_pos)

        visual_mock = pvm.PsychoPyVisualMock()
        visual_mock.setReturnKeyList(['q'])
        with self.assertRaises(SystemExit):
            instruction_helper._InstructionHelper__show_message(
                instruction_helper.ending, experiment)
Esempio n. 19
0
    def testDefault(self):
        asrt.g_tobii_available = False
        gui_mock = pgm.PsychoPyGuiMock()
        exp_settings = asrt.ExperimentSettings("", "")
        numgroups = exp_settings.show_basic_settings_dialog()
        self.assertEqual(numgroups, 2)
        self.assertEqual(exp_settings.numsessions, 2)

        list_of_texts = gui_mock.getListOfTexts()
        self.assertEqual(len(list_of_texts), 3)
        self.assertEqual(
            list_of_texts[0],
            "Még nincsenek beállítások mentve ehhez a kísérlethez...")
        self.assertEqual(
            list_of_texts[1],
            "A logfile optimalizálása érdekében kérjük add meg, hányféle csoporttal tervezed az adatfelvételt."
        )
        self.assertEqual(list_of_texts[2],
                         "Hány ülés (session) lesz a kísérletben?")

        list_of_fields = gui_mock.getListOfFields()
        self.assertEqual(len(list_of_fields), 3)
        self.assertEqual(list_of_fields[0].label, "Kísérlet típusa:")
        self.assertEqual(list_of_fields[0].initial, "reakció idő")
        self.assertEqual(list_of_fields[1].label,
                         "Kiserleti + Kontrollcsoportok szama osszesen")
        self.assertEqual(list_of_fields[1].initial, 2)
        self.assertEqual(list_of_fields[2].label, "Ulesek szama")
        self.assertEqual(list_of_fields[2].initial, 2)
Esempio n. 20
0
    def testInvalidEyeData(self):
        experiment = asrt.Experiment("")
        experiment.person_data = asrt.PersonDataHandler("", "", "", "", "", "")
        experiment.settings = asrt.ExperimentSettings("", "")
        experiment.current_sampling_window = 24
        experiment.last_N = 10
        experiment.last_RSI = 400.0
        experiment.trial_phase = "before_stimulus"

        gazeData = {}
        gazeData['left_gaze_point_on_display_area'] = (0.5, 0.5)
        gazeData['right_gaze_point_on_display_area'] = (1.0, 1.0)
        gazeData['left_gaze_point_validity'] = 0
        gazeData['right_gaze_point_validity'] = 0

        experiment.eye_data_callback(gazeData)
        self.assertEqual(len(experiment.gaze_data_list), 1)
        self.assertEqual(experiment.gaze_data_list[0][0], None)
        self.assertEqual(experiment.gaze_data_list[0][1], None)

        gazeData['left_gaze_point_on_display_area'] = (0.5, 0.5)
        gazeData['right_gaze_point_on_display_area'] = (1.0, 1.0)
        gazeData['left_gaze_point_validity'] = 1
        gazeData['right_gaze_point_validity'] = 1

        experiment.eye_data_callback(gazeData)
        self.assertEqual(len(experiment.gaze_data_list), 2)
        self.assertEqual(experiment.gaze_data_list[1][0], 0.75)
        self.assertEqual(experiment.gaze_data_list[1][1], 0.75)

        gazeData['left_gaze_point_on_display_area'] = (0.5, 0.5)
        gazeData['right_gaze_point_on_display_area'] = (1.0, 1.0)
        gazeData['left_gaze_point_validity'] = 0
        gazeData['right_gaze_point_validity'] = 1

        experiment.eye_data_callback(gazeData)
        self.assertEqual(len(experiment.gaze_data_list), 3)
        self.assertEqual(experiment.gaze_data_list[2][0], 1.0)
        self.assertEqual(experiment.gaze_data_list[2][1], 1.0)

        gazeData['left_gaze_point_on_display_area'] = (0.5, 0.5)
        gazeData['right_gaze_point_on_display_area'] = (1.0, 1.0)
        gazeData['left_gaze_point_validity'] = 1
        gazeData['right_gaze_point_validity'] = 0

        experiment.eye_data_callback(gazeData)
        self.assertEqual(len(experiment.gaze_data_list), 4)
        self.assertEqual(experiment.gaze_data_list[3][0], 0.5)
        self.assertEqual(experiment.gaze_data_list[3][1], 0.5)

        gazeData['left_gaze_point_on_display_area'] = (0.5, 0.5)
        gazeData['right_gaze_point_on_display_area'] = (1.0, 1.0)
        gazeData['left_gaze_point_validity'] = 0
        gazeData['right_gaze_point_validity'] = 0

        experiment.eye_data_callback(gazeData)
        self.assertEqual(len(experiment.gaze_data_list), 5)
        self.assertEqual(experiment.gaze_data_list[4][0], None)
        self.assertEqual(experiment.gaze_data_list[4][1], None)
Esempio n. 21
0
 def dump(self, file_path, file_name):
     print(os.path.join(file_path, file_name))
     print(os.path.join(file_path, "settings_reminder.txt"))
     exp_settings = asrt.ExperimentSettings(
         os.path.join(file_path, file_name),
         os.path.join(file_path, "settings_reminder.txt"))
     exp_settings.read_from_file()
     exp_settings.write_out_reminder()
Esempio n. 22
0
    def testETMissingDependency(self):
        asrt.g_tobii_available = False
        gui_mock = pgm.PsychoPyGuiMock()
        gui_mock.addFieldValues(['eye-tracking', 4, 5])

        exp_settings = asrt.ExperimentSettings("", "")
        with self.assertRaises(SystemExit):
            exp_settings.show_basic_settings_dialog()
    def testCancel(self):
        gui_mock = pgm.PsychoPyGuiMock()
        gui_mock.setReturnValue(False)

        exp_settings = asrt.ExperimentSettings("", "")
        exp_settings.numsessions = 1

        with self.assertRaises(SystemExit):
            exp_settings.show_epoch_and_block_settings_dialog()
    def testCancel(self):
        gui_mock = pgm.PsychoPyGuiMock()
        gui_mock.setReturnValue(False)

        experiment = asrt.Experiment("")
        experiment.settings = asrt.ExperimentSettings("", "")
        experiment.settings.groups = ["kontrol", "exp1"]
        with self.assertRaises(SystemExit):
            experiment.show_subject_identification_dialog()
Esempio n. 25
0
    def testCenterPos(self):
        experiment = asrt.Experiment("")
        with self.initWindow() as experiment.mywindow:
            experiment.mymonitor = self.my_monitor
            experiment.settings = asrt.ExperimentSettings("", "")
            experiment.settings.monitor_width = 47.6

            result = experiment.ADCS_to_PCMCS((0.5, 0.5))
            self.assertAlmostEqual(result[0], 0.0, delta=0.001)
            self.assertAlmostEqual(result[1], 0.0, delta=0.001)
Esempio n. 26
0
    def testBottomRightPos(self):
        experiment = asrt.Experiment("")
        with self.initWindow() as experiment.mywindow:
            experiment.mymonitor = self.my_monitor
            experiment.settings = asrt.ExperimentSettings("", "")
            experiment.settings.monitor_width = 47.6

            result = experiment.ADCS_to_PCMCS((1.0, 1.0))
            self.assertAlmostEqual(result[0], 23.8, delta=0.001)
            self.assertAlmostEqual(result[1], -13.38, delta=0.001)
    def testSmallValues(self):
        experiment = asrt.Experiment("")
        with self.initWindow() as experiment.mywindow:
            experiment.mymonitor = self.my_monitor
            experiment.settings = asrt.ExperimentSettings("", "")
            experiment.settings.monitor_width = 47.6

            result = experiment.distance_ADCS_to_PCMCS((0.02, 0.02))
            self.assertAlmostEqual(result[0], 0.952, delta=0.001)
            self.assertAlmostEqual(result[1], 0.535, delta=0.001)
Esempio n. 28
0
    def testCustomValuesET(self):
        asrt.g_tobii_available = True
        gui_mock = pgm.PsychoPyGuiMock()
        gui_mock.addFieldValues(['eye-tracking', 4, 5])

        exp_settings = asrt.ExperimentSettings("", "")
        numgroups = exp_settings.show_basic_settings_dialog()
        self.assertEqual(exp_settings.experiment_type, 'eye-tracking')
        self.assertEqual(numgroups, 4)
        self.assertEqual(exp_settings.numsessions, 5)
Esempio n. 29
0
    def testCustomValues(self):
        asrt.g_tobii_available = False
        gui_mock = pgm.PsychoPyGuiMock()
        gui_mock.addFieldValues(['reakció idő', 3, 3])

        exp_settings = asrt.ExperimentSettings("", "")
        numgroups = exp_settings.show_basic_settings_dialog()
        self.assertEqual(exp_settings.experiment_type, 'reaction-time')
        self.assertEqual(numgroups, 3)
        self.assertEqual(exp_settings.numsessions, 3)
    def testAccentCharacters(self):
        gui_mock = pgm.PsychoPyGuiMock()
        gui_mock.addFieldValues(["áaéeíióoőöúuűüÁAÉEÍIÓOŐÖÚUŰÜ", "kontrol"])
        numgroups = 2
        exp_settings = asrt.ExperimentSettings("", "")
        exp_settings.show_group_settings_dialog(numgroups)

        self.assertEqual(len(exp_settings.groups), numgroups)
        self.assertEqual(exp_settings.groups[0],
                         "aaeeiioooouuuuaaeeiioooouuuu")
        self.assertEqual(exp_settings.groups[1], "kontrol")