Esempio n. 1
0
    def _setResponse(self, item, question):
        """Creates slider object for responses

        Returns
        -------
        psychopy.visual.slider.Slider
            The Slider object for response
        aHeight
            The height of the response object as type float
        """
        pos = (self.rightEdge - item['aWidth'] * self.size[0], question.pos[1])
        aHeight = self.getRespHeight(item)

        # Set radio button choice layout
        if item['orientation'] == 'horizontal':
            aSize = (item['aWidth'] * self.size[0], 0.03)
        elif item['orientation'] == 'vertical':
            aSize = (0.03, aHeight)


        if item['type'].lower() in ['instruct']:

            #below does nothing except stop the code breaking
            resp = visual.TextStim( self.win,
                                    text="", #this is meant to be blank
                                    pos=pos,
                                    units=self.units,
                                    height=self.textHeight)

        if item['type'].lower() in ['slider']: #'rating',
            resp = visual.Slider(self.win,
                                 pos=pos,
                                 name=item["item_name"],
                                 size=(item['aWidth'] * self.size[0], 0.03),
                                 ticks=[0, 1],
                                 color='blue',
                                 labels=item['answers'],
                                 units=self.units,
                                 labelHeight=self.labelHeight,
                                 flip=True)
        elif item['type'].lower() in ['radio']:
            resp = visual.Slider(self.win,
                                 pos=pos,
                                 name=item["item_name"],
                                 size=aSize,
                                 color='blue',
                                 ticks=None,
                                 labels=item['answers'],
                                 units=self.units,
                                 labelHeight=self.textHeight,
                                 style='radio',
                                 flip=True)

        self._items['response'].append(resp)
        return resp, aHeight
Esempio n. 2
0
def phase03_age():
    slider = visual.Slider(win, ticks=[5,110], granularity=1, labels=[5,110])
    
    instruction = visual.TextStim(win, text=['Wie alt bist du?', 'How old are you?'][cfg.langID], pos=[0,.7], color=cfg.fontColor)
    
    clickBox = visual.Rect(win, width=.5,height=.25, pos=[.5,-.5], lineColor=cfg.fontColor)
    
    clickBoxText = visual.TextStim(win, text=['WEITER', 'NEXT'][cfg.langID], pos=[.5, -.5], color=cfg.fontColor)
    
    while True:
        
        core.wait(.1)
        
        if checkQuit():
            break
        
        instruction.draw()
        clickBox.draw();
        clickBoxText.draw();
            
        slider.draw()
        currRating= slider.markerPos
        
        sliderVal = visual.TextStim(win, text=currRating, pos=[0,.5])
        sliderVal.draw();
        
        win.flip()
        
        if clickBox.contains(mouse) & (currRating is not None):
            break
    
    updatePhase()
Esempio n. 3
0
    def _setScrollBar(self):
        """Creates Slider object for scrollbar

        Returns
        -------
        psychopy.visual.slider.Slider
            The Slider object for scroll bar
        """
        return visual.Slider(win=self.win, size=(0.03, self.size[1]),
                             ticks=[0, 1], style='slider',
                             pos=(self.rightEdge, self.pos[1]))
Esempio n. 4
0
    def _setResponse(self, item, question):
        """Creates slider object for responses

        Returns
        -------
        psychopy.visual.slider.Slider
            The Slider object for response
        aHeight
            The height of the response object as type float
        """
        pos = (self.rightEdge - item['aWidth'] * self.size[0], question.pos[1])
        aHeight = self.getRespHeight(item)

        # Set radio button choice layout
        if item['aLayout'] == 'horiz':
            aSize = (item['aWidth'] * self.size[0], 0.03)
        elif item['aLayout'] == 'vert':
            aSize = (0.03, aHeight)

        if item['aType'].lower() in ['rating', 'slider']:
            resp = visual.Slider(self.win,
                                 pos=pos,
                                 size=(item['aWidth'] * self.size[0], 0.03),
                                 ticks=[0, 1],
                                 labels=item['aOptions'],
                                 units=self.units,
                                 labelHeight=self.labelHeight,
                                 flip=True)
        elif item['aType'].lower() in ['choice']:
            resp = visual.Slider(self.win,
                                 pos=pos,
                                 size=aSize,
                                 ticks=None,
                                 labels=item['aOptions'],
                                 units=self.units,
                                 labelHeight=self.textHeight,
                                 style='radio',
                                 flip=True)

        self._items['response'].append(resp)
        return resp, aHeight
Esempio n. 5
0
def ShowVAS(Window, Question, VASLabels, RefreshRate, TickLims = [-15, 0, 15], MarkerColor = 'DarkSlateGrey', TextColor = 'White', SliderColor = 'LightGrey'):
    # Create slider object
    Slider = visual.Slider(Window, ticks = TickLims,
                           labels = VASLabels,
                           granularity = 0,
                           style='triangleMarker',
                           pos = (0, -0.25),
                           color = SliderColor)
    # Create text object, which displays 'Question'
    Text = visual.TextStim(Window, text = Question, pos = (0, 0.55), bold = True, height = 0.15, color = TextColor, alignText="center")
    # Create instruction object, below 'Question'
    Instruction = visual.TextStim(Window, text = 'Please click the location on the line below which best describes how you feel',
                                 pos = (0, 0.2),
                                 italic = True, height = 0.05, color = TextColor)
    # Set slider bar color
    Slider.marker.color = MarkerColor

    # While waiting for a response, show slider, question and instruction
    Waiting = True
    while Waiting:
        # Check if 'esc' has been hit
        CheckQuitWindow(Window)
        Slider.draw()
        Text.draw()
        Instruction.draw()
        Window.flip()
        # Retrieve response, if any
        Res = Slider.getRating()
        # Once response is received, stop loop and show visual feedback of response
        # for 0.3 seconds
        if Res != None:
            Waiting = False
            for frame in range(int(RefreshRate*0.3)):
                Slider.draw()
                Text.draw()
                Window.flip()

    # Reset slider position
    Slider.reset()
    Window.flip()

    return Res/TickLims[-1]
Esempio n. 6
0
    def __init__(
        self,
        mouse: Mouse,
        window: Window,
        a_stimuli: List[str],
        b_stimuli: List[str],
        a_title: str,
        b_title: str,
    ):
        super().__init__(mouse, window, a_stimuli, b_stimuli, a_title, b_title,
                         (57, 150))

        self.slider: visual.Slider = visual.Slider(
            self.window,
            pos=(0, -400),  #-250),
            ticks=(-100, 100),
            labels=("Not intuitive", "Intuitive"),
            granularity=1,
            color="black",
            units="pix",
            size=(600, 20),
            style="rating",
        )

        self.slider.markerPos = 0
        self.slider.marker.size = (20, 20)
        self.slider.marker.color = "black"
        self.slider.mouse = self.mouse

        self.instructions_text = visual.TextStim(
            self.window,
            text="How intuitive do you find\n"
            "the explanation of\n"
            "these optimized images\n"
            "for the given natural images?",
            color="black",
            height=0.8 * 30,
        )
        self.instructions_text.setPos((0, -300))  #-150))
Esempio n. 7
0
def ShowSlider(Window, Question, Labels, Ticks, RefreshRate, Style = 'rating', Size = (1.2, 0.1), MarkerColor = 'DarkSlateGrey', TextColor = 'White', SliderColor = 'LightGrey'):
    # Create slider object
    Slider = visual.Slider(Window, ticks = Ticks, labels = Labels, pos = (0, -0.25), granularity = 1,
                            style=Style, size = Size, labelHeight = 0.07, color = SliderColor)
    # Create text object, which displays 'Question'
    Text = visual.TextStim(Window, text = Question, pos = (0, 0.55), bold = True, height = 0.15, color = TextColor)
    # Create instruction object, below 'Question'
    Instruction = visual.TextStim(Window, text = 'Please indicate your agreement with the above statement on the scale below',
                                  pos = (0, 0.2), italic = True, height = 0.05, color = TextColor)
    #Set slider bar color
    Slider.marker.color = MarkerColor

    # While waiting for a response, show slider, question and instruction
    Waiting = True
    while Waiting:
        # Check if 'esc' has been hit
        CheckQuitWindow(Window)
        Slider.draw()
        Text.draw()
        Instruction.draw()
        Window.flip()
        # Retrieve response, if any
        Res = Slider.getRating()
        # Once response is received, stop loop and show visual feedback of response
        # for 0.3 seconds
        if Res != None:
            Waiting = False
            for frame in range(int(RefreshRate*0.3)):
                Slider.draw()
                Text.draw()
                Window.flip()

    # Reset slider position
    Slider.reset()
    Window.flip()

    return Res
    color='black',
    colorSpace='rgb',
    opacity=None,
    languageStyle='LTR',
    depth=0.0)
slider_arousal = visual.Slider(win=win,
                               name='slider_arousal',
                               startValue=None,
                               size=[1.0, 0.1],
                               pos=(0, -0.2),
                               units=None,
                               labels=("sehr gering", "sehr hoch"),
                               ticks=(0, 400),
                               granularity=0.0,
                               style='slider',
                               styleTweaks=(),
                               opacity=None,
                               color='black',
                               fillColor='black',
                               borderColor='black',
                               colorSpace='rgb',
                               font='Open Sans',
                               labelHeight=0.05,
                               flip=False,
                               depth=-1,
                               readOnly=False)

# Initialize components for Routine "Slider_Effort"
Slider_EffortClock = core.Clock()
text_slider_effort = visual.TextStim(
    win=win,
Esempio n. 9
0
qInst = visual.TextStim(win=win, text="Please use either the mouse or the number keys (1-7) to respond, then press ENTER to continue.", pos=(0,0.39), height=0.037, wrapWidth=1.5, color="white");
endText = visual.TextStim(win=win,
    text='Thank you for your participation in this study!\n\nTo submit your work and continue to the next part of the study, please press ENTER!',
    pos=(0, 0), height=0.06, wrapWidth=1.6, color='white');

yCoord = visual.TextStim(win=win, text="", height=0.08, color="white")
xArray = []
yArray = []

AccusedImage = visual.ImageStim(win=win, image='sin', mask=None, ori=0.0, pos=(-0.55, -0.05), size=(0.37, 0.27),
    color=[1,1,1], colorSpace='rgb', texRes=128.0, interpolate=True, depth=-3.0)
VictimImage = visual.ImageStim(win=win,image='sin', mask=None, ori=0.0, pos=(-0.55, 0.29), size=(0.37, 0.28),
    color=[1,1,1], colorSpace='rgb', texRes=128.0, interpolate=True, depth=-4.0)
CertaintyRatings = visual.Slider(win=win, size=(0.995, 0.11), pos=(0,  -0.39), units=None,
    labels=None, ticks=[1,2, 3, 4, 5], granularity=0.0,
    style='slider', styleTweaks=(), opacity=1.0,
    color='black', fillColor='darkblue', borderColor='White', colorSpace='rgb',
    font='Open Sans', labelHeight=0.05,
    flip=False, depth=-3, readOnly=False)
y1=0
innScale = visual.Rect(win=win, width=(y1, 0.11)[0], height=(y1, 0.18)[1],
    ori=0.0, pos=(0.6, 0),lineWidth=1.0,  colorSpace='rgb',  lineColor='darkGrey', fillColor='green',
    opacity=0.5, depth=-6.0, interpolate=True)
QuestionScale = visual.RatingScale(win=win, scale=None, showValue=False, showAccept=False, textColor="darkGrey", skipKeys=None, stretch=2.0, tickHeight=-1.0)

Space2 = keyboard.Keyboard()
Space1 = keyboard.Keyboard()
innKeys = keyboard.Keyboard()
guiltyKeys = keyboard.Keyboard()
endEnter = keyboard.Keyboard()
EnterEnd = keyboard.Keyboard()
enter=keyboard.Keyboard()
Esempio n. 10
0
                    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

# Initialize components for Routine "trial"
trialClock = core.Clock()
slider = visual.Slider(win=win,
                       name='slider',
                       size=(1.0, 0.1),
                       pos=(0, -0.4),
                       labels=None,
                       ticks=(1, 2, 3, 4, 5),
                       granularity=0,
                       style=['rating'],
                       color='LightGray',
                       font='HelveticaBold',
                       flip=False)

# 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

# ------Prepare to start Routine "trial"-------
t = 0
trialClock.reset()  # clock
frameN = -1
                       font='Helvetica',
                       pos=(0, 0),
                       height=30,
                       wrapWidth=1000,
                       ori=0,
                       color='Black',
                       colorSpace='rgb',
                       opacity=1,
                       languageStyle='LTR',
                       depth=0.0)
Rating_response = visual.Slider(win=win,
                                name='Rating_response',
                                size=(500, 20),
                                pos=(0, -200),
                                units='pix',
                                labels=['1', '2', '3', '4', '5', '6', '7'],
                                ticks=(1, 2, 3, 4, 5, 6, 7),
                                granularity=1,
                                style=['radio'],
                                color='Black',
                                font='HelveticaBold',
                                flip=False)
text_2 = visual.TextStim(win=win,
                         name='text_2',
                         text='Very negative',
                         font='Hevetica',
                         pos=(-420, -200),
                         height=25,
                         wrapWidth=None,
                         ori=0,
                         color='black',
                         colorSpace='rgb',
Esempio n. 12
0
    image='sin', mask=None,
    ori=0, pos=[0, 0], size=[0.5, 0.5],
    color=[1,1,1], colorSpace='rgb', opacity=1,
    flipHoriz=False, flipVert=False,
    texRes=512, interpolate=True, depth=0.0)
rateA_text = visual.TextStim(win=win, name='rateA_text',
    text='',
    font='Arial',
    pos=[0, 0.5], height=0.1, wrapWidth=1.5, ori=0, 
    color='white', colorSpace='rgb', opacity=1, 
    languageStyle='LTR',
    depth=-1.0);
sliderA = visual.Slider(win=win, name='sliderA',
    size=(1.0, 0.1), pos=(0, -0.4), units=None,
    labels=(1, 2, 3, 4, 5), ticks=(1, 2, 3, 4, 5), granularity=0.0,
    style='rating', styleTweaks=(), opacity=None,
    color='LightGray', fillColor='Red', borderColor='White', colorSpace='rgb',
    font='Open Sans', labelHeight=0.05,
    flip=False, depth=-2, readOnly=False)

# Initialize components for Routine "Rate_B"
Rate_BClock = core.Clock()
testSnackB = visual.ImageStim(
    win=win,
    name='testSnackB', 
    image='sin', mask=None,
    ori=0, pos=[0, 0], size=[0.5, 0.5],
    color=[1,1,1], colorSpace='rgb', opacity=1,
    flipHoriz=False, flipVert=False,
    texRes=128, interpolate=True, depth=0.0)
rateB_text = visual.TextStim(win=win, name='rateB_text',
Esempio n. 13
0
    color='black', colorSpace='rgb', opacity=1, 
    languageStyle='LTR',
    depth=0.0);
sound_clip = sound.Sound('A', secs=-1, stereo=True, hamming=True,
    name='sound_clip')
sound_clip.setVolume(1)
repetir = visual.TextStim(win=win, name='repetir',
    text='Aperte “r” se desejar ouvir o áudio novamente',
    font='Arial',
    pos=(0, 0.3), height=0.03, wrapWidth=None, ori=0, 
    color='red', colorSpace='rgb', opacity=1, 
    languageStyle='LTR',
    depth=-2.0);
slider = visual.Slider(win=win, name='slider',
    size=(1.0, 0.1), pos=(0, -0.2), units='height',
    labels=("1 = pouco", "2", "3", "4", "5 = muito"), ticks=(1, 2, 3, 4, 5),
    granularity=1, style=['rating', 'triangleMarker'],
    color='black', font='HelveticaBold',
    flip=False, depth=-5)
passagem = visual.TextStim(win=win, name='passagem',
    text='Aperte ESPAÇO para continuar',
    font='Arial',
    pos=(0, -0.4), height=0.03, wrapWidth=None, ori=0, 
    color='black', colorSpace='rgb', opacity=1, 
    languageStyle='LTR',
    depth=-6.0);
passagemBarra = keyboard.Keyboard()
pergunta = visual.TextStim(win=win, name='pergunta',
    text='default text',
    font='Arial',
    pos=(0, 0.1), height=0.05, wrapWidth=None, ori=0, 
    color='black', colorSpace='rgb', opacity=1, 
Esempio n. 14
0
def vaff(participant_id: str, session: str, run_number: str, is_first: bool):
    """
    Run the value affirmation task for the smoking study.

    :param participant_id: Participant identifier such as ASH999
    :param session: Session number (should be 1 or 2)
    :param run_number: Run number (should be 1, 2, 3, 4)
    :param is_first: True if the first run in a block, False if not
    :return: None
    """
    # Ensure that relative paths start from the same directory as this script
    _thisDir = os.path.dirname(os.path.abspath(__file__))
    os.chdir(_thisDir)

    # Store info about the experiment session
    psychopyVersion = '2021.1.2'
    expName = 'value_affirmation'  # from the Builder filename that created this script
    expInfo = {'participant': participant_id, 'session': session, 'run_number': run_number}
    expInfo['date'] = data.getDateStr()  # add a simple timestamp
    expInfo['expName'] = expName
    expInfo['psychopyVersion'] = psychopyVersion

    # Data file name stem = absolute path + name; later add .psyexp, .csv, .log, etc
    filename = _thisDir + os.sep + u'data/%s_%s_%s' % (expInfo['participant'], expName, expInfo['date'])

    # An ExperimentHandler isn't essential but helps with data saving
    thisExp = data.ExperimentHandler(name=expName, version='',
                                     extraInfo=expInfo, runtimeInfo=None,
                                     originPath='/Users/pnovak2/src/smoking/value_affirmation/value_affirmation_lastrun.py',
                                     savePickle=True, saveWideText=True,
                                     dataFileName=filename)
    # save a log file for detail verbose info
    logFile = logging.LogFile(filename + '.log', level=logging.DEBUG)
    logging.console.setLevel(logging.WARNING)  # this outputs to the screen, not a file

    endExpNow = False  # flag for 'escape' or other condition => quit the exp
    frameTolerance = 0.001  # how close to onset before 'same' frame

    # Start Code - component code to be run after the window creation

    # Setup the Window
    win = visual.Window(
        size=[2560, 1440], fullscr=True, screen=0,
        winType='pyglet', allowGUI=False, allowStencil=False,
        monitor='testMonitor', color=[-1, -1, -1], colorSpace='rgb',
        blendMode='avg', useFBO=True,
        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 Routine "setup"
    setupClock = core.Clock()
    if is_first:
        start_text_str = 'Calibrating scanner'
        start_text_duration = 120
        end_text_str = 'The task has ended. The next task will start in a few seconds.'
        end_text_duration = 10
    else:
        start_text_str = ''
        start_text_duration = 0.1
        end_text_str = 'The task has ended. Waiting for researcher to start next task.'
        end_text_duration = 3600

    conditions_file = os.path.join('conditions',
                                   f'VAFF_{expInfo["participant"]}_Session{expInfo["session"]}_Run{expInfo["run_number"]}.csv')

    # session 0 is a practice session
    if expInfo['session'] == '0':
        conditions_file = os.path.join('conditions', 'conditions_practice.csv')
        start_text_str = 'Practice for message task'
        start_text_duration = 20

    # Initialize components for Routine "instructions"
    instructionsClock = core.Clock()
    title_text = visual.TextStim(win=win, name='title_text',
                                 text='The Message Task',
                                 font='Open Sans',
                                 pos=(0, 0), height=0.1, wrapWidth=None, ori=0.0,
                                 color='white', colorSpace='rgb', opacity=None,
                                 languageStyle='LTR',
                                 depth=0.0);
    start_text = visual.TextStim(win=win, name='start_text',
                                 text=start_text_str,
                                 font='Helvetica',
                                 pos=(0, 0), height=0.05, wrapWidth=None, ori=0,
                                 color='white', colorSpace='rgb', opacity=1,
                                 languageStyle='LTR',
                                 depth=-1.0);
    start_trigger = keyboard.Keyboard()

    # Initialize components for Routine "trial"
    trialClock = core.Clock()
    value_message_text = visual.TextStim(win=win, name='value_message_text',
                                         text='',
                                         font='Helvetica',
                                         pos=(0, 0), height=0.05, wrapWidth=None, ori=0,
                                         color='white', colorSpace='rgb', opacity=1,
                                         languageStyle='LTR',
                                         depth=-1.0);
    rating_text = visual.TextStim(win=win, name='rating_text',
                                  text='How helpful is this message to help you quit smoking?',
                                  font='Helvetica',
                                  pos=(0, 0.2), height=0.05, wrapWidth=None, ori=0,
                                  color='white', colorSpace='rgb', opacity=1,
                                  languageStyle='LTR',
                                  depth=-2.0);
    value_rating = visual.Slider(win=win, name='value_rating',
                                 size=(1.0, 0.025), pos=(0, -0.3), units=None,
                                 labels=['not at all', 'extremely'], ticks=(1, 2, 3, 4, 5), granularity=0,
                                 style='rating', styleTweaks=('triangleMarker',), opacity=1,
                                 color='LightGray', fillColor='Red', borderColor='White', colorSpace='rgb',
                                 font='Helvetica', labelHeight=0.05,
                                 flip=False, depth=-3, readOnly=False)
    value_keyboard = keyboard.Keyboard()

    # Initialize components for Routine "iti"
    itiClock = core.Clock()
    intertrial_interval = visual.ImageStim(
        win=win,
        name='intertrial_interval',
        image=None, mask=None,
        ori=0, pos=(0, 0), size=(0.5, 0.5),
        color=[1, 1, 1], colorSpace='rgb', opacity=1,
        flipHoriz=False, flipVert=False,
        texRes=128, interpolate=True, depth=0.0)

    # Initialize components for Routine "end"
    endClock = core.Clock()
    end_text = visual.TextStim(win=win, name='end_text',
                               text=end_text_str,
                               font='Helvetica',
                               pos=(0, 0), height=0.05, wrapWidth=None, ori=0,
                               color='white', colorSpace='rgb', opacity=1,
                               languageStyle='LTR',
                               depth=0.0);
    end_key_resp = keyboard.Keyboard()

    # 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

    # ------Prepare to start Routine "setup"-------
    continueRoutine = True
    # update component parameters for each repeat
    # keep track of which components have finished
    setupComponents = []
    for thisComponent in setupComponents:
        thisComponent.tStart = None
        thisComponent.tStop = None
        thisComponent.tStartRefresh = None
        thisComponent.tStopRefresh = None
        if hasattr(thisComponent, 'status'):
            thisComponent.status = NOT_STARTED
    # reset timers
    t = 0
    _timeToFirstFrame = win.getFutureFlipTime(clock="now")
    setupClock.reset(-_timeToFirstFrame)  # t0 is time of first possible flip
    frameN = -1

    # -------Run Routine "setup"-------
    while continueRoutine:
        # get current time
        t = setupClock.getTime()
        tThisFlip = win.getFutureFlipTime(clock=setupClock)
        tThisFlipGlobal = win.getFutureFlipTime(clock=None)
        frameN = frameN + 1  # number of completed frames (so 0 is the first frame)
        # update/draw components on each frame

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

        # 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 setupComponents:
            if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
                continueRoutine = True
                break  # at least one component has not yet finished

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

    # -------Ending Routine "setup"-------
    for thisComponent in setupComponents:
        if hasattr(thisComponent, "setAutoDraw"):
            thisComponent.setAutoDraw(False)
    # the Routine "setup" was not non-slip safe, so reset the non-slip timer
    routineTimer.reset()

    # ------Prepare to start Routine "instructions"-------
    continueRoutine = True
    # update component parameters for each repeat
    start_trigger.keys = []
    start_trigger.rt = []
    _start_trigger_allKeys = []
    # keep track of which components have finished
    instructionsComponents = [title_text, start_text, start_trigger]
    for thisComponent in instructionsComponents:
        thisComponent.tStart = None
        thisComponent.tStop = None
        thisComponent.tStartRefresh = None
        thisComponent.tStopRefresh = None
        if hasattr(thisComponent, 'status'):
            thisComponent.status = NOT_STARTED
    # reset timers
    t = 0
    _timeToFirstFrame = win.getFutureFlipTime(clock="now")
    instructionsClock.reset(-_timeToFirstFrame)  # t0 is time of first possible flip
    frameN = -1

    # -------Run Routine "instructions"-------
    while continueRoutine:
        # get current time
        t = instructionsClock.getTime()
        tThisFlip = win.getFutureFlipTime(clock=instructionsClock)
        tThisFlipGlobal = win.getFutureFlipTime(clock=None)
        frameN = frameN + 1  # number of completed frames (so 0 is the first frame)
        # update/draw components on each frame

        # *title_text* updates
        if title_text.status == NOT_STARTED and tThisFlip >= 0.0 - frameTolerance:
            # keep track of start time/frame for later
            title_text.frameNStart = frameN  # exact frame index
            title_text.tStart = t  # local t and not account for scr refresh
            title_text.tStartRefresh = tThisFlipGlobal  # on global time
            win.timeOnFlip(title_text, 'tStartRefresh')  # time at next scr refresh
            title_text.setAutoDraw(True)
        if title_text.status == STARTED:
            # is it time to stop? (based on global clock, using actual start)
            if tThisFlipGlobal > title_text.tStartRefresh + 2.0 - frameTolerance:
                # keep track of stop time/frame for later
                title_text.tStop = t  # not accounting for scr refresh
                title_text.frameNStop = frameN  # exact frame index
                win.timeOnFlip(title_text, 'tStopRefresh')  # time at next scr refresh
                title_text.setAutoDraw(False)

        # *start_text* updates
        if start_text.status == NOT_STARTED and tThisFlip >= 2 - frameTolerance:
            # keep track of start time/frame for later
            start_text.frameNStart = frameN  # exact frame index
            start_text.tStart = t  # local t and not account for scr refresh
            start_text.tStartRefresh = tThisFlipGlobal  # on global time
            win.timeOnFlip(start_text, 'tStartRefresh')  # time at next scr refresh
            start_text.setAutoDraw(True)
        if start_text.status == STARTED:
            # is it time to stop? (based on global clock, using actual start)
            if tThisFlipGlobal > start_text.tStartRefresh + start_text_duration - frameTolerance:
                # keep track of stop time/frame for later
                start_text.tStop = t  # not accounting for scr refresh
                start_text.frameNStop = frameN  # exact frame index
                win.timeOnFlip(start_text, 'tStopRefresh')  # time at next scr refresh
                start_text.setAutoDraw(False)

        # *start_trigger* updates
        waitOnFlip = False
        if start_trigger.status == NOT_STARTED and tThisFlip >= 2 - frameTolerance:
            # keep track of start time/frame for later
            start_trigger.frameNStart = frameN  # exact frame index
            start_trigger.tStart = t  # local t and not account for scr refresh
            start_trigger.tStartRefresh = tThisFlipGlobal  # on global time
            win.timeOnFlip(start_trigger, 'tStartRefresh')  # time at next scr refresh
            start_trigger.status = STARTED
            # keyboard checking is just starting
            waitOnFlip = True
            win.callOnFlip(start_trigger.clock.reset)  # t=0 on next screen flip
            win.callOnFlip(start_trigger.clearEvents, eventType='keyboard')  # clear events on next screen flip
        if start_trigger.status == STARTED:
            # is it time to stop? (based on global clock, using actual start)
            if tThisFlipGlobal > start_trigger.tStartRefresh + start_text_duration - frameTolerance:
                # keep track of stop time/frame for later
                start_trigger.tStop = t  # not accounting for scr refresh
                start_trigger.frameNStop = frameN  # exact frame index
                win.timeOnFlip(start_trigger, 'tStopRefresh')  # time at next scr refresh
                start_trigger.status = FINISHED
        if start_trigger.status == STARTED and not waitOnFlip:
            theseKeys = start_trigger.getKeys(keyList=['apostrophe'], waitRelease=False)
            _start_trigger_allKeys.extend(theseKeys)
            if len(_start_trigger_allKeys):
                start_trigger.keys = _start_trigger_allKeys[-1].name  # just the last key pressed
                start_trigger.rt = _start_trigger_allKeys[-1].rt
                # a response ends the routine
                continueRoutine = False

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

        # 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 instructionsComponents:
            if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
                continueRoutine = True
                break  # at least one component has not yet finished

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

    # -------Ending Routine "instructions"-------
    for thisComponent in instructionsComponents:
        if hasattr(thisComponent, "setAutoDraw"):
            thisComponent.setAutoDraw(False)
    thisExp.addData('title_text.started', title_text.tStartRefresh)
    thisExp.addData('title_text.stopped', title_text.tStopRefresh)
    # the Routine "instructions" was not non-slip safe, so reset the non-slip timer
    routineTimer.reset()

    # set up handler to look after randomisation of conditions etc
    trials = data.TrialHandler(nReps=1, method='sequential',
                               extraInfo=expInfo, originPath=-1,
                               trialList=data.importConditions(conditions_file),
                               seed=None, name='trials')
    thisExp.addLoop(trials)  # add the loop to the experiment

    for thisTrial in trials:
        currentLoop = trials

        # ------Prepare to start Routine "trial"-------
        continueRoutine = True
        routineTimer.add(10.000000)
        # update component parameters for each repeat
        value_message_text.setText(thisTrial['message'])
        value_rating.reset()
        value_keyboard.keys = []
        value_keyboard.rt = []
        _value_keyboard_allKeys = []
        # keep track of which components have finished
        trialComponents = [value_message_text, rating_text, value_rating, value_keyboard]
        for thisComponent in trialComponents:
            thisComponent.tStart = None
            thisComponent.tStop = None
            thisComponent.tStartRefresh = None
            thisComponent.tStopRefresh = None
            if hasattr(thisComponent, 'status'):
                thisComponent.status = NOT_STARTED
        # reset timers
        t = 0
        _timeToFirstFrame = win.getFutureFlipTime(clock="now")
        trialClock.reset(-_timeToFirstFrame)  # t0 is time of first possible flip
        frameN = -1

        # -------Run Routine "trial"-------
        while continueRoutine and routineTimer.getTime() > 0:
            # get current time
            t = trialClock.getTime()
            tThisFlip = win.getFutureFlipTime(clock=trialClock)
            tThisFlipGlobal = win.getFutureFlipTime(clock=None)
            frameN = frameN + 1  # number of completed frames (so 0 is the first frame)
            # update/draw components on each frame
            # Update marker position and slider rating
            # when there are keypresses of the rating buttons
            r = convert_key_to_rating(value_keyboard.keys)
            value_rating.markerPos = r
            # confirm rating by setting to current markerPos
            value_rating.rating = r

            # *value_message_text* updates
            if value_message_text.status == NOT_STARTED and tThisFlip >= 0.0 - frameTolerance:
                # keep track of start time/frame for later
                value_message_text.frameNStart = frameN  # exact frame index
                value_message_text.tStart = t  # local t and not account for scr refresh
                value_message_text.tStartRefresh = tThisFlipGlobal  # on global time
                win.timeOnFlip(value_message_text, 'tStartRefresh')  # time at next scr refresh
                value_message_text.setAutoDraw(True)
            if value_message_text.status == STARTED:
                # is it time to stop? (based on global clock, using actual start)
                if tThisFlipGlobal > value_message_text.tStartRefresh + 6 - frameTolerance:
                    # keep track of stop time/frame for later
                    value_message_text.tStop = t  # not accounting for scr refresh
                    value_message_text.frameNStop = frameN  # exact frame index
                    win.timeOnFlip(value_message_text, 'tStopRefresh')  # time at next scr refresh
                    value_message_text.setAutoDraw(False)

            # *rating_text* updates
            if rating_text.status == NOT_STARTED and tThisFlip >= 6 - frameTolerance:
                # keep track of start time/frame for later
                rating_text.frameNStart = frameN  # exact frame index
                rating_text.tStart = t  # local t and not account for scr refresh
                rating_text.tStartRefresh = tThisFlipGlobal  # on global time
                win.timeOnFlip(rating_text, 'tStartRefresh')  # time at next scr refresh
                rating_text.setAutoDraw(True)
            if rating_text.status == STARTED:
                # is it time to stop? (based on global clock, using actual start)
                if tThisFlipGlobal > rating_text.tStartRefresh + 4 - frameTolerance:
                    # keep track of stop time/frame for later
                    rating_text.tStop = t  # not accounting for scr refresh
                    rating_text.frameNStop = frameN  # exact frame index
                    win.timeOnFlip(rating_text, 'tStopRefresh')  # time at next scr refresh
                    rating_text.setAutoDraw(False)

            # *value_rating* updates
            if value_rating.status == NOT_STARTED and tThisFlip >= 6 - frameTolerance:
                # keep track of start time/frame for later
                value_rating.frameNStart = frameN  # exact frame index
                value_rating.tStart = t  # local t and not account for scr refresh
                value_rating.tStartRefresh = tThisFlipGlobal  # on global time
                win.timeOnFlip(value_rating, 'tStartRefresh')  # time at next scr refresh
                value_rating.setAutoDraw(True)
            if value_rating.status == STARTED:
                # is it time to stop? (based on global clock, using actual start)
                if tThisFlipGlobal > value_rating.tStartRefresh + 4 - frameTolerance:
                    # keep track of stop time/frame for later
                    value_rating.tStop = t  # not accounting for scr refresh
                    value_rating.frameNStop = frameN  # exact frame index
                    win.timeOnFlip(value_rating, 'tStopRefresh')  # time at next scr refresh
                    value_rating.setAutoDraw(False)

            # *value_keyboard* updates
            waitOnFlip = False
            if value_keyboard.status == NOT_STARTED and tThisFlip >= 6 - frameTolerance:
                # keep track of start time/frame for later
                value_keyboard.frameNStart = frameN  # exact frame index
                value_keyboard.tStart = t  # local t and not account for scr refresh
                value_keyboard.tStartRefresh = tThisFlipGlobal  # on global time
                win.timeOnFlip(value_keyboard, 'tStartRefresh')  # time at next scr refresh
                value_keyboard.status = STARTED
                # keyboard checking is just starting
                waitOnFlip = True
                win.callOnFlip(value_keyboard.clock.reset)  # t=0 on next screen flip
                win.callOnFlip(value_keyboard.clearEvents, eventType='keyboard')  # clear events on next screen flip
            if value_keyboard.status == STARTED:
                # is it time to stop? (based on global clock, using actual start)
                if tThisFlipGlobal > value_keyboard.tStartRefresh + 4 - frameTolerance:
                    # keep track of stop time/frame for later
                    value_keyboard.tStop = t  # not accounting for scr refresh
                    value_keyboard.frameNStop = frameN  # exact frame index
                    win.timeOnFlip(value_keyboard, 'tStopRefresh')  # time at next scr refresh
                    value_keyboard.status = FINISHED
            if value_keyboard.status == STARTED and not waitOnFlip:
                theseKeys = value_keyboard.getKeys(keyList=['5', '6', '7', '8', '9'], waitRelease=False)
                _value_keyboard_allKeys.extend(theseKeys)
                if len(_value_keyboard_allKeys):
                    value_keyboard.keys = _value_keyboard_allKeys[-1].name  # just the last key pressed
                    value_keyboard.rt = _value_keyboard_allKeys[-1].rt

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

            # 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 trialComponents:
                if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
                    continueRoutine = True
                    break  # at least one component has not yet finished

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

        # -------Ending Routine "trial"-------
        for thisComponent in trialComponents:
            if hasattr(thisComponent, "setAutoDraw"):
                thisComponent.setAutoDraw(False)
        rating_text.tStopRefresh = tThisFlipGlobal
        value_rating.tStopRefresh = tThisFlipGlobal
        value_keyboard.tStopRefresh = tThisFlipGlobal
        trials.addData('value_message_text.started', value_message_text.tStartRefresh)
        trials.addData('value_message_text.stopped', value_message_text.tStopRefresh)
        trials.addData('rating_text.started', rating_text.tStartRefresh)
        trials.addData('rating_text.stopped', rating_text.tStopRefresh)
        trials.addData('value_rating.response', value_rating.getRating())
        trials.addData('value_rating.started', value_rating.tStartRefresh)
        trials.addData('value_rating.stopped', value_rating.tStopRefresh)
        # check responses
        if value_keyboard.keys in ['', [], None]:  # No response was made
            value_keyboard.keys = None
        trials.addData('value_keyboard.keys', value_keyboard.keys)
        if value_keyboard.keys != None:  # we had a response
            trials.addData('value_keyboard.rt', value_keyboard.rt)
        trials.addData('value_keyboard.started', value_keyboard.tStartRefresh)
        trials.addData('value_keyboard.stopped', value_keyboard.tStopRefresh)

        # ------Prepare to start Routine "iti"-------
        continueRoutine = True
        # update component parameters for each repeat
        # keep track of which components have finished
        itiComponents = [intertrial_interval]
        for thisComponent in itiComponents:
            thisComponent.tStart = None
            thisComponent.tStop = None
            thisComponent.tStartRefresh = None
            thisComponent.tStopRefresh = None
            if hasattr(thisComponent, 'status'):
                thisComponent.status = NOT_STARTED
        # reset timers
        t = 0
        _timeToFirstFrame = win.getFutureFlipTime(clock="now")
        itiClock.reset(-_timeToFirstFrame)  # t0 is time of first possible flip
        frameN = -1

        # -------Run Routine "iti"-------
        while continueRoutine:
            # get current time
            t = itiClock.getTime()
            tThisFlip = win.getFutureFlipTime(clock=itiClock)
            tThisFlipGlobal = win.getFutureFlipTime(clock=None)
            frameN = frameN + 1  # number of completed frames (so 0 is the first frame)
            # update/draw components on each frame

            # *intertrial_interval* updates
            if intertrial_interval.status == NOT_STARTED and tThisFlip >= 0.0 - frameTolerance:
                # keep track of start time/frame for later
                intertrial_interval.frameNStart = frameN  # exact frame index
                intertrial_interval.tStart = t  # local t and not account for scr refresh
                intertrial_interval.tStartRefresh = tThisFlipGlobal  # on global time
                win.timeOnFlip(intertrial_interval, 'tStartRefresh')  # time at next scr refresh
                intertrial_interval.setAutoDraw(True)
            if intertrial_interval.status == STARTED:
                # is it time to stop? (based on global clock, using actual start)
                if tThisFlipGlobal > intertrial_interval.tStartRefresh + thisTrial['iti'] - frameTolerance:
                    # keep track of stop time/frame for later
                    intertrial_interval.tStop = t  # not accounting for scr refresh
                    intertrial_interval.frameNStop = frameN  # exact frame index
                    win.timeOnFlip(intertrial_interval, 'tStopRefresh')  # time at next scr refresh
                    intertrial_interval.setAutoDraw(False)

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

            # 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 itiComponents:
                if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
                    continueRoutine = True
                    break  # at least one component has not yet finished

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

        # -------Ending Routine "iti"-------
        for thisComponent in itiComponents:
            if hasattr(thisComponent, "setAutoDraw"):
                thisComponent.setAutoDraw(False)
        trials.addData('intertrial_interval.started', intertrial_interval.tStartRefresh)
        trials.addData('intertrial_interval.stopped', intertrial_interval.tStopRefresh)
        # the Routine "iti" was not non-slip safe, so reset the non-slip timer
        routineTimer.reset()
        thisExp.nextEntry()

    # completed 1 repeats of 'trials'

    # ------Prepare to start Routine "end"-------
    continueRoutine = True
    # update component parameters for each repeat
    end_key_resp.keys = []
    end_key_resp.rt = []
    _end_key_resp_allKeys = []
    # keep track of which components have finished
    endComponents = [end_text, end_key_resp]
    for thisComponent in endComponents:
        thisComponent.tStart = None
        thisComponent.tStop = None
        thisComponent.tStartRefresh = None
        thisComponent.tStopRefresh = None
        if hasattr(thisComponent, 'status'):
            thisComponent.status = NOT_STARTED
    # reset timers
    t = 0
    _timeToFirstFrame = win.getFutureFlipTime(clock="now")
    endClock.reset(-_timeToFirstFrame)  # t0 is time of first possible flip
    frameN = -1

    # -------Run Routine "end"-------
    while continueRoutine:
        # get current time
        t = endClock.getTime()
        tThisFlip = win.getFutureFlipTime(clock=endClock)
        tThisFlipGlobal = win.getFutureFlipTime(clock=None)
        frameN = frameN + 1  # number of completed frames (so 0 is the first frame)
        # update/draw components on each frame

        # *end_text* updates
        if end_text.status == NOT_STARTED and tThisFlip >= 0.0 - frameTolerance:
            # keep track of start time/frame for later
            end_text.frameNStart = frameN  # exact frame index
            end_text.tStart = t  # local t and not account for scr refresh
            end_text.tStartRefresh = tThisFlipGlobal  # on global time
            win.timeOnFlip(end_text, 'tStartRefresh')  # time at next scr refresh
            end_text.setAutoDraw(True)
        if end_text.status == STARTED:
            # is it time to stop? (based on global clock, using actual start)
            if tThisFlipGlobal > end_text.tStartRefresh + end_text_duration - frameTolerance:
                # keep track of stop time/frame for later
                end_text.tStop = t  # not accounting for scr refresh
                end_text.frameNStop = frameN  # exact frame index
                win.timeOnFlip(end_text, 'tStopRefresh')  # time at next scr refresh
                end_text.setAutoDraw(False)

        # *end_key_resp* updates
        waitOnFlip = False
        if end_key_resp.status == NOT_STARTED and tThisFlip >= 0.0 - frameTolerance:
            # keep track of start time/frame for later
            end_key_resp.frameNStart = frameN  # exact frame index
            end_key_resp.tStart = t  # local t and not account for scr refresh
            end_key_resp.tStartRefresh = tThisFlipGlobal  # on global time
            win.timeOnFlip(end_key_resp, 'tStartRefresh')  # time at next scr refresh
            end_key_resp.status = STARTED
            # keyboard checking is just starting
            waitOnFlip = True
            win.callOnFlip(end_key_resp.clock.reset)  # t=0 on next screen flip
            win.callOnFlip(end_key_resp.clearEvents, eventType='keyboard')  # clear events on next screen flip
        if end_key_resp.status == STARTED:
            # is it time to stop? (based on global clock, using actual start)
            if tThisFlipGlobal > end_key_resp.tStartRefresh + asarray(end_text_duration) - frameTolerance:
                # keep track of stop time/frame for later
                end_key_resp.tStop = t  # not accounting for scr refresh
                end_key_resp.frameNStop = frameN  # exact frame index
                win.timeOnFlip(end_key_resp, 'tStopRefresh')  # time at next scr refresh
                end_key_resp.status = FINISHED
        if end_key_resp.status == STARTED and not waitOnFlip:
            theseKeys = end_key_resp.getKeys(keyList=['space'], waitRelease=False)
            _end_key_resp_allKeys.extend(theseKeys)
            if len(_end_key_resp_allKeys):
                end_key_resp.keys = _end_key_resp_allKeys[-1].name  # just the last key pressed
                end_key_resp.rt = _end_key_resp_allKeys[-1].rt
                # a response ends the routine
                continueRoutine = False

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

        # 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 endComponents:
            if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
                continueRoutine = True
                break  # at least one component has not yet finished

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

    # -------Ending Routine "end"-------
    for thisComponent in endComponents:
        if hasattr(thisComponent, "setAutoDraw"):
            thisComponent.setAutoDraw(False)
    thisExp.addData('end_text.started', end_text.tStartRefresh)
    thisExp.addData('end_text.stopped', end_text.tStopRefresh)
    # check responses
    if end_key_resp.keys in ['', [], None]:  # No response was made
        end_key_resp.keys = None
    thisExp.addData('end_key_resp.keys', end_key_resp.keys)
    if end_key_resp.keys != None:  # we had a response
        thisExp.addData('end_key_resp.rt', end_key_resp.rt)
    thisExp.addData('end_key_resp.started', end_key_resp.tStartRefresh)
    thisExp.addData('end_key_resp.stopped', end_key_resp.tStopRefresh)
    thisExp.nextEntry()
    # the Routine "end" was not non-slip safe, so reset the non-slip timer
    routineTimer.reset()

    # Flip one final time so any remaining win.callOnFlip()
    # and win.timeOnFlip() tasks get executed before quitting
    win.flip()

    # these shouldn't be strictly necessary (should auto-save)
    thisExp.saveAsWideText(filename + '.csv', delim='auto')
    thisExp.saveAsPickle(filename)
    logging.flush()
    # make sure everything is closed down
    thisExp.abort()  # or data files will save again on exit
    win.close()
    core.quit()
Esempio n. 15
0
File: main.py Progetto: abcsds/NPLab
                           pos=(0, 0),
                           size=(1.2, 0.2),
                           color=[1, 1, 1],
                           colorSpace='rgb',
                           opacity=1,
                           flipHoriz=False,
                           flipVert=False,
                           texRes=128,
                           interpolate=True,
                           depth=-1.0)
slider_a = visual.Slider(win=win,
                         name='slider_a',
                         size=(1.0, 0.05),
                         pos=(0, -.15),
                         units=None,
                         labels=None,
                         ticks=(1, 2, 3, 4, 5, 6, 7, 8, 9),
                         granularity=0,
                         style=('triangleMarker', ),
                         color='LightGray',
                         font='HelveticaBold',
                         flip=False)
scale_v = visual.ImageStim(win=win,
                           name='scale_v',
                           image='exp_data/img/SAM-V-9.png',
                           mask=None,
                           ori=0,
                           pos=(0, -.3),
                           size=(1.2, 0.2),
                           color=[1, 1, 1],
                           colorSpace='rgb',
                           opacity=1,
                             wrapWidth=None,
                             ori=0,
                             color='black',
                             colorSpace='rgb',
                             opacity=1,
                             languageStyle='LTR',
                             depth=-2.0)

# -----sliders----- #

slider1 = visual.Slider(win=win,
                        name='slider1',
                        size=(sliderW, sliderH),
                        pos=(sliderX, sliderP1),
                        ticks=(startP, endP),
                        labels=(startT, endT),
                        granularity=0,
                        style=['rating'],
                        color='Gray',
                        font='HelveticaBold',
                        flip=False)
slider2 = visual.Slider(win=win,
                        name='slider2',
                        size=(sliderW, sliderH),
                        pos=(sliderX, sliderP1 - sliderD),
                        ticks=(startP, endP),
                        labels=(startT, endT),
                        granularity=0,
                        style=['rating'],
                        color='Gray',
                        font='HelveticaBold',
Esempio n. 17
0
                                units='pix',
                                image=None,
                                mask=None,
                                texRes=64,
                                depth=0.0)

valuePalette = visual.ImageStim(win=win,
                                name='valuePalette',
                                units='pix',
                                pos=(0, -250),
                                depth=-1.0)

hueSlider = visual.Slider(win=win,
                          name='hueSlider',
                          size=(.37, .02),
                          pos=(0, 0.2),
                          labels=None,
                          ticks=(0, 360),
                          style=['rating'])

satSlider = visual.Slider(win=win,
                          name='satSlider',
                          size=(.02, .37),
                          pos=(0.2, 0),
                          labels=None,
                          ticks=(0, 1),
                          style=['rating'])

valSlider = visual.Slider(win=win,
                          name='valSlider',
                          size=(.37, .02),
Esempio n. 18
0
right_labels = [
    'very pleasant', 'very relaxing', 'very pleasant', 'very relaxing',
    'very trustworthy', 'very attractive', 'very calming'
]

win = visual.Window(
    #size=[1920, 1080],
    size=[900, 600],
    units='norm',
    fullscr=
    True,  # True if you want whole screen and False if not (False is just for debugging really)
    color='black')

vas = visual.Slider(win,
                    ticks=(-10, 10),
                    labels=('', ''),
                    granularity=0,
                    color='white')

anchor_left = visual.TextStim(win,
                              text='foo',
                              pos=[0.2, -0.2],
                              alignHoriz='center')

anchor_right = visual.TextStim(win,
                               text='bar',
                               pos=[1.3, -0.2],
                               alignHoriz='center')

message = visual.TextStim(win,
                          text='press any key to start',
Esempio n. 19
0
buttonComponents = [buttonS, buttonB1, buttonB2, buttonT1, buttonT2]


# -----slider subject-----
sliderS = visual.TextStim(win=win, name='sliderS',
    text = sliderSText,    
    font='Arial',
    pos=(sliderSX, sliderSY), height=sliderSH, wrapWidth=1.5, ori=0, 
    color='black', colorSpace='rgb', opacity=1, 
    languageStyle='LTR',
    depth=0.0);
    
# -----slider-----
slider = visual.Slider(win=win, name='slider',
    size=(sliderW, sliderH), pos=(sliderX, sliderY),
    ticks=(sliderStartP, sliderEndP),labels=(sliderStartT, sliderEndT),
    granularity=0, style=['rating'],
    color='Gray', font='HelveticaBold',
    flip=False)
    
# -----slider value-----

sliderV = visual.TextStim(win=win, name='sliderV1',
    text='',
    font='Arial',
    pos=(sliderVX, sliderVY), height=sliderVH, wrapWidth=None, ori=0, 
    color='black', colorSpace='rgb', opacity=1, 
    languageStyle='LTR',
    depth=-10.0);

sliderComponents = [sliderS, slider, sliderV]
Esempio n. 20
0
                               pos=(0, -300),
                               size=(150, 76),
                               color=[1, 1, 1],
                               colorSpace='rgb',
                               opacity=1,
                               flipHoriz=False,
                               flipVert=False,
                               texRes=128,
                               interpolate=True,
                               depth=-2.0)
slider = visual.Slider(win=win,
                       name='slider',
                       size=(400, 50),
                       pos=(263.5, -189.5),
                       units=None,
                       labels=(-2000, 0),
                       ticks=(-2000, 0),
                       granularity=0,
                       style=['rating', 'whiteOnBlack'],
                       color='black',
                       font='HelveticaBold',
                       flip=True)
down = visual.ShapeStim(win=win,
                        name='down',
                        vertices=[[-(50, 50)[0] / 2.0, -(50, 50)[1] / 2.0],
                                  [+(50, 50)[0] / 2.0, -(50, 50)[1] / 2.0],
                                  [0, (50, 50)[1] / 2.0]],
                        ori=-90,
                        pos=(10, -189.5),
                        lineWidth=1,
                        lineColor=[1, 1, 1],
                        lineColorSpace='rgb',
Esempio n. 21
0
key_resp_2 = keyboard.Keyboard()

# Initialize components for Routine "Trial1"
Trial1Clock = core.Clock()
text_2 = visual.TextStim(win=win, name='text_2',
    text='',
    font='Arial',
    units='norm', pos=(0, 0.75), height=0.1, wrapWidth=None, ori=0.0, 
    color='lightblue', colorSpace='rgb', opacity=None, 
    languageStyle='LTR',
    depth=0.0);
key_resp_3 = keyboard.Keyboard()
slider = visual.Slider(win=win, name='slider',
    size=(0.8, 0.5 ), pos=(0, -0.3), units='norm',
    labels=(0,100,200,300,400,500,600,700,800,900,1000), ticks=(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11), granularity=1.0,
    style='slider', styleTweaks=('triangleMarker',), opacity=1.0,
    color='Darkblue', fillColor='Red', borderColor='White', colorSpace='rgb',
    font='Arial', labelHeight=0.07,
    flip=True, depth=-2, readOnly=False)

# Initialize components for Routine "instructions2"
instructions2Clock = core.Clock()
text_6 = visual.TextStim(win=win, name='text_6',
    text='The screen will display the name or number of the participant. A slider will be displayed which will contain denominations of 100 that can be given to the other participants of the study. You have to select the option which is consistent with the amount you want to allocate. Press SPACE if you want to continue to the game, or press ESC if you want to end the experiment. Press Space after every trial to move on to the next participant. It is assumed that you will have Rs 1000 for every new participant shown on the screen. The name of the participants will be visible to your for these trials.',
    font='Arial',
    units='norm', pos=(0, 0.3), height=0.08, wrapWidth=None, ori=0.0, 
    color='white', colorSpace='rgb', opacity=1.0, 
    languageStyle='LTR',
    depth=0.0);
key_resp_2 = keyboard.Keyboard()
Esempio n. 22
0
# Create window
win = visual.Window(size=(1080, 720), units='height')

# Button to end script
endBtn = visual.ButtonStim(win,
                           "End",
                           pos=(0, -0.45),
                           anchor='bottom-center',
                           size=(0.2, 0.1),
                           letterHeight=0.05)
# Color space chooser
spaces = ['named', 'hex', 'rgb', 'rgb1', 'rgb255', 'hsv', 'lms', 'dkl']
spaceCtrl = visual.Slider(win,
                          style="radio",
                          ticks=list(range(len(spaces))),
                          granularity=1,
                          labels=spaces,
                          pos=(0, 0.4),
                          size=(1.2, 0.05),
                          labelHeight=0.02)
spaceCtrl.value = spaces.index('rgb')
# TextBox to type in values to try out
valueCtrl = visual.TextBox2(win,
                            text="#ffffff",
                            font="Courier Prime",
                            pos=(-0.3, 0.1),
                            size=(0.5, 0.2),
                            letterHeight=0.05,
                            color='white',
                            fillColor='black',
                            editable=True)
win.currentEditable = valueCtrl
                              wrapWidth=None,
                              ori=0,
                              color='black',
                              colorSpace='rgb',
                              opacity=1,
                              languageStyle='LTR',
                              depth=0.0)

# Initialize components for Routine

slider = visual.Slider(win=win,
                       name='slider',
                       size=(0.04, 0.6),
                       pos=(0.5, 0),
                       labels=(sliderLeftT, sliderRightT),
                       ticks=(sliderLeftP, sliderRightP),
                       granularity=0,
                       style=['slider'],
                       color='black',
                       font='HelveticaBold',
                       flip=True,
                       units="height")

#  notice that the "size" of the slider controls whether the slider is verticle or horizontal
#  change to desired style, using the in-built visual stimulus from psychopy

slider.marker = Circle(
    win,
    radius=slider.size[0] * 0.5,  # The radius should be half the width 
    edges=32,
    fillColor='black',
    lineColor='gray')
    pos=(0, 0.3),
    height=0.02,
    wrapWidth=None,
    ori=0,
    color='black',
    colorSpace='rgb',
    opacity=1,
    languageStyle='LTR',
    depth=0.0)
slider_2 = visual.Slider(win=win,
                         name='slider_2',
                         size=(1.0, 0.1),
                         pos=(0, 0),
                         units=None,
                         labels=['necessary', 'decessary'],
                         ticks=(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
                         granularity=0,
                         style=['rating'],
                         color='black',
                         font='HelveticaBold',
                         flip=False,
                         depth=-1)

# Initialize components for Routine "begin"
beginClock = core.Clock()
text_6 = visual.TextStim(win=win,
                         name='text_6',
                         text='Press SPACE to begin!',
                         font='Arial',
                         pos=(0, 0),
                         height=0.05,
qInst = visual.TextStim(win=win, text="Please use the mouse to click on the scale, then press ENTER to continue.", pos=(0,0.39), height=0.037, wrapWidth=1.5, color="white");
endText = visual.TextStim(win=win,
    text='Thank you for your participation in this study!\n\nTo submit your work and continue to the next part of the study, please press ESCAPE!',
    pos=(0, 0), height=0.06, wrapWidth=1.6, color='white');

yCoord = visual.TextStim(win=win, text="", height=0.08, color="white")
xArray = []
yArray = []

AccusedImage = visual.ImageStim(win=win, image='sin', mask=None, ori=0.0, pos=(-0.55, -0.05), size=(0.37, 0.27),
    color=[1,1,1], colorSpace='rgb', texRes=128.0, interpolate=True, depth=-3.0)
VictimImage = visual.ImageStim(win=win,image='sin', mask=None, ori=0.0, pos=(-0.55, 0.29), size=(0.37, 0.28),
    color=[1,1,1], colorSpace='rgb', texRes=128.0, interpolate=True, depth=-4.0)
CertaintyRatings = visual.Slider(win=win, size=(0.18, 0.594), pos=(0.53,  0), units=None,
    labels=None, ticks=[1,2, 3, 4, 5], granularity=0.0,
    style='slider', opacity=1.0,
    color='black', fillColor='darkblue', borderColor='White', colorSpace='rgb',
    font='Open Sans', labelHeight=0.05, flip=False, depth=-3, readOnly=False)
y1=0
innScale = visual.Rect(win=win, width=(0.18, y1)[0], height=(0.18, y1)[1],
    ori=0.0, pos=(0.53, 0),lineWidth=1.0,  colorSpace='rgb',  lineColor='darkGrey', fillColor='green',
    opacity=0.5, depth=-6.0, interpolate=True)
QuestionScale = visual.Slider(win=win, size=(1.0, 0.1), pos=(0,-0.14), ticks=(1,2,3,4,5,6,7), units=None, labels=None, granularity = 1.0, style='rating', color='LightGrey', fillColor='Blue', borderColor='White', labelHeight=0.01, flip=False, depth=0, readOnly=False)
qNums = visual.TextStim(win=win, text='1               2               3               4               5               6               7',pos=(0, -0.246), height=0.0365, wrapWidth=1.8, color='white');

Space2 = keyboard.Keyboard()
Space1 = keyboard.Keyboard()
innKeys = keyboard.Keyboard()
guiltyKeys = keyboard.Keyboard()
endEnter = keyboard.Keyboard()
EnterEnd = keyboard.Keyboard()
Esempio n. 26
0
img_height = int(win_height*0.65)

rating_values = []
reaction_times = []
win = visual.Window(size=[win_width,win_height], units='pix')
stim_num = 10 # all: len(images_path)==101
for image_idx in range(stim_num):
    # Display image
    img = visual.ImageStim(win, images_path[image_idx])
    img.setSize([img_width,img_height])
    img.setPos([0,0])
    img.draw()
    
    # Display rating slider
    values = list(range(1,8))
    rating_slider = visual.Slider(win, ticks=values, labels=values, size=[250,25], pos=[0,-400], style='rating', font='Helvetica')
    rating_slider.draw()
    
    win.flip()
    start_time = time.time()
    
    # Get rating value
    while True:
        if rating_slider.getMouseResponses() is not None:
            rating_value = rating_slider.getRating()
            rating_values.append(rating_value)
            
            reaction_time = time.time() - start_time
            reaction_times.append(reaction_time)
            
            break