Skip to content

Commit 6d905a8

Browse files
committed
RF: changed bart timing, added 2 questions
1 parent e96029f commit 6d905a8

File tree

4 files changed

+91
-59
lines changed

4 files changed

+91
-59
lines changed

config.py

Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import os
44

5-
EXP_NAME = "SUPREME-03252020"
5+
EXP_NAME = "SUPREMEMOOD"
66

77
BACKGROUND_COLOR = (.35, .35, .35, 1.0)
88

@@ -165,144 +165,153 @@
165165
CESD = [{'type':'TITLE',
166166
'question':"General Questionnaire",
167167
},
168-
{'type':'LI',
169-
'question':"1. I was bothered by things that usually don't bother me.",
170-
'ans':['Rarely or none\nof the time\n(less than 1 day)',
171-
'Some or a little of\nthe time (1-2 days)',
172-
'Occasionally or a\nmoderate amount of time\n(3-4 days)',
173-
'Most or all of the time\n(5-7 days)'],
168+
{'type':'MC',
169+
'question':"1. Sex assigned at birth:",
170+
'ans':['Male',
171+
'Female',
172+
'Perfer not to answer'],
174173
'group_id':"1"},
174+
{'type':'TI',
175+
'question':"2. Your Age: ",
176+
'multiline':1},
175177
{'type':'LI',
176-
'question':"2. I did not feel like eating; my appetite was poor.",
177-
'ans':['Rarely or none\nof the time\n(less than 1 day)',
178-
'Some or a little of\nthe time (1-2 days)',
179-
'Occasionally or a\nmoderate amount of time\n(3-4 days)',
180-
'Most or all of the time\n(5-7 days)'],
181-
'group_id':"2"},
182-
{'type':'LI',
183-
'question':"3. I felt that I could not shake off the blues even with help from my family or friends.",
178+
'question':"3. I was bothered by things that usually don't bother me.",
184179
'ans':['Rarely or none\nof the time\n(less than 1 day)',
185180
'Some or a little of\nthe time (1-2 days)',
186181
'Occasionally or a\nmoderate amount of time\n(3-4 days)',
187182
'Most or all of the time\n(5-7 days)'],
188183
'group_id':"3"},
189184
{'type':'LI',
190-
'question':"4. I felt I was just as good as other people.",
185+
'question':"4. I did not feel like eating; my appetite was poor.",
191186
'ans':['Rarely or none\nof the time\n(less than 1 day)',
192187
'Some or a little of\nthe time (1-2 days)',
193188
'Occasionally or a\nmoderate amount of time\n(3-4 days)',
194189
'Most or all of the time\n(5-7 days)'],
195190
'group_id':"4"},
196191
{'type':'LI',
197-
'question':"5. I had trouble keeping my mind on what I was doing.",
192+
'question':"5. I felt that I could not shake off the blues even with help from my family or friends.",
198193
'ans':['Rarely or none\nof the time\n(less than 1 day)',
199194
'Some or a little of\nthe time (1-2 days)',
200195
'Occasionally or a\nmoderate amount of time\n(3-4 days)',
201196
'Most or all of the time\n(5-7 days)'],
202197
'group_id':"5"},
203198
{'type':'LI',
204-
'question':"6. I felt depressed.",
199+
'question':"6. I felt I was just as good as other people.",
205200
'ans':['Rarely or none\nof the time\n(less than 1 day)',
206201
'Some or a little of\nthe time (1-2 days)',
207202
'Occasionally or a\nmoderate amount of time\n(3-4 days)',
208203
'Most or all of the time\n(5-7 days)'],
209204
'group_id':"6"},
210205
{'type':'LI',
211-
'question':"7. I felt that everything I did was an effort.",
206+
'question':"7. I had trouble keeping my mind on what I was doing.",
212207
'ans':['Rarely or none\nof the time\n(less than 1 day)',
213208
'Some or a little of\nthe time (1-2 days)',
214209
'Occasionally or a\nmoderate amount of time\n(3-4 days)',
215210
'Most or all of the time\n(5-7 days)'],
216211
'group_id':"7"},
217212
{'type':'LI',
218-
'question':"8. I felt hopeful about the future.",
213+
'question':"8. I felt depressed.",
219214
'ans':['Rarely or none\nof the time\n(less than 1 day)',
220215
'Some or a little of\nthe time (1-2 days)',
221216
'Occasionally or a\nmoderate amount of time\n(3-4 days)',
222217
'Most or all of the time\n(5-7 days)'],
223218
'group_id':"8"},
224219
{'type':'LI',
225-
'question':"9. I thought my life had been a failure.",
220+
'question':"9. I felt that everything I did was an effort.",
226221
'ans':['Rarely or none\nof the time\n(less than 1 day)',
227222
'Some or a little of\nthe time (1-2 days)',
228223
'Occasionally or a\nmoderate amount of time\n(3-4 days)',
229224
'Most or all of the time\n(5-7 days)'],
230225
'group_id':"9"},
231226
{'type':'LI',
232-
'question':"10. I felt fearful.",
227+
'question':"10. I felt hopeful about the future.",
233228
'ans':['Rarely or none\nof the time\n(less than 1 day)',
234229
'Some or a little of\nthe time (1-2 days)',
235230
'Occasionally or a\nmoderate amount of time\n(3-4 days)',
236231
'Most or all of the time\n(5-7 days)'],
237232
'group_id':"10"},
238233
{'type':'LI',
239-
'question':"11. My sleep was restless",
234+
'question':"11. I thought my life had been a failure.",
240235
'ans':['Rarely or none\nof the time\n(less than 1 day)',
241236
'Some or a little of\nthe time (1-2 days)',
242237
'Occasionally or a\nmoderate amount of time\n(3-4 days)',
243238
'Most or all of the time\n(5-7 days)'],
244239
'group_id':"11"},
245240
{'type':'LI',
246-
'question':"12. I was happy.",
241+
'question':"12. I felt fearful.",
247242
'ans':['Rarely or none\nof the time\n(less than 1 day)',
248243
'Some or a little of\nthe time (1-2 days)',
249244
'Occasionally or a\nmoderate amount of time\n(3-4 days)',
250245
'Most or all of the time\n(5-7 days)'],
251246
'group_id':"12"},
252247
{'type':'LI',
253-
'question':"13. I talked less than usual.",
248+
'question':"13. My sleep was restless",
254249
'ans':['Rarely or none\nof the time\n(less than 1 day)',
255250
'Some or a little of\nthe time (1-2 days)',
256251
'Occasionally or a\nmoderate amount of time\n(3-4 days)',
257252
'Most or all of the time\n(5-7 days)'],
258253
'group_id':"13"},
259254
{'type':'LI',
260-
'question':"14. I felt lonely.",
255+
'question':"14. I was happy.",
261256
'ans':['Rarely or none\nof the time\n(less than 1 day)',
262257
'Some or a little of\nthe time (1-2 days)',
263258
'Occasionally or a\nmoderate amount of time\n(3-4 days)',
264259
'Most or all of the time\n(5-7 days)'],
265260
'group_id':"14"},
266261
{'type':'LI',
267-
'question':"15. People were unfriendly.",
262+
'question':"15. I talked less than usual.",
268263
'ans':['Rarely or none\nof the time\n(less than 1 day)',
269264
'Some or a little of\nthe time (1-2 days)',
270265
'Occasionally or a\nmoderate amount of time\n(3-4 days)',
271266
'Most or all of the time\n(5-7 days)'],
272267
'group_id':"15"},
273268
{'type':'LI',
274-
'question':"16. I enjoyed life.",
269+
'question':"16. I felt lonely.",
275270
'ans':['Rarely or none\nof the time\n(less than 1 day)',
276271
'Some or a little of\nthe time (1-2 days)',
277272
'Occasionally or a\nmoderate amount of time\n(3-4 days)',
278273
'Most or all of the time\n(5-7 days)'],
279274
'group_id':"16"},
280275
{'type':'LI',
281-
'question':"17. I had crying spells.",
276+
'question':"17. People were unfriendly.",
282277
'ans':['Rarely or none\nof the time\n(less than 1 day)',
283278
'Some or a little of\nthe time (1-2 days)',
284279
'Occasionally or a\nmoderate amount of time\n(3-4 days)',
285280
'Most or all of the time\n(5-7 days)'],
286281
'group_id':"17"},
287282
{'type':'LI',
288-
'question':"18. I felt sad.",
283+
'question':"18. I enjoyed life.",
289284
'ans':['Rarely or none\nof the time\n(less than 1 day)',
290285
'Some or a little of\nthe time (1-2 days)',
291286
'Occasionally or a\nmoderate amount of time\n(3-4 days)',
292287
'Most or all of the time\n(5-7 days)'],
293288
'group_id':"18"},
294289
{'type':'LI',
295-
'question':"19. I felt that people dislike me.",
290+
'question':"19. I had crying spells.",
296291
'ans':['Rarely or none\nof the time\n(less than 1 day)',
297292
'Some or a little of\nthe time (1-2 days)',
298293
'Occasionally or a\nmoderate amount of time\n(3-4 days)',
299294
'Most or all of the time\n(5-7 days)'],
300295
'group_id':"19"},
301296
{'type':'LI',
302-
'question':"20. I could not get \"going.\"",
297+
'question':"20. I felt sad.",
298+
'ans':['Rarely or none\nof the time\n(less than 1 day)',
299+
'Some or a little of\nthe time (1-2 days)',
300+
'Occasionally or a\nmoderate amount of time\n(3-4 days)',
301+
'Most or all of the time\n(5-7 days)'],
302+
'group_id':"20"},
303+
{'type':'LI',
304+
'question':"21. I felt that people dislike me.",
305+
'ans':['Rarely or none\nof the time\n(less than 1 day)',
306+
'Some or a little of\nthe time (1-2 days)',
307+
'Occasionally or a\nmoderate amount of time\n(3-4 days)',
308+
'Most or all of the time\n(5-7 days)'],
309+
'group_id':"21"},
310+
{'type':'LI',
311+
'question':"22. I could not get \"going.\"",
303312
'ans':['Rarely or none\nof the time\n(less than 1 day)',
304313
'Some or a little of\nthe time (1-2 days)',
305314
'Occasionally or a\nmoderate amount of time\n(3-4 days)',
306315
'Most or all of the time\n(5-7 days)'],
307-
'group_id':"20"}
316+
'group_id':"22"}
308317
]

main.py

Lines changed: 47 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import json
66
import subprocess
77
import zipfile
8+
import hashlib
89
# Smile imports
910
from smile.common import Experiment, Log, Wait, Func, UntilDone, ButtonPress, \
1011
Button, Label, Loop, If, Elif, Else, KeyPress, Ref,\
@@ -50,27 +51,45 @@ def ToOut(message, exp, post_urlFULL):
5051
print(f"Unexpected {err=}, Could not zip directory.{type(err)=}")
5152
raise err
5253

53-
if not (message is None):
54+
status_code = None
55+
try:
56+
with open(to_zip, 'rb') as f:
57+
data = f.read()
58+
print(post_urlFULL)
59+
r = requests.post(post_urlFULL,
60+
data={'results':data},
61+
verify=os.path.join(WRK_DIR, "cert.pem"),
62+
allow_redirects=False,
63+
timeout=120)
64+
print(r.status_code)
65+
status_code = r.status_code
66+
except BaseException as err:
67+
print(f"Unexpected {err=}, {type(err)=}")
68+
failed_post = True
69+
if status_code != 200:
70+
failed_post = True
71+
m = 'e0000000000'
72+
if (not (message is None)) & (not failed_post):
5473
with open('confirmation_code.txt', 'w') as f:
5574
f.write(message['extra'][10:-5])
75+
5676
try:
5777
copy2clip(message['extra'][10:-5])
78+
m = message['extra'][10:-5]
5879
except BaseException as err:
5980
print(f"Unexpected {err=}, Could not copy to clipboard: {type(err)=}")
6081
failed_copy = True
61-
try:
82+
else:
6283
with open(to_zip, 'rb') as f:
6384
data = f.read()
64-
r = requests.post(post_urlFULL,
65-
data={'results':data},
66-
verify=os.path.join(WRK_DIR, "cert.pem"),
67-
timeout=120)
68-
print(r)
69-
except BaseException as err:
70-
print(f"Unexpected {err=}, {type(err)=}")
71-
raise err
72-
failed_post = True
73-
return failed_post, failed_copy
85+
m = "e" + hashlib.md5(data).hexdigest()[:10]
86+
try:
87+
copy2clip(m)
88+
except BaseException as err:
89+
print(f"Unexpected {err=}, Could not copy to clipboard: {type(err)=}")
90+
failed_copy = True
91+
92+
return failed_post, failed_copy, m
7493
#----------------WRK_DIR EDITS HERE----------------
7594
# edited so the data_dir is the WRK_DIR if running from the packaged exe
7695
# otherwise the data_dir is '.'
@@ -125,14 +144,15 @@ def ToOut(message, exp, post_urlFULL):
125144
# Do the get
126145
print('About to get')
127146
with open(os.path.join(WRK_DIR, 'serverinfo.txt'), 'r') as f:
128-
serverinfo = f.read()
147+
serverinfo = f.readline().strip()
148+
post_urlFULL = f.readline().strip()
149+
print(serverinfo, post_urlFULL)
129150

130151
try:
131152
r = requests.get(serverinfo, verify=os.path.join(WRK_DIR, "cert.pem"),
132153
timeout=2)
133154
print(r.text)
134155
message = json.loads(r.text.replace("\'", "\""))
135-
post_urlFULL = serverinfo[:serverinfo.rfind('/')+1] + "end.php?at={}&sqlid={}"
136156
post_urlFULL = post_urlFULL.format(message['platformid'],
137157
message['sqlid'])
138158
connected = True
@@ -143,6 +163,7 @@ def ToOut(message, exp, post_urlFULL):
143163
post_urlFULL = None
144164
connected = False
145165
to_message = "Yo"
166+
print("connected: ", connected)
146167
# Initialize the SMILE experiment.
147168
exp = Experiment(name=CogBatt_config.EXP_NAME,
148169
background_color=CogBatt_config.BACKGROUND_COLOR,
@@ -292,26 +313,27 @@ def ToOut(message, exp, post_urlFULL):
292313
KeyPress(['ESCAPE'], blocking=False)
293314
Wait(.25)
294315
with If(connected):
295-
Label(text="Thank you! Your data will be sent after the experiment window closes.\nOn the next screen you will see your confirmation code!\nPress any key to continue",
316+
Label(text="Thank you! Your data is about to be sent to our servers.\nOn one of the next screens, you will see your confirmation code!\nPress any key to continue",
296317
text_size=(s(900), None), font_size=s(CogBatt_config.SSI_FONT_SIZE))
297318
with UntilDone():
298319
KeyPress()
299320
# Start the experiment, everything above runs before the experiment even starts
300321
# since SMILE is a state machine. You must build it and then *.run()* it.
301322

302323
Wait(.25)
303-
Label(text="Code: {}\n\nThe code is saved to confirmation_code.txt\nPlease write down the code just in case it gets lost.\n\nOn the following screen we will attempt to send your data to our server and copy the code so you can paste into MTurk\n\nPress any key to continue. ".format(to_message),
304-
text_size=(s(900), None), font_size=s(CogBatt_config.SSI_FONT_SIZE))
305-
with UntilDone():
306-
KeyPress()
307-
308324
Label(text="Please wait, this could take several minutes...",
309325
text_size=(s(900), None), font_size=s(CogBatt_config.SSI_FONT_SIZE))
310326
with UntilDone():
311327
Wait(.033)
312328
to_server_resp = Func(ToOut, message, exp, post_urlFULL)
313329
with If(to_server_resp.result[1]):
314-
Label(text="Due to an error, we were unable to copy the code to your clipboard.\n\nPlease see confirmation_code.txt for your code and paste it into MTurk. In case you cannot find this file, the code again is:\n\n{}\n\nPress any key to continue.".format(to_message),
330+
331+
Label(text="Due to an error, we were unable to copy the code to your clipboard.\n\nPlease see confirmation_code.txt for your code and paste it into MTurk. In case you cannot find this file, the code again is:\n\n"+to_server_resp.result[2]+"\n\nPress any key to continue.",
332+
text_size=(s(900), None), font_size=s(CogBatt_config.SSI_FONT_SIZE))
333+
with UntilDone():
334+
KeyPress()
335+
with Else():
336+
Label(text="Your confirmation code was sent to your clipboard and saved in confirmation_code.txt.\n\nPlease paste it into MTurk. The code is:\n\n"+ to_server_resp.result[2] + "\n\nPlease write it down, then press any key to continue.",
315337
text_size=(s(900), None), font_size=s(CogBatt_config.SSI_FONT_SIZE))
316338
with UntilDone():
317339
KeyPress()
@@ -321,9 +343,11 @@ def ToOut(message, exp, post_urlFULL):
321343
with UntilDone():
322344
KeyPress()
323345
with Else():
324-
Label(text="Thank you!\n\nDue to an error with the server, we ask that you send your data to: [email protected]\n\nYour data is in a file called data.zip located the same place as this experiment, cogmood.exe.\n\nPress any key to continue.",
346+
ret2 = Func(ToOut, message, exp, post_urlFULL)
347+
348+
Label(text="Thank you!\n\nDue to an error with the server, we ask that you send your data to: [email protected]\n\nYour data is in a file called data.zip located the same place as this experiment, cogmood.exe.\n\nYour confirmation code for the experiment is\n\n" +ret2.result[2]+".\n\nPress any key to continue.",
325349
text_size=(s(900), None), font_size=s(CogBatt_config.SSI_FONT_SIZE))
326350
with UntilDone():
327351
KeyPress()
328-
Func(ToOut, message, exp, post_urlFULL)
352+
329353
exp.run()

tasks/BARTUVA/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434

3535
FEEDBACK_TIME = 0.75
3636
ISI = 0.25
37-
INTER_PUMP_DURATION = 0.75
37+
INTER_PUMP_DURATION = 0.0
3838
REWARD_SLIDE_DURATION = 0.25
3939
PUMP_DURATION = 0.25
4040
COLLECT_DURATION = 0.5
41-
BALLOON_GROWTH_DURATION = 0.3
41+
BALLOON_GROWTH_DURATION = 0.2
4242
POP_ANIMATION_DURATION = 1.0
4343

4444
BALLOON_START_SIZE = 100

tasks/BARTUVA/trial.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ def BARTSub(self,
220220
Reward_label.slide(duration=config.REWARD_SLIDE_DURATION,
221221
center=Balloon.center,
222222
color=(0,0,0,0))
223-
Wait(0.5, jitter=0.3)
224223
with Parallel():
225224
Balloon.slide(duration=config.BALLOON_GROWTH_DURATION,
226225
size=(s(self.curr_balloon_size),s(self.curr_balloon_size)),

0 commit comments

Comments
 (0)