コード例 #1
0
    def test_best_case_sequence_gen(self):
        """Test best_case_rsvp_seq_gen"""
        alp = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
        n = 5
        samples, times, colors = best_case_rsvp_seq_gen(
            alp=alp,
            session_stimuli=[0.1, 0.1, 0.1, 0.2, 0.2, 0.1, 0.2],
            timing=[1, 0.2],
            color=['red', 'white'],
            num_sti=1,
            len_sti=n,
            is_txt=True)

        first_seq = samples[0]
        self.assertEqual(1, len(samples))
        self.assertEqual(n + 1, len(first_seq),
                         'Should include fixation cross.')
        self.assertEqual(len(samples), len(times))
        self.assertEqual(len(samples), len(colors))

        expected = ['+', 'a', 'b', 'd', 'e', 'g']
        for letter in expected:
            self.assertTrue(letter in first_seq)

        self.assertNotEqual(expected, first_seq, 'Should be in random order.')
        self.assertEqual([1] + ([0.2] * n), times[0])
        self.assertEqual(['red'] + (['white'] * n), colors[0])
コード例 #2
0
    def test_best_case_sequence_gen_with_seq_constants(self):
        """Test best_case_rsvp_seq_gen with sequence constants"""

        alp = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
        n = 5

        with self.assertRaises(Exception,
                               msg='Constants should be in the alphabet'):
            best_case_rsvp_seq_gen(
                alp=alp,
                session_stimuli=[0.1, 0.1, 0.1, 0.2, 0.2, 0.1, 0.2],
                seq_constants=['<'])

        alp = ['a', 'b', 'c', 'd', 'e', 'f', 'g', '<']
        samples, times, colors = best_case_rsvp_seq_gen(
            alp=alp,
            session_stimuli=[0.1, 0.1, 0.1, 0.2, 0.2, 0.1, 0.2, 0.0],
            num_sti=1,
            len_sti=n,
            is_txt=True,
            seq_constants=['<'])

        first_seq = samples[0]
        self.assertEqual(1, len(samples))
        self.assertEqual(n + 1, len(first_seq),
                         'Should include fixation cross.')
        self.assertEqual(len(samples), len(times))
        self.assertEqual(len(samples), len(colors))

        expected = ['+', 'a', 'd', 'e', 'g', '<']
        for letter in expected:
            self.assertTrue(letter in first_seq)

        self.assertNotEqual(expected, first_seq, 'Should be in random order.')
        self.assertEqual([1] + ([0.2] * n), times[0])
        self.assertEqual(['red'] + (['white'] * n), colors[0])
コード例 #3
0
ファイル: main_frame.py プロジェクト: theGreenJedi/BciPy
    def prepare_stimuli(self):
        """ Given the alphabet, under a rule, prepares a stimuli for
            the next sequence
            Return:
                stimuli(tuple[list[char],list[float],list[str]]): tuple of
                    stimuli information. [0]: letter, [1]: timing, [2]: color
                """

        stimuli = best_case_rsvp_seq_gen(
            self.alphabet,
            self.list_epoch[-1]['list_distribution'][-1],
            stim_number=1,
            is_txt=self.is_txt_stim,
            timing=self.stimuli_timing,
            seq_constants=self.seq_constants)
        return stimuli