我正在尝试修改演示IAT并添加更复杂的反馈

时间:2015-05-25 11:15:28

标签: python psychopy

我几乎是'建设者'用户。

我通过修改“demo IAT practical-Creative”来制作IAT 但我发现演示IAT与哈佛IAT和另一种IAT在反馈方面有所不同。 演示IAT:反馈“X”出现,如果出现,则允许的键都是“e”和“i”。如果参与者第二次出错,则例程结束并继续。 哈佛和其他IAT:出现反馈“X”,如果出现,则允许的键只是“正确”键。如果参与者再次犯错,他或她无法结束审判,并且“X”出现,直到参与者按下正确的密钥。

我试图将demoIAT修改为像哈佛和其他IAT一样。

我做了 [允许的密钥] => $ [key](设置每次重复)
(“key”是包含正确答案的excel列)

虽然有效,但实际上,问题发生在下一次试验中。 有时,如果参与者连续按错了答案,但最后按正确答案, 下一次试验的刺激出现“带X”......反馈X ..

我不知道它是之前试验的剩余部分.. 喜欢时间分辨率的问题..

当参与者连续按下按钮时,心理模糊通常会出现问题 不必要的巨大时间?

我将保留代码版本.. 我会留下一个常规块.. 这与demoIAT几乎相同,只是它在“Keys_1”响应中只有一个“允许键”。

#-------Start Routine "Block1"-------
continueRoutine = True
while continueRoutine:
    # get current time
    t = Block1Clock.getTime()
    frameN = frameN + 1  # number of completed frames (so 0 is the first frame)
    # update/draw components on each frame

    # *Near* updates
    if t >= 0 and Near.status == NOT_STARTED:
        # keep track of start time/frame for later
        Near.tStart = t  # underestimates by a little under one frame
        Near.frameNStart = frameN  # exact frame index
        Near.setAutoDraw(True)

    # *Distal* updates
    if t >= 0.0 and Distal.status == NOT_STARTED:
        # keep track of start time/frame for later
        Distal.tStart = t  # underestimates by a little under one frame
        Distal.frameNStart = frameN  # exact frame index
        Distal.setAutoDraw(True)

    # *Response_1* updates
    if t >= 0.3 and Response_1.status == NOT_STARTED:
        # keep track of start time/frame for later
        Response_1.tStart = t  # underestimates by a little under one frame
        Response_1.frameNStart = frameN  # exact frame index
        Response_1.status = STARTED
        # keyboard checking is just starting
        Response_1.clock.reset()  # now t=0
    if Response_1.status == STARTED and (feedback_text.status == STARTED):
        Response_1.status = STOPPED
    if Response_1.status == STARTED:
        theseKeys = event.getKeys(keyList=['e', 'i'])

        # check for quit:
        if "escape" in theseKeys:
            endExpNow = True
        if len(theseKeys) > 0:  # at least one key was pressed
            if Response_1.keys == []:  # then this was the first keypress
                Response_1.keys = theseKeys[0]  # just the first key pressed
                Response_1.rt = Response_1.clock.getTime()
                # was this 'correct'?
                if (Response_1.keys == str(key)) or (Response_1.keys == key):
                    Response_1.corr = 1
                else:
                    Response_1.corr = 0
    if Response_1.status == STARTED:
        if len(theseKeys) > 0:
            if Response_1.corr == 1:
                continueRoutine = False
            else:
                feedback_text.setAutoDraw(True)
                feedback_text.status = STARTED


    # *feedback_text* updates
    if (len(theseKeys) > 5) and feedback_text.status == NOT_STARTED:
        # keep track of start time/frame for later
        feedback_text.tStart = t  # underestimates by a little under one frame
        feedback_text.frameNStart = frameN  # exact frame index
        feedback_text.setAutoDraw(True)
    if feedback_text.status == STARTED:  # only update if being drawn
        feedback_text.setColor(u'red', colorSpace='rgb', log=False)
        feedback_text.setPos([0, -.3], log=False)
        feedback_text.setText(u'X', log=False)
        feedback_text.setFont(u'Arial', log=False)
        feedback_text.setHeight(0.3, log=False)

    # *wordimage_1* updates
    if t >= 0.3 and wordimage_1.status == NOT_STARTED:
        # keep track of start time/frame for later
        wordimage_1.tStart = t  # underestimates by a little under one frame
        wordimage_1.frameNStart = frameN  # exact frame index
        wordimage_1.setAutoDraw(True)

    # *Keys_1* updates
    if (feedback_text.status == STARTED) and Keys_1.status == NOT_STARTED:
        # keep track of start time/frame for later
        Keys_1.tStart = t  # underestimates by a little under one frame
        Keys_1.frameNStart = frameN  # exact frame index
        Keys_1.status = STARTED
        # AllowedKeys looks like a variable named `key`
        if not 'key' in locals():
            logging.error('AllowedKeys variable `key` is not defined.')
            core.quit()
        if not type(key) in [list, tuple, np.ndarray]:
            if not isinstance(key, basestring):
                logging.error('AllowedKeys variable `key` is not string- or list-like.')
                core.quit()
            elif not ',' in key: key = (key,)
            else:  key = eval(key)
        # keyboard checking is just starting
        Keys_1.clock.reset()  # now t=0
        event.clearEvents(eventType='keyboard')
    if Keys_1.status == STARTED:
        theseKeys = event.getKeys(keyList=list(key))

        # check for quit:
        if "escape" in theseKeys:
            endExpNow = True
        if len(theseKeys) > 0:  # at least one key was pressed
            if Keys_1.keys == []:  # then this was the first keypress
                Keys_1.keys = theseKeys[0]  # just the first key pressed
                Keys_1.rt = Keys_1.clock.getTime()
                # was this 'correct'?
                if (Keys_1.keys == str(key)) or (Keys_1.keys == key):
                    Keys_1.corr = 1
                else:
                    Keys_1.corr = 0
                # a response ends the routine
                continueRoutine = False

    # check if all components have finished
    if not continueRoutine:  # a component has requested a forced-end of Routine
        break
    continueRoutine = False  # will revert to True if at least one component still running
    for thisComponent in Block1Components:
        if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
            continueRoutine = True
            break  # at least one component has not yet finished

    # check for quit (the Esc key)
    if endExpNow or event.getKeys(keyList=["escape"]):
        core.quit()

    # refresh the screen
    if continueRoutine:  # don't flip if this routine is over or we'll get a blank screen
        win.flip()

#-------Ending Routine "Block1"-------
for thisComponent in Block1Components:
    if hasattr(thisComponent, "setAutoDraw"):
        thisComponent.setAutoDraw(False)
# check responses
if Response_1.keys in ['', [], None]:  # No response was made
   Response_1.keys=None
   # was no response the correct answer?!
   if str(key).lower() == 'none': Response_1.corr = 1  # correct non-response
   else: Response_1.corr = 0  # failed to respond (incorrectly)
# store data for trials (TrialHandler)
trials.addData('Response_1.keys',Response_1.keys)
trials.addData('Response_1.corr', Response_1.corr)
if Response_1.keys != None:  # we had a response
    trials.addData('Response_1.rt', Response_1.rt)

# check responses
if Keys_1.keys in ['', [], None]:  # No response was made
   Keys_1.keys=None
   # was no response the correct answer?!
   if str(key).lower() == 'none': Keys_1.corr = 1  # correct non-response
   else: Keys_1.corr = 0  # failed to respond (incorrectly)
# store data for trials (TrialHandler)
trials.addData('Keys_1.keys',Keys_1.keys)
trials.addData('Keys_1.corr', Keys_1.corr)
if Keys_1.keys != None:  # we had a response
    trials.addData('Keys_1.rt', Keys_1.rt)
# the Routine "Block1" was not non-slip safe, so reset the non-slip timer
routineTimer.reset()
thisExp.nextEntry()

完成了2次重复的“试验”

0 个答案:

没有答案