Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- API: 2
- OpenSesame: 3.0.7
- Platform: nt
- ---
- set width 1024
- set uniform_coordinates yes
- set title "New experiment"
- set subject_parity even
- set subject_nr 0
- set start experiment
- set sampler_backend legacy
- set mouse_backend xpyriment
- set keyboard_backend legacy
- set height 768
- set foreground white
- set font_size 18
- set font_italic no
- set font_family mono
- set font_bold no
- set experiment_path "C:\\Users\\Guven\\Desktop\\Minor Thesis\\Programs\\FINAL VERSIONS"
- set description "Default description"
- set coordinates uniform
- set compensation 0
- set color_backend legacy
- set clock_backend legacy
- set canvas_backend xpyriment
- set bidi no
- set background black
- define sketchpad Description
- set duration keypress
- set description "Displays stimuli"
- 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
- define sketchpad EndofExperiment
- set duration keypress
- set description "Displays stimuli"
- 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
- define notepad History_and_Documentation
- __note__
- Flashcard Learning Script for Güven's experiment
- Hedderik van Rijn, 2016
- In flashcard learning, a list of cue-response pairs is distributed over a
- number of stacks. The first time a stack is presented, it is presented as
- a learning trial, meaning that the learner sees both cue and response. After
- all items in a stack have been studied, the items are presented again in test
- trials. In these trials, a learner just sees the cue, and has to respond with
- the response. If incorrect, the item is added to the end of the current stack.
- If all items in a stack are responded to correctly, the next stack is selected,
- ad infitum.
- v1. Initial Version. See below for a wordy description of the code.
- This is a slightly complicated flashcard learning script as some items are
- presented more often than others. In defineItems, two
- dictionaries of items are defined modifiersItems and headerItems. These are the
- two stems of a compound, and we want the participants to learn half of the
- modifiers and half of the headers 3x as much as the other half. (I.e.,
- experimentally manipulate the frequency of the stems). So, after randomization,
- the two dictionaries are distributed over a high- and a low-frequent cue list
- (cueLF, cueHF).
- The loop runBlock is there to just indicate how many times a new stack has to
- be selected. Note that it is best to set this to a number that ensures that
- each block of a list is presented equally often. In the case of 24 items per
- list, and 6 items per stack (or block), we have 4 stacks in a list. With the
- HF items presented 3x as often as the LF items, the number should be set to
- n * (3 * 4 + 1 * 4), so 16, 32, etc.
- In the python code populateTheCurrentStack, we use the current block number (or
- stack number) to figure out from which list to select which items for the
- current stack.
- The loop untilCurrentStackIsEmpty repeats the selectaAndPresentItem sequence a
- very large number of times (100?), but the trick is that the "break if" is set
- so that this loop is exited as soon as the current stack is empty.
- In selectItemAndDetermineTrialType, we select and then remove the first item
- from the stack and determine whether to present it as a study or a test trial.
- If this is a study trial, the item is immediately added to the end of the stack,
- as it will be tested after all other items in the stack have been studied.
- Based on the "run if" statements in "untilCurrentStackIsEmpty", then either the
- doStudyTrial sequence or the doTestTrial sequence is selected. The former just
- presents the cue and response on the screen for the amount of time specified
- in the global studyTime. The latter presents the cue on the screen and a prompt
- indicating that the learner can type the response. Is the response is correct,
- the next item is selected. If the response is incorrect, the item is added
- to the end of the current stack, and the learner is presented a study trial.
- For each trial, the following variables are set (and exported to the CSV file):
- * cue
- * response
- * trialType (study / test)
- * currentBlock: current block number (continuously counting)
- * frequency: whether this is a 'lf' or a 'hf' block
- * whichStack: which stack within the hf/lf list this is (1..4)
- if trialType == test
- * givenResponse: the typed response
- * firstResponseRT: the RT of the first key pressed
- * finalResponseRT: the RT of the final "enter", committing the response
- * backspaceUsed: was backspace used during entry?
- * backspacedFirstCharacter: was the first character of the response backspace'd?
- __end__
- set description ""
- define sketchpad Instructions
- set duration keypress
- set description "Displays stimuli"
- 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
- define sketchpad Instructions2
- set duration keypress
- set description "Displays stimuli"
- 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
- 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
- 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
- define sketchpad StudyBEGIN
- set duration keypress
- set description "Displays stimuli"
- 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
- define sequence blockSequence
- set flush_keyboard yes
- set description "Runs a number of items in sequence"
- run populateTheCurrentStack always
- run untilCurrentStackIsEmpty always
- define inline_script collectAndDisplayInput
- set description "Executes Python code"
- ___run__
- from openexp.canvas import canvas
- from openexp.keyboard import keyboard
- # vertical coordinate of image and text
- instructionY = int(self.get('height') * -0.1)
- cueY = int(0)
- answerY = int(self.get('height') * 0.1)
- # allowed characters
- allowed = 'abcdefghijklmnopqrstuvwxyz.,'
- # create objects
- my_kb = keyboard(exp)
- my_canvas = canvas(exp)
- # draw the first canvas
- my_canvas.clear()
- my_canvas.text(var.cue, center=True, color='White', max_width=None, html=True, bidi=False, y=cueY, x=None)
- my_canvas.text('Translate:', center=True, color='Blue', max_width=None, html=True, bidi=False, y=instructionY, x=None)
- my_canvas.text('_', center=True, color='White', max_width=None, html=True, bidi=False, y=answerY, x=None)
- my_canvas.show()
- # run until the Enter key is pressed
- stop = False
- my_string = ""
- startTime = -1
- bsUsed = 0
- bsFirstCharacter = 0
- # get starting time
- t0 = self.time()
- while not stop:
- # get keypress
- key, t1 = my_kb.get_key(timeout=None)
- # handle input
- if key.lower() in allowed:
- if (startTime == -1):
- startTime = t1
- my_string += key
- elif key == 'space':
- my_string += " "
- elif key in ['enter','return']:
- stop = True
- elif key =='backspace' and len(my_string) > 0:
- my_string = my_string[:-1]
- bsUsed = 1
- if (len(my_string)) == 0:
- bsFirstCharacter = 1
- # update display
- my_canvas.clear()
- my_canvas.text(var.cue, center=True, color='White', max_width=None, html=True, bidi=False, y=cueY, x=None)
- my_canvas.text('Translate:', center=True, color='Blue', max_width=None, html=True, bidi=False, y=instructionY, x=None)
- my_canvas.text(my_string + '_', center=True, color='White', max_width=None, html=True, bidi=False, y=answerY, x=None)
- my_canvas.show()
- # save the string
- exp.set("givenResponse", my_string)
- exp.set("firstResponseRT", startTime-t0)
- exp.set("finalResponseRT", t1-t0)
- exp.set("backspaceUsed", bsUsed)
- exp.set("backspacedFirstCharacter", bsFirstCharacter)
- # Add incorrect responded items to the end of the stack:
- if (var.response != var.givenResponse):
- curItems.append(var.cue)
- __end__
- set _prepare ""
- define inline_script defineItems
- set description "Executes Python code"
- ___run__
- import random
- ## Define all items by using 'TurkishWord':'DutchWord' definition pairs.
- 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' }
- 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' }
- allItems = modifiersItems.copy()
- allItems.update(headersItems)
- modifiersCues = list(modifiersItems)
- headersCues = list(headersItems)
- ## In the final code, this should be shuffled.
- random.shuffle(modifiersCues)
- random.shuffle(headersCues)
- ## cuesLF will contain the items that are presented less often, cuesHF will
- ## present the items that will be presented more often.
- cuesLF = [modifiersCues[i] for i in range(12)]
- cuesHF = [modifiersCues[i] for i in range(12,24)]
- cuesLF.extend([headersCues[i] for i in range(12)])
- cuesHF.extend([headersCues[i] for i in range(12,24)])
- random.shuffle(cuesLF)
- random.shuffle(cuesHF)
- ## To keep track which item has been presented
- itemsPresented = []
- ## Current Block
- curBlock = 0;
- #modifiersItems[cuesLF[0]]
- __end__
- set _prepare ""
- define inline_script displayStudyInfo
- set description "Executes Python code"
- ___run__
- from openexp.canvas import canvas
- # vertical coordinate of image and text
- instructionY = int(self.get('height') * -0.1)
- cueY = int(0)
- answerY = int(self.get('height') * 0.1)
- # create objects
- my_canvas = canvas(exp)
- # draw the first canvas
- my_canvas.clear()
- my_canvas.text(var.cue, center=True, color='White', max_width=None, html=True, bidi=False, y=cueY, x=None)
- my_canvas.text('Study:', center=True, color='Green', max_width=None, html=True, bidi=False, y=instructionY, x=None)
- my_canvas.text(var.response, center=True, color='White', max_width=None, html=True, bidi=False, y=answerY, x=None)
- my_canvas.show()
- clock.sleep(studyTime)
- __end__
- set _prepare ""
- define sequence doStudyTrial
- set flush_keyboard yes
- set description "Runs a number of items in sequence"
- run fixation always
- run displayStudyInfo always
- define sequence doTestTrial
- set flush_keyboard yes
- set description "Runs a number of items in sequence"
- run fixation always
- run collectAndDisplayInput always
- run studyAfterIncorrectResponse_1 always
- define sequence experiment
- set flush_keyboard yes
- set description "Runs a number of items in sequence"
- run History_and_Documentation always
- run welcome always
- run Description always
- run Instructions always
- run Instructions2 always
- run StudyBEGIN always
- run globals always
- run defineItems always
- run runBlock always
- run EndofExperiment always
- define sketchpad fixation
- set duration "[fixationDuration]"
- set description "Displays stimuli"
- draw fixdot color=white show_if=always style=default x=0 y=0 z_index=0
- define inline_script globals
- set description "Executes Python code"
- ___run__
- global modifiersItems
- global headersItems
- global allItems
- global cuesLF
- global cuesHF
- global itemsPresented
- global curBlock
- global studyTime
- global whichLFBlock
- global whichHFBlock
- whichLFBlock = 0
- whichHFBlock = 0
- var.experimentVersion = 'v1'
- var.fixationDuration = 1000
- ## The time a study item is presented on the screen
- studyTime = 3000
- __end__
- set _prepare ""
- define logger new_logger
- set description "Logs experimental data"
- set auto_log yes
- define inline_script populateTheCurrentStack
- set description "Executes Python code"
- ___run__
- import random
- curBlock = curBlock + 1
- var.currentBlock = curBlock
- ## Present a low frequency block if this is the fourth, eight, etc block:
- if (curBlock % 4) == 0:
- ## Figure out which "internal" stack of the LF items should be used:
- whichLFBlock += 1
- if (whichLFBlock > 4):
- whichLFBlock = 1
- var.frequency = 'lf'
- var.whichStack = whichLFBlock
- ## populate the curItems list with the items of this stack
- curItems = cuesLF[((whichLFBlock-1)*6):whichLFBlock*6]
- else:
- whichHFBlock += 1
- if (whichHFBlock > 4):
- whichHFBlock = 1
- var.frequency = 'hf'
- var.whichStack = whichHFBlock
- curItems = cuesHF[((whichHFBlock-1)*6):whichHFBlock*6]
- random.shuffle(curItems)
- ## Needs to be shuffled in the final version
- # shuffle(curItems)
- __end__
- set _prepare ""
- define loop runBlock
- set skip 0
- set repeat 16
- set order random
- set offset no
- set item blockSequence
- set description "Repeatedly runs another item"
- set cycles 1
- set column_order ""
- set break_if never
- run blockSequence
- define sequence selectAndPresentItem
- set flush_keyboard yes
- set description "Runs a number of items in sequence"
- run selectItemAndDetermineTrialType always
- run doStudyTrial "[trialType] = 'study'"
- run doTestTrial "[trialType] = 'test'"
- run new_logger always
- define inline_script selectItemAndDetermineTrialType
- set description "Executes Python code"
- set _run ""
- ___prepare__
- ## Select the current item:
- curItem = curItems[0]
- ## Remove this item for the to be studied items, as the participant might
- ## answer it correctly.
- curItems.remove(curItem)
- ## Figure out whether we already presented this item. If so, present a test
- ## trial, if not, present a study trial *and* make sure that next time round
- ## we'll present it as a study trial.
- if (curItem in itemsPresented):
- trialType = 'test'
- else:
- trialType = 'study'
- curItems.append(curItem)
- itemsPresented.append(curItem)
- var.cue = curItem
- var.response = allItems[curItem]
- var.trialType = trialType
- __end__
- define inline_script studyAfterIncorrectResponse_1
- set description "Executes Python code"
- ___run__
- from openexp.canvas import canvas
- # vertical coordinate of image and text
- instructionY = int(self.get('height') * -0.1)
- cueY = int(0)
- answerY = int(self.get('height') * 0.1)
- my_canvas = canvas(exp)
- if (var.response != var.givenResponse):
- # update display
- my_canvas.clear()
- my_canvas.text('Incorrect, re-study:', center=True, color='Red', max_width=None, html=True, bidi=False, y=instructionY, x=None)
- my_canvas.text(var.cue, center=True, color='White', max_width=None, html=True, bidi=False, y=cueY, x=None)
- my_canvas.text(var.response, center=True, color='White', max_width=None, html=True, bidi=False, y=answerY, x=None)
- my_canvas.show()
- clock.sleep(studyTime)
- __end__
- set _prepare ""
- define loop untilCurrentStackIsEmpty
- set skip 0
- set repeat 100
- set order random
- set offset no
- set item selectAndPresentItem
- set description "Repeatedly runs another item"
- set cycles 1
- set column_order "cue;response;trialType;backspaceUsed;firstResponseRT;finalResponseRT;backspacedFirstCharacter;givenResponse"
- set break_if "=len(curItems)==0"
- setcycle 0 backspacedFirstCharacter "-1"
- setcycle 0 finalResponseRT "-1"
- setcycle 0 backspaceUsed "-1"
- setcycle 0 firstResponseRT "-1"
- setcycle 0 cue "none"
- setcycle 0 trialType "none"
- setcycle 0 givenResponse "xxx"
- setcycle 0 response "none"
- run selectAndPresentItem
- define sketchpad welcome
- set start_response_interval no
- set reset_variables no
- set duration keypress
- set description "Displays stimuli"
- 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