A class for getting numeric or categorical ratings, e.g., a 1-to-7 scale.
Returns a re-usable rating-scale object having a .draw() method, with customizable visual appearance and full data options, including RT and history.
The .draw() method displays the rating scale, handles the subject’s responses, and updates the display. When the subject makes a final response, .noResponse goes False (i.e., there is a response). You can then call .getRating() to obtain the final rating, .getRT() to get the decision time, or .getHistory() to obtain all intermediate values (rating, RT), up to an including the final one. This feature can be used to obtain continuous ratings using a single RatingScale object.
The experimenter has to draw the item to be rated, i.e., draw() it in the same window each frame. A RatingScale instance has no idea what else is on the screen.
The subject can use the arrow keys (left, right) to move the marker in small increments (e.g., 1/100th of a tick-mark if precision = 100).
Auto-rescaling happens if the low-anchor is 0 and the high-anchor is a multiple of 10, just to reduce visual clutter.
The default 7-point scale:myItem = <create your text, image, movie, ...> myRatingScale = visual.RatingScale(myWin) while myRatingScale.noResponse: myItem.draw() myRatingScale.draw() myWin.flip() rating = myRatingScale.getRating() decisionTime = myRatingScale.getRT() choiceHistory = myRatingScale.getHistory()
Key-board only. Considerable customization is possible. For fMRI, if your response box sends keys 1-4, you could specify left, right, and accept keys, and no mouse:myRatingScale = visual.RatingScale(myWin, markerStart=4, leftKeys='1', rightKeys = '2', acceptKeys='4')
Non-numeric choices (categorical, unordered):myRatingScale = visual.RatingScale(myWin, choices=['agree', 'disagree'])
A text version of the item will be displayed, but the value returned by getResponse() will be of type you gave it:var = 3.14 myRatingScale = visual.RatingScale(myWin, choices=['cherry', 'apple', True, var, 'pie'])
So if the subject chooses True, getResponse() will return True (bool) and not u’True’ (unicode).
See Coder Demos -> stimuli -> ratingScale.py for examples. As another example, fMRI_launchScan.py uses a rating scale for the experimenter to choose between two modes (and not for subjects giving ratings).
The Builder RatingScale component gives a restricted set of options, but also allows full control over a RatingScale (via ‘customizeEverything’).
2010 Jeremy Gray, with on-going updates 2012 Henrik Singmann: tickMarks, labels, ticksAboveLine
Update the visual display, check for response (key, mouse, skip).
sets response flags as appropriate (self.noResponse, self.timedOut). draw() only draws the rating scale, not the item to be rated
Return the subject’s intermediate selection history, up to and including the final accepted choice, as a list of (rating, time) tuples. The history can be retrieved at any time, allowing for continuous ratings to be obtained in real-time. Both numerical and categorical choices are stored automatically in the history.
Returns the seconds taken to make the rating (or to indicate skip). Returns None if no rating available, or maxTime if the response timed out. Returns the time elapsed so far if no rating has been accepted yet (e.g., for continuous usage).
Returns the final, accepted rating, or the current (non-accepted) intermediate selection. The rating is None if the subject skipped this item, or False if not available. Returns the currently indicated rating even if it has not been accepted yet (and so might change until accept is pressed).
Restores the rating-scale to its post-creation state.
The history is cleared, and the status is set to NOT_STARTED. Does not restore the scale text description (such reset is needed between items when rating multiple items)
Method to set the text description that appears above the rating line.
Useful when using the same RatingScale object to rate several dimensions. setDescription(None) will reset the description to its initial state. Set to a space character (‘ ‘) to make the description invisible. The description will not be visible if showScale is False.
Sets current vertical mirroring to newVal.
Method to allow the experimenter to set the marker’s position on the scale (in units of tick marks). This method can also set the index within a list of choices (which start at 0). No range checking is done.
Assuming you have defined rs = RatingScale(...), you can specify a tick position directly:
or do range checking, precision management, and auto-rescaling:
To work from a screen coordinate, such as the X position of a mouse click: