diff --git a/package/NIMHCogMood.spec b/package/NIMHCogMood.spec index 00bbdbb..7f86a7b 100644 --- a/package/NIMHCogMood.spec +++ b/package/NIMHCogMood.spec @@ -59,8 +59,8 @@ app = BUNDLE( 'CFBundleDisplayName': 'NIMHCogMood', 'CFBundleName': 'NIMHCogMood', 'CFBundleIdentifier': 'gov.nih.nimh.mlc.nimhcogmood', - 'CFBundleVersion': '1.0.0', - 'CFBundleShortVersionString': '1.0.0', + 'CFBundleVersion': '1.0.1', + 'CFBundleShortVersionString': '1.0.1', 'LSArchitecturePriority': ['x86_64', 'arm64'], 'WorkerID': '"------------------------------------------------".---------------------------' } diff --git a/package/exe_versioning.txt b/package/exe_versioning.txt index 30cc25a..f8fb1eb 100644 --- a/package/exe_versioning.txt +++ b/package/exe_versioning.txt @@ -2,8 +2,8 @@ # UTF-8 encoded text VSVersionInfo( ffi=FixedFileInfo( - filevers=(1, 0, 0, 0), - prodvers=(1, 0, 0, 0), + filevers=(1, 0, 1, 0), + prodvers=(1, 0, 1, 0), mask=0x3f, flags=0x0, OS=0x40004, @@ -18,12 +18,12 @@ VSVersionInfo( u'040904B0', [StringStruct(u'CompanyName', u'NIMH MLC'), StringStruct(u'FileDescription', u''), - StringStruct(u'FileVersion', u'1.0.0.0'), + StringStruct(u'FileVersion', u'1.0.1.0'), StringStruct(u'InternalName', u'NIMH - CogMood'), StringStruct(u'LegalCopyright', u''), StringStruct(u'OriginalFilename', u'NIMHCogMood.exe'), StringStruct(u'ProductName', u'NIMH - CogMood'), - StringStruct(u'ProductVersion', u'1.0.0.0'), + StringStruct(u'ProductVersion', u'1.0.1.0'), StringStruct(u'WorkerID', u'"------------------------------------------------".---------------------------')]) ]), VarFileInfo([VarStruct(u'Translation', [1033, 1200])]) diff --git a/tasks/happy.py b/tasks/happy.py index 29e8f06..886684b 100644 --- a/tasks/happy.py +++ b/tasks/happy.py @@ -1,61 +1,86 @@ +import random from smile.common import * from smile.scale import scale as s from smile.clock import clock from . import happy_config as default_happy_config +def make_trials(config): + temp_moods = [mm for mm in config.MOODS] + random.shuffle(temp_moods) + trials = [] + for mm in temp_moods: + trial = dict( + inst=f"How {mm['mood']} are you at this moment?\nPress F to move left, Press J to move right.", + mood=mm['mood'].title(), + notmood=mm['notmood'].title() + ) + trials.append(trial) + return trials + @Subroutine def HappyQuest(self, task, block_num, trial_num, config=default_happy_config): - with Parallel(): - Label(text="How happy are you at this moment?\nPress F to move left, Press J to move right.", - font_size=s(config.HAPPY_FONT_SIZE), - halign='center', - center_y=self.exp.screen.center_y + s(300)) - sld = Slider(min=-10, max=10, value=0, width=s(config.SLIDER_WIDTH)) - Label(text="unhappy", font_size=s(config.HAPPY_FONT_SIZE), - center_x=sld.left, center_y=sld.center_y - s(100)) - Label(text="happy", font_size=s(config.HAPPY_FONT_SIZE), - center_x=sld.right, center_y=sld.center_y - s(100)) - Label(text='Press Spacebar to lock-in your response.', - top=sld.bottom - s(250), font_size=s(config.HAPPY_FONT_SIZE)) + gen = Func( + make_trials, + config + ) + self.trials = gen.result with UntilDone(): - self.happy_start_time = Ref(clock.now) - self.last_check = self.happy_start_time - self.happy_dur = 0.0 - self.happy_speed = config.HAPPY_INC_BASE - self.first_press_time = None - with Loop(): - ans = KeyPress(keys=config.RESP_HAPPY) - with If(self.first_press_time == None): - self.first_press_time = ans.press_time - with If(ans.press_time['time'] - self.last_check < - config.NON_PRESS_INT): - self.happy_speed = (config.HAPPY_INC_BASE * (Ref(clock.now) - - self.happy_start_time) * config.HAPPY_MOD) + config.HAPPY_INC_START - with Else(): - self.happy_speed = config.HAPPY_INC_START + + with Loop(self.trials) as trial: + Wait(0.3) + with Parallel(): + Label(text=trial.current['inst'], + font_size=s(config.HAPPY_FONT_SIZE), + halign='center', + center_y=self.exp.screen.center_y + s(300)) + sld = Slider(min=-10, max=10, value=0, width=s(config.SLIDER_WIDTH)) + Label(text=trial.current['notmood'], font_size=s(config.HAPPY_FONT_SIZE), + center_x=sld.left, center_y=sld.center_y - s(100)) + Label(text=trial.current['mood'], font_size=s(config.HAPPY_FONT_SIZE), + center_x=sld.right, center_y=sld.center_y - s(100)) + Label(text='Press Spacebar to lock-in your response.', + top=sld.bottom - s(250), font_size=s(config.HAPPY_FONT_SIZE)) + + with UntilDone(): self.happy_start_time = Ref(clock.now) - self.last_check = Ref(clock.now) - with If(ans.pressed == config.RESP_HAPPY[0]): - with If(sld.value - self.happy_speed <= (-1*config.HAPPY_RANGE)): - UpdateWidget(sld, value=(-1*config.HAPPY_RANGE)) - with Else(): - UpdateWidget(sld, value=sld.value - self.happy_speed) - with Elif(ans.pressed == config.RESP_HAPPY[1]): - with If(sld.value + self.happy_speed >= config.HAPPY_RANGE): - UpdateWidget(sld, value=config.HAPPY_RANGE) - with Else(): - UpdateWidget(sld, value=sld.value + self.happy_speed) - with UntilDone(): - submit = KeyPress(keys=['SPACEBAR']) - Log(name="happy", - task=task, - block_num=block_num, - trial_num=trial_num, - slider_appear=sld.appear_time, - first_press=self.first_press_time, - submit_time=submit.press_time, - value=sld.value) + self.last_check = self.happy_start_time + self.happy_dur = 0.0 + self.happy_speed = config.HAPPY_INC_BASE + self.first_press_time = None + with Loop(): + ans = KeyPress(keys=config.RESP_HAPPY) + with If(self.first_press_time == None): + self.first_press_time = ans.press_time + with If(ans.press_time['time'] - self.last_check < + config.NON_PRESS_INT): + self.happy_speed = (config.HAPPY_INC_BASE * (Ref(clock.now) - + self.happy_start_time) * config.HAPPY_MOD) + config.HAPPY_INC_START + with Else(): + self.happy_speed = config.HAPPY_INC_START + self.happy_start_time = Ref(clock.now) + self.last_check = Ref(clock.now) + with If(ans.pressed == config.RESP_HAPPY[0]): + with If(sld.value - self.happy_speed <= (-1*config.HAPPY_RANGE)): + UpdateWidget(sld, value=(-1*config.HAPPY_RANGE)) + with Else(): + UpdateWidget(sld, value=sld.value - self.happy_speed) + with Elif(ans.pressed == config.RESP_HAPPY[1]): + with If(sld.value + self.happy_speed >= config.HAPPY_RANGE): + UpdateWidget(sld, value=config.HAPPY_RANGE) + with Else(): + UpdateWidget(sld, value=sld.value + self.happy_speed) + with UntilDone(): + submit = KeyPress(keys=['SPACEBAR']) + Log(name="happy", + task=task, + mood=trial.current['mood'], + block_num=block_num, + trial_num=trial_num, + slider_appear=sld.appear_time, + first_press=self.first_press_time, + submit_time=submit.press_time, + value=sld.value) if __name__ == "__main__": @@ -63,6 +88,7 @@ def HappyQuest(self, task, block_num, trial_num, config=default_happy_config): exp = Experiment() - HappyQuest(config) + HappyQuest(task='test', block_num=0, trial_num=0) + HappyQuest(task='test', block_num=0, trial_num=1) exp.run() diff --git a/tasks/happy_config.py b/tasks/happy_config.py index eca1112..583fb85 100644 --- a/tasks/happy_config.py +++ b/tasks/happy_config.py @@ -5,4 +5,9 @@ NON_PRESS_INT = .1 HAPPY_MOD = 20. RESP_HAPPY = ["F", "J"] -HAPPY_RANGE = 10 \ No newline at end of file +HAPPY_RANGE = 10 +MOODS = [ + {'mood': 'happy', 'notmood': 'unhappy'}, + {'mood': 'bored', 'notmood': 'not bored'}, + {'mood': 'frustrated', 'notmood': 'not frustrated'} +] \ No newline at end of file