OS
Windows
PsychoPy version
2020.2.4
Standard Standalone? (y/n)
Y
What are you trying to achieve?:
I am trying to create a masked self-paced reading experiment which:
- Shows an entire paragraph on screen.
- Changes all words but the currently read sentence to the letter “X”.
- Allows participants to use the ‘down’ key to read the next line of the paragraph and the ‘up’ key to read the previous line.
3.1 If Participants press ‘Up’ on the first sentence the sentence does not change. If participants press ‘down’ on the last sentence the sentence does not change. For them to advance they must press space but only on the last line ( Line 5)
What did you try to make it work?:
I have used previous topics of discussion as a backbone for this experiment.
For example:
https://groups.google.com/g/psychopy-users/c/sjX7_Oa_WXc
and
Self paced reading - space doesn’t always move window - Builder - PsychoPy
Both of which have been very useful to understanding how these sorts of tasks are handled in PsychoPy.
From the codes used in these I created a code that I had hoped did both.
My Code is as Follows:
Begin Experiment*
Blockquote
def replaceWithdash(sentenceList, Sentence_Number):
dashSentence = ‘’
for index, word in enumerate(sentenceList):
if index != Sentence_Number:
dashSentence = dashSentence + ’ ’ + ‘-’ * len(sentence)
else:
dashSentence = dashSentence + ’ ’ + sentence
return dashSentence +‘.’
Blockquote
- Begin Routine
Blockquote
sentenceList=sentence.split(“.”)
Sentence_Number=-1
Stim_text.text = replaceWithX(sentenceList, Sentence_Number)
Blockquote
- Each Frame
Blockquote
keypresses = event.getKeys() # returns a list of keypresses
if len(keypresses) > 0: # at least one key was pushed
if ‘down’ in keypresses:
Sentence_Number = Sentence_Number + 1
if Sentence_Number < len(sentenceList):
Stim_text.text.text = replaceWithX(sentenceList, Sentence_Number)
else:
continueRoutine = False
elif ‘up’ in keypresses:
Sentence_Number = Sentence_Number -1
Stim_text.text.text = replaceWithX(sentenceList, Sentence_Number)
elif ‘esc’ in keypresses:
core.quit()
Blockquote
What specifically went wrong when you tried that?:
The way this is currently coded I get Syntax errors which I don’t really see as Syntax errors. From what I understand there are none, but PsychoPy seems to think there are.
As you can see in the code there is currently no IF (sentence_number=len(sentence_list) and if ‘space’ in keypresses. Line to end the experiment.
The reason for this is that when this code is there the experiment runs just fine, only that the welcome text is displayed and then promptly finishes the experiment, data is recorded even though nothing was pressed and no stimuli were presented.
I am going to attach my Stimulus file and Experiment file [Tst2.xlsx|attachment] (upload://tkq8TtdTEGGU2ELGGQSbe0AwbcE.xlsx) (10.1 KB) g.psyexp (11.7 KB)
P.S
I am clearly lacking some understanding as to how PsychoPy works so if you know what I have done wrong could you explain to me as though I were a crying child.