def liking2(InstructionLiking2):
    myRatingScale1 = visual.RatingScale(window, low= 1, high=9, skipKeys=None, scale = (u"Slecht \t\t\t\t\t\t\t\t\t\t Goed"), stretch = 1.4, textSize = 0.4, size = 1.2, textColor = 'white', \
    lineColor = 'white', showValue=False, pos=[0,260], tickMarks=[1, 2, 3, 4, 5, 6, 7, 8, 9], labels=["1", "2", "3", "4", "5", "6", "7", "8", "9"], acceptPreText  = u"Klik op de lijn", acceptText = u"Aanvaarden", \
    acceptSize = 2.2, mouseOnly = True, name='gutschlecht') 
    
    myRatingScale2 = visual.RatingScale(window, low= 1, high=9, skipKeys=None, scale = (u"Gemeen \t\t\t\t\t\t\t\t\t\t Aangenaam"), stretch = 1.4, textSize = 0.4, size = 1.2, textColor = 'white', \
    lineColor = 'white', showValue=False, pos=[0,115], tickMarks=[1, 2, 3, 4, 5, 6, 7, 8, 9], labels=["1", "2", "3", "4", "5", "6", "7", "8", "9"], acceptPreText  = u"Klik op de lijn", acceptText = u"Aanvaarden", \
    acceptSize = 2.2, mouseOnly = True, name='freundlichgemein')
    
    myRatingScale3 = visual.RatingScale(window, low= 1, high=9, skipKeys=None, scale = (u"Onprettig \t\t\t\t\t\t\t\t\t\t Prettig"), stretch = 1.4, textSize = 0.4, size = 1.2, textColor = 'white', \
    lineColor = 'white', showValue=False, pos=[0,-30], tickMarks=[1, 2, 3, 4, 5, 6, 7, 8, 9], labels=["1", "2", "3", "4", "5", "6", "7", "8", "9"], acceptPreText  = u"Klik op de lijn", acceptText = u"Aanvaarden", \
    acceptSize = 2.2, mouseOnly = True, name='disagreeable') 
    
    myRatingScale4 = visual.RatingScale(window, low= 1, high=9, skipKeys=None, scale = (u"Onzorgzaam \t\t\t\t\t\t\t\t\t\t Zorgzaam"), stretch = 1.4, textSize = 0.4, size = 1.2, textColor = 'white', \
    lineColor = 'white', showValue=False, pos=[0,-175], tickMarks=[1, 2, 3, 4, 5, 6, 7, 8, 9], labels=["1", "2", "3", "4", "5", "6", "7", "8", "9"], acceptPreText  = u"Klik op de lijn", acceptText = u"Aanvaarden", \
    acceptSize = 2.2, mouseOnly = True, name='uncaring') 
    
    myRatingScale5 = visual.RatingScale(window, low= 1, high=9, skipKeys=None, scale = (u"Wreedaardig \t\t\t\t\t\t\t\t\t\t Lief"), stretch = 1.4, textSize = 0.4, size = 1.2, textColor = 'white', \
    lineColor = 'white', showValue=False, pos=[0,-320], tickMarks=[1, 2, 3, 4, 5, 6, 7, 8, 9], labels=["1", "2", "3", "4", "5", "6", "7", "8", "9"], acceptPreText  = u"Klik op de lijn", acceptText = u"Aanvaarden", \
    acceptSize = 2.2, mouseOnly = True, name='cruelkind') 
    
    instr = visual.TextStim(window, text=InstructionLiking2, pos = (0, 350), color = 'white')
    
    event.clearEvents()
    while myRatingScale1.noResponse or myRatingScale2.noResponse or myRatingScale3.noResponse or myRatingScale4.noResponse or myRatingScale5.noResponse:
        myRatingScale1.draw()
        myRatingScale2.draw()
        myRatingScale3.draw()
        myRatingScale4.draw()
        myRatingScale5.draw()
        instr.draw()
        window.flip()
    return(myRatingScale1.getRating(), myRatingScale2.getRating(), myRatingScale3.getRating(), myRatingScale4.getRating(), myRatingScale5.getRating())
def liking2(InstructionLiking2):
    myRatingScale1 = visual.RatingScale(window, low= 1, high=9, skipKeys=None, scale = ("Bad \t\t\t\t\t\t\t\t\t\t Good"), stretch = 1.4, textSize = 0.4, size = 1.2, textColor = 'white', \
    lineColor = 'white', showValue=False, pos=[0,260], tickMarks=[1, 2, 3, 4, 5, 6, 7, 8, 9], labels=["1", "2", "3", "4", "5", "6", "7", "8", "9"], acceptPreText  = "Please, click on the line", acceptText = "Accept", \
    acceptSize = 2.2, mouseOnly = True, name='gutschlecht') 
    
    myRatingScale2 = visual.RatingScale(window, low= 1, high=9, skipKeys=None, scale = ("Mean \t\t\t\t\t\t\t\t\t\t Pleasant"), stretch = 1.4, textSize = 0.4, size = 1.2, textColor = 'white', \
    lineColor = 'white', showValue=False, pos=[0,115], tickMarks=[1, 2, 3, 4, 5, 6, 7, 8, 9], labels=["1", "2", "3", "4", "5", "6", "7", "8", "9"], acceptPreText  = "Please, click on the line", acceptText = "Accept", \
    acceptSize = 2.2, mouseOnly = True, name='freundlichgemein')
    
    myRatingScale3 = visual.RatingScale(window, low= 1, high=9, skipKeys=None, scale = (u"Disagreeable \t\t\t\t\t\t\t\t\t\t Agreeable"), stretch = 1.4, textSize = 0.4, size = 1.2, textColor = 'white', \
    lineColor = 'white', showValue=False, pos=[0,-30], tickMarks=[1, 2, 3, 4, 5, 6, 7, 8, 9], labels=["1", "2", "3", "4", "5", "6", "7", "8", "9"], acceptPreText  = "Please, click on the line", acceptText = "Accept", \
    acceptSize = 2.2, mouseOnly = True, name='disagreeable') 
    
    myRatingScale4 = visual.RatingScale(window, low= 1, high=9, skipKeys=None, scale = (u"Uncaring \t\t\t\t\t\t\t\t\t\t Caring"), stretch = 1.4, textSize = 0.4, size = 1.2, textColor = 'white', \
    lineColor = 'white', showValue=False, pos=[0,-175], tickMarks=[1, 2, 3, 4, 5, 6, 7, 8, 9], labels=["1", "2", "3", "4", "5", "6", "7", "8", "9"], acceptPreText  = "Please, click on the line", acceptText = "Accept", \
    acceptSize = 2.2, mouseOnly = True, name='uncaring') 
    
    myRatingScale5 = visual.RatingScale(window, low= 1, high=9, skipKeys=None, scale = (u"Cruel \t\t\t\t\t\t\t\t\t\t Kind"), stretch = 1.4, textSize = 0.4, size = 1.2, textColor = 'white', \
    lineColor = 'white', showValue=False, pos=[0,-320], tickMarks=[1, 2, 3, 4, 5, 6, 7, 8, 9], labels=["1", "2", "3", "4", "5", "6", "7", "8", "9"], acceptPreText  = "Please, click on the line", acceptText = "Accept", \
    acceptSize = 2.2, mouseOnly = True, name='cruelkind') 
    
    instr = visual.TextStim(window, text=InstructionLiking2, pos = (0, 350), color = 'white')
    
    event.clearEvents()
    while myRatingScale1.noResponse or myRatingScale2.noResponse or myRatingScale3.noResponse or myRatingScale4.noResponse or myRatingScale5.noResponse:
        myRatingScale1.draw()
        myRatingScale2.draw()
        myRatingScale3.draw()
        myRatingScale4.draw()
        myRatingScale5.draw()
        instr.draw()
        window.flip()
    return(myRatingScale1.getRating(), myRatingScale2.getRating(), myRatingScale3.getRating(), myRatingScale4.getRating(), myRatingScale5.getRating())
Exemple #3
0
 def next_question(self):
     """
     Gets the next form question and creates a RatingScale. Two different RatingScales are created depending on how many labels are needed.
     Note that it does not work setting the number of labels to the number of ticks. The reason for this is unkown.
     Params:
         None
     Returns:
         None
     """
     if (len(self.data["Scale"][self.current_question].split(",")) > 2):
         self.scale = visual.RatingScale(
             self.win,
             choices=self.data["Scale"][self.current_question].split(","),
             scale=self.data["Survey_items"][self.current_question],
             size=1,
             stretch=2)
     else:
         self.scale = visual.RatingScale(
             self.win,
             low=1,
             high=len(self.data["Response_options"][0].split(
                 ",")),  #Needs format revision
             labels=self.data["Scale"][self.current_question].split(","),
             scale=self.data["Survey_items"][self.current_question],
             size=1,
             stretch=2)
     self.current_question += 1
     self.t0 = self.clock.getTime()
def confidencePrompt(fx, Screen, Clock, trialClock, waitTime, counterBalance):
    """a script to call which asks participants to respond on a scale of 0-7 how confident they were"""
    first = [[-1, -1]]

    targetTime = trialClock.getTime() + waitTime

    if counterBalance == 'cb':
        msg = visual.TextStim(Screen,
                              wrapWidth=1000,
                              pos=(0, 1),
                              text="How confident are you in your answer?")
        ConfScale = visual.RatingScale(Screen,
                                       showAccept=False,
                                       scale="Certain              Guessed")
        ConfScale.draw()

        Clock.reset()
        while trialClock.getTime() < targetTime:
            msg.draw()
            ConfScale.draw()
            fx.draw()
            Screen.flip()
            core.wait(0.001)

        if ConfScale:
            first[0][0] = ConfScale.getRating()
            first[0][1] = ConfScale.getRT()
        else:
            first[0][0] = 'NaN'
            first[0][1] = 'NaN'

    else:
        msg = visual.TextStim(Screen,
                              wrapWidth=1000,
                              pos=(0, 1),
                              text="How confident are you in your answer?")
        ConfScale = visual.RatingScale(Screen,
                                       showAccept=False,
                                       scale="Guessed              Certain")
        Clock.reset()

        while trialClock.getTime() < targetTime:
            msg.draw()
            ConfScale.draw()
            fx.draw()
            Screen.flip()
            core.wait(0.001)

        if ConfScale:
            first[0][0] = ConfScale.getRating()
            first[0][1] = ConfScale.getRT()
        else:
            first[0][0] = 'NaN'
            first[0][1] = 'NaN'

        while Clock.getTime() < .992:
            core.wait(0.001)

    return (first)
def get_valence_or_arousal(valence, question, g):
    #valence will be either True or False
    if valence:
        image_file = os.path.join(os.path.dirname(__file__), 'media', 'valence.bmp')
        
    else:
        image_file = os.path.join(os.path.dirname(__file__), 'media', 'arousal.bmp')
    image = visual.ImageStim(g.win, image_file, pos=[0,-.4], units='norm', size=[2, .34]) 
    
    scale_1 = visual.RatingScale(g.win, lineColor='White', precision=1, low=1, high=5, singleClick=False, leftKeys=g.session_params['left'], rightKeys=g.session_params['right'], acceptKeys=g.session_params['select'], mouseOnly = False, marker=visual.TextStim(g.win, text='l', units='norm', color='red'),
        textColor='White', scale=None, pos=(0,-.65), showAccept=False, stretch=2.85, markerStart = 3, labels=['1', '2', '3', '4', '5'], tickMarks=range(1,6))
    msg = visual.TextStim(g.win,text="",units='norm',pos=[-0,-.8],color=[1,1,1],height=.1,wrapWidth=2, alignHoriz = 'center', alignVert='top')
    msg.setText(question)
    
    msg.draw()
    scale_1.draw()
    image.draw()
    g.win.flip()
    start_time = g.clock.getTime()
    while scale_1.noResponse:
        image.draw()
        check_for_esc()
        msg.draw()
        scale_1.draw()
        g.win.flip()
    end_time = g.clock.getTime()
    return scale_1.getRating(), end_time, end_time - start_time
Exemple #6
0
def MakeRatingScale():
    global myRatingScale, rating_dir1, rating_dir2

    #Rating directions (rating_dir1 for practice trials, rating_dir2 for task)
    rating_dir1 = visual.TextStim(win,
                                  height=0.6,
                                  wrapWidth=28,
                                  color='black',
                                  pos=(-1, 3),
                                  text='''
        On the next screen you will use the keyboard arrows to select how well you timed the interval. 
        Select   "Early"   if you think you pressed well before the interval elapsed,   "Close"   if you think 
        you pressed approximately when the interval elapsed, or   "Late"   if you think you pressed well 
        after the interval elapsed. There's no right or wrong answer for this, just your own opinion! 
        (You will be asked to do this after each trial).\n\n
        Press any key to display the rating scale and make your selection.
        ''')

    rating_dir2 = visual.TextStim(win,
                                  height=0.7,
                                  wrapWidth=28,
                                  color='black',
                                  pos=(-1, 7),
                                  text='''
          Use the arrows to select how well you timed the interval.\n\n
                                   Press enter when done.''')

    #Initialize rating scale
    myRatingScale = visual.RatingScale(win,
                                       pos=(0, 0),
                                       lineColor='black',
                                       markerStart='Close',
                                       choices=['Early', 'Close', 'Late'])
def memory_run(win, run, mem_df, params, timing, paths, test = False):
    """
    Displays full memory run, saves out data to csv

    inputs:
        win - visual window
        run - run number (int)
        paths - paths to subject-relevant directories (dictionary)
        params - experiment parameters (dictionary)
        timing - stimulus display times (dictionary)
        mem_df - all trial info for current memory block (dataframe)
    """
    fixation = fix_stim(win)

    for trial in mem_df.index.values:

        display(win, [fixation], timing['pause'], path = paths)

        rating_scale = visual.RatingScale( win, low = 1, high = 4, labels=['unfamiliar','familiar'], scale='1               2               3               4',
                                            pos = [0,-.42], acceptPreText = '-',
                                            maxTime=3.0, minTime=0, marker = 'triangle', showAccept=False, acceptSize=0, singleClick = True)

        resp_clock = core.Clock()
        im_path = paths['stim_path']+'single/'+mem_df['Memory Image']
        image = memory_stim(win, mem_df['Memory Image'][trial], paths['stim_path'])

        display(win, [image, rating_scale], timing['mem'], accepted_keys=['1','2','3','4'], trial=trial, df=mem_df, path = paths)
        mem_df.to_csv(paths['subject']+'mem'+str(run)+'.csv')
Exemple #8
0
def presentValenceProbe(win, valenceStim, EDFfilename):
    ## Presents the valence question.
    
    #win.callOnFlip(getEYELINK().sendMessage, "STICKY_ON")
    valenceStim.draw()
    win.flip()
    event.getKeys()
    
    valenceScale = visual.RatingScale(win, low = 1, high = 100, tickMarks= [1, 25, 50, 75, 100], labels = ['--', '-', 'neutral', '+', '++'], showValue = False, acceptPreText ='click line', acceptText = 'Continue')
    valenceRating = []
    item = valenceStim
    while valenceScale.noResponse:
        item.draw()
        valenceScale.draw()
        win.flip()
        if event.getKeys(['escape']):
                core.quit()
    valenceRating.append(valenceScale.getRating())
    valenceRT = valenceScale.getRT()
    vlaenceChoiceHistory = valenceScale.getHistory()
    
    #getEYELINK().sendMessage("STICKY_RESPONSE %s" %(stickyResponse[0]))
    
    if event.getKeys(keyList=["escape"]):
        #closeEyetracker(EDFfilename)
        core.quit()
        
    if valenceRating:
        return valenceRating[0]
    else:
        #getEYELINK().sendMessage("NO_STICKY_RESPONSE")
        return ''
Exemple #9
0
    def __init__(self,
                 window,
                 movie,
                 destination_path,
                 movie_dimensions=(1, 1),
                 units='norm',
                 tick_marks=[1, 2, 3, 4, 5, 6, 7, 8, 9],
                 rating_description='Very negative  . . .  Very positive',
                 header_text=None,
                 header_size=0.15,
                 stretch_horizontal=2.7,
                 marker_style='triangle',
                 marker_color='White',
                 marker_start=5,
                 low=1,
                 high=9,
                 pos=None,
                 button_box=None,
                 *args,
                 **kwargs):

        super(VideoRating, self).__init__(window)
        # FIXME: video should mantain aspect ratio regardless of window dimensions
        self.mov = visual.MovieStim(self.window,
                                    movie,
                                    size=movie_dimensions,
                                    units=units,
                                    flipVert=False,
                                    loop=False)

        # Header text
        if header_text:
            self.header_text = visual.TextStim(
                self.window,
                text=header_text,
                pos=(0, 0.7),
                height=header_size,
                wrapWidth=2.0,  # ??
                units=units)
        else:
            self.header_text = None

        self.rating_scale = visual.RatingScale(self.window,
                                               low=low,
                                               high=high,
                                               tickMarks=tick_marks,
                                               precision=1,
                                               pos=(0, -0.75),
                                               stretchHoriz=stretch_horizontal,
                                               showAccept=False,
                                               acceptKeys=[None],
                                               markerStyle=marker_style,
                                               markerColor=marker_color,
                                               markerStart=marker_start,
                                               *args,
                                               **kwargs)
        self.rating_scale.setDescription(rating_description)
        # The destination path to write the history to
        self.dest = destination_path
        self.button_box = button_box
Exemple #10
0
 def __init__(self, window, questions, color):
     '''Initialize a question stimulus.
     Args:
     window - The window object
     questions - a list of dictionaries
     keys - list of keys to press to continue to next stimulus. If None,
             will automatically go to the next stimulus.
     Additional args and kwargs are passed to the visual.TextStim
     constructor.
     '''
     self.window = window
     self.description = visual.TextStim(self.window,
                                        text=None,
                                        height=34,
                                        wrapWidth=1100,
                                        color=color,
                                        font=sans)
     self.questions = questions
     self.rating = visual.RatingScale(self.window,
                                      low=1,
                                      high=9,
                                      markerStart=4,
                                      precision=10,
                                      tickMarks=[1, 9],
                                      leftKeys='1',
                                      rightKeys='2',
                                      acceptKeys='4')
Exemple #11
0
def displayVAS(Df, params, win, text, labels):
    scale = visual.RatingScale(
        win,
        labels=labels,  # End points
        scale=None,  # Suppress default
        # markerStart=50,
        low=0,
        high=100,
        tickHeight=0,
        precision=1,
        size=2,
        textSize=0.6,
        acceptText='Continue',
        showValue=False,
        showAccept=True,
        markerColor="Yellow")  # markerstart=50
    myItem = visual.TextStim(win,
                             text=text,
                             height=.12,
                             units='norm',
                             pos=[0, 0.3],
                             wrapWidth=2)

    # Show scale and measure the elapsed wall-clock time.
    startTime = time.time()
    while scale.noResponse:
        scale.draw()
        myItem.draw()
        win.flip()
        get_keypress(Df, params)
    endTime = time.time()
    win.flip()
    return scale.getRating(), endTime - startTime
Exemple #12
0
 def test_rating_scale(self):
     if self.win.winType == 'pygame':
         pytest.skip("RatingScale not available on pygame")
     # try to avoid text; avoid default / 'triangle' because it does not display on win XP
     win = self.win
     win.flip()
     rs = visual.RatingScale(win,
                             low=0,
                             high=1,
                             precision=100,
                             size=3,
                             pos=(0, -.4),
                             labels=[' ', ' '],
                             scale=' ',
                             marker='glow',
                             markerStart=0.7,
                             markerColor='darkBlue',
                             autoLog=False)
     str(rs)  #check that str(xxx) is working
     rs.draw()
     if self.win.winType == 'pyglet' and utils._under_xvfb:
         pytest.xfail("not clear why fails under Xvfb"
                      )  # skip late so we smoke test the code
     utils.compareScreenshot('ratingscale1_%s.png' % (self.contextName),
                             win,
                             crit=30.0)
     win.flip()  #AFTER compare screenshot
Exemple #13
0
def survey_outro():
    shuffle(questions)  #randomize order of questions
    event.clearEvents()
    instr3.draw()
    win.flip()
    if 'escape' in event.waitKeys():
        core.quit()
    for i in questions:
        myRatingScale = visual.RatingScale(
            win,
            choices=[
                '      1:\nvery slightly/\nnot at all', '    2:\na little',
                '       3:\nmoderately', '        4:\nquite a bit',
                '      5:\nextremely'
            ],
            stretch=2.4,
            textColor='Black',
            lineColor='Black',
            showValue=False,
            acceptText='continue')
        myItem = visual.TextStim(win,
                                 text=qlibrary[i],
                                 height=.07,
                                 units='norm',
                                 color="#000000")
        event.clearEvents()
        while myRatingScale.noResponse:  # show & update until a response has been made
            myItem.draw()
            myRatingScale.draw()
            win.flip()
            if event.getKeys(['escape']):
                core.quit()
        response = myRatingScale.getRating()
        logging.log(level=logging.DATA,
                    msg="Question Number: %i , Response: %s" % (i, response))
 def create_rating_scale(win, pos):
     # rating scale
     scale = visual.RatingScale(win,
                                low=-1,
                                high=1,
                                size=1.5,
                                precision=10,
                                tickMarks=[('%.1f' % i)
                                           for i in np.linspace(-1, 1, 21)],
                                tickHeight=0.6,
                                markerStart='0',
                                marker='slider',
                                markerColor='white',
                                textSize=.25,
                                showValue=True,
                                textColor='white',
                                acceptSize=1.5,
                                showAccept=False,
                                noMouse=True,
                                maxTime=1000,
                                pos=pos)
     scale.marker.setSize(0.3)
     scale.line.setLineWidth(0.7)
     # scale.accept.setColor('black')
     return scale
Exemple #15
0
def run_trial(config, fix_stim, left_stim, mask_stim, fix_time, right_stim,
              soa, win, arrow_label, question_text, response_clock):
    trial_type = random.choice([CorrectStim.LEFT, CorrectStim.RIGHT])
    stim = left_stim if trial_type == CorrectStim.LEFT else right_stim
    stim_name = 'left' if trial_type == CorrectStim.LEFT else 'right'
    rt = -1.0
    win.callOnFlip(PORT.setData, TriggerTypes.FIX_START)

    for i in range(fix_time):  # Fixation octagon
        fix_stim.draw()
        win.flip()
        if i == 1:
            win.callOnFlip(PORT.setData, TriggerTypes.CLEAR)
        check_exit()
    win.callOnFlip(PORT.setData, TriggerTypes.TRIAL_START)
    for i in range(soa):  # Stimulus presentation
        stim.draw()
        win.flip()
        if i == 1:
            win.callOnFlip(PORT.setData, TriggerTypes.CLEAR)
        check_exit()
    for _ in range(config['MTIME']):  # Mask presentation
        mask_stim.draw()
        win.flip()
        check_exit()
    corr = False  # Used if timeout
    win.callOnFlip(response_clock.reset)
    event.clearEvents()
    for _ in range(config['RTIME']):  # Time for reaction
        arrow_label.draw()
        question_text.draw()
        win.flip()
        keys = event.getKeys(keyList=KEYS)
        if keys:
            corr = True if keys[0] == stim_name else False
            rt = response_clock.getTime()
            PORT.setData(TriggerTypes.TRIAL_ANS)
            core.wait(0.04)
            PORT.setData(TriggerTypes.CLEAR)
            break
        check_exit()
    # Rating Scale

    ratingScale = visual.RatingScale(
        win,
        size=0.8,
        noMouse=True,
        markerStart=2,
        stretch=1.4,
        scale=
        "Okre\u015bl swoj\u0105 pewno\u015b\u0107 co do udzielonej odpowiedzi",
        acceptPreText='Wybierz',
        choices=["\u017badna", "Ma\u0142a", "Du\u017ca", "Ca\u0142kowita"])
    while ratingScale.noResponse:
        ratingScale.draw()
        win.flip()
    rating = ratingScale.getRating()
    win.flip()
    return corr, rt, rating
Exemple #16
0
def get_one_vas_rating(g, vas_text):
    g.mouse.setVisible(1)
    top_text = visual.TextStim(g.win,
                               text="Please use the mouse to make a rating.",
                               units='pix',
                               height=80,
                               color='White',
                               pos=[0, 405],
                               wrapWidth=int(1600))

    text_1 = visual.TextStim(g.win,
                             text=vas_text,
                             units='norm',
                             height=0.07,
                             color='White',
                             pos=[0, 0.2],
                             wrapWidth=int(1600))
    scale_1 = visual.RatingScale(g.win,
                                 lineColor='White',
                                 marker=visual.TextStim(g.win,
                                                        text='l',
                                                        units='norm',
                                                        color='White'),
                                 precision=1,
                                 low=0,
                                 high=100,
                                 textColor='White',
                                 markerStart=50,
                                 scale=None,
                                 labels=['not at all', 'extremely'],
                                 tickMarks=[0, 100],
                                 showValue=False,
                                 pos=(0, 0),
                                 showAccept=False,
                                 acceptKeys='z')

    bot_text = visual.TextStim(g.win,
                               text="Press enter when done",
                               units='pix',
                               height=50,
                               color='White',
                               pos=[0, -450],
                               wrapWidth=int(1600))
    vas_start_time = g.clock.getTime()
    while True:
        if event.getKeys(["escape"]):
            raise QuitException()
        if event.getKeys(["return"]):
            break
        #item.draw()
        text_1.draw()
        scale_1.draw()
        top_text.draw()
        bot_text.draw()
        g.win.flip()
    now = g.clock.getTime()
    g.mouse.setVisible(0)
    return scale_1.getRating()
Exemple #17
0
 def test_rating_scale(self):
     # try to avoid text; avoid default / 'triangle' because it does not display on win XP
     win = self.win
     win.flip()
     rs = visual.RatingScale(win, low=0,high=1,precision=100, displaySizeFactor=3, pos=(0,-.4),
                     lowAnchorText=' ', highAnchorText=' ', scale=' ',
                     markerStyle='glow', markerStart=0.7, markerColor='darkBlue')
     rs.draw()
     utils.compareScreenshot('ratingscale1_%s.png' %(self.contextName), win, crit=30.0)
     win.flip()#AFTER compare screenshot
def csRatings(sessID,blockID,blockFile,name, shape,blockType,randCond):
    ''' This is the function for rating their feelings about shapes
    '''
    curRating = visual.RatingScale(win=win,
                                   low = 0,
                                   high = 100,
                                   precision=3,
                                   #tickMarks=(0,100),      # the location of tick marker
                                   tickHeight=1,            # suppress the ticker
                                   markerStart=np.random.choice(np.arange(3.0,7.0,0.1),1),
                                   scale = None,
                                   labels = ('sehr niedrig', 'sehr hoch'),
                                   stretch = 1.5,
                                   pos=(0.0, -150),          # this is the default setting
                                   leftKeys=['1', 'left'],   # keys for moving left
                                   rightKeys=['2', 'right'], # keys for moving right
                                   acceptKeys=['3','return'],# keys for accept the ratings
                                   noMouse=True,             # use mouse or not
                                   showValue=False,          # param for showing value or not
                                   name=name)                # the name for current rating
    curRating.slidingInterval = 0.1
    escDown = None
    while curRating.noResponse and escDown is None:
        escDown = get_keypress()
        if escDown is not None:
            shutdown()
        # prepare the instruction for rating emotion regulation strategy
        imName = _thisDir + os.sep + 'stim' + os.sep + 'rating_shape.jpg'
        showImage = visual.ImageStim(win, image=imName,pos=[0, 150])
        showImage.draw()
        if shape == "ci":   # if the shape is circle
            shapePres(shape,[0, 0], 75,0)
        else:               # if the shape is triangle
            shapePres(shape,[0, 0], 90, 0)
        curRating.draw()
        win.flip()
    cs_get_rating    = curRating.getRating()
    cs_decision_time = curRating.getRT()
  # write the rating
    # recode the CS+ and CS-
    if (randCond == '1' and shape == 'ci') | (randCond == '2' and shape == 'tr'):
        CStype = 1    # define the CS+
    elif (randCond == '1' and shape == 'tr') | (randCond == '2' and shape == 'ci'):
        CStype = 0    # define the CS-

    if blockType == 'R':
        blockTypeCode = 1
    else:
        blockTypeCode = 0
    resultRec = open(blockFile,'a+')
    # ['Session','Block','ratingType', 'blockType', 'CS(1+0-)','Ratings', 'Rating_time']
    curLine = ','.join(map(str,[sessID,blockID,'AnxRating', blockTypeCode, CStype,cs_get_rating,cs_decision_time]))
    resultRec.write(curLine)
    resultRec.write('\n')
    resultRec.close()
Exemple #19
0
 def __init__(self,fullscr,screen,size,message,question,minLabel,maxLabel):
     DisplayInterface.__init__(self,fullscr,screen,size,message)
     
     self.mouse = event.Mouse(True,None,self.win)
     
     barMarker = visual.TextStim(self.win, text='|', units='norm')
     
     self.VAS = visual.RatingScale(self.win, low=-10, high=10, precision=10, 
         showValue=False, marker=barMarker, scale = question,
         tickHeight=1, stretch=1.5, size = 0.8, 
         labels=[minLabel, maxLabel],
         tickMarks=[-10,10], mouseOnly = True, pos=(0,0))
def get_effort_rating(g, vas_text):
    #used by ColdPressor and BreathHold to get effort ratings
    start_time = g.clock.getTime()
    g.mouse.setVisible(1)
    top_text = visual.TextStim(g.win,
                               text="Please use the mouse to make a rating.",
                               units='pix',
                               height=80,
                               color='White',
                               pos=[0, 405],
                               wrapWidth=int(1600))

    text_1 = visual.TextStim(g.win,
                             text=g.effort_question_text,
                             units='norm',
                             height=0.07,
                             color='White',
                             pos=[0, 0.2],
                             wrapWidth=int(1600))
    scale_1 = visual.RatingScale(g.win,
                                 lineColor='White',
                                 marker=visual.TextStim(g.win,
                                                        text='l',
                                                        units='norm',
                                                        color='White'),
                                 precision=1,
                                 low=0,
                                 stretch=1.73,
                                 textSize=1,
                                 high=100,
                                 textColor='White',
                                 markerStart=50,
                                 scale=None,
                                 labels=g.effort_anchors,
                                 tickMarks=[0, 25, 50, 75, 100],
                                 showValue=False,
                                 pos=(0, 0),
                                 showAccept=True)

    #bot_text = visual.TextStim(g.win, text="Press enter when done", units='pix', height=50, color='White', pos=[0,-450], wrapWidth=int(1600))
    vas_start_time = g.clock.getTime()
    while scale_1.noResponse:
        if event.getKeys(["escape"]):
            raise QuitException()
        #item.draw()
        text_1.draw()
        scale_1.draw()
        top_text.draw()
        #bot_text.draw()
        g.win.flip()
    g.mouse.setVisible(0)
    return scale_1.getRating()
def init_rating_scale():
    rating_scale = visual.RatingScale(window, low=0,
                                      high=1,
                                      scale='rate the emotion',
                                      size=1.0,
                                      precision=100,
                                      markerStart=0.5,
                                      stretch=2.0,
                                      textColor='Gray',
                                      mouseOnly=True,
                                      showValue=False
                                      )
    rating_scale.acceptBox.pos = [-10, -100]
    return rating_scale
Exemple #22
0
def setupRatingScale():
    global ratingScale
    ratingScale = visual.RatingScale(win,
                                     low=1,
                                     high=10,
                                     noMouse=True,
                                     markerStart=5.5,
                                     lineColor='black',
                                     stretch=2.0,
                                     labels=('1', '2', '3', '4', '5', '6', '7',
                                             '8', '9', '10'),
                                     markerColor='black',
                                     scale=None,
                                     acceptPreText='')
def liking1(InstructionLiking1):
    myRatingScale = visual.RatingScale(window, low= 1, high=9, skipKeys=None, stretch = 1.4, scale = (u'Zeer onaardig                             \t\t\t\t\t\t\t\t                           Zeer aardig'), \
    textSize = 0.4, size = 1.55, textColor = 'white', lineColor = 'white', showValue=False, pos=[0,-30], \
    tickMarks=[1, 2, 3, 4, 5, 6, 7, 8, 9], labels=["1", "2", "3", "4", "5", "6", "7", "8", "9"], acceptPreText  = "Klik op de lijn", acceptText = "Aanvaarden", acceptSize = 2.2, mouseOnly = True) 
    instr = visual.TextStim(window, text=InstructionLiking1, pos = (0, 50), color = 'white')
    while myRatingScale.noResponse:
        instr.draw()
        myRatingScale.draw()
        window.flip()
    likingRating = myRatingScale.getRating()
    likingRT = myRatingScale.getRT()
    window.flip()
    core.wait(0.2)
    return(likingRating)
Exemple #24
0
def get_one_rating(question, responses, g, clk):
    print(str(question) + ' | ' + str(responses))
    msg_continue = visual.TextStim(g.win,
                                   text="Press enter when you are done.",
                                   units='norm',
                                   pos=(0, 0.7),
                                   color='red',
                                   height=0.075)
    msg = visual.TextStim(g.win,
                          text="",
                          units='norm',
                          pos=(0, 0.5),
                          color=[-1, -1, -1],
                          height=0.075,
                          wrapWidth=int(1.75))
    msg.setText(question)
    scale_1 = visual.RatingScale(g.win,
                                 lineColor='Black',
                                 precision=1,
                                 low=1,
                                 high=7,
                                 mouseOnly=True,
                                 marker=visual.TextStim(g.win,
                                                        text='l',
                                                        units='norm',
                                                        color='red'),
                                 textColor='Black',
                                 scale=None,
                                 labels=responses,
                                 textSize=0.7,
                                 pos=(0, 0),
                                 showAccept=False,
                                 stretch=1.8,
                                 tickMarks=[1, 2, 3, 4, 5, 6, 7])
    msg_continue.draw()
    msg.draw()
    scale_1.draw()
    g.win.flip()
    start_time = clk.getTime()
    while scale_1.noResponse:
        if event.getKeys(["escape"]):
            raise StimToolLib.QuitException()
        elif event.getKeys(["return"]):
            break
        msg_continue.draw()
        msg.draw()
        scale_1.draw()
        g.win.flip()
    end_time = clk.getTime()
    return scale_1.getRating(), end_time, end_time - start_time
def noiseEstimation(chosenImage, estTime, Clock, Screen):
    #fix the scale here
    noiseScale = visual.RatingScale(Screen,
                                    marker="slider",
                                    markerColor="white",
                                    choices=None,
                                    low=0,
                                    high=125,
                                    showAccept=False,
                                    tickMarks=[0, 25, 50, 75, 100, 125],
                                    labels=None,
                                    showValue=False,
                                    acceptText='Match',
                                    size=1.0,
                                    textSize=0.0,
                                    scale=None)
    #change image to the default read
    name, ext = os.path.splitext(chosenImage)
    name = os.path.basename(name)
    defImage = name.split('_', 1)[0]

    tmp = Image.open(ndir + defImage + ".jpg")
    pic = numpy.array(tmp)
    im = Image.fromarray(pic)
    pres = visual.ImageStim(Screen, im, pos=(0, 0), size=(8, 8))
    num = 0

    Clock.reset()
    while Clock.getTime() < estTime:
        noiseScale.draw()
        pres.draw()
        Screen.flip()
        rating = noiseScale.getRating()
        if rating:
            if rating != num:
                num = rating
                n = rating / 1000
                tp = applySaltPepper(pic, n)
                tsp = Image.fromarray(tp)
                pres.setImage(tsp)
    if rating:
        rating = noiseScale.getRating() / 1000
        ratingRT = noiseScale.getRT()
        choiceHistory = noiseScale.getHistory()
    else:
        rating = 'NaN'
        ratingRT = 'Nan'
    return ((rating, ratingRT))
def erRatings(sessID, blockID, name, blockFile):
    ''' This is the function for rating the strategy
    '''
    curER_Rating = visual.RatingScale(
        win=win,
        low=0,
        high=100,
        precision=3,
        #tickMarks=(0,100),      # the location of tick marker
        tickHeight=1,  # suppress the ticker
        markerStart=np.random.choice(np.arange(3.0, 7.0, 0.1), 1),
        scale=None,
        labels=('gar nicht erfolgreich', 'sehr erfolgreich'),
        stretch=1.5,
        pos=(0.0, -100),  # this is the default setting
        leftKeys=['1', 'left'],  # keys for moving left
        rightKeys=['2', 'right'],  # keys for moving right
        acceptKeys=['3', 'return'],  # keys for accept the ratings
        noMouse=True,
        showValue=False,  # param for showing value or not
        name=name)  # the name for current rating
    curER_Rating.slidingInterval = 0.1
    escDown = None
    while curER_Rating.noResponse and escDown is None:
        escDown = get_keypress()
        if escDown is not None:
            shutdown()
        # prepare the instruction for rating emotion regulation strategy
        imName = _thisDir + os.sep + 'stim' + os.sep + 'rating_strag.jpg'
        showImage = visual.ImageStim(win, image=imName, pos=[0, 100])
        showImage.draw()
        # prepare the scale
        curER_Rating.draw()
        win.flip()
    get_rating = curER_Rating.getRating()
    decision_time = curER_Rating.getRT()

    # write the rating
    resultRec = open(blockFile, 'a+')
    # 'Session','Block','ratingType', 'blockType', 'CS(1+0-)','Ratings', 'Rating_time'
    curLine = ','.join(
        map(str,
            [sessID, blockID, 'StrRating', 1, 'NA', get_rating, decision_time
             ]))
    resultRec.write(curLine)
    resultRec.write('\n')
    resultRec.close()
def get_one_rating(question, responses, win, clk):
    msg = visual.TextStim(win,text="",units='pix',pos=[-600,250],color=[-1,-1,-1],height=50,wrapWidth=int(1200), alignHoriz = 'left', alignVert='top')
    msg.setText(question)
    scale_1 = visual.RatingScale(win, lineColor='Black', precision=1, low=1, high=7, singleClick=True, mouseOnly = True, marker=visual.TextStim(win, text='l', units='norm', color='red'),
        textColor='Black', scale=None, labels=responses,  pos=(0,0), showAccept=False, stretch=2, tickMarks=[1,2,3,4,5,6,7])
    msg.draw()
    scale_1.draw()
    win.flip()
    start_time = clk.getTime()
    while scale_1.noResponse: 
        if event.getKeys(["escape"]):
            raise QuitException()
        msg.draw()
        scale_1.draw()
        win.flip()
    end_time = clk.getTime()
    return scale_1.getRating(), end_time, end_time - start_time
Exemple #28
0
 def __init__(self):
     self.expWindow = visual.Window(  # psychopy visual.Window()
         units='pix',
         winType='pyglet',
         screen=0,
         color='black',
         size=[1440, 900],
         fullscr=True,
         allowGUI=False)
     self.expMouse = event.Mouse(  # psychopy event.Mouse()
         win=self.expWindow, visible=False)
     self.instructions = visual.TextStim(  # psychopy visual.TextStim()
         win=self.expWindow,
         pos=[0, 300],
         color='white',
         height=20,
         font='Helvetica',
         wrapWidth=800)
     self.progBarOutline = visual.Rect(  # psychopy visual.Rect()
         win=self.expWindow,
         pos=[0, 350],
         width=680,
         height=23,
         lineColor='white')
     self.progBar = visual.Rect(  # psychopy visual.Rect()
         win=self.expWindow,
         pos=[0, 350],
         width=680,
         height=20,
         fillColor='gray',
         opacity=0.8)
     self.ratingScale = visual.RatingScale(  # psychopy visual.RatingScale()
         win=self.expWindow,
         pos=[0, -150],
         low=1,
         high=5,
         precision=1,
         choices=(1, 2, 3, 4, 5),
         textColor='white',
         marker='triangle',
         size=1.0,
         stretch=1.0,
         lineColor='white',
         markerColor='blue',
         scale=None)
Exemple #29
0
 def __init__(self, win, colours):
     """
     This method initializes a new RatingScale object to use as the rating scale.
     Params:
         win: A window object representing the window the object should be drawn to
         colours: A colours tuple containing two colours
     Returns:
         None
     """
     self.scale = visual.RatingScale(
         win,
         pos=[0, -400],
         choices=Constants.CONFIDENCE_RATING_LVLS,
         textSize=Constants.RATING_TEXT_SCALE,
         stretch=2.5,
         scale=
         f"In your opinion, what is the most dominant colour between {colours[2]} and {colours[3]}",
     )
def noiseEstimation(chosenImage, Clock, Screen, expData):
    noiseScale = visual.RatingScale(Screen,
                                    lineColor='black',
                                    choices=None,
                                    low=0,
                                    high=300,
                                    tickMarks=None,
                                    labels=None,
                                    mouseOnly=True,
                                    showValue=False,
                                    acceptText='Match',
                                    acceptKeys='return')
    #change image to the default read
    name, ext = os.path.splitext(chosenImage)
    name = os.path.basename(name)
    defImage = name.split('_', 1)[0]

    tmp = Image.open(ndir + defImage + ".jpg")
    pic = numpy.array(tmp)
    im = Image.fromarray(pic)
    pres = visual.ImageStim(Screen, im, pos=(0, 4), size=(20, 20))
    num = 0

    while noiseScale.noResponse:
        noiseScale.draw()
        pres.draw()
        Screen.flip()
        rating = noiseScale.getRating()
        if rating:
            if rating != num:
                num = rating
                n = rating / 1000
                tp = applySaltPepper(pic, n)
                tsp = Image.fromarray(tp)
                pres.setImage(tsp)

    rating = noiseScale.getRating()
    #print("rating:", rating)
    ratingRT = noiseScale.getRT()
    #print("rating RT:", decisionTime)
    choiceHistory = noiseScale.getHistory()
    print("rating Hist:", choiceHistory)

    return ((rating, ratingRT))