Beispiel #1
0
def test_1(soundfiles, soundID, ID=0):

    if (ID == 1):        
        gui.show()
        subj_id = gui.data[0]
    else:
        subj_id = 'dummy'

    # make a text file to save data
    fileName = expInfo['dateStr'] + expInfo['dateStr']
    dataFile = open('data/'+fileName+'.csv', 'w')  
    dataFile.write('ID, voice, choice1, t1, s1, choice2, t2, s2, choice3, t3, s3 \n') # todo ID, suitability

    shuffle = random.sample(range(0, len(robots)), len(robots))
    soundfiles = [ soundfiles[i] for i in shuffle]
    soundID = [ soundID[i] for i in shuffle]

    counter = 0
    for voices in soundfiles:
        tempResponse = [subj_id, soundID[counter]]  
        counter+=1
        robot_list = updateRobotList()
        # first turn 
        # a) play 3 sound clips at random
        voiceOrder = []
        for i in range(0,3):
            voice = random.choice(voices)
            voiceOrder.append(voice)
            playSound(voice)
            core.wait(0.5)        

        # b) splash screen with options     
        num_pick = 0
        while  num_pick < 3:
            selectRobot(num_pick,robot_list)
            win.flip()
            clock.reset()
            [name, clicked, timer] = checkRobot()
            print("time taken was %f seconds" % timer)
            

            # todo save details of choice
            if name != "button":
                rating = getRating(expInfo[name])
                robot_list.remove(clicked)
                num_pick +=1
            else:
                rating = 0
                for i in range(0,len(voiceOrder)):
                    playSound(voiceOrder[i])
                    core.wait(0.5) 
            tempResponse.append(name)
            tempResponse.append(str(timer))
            tempResponse.append(str(rating))
            core.wait(0.2)
        tempResponse = ','.join(tempResponse)
        saveData(dataFile, tempResponse+'\n')
        print(tempResponse)
def init_and_show_gui():
    gui = psychopy.gui.Dlg()
    gui.addField("Participant Number:", "001")
    gui.addField("Condition Number:", 1)
    gui.addField("Age:", 26)
    gui.addField("Gender(m/f/o):", "f")
    gui.show()
    print(gui.data)
    return gui
Beispiel #3
0
def registration(gui=gui):
    gui = gui.Dlg()
    gui.addField("Subject ID:")
    gui.addField("Condition Num:")
    gui.show()
    gui.close()
    #save data
    subj_id = gui.data[0]
    cond_num = int(gui.data[1])  # Control =0, retreat = 1
    return (subj_id, cond_num)  #save this data as the excell name?


# cross object

# registration()
def show_dialog_and_get_info():
    print("show_dialog...")
    gui = psychopy.gui.Dlg()
    gui.addField("Participant Name:", "Ilaria")
    gui.addField("Condition Number:", 1)
    gui.addField("Age:", 26)
    gui.addField("Gender(m/f/o):", "f")
    # this is a blocking function. as long as the participant has not clicked ok the code progression
    # will be blocked here
    gui.show()
    participant_number = gui.data[0]
    cond_num = int(gui.data[1])
    age = int(gui.data[2])
    gender = (gui.data[3])
    return participant_number, cond_num, age, gender
# Stimulus parameters
habituation_total_duration = 10  # in seconds
habituation_image_duration = 0.5  # in seconds
habituation_isi = 0.2  # in seconds
test_total_duration = 10  # in seconds
test_image_duration = 1  # in seconds
test_isi = 1  # in seconds
background_color = 'grey'
path_to_images = 'G:\My Drive\Lara\SNARC'
#path_to_logfile = 'G:\My Drive\Lara\SNARC\test\test.txt'

# This creates the message box to get measure ID
gui = gui.Dlg()
gui.addField("Subject ID:")
gui.show()

# This creates the windows where you draw your stimuli
window_1 = visual.Window(size=(monitor_width, monitor_height),
                         fullscr=True,
                         screen=0,
                         allowGUI=False,
                         units='pix',
                         monitor='testMonitor',
                         colorSpace='rgb255',
                         color=background_color)

# Create images
squares_12_1 = visual.ImageStim(window_1,
                                image=path_to_images + '\squares_12_1.png',
                                mask=None,
def RunMathTask():
    #declare global variables
    global task_start_time
    global window
    global kb
    global log_file
    global procs
    global rules
    global pracs
    global rulenames
    global pracnames
    global instnames
    global insts
    global postnames
    global posts
    global gui

    #Get Subject ID using gui

    gui = gui.Dlg()
    gui.addField("Subject ID:")
    gui.show()
    SubjectID = gui.data[0]
    print(SubjectID)

    #onset of first instruction via image

    proc1 = visual.ImageStim(window, image='Proc01.jpeg')

    proc1.draw()
    window.flip()

    proc1response = event.waitKeys(keyList=[
        'space',
    ], timeStamped=True)

    #Rule videos and practice problem sequence

    #play each of the 6 rule videos
    for i in range(3):
        rulemov = visual.MovieStim3(window,
                                    name=rulenames[i],
                                    noAudio=False,
                                    filename=rules[i])

        rulemov.play()

        #play full video for each
        for j in range(int(rulemov.duration * 60)):
            rulemov.draw()
            window.flip()

    #show each of the 6 practice problems, participants have to answer each one using '1', '2', or '3'
    responserec = ""

    for i in range(6):
        ruleprac = visual.ImageStim(window, name=pracnames[i], image=pracs[i])

        ruleprac.draw()
        window.flip()

        pracresponse = event.waitKeys(keyList=[
            '1',
            '2',
            '3',
        ],
                                      timeStamped=True)

        #log Subject ID, name of the problem, and response to each problem
        log_file.write(SubjectID + "," + pracnames[i] + "," +
                       pracresponse[0][0] + "\n")

    #onset of second instruction via image (we skip Proc02 in the lab and go right to Proc03)
    proc3 = visual.ImageStim(window, image='Proc03.jpeg')

    proc3.draw()
    window.flip()

    proc3response = event.waitKeys(keyList=[
        'space',
    ], timeStamped=True)

    #instructional problem sequence

    #show each of the 8 instructional problems, participants have to answer each one using '1', '2', or '3'
    responserec = ""

    for i in range(8):
        instprobs = visual.ImageStim(window, name=instnames[i], image=insts[i])

        instprobs.draw()
        window.flip()

        instresponse = event.waitKeys(keyList=[
            '1',
            '2',
            '3',
        ],
                                      timeStamped=True)

        #log Subject ID, name of the problem, and response to each problem
        log_file.write(SubjectID + "," + instnames[i] + "," +
                       instresponse[0][0] + "\n")

    #onset of next instruction screen via image (this image prompts the post test)
    proc4 = visual.ImageStim(window, image='Proc04.jpeg')

    proc4.draw()
    window.flip()

    proc4response = event.waitKeys(keyList=[
        'space',
    ], timeStamped=True)

    #beginning of post test

    #show each of the 8 instructional problems, participants have to answer each one using '1', '2', or '3'
    responserec = ""

    for i in range(35):
        postprobs = visual.ImageStim(window, name=postnames[i], image=posts[i])

        postprobs.draw()
        window.flip()

        postresponse = event.waitKeys(keyList=[
            '1',
            '2',
            '3',
        ],
                                      timeStamped=True)

        #log Subject ID, name of the problem, and response to each problem
        log_file.write(SubjectID + "," + postnames[i] + "," +
                       postresponse[0][0] + "\n")

    #onset of final instruction  screen thanking participant for participation
    proc5 = visual.ImageStim(window, image='Proc05.jpeg')

    proc5.draw()
    window.flip()

    proc5response = event.waitKeys(keyList=[
        'space',
    ], timeStamped=True)