From 9ce0bc13437a0bbb109d016136b7cf83c036c9c6 Mon Sep 17 00:00:00 2001 From: ursula-37 <1612876366@qq.com> Date: Thu, 5 Feb 2026 00:19:33 +0800 Subject: [PATCH] add Chinese MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hello,I add Chinese and nativelanguage(yes or no) . Because i use English at first,but I want to try my nativelanguage,Then contrast them. This is the first time that i try to alter code,hope this helps. Have a nice day. --- INSTRUCTIONS | 43 +++++++++++++++++++++++++++++++++++++++++++ stroopy.py | 22 ++++++++++++++++++++-- 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/INSTRUCTIONS b/INSTRUCTIONS index a8b0840..a46b748 100644 --- a/INSTRUCTIONS +++ b/INSTRUCTIONS @@ -96,3 +96,46 @@ Incorrect! It is the color not the word incorrectEND EnglishEnd + + +Chinese + +instructionsSTART +你的任务是尽可能准确且快速地判断所显示单词的颜色。 +你会在彩色单词的两侧看到两个选项。 +如果正确选项在左边,请按X键,如果正确选项在右边,请按M键。 + +在下面的示例中,由于单词的颜色是绿色,你应按X(左)。 +instructionsEND + +practiceSTART +按空格键测试六次试验,然后开始正式测试。 +practiceEND + +testSTART +干得好! + +如果你有任何问题,请现在向实验负责人提问。 + +尽量快速且准确地回答。 + +按空格键开始实验。 +testEND + +doneSTART +实验结束, + +请通知实验负责人 + +按空格键结束实验 +doneEND + +rightSTART +正确! +rightEND + +incorrectSTART +错误!是颜色而不是单词。 +incorrectEND + +ChineseEnd diff --git a/stroopy.py b/stroopy.py index 10e4f46..d78d5be 100644 --- a/stroopy.py +++ b/stroopy.py @@ -19,7 +19,7 @@ def create_window(self, color=(1, 1, 1)): def settings(self): experiment_info = {'Subid': '', 'Age': '', 'Experiment Version': 0.1, 'Sex': ['Male', 'Female', 'Other'], - 'Language': ['English', 'Swedish'], u'date': + 'Language': ['English', 'Swedish','Chinese'], 'NativeLanguage':['Yes','No'],u'date': data.getDateStr(format="%Y-%m-%d_%H:%M")} info_dialog = gui.DlgFromDict(title='Stroop task', dictionary=experiment_info, @@ -45,7 +45,7 @@ def create_text_stimuli(self, text=None, pos=[0.0, 0.0], name='', color=None): def create_trials(self, trial_file, randomization='random'): '''Doc string''' - data_types = ['Response', 'Accuracy', 'RT', 'Sub_id', 'Sex'] + data_types = ['Response', 'Accuracy', 'RT', 'Sub_id', 'Sex','NativeLanguage','Language'] with open(trial_file, 'r') as stimfile: _stims = csv.DictReader(stimfile) trials = data.TrialHandler(list(_stims), 1, @@ -60,6 +60,8 @@ def present_stimuli(self, color, text, position, stim): position = position if settings['Language'] == "Swedish": text = swedish_task(text) + elif settings['Language'] == "Chinese": + text = chinese_task(text) else: text = text _stimulus.pos = position @@ -118,6 +120,8 @@ def running_experiment(self, trials, testtype): trial['Response'] = keys[0] trial['Sub_id'] = settings['Subid'] trial['Sex'] = settings['Sex'] + trial['Language'] = settings['Language'] + trial['NativeLanguage'] = settings['NativeLanguage'] write_csv(settings[u'DataFile'], trial) event.clearEvents() @@ -164,6 +168,8 @@ def display_instructions(start_instruction=''): example_words = ['green', 'blue', 'green'] if settings['Language'] == 'Swedish': example_words = [swedish_task(word) for word in example_words] + elif settings['Language'] == 'Chinese': + example_words = [chinese_task(word) for word in example_words] for i, pos in enumerate(positions): examples[i].pos = pos @@ -203,6 +209,18 @@ def swedish_task(word): swedish = "gul" return swedish +def chinese_task(word): + chinese = '+' + if word == "blue": + chinese = u"蓝色" + elif word == "red": + chinese = u"红色" + elif word == "green": + chinese = u"绿色" + elif word == "yellow": + chinese = "黄色" + return chinese + if __name__ == "__main__": background = "Black"