Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.49 KB | None | 0 0
  1. ---
  2. API: 2
  3. OpenSesame: 3.0.7
  4. Platform: nt
  5. ---
  6. set width 1024
  7. set uniform_coordinates yes
  8. set title "New experiment"
  9. set subject_parity even
  10. set subject_nr 0
  11. set start experiment
  12. set sampler_backend legacy
  13. set mouse_backend xpyriment
  14. set keyboard_backend legacy
  15. set height 768
  16. set foreground white
  17. set font_size 18
  18. set font_italic no
  19. set font_family mono
  20. set font_bold no
  21. set experiment_path "C:\\Users\\Guven\\Desktop\\Minor Thesis\\Programs\\FINAL VERSIONS"
  22. set description "Default description"
  23. set coordinates uniform
  24. set compensation 0
  25. set color_backend legacy
  26. set clock_backend legacy
  27. set canvas_backend xpyriment
  28. set bidi no
  29. set background black
  30.  
  31. define sketchpad Description
  32. set duration keypress
  33. set description "Displays stimuli"
  34. draw textline center=1 color=white font_bold=no font_family=mono font_italic=no font_size=18 html=yes show_if=always text="Welkom bij de eerste sessie van het experiment!<br /><br />In het eerste deel van de sessie ga je Turkse woorden en hun Nederlandse vertalingen leren. <br /><br />In het tweede deel ga je een toets maken!<br /><br /><br /><br />Druk op een toets om de instructies voor het leeronderdeel te zien!" x=0 y=0 z_index=0
  35.  
  36. define sketchpad EndofExperiment
  37. set duration keypress
  38. set description "Displays stimuli"
  39. draw textline center=1 color=white font_bold=no font_family=mono font_italic=no font_size=18 html=yes show_if=always text="Gefeliciteerd!<br /><br /><br />Het leeronderdeel van sessie 1 is voltooid! <br /><br />Vraag a.u.b. de onderzoeker om het volgende onderdeel te starten!" x=0 y=0 z_index=0
  40.  
  41. define notepad History_and_Documentation
  42. __note__
  43. Flashcard Learning Script for Güven's experiment
  44.  
  45. Hedderik van Rijn, 2016
  46.  
  47. In flashcard learning, a list of cue-response pairs is distributed over a
  48. number of stacks. The first time a stack is presented, it is presented as
  49. a learning trial, meaning that the learner sees both cue and response. After
  50. all items in a stack have been studied, the items are presented again in test
  51. trials. In these trials, a learner just sees the cue, and has to respond with
  52. the response. If incorrect, the item is added to the end of the current stack.
  53. If all items in a stack are responded to correctly, the next stack is selected,
  54. ad infitum.
  55.  
  56.  
  57. v1. Initial Version. See below for a wordy description of the code.
  58.  
  59. This is a slightly complicated flashcard learning script as some items are
  60. presented more often than others. In defineItems, two
  61. dictionaries of items are defined modifiersItems and headerItems. These are the
  62. two stems of a compound, and we want the participants to learn half of the
  63. modifiers and half of the headers 3x as much as the other half. (I.e.,
  64. experimentally manipulate the frequency of the stems). So, after randomization,
  65. the two dictionaries are distributed over a high- and a low-frequent cue list
  66. (cueLF, cueHF).
  67.  
  68. The loop runBlock is there to just indicate how many times a new stack has to
  69. be selected. Note that it is best to set this to a number that ensures that
  70. each block of a list is presented equally often. In the case of 24 items per
  71. list, and 6 items per stack (or block), we have 4 stacks in a list. With the
  72. HF items presented 3x as often as the LF items, the number should be set to
  73. n * (3 * 4 + 1 * 4), so 16, 32, etc.
  74.  
  75. In the python code populateTheCurrentStack, we use the current block number (or
  76. stack number) to figure out from which list to select which items for the
  77. current stack.
  78.  
  79. The loop untilCurrentStackIsEmpty repeats the selectaAndPresentItem sequence a
  80. very large number of times (100?), but the trick is that the "break if" is set
  81. so that this loop is exited as soon as the current stack is empty.
  82.  
  83. In selectItemAndDetermineTrialType, we select and then remove the first item
  84. from the stack and determine whether to present it as a study or a test trial.
  85. If this is a study trial, the item is immediately added to the end of the stack,
  86. as it will be tested after all other items in the stack have been studied.
  87. Based on the "run if" statements in "untilCurrentStackIsEmpty", then either the
  88. doStudyTrial sequence or the doTestTrial sequence is selected. The former just
  89. presents the cue and response on the screen for the amount of time specified
  90. in the global studyTime. The latter presents the cue on the screen and a prompt
  91. indicating that the learner can type the response. Is the response is correct,
  92. the next item is selected. If the response is incorrect, the item is added
  93. to the end of the current stack, and the learner is presented a study trial.
  94.  
  95. For each trial, the following variables are set (and exported to the CSV file):
  96.  
  97. * cue
  98. * response
  99. * trialType (study / test)
  100. * currentBlock: current block number (continuously counting)
  101. * frequency: whether this is a 'lf' or a 'hf' block
  102. * whichStack: which stack within the hf/lf list this is (1..4)
  103.  
  104. if trialType == test
  105. * givenResponse: the typed response
  106. * firstResponseRT: the RT of the first key pressed
  107. * finalResponseRT: the RT of the final "enter", committing the response
  108. * backspaceUsed: was backspace used during entry?
  109. * backspacedFirstCharacter: was the first character of the response backspace'd?
  110. __end__
  111. set description ""
  112.  
  113. define sketchpad Instructions
  114. set duration keypress
  115. set description "Displays stimuli"
  116. draw textline center=1 color=white font_bold=no font_family=mono font_italic=no font_size=18 html=yes show_if=always text="In dit deel van het experiment ga je Turkse woorden met hun <br />Nederlandse vertalingen leren en oefenen. <br /><br /><br />Aan het begin van elke proef worden 6 Turks-Nederlandse woordenparen gepresenteerd.<br /><br />Hierna begint automatisch een oefentest.<br /><br />Tijdens de oefentests zullen Turkse woorden een voor een gepresenteerd worden. <br /><br /><br /><br />Druk op een toets voor het volgende deel van de instructies.<br />" x=0 y=0 z_index=0
  117.  
  118. define sketchpad Instructions2
  119. set duration keypress
  120. set description "Displays stimuli"
  121. draw textline center=1 color=white font_bold=no font_family=mono font_italic=no font_size=18 html=yes show_if=always text="" x=0 y=-64 z_index=0
  122. draw textline center=1 color=white font_bold=no font_family=mono font_italic=no font_size=18 html=yes show_if=always text="Jouw taak is het om de Nederlandse vertalingen in te vullen. <br /><br />Druk daarna op ENTER om je antwoord te bevestigen.<br /><br /><br />Als je een fout antwoord geeft, zal dat worden aangegeven op het scherm,<br /><br />en zal het betreffende woord later herhaald worden.<br /><br /><br /><br /><br />Druk op een toets om de instructies te sluiten!" x=0 y=0 z_index=0
  123. draw textline center=1 color=white font_bold=no font_family=mono font_italic=no font_size=18 html=yes show_if=always text="" x=32 y=224 z_index=0
  124.  
  125. define sketchpad StudyBEGIN
  126. set duration keypress
  127. set description "Displays stimuli"
  128. draw textline center=1 color=white font_bold=no font_family=mono font_italic=no font_size=18 html=yes show_if=always text="Ben je er klaar voor?<br /><br />Druk op een toets om te beginnen met leren!" x=0 y=0 z_index=0
  129.  
  130. define sequence blockSequence
  131. set flush_keyboard yes
  132. set description "Runs a number of items in sequence"
  133. run populateTheCurrentStack always
  134. run untilCurrentStackIsEmpty always
  135.  
  136. define inline_script collectAndDisplayInput
  137. set description "Executes Python code"
  138. ___run__
  139. from openexp.canvas import canvas
  140. from openexp.keyboard import keyboard
  141.  
  142. # vertical coordinate of image and text
  143. instructionY = int(self.get('height') * -0.1)
  144. cueY = int(0)
  145. answerY = int(self.get('height') * 0.1)
  146.  
  147. # allowed characters
  148. allowed = 'abcdefghijklmnopqrstuvwxyz.,'
  149.  
  150. # create objects
  151. my_kb = keyboard(exp)
  152. my_canvas = canvas(exp)
  153.  
  154. # draw the first canvas
  155. my_canvas.clear()
  156. my_canvas.text(var.cue, center=True, color='White', max_width=None, html=True, bidi=False, y=cueY, x=None)
  157. my_canvas.text('Translate:', center=True, color='Blue', max_width=None, html=True, bidi=False, y=instructionY, x=None)
  158. my_canvas.text('_', center=True, color='White', max_width=None, html=True, bidi=False, y=answerY, x=None)
  159. my_canvas.show()
  160.  
  161. # run until the Enter key is pressed
  162. stop = False
  163. my_string = ""
  164. startTime = -1
  165. bsUsed = 0
  166. bsFirstCharacter = 0
  167.  
  168. # get starting time
  169. t0 = self.time()
  170.  
  171. while not stop:
  172. # get keypress
  173. key, t1 = my_kb.get_key(timeout=None)
  174. # handle input
  175. if key.lower() in allowed:
  176. if (startTime == -1):
  177. startTime = t1
  178. my_string += key
  179. elif key == 'space':
  180. my_string += " "
  181. elif key in ['enter','return']:
  182. stop = True
  183. elif key =='backspace' and len(my_string) > 0:
  184. my_string = my_string[:-1]
  185. bsUsed = 1
  186. if (len(my_string)) == 0:
  187. bsFirstCharacter = 1
  188.  
  189. # update display
  190. my_canvas.clear()
  191. my_canvas.text(var.cue, center=True, color='White', max_width=None, html=True, bidi=False, y=cueY, x=None)
  192. my_canvas.text('Translate:', center=True, color='Blue', max_width=None, html=True, bidi=False, y=instructionY, x=None)
  193. my_canvas.text(my_string + '_', center=True, color='White', max_width=None, html=True, bidi=False, y=answerY, x=None)
  194. my_canvas.show()
  195.  
  196. # save the string
  197. exp.set("givenResponse", my_string)
  198. exp.set("firstResponseRT", startTime-t0)
  199. exp.set("finalResponseRT", t1-t0)
  200. exp.set("backspaceUsed", bsUsed)
  201. exp.set("backspacedFirstCharacter", bsFirstCharacter)
  202.  
  203. # Add incorrect responded items to the end of the stack:
  204. if (var.response != var.givenResponse):
  205. curItems.append(var.cue)
  206. __end__
  207. set _prepare ""
  208.  
  209. define inline_script defineItems
  210. set description "Executes Python code"
  211. ___run__
  212. import random
  213.  
  214. ## Define all items by using 'TurkishWord':'DutchWord' definition pairs.
  215.  
  216. modifiersItems = {'meyve':'fruit', 'çim':'gras', 'hava':'lucht', 'zeytin':'olijf', 'böbrek':'nier', 'toz':'stof', 'çay':'thee', 'bahçe':'tuin', 'yel':'wind', 'tırnak':'nagel', 'saç':'haar', 'sokak':'straat', 'su':'water', 'masa':'tafel', 'dolap':'kast', 'ekmek':'brood', 'kuş':'vogel', 'güneş':'zon', 'cinayet':'moord', 'kulak':'oor', 'sırt':'rug', 'burun':'neus', 'inek':'koe', 'yağmur':'regen' }
  217.  
  218. headersItems = {'kase':'schaal', 'alan':'veld', 'liman':'haven', 'yağ':'olie', 'taş':'steen', 'bez':'doek', 'kaşık':'lepel', 'çit':'hek', 'değirmen':'molen', 'törpü':'vijl', 'boya':'verf', 'köpek':'hond', 'boru':'pijp', 'bacak':'poot', 'kapı':'deur', 'bıçak':'mes', 'kafes':'kooi', 'ışık':'licht', 'silah':'wapen', 'küpe':'ring', 'çanta':'zak', 'delik':'gat', 'süt':'melk', 'bulut':'wolk' }
  219.  
  220. allItems = modifiersItems.copy()
  221. allItems.update(headersItems)
  222.  
  223. modifiersCues = list(modifiersItems)
  224. headersCues = list(headersItems)
  225.  
  226. ## In the final code, this should be shuffled.
  227. random.shuffle(modifiersCues)
  228. random.shuffle(headersCues)
  229.  
  230. ## cuesLF will contain the items that are presented less often, cuesHF will
  231. ## present the items that will be presented more often.
  232. cuesLF = [modifiersCues[i] for i in range(12)]
  233. cuesHF = [modifiersCues[i] for i in range(12,24)]
  234.  
  235. cuesLF.extend([headersCues[i] for i in range(12)])
  236. cuesHF.extend([headersCues[i] for i in range(12,24)])
  237.  
  238. random.shuffle(cuesLF)
  239. random.shuffle(cuesHF)
  240.  
  241. ## To keep track which item has been presented
  242. itemsPresented = []
  243.  
  244. ## Current Block
  245. curBlock = 0;
  246.  
  247.  
  248. #modifiersItems[cuesLF[0]]
  249. __end__
  250. set _prepare ""
  251.  
  252. define inline_script displayStudyInfo
  253. set description "Executes Python code"
  254. ___run__
  255. from openexp.canvas import canvas
  256.  
  257. # vertical coordinate of image and text
  258. instructionY = int(self.get('height') * -0.1)
  259. cueY = int(0)
  260. answerY = int(self.get('height') * 0.1)
  261.  
  262. # create objects
  263. my_canvas = canvas(exp)
  264.  
  265. # draw the first canvas
  266. my_canvas.clear()
  267. my_canvas.text(var.cue, center=True, color='White', max_width=None, html=True, bidi=False, y=cueY, x=None)
  268. my_canvas.text('Study:', center=True, color='Green', max_width=None, html=True, bidi=False, y=instructionY, x=None)
  269. my_canvas.text(var.response, center=True, color='White', max_width=None, html=True, bidi=False, y=answerY, x=None)
  270. my_canvas.show()
  271.  
  272. clock.sleep(studyTime)
  273. __end__
  274. set _prepare ""
  275.  
  276. define sequence doStudyTrial
  277. set flush_keyboard yes
  278. set description "Runs a number of items in sequence"
  279. run fixation always
  280. run displayStudyInfo always
  281.  
  282. define sequence doTestTrial
  283. set flush_keyboard yes
  284. set description "Runs a number of items in sequence"
  285. run fixation always
  286. run collectAndDisplayInput always
  287. run studyAfterIncorrectResponse_1 always
  288.  
  289. define sequence experiment
  290. set flush_keyboard yes
  291. set description "Runs a number of items in sequence"
  292. run History_and_Documentation always
  293. run welcome always
  294. run Description always
  295. run Instructions always
  296. run Instructions2 always
  297. run StudyBEGIN always
  298. run globals always
  299. run defineItems always
  300. run runBlock always
  301. run EndofExperiment always
  302.  
  303. define sketchpad fixation
  304. set duration "[fixationDuration]"
  305. set description "Displays stimuli"
  306. draw fixdot color=white show_if=always style=default x=0 y=0 z_index=0
  307.  
  308. define inline_script globals
  309. set description "Executes Python code"
  310. ___run__
  311. global modifiersItems
  312. global headersItems
  313. global allItems
  314. global cuesLF
  315. global cuesHF
  316. global itemsPresented
  317. global curBlock
  318. global studyTime
  319.  
  320. global whichLFBlock
  321. global whichHFBlock
  322.  
  323. whichLFBlock = 0
  324. whichHFBlock = 0
  325.  
  326. var.experimentVersion = 'v1'
  327. var.fixationDuration = 1000
  328.  
  329. ## The time a study item is presented on the screen
  330. studyTime = 3000
  331. __end__
  332. set _prepare ""
  333.  
  334. define logger new_logger
  335. set description "Logs experimental data"
  336. set auto_log yes
  337.  
  338. define inline_script populateTheCurrentStack
  339. set description "Executes Python code"
  340. ___run__
  341. import random
  342.  
  343. curBlock = curBlock + 1
  344.  
  345. var.currentBlock = curBlock
  346.  
  347. ## Present a low frequency block if this is the fourth, eight, etc block:
  348. if (curBlock % 4) == 0:
  349. ## Figure out which "internal" stack of the LF items should be used:
  350. whichLFBlock += 1
  351. if (whichLFBlock > 4):
  352. whichLFBlock = 1
  353.  
  354. var.frequency = 'lf'
  355. var.whichStack = whichLFBlock
  356. ## populate the curItems list with the items of this stack
  357. curItems = cuesLF[((whichLFBlock-1)*6):whichLFBlock*6]
  358. else:
  359. whichHFBlock += 1
  360. if (whichHFBlock > 4):
  361. whichHFBlock = 1
  362. var.frequency = 'hf'
  363. var.whichStack = whichHFBlock
  364. curItems = cuesHF[((whichHFBlock-1)*6):whichHFBlock*6]
  365.  
  366. random.shuffle(curItems)
  367.  
  368. ## Needs to be shuffled in the final version
  369. # shuffle(curItems)
  370. __end__
  371. set _prepare ""
  372.  
  373. define loop runBlock
  374. set skip 0
  375. set repeat 16
  376. set order random
  377. set offset no
  378. set item blockSequence
  379. set description "Repeatedly runs another item"
  380. set cycles 1
  381. set column_order ""
  382. set break_if never
  383. run blockSequence
  384.  
  385. define sequence selectAndPresentItem
  386. set flush_keyboard yes
  387. set description "Runs a number of items in sequence"
  388. run selectItemAndDetermineTrialType always
  389. run doStudyTrial "[trialType] = 'study'"
  390. run doTestTrial "[trialType] = 'test'"
  391. run new_logger always
  392.  
  393. define inline_script selectItemAndDetermineTrialType
  394. set description "Executes Python code"
  395. set _run ""
  396. ___prepare__
  397.  
  398. ## Select the current item:
  399. curItem = curItems[0]
  400.  
  401. ## Remove this item for the to be studied items, as the participant might
  402. ## answer it correctly.
  403. curItems.remove(curItem)
  404.  
  405. ## Figure out whether we already presented this item. If so, present a test
  406. ## trial, if not, present a study trial *and* make sure that next time round
  407. ## we'll present it as a study trial.
  408. if (curItem in itemsPresented):
  409. trialType = 'test'
  410. else:
  411. trialType = 'study'
  412. curItems.append(curItem)
  413. itemsPresented.append(curItem)
  414.  
  415. var.cue = curItem
  416. var.response = allItems[curItem]
  417. var.trialType = trialType
  418. __end__
  419.  
  420. define inline_script studyAfterIncorrectResponse_1
  421. set description "Executes Python code"
  422. ___run__
  423. from openexp.canvas import canvas
  424.  
  425. # vertical coordinate of image and text
  426. instructionY = int(self.get('height') * -0.1)
  427. cueY = int(0)
  428. answerY = int(self.get('height') * 0.1)
  429.  
  430. my_canvas = canvas(exp)
  431.  
  432. if (var.response != var.givenResponse):
  433. # update display
  434. my_canvas.clear()
  435. my_canvas.text('Incorrect, re-study:', center=True, color='Red', max_width=None, html=True, bidi=False, y=instructionY, x=None)
  436. my_canvas.text(var.cue, center=True, color='White', max_width=None, html=True, bidi=False, y=cueY, x=None)
  437. my_canvas.text(var.response, center=True, color='White', max_width=None, html=True, bidi=False, y=answerY, x=None)
  438. my_canvas.show()
  439. clock.sleep(studyTime)
  440. __end__
  441. set _prepare ""
  442.  
  443. define loop untilCurrentStackIsEmpty
  444. set skip 0
  445. set repeat 100
  446. set order random
  447. set offset no
  448. set item selectAndPresentItem
  449. set description "Repeatedly runs another item"
  450. set cycles 1
  451. set column_order "cue;response;trialType;backspaceUsed;firstResponseRT;finalResponseRT;backspacedFirstCharacter;givenResponse"
  452. set break_if "=len(curItems)==0"
  453. setcycle 0 backspacedFirstCharacter "-1"
  454. setcycle 0 finalResponseRT "-1"
  455. setcycle 0 backspaceUsed "-1"
  456. setcycle 0 firstResponseRT "-1"
  457. setcycle 0 cue "none"
  458. setcycle 0 trialType "none"
  459. setcycle 0 givenResponse "xxx"
  460. setcycle 0 response "none"
  461. run selectAndPresentItem
  462.  
  463. define sketchpad welcome
  464. set start_response_interval no
  465. set reset_variables no
  466. set duration keypress
  467. set description "Displays stimuli"
  468. draw textline center=1 color=white font_bold=no font_family=serif font_italic=no font_size=32 html=yes show_if=always text="OpenSesame 3.0 <i>Interactive Ising</i>" x=0 y=0 z_index=0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement