Beispiel #1
0
import sys, os
sys.path.append('./submodules')
from psychopy import visual, core
import config

win = visual.Window([400, 400], screen=1, winType='pyglet',
                    color=[-1, -1, -1])  #,fullscr=True)
stim = visual.TextStim(win=win,
                       text='01234',
                       pos=[0, 100],
                       units='pix',
                       height=20)
stim.fontFiles = [
    os.path.join(config.assetsPath, config.stimulusFont)
]  # set fontFiles to include our local version of snellen rather than using installed version
stim.font = os.path.splitext(config.stimulusFont)[0]
stim2 = visual.TextStim(win=win,
                        text='01234',
                        pos=[0, -100],
                        units='pix',
                        height=300)
stim2.fontFiles = [
    os.path.join(config.assetsPath, config.stimulusFont)
]  # set fontFiles to include our local version of snellen rather than using installed version
stim2.font = os.path.splitext(config.stimulusFont)[0]

for i in range(20, 300):
    stim.height = 2**(i / 40)
    stim.draw(win)
    stim2.height = 202 - 2**(i / 40)
    stim2.draw(win)
Beispiel #2
0
    frameDur = 1.0 / round(expInfo['frameRate'])
else:
    frameDur = 1.0 / 60.0  # could not measure, so guess

# create a default keyboard (e.g. to check for escape)
defaultKeyboard = keyboard.Keyboard()

# Initialize components for Routine "Instructionm"
InstructionmClock = core.Clock()
text_2 = visual.TextStim(
    win=win,
    name='text_2',
    text='Try memorize the word and the images paried with each word.',
    font='Arial',
    pos=(0, 0),
    height=0.1,
    wrapWidth=None,
    ori=0,
    color='Red',
    colorSpace='rgb',
    opacity=1,
    languageStyle='LTR',
    depth=0.0)

# Initialize components for Routine "trial"
trialClock = core.Clock()
text = visual.TextStim(win=win,
                       name='text',
                       text='default text',
                       font='Arial',
                       pos=(0, 0),
                       height=0.1,
timer = core.Clock()
globalClock = core.Clock()

# response parameters
resp = ['1', '2']

# color parameters
# window setup
win = visual.Window([800,600], monitor="testMonitor", units="deg", fullscr=False,
    allowGUI=False, screen=0) #set screen to 1 for dual monitor

#colors
colors = ['red', 'green', 'blue']

# visual stim setup
word = visual.TextStim(win, height=1, alignHoriz='center', alignVert='center')
fixation = visual.TextStim(win, text="+", height=2)

# setting up the trial handler
trial_data = [r for r in csv.DictReader(open('%s/misc/PsychoPy_Intro-stim.csv' % pwd, 'rU'))]
print(trial_data)
trials = data.TrialHandler(trial_data, nReps=3, method="random") # we want 12 trials, so we'll repeat the process twice
# let's loop through the task!

# this will be the FIRST AND ONLY TIME YOU RESET THE GLOBAL CLOCK
globalClock.reset()

# create a task start variable so we can calculate RT
task_onset = globalClock.getTime()

for trial in trials:
foil = visual.GratingStim(win,
                          sf=1,
                          size=4,
                          mask='gauss',
                          ori=expInfo['refOrientation'])
target = visual.GratingStim(win,
                            sf=1,
                            size=4,
                            mask='gauss',
                            ori=expInfo['refOrientation'])
fixation = visual.GratingStim(win,
                              color='black',
                              tex=None,
                              mask='circle',
                              size=0.2)
message1 = visual.TextStim(win, pos=[0, +3], text='Hit a key when ready.')
message2 = visual.TextStim(
    win,
    pos=[0, -3],
    text="Then press left or right to identify the %.1fdegree probe." %
    expInfo['refOrientation'])

# create the staircase handler
staircase = data.StairHandler(
    startVal=20.0,
    stepType='lin',
    stepSizes=[8, 4, 4, 2, 2, 1, 1],  # reduce step size every two reversals
    minVal=0,
    maxVal=90,
    nUp=1,
    nDown=3,  # will home in on the 80% threshold
Beispiel #5
0
    def run(self, *args):
        """
        The run method contains your experiment logic. In this example we:

        1) Load an xlsx file containing the trial conditions for use
           during the experiment. All DV's and IV's to be used or updated
           for each trial must be specified as columns in the xlsx file.
        2) Inform the ioDataStore of the trial conditions to be used, resulting in the
           creation of an experiment specific results table, with a field for each
           DV and IV defined in the xls file.
        3) Run the eye tracking device's runSetupProcedure(), which allows
           the calibration, validation, etc. of the eye tracking system being used.
        4) Create the experiment runtime graphics, including creating a cache of
           images to be displayed for each trial of the experiment.
        5) Run the experimental block of trials of the demo. Each trial sequence
           consists of:
               a) The participant pressing the SPACE key to start the trial.
               b) Randomly displaying one of the background images for a trial.
               c) Starting recording of data from the eye tracker.
               d) Displaying a gaze contingent dot located at the gaze position reported by the eye tracker.
               e) Ending each trial by pressing the SPACE key.
               f) Sending any condition variable value changes for that trial
                  to the ioDataStore for easy future selection of device events
                  recorded during the trial or for specific condition variable values.
               g) Stopping of event recording on the eye tracker device.
        """

        exp_conditions = importConditions('trial_conditions.xlsx')
        trials = TrialHandler(exp_conditions, 1)

        # Inform the ioDataStore that the experiment is using a
        # TrialHandler. The ioDataStore will create a table
        # which can be used to record the actual trial variable values (DV or IV)
        # in the order run / collected.
        #
        self.hub.createTrialHandlerRecordTable(trials)

        # Let's make some short-cuts to the devices we will be using
        # in this demo.
        try:
            tracker = self.hub.devices.tracker
        except:
            # No eye tracker config found in iohub_config.yaml
            from psychopy.iohub.util import MessageDialog
            md = MessageDialog(title="No Eye Tracker Configuration Found",
                               msg="Update the iohub_config.yaml file by "
                               "uncommenting\nthe appropriate eye tracker "
                               "config lines.\n\nPress OK to exit demo.",
                               showButtons=MessageDialog.OK_BUTTON,
                               dialogType=MessageDialog.ERROR_DIALOG,
                               allowCancel=False,
                               display_index=0)
            md.show()
            return 1

        display = self.hub.devices.display
        kb = self.hub.devices.keyboard
        mouse = self.hub.devices.mouse

        # Start by running the eye tracker default setup procedure.
        # The details of the setup procedure (calibration, validation, etc)
        # are unique to each implementation of the Common Eye Tracker Interface.
        # All have the common end goal of calibrating the eye tracking system
        # prior to data collection.
        # Please see the eye tracker interface implementation details for the
        # hardware being used at:
        # http://www.isolver-solutions.com/iohubdocs/iohub/api_and_manual/device_details/eyetracker.html#eye-tracking-hardware-implementations
        #
        tracker.runSetupProcedure()

        # Create a psychopy window for the experiment graphics,
        # ioHub supports the use of one full screen window during
        # the experiment runtime. (If you are using a window at all).
        #
        res = display.getPixelResolution(
        )  # Current pixel resolution of the Display to be used
        coord_type = display.getCoordinateType()
        window = visual.Window(
            res,
            monitor=display.getPsychopyMonitorName(
            ),  # name of the PsychoPy Monitor Config file if used.
            units=coord_type,  # coordinate space to use.
            fullscr=True,  # We need full screen mode.
            allowGUI=False,  # We want it to be borderless
            screen=display.getIndex(
            )  # The display index to use, assuming a multi display setup.
        )

        # Hide the 'system mouse cursor' during the experiment.
        #
        mouse.setSystemCursorVisibility(False)

        # Create a dict of image stim for trials and a gaze blob to show the
        # reported gaze position with.
        #
        image_cache = dict()
        image_names = [
            'canal.jpg', 'fall.jpg', 'party.jpg', 'swimming.jpg', 'lake.jpg'
        ]
        for iname in image_names:
            image_cache[iname] = visual.ImageStim(window,
                                                  image=os.path.join(
                                                      './images/', iname),
                                                  name=iname,
                                                  units=coord_type)

        # Create a circle to use for the Gaze Cursor. Current units assume pix.
        #
        gaze_dot = visual.GratingStim(window,
                                      tex=None,
                                      mask="gauss",
                                      pos=(0, 0),
                                      size=(66, 66),
                                      color='green',
                                      units=coord_type)

        # Create a Text Stim for use on /instuction/ type screens.
        # Current units assume pix.
        instructions_text_stim = visual.TextStim(window,
                                                 text='',
                                                 pos=[0, 0],
                                                 height=24,
                                                 color=[-1, -1, -1],
                                                 colorSpace='rgb',
                                                 alignHoriz='center',
                                                 alignVert='center',
                                                 wrapWidth=window.size[0] * .9)

        # Update Instruction Text and display on screen.
        # Send Message to ioHub DataStore with Exp. Start Screen display time.
        #
        instuction_text = "Press Any Key to Start Experiment."
        instructions_text_stim.setText(instuction_text)
        instructions_text_stim.draw()
        flip_time = window.flip()
        self.hub.sendMessageEvent(text="EXPERIMENT_START", sec_time=flip_time)

        # Wait until a key event occurs after the instructions are displayed
        self.hub.clearEvents('all')
        kb.waitForPresses()

        # Send some information to the ioDataStore as experiment messages,
        # including the experiment and session id's, the calculated pixels per
        # degree, display resolution, etc.
        #
        self.hub.sendMessageEvent(text="IO_HUB EXPERIMENT_INFO START")
        self.hub.sendMessageEvent(text="ioHub Experiment started {0}".format(
            getCurrentDateTimeString()))
        self.hub.sendMessageEvent(
            text="Experiment ID: {0}, Session ID: {1}".format(
                self.hub.experimentID, self.hub.experimentSessionID))
        self.hub.sendMessageEvent(
            text="Stimulus Screen ID: {0}, Size (pixels): {1}, CoordType: {2}".
            format(display.getIndex(), display.getPixelResolution(),
                   display.getCoordinateType()))
        self.hub.sendMessageEvent(
            text="Calculated Pixels Per Degree: {0} x, {1} y".format(
                *display.getPixelsPerDegree()))
        self.hub.sendMessageEvent(text="IO_HUB EXPERIMENT_INFO END")

        self.hub.clearEvents('all')

        # For each trial in the set of trials within the current block.
        #
        t = 0
        for trial in trials:
            # Update the instruction screen text to indicate
            # a trial is about to start.
            #
            instuction_text = "Press Space Key To Start Trial %d" % t
            instructions_text_stim.setText(instuction_text)
            instructions_text_stim.draw()
            flip_time = window.flip()
            self.hub.sendMessageEvent(text="EXPERIMENT_START",
                                      sec_time=flip_time)

            # Wait until a space key press event occurs after the
            # start trial instuctions have been displayed.
            #
            self.hub.clearEvents('all')
            kb.waitForPresses(keys=[
                ' ',
            ])

            # Space Key has been pressed, start the trial.
            # Set the current session and trial id values to be saved
            # in the ioDataStore for the upcoming trial.
            #

            trial['session_id'] = self.hub.getSessionID()
            trial['trial_id'] = t + 1

            # Send a msg to the ioHub indicating that the trial started, and the time of
            # the first retrace displaying the trial stm.
            #
            self.hub.sendMessageEvent(text="TRIAL_START", sec_time=flip_time)

            # Start Recording Eye Data
            #
            tracker.setRecordingState(True)

            # Get the image stim for this trial.
            #
            imageStim = image_cache[trial['IMAGE_NAME']]
            imageStim.draw()
            flip_time = window.flip()
            # Clear all the events received prior to the trial start.
            #
            self.hub.clearEvents('all')
            # Send a msg to the ioHub indicating that the trial started,
            # and the time of the first retrace displaying the trial stim.
            #
            self.hub.sendMessageEvent(text="TRIAL_START", sec_time=flip_time)
            # Set the value of the trial start variable for this trial
            #
            trial['TRIAL_START'] = flip_time

            # Loop until we get a keyboard event
            #
            run_trial = True
            while run_trial is True:
                # Get the latest gaze position in display coord space..
                #
                gpos = tracker.getPosition()
                if type(gpos) in [tuple, list]:
                    # If we have a gaze position from the tracker,
                    # redraw the background image and then the
                    # gaze_cursor at the current eye position.
                    #
                    gaze_dot.setPos([gpos[0], gpos[1]])
                    imageStim.draw()
                    gaze_dot.draw()
                else:
                    # Otherwise just draw the background image.
                    # This will remove the gaze cursor from the screen
                    # when the eye tracker is not successfully
                    # tracking eye position.
                    #
                    imageStim.draw()

                # Flip video buffers, displaying the stim we just
                # updated.
                #
                flip_time = window.flip()

                # Send an experiment message to the ioDataStore
                # indicating the time the image was drawn and
                # current position of gaze spot.
                #
                if type(gpos) in [tuple, list]:
                    self.hub.sendMessageEvent(
                        "IMAGE_UPDATE %s %.3f %.3f" %
                        (trial['IMAGE_NAME'], gpos[0], gpos[1]),
                        sec_time=flip_time)
                else:
                    self.hub.sendMessageEvent("IMAGE_UPDATE %s [NO GAZE]" %
                                              (trial['IMAGE_NAME']),
                                              sec_time=flip_time)

                # Check any new keyboard press events by a space key.
                # If one is found, set the trial end variable and break.
                # from the loop
                if kb.getPresses(keys=[
                        ' ',
                ]):
                    run_trial = False
                    break

            # The trial has ended, so update the trial end time condition value,
            # and send a message to the ioDataStore with the trial end time.
            #
            flip_time = window.flip()
            trial['TRIAL_END'] = flip_time
            self.hub.sendMessageEvent(text="TRIAL_END %d" % t,
                                      sec_time=flip_time)

            # Stop recording eye data.
            # In this example, we have no use for any eye data
            # between trials, so why save it.
            #
            tracker.setRecordingState(False)

            # Save the experiment condition variable values for this
            # trial to the ioDataStore.
            #
            self.hub.addRowToConditionVariableTable(trial.values())

            # Clear all event buffers
            #
            self.hub.clearEvents('all')
            t += 1

        # All trials have been run, so end the experiment.
        #

        flip_time = window.flip()
        self.hub.sendMessageEvent(text='EXPERIMENT_COMPLETE',
                                  sec_time=flip_time)

        # Disconnect the eye tracking device.
        #
        tracker.setConnectionState(False)

        # The experiment is done, all trials have been run.
        # Clear the screen and show an 'experiment  done' message using the
        # instructionScreen text.
        #
        instuction_text = "Press Any Key to Exit Demo"
        instructions_text_stim.setText(instuction_text)
        instructions_text_stim.draw()
        flip_time = window.flip()
        self.hub.sendMessageEvent(text="SHOW_DONE_TEXT", sec_time=flip_time)
        self.hub.clearEvents('all')
        # wait until any key is pressed
        kb.waitForPresses()
Beispiel #6
0
else:
    frameDur = 1.0 / 60.0  # could not measure, so guess

# create a default keyboard (e.g. to check for escape)
defaultKeyboard = keyboard.Keyboard()

# Initialize components for Routine "Instruct"
InstructClock = core.Clock()
text = visual.TextStim(
    win=win,
    name='text',
    text=
    'Инструкция\nВам будет представлена последовательность однотипных стимулов. \n\nОни представляют собой центральную контурную фигуру, изменяющуюся во времени по величине.\nПеред каждым стимулом будут предъявляться: центральная точка, затем изменяющаяся фигура, которая либо увеличивается от малого до большого размера, либо уменьшается от того же большого до того же маленького размера, и затем исчезает.\n\nПосле каждого предъявления фигуры ответьте на вопрос: \n\nЧто, на Ваш взгляд, видно лучше: большой или маленький размер фигуры?\n\nФигуре маленького размера соответствует нажатие «левой стрелки», а фигуре большого размера – «правой стрелки» на клавиатуре.\n\nДля начала каждого следующего предъявления стимула нажмите клавишу пробел.\n\nПо окончанию предъявления стимулов будет представлена надпись «Конец эксперимента»\n',
    font='Arial',
    pos=(0, 0),
    height=0.03,
    wrapWidth=None,
    ori=0,
    color='black',
    colorSpace='rgb',
    opacity=1,
    languageStyle='LTR',
    depth=0.0)
key_resp = keyboard.Keyboard()

# Initialize components for Routine "Cross"
CrossClock = core.Clock()
cross = visual.ShapeStim(win=win,
                         name='cross',
                         vertices='cross',
                         units='cm',
Beispiel #7
0
# store frame rate of monitor if we can measure it
expInfo['frameRate'] = win.getActualFrameRate()
if expInfo['frameRate'] != None:
    frameDur = 1.0 / round(expInfo['frameRate'])
else:
    frameDur = 1.0 / 60.0  # could not measure, so guess

# Initialize components for Routine "Instruct1"
Instruct1Clock = core.Clock()
text = visual.TextStim(
    win=win,
    name='text',
    text=
    u'ANLEITUNG\n\nLiebe Teilnehmer vielen Dank, dass Sie durch Ihre Teilnahme einen wertvollen Beitrag zu unserer Forschung leisten!\n\nIm Folgenden werden wir Ihnen eine Vielzahl von W\xf6rtern pr\xe4sentieren. Ihre Aufgabe wird es sein, die pr\xe4sentierten Tierw\xf6rter als solche zu identifizieren. Dr\xfccken Sie bitte daf\xfcr immer die gr\xfcne Taste (rechte Seite).\nIst das Wort keines, welches ein Tier beschreibt dann dr\xfccken Sie bitte die rote Taste (links).\n\nWeiter mit dr\xfccken beliebiger Taste...',
    font=u'Arial',
    pos=(0, 0),
    height=0.05,
    wrapWidth=None,
    ori=0,
    color=u'white',
    colorSpace='rgb',
    opacity=1,
    depth=0.0)

# Initialize components for Routine "Instruct2"
Instruct2Clock = core.Clock()
text_6 = visual.TextStim(
    win=win,
    name='text_6',
    text=
    u'Bitte legen Sie ihren rechten Zeigefinge auf die gr\xfcne Taste und den linken Zeigefinger auf die rote Taste und lassen Sie die Finger die ganze Aufgabe \xfcber dort ruhen.\n\nBevor das Experiment anf\xe4ngt durchlaufen Sie erstmal einen Probedurchlauf, ob Sie die Anleitung verstanden haben.\n\nF\xfcr weitere Fragen wenden Sie sich bitte an die Versuchsleitung.\n\nDen Probedurchlauf beginnen Sie mit dem Dr\xfccken einer beliebiger Taste...',
    font=u'Arial',
Beispiel #8
0
    def __init__(self):
        self.left_win = visual.Window(size=constants.SCREEN_SIZE,
                                      units='norm',
                                      fullscr=True,
                                      screen=1,
                                      color='#000000')
        self.right_win = self.left_win
        self.mouse = event.Mouse(win=self.left_win, visible=True)

        self.main_text_height = 0.1
        self.start_button_text_height = 0.05

        ### Parameters of the trial start screen ###
        self.start_button_pos = (0, -0.9)
        self.start_button_size = (0.15, 0.1)
        self.start_button_rect = visual.Rect(win=self.left_win,
                                             pos=self.start_button_pos,
                                             width=self.start_button_size[0],
                                             height=self.start_button_size[1],
                                             lineColor='#FFFFFF',
                                             fillColor=None,
                                             lineWidth=3)

        self.start_button_text = visual.TextStim(
            self.left_win,
            text='Start',
            color='#FFFFFF',
            pos=self.start_button_pos,
            height=self.start_button_text_height)

        ### Parameters of the response screen ###
        self.deadzone = ((-1, 1), (-1, -0.7))
        self.left_response_area_pos = (-0.42, 0.85)
        self.right_response_area_pos = (0.42, 0.85)

        # assuming 3:4 proportion between width and height, and 1.77:1 screen aspect ratio
        # we get the width of the response area in the PsychoPy normed units (-1 to 1) as
        # 2*(3/4)*(1/1.77)
        self.response_area_size = (0.33, 0.25)

        self.text_h_offset = 0.85
        self.text_v_offset_left = 0.85
        self.text_v_offset_right = self.text_v_offset_left

        self.left_amount_pos = (self.left_response_area_pos[0],
                                self.left_response_area_pos[1] +
                                self.main_text_height / 2)
        self.left_delay_pos = (self.left_response_area_pos[0],
                               self.left_response_area_pos[1] -
                               self.main_text_height / 2)

        self.right_amount_pos = (self.right_response_area_pos[0],
                                 self.right_response_area_pos[1] +
                                 self.main_text_height / 2)
        self.right_delay_pos = (self.right_response_area_pos[0],
                                self.right_response_area_pos[1] -
                                self.main_text_height / 2)

        self.left_response_area = visual.Rect(
            win=self.left_win,
            pos=self.left_response_area_pos,
            width=self.response_area_size[0],
            height=self.response_area_size[1],
            lineColor='#FFFFFF',
            fillColor=None)
        self.right_response_area = visual.Rect(
            win=self.left_win,
            pos=self.right_response_area_pos,
            width=self.response_area_size[0],
            height=self.response_area_size[1],
            lineColor='#FFFFFF',
            fillColor=None)

        super(WalkingExpUIMouse, self).__init__()
Beispiel #9
0
time2 = '2'
time3 = '3'
time4 = '4'
time5 = '5'

instrSlow = "Te traag"

EndInstr1 = 'Dit deel is afgelopen is afgelopen. \n \nDruk op een willekeurige toets om verder te gaan naar de vragenlijst.'

Fatal = 'Oeps! Er is iets fout gegaan... \n \nRoep de experimentleider.'

Pause = 'Hier kan je even rusten, druk op een willekeurige knop om verder te gaan. \n \nJe mag zo lang rusten als je zelf wil.'

# Declareren van PsychoPy text properties

instruction9 = visual.TextStim(win_exp, text=instr9,units='norm',height=0.12, color='White',pos=[0,0], alignHoriz='center',flipHoriz=False)
instruction10 = visual.TextStim(win_exp, text=instr10,units='norm',height=0.12, color='White',pos=[0,0], alignHoriz='center',flipHoriz=False)
instruction11 = visual.TextStim(win_exp, text=instr11,units='norm',height=0.12, color='White',pos=[0,0], alignHoriz='center',flipHoriz=False)
instruction12 = visual.TextStim(win_exp, text=instr12,units='norm',height=0.12, color='White',pos=[0,0], alignHoriz='center',flipHoriz=False)
instruction13 = visual.TextStim(win_exp, text=instr13,units='norm',height=0.12, color='White',pos=[0,0], alignHoriz='center',flipHoriz=False)
instruction14 = visual.TextStim(win_exp, text=instr14,units='norm',height=0.12, color='White',pos=[0,0], alignHoriz='center',flipHoriz=False)

timing1 = visual.TextStim(win_exp, text=time1,units='norm',height=0.12, color='White',pos=[0,0], alignHoriz='center',flipHoriz=False)
timing2 = visual.TextStim(win_exp, text=time2,units='norm',height=0.12, color='White',pos=[0,0], alignHoriz='center',flipHoriz=False)
timing3 = visual.TextStim(win_exp, text=time3,units='norm',height=0.12, color='White',pos=[0,0], alignHoriz='center',flipHoriz=False)
timing4 = visual.TextStim(win_exp, text=time4,units='norm',height=0.12, color='White',pos=[0,0], alignHoriz='center',flipHoriz=False)
timing5 = visual.TextStim(win_exp, text=time5,units='norm',height=0.12, color='White',pos=[0,0], alignHoriz='center',flipHoriz=False)

tooSlow = visual.TextStim(win_exp, text=instrSlow,units='norm',height=0.12, color='White',pos=[0,0], alignHoriz='center',flipHoriz=False)

EndInstruction1 = visual.TextStim(win_exp, text=EndInstr1,units='norm',height=0.12, color='White',pos=[0,0], alignHoriz='center',flipHoriz=False)
Beispiel #10
0
                       lineColor=arrow_circleColor,
                       radius=arrow_circleRadius,
                       units='cm',
                       edges=32)

#Create Red Cross for rest periods
cross = visual.ShapeStim(currWindow,
                         units='cm',
                         vertices=((0, -2), (0, 2), (0, 0), (-2, 0), (2, 0)),
                         lineWidth=900,
                         closeShape=False,
                         lineColor='red')

waitStim = visual.TextStim(currWindow,
                           text=readyMessage[infos['language']],
                           color='gold',
                           wrapWidth=100,
                           pos=(0, -.7))
waitStim.draw()
currWindow.flip()

# Wait for trigger
out = event.waitKeys(maxWait=np.inf, keyList=['5'], timeStamped=True)

# Reset Clock
globalClock = core.Clock()
logging.setDefaultClock(globalClock)

#First RED Cross
currWindow.logOnFlip('', level=logging.EXP + 1)
cross.draw()
Beispiel #11
0
win = visual.Window(
    size=(1024, 768), fullscr=False,
    color='black', units='height')
# store frame rate of monitor if we can measure it
expInfo['frameRate'] = win.getActualFrameRate()
if expInfo['frameRate'] != None:
    frameDur = 1.0 / round(expInfo['frameRate'])
else:
    frameDur = 1.0 / 60.0  # could not measure, so guess

# create a default keyboard (e.g. to check for escape)
defaultKeyboard = keyboard.Keyboard()

# Initialize components for Hello test
Hello_clock = core.Clock()
Hello_text = visual.TextStim(win=win, name='Hello_text', pos=(0.0, 0.0), height=0.2, color='#ffffff')
Hello_text.model_name = None
Hello_text.cname = 'Hello_text'


Hello_components = [
    Hello_text]


# Trial component settings for Hello test
Hello_1 = [
       # Trial 1
      {'vars': {'order': 1,
            'who': 'Hello, person 1!',
            'repeat_index': 1},
        'ph_exec': [
Beispiel #12
0
# store frame rate of monitor if we can measure it
expInfo['frameRate'] = win.getActualFrameRate()
if expInfo['frameRate'] != None:
    frameDur = 1.0 / round(expInfo['frameRate'])
else:
    frameDur = 1.0 / 60.0  # could not measure, so guess

# Initialize components for Routine "instructions"
instructionsClock = core.Clock()
text_instruct = visual.TextStim(
    win=win,
    name='text_instruct',
    text=u'\nPlease stay as still\nas possible and enjoy\nthe movie!',
    font=u'Arial',
    pos=(0, 0),
    height=0.18,
    wrapWidth=None,
    ori=0,
    color=u'white',
    colorSpace='rgb',
    opacity=1,
    depth=0.0)

# Initialize components for Routine "fixation"
fixationClock = core.Clock()
fixation_txt = visual.TextStim(win=win,
                               ori=0,
                               name='fixation_txt',
                               text=u'+',
                               font=u'Arial',
                               pos=[0, 0],
Beispiel #13
0
                             size=(0.05, 0.05),
                             color='black',
                             autoLog=False)
grating = visual.GratingStim(
    win,
    pos=(0.5, 0),
    tex="sin",
    mask="gauss",
    color=[1.0, 0.5, -1.0],
    size=(1.0, 1.0),
    sf=(3, 0),
    autoLog=False)  # autologging not useful for dynamic stimuli
myMouse = event.Mouse()  #  will use win by default
message = visual.TextStim(win,
                          pos=(-0.95, -0.9),
                          alignHoriz='left',
                          height=0.08,
                          text='left-drag=SF, right-drag=pos, scroll=ori',
                          autoLog=False)

# Continue until keypress
while not event.getKeys():
    # get mouse events
    mouse_dX, mouse_dY = myMouse.getRel()
    mouse1, mouse2, mouse3 = myMouse.getPressed()
    if (mouse1):
        grating.setSF(mouse_dX, '+')
    elif (mouse3):
        grating.setPos([mouse_dX, mouse_dY], '+')
    else:
        fixSpot.setPos(myMouse.getPos())
# Scanner pulses
pulses = []

### Objects ####################################################################
mywin = visual.Window(size=win_size,
                      fullscr=win_fullscr,
                      color=win_color,
                      monitor=win_monitor,
                      screen=win_screen,
                      units='norm',
                      winType='pyglet')
mywin.mouseVisible = win_mouse_visible
fix = visual.TextStim(win=mywin,
                      text='+',
                      pos=[0, 0],
                      color=text_color,
                      height=text_fix_height)
digit_l = visual.TextStim(win=mywin,
                          text='',
                          pos=[-digit_separation, 0],
                          color=text_color,
                          height=digit_height)
digit_r = visual.TextStim(win=mywin,
                          text='',
                          pos=[digit_separation, 0],
                          color=text_color,
                          height=digit_height)
digit_c = visual.TextStim(win=mywin,
                          text='',
                          pos=[0, 0],
Beispiel #15
0
    size=(1920, 1080), fullscr=True, screen=0,
    allowGUI=False, allowStencil=False,
    monitor='testMonitor', color=[0,0,0], colorSpace='rgb',
    blendMode='avg', useFBO=True)
# store frame rate of monitor if we can measure it
expInfo['frameRate'] = win.getActualFrameRate()
if expInfo['frameRate'] != None:
    frameDur = 1.0 / round(expInfo['frameRate'])
else:
    frameDur = 1.0 / 60.0  # could not measure, so guess

# Initialize components for Routine "trial"
trialClock = core.Clock()
fixation = visual.TextStim(win=win, name='fixation',
    text='+',
    font='Arial',
    pos=(0, 0), height=0.1, wrapWidth=None, ori=0, 
    color='white', colorSpace='rgb', opacity=1,
    depth=0.0);
text = visual.TextStim(win=win, name='text',
    text='default text',
    font='Arial',
    pos=(0, 0), height=0.1, wrapWidth=None, ori=0, 
    color=1.0, colorSpace='rgb', opacity=1,
    depth=-1.0);

# Create some handy timers
globalClock = core.Clock()  # to track the time since experiment started
routineTimer = core.CountdownTimer()  # to track time remaining of each (non-slip) routine 

# set up handler to look after randomisation of conditions etc
trials = data.TrialHandler(nReps=5, method='random', 
#trialClock = core.Clock()

option_chosen = event.getKeys(keyList=('a', 'b'))
option_A_chosen = 0
option_B_chosen = 0

option_A_self = [1, 2, 5]
option_A_other = [5, 10, 15]

option_B_self = [5, 10, 15]
option_B_other = [-10, -15, -20]


option_A = visual.TextStim(win=win, name='option_A',
    text='   Option A\n\n    You: +'+option_A_self[random.randint(0, 2)]+'\nYour Team: +'+option_A_other[random.randint(0, 2)]+'',
    font='Arial',
    pos=(-0.4, -0.2), height=0.1,
    color='black', depth=0.0);
option_A.draw()
option_B = visual.TextStim(win=win, name='option_B',
    text='    Option B\n\n     You: +'+option_B_self[random.randint(0, 2)]+'\nYour Team: '+option_B_other[random.randint(0, 2)]+'',
    font='Arial',
    pos=(0.4, -0.2), height=0.1,
    color='black', depth=-1.0);
option_B.draw()
win.flip()

if option_chosen[0] == 'a':
    option_A_chosen += 1
    event.clearEvents()
    option_A.hide()
	def draw_text(self, win, text, pos=[0,0], draw_now=True):
		text = visual.TextStim(win, pos=pos, text=text, wrapWidth=30, alignHoriz='center')
		text.draw()
		if draw_now == True:
			win.flip()
Beispiel #18
0
# Define the visual stimuli (standard and oddball)

stdStimRadius = 1.06 / 2
oddBallMinRadius = 1.06 / 4
oddBallMaxRadius = 1.06 / 2

TEXT_HEIGHT = 0.5  # The height in visual degrees of instruction text
TEXT_WRAP = 30  # The character limit of each line of text before word wrap
display_text = visual.TextStim(
    win=myWin,
    ori=0,
    name='text',
    text=
    "Please press s for short, and l for long to judge the oddball duration against the standard",
    font='Arial',
    pos=[0, -5],
    wrapWidth=TEXT_WRAP,
    height=TEXT_HEIGHT,
    color=stimColor,
    colorSpace='rgb',
    opacity=1,
    depth=-1.0)

standardStim = visual.Circle(
    myWin,
    radius=stdStimRadius,  # Martini used circles with diameter of 12 deg
    lineColorSpace='rgb',
    lineColor=stimColor,
    lineWidth=2.0,  # in pixels
    units='deg',
    fillColorSpace='rgb',
 mouse_click = myMouse.getPressed()
 
 
 #
 Resp_time= start_response + limit_time        
 while response_time< start_response + limit_time:
     
     ####
     if keyboard[key.E]:
         win.close()
     
     ####
     
     
     if mouse_click[0]:#keyboard[key.A]:
         resp_text=visual.TextStim(win=win, text='same', pos=[-3,0], color=[1,1,1], units='pix', height=100)        
         Response=0
         #RT=Reaction_time.getTime()
         trial_time=TIME.getTime()
         response_time=TIME.getTime()
         Resp_time=TIME.getTime()
         FIXATION()
         win.flip()
         break
     
     elif mouse_click[2]:
         resp_text=visual.TextStim(win=win, text='diff', pos=[-3,0], color=[1,1,1], units='pix', height=100)        
         Response=1
         #RT=Reaction_time.getTime()
         trial_time=TIME.getTime()
         response_time=TIME.getTime()
Beispiel #20
0
    filename = op.join(script_dir, 'data', '{0}_events'.format(base_name))
    logfile = logging.LogFile(filename + '.log', level=logging.EXP)
    logging.console.setLevel(
        logging.WARNING)  # this outputs to the screen, not a file

    # Initialize stimuli
    # ------------------
    instruction_text_box = visual.TextStim(win=window,
                                           name='instruction_text_box',
                                           text="""\
You will be shown a series of formulae and individual numbers,
you must determine if the result is less than, equal to, or greater than
the value that follows:
      1 - Less Than
      2 - Equal to
      3 - Greater Than""",
                                           font=u'Arial',
                                           height=0.1,
                                           pos=(0, 0),
                                           wrapWidth=None,
                                           ori=0,
                                           color='white',
                                           colorSpace='rgb',
                                           opacity=1,
                                           depth=-1.0)
    term1_image = visual.ImageStim(win=window,
                                   name='equation_first_term',
                                   image=None,
                                   ori=0,
                                   color=[1, 1, 1],
                                   colorSpace='rgb',
                                   opacity=1,
    frameDur = 1.0 / round(expInfo['frameRate'])
else:
    frameDur = 1.0 / 60.0  # could not measure, so guess

# create a default keyboard (e.g. to check for escape)
defaultKeyboard = keyboard.Keyboard()

# Initialize components for Routine "B2_Instr"
B2_InstrClock = core.Clock()
B2_instr_txt = visual.TextStim(win=win,
                               name='B2_instr_txt',
                               text='default text',
                               font='Arial',
                               pos=(0, 0),
                               height=0.05,
                               wrapWidth=None,
                               ori=0,
                               color='white',
                               colorSpace='rgb',
                               opacity=1,
                               languageStyle='LTR',
                               depth=0.0)
B2_cont_txt = visual.TextStim(win=win,
                              name='B2_cont_txt',
                              text='default text',
                              font='Arial',
                              pos=(0, -0.40),
                              height=0.05,
                              wrapWidth=None,
                              ori=0,
                              color='white',
Beispiel #22
0
                    fullscr=True,
                    screen=0,
                    allowGUI=True,
                    allowStencil=False,
                    monitor='testMonitor',
                    color=[0, 0, 0],
                    colorSpace='rgb')

#Initialise all texts
text_intro = visual.TextStim(
    win=win,
    ori=0,
    name='text_intro',
    text=u'Hello! Touch anywhere on the screen to begin.',
    font=u'Arial',
    pos=[0, 0],
    height=0.09,
    wrapWidth=1.2,
    color=u'white',
    colorSpace=u'rgb',
    opacity=1,
    depth=0.0)
text_01 = visual.TextStim(win=win,
                          ori=0,
                          name='text_01',
                          text=plaintext_01,
                          font=u'Arial',
                          pos=[0, 0.1],
                          height=0.07,
                          wrapWidth=1.3,
                          color=u'white',