diff --git a/.github/workflows/build_executables.yml b/.github/workflows/build_executables.yml index aa32741..f2d0472 100644 --- a/.github/workflows/build_executables.yml +++ b/.github/workflows/build_executables.yml @@ -57,8 +57,8 @@ jobs: - name: save exe uses: actions/upload-artifact@v4 with: - name: SUPREME_win - path: package/dist/SUPREME.exe + name: NIMHCogMood_win + path: package/dist/NIMHCogMood.exe build-macos: @@ -111,12 +111,12 @@ jobs: cd package python3 -m PyInstaller --noconfirm cogmood_mac.spec cd .. - mkdir SUPREME - cp -r package/dist/SUPREME.app SUPREME/ - create-dmg --volname SUPREME SUPREME.dmg SUPREME + mkdir NIMHCogMood + cp -r package/dist/NIMHCogMood.app NIMHCogMood/ + create-dmg --volname NIMHCogMood NIMHCogMood.dmg NIMHCogMood - name: Upload macOS executable uses: actions/upload-artifact@v4 with: - name: SUPREME_mac - path: SUPREME.dmg + name: NIMHCogMood_mac + path: NIMHCogMood.dmg diff --git a/main.py b/main.py index d23759c..14c8805 100644 --- a/main.py +++ b/main.py @@ -200,7 +200,7 @@ BartuvaExp(Bartuva_config, run_num=exp.block_number, sub_dir=Ref.object(exp)._session_dir, - practice=False, + practice=True, task_dir=task2dir, happy_mid=False) diff --git a/package/Makefile b/package/Makefile index 1a7fa7e..4939e24 100644 --- a/package/Makefile +++ b/package/Makefile @@ -1,7 +1,7 @@ # Define the spec files for each OS MAC_SPEC_FILE=cogmood_mac.spec WIN_SPEC_FILE=cogmood_windows.spec -EXECUTABLE_NAME=SUPREME +EXECUTABLE_NAME=NIMHCogMood # Define UPX executable path WIN_UPX=upx/windows_upx.exe diff --git a/package/cogmood_mac.spec b/package/cogmood_mac.spec index 6c8b349..b0b1db3 100644 --- a/package/cogmood_mac.spec +++ b/package/cogmood_mac.spec @@ -38,7 +38,7 @@ exe = EXE( a.zipfiles, a.datas, [], - name='SUPREME', + name='NIMHCogMood', debug=False, bootloader_ignore_signals=False, strip=False, @@ -51,14 +51,14 @@ exe = EXE( app = BUNDLE( exe, - name='SUPREME.app', + name='NIMHCogMood.app', icon=None, - bundle_identifier='uva.compmem.supreme', + bundle_identifier='nimh.mlc.nimhcogmood', info_plist={ 'NSHighResolutionCapable': 'True', - 'CFBundleDisplayName': 'SUPREME', - 'CFBundleName': 'SUPREME', - 'CFBundleIdentifier': 'uva.compmem.supreme', + 'CFBundleDisplayName': 'NIMHCogMood', + 'CFBundleName': 'NIMHCogMood', + 'CFBundleIdentifier': 'nimh.mlc.nimhcogmood', 'CFBundleVersion': '1.0.0', 'CFBundleShortVersionString': '1.0.0', 'LSArchitecturePriority': ['x86_64', 'arm64'], diff --git a/package/cogmood_windows.spec b/package/cogmood_windows.spec index 9a9f35b..6edcdae 100644 --- a/package/cogmood_windows.spec +++ b/package/cogmood_windows.spec @@ -37,7 +37,7 @@ exe = EXE(pyz, a.zipfiles, a.datas, *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)], - name='SUPREME', + name='NIMHCogMood', debug=False, bootloader_ignore_signals=False, strip=False, diff --git a/package/exe_versioning.txt b/package/exe_versioning.txt index 57b85eb..30cc25a 100644 --- a/package/exe_versioning.txt +++ b/package/exe_versioning.txt @@ -16,13 +16,13 @@ VSVersionInfo( [ StringTable( u'040904B0', - [StringStruct(u'CompanyName', u'UVA CompMem'), + [StringStruct(u'CompanyName', u'NIMH MLC'), StringStruct(u'FileDescription', u''), StringStruct(u'FileVersion', u'1.0.0.0'), - StringStruct(u'InternalName', u'SUPREME - CogMood'), + StringStruct(u'InternalName', u'NIMH - CogMood'), StringStruct(u'LegalCopyright', u''), - StringStruct(u'OriginalFilename', u'SUPREME.exe'), - StringStruct(u'ProductName', u'SUPREME - CogMood'), + StringStruct(u'OriginalFilename', u'NIMHCogMood.exe'), + StringStruct(u'ProductName', u'NIMH - CogMood'), StringStruct(u'ProductVersion', u'1.0.0.0'), StringStruct(u'WorkerID', u'"------------------------------------------------".---------------------------')]) ]), diff --git a/tasks/AssBind/instruct.py b/tasks/AssBind/instruct.py index 611f40a..acff41a 100644 --- a/tasks/AssBind/instruct.py +++ b/tasks/AssBind/instruct.py @@ -3,58 +3,115 @@ from smile.scale import scale as s from .GetResponse import GetResponse + +def get_is_first(run_num): + return run_num == 0 # present instructions @Subroutine -def Instruct(self, config, text_names):#, resp_keys, touch, font_size): +def Instruct(self, config, text_names, run_num):#, resp_keys, touch, font_size): + + is_first = Func(get_is_first, run_num).result texts = get_text(config) - with Parallel(): - if not config.TOUCH: - MouseCursor(blocking=False) - with Serial(blocking=False): - for doc in text_names: - with Parallel(): - title = Label(text='Memory Task Instructions', - font_size=s(config.INST_TITLE_FONT_SIZE), + with If(is_first): + with Parallel(): + if not config.TOUCH: + MouseCursor(blocking=False) + with Serial(blocking=True): + for doc in text_names: + with Parallel(): + title = Label(text='Memory Task Instructions', + font_size=s(config.INST_TITLE_FONT_SIZE), + text_size=(s(config.TEXT_SIZE_WIDTH), None), + top=self.exp.screen.center_y + s(415)) + + # image != None for 4 example slides + with If(texts[doc]['image'] != None): + image = Image(source=texts[doc]['image'], + top=(title.bottom - s(10)), + width=s(config.INST_IMG_WIDTH), + height=s(config.INST_IMG_HEIGHT), + allow_stretch=True, keep_ratio=False) + with If(texts[doc]['image'] != None): + Label(text=texts[doc]['text'], + font_size=s(config.INST_FONT_SIZE), + text_size=(s(config.TEXT_SIZE_WIDTH), None), + top=(image.bottom - s(10))) + + # image == None for first and last slides (instructions and reminder) + with If(texts[doc]['image'] == None): + Label(text=texts[doc]['text'], + text_size=(s(config.TEXT_SIZE_WIDTH), None), + font_size=s(config.INST_FONT_SIZE), + top=(title.bottom - s(10))) + + with UntilDone(): + Wait(1.0) + GetResponse(keys=texts[doc]['keys']) + + with Else(): + with Parallel(): + if not config.TOUCH: + MouseCursor(blocking=False) + with Serial(blocking=False): + for doc in text_names: + with Parallel(): + title = Label(text='Memory Task Instructions', + font_size=s(config.INST_TITLE_FONT_SIZE), + text_size=(s(config.TEXT_SIZE_WIDTH), None), + top=self.exp.screen.center_y + s(415)) + + # image != None for 4 example slides + with If(texts[doc]['image'] != None): + image = Image(source=texts[doc]['image'], + top=(title.bottom - s(10)), + width=s(config.INST_IMG_WIDTH), + height=s(config.INST_IMG_HEIGHT), + allow_stretch=True, keep_ratio=False) + with If(texts[doc]['image'] != None): + Label(text=texts[doc]['text'], + font_size=s(config.INST_FONT_SIZE), + text_size=(s(config.TEXT_SIZE_WIDTH), None), + top=(image.bottom - s(10))) + + # image == None for first and last slides (instructions and reminder) + with If(texts[doc]['image'] == None): + Label(text=texts[doc]['text'] + '\n\nYou may press the button in the' + ' lower right corner to skip the practice', text_size=(s(config.TEXT_SIZE_WIDTH), None), - top=self.exp.screen.center_y + s(415)) - - # image != None for 4 example slides - with If(texts[doc]['image'] != None): - image = Image(source=texts[doc]['image'], - top=(title.bottom - s(10)), - width=s(config.INST_IMG_WIDTH), - height=s(config.INST_IMG_HEIGHT), - allow_stretch=True, keep_ratio=False) - with If(texts[doc]['image'] != None): - Label(text=texts[doc]['text'], - font_size=s(config.INST_FONT_SIZE), - text_size=(s(config.TEXT_SIZE_WIDTH), None), - top=(image.bottom - s(10))) - - # image == None for first and last slides (instructions and reminder) - with If(texts[doc]['image'] == None): - Label(text=texts[doc]['text'], - text_size=(s(config.TEXT_SIZE_WIDTH), None), - font_size=s(config.INST_FONT_SIZE), - top=(title.bottom - s(10))) - - with UntilDone(): - Wait(1.0) - GetResponse(keys=texts[doc]['keys']) - - #RstDocument(text=texts[doc]['text'], - #width=self.exp.screen.height, - #height=self.exp.screen.height, - #base_font_size=s(config.RST_FONT_SIZE)) - - - with Serial(blocking=False): - with ButtonPress(): - Button(text="Skip Practice", right=self.exp.screen.width, - bottom=0, width=s(config.SKIP_SIZE[0]), - height=s(config.SKIP_SIZE[1]), blocking=False, - font_size=s(config.SKIP_FONT_SIZE)) + font_size=s(config.INST_FONT_SIZE), + top=(title.bottom - s(10))) + + with UntilDone(): + Wait(1.0) + GetResponse(keys=texts[doc]['keys']) + + #RstDocument(text=texts[doc]['text'], + #width=self.exp.screen.height, + #height=self.exp.screen.height, + #base_font_size=s(config.RST_FONT_SIZE)) + + with Serial(blocking=False): + with ButtonPress(): + Button(text="Skip Practice", right=self.exp.screen.width, + bottom=0, width=s(config.SKIP_SIZE[0]), + height=s(config.SKIP_SIZE[1]), blocking=False, + font_size=s(config.SKIP_FONT_SIZE)) + with Parallel(): + doc = 'remind' + title = Label(text='Memory Task Instructions', + font_size=s(config.INST_TITLE_FONT_SIZE), + text_size=(s(config.TEXT_SIZE_WIDTH), None), + top=self.exp.screen.center_y + s(415)) + Label(text=texts[doc]['text'], + text_size=(s(config.TEXT_SIZE_WIDTH), None), + font_size=s(config.INST_FONT_SIZE), + top=(title.bottom - s(10))) + + with UntilDone(): + Wait(1.0) + GetResponse(keys=texts[doc]['keys']) + Wait(2.0) diff --git a/tasks/AssBind/main.py b/tasks/AssBind/main.py index 4c1cf84..24aec29 100644 --- a/tasks/AssBind/main.py +++ b/tasks/AssBind/main.py @@ -71,9 +71,9 @@ def AssBindExp(self, config, sub_dir, task_dir=None, block=0, text_names = ['main', 'ex1', 'ex2', 'ex3', 'ex4', 'remind'] rem_names = ['remind'] with If(reminder_only): - Instruct(config=config, text_names=rem_names) + Instruct(config=config, text_names=rem_names, run_num=block) with Else(): - Instruct(config=config, text_names=text_names) + Instruct(config=config, text_names=text_names, run_num=block) Wait(1.0) diff --git a/tasks/BARTUVA/config.py b/tasks/BARTUVA/config.py index 5d2887c..a97816e 100644 --- a/tasks/BARTUVA/config.py +++ b/tasks/BARTUVA/config.py @@ -8,9 +8,9 @@ BALLOON_SETUP = [{'range': [0, 8], 'number_of_balloons':8}, {'range': [0, 16], 'number_of_balloons':8}, {'range': [8, 16], 'number_of_balloons':8}] -PRACTICE_SETUP = [{'range': [10,10], 'number_of_balloons':0}, - {'range': [3,3], 'number_of_balloons':0}, - {'range': [6,6], 'number_of_balloons':0}] +PRACTICE_SETUP = [{'range': [10,10], 'number_of_balloons':2}, + {'range': [3,3], 'number_of_balloons':2}, + {'range': [6,6], 'number_of_balloons':2}] NUM_BALLOONS = 18 NUM_BAGS = len(BALLOON_SETUP) BALLOONS_PER_BAG = NUM_BALLOONS/NUM_BAGS diff --git a/tasks/BARTUVA/instruct.py b/tasks/BARTUVA/instruct.py index 66ff31c..95f52ce 100644 --- a/tasks/BARTUVA/instruct.py +++ b/tasks/BARTUVA/instruct.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - from smile.common import * from smile.scale import scale as s from .inst.computer import computer_list @@ -10,16 +9,33 @@ import os +def get_is_first(run_num): + return run_num == 0 + +def get_practice_inst(config, run_num): + if len(config.CONT_KEY) > 1: + cont_key_str = str(config.CONT_KEY[0]) + " or " + str(config.CONT_KEY[-1]) + else: + cont_key_str = str(config.CONT_KEY[0]) + practice_inst = "You will now have a short practice bag of balloons.\n " \ + "Please note how the money in the bank drops until you" \ + " make a decision.\nPress %s to continue." % (cont_key_str) + if run_num > 0: + practice_inst += "\n You may press the button in the lower right " \ + f"corner to skip the practice." + return practice_inst @Subroutine def Instruct(self, config, run_num, sub_dir, task_dir=None, full_instructions=True, practice=True, lang="E",): + is_first = Func(get_is_first, run_num).result if len(config.CONT_KEY) > 1: cont_key_str = str(config.CONT_KEY[0]) + " or " + str(config.CONT_KEY[-1]) else: cont_key_str = str(config.CONT_KEY[0]) + practice_inst = Func(get_practice_inst, config, run_num).result if config.TOUCH: with Loop(computer_list) as instruction: txt = instruction.current @@ -51,106 +67,199 @@ def Instruct(self, config, run_num, sub_dir, task_dir=None, GetResponse(keys=config.CONT_KEY) else: - with Parallel(): - MouseCursor(blocking=False) - with Serial(blocking=False): - with If(full_instructions): - with Loop(computer_list) as instruction: - txt = instruction.current - with Parallel(): - with If((instruction.i==2)): - with Parallel(): - img2 = Image(source=config.INST2_IMG_PATH, - bottom=(self.exp.screen.height/2.) + s(50), - keep_ratio=True, allow_stretch=True, - height=s(400)) - lbl2 = Label(text=txt%(config.KEY_TEXT[0], - config.KEY_TEXT[-1]), - halign='left', top=img2.bottom-s(10), - font_size=s(config.LABEL_FONT_SIZE)) - Label(text='Press %s to continue'%(config.CONT_KEY_STR), - halign='left', - top=lbl2.bottom, - font_size=s(config.LABEL_FONT_SIZE)) - with Else(): - with Parallel(): - lbl1 = Label(text=txt, - halign='left', - font_size=s(config.LABEL_FONT_SIZE)) - Label(text='Press %s to continue'%(config.CONT_KEY_STR), - halign='left', - top=lbl1.bottom - s(75), - font_size=s(config.LABEL_FONT_SIZE)) + with If(is_first): + with Parallel(): + MouseCursor(blocking=False) + with Serial(blocking=True): + with If(full_instructions): + with Loop(computer_list) as instruction: + txt = instruction.current + with Parallel(): + with If((instruction.i==2)): + with Parallel(): + img2 = Image(source=config.INST2_IMG_PATH, + bottom=(self.exp.screen.height/2.) + s(50), + keep_ratio=True, allow_stretch=True, + height=s(400)) + lbl2 = Label(text=txt%(config.KEY_TEXT[0], + config.KEY_TEXT[-1]), + halign='left', top=img2.bottom-s(10), + font_size=s(config.LABEL_FONT_SIZE)) + Label(text='Press %s to continue'%(config.CONT_KEY_STR), + halign='left', + top=lbl2.bottom, + font_size=s(config.LABEL_FONT_SIZE)) + with Else(): + with Parallel(): + lbl1 = Label(text=txt, + halign='left', + font_size=s(config.LABEL_FONT_SIZE)) + Label(text='Press %s to continue'%(config.CONT_KEY_STR), + halign='left', + top=lbl1.bottom - s(75), + font_size=s(config.LABEL_FONT_SIZE)) + with UntilDone(): + Wait(.5) + GetResponse(keys=config.CONT_KEY) + + with If(practice): + + Label(text=practice_inst, + halign='center', + font_size=s(config.LABEL_FONT_SIZE)) with UntilDone(): Wait(.5) GetResponse(keys=config.CONT_KEY) - with If(practice): + number_of_sets = 1 + self.set_number = 0 + self.grand_total = config.GRAND_TOTAL + self.balloon_number_session = 0 + self.trkp_press_time = None + + Wait(1.) + # Loop over practice blocks + with Loop(number_of_sets): + Wait(.5, jitter=.5) + + # Calling listgen as 'bags' + bg = Func(add_air, + total_number_of_balloons=len(config.PRACTICE_SETUP) * 2, + num_ranges=len(config.PRACTICE_SETUP), + balloon_setup=config.PRACTICE_SETUP, + randomize=config.RANDOMIZE_BALLOON_NUM, + reward_low=config.REWARD_LOW, + reward_high=config.REWARD_HIGH, + subject_directory=sub_dir, + practice=True, + shuffle_bags=config.SHUFFLE_BAGS) + bags = bg.result + self.block_tic = 0 + + # with Loop(bag.current) as balloon: + with Loop(bags) as balloon: + Balloon = BARTSub(config, + log_name='bart_practice', + balloon=balloon.current, + block=self.block_tic, + set_number=self.set_number, + grand_total=self.grand_total, + balloon_number_session=self.balloon_number_session, + subject=self._exp.subject, + run_num=run_num, + trkp_press_time=self.trkp_press_time) + self.balloon_number_session += 1 + self.grand_total = Balloon.grand_total + self.block_tic += 1 + + self.set_number += 1 - Label(text="You will now have a short practice bag of balloons.\n" + - "Please note how the money in the bank drops until you" + - " make a decision.\nPress %s to continue." % (cont_key_str), - halign='center', - font_size=s(config.LABEL_FONT_SIZE)) - with UntilDone(): Wait(.5) - GetResponse(keys=config.CONT_KEY) - - number_of_sets = 1 - self.set_number = 0 - self.grand_total = config.GRAND_TOTAL - self.balloon_number_session = 0 - self.trkp_press_time = None - - Wait(1.) - # Loop over practice blocks - with Loop(number_of_sets): - Wait(.5, jitter=.5) - - # Calling listgen as 'bags' - bg = Func(add_air, - total_number_of_balloons=len(config.PRACTICE_SETUP), - num_ranges=len(config.PRACTICE_SETUP), - balloon_setup=config.PRACTICE_SETUP, - randomize=config.RANDOMIZE_BALLOON_NUM, - reward_low=config.REWARD_LOW, - reward_high=config.REWARD_HIGH, - subject_directory=sub_dir, - practice=True, - shuffle_bags=config.SHUFFLE_BAGS) - bags = bg.result - - self.block_tic = 0 - - # with Loop(bag.current) as balloon: - with Loop(bags) as balloon: - Balloon = BARTSub(config, - log_name='bart_practice', - balloon=balloon.current, - block=self.block_tic, - set_number=self.set_number, - grand_total=self.grand_total, - balloon_number_session=self.balloon_number_session, - subject=self._exp.subject, - run_num=run_num, - trkp_press_time=self.trkp_press_time) - self.balloon_number_session += 1 - self.grand_total = Balloon.grand_total - self.block_tic += 1 - - self.set_number += 1 - - Wait(.5) - Label(text='You have completed the practice.\n' + - 'Press %s to continue.' % (cont_key_str), - halign='center', - font_size=s(config.LABEL_FONT_SIZE)) - with UntilDone(): - Wait(1.5) - GetResponse(keys=config.CONT_KEY) - with Serial(blocking=False): - with ButtonPress(): - Button(text="Skip Practice", width=s(config.SKIP_SIZE[0]), - bottom=0, right=self.exp.screen.width, - height=s(config.SKIP_SIZE[1]), - font_size=s(config.SKIP_FONT_SIZE)) + Label(text='You have completed the practice.\n' + + 'Press %s to continue.' % (cont_key_str), + halign='center', + font_size=s(config.LABEL_FONT_SIZE)) + with UntilDone(): + Wait(0.5) + GetResponse(keys=config.CONT_KEY) + + with Else(): + with Parallel(): + MouseCursor(blocking=False) + with Serial(blocking=False): + with If(full_instructions): + with Loop(computer_list) as instruction: + txt = instruction.current + with Parallel(): + with If((instruction.i == 2)): + with Parallel(): + img2 = Image(source=config.INST2_IMG_PATH, + bottom=(self.exp.screen.height / 2.) + s(50), + keep_ratio=True, allow_stretch=True, + height=s(400)) + lbl2 = Label(text=txt % (config.KEY_TEXT[0], + config.KEY_TEXT[-1]), + halign='left', top=img2.bottom - s(10), + font_size=s(config.LABEL_FONT_SIZE)) + Label(text='Press %s to continue' % (config.CONT_KEY_STR), + halign='left', + top=lbl2.bottom, + font_size=s(config.LABEL_FONT_SIZE)) + with Else(): + with Parallel(): + lbl1 = Label(text=txt, + halign='left', + font_size=s(config.LABEL_FONT_SIZE)) + Label(text='Press %s to continue' % (config.CONT_KEY_STR), + halign='left', + top=lbl1.bottom - s(75), + font_size=s(config.LABEL_FONT_SIZE)) + with UntilDone(): + Wait(.5) + GetResponse(keys=config.CONT_KEY) + + with If(practice): + Label(text=practice_inst, + halign='center', + font_size=s(config.LABEL_FONT_SIZE)) + with UntilDone(): + Wait(.5) + GetResponse(keys=config.CONT_KEY) + + number_of_sets = 1 + self.set_number = 0 + self.grand_total = config.GRAND_TOTAL + self.balloon_number_session = 0 + self.trkp_press_time = None + + Wait(1.) + # Loop over practice blocks + with Loop(number_of_sets): + Wait(.5, jitter=.5) + + # Calling listgen as 'bags' + bg = Func(add_air, + total_number_of_balloons=len(config.PRACTICE_SETUP) * 2, + num_ranges=len(config.PRACTICE_SETUP), + balloon_setup=config.PRACTICE_SETUP, + randomize=config.RANDOMIZE_BALLOON_NUM, + reward_low=config.REWARD_LOW, + reward_high=config.REWARD_HIGH, + subject_directory=sub_dir, + practice=True, + shuffle_bags=config.SHUFFLE_BAGS) + bags = bg.result + self.block_tic = 0 + + # with Loop(bag.current) as balloon: + with Loop(bags) as balloon: + Balloon = BARTSub(config, + log_name='bart_practice', + balloon=balloon.current, + block=self.block_tic, + set_number=self.set_number, + grand_total=self.grand_total, + balloon_number_session=self.balloon_number_session, + subject=self._exp.subject, + run_num=run_num, + trkp_press_time=self.trkp_press_time) + self.balloon_number_session += 1 + self.grand_total = Balloon.grand_total + self.block_tic += 1 + + self.set_number += 1 + + Wait(.5) + Label(text='You have completed the practice.\n' + + 'Press %s to continue.' % (cont_key_str), + halign='center', + font_size=s(config.LABEL_FONT_SIZE)) + with UntilDone(): + Wait(0.5) + GetResponse(keys=config.CONT_KEY) + with Serial(blocking=False): + with ButtonPress(): + Button(text="Skip Practice", width=s(config.SKIP_SIZE[0]), + bottom=0, right=self.exp.screen.width, + height=s(config.SKIP_SIZE[1]), + font_size=s(config.SKIP_FONT_SIZE)) diff --git a/tasks/BARTUVA/list_gen.py b/tasks/BARTUVA/list_gen.py index 19bad5e..86076b7 100644 --- a/tasks/BARTUVA/list_gen.py +++ b/tasks/BARTUVA/list_gen.py @@ -43,7 +43,7 @@ def add_air(total_number_of_balloons,num_ranges,balloon_setup,randomize,reward_l colors = ["red", "orange", "yellow", "green", "lime", "mustard", "salmon", "purple", "lavender", "navy", "blue", "maroon"] random.shuffle(colors) if practice == True: - colors = ["practice"] + colors = ["practice", "pink", "teal"] for balloon_set in x: limits=balloon_set['range'] diff --git a/tasks/BARTUVA/main.py b/tasks/BARTUVA/main.py index 62967ad..d2da3ab 100644 --- a/tasks/BARTUVA/main.py +++ b/tasks/BARTUVA/main.py @@ -56,7 +56,8 @@ def BartuvaExp(self, num_balloons = config.NUM_BALLOONS Label(text='You will now begin the balloon task.' + - '\nPress %s to continue.' % (cont_key_str), + '\nOnce you press %s, the task will begin. Get ready!' % (cont_key_str) + + '\nPress %s to start the task.' % (cont_key_str), halign='center', font_size=s(config.LABEL_FONT_SIZE)) with UntilDone(): diff --git a/tasks/flanker/instruct.py b/tasks/flanker/instruct.py index 6be87c0..97c54b0 100644 --- a/tasks/flanker/instruct.py +++ b/tasks/flanker/instruct.py @@ -10,7 +10,10 @@ from math import cos, sin, sqrt, pi, radians -def get_instructions(config): +def get_is_first(run_num): + return run_num == 0 + +def get_instructions(config, run_num): if len(config.CONT_KEY) > 1: cont_key = str(config.CONT_KEY[0]) + " or " + str(config.CONT_KEY[-1]) else: @@ -21,7 +24,9 @@ def get_instructions(config): inst['top_text'] = 'You will be presented with a group of symbols. \n' + \ 'You will be asked to indicate the direction that the \n' + \ '[b]middle symbol is pointing[/b], while ignoring any other symbols. \n\n' - + if run_num > 0: + inst['top_text'] += "You may press the button in the lower right " \ + "corner to skip the practice \n\n." inst['inst_1'] = '[b]Practice 1:[/b] \n \n' + \ 'Respond to the arrow in the red circle while ignoring the other symbols. \n' @@ -66,255 +71,491 @@ def get_instructions(config): @Subroutine -def Instruct(self, config, lang="E"): - - inst = Func(get_instructions, config).result - - # with If(practice==True): - with Parallel(): - if not config.TOUCH: - MouseCursor(blocking=False) - with Serial(blocking=False): - with Parallel(): - toplbl = Label(text=inst['top_text'], - markup=True, - halign='center', +def Instruct(self, config, run_num, lang="E"): + + inst = Func(get_instructions, config, run_num).result + is_first = Func(get_is_first, run_num).result + + with If(is_first): + with Parallel(): + if not config.TOUCH: + MouseCursor(blocking=False) + with Serial(blocking=True): + with Parallel(): + toplbl = Label(text=inst['top_text'], + markup=True, + halign='center', + center_x=self.exp.screen.center_x, + center_y=self.exp.screen.center_y, + font_size=s(config.INST_FONT_SIZE)) + + # upper left + Flanker(config, center_x=self.exp.screen.center_x - s(400), + center_y=toplbl.top + s(150), + direction = "left", + condition = "+", + layers = config.LAYERS, + background = False) + + #stim="__<__\n_<<<_\n<<<<<\n_<<<_\n__<__\n") + # upper middle + Flanker(config, center_x=self.exp.screen.center_x, + center_y=toplbl.top + s(150), + direction = "left", + condition = "=", + layers = config.LAYERS, + background = False) + + #stim="__>__\n_><>_\n><<<>\n_><>_\n__>__\n") + # upper right + Flanker(config, center_x=self.exp.screen.center_x + s(400), + center_y=toplbl.top + s(150), + direction = "left", + condition = "~", + layers = config.LAYERS, + background = False) + + + #stim="__<__\n_<><_\n<><><\n_<><_\n__<__\n") + + # lower left + Flanker(config, center_x=self.exp.screen.center_x - s(400), + center_y=toplbl.bottom - s(150), + direction = "right", + condition = "+", + layers = config.LAYERS, + background = False) + # stim="__<__\n_<><_\n<><><\n_<><_\n__<__\n") + # WONDERING IF THIS IS AN ERROR BECAUSE IT SHOWS THE SAME ONE TWICE, I DIDN'T WRITE THIS PART + # lower middle + Flanker(config, center_x=self.exp.screen.center_x, + center_y=toplbl.bottom - s(150), + direction = "right", + condition = "=", + layers = config.LAYERS, + background = False) + # stim="__>__\n_><>_\n><><>\n_><>_\n__>__\n") + # lower right + Flanker(config, center_x=self.exp.screen.center_x + s(400), + center_y=toplbl.bottom - s(150), + direction = "right", + condition = "~", + layers = config.LAYERS, + background = False) + # stim="__<__\n_<><_\n<>>><\n_<><_\n__<__\n") + + with UntilDone(): + Wait(until=toplbl.appear_time) + GetResponse(keys=config.CONT_KEY) + + Wait(1.0) + + with Loop([["left", config.RESP_KEYS[0]], + ["left", config.RESP_KEYS[0]], + ["right", config.RESP_KEYS[-1]], + ["right", config.RESP_KEYS[-1]]]) as prac_ev: + p2 = Trial(config, + direct=prac_ev.current[0], center_x=self.exp.screen.center_x, center_y=self.exp.screen.center_y, - font_size=s(config.INST_FONT_SIZE)) - - # upper left - Flanker(config, center_x=self.exp.screen.center_x - s(400), - center_y=toplbl.top + s(150), - direction = "left", - condition = "+", - layers = config.LAYERS, - background = False) - - #stim="__<__\n_<<<_\n<<<<<\n_<<<_\n__<__\n") - # upper middle - Flanker(config, center_x=self.exp.screen.center_x, - center_y=toplbl.top + s(150), - direction = "left", - condition = "=", - layers = config.LAYERS, - background = False) - - #stim="__>__\n_><>_\n><<<>\n_><>_\n__>__\n") - # upper right - Flanker(config, center_x=self.exp.screen.center_x + s(400), - center_y=toplbl.top + s(150), - direction = "left", - condition = "~", - layers = config.LAYERS, - background = False) - - - #stim="__<__\n_<><_\n<><><\n_<><_\n__<__\n") - - # lower left - Flanker(config, center_x=self.exp.screen.center_x - s(400), - center_y=toplbl.bottom - s(150), - direction = "right", - condition = "+", - layers = config.LAYERS, - background = False) - # stim="__<__\n_<><_\n<><><\n_<><_\n__<__\n") - # WONDERING IF THIS IS AN ERROR BECAUSE IT SHOWS THE SAME ONE TWICE, I DIDN'T WRITE THIS PART - # lower middle - Flanker(config, center_x=self.exp.screen.center_x, - center_y=toplbl.bottom - s(150), - direction = "right", - condition = "=", - layers = config.LAYERS, - background = False) - # stim="__>__\n_><>_\n><><>\n_><>_\n__>__\n") - # lower right - Flanker(config, center_x=self.exp.screen.center_x + s(400), - center_y=toplbl.bottom - s(150), - direction = "right", - condition = "~", - layers = config.LAYERS, - background = False) - # stim="__<__\n_<><_\n<>>><\n_<><_\n__<__\n") - - with UntilDone(): - Wait(until=toplbl.appear_time) - GetResponse(keys=config.CONT_KEY) - - Wait(1.0) - - with Loop([["left", config.RESP_KEYS[0]], - ["left", config.RESP_KEYS[0]], - ["right", config.RESP_KEYS[-1]], - ["right", config.RESP_KEYS[-1]]]) as prac_ev: - p2 = Trial(config, - direct=prac_ev.current[0], - center_x=self.exp.screen.center_x, - center_y=self.exp.screen.center_y, - correct_resp=prac_ev.current[1], condition='+', - background = False) - with If(p2.correct): - # They got it right - Label(text=u"\u2713", color='lime', duration=config.FEEDBACK_TIME, - font_size=s(config.FEEDBACK_FONT_SIZE), - font_name='DejaVuSans.ttf') - with Else(): - # they got it wrong - Label(text=u"\u2717", color='red', - font_size=s(config.FEEDBACK_FONT_SIZE), - duration=config.FEEDBACK_TIME, font_name='DejaVuSans.ttf') - - with Meanwhile(): - with Parallel(): - Ellipse(color='red', size=(s(55),s(55))) - Ellipse(color=config.INNER_CIRCLE_COLOR, size=(s(45),s(45))) - Label(text=inst['inst_1'], - markup=True, - halign='center', - center_x=self.exp.screen.center_x, - center_y=self.exp.screen.center_y + s(300), - font_size=s(config.INST_FONT_SIZE)) - - Wait(1.0) - Label(text=inst['inst_2'], - markup=True, - halign='center', - center_x=self.exp.screen.center_x, - center_y=self.exp.screen.center_y + s(300), - font_size=s(config.INST_FONT_SIZE)) - with UntilDone(): - GetResponse(keys=config.CONT_KEY) - - - with Loop([["right", config.RESP_KEYS[1], - cos(radians((360./config.NUM_LOCS)*5)), sin(radians((360./config.NUM_LOCS)*5))], - ["left", config.RESP_KEYS[0], - cos(radians((360./config.NUM_LOCS)*1)), sin(radians((360./config.NUM_LOCS)*1))], - ["right", config.RESP_KEYS[1], - cos(radians((360./config.NUM_LOCS)*3.)), sin(radians((360./config.NUM_LOCS)*3.))], - ["right", config.RESP_KEYS[1], - cos(radians((360./config.NUM_LOCS)*4.)), sin(radians((360./config.NUM_LOCS)*4.))], - ["right", config.RESP_KEYS[1], - cos(radians((360./config.NUM_LOCS)*0)), sin(radians((360./config.NUM_LOCS)*0))], - ["left", config.RESP_KEYS[0], - cos(radians((360./config.NUM_LOCS)*2)), sin(radians((360./config.NUM_LOCS)*2))] - ]) as prac_ev: - # Wait(1.0) - with Parallel(): - Background = Image(source = config.BACKGROUND_IMAGE, size = (self.exp.screen.size[0] * 1.1, - self.exp.screen.size[1] * 1.1), - allow_stretch = True, keep_ratio = False, blocking = False) - fix = Label(text='+', color=config.CROSS_COLOR, - font_size=s(config.CROSS_FONTSIZE), blocking = False) - Ellipse(color='red', size=(s(55),s(55)), - center_x=self.exp.screen.center_x + prac_ev.current[2]*s(config.FROM_CENTER), - center_y=self.exp.screen.center_y + prac_ev.current[3]*s(config.FROM_CENTER), - blocking=False) - Ellipse(color=config.INNER_CIRCLE_COLOR, size=(s(45),s(45)), - center_x=self.exp.screen.center_x + prac_ev.current[2]*s(config.FROM_CENTER), - center_y=self.exp.screen.center_y + prac_ev.current[3]*s(config.FROM_CENTER), - blocking=False) - p4 = Trial(config,direct=prac_ev.current[0], - center_x=self.exp.screen.center_x + prac_ev.current[2]*s(config.FROM_CENTER), - center_y=self.exp.screen.center_y + prac_ev.current[3]*s(config.FROM_CENTER), correct_resp=prac_ev.current[1], condition='+', background = False) - with If(p4.correct): - with Parallel(): - # They got it right - Background = Image(source = config.BACKGROUND_IMAGE, size = (self.exp.screen.size[0] * 1.1, - self.exp.screen.size[1] * 1.1), - allow_stretch = True, keep_ratio = False, blocking = False) + with If(p2.correct): + # They got it right Label(text=u"\u2713", color='lime', duration=config.FEEDBACK_TIME, - font_size=s(config.FEEDBACK_FONT_SIZE), - font_name='DejaVuSans.ttf') - - with Else(): - with Parallel(): - Background = Image(source = config.BACKGROUND_IMAGE, size = (self.exp.screen.size[0] * 1.1, - self.exp.screen.size[1] * 1.1), - allow_stretch = True, keep_ratio = False, blocking = False) - # they got it wrong + font_size=s(config.FEEDBACK_FONT_SIZE), + font_name='DejaVuSans.ttf') + with Else(): + # they got it wrong Label(text=u"\u2717", color='red', - font_size=s(config.FEEDBACK_FONT_SIZE), - duration=config.FEEDBACK_TIME, font_name='DejaVuSans.ttf') - - - Label(text=inst['to_cont'], - halign='center', - center_x=self.exp.screen.center_x, - center_y=self.exp.screen.center_y, - font_size=s(config.INST_FONT_SIZE)) - with UntilDone(): - GetResponse(keys=config.CONT_KEY) - - - Wait(1.0) - Label(text=inst['inst_3'], - markup=True, - halign='center', - center_x=self.exp.screen.center_x, - center_y=self.exp.screen.center_y + s(200), - font_size=s(config.INST_FONT_SIZE)) - with UntilDone(): - GetResponse(keys=config.CONT_KEY) - - - with Loop([["right", config.RESP_KEYS[1], - cos(radians((360./config.NUM_LOCS)*5)), sin(radians((360./config.NUM_LOCS)*5))], - ["left", config.RESP_KEYS[0], - cos(radians((360./config.NUM_LOCS)*1)), sin(radians((360./config.NUM_LOCS)*1))], - ["right", config.RESP_KEYS[1], - cos(radians((360./config.NUM_LOCS)*3)), sin(radians((360./config.NUM_LOCS)*3))], - ["right", config.RESP_KEYS[1], - cos(radians((360./config.NUM_LOCS)*6)), sin(radians((360./config.NUM_LOCS)*6))], - ["left", config.RESP_KEYS[0], - cos(radians((360./config.NUM_LOCS)*2)), sin(radians((360./config.NUM_LOCS)*2))] - ]) as prac_ev: - # Wait(1.0) - with Parallel(): - Background = Image(source = config.BACKGROUND_IMAGE, size = (self.exp.screen.size[0] * 1.1, - self.exp.screen.size[1] * 1.1), - allow_stretch = True, keep_ratio = False, blocking = False) - fix = Label(text='+', color=config.CROSS_COLOR, - font_size=s(config.CROSS_FONTSIZE), + font_size=s(config.FEEDBACK_FONT_SIZE), + duration=config.FEEDBACK_TIME, font_name='DejaVuSans.ttf') + + with Meanwhile(): + with Parallel(): + Ellipse(color='red', size=(s(55),s(55))) + Ellipse(color=config.INNER_CIRCLE_COLOR, size=(s(45),s(45))) + Label(text=inst['inst_1'], + markup=True, + halign='center', + center_x=self.exp.screen.center_x, + center_y=self.exp.screen.center_y + s(300), + font_size=s(config.INST_FONT_SIZE)) + + Wait(1.0) + Label(text=inst['inst_2'], + markup=True, + halign='center', + center_x=self.exp.screen.center_x, + center_y=self.exp.screen.center_y + s(300), + font_size=s(config.INST_FONT_SIZE)) + with UntilDone(): + GetResponse(keys=config.CONT_KEY) + + + with Loop([["right", config.RESP_KEYS[1], + cos(radians((360./config.NUM_LOCS)*5)), sin(radians((360./config.NUM_LOCS)*5))], + ["left", config.RESP_KEYS[0], + cos(radians((360./config.NUM_LOCS)*1)), sin(radians((360./config.NUM_LOCS)*1))], + ["right", config.RESP_KEYS[1], + cos(radians((360./config.NUM_LOCS)*3.)), sin(radians((360./config.NUM_LOCS)*3.))], + ["right", config.RESP_KEYS[1], + cos(radians((360./config.NUM_LOCS)*4.)), sin(radians((360./config.NUM_LOCS)*4.))], + ["right", config.RESP_KEYS[1], + cos(radians((360./config.NUM_LOCS)*0)), sin(radians((360./config.NUM_LOCS)*0))], + ["left", config.RESP_KEYS[0], + cos(radians((360./config.NUM_LOCS)*2)), sin(radians((360./config.NUM_LOCS)*2))] + ]) as prac_ev: + # Wait(1.0) + with Parallel(): + Background = Image(source = config.BACKGROUND_IMAGE, size = (self.exp.screen.size[0] * 1.1, + self.exp.screen.size[1] * 1.1), + allow_stretch = True, keep_ratio = False, blocking = False) + fix = Label(text='+', color=config.CROSS_COLOR, + font_size=s(config.CROSS_FONTSIZE), blocking = False) + Ellipse(color='red', size=(s(55),s(55)), + center_x=self.exp.screen.center_x + prac_ev.current[2]*s(config.FROM_CENTER), + center_y=self.exp.screen.center_y + prac_ev.current[3]*s(config.FROM_CENTER), blocking=False) - p5 = Trial(config, direct=prac_ev.current[0], - center_x=self.exp.screen.center_x + prac_ev.current[2]*s(config.FROM_CENTER), - center_y=self.exp.screen.center_y + prac_ev.current[3]*s(config.FROM_CENTER), - correct_resp=prac_ev.current[1], condition='+', - background = False) - - with If(p5.correct): - # They got it right + Ellipse(color=config.INNER_CIRCLE_COLOR, size=(s(45),s(45)), + center_x=self.exp.screen.center_x + prac_ev.current[2]*s(config.FROM_CENTER), + center_y=self.exp.screen.center_y + prac_ev.current[3]*s(config.FROM_CENTER), + blocking=False) + p4 = Trial(config,direct=prac_ev.current[0], + center_x=self.exp.screen.center_x + prac_ev.current[2]*s(config.FROM_CENTER), + center_y=self.exp.screen.center_y + prac_ev.current[3]*s(config.FROM_CENTER), + correct_resp=prac_ev.current[1], condition='+', + background = False) + with If(p4.correct): + with Parallel(): + # They got it right + Background = Image(source = config.BACKGROUND_IMAGE, size = (self.exp.screen.size[0] * 1.1, + self.exp.screen.size[1] * 1.1), + allow_stretch = True, keep_ratio = False, blocking = False) + Label(text=u"\u2713", color='lime', duration=config.FEEDBACK_TIME, + font_size=s(config.FEEDBACK_FONT_SIZE), + font_name='DejaVuSans.ttf') + + with Else(): + with Parallel(): + Background = Image(source = config.BACKGROUND_IMAGE, size = (self.exp.screen.size[0] * 1.1, + self.exp.screen.size[1] * 1.1), + allow_stretch = True, keep_ratio = False, blocking = False) + # they got it wrong + Label(text=u"\u2717", color='red', + font_size=s(config.FEEDBACK_FONT_SIZE), + duration=config.FEEDBACK_TIME, font_name='DejaVuSans.ttf') + + + Label(text=inst['to_cont'], + halign='center', + center_x=self.exp.screen.center_x, + center_y=self.exp.screen.center_y, + font_size=s(config.INST_FONT_SIZE)) + with UntilDone(): + GetResponse(keys=config.CONT_KEY) + + + Wait(1.0) + Label(text=inst['inst_3'], + markup=True, + halign='center', + center_x=self.exp.screen.center_x, + center_y=self.exp.screen.center_y + s(200), + font_size=s(config.INST_FONT_SIZE)) + with UntilDone(): + GetResponse(keys=config.CONT_KEY) + + + with Loop([["right", config.RESP_KEYS[1], + cos(radians((360./config.NUM_LOCS)*5)), sin(radians((360./config.NUM_LOCS)*5))], + ["left", config.RESP_KEYS[0], + cos(radians((360./config.NUM_LOCS)*1)), sin(radians((360./config.NUM_LOCS)*1))], + ["right", config.RESP_KEYS[1], + cos(radians((360./config.NUM_LOCS)*3)), sin(radians((360./config.NUM_LOCS)*3))], + ["right", config.RESP_KEYS[1], + cos(radians((360./config.NUM_LOCS)*6)), sin(radians((360./config.NUM_LOCS)*6))], + ["left", config.RESP_KEYS[0], + cos(radians((360./config.NUM_LOCS)*2)), sin(radians((360./config.NUM_LOCS)*2))] + ]) as prac_ev: + # Wait(1.0) with Parallel(): - Background = Image(source = config.BACKGROUND_IMAGE, size = (self.exp.screen.size[0] * 1.1, - self.exp.screen.size[1] * 1.1), - allow_stretch = True, keep_ratio = False, blocking = False) + Background = Image(source = config.BACKGROUND_IMAGE, size = (self.exp.screen.size[0] * 1.1, + self.exp.screen.size[1] * 1.1), + allow_stretch = True, keep_ratio = False, blocking = False) + fix = Label(text='+', color=config.CROSS_COLOR, + font_size=s(config.CROSS_FONTSIZE), + blocking=False) + p5 = Trial(config, direct=prac_ev.current[0], + center_x=self.exp.screen.center_x + prac_ev.current[2]*s(config.FROM_CENTER), + center_y=self.exp.screen.center_y + prac_ev.current[3]*s(config.FROM_CENTER), + correct_resp=prac_ev.current[1], condition='+', + background = False) + + with If(p5.correct): + # They got it right + with Parallel(): + Background = Image(source = config.BACKGROUND_IMAGE, size = (self.exp.screen.size[0] * 1.1, + self.exp.screen.size[1] * 1.1), + allow_stretch = True, keep_ratio = False, blocking = False) + Label(text=u"\u2713", color='lime', duration=config.FEEDBACK_TIME, + font_size=s(config.FEEDBACK_FONT_SIZE), + center_y=self.exp.screen.center_y + s(50), + font_name='DejaVuSans.ttf') + with Else(): + # they got it wrong + with Parallel(): + Background = Image(source = config.BACKGROUND_IMAGE, size = (self.exp.screen.size[0] * 1.1, + self.exp.screen.size[1] * 1.1), + allow_stretch = True, keep_ratio = False, blocking = False) + Label(text=u"\u2717", color='red', + font_size=s(config.FEEDBACK_FONT_SIZE), + center_y=self.exp.screen.center_y + s(50), + duration=config.FEEDBACK_TIME, font_name='DejaVuSans.ttf') + with Meanwhile(): + Label(text="+", font_size=s(config.ORIENT_FONT_SIZE)) + + with Else(): + with Parallel(): + if not config.TOUCH: + MouseCursor(blocking=False) + with Serial(blocking=False): + with Parallel(): + toplbl = Label(text=inst['top_text'], + markup=True, + halign='center', + center_x=self.exp.screen.center_x, + center_y=self.exp.screen.center_y, + font_size=s(config.INST_FONT_SIZE)) + + # upper left + Flanker(config, center_x=self.exp.screen.center_x - s(400), + center_y=toplbl.top + s(150), + direction="left", + condition="+", + layers=config.LAYERS, + background=False) + + # stim="__<__\n_<<<_\n<<<<<\n_<<<_\n__<__\n") + # upper middle + Flanker(config, center_x=self.exp.screen.center_x, + center_y=toplbl.top + s(150), + direction="left", + condition="=", + layers=config.LAYERS, + background=False) + + # stim="__>__\n_><>_\n><<<>\n_><>_\n__>__\n") + # upper right + Flanker(config, center_x=self.exp.screen.center_x + s(400), + center_y=toplbl.top + s(150), + direction="left", + condition="~", + layers=config.LAYERS, + background=False) + + # stim="__<__\n_<><_\n<><><\n_<><_\n__<__\n") + + # lower left + Flanker(config, center_x=self.exp.screen.center_x - s(400), + center_y=toplbl.bottom - s(150), + direction="right", + condition="+", + layers=config.LAYERS, + background=False) + # stim="__<__\n_<><_\n<><><\n_<><_\n__<__\n") + # WONDERING IF THIS IS AN ERROR BECAUSE IT SHOWS THE SAME ONE TWICE, I DIDN'T WRITE THIS PART + # lower middle + Flanker(config, center_x=self.exp.screen.center_x, + center_y=toplbl.bottom - s(150), + direction="right", + condition="=", + layers=config.LAYERS, + background=False) + # stim="__>__\n_><>_\n><><>\n_><>_\n__>__\n") + # lower right + Flanker(config, center_x=self.exp.screen.center_x + s(400), + center_y=toplbl.bottom - s(150), + direction="right", + condition="~", + layers=config.LAYERS, + background=False) + # stim="__<__\n_<><_\n<>>><\n_<><_\n__<__\n") + + with UntilDone(): + Wait(until=toplbl.appear_time) + GetResponse(keys=config.CONT_KEY) + + Wait(1.0) + + with Loop([["left", config.RESP_KEYS[0]], + ["left", config.RESP_KEYS[0]], + ["right", config.RESP_KEYS[-1]], + ["right", config.RESP_KEYS[-1]]]) as prac_ev: + p2 = Trial(config, + direct=prac_ev.current[0], + center_x=self.exp.screen.center_x, + center_y=self.exp.screen.center_y, + correct_resp=prac_ev.current[1], condition='+', + background=False) + with If(p2.correct): + # They got it right Label(text=u"\u2713", color='lime', duration=config.FEEDBACK_TIME, - font_size=s(config.FEEDBACK_FONT_SIZE), - center_y=self.exp.screen.center_y + s(50), - font_name='DejaVuSans.ttf') - with Else(): - # they got it wrong - with Parallel(): - Background = Image(source = config.BACKGROUND_IMAGE, size = (self.exp.screen.size[0] * 1.1, - self.exp.screen.size[1] * 1.1), - allow_stretch = True, keep_ratio = False, blocking = False) + font_size=s(config.FEEDBACK_FONT_SIZE), + font_name='DejaVuSans.ttf') + with Else(): + # they got it wrong Label(text=u"\u2717", color='red', - font_size=s(config.FEEDBACK_FONT_SIZE), - center_y=self.exp.screen.center_y + s(50), - duration=config.FEEDBACK_TIME, font_name='DejaVuSans.ttf') - with Meanwhile(): - Label(text="+", font_size=s(config.ORIENT_FONT_SIZE)) - - with Serial(blocking=False): - with ButtonPress(): - Button(text=inst['skip_text'], right=self.exp.screen.width, - bottom=0, width=s(config.SKIP_SIZE[0]), - height=s(config.SKIP_SIZE[1]), blocking=False, - font_size=s(config.SKIP_FONT_SIZE)) + font_size=s(config.FEEDBACK_FONT_SIZE), + duration=config.FEEDBACK_TIME, font_name='DejaVuSans.ttf') + + with Meanwhile(): + with Parallel(): + Ellipse(color='red', size=(s(55), s(55))) + Ellipse(color=config.INNER_CIRCLE_COLOR, size=(s(45), s(45))) + Label(text=inst['inst_1'], + markup=True, + halign='center', + center_x=self.exp.screen.center_x, + center_y=self.exp.screen.center_y + s(300), + font_size=s(config.INST_FONT_SIZE)) + + Wait(1.0) + Label(text=inst['inst_2'], + markup=True, + halign='center', + center_x=self.exp.screen.center_x, + center_y=self.exp.screen.center_y + s(300), + font_size=s(config.INST_FONT_SIZE)) + with UntilDone(): + GetResponse(keys=config.CONT_KEY) + + with Loop([["right", config.RESP_KEYS[1], + cos(radians((360. / config.NUM_LOCS) * 5)), sin(radians((360. / config.NUM_LOCS) * 5))], + ["left", config.RESP_KEYS[0], + cos(radians((360. / config.NUM_LOCS) * 1)), sin(radians((360. / config.NUM_LOCS) * 1))], + ["right", config.RESP_KEYS[1], + cos(radians((360. / config.NUM_LOCS) * 3.)), sin(radians((360. / config.NUM_LOCS) * 3.))], + ["right", config.RESP_KEYS[1], + cos(radians((360. / config.NUM_LOCS) * 4.)), sin(radians((360. / config.NUM_LOCS) * 4.))], + ["right", config.RESP_KEYS[1], + cos(radians((360. / config.NUM_LOCS) * 0)), sin(radians((360. / config.NUM_LOCS) * 0))], + ["left", config.RESP_KEYS[0], + cos(radians((360. / config.NUM_LOCS) * 2)), sin(radians((360. / config.NUM_LOCS) * 2))] + ]) as prac_ev: + # Wait(1.0) + with Parallel(): + Background = Image(source=config.BACKGROUND_IMAGE, size=(self.exp.screen.size[0] * 1.1, + self.exp.screen.size[1] * 1.1), + allow_stretch=True, keep_ratio=False, blocking=False) + fix = Label(text='+', color=config.CROSS_COLOR, + font_size=s(config.CROSS_FONTSIZE), blocking=False) + Ellipse(color='red', size=(s(55), s(55)), + center_x=self.exp.screen.center_x + prac_ev.current[2] * s(config.FROM_CENTER), + center_y=self.exp.screen.center_y + prac_ev.current[3] * s(config.FROM_CENTER), + blocking=False) + Ellipse(color=config.INNER_CIRCLE_COLOR, size=(s(45), s(45)), + center_x=self.exp.screen.center_x + prac_ev.current[2] * s(config.FROM_CENTER), + center_y=self.exp.screen.center_y + prac_ev.current[3] * s(config.FROM_CENTER), + blocking=False) + p4 = Trial(config, direct=prac_ev.current[0], + center_x=self.exp.screen.center_x + prac_ev.current[2] * s(config.FROM_CENTER), + center_y=self.exp.screen.center_y + prac_ev.current[3] * s(config.FROM_CENTER), + correct_resp=prac_ev.current[1], condition='+', + background=False) + with If(p4.correct): + with Parallel(): + # They got it right + Background = Image(source=config.BACKGROUND_IMAGE, size=(self.exp.screen.size[0] * 1.1, + self.exp.screen.size[1] * 1.1), + allow_stretch=True, keep_ratio=False, blocking=False) + Label(text=u"\u2713", color='lime', duration=config.FEEDBACK_TIME, + font_size=s(config.FEEDBACK_FONT_SIZE), + font_name='DejaVuSans.ttf') + + with Else(): + with Parallel(): + Background = Image(source=config.BACKGROUND_IMAGE, size=(self.exp.screen.size[0] * 1.1, + self.exp.screen.size[1] * 1.1), + allow_stretch=True, keep_ratio=False, blocking=False) + # they got it wrong + Label(text=u"\u2717", color='red', + font_size=s(config.FEEDBACK_FONT_SIZE), + duration=config.FEEDBACK_TIME, font_name='DejaVuSans.ttf') + + Label(text=inst['to_cont'], + halign='center', + center_x=self.exp.screen.center_x, + center_y=self.exp.screen.center_y, + font_size=s(config.INST_FONT_SIZE)) + with UntilDone(): + GetResponse(keys=config.CONT_KEY) + + Wait(1.0) + Label(text=inst['inst_3'], + markup=True, + halign='center', + center_x=self.exp.screen.center_x, + center_y=self.exp.screen.center_y + s(200), + font_size=s(config.INST_FONT_SIZE)) + with UntilDone(): + GetResponse(keys=config.CONT_KEY) + + with Loop([["right", config.RESP_KEYS[1], + cos(radians((360. / config.NUM_LOCS) * 5)), sin(radians((360. / config.NUM_LOCS) * 5))], + ["left", config.RESP_KEYS[0], + cos(radians((360. / config.NUM_LOCS) * 1)), sin(radians((360. / config.NUM_LOCS) * 1))], + ["right", config.RESP_KEYS[1], + cos(radians((360. / config.NUM_LOCS) * 3)), sin(radians((360. / config.NUM_LOCS) * 3))], + ["right", config.RESP_KEYS[1], + cos(radians((360. / config.NUM_LOCS) * 6)), sin(radians((360. / config.NUM_LOCS) * 6))], + ["left", config.RESP_KEYS[0], + cos(radians((360. / config.NUM_LOCS) * 2)), sin(radians((360. / config.NUM_LOCS) * 2))] + ]) as prac_ev: + # Wait(1.0) + with Parallel(): + Background = Image(source=config.BACKGROUND_IMAGE, size=(self.exp.screen.size[0] * 1.1, + self.exp.screen.size[1] * 1.1), + allow_stretch=True, keep_ratio=False, blocking=False) + fix = Label(text='+', color=config.CROSS_COLOR, + font_size=s(config.CROSS_FONTSIZE), + blocking=False) + p5 = Trial(config, direct=prac_ev.current[0], + center_x=self.exp.screen.center_x + prac_ev.current[2] * s(config.FROM_CENTER), + center_y=self.exp.screen.center_y + prac_ev.current[3] * s(config.FROM_CENTER), + correct_resp=prac_ev.current[1], condition='+', + background=False) + + with If(p5.correct): + # They got it right + with Parallel(): + Background = Image(source=config.BACKGROUND_IMAGE, size=(self.exp.screen.size[0] * 1.1, + self.exp.screen.size[1] * 1.1), + allow_stretch=True, keep_ratio=False, blocking=False) + Label(text=u"\u2713", color='lime', duration=config.FEEDBACK_TIME, + font_size=s(config.FEEDBACK_FONT_SIZE), + center_y=self.exp.screen.center_y + s(50), + font_name='DejaVuSans.ttf') + with Else(): + # they got it wrong + with Parallel(): + Background = Image(source=config.BACKGROUND_IMAGE, size=(self.exp.screen.size[0] * 1.1, + self.exp.screen.size[1] * 1.1), + allow_stretch=True, keep_ratio=False, blocking=False) + Label(text=u"\u2717", color='red', + font_size=s(config.FEEDBACK_FONT_SIZE), + center_y=self.exp.screen.center_y + s(50), + duration=config.FEEDBACK_TIME, font_name='DejaVuSans.ttf') + with Meanwhile(): + Label(text="+", font_size=s(config.ORIENT_FONT_SIZE)) + + with Serial(blocking=False): + with ButtonPress(): + Button(text=inst['skip_text'], right=self.exp.screen.width, + bottom=0, width=s(config.SKIP_SIZE[0]), + height=s(config.SKIP_SIZE[1]), blocking=False, + font_size=s(config.SKIP_FONT_SIZE)) + Wait(1.0) @@ -325,3 +566,4 @@ def Instruct(self, config, lang="E"): font_size=s(config.INST_FONT_SIZE)) with UntilDone(): GetResponse(keys=config.CONT_KEY) + diff --git a/tasks/flanker/main.py b/tasks/flanker/main.py index 53e3f85..34825f0 100644 --- a/tasks/flanker/main.py +++ b/tasks/flanker/main.py @@ -44,7 +44,15 @@ def FlankerExp(self, config, run_num=0, lang="E", pulse_server=None, #date_time=version.__date__, #email=version.__email__) - Instruct(config, lang=lang) + Instruct(config, run_num, lang=lang) + Label(text='You will now begin the fish task.' + + '\nOnce you press %s, the task will begin. Get ready!' % (cont_key_str) + + '\nPress %s to start the task.' % (cont_key_str), + halign='center', + font_size=s(config.FINAL_FONT_SIZE)) + with UntilDone(): + Wait(.5) + GetResponse(keys=config.CONT_KEY) Wait(2.0) self.trials_corr = 0.