Exemple #1
0
    sendTriggerMEG(trigger)
    time = expclock.getTime()
    t.write('%d, %3.6f\n' % (trigger, time))
    # reset trigger after
    win.flip()
    trigger = 0
    sendTriggerMEG(trigger)
    #------------------------------------------------------------------

    # trial loop
    for trial in range(
            totalBlockTrials
    ):  # range(totalBlockTrials*blocks) # minus the placeholder so that we run fewer trials when we have already done some
        # length of presentations:
        ISI = round(
            (0.6 + random.randrange(0, 1000) / 5000) * MonFrameRate
        )  # picks a random length (0.6 - 0.8s) with millisecond precision
        ITI = round(
            (1 + random.randrange(0, 1000) / 5000
             ))  # picks a random length (1 - 1.2s) with millisecond precision
        # ITI is in seconds and not frames because easier to wait for keys

        ISI = int(ISI)

        # setting up grating contrast levels:
        g1 = contrast_g1[indexing[trial]]
        g2 = contrast_g2[indexing[trial]]
        grating1.contrast = g1
        grating2.contrast = g2
        correctResp = correctResps[indexing[trial]]
        # showing stimuli:
for thisTrial in trials:
    currentLoop = trials
    # abbreviate parameter names if possible (e.g. rgb = thisTrial.rgb)
    if thisTrial != None:
        for paramName in thisTrial.keys():
            exec(paramName + '= thisTrial.' + paramName)
    
    #------Prepare to start Routine "trial"-------
    t = 0
    trialClock.reset()  # clock 
    frameN = -1
    # update component parameters for each repeat
    import random
    
    jitter = random.randrange(50, 100)*.01
    key_resp_2 = event.BuilderKeyResponse()  # create an object of type KeyResponse
    key_resp_2.status = NOT_STARTED
    # keep track of which components have finished
    trialComponents = []
    trialComponents.append(ISI)
    trialComponents.append(text)
    trialComponents.append(key_resp_2)
    trialComponents.append(text_2)
    for thisComponent in trialComponents:
        if hasattr(thisComponent, 'status'):
            thisComponent.status = NOT_STARTED
    
    #-------Start Routine "trial"-------
    continueRoutine = True
    while continueRoutine:
                resp.corr = 1  # correct non-response
            else:
                resp.corr = 0  # failed to respond (incorrectly)
        # store data for ReDoLoop (TrialHandler)
        ReDoLoop.addData('resp.keys', resp.keys)
        ReDoLoop.addData('resp.corr', resp.corr)
        if resp.keys != None:  # we had a response
            ReDoLoop.addData('resp.rt', resp.rt)

        #------Prepare to start Routine "feedback"-------
        t = 0
        feedbackClock.reset()  # clock
        frameN = -1
        routineTimer.add(1.000000)
        # update component parameters for each repeat
        DisplayReward = random.randrange(1, 6)

        if resp.corr:  #stored on last run routine
            if DisplayReward == 1:
                message = "You won " + str(0)
            else:
                if ConditionChoice == 1:
                    CurrentReward = ConditionOne['reward']
                    message = "You won " + str(CurrentReward +
                                               (random.randrange(-25, 26) *
                                                .01))
                elif ConditionChoice == 2:
                    CurrentReward = ConditionTwo['reward']
                    message = "You won " + str(CurrentReward +
                                               (random.randrange(-25, 26) *
                                                .01))
Exemple #4
0
    trialDetails = {} # a dictionary of key-value pairs
    trialDetails['fileName'] = shapes[i] + color + '.gif'
    trialDetails['reward'] = rewards[i]
    trialDetails['condition'] = conditions[i]
    trialDetailsList.append(trialDetails)

shuffle(trialDetailsList) # do this now to ensure that order of presentation of rewards and conditions is also shuffled

for k in range(0, numLearningRepetitions):
    for n in range (0, numStim): 
        learningTrialList.append(trialDetailsList[n])

shuffle(learningTrialList)

for o in range(0, numLearningPracTrial):
    p = random.randrange(0, numStim)
    learningPracTrialList.append(trialDetailsList[p])

shuffle(learningPracTrialList)

for q in range (0, numStim):
    if trialDetailsList[q] == 'go':
        trialDetailsList[q]['stopOrGo'] =  'go'
        for i in range(0, goTrialsPerGoStim):
            stopTrialList.append(deepcopy(trialDetailsList[q])
    elif trialDetailsList[q] == 'stop':
        for j in range(0, goTrialsPerStopStim):
            trialDetailsList[q]['stopOrGo'] = 'go'
            stopTrialList.append(deepcopy(trialDetailsList[q])
        for i in range(0, stopTrialsPerStopStim + 1):
            trialDetailsList[q]['stopOrGo'] = 'stop'
Exemple #5
0
    elif ConditionChoice == 2:
        CurrentReward = ConditionTwo['reward']
    elif ConditionChoice == 3:
        CurrentReward = ConditionThree['reward']
    elif ConditionChoice == 4:
        CurrentReward = ConditionFour['reward']
    elif ConditionChoice == 5:
        CurrentReward = ConditionFive['reward']
    elif ConditionChoice == 6:
        CurrentReward = ConditionSix['reward']
    elif ConditionChoice == 7:
        CurrentReward = ConditionSeven['reward']
    elif ConditionChoice == 8:
        CurrentReward = ConditionEight['reward']

    DisplayReward = random.randrange(1, 6)
    if DisplayReward == 1:
        message = 0
    else:
        message = CurrentReward + (random.randrange(-25, 26) * .01)
    feedback_2.setText(message)
    # keep track of which components have finished
    feedbackComponents = []
    feedbackComponents.append(feedback_2)
    for thisComponent in feedbackComponents:
        if hasattr(thisComponent, 'status'):
            thisComponent.status = NOT_STARTED

    #-------Start Routine "feedback"-------
    continueRoutine = True
    while continueRoutine and routineTimer.getTime() > 0:
 elif ConditionChoice == 2:
     CurrentReward = ConditionTwo['reward']
 elif ConditionChoice == 3:
     CurrentReward = ConditionThree['reward']
 elif ConditionChoice == 4:
     CurrentReward = ConditionFour['reward']
 elif ConditionChoice == 5:
     CurrentReward = ConditionFive['reward']
 elif ConditionChoice == 6:
     CurrentReward = ConditionSix['reward']
 elif ConditionChoice == 7:
     CurrentReward = ConditionSeven['reward']
 elif ConditionChoice == 8:
     CurrentReward = ConditionEight['reward']
 
 DisplayReward = random.randrange(1, 6)
 if DisplayReward == 1:
     message = 0;
 else:
     message = CurrentReward + (random.randrange(-25, 26)*.01)
 feedback_2.setText(message)
 # keep track of which components have finished
 feedbackComponents = []
 feedbackComponents.append(feedback_2)
 for thisComponent in feedbackComponents:
     if hasattr(thisComponent, 'status'):
         thisComponent.status = NOT_STARTED
 
 #-------Start Routine "feedback"-------
 continueRoutine = True
 while continueRoutine and routineTimer.getTime() > 0:
for thisTrial in trials:
    currentLoop = trials
    # abbreviate parameter names if possible (e.g. rgb = thisTrial.rgb)
    if thisTrial != None:
        for paramName in thisTrial.keys():
            exec(paramName + '= thisTrial.' + paramName)

    #------Prepare to start Routine "trial"-------
    t = 0
    trialClock.reset()  # clock
    frameN = -1
    # update component parameters for each repeat
    import random

    jitter = random.randrange(50, 100) * .01
    key_resp_2 = event.BuilderKeyResponse(
    )  # create an object of type KeyResponse
    key_resp_2.status = NOT_STARTED
    # keep track of which components have finished
    trialComponents = []
    trialComponents.append(ISI)
    trialComponents.append(text)
    trialComponents.append(key_resp_2)
    trialComponents.append(text_2)
    for thisComponent in trialComponents:
        if hasattr(thisComponent, 'status'):
            thisComponent.status = NOT_STARTED

    #-------Start Routine "trial"-------
    continueRoutine = True
    else: resp.corr = 0  # failed to respond (incorrectly)
 # store data for ReDoLoopMain (TrialHandler)
 ReDoLoopMain.addData('resp.keys',resp.keys)
 ReDoLoopMain.addData('resp.corr', resp.corr)
 if resp.keys != None:  # we had a response
     ReDoLoopMain.addData('resp.rt', resp.rt)
 
 #------Prepare to start Routine "feedback"-------
 t = 0
 feedbackClock.reset()  # clock 
 frameN = -1
 routineTimer.add(1.000000)
 # update component parameters for each repeat
 import random
 
 displayReward = random.randrange(1, 6)
 
 if resp.corr:#stored on last run routine
     if displayReward == 1:
             message = "You won $" + str(0);
     else: 
             currentReward = currentLearningTrial['reward']
             message = "You won $" + str(currentReward + (random.randrange(-25, 26)*.01))
 elif resp.keys is None: #or len(key_resp.keys)<1:
 #elif resp.rt == 0:
     message ="Too Slow"
 else:
   message="Wrong"
 feedback_2.setText(message)
 image.setPos([xPos, yPos])
 image.setImage(currentStimulus)
 elif ConditionChoice == 2:
     CurrentReward = ConditionTwo['reward']
 elif ConditionChoice == 3:
     CurrentReward = ConditionThree['reward']
 elif ConditionChoice == 4:
     CurrentReward = ConditionFour['reward']
 elif ConditionChoice == 5:
     CurrentReward = ConditionFive['reward']
 elif ConditionChoice == 6:
     CurrentReward = ConditionSix['reward']
 elif ConditionChoice == 7:
     CurrentReward = ConditionSeven['reward']
 elif ConditionChoice == 8:
     CurrentReward = ConditionEight['reward']
 
 message = CurrentReward + (random.randrange(-25, 26)*.01)
 feedback_2.setText(message)
 # keep track of which components have finished
 feedbackComponents = []
 feedbackComponents.append(feedback_2)
 for thisComponent in feedbackComponents:
     if hasattr(thisComponent, 'status'):
         thisComponent.status = NOT_STARTED
 
 #-------Start Routine "feedback"-------
 continueRoutine = True
 while continueRoutine and routineTimer.getTime() > 0:
     # get current time
     t = feedbackClock.getTime()
     frameN = frameN + 1  # number of completed frames (so 0 is the first frame)
     # update/draw components on each frame