Skip to content

Commit 6ea21da

Browse files
authored
Merge pull request #11 from compmem/new_moods
Add: Collect data on happiness, boredom, and frustration between blocks.
2 parents f7a3b6d + 960ea24 commit 6ea21da

File tree

4 files changed

+87
-56
lines changed

4 files changed

+87
-56
lines changed

package/NIMHCogMood.spec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ app = BUNDLE(
5959
'CFBundleDisplayName': 'NIMHCogMood',
6060
'CFBundleName': 'NIMHCogMood',
6161
'CFBundleIdentifier': 'gov.nih.nimh.mlc.nimhcogmood',
62-
'CFBundleVersion': '1.0.0',
63-
'CFBundleShortVersionString': '1.0.0',
62+
'CFBundleVersion': '1.0.1',
63+
'CFBundleShortVersionString': '1.0.1',
6464
'LSArchitecturePriority': ['x86_64', 'arm64'],
6565
'WorkerID': '"------------------------------------------------".---------------------------'
6666
}

package/exe_versioning.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# UTF-8 encoded text
33
VSVersionInfo(
44
ffi=FixedFileInfo(
5-
filevers=(1, 0, 0, 0),
6-
prodvers=(1, 0, 0, 0),
5+
filevers=(1, 0, 1, 0),
6+
prodvers=(1, 0, 1, 0),
77
mask=0x3f,
88
flags=0x0,
99
OS=0x40004,
@@ -18,12 +18,12 @@ VSVersionInfo(
1818
u'040904B0',
1919
[StringStruct(u'CompanyName', u'NIMH MLC'),
2020
StringStruct(u'FileDescription', u''),
21-
StringStruct(u'FileVersion', u'1.0.0.0'),
21+
StringStruct(u'FileVersion', u'1.0.1.0'),
2222
StringStruct(u'InternalName', u'NIMH - CogMood'),
2323
StringStruct(u'LegalCopyright', u''),
2424
StringStruct(u'OriginalFilename', u'NIMHCogMood.exe'),
2525
StringStruct(u'ProductName', u'NIMH - CogMood'),
26-
StringStruct(u'ProductVersion', u'1.0.0.0'),
26+
StringStruct(u'ProductVersion', u'1.0.1.0'),
2727
StringStruct(u'WorkerID', u'"------------------------------------------------".---------------------------')])
2828
]),
2929
VarFileInfo([VarStruct(u'Translation', [1033, 1200])])

tasks/happy.py

Lines changed: 75 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,94 @@
1+
import random
12
from smile.common import *
23
from smile.scale import scale as s
34
from smile.clock import clock
45
from . import happy_config as default_happy_config
56

7+
def make_trials(config):
8+
temp_moods = [mm for mm in config.MOODS]
9+
random.shuffle(temp_moods)
10+
trials = []
11+
for mm in temp_moods:
12+
trial = dict(
13+
inst=f"How {mm['mood']} are you at this moment?\nPress F to move left, Press J to move right.",
14+
mood=mm['mood'].title(),
15+
notmood=mm['notmood'].title()
16+
)
17+
trials.append(trial)
18+
return trials
19+
620
@Subroutine
721
def HappyQuest(self, task, block_num, trial_num, config=default_happy_config):
8-
with Parallel():
9-
Label(text="How happy are you at this moment?\nPress F to move left, Press J to move right.",
10-
font_size=s(config.HAPPY_FONT_SIZE),
11-
halign='center',
12-
center_y=self.exp.screen.center_y + s(300))
13-
sld = Slider(min=-10, max=10, value=0, width=s(config.SLIDER_WIDTH))
14-
Label(text="unhappy", font_size=s(config.HAPPY_FONT_SIZE),
15-
center_x=sld.left, center_y=sld.center_y - s(100))
16-
Label(text="happy", font_size=s(config.HAPPY_FONT_SIZE),
17-
center_x=sld.right, center_y=sld.center_y - s(100))
18-
Label(text='Press Spacebar to lock-in your response.',
19-
top=sld.bottom - s(250), font_size=s(config.HAPPY_FONT_SIZE))
22+
gen = Func(
23+
make_trials,
24+
config
25+
)
26+
self.trials = gen.result
2027

2128
with UntilDone():
22-
self.happy_start_time = Ref(clock.now)
23-
self.last_check = self.happy_start_time
24-
self.happy_dur = 0.0
25-
self.happy_speed = config.HAPPY_INC_BASE
26-
self.first_press_time = None
27-
with Loop():
28-
ans = KeyPress(keys=config.RESP_HAPPY)
29-
with If(self.first_press_time == None):
30-
self.first_press_time = ans.press_time
31-
with If(ans.press_time['time'] - self.last_check <
32-
config.NON_PRESS_INT):
33-
self.happy_speed = (config.HAPPY_INC_BASE * (Ref(clock.now) -
34-
self.happy_start_time) * config.HAPPY_MOD) + config.HAPPY_INC_START
35-
with Else():
36-
self.happy_speed = config.HAPPY_INC_START
29+
30+
with Loop(self.trials) as trial:
31+
Wait(0.3)
32+
with Parallel():
33+
Label(text=trial.current['inst'],
34+
font_size=s(config.HAPPY_FONT_SIZE),
35+
halign='center',
36+
center_y=self.exp.screen.center_y + s(300))
37+
sld = Slider(min=-10, max=10, value=0, width=s(config.SLIDER_WIDTH))
38+
Label(text=trial.current['notmood'], font_size=s(config.HAPPY_FONT_SIZE),
39+
center_x=sld.left, center_y=sld.center_y - s(100))
40+
Label(text=trial.current['mood'], font_size=s(config.HAPPY_FONT_SIZE),
41+
center_x=sld.right, center_y=sld.center_y - s(100))
42+
Label(text='Press Spacebar to lock-in your response.',
43+
top=sld.bottom - s(250), font_size=s(config.HAPPY_FONT_SIZE))
44+
45+
with UntilDone():
3746
self.happy_start_time = Ref(clock.now)
38-
self.last_check = Ref(clock.now)
39-
with If(ans.pressed == config.RESP_HAPPY[0]):
40-
with If(sld.value - self.happy_speed <= (-1*config.HAPPY_RANGE)):
41-
UpdateWidget(sld, value=(-1*config.HAPPY_RANGE))
42-
with Else():
43-
UpdateWidget(sld, value=sld.value - self.happy_speed)
44-
with Elif(ans.pressed == config.RESP_HAPPY[1]):
45-
with If(sld.value + self.happy_speed >= config.HAPPY_RANGE):
46-
UpdateWidget(sld, value=config.HAPPY_RANGE)
47-
with Else():
48-
UpdateWidget(sld, value=sld.value + self.happy_speed)
49-
with UntilDone():
50-
submit = KeyPress(keys=['SPACEBAR'])
51-
Log(name="happy",
52-
task=task,
53-
block_num=block_num,
54-
trial_num=trial_num,
55-
slider_appear=sld.appear_time,
56-
first_press=self.first_press_time,
57-
submit_time=submit.press_time,
58-
value=sld.value)
47+
self.last_check = self.happy_start_time
48+
self.happy_dur = 0.0
49+
self.happy_speed = config.HAPPY_INC_BASE
50+
self.first_press_time = None
51+
with Loop():
52+
ans = KeyPress(keys=config.RESP_HAPPY)
53+
with If(self.first_press_time == None):
54+
self.first_press_time = ans.press_time
55+
with If(ans.press_time['time'] - self.last_check <
56+
config.NON_PRESS_INT):
57+
self.happy_speed = (config.HAPPY_INC_BASE * (Ref(clock.now) -
58+
self.happy_start_time) * config.HAPPY_MOD) + config.HAPPY_INC_START
59+
with Else():
60+
self.happy_speed = config.HAPPY_INC_START
61+
self.happy_start_time = Ref(clock.now)
62+
self.last_check = Ref(clock.now)
63+
with If(ans.pressed == config.RESP_HAPPY[0]):
64+
with If(sld.value - self.happy_speed <= (-1*config.HAPPY_RANGE)):
65+
UpdateWidget(sld, value=(-1*config.HAPPY_RANGE))
66+
with Else():
67+
UpdateWidget(sld, value=sld.value - self.happy_speed)
68+
with Elif(ans.pressed == config.RESP_HAPPY[1]):
69+
with If(sld.value + self.happy_speed >= config.HAPPY_RANGE):
70+
UpdateWidget(sld, value=config.HAPPY_RANGE)
71+
with Else():
72+
UpdateWidget(sld, value=sld.value + self.happy_speed)
73+
with UntilDone():
74+
submit = KeyPress(keys=['SPACEBAR'])
75+
Log(name="happy",
76+
task=task,
77+
mood=trial.current['mood'],
78+
block_num=block_num,
79+
trial_num=trial_num,
80+
slider_appear=sld.appear_time,
81+
first_press=self.first_press_time,
82+
submit_time=submit.press_time,
83+
value=sld.value)
5984

6085

6186
if __name__ == "__main__":
6287
import config
6388

6489
exp = Experiment()
6590

66-
HappyQuest(config)
91+
HappyQuest(task='test', block_num=0, trial_num=0)
92+
HappyQuest(task='test', block_num=0, trial_num=1)
6793

6894
exp.run()

tasks/happy_config.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,9 @@
55
NON_PRESS_INT = .1
66
HAPPY_MOD = 20.
77
RESP_HAPPY = ["F", "J"]
8-
HAPPY_RANGE = 10
8+
HAPPY_RANGE = 10
9+
MOODS = [
10+
{'mood': 'happy', 'notmood': 'unhappy'},
11+
{'mood': 'bored', 'notmood': 'not bored'},
12+
{'mood': 'frustrated', 'notmood': 'not frustrated'}
13+
]

0 commit comments

Comments
 (0)