Update Text Options: Insert content authored by Fabian Berg's avatar Fabian Berg
...@@ -2,16 +2,294 @@ ...@@ -2,16 +2,294 @@
## showText ## showText
function: [newX,newY,textbounds,flipTime] = showText(text, varargin)
**Description**
Use this function to plot a text on the presentation window. A wrapper function for the psych function DrawFormattedText that handles the typical Psychophysics Toolbox problems for beginners.
**Inputs**
~~~
text enter text as string
~~~
**Inputs-optional**
~~~
varargin ‘x’ x position in percent (0  left, 100  right)
‘y’ y position in percent (0  top, 100  bottom)
‘orientation’ orientation of the text, always followed by one of these
arguments:
‘center’ default value
‘left’ text starts at given x value (needs x value as
additional input argument)
‘right’ text ends at given x value (needs x value as
additional input argument)
‘rect’ plots text centered in the given rect! good for long
texts. rect is the standard Psychtoolbox rect format:
[xUpper yUpper xLower yLower] for pixel number (advanced
users)
‘color’ text color as RGB vector with values from 0:255
‘size’ text size in pixel
‘time’ time to wait
‘key’ wait until any key is pressed
‘dontFlip’ don't flip buffers (advanced users)
‘wrapat’ wrap text if it's to long after given number of
characters
‘speed’ speeds up text drawing. Makes Text positioning more
inaccurate and text is without anti-aliasing.
~~~
**Outputs**
~~~
newX, newY, textbounds outputs of the psychophysics toolbox function
drawFormattedText (advanced users)
flipTime internal time of the flip (see chapter 2.1.
Flip/dontFlip)
~~~
**Examples**
~~~
1. showText('Hello World');
% Draws the string Hello World on the middle of the screen
2. showText('Hello World', 'x', 10, 'y', 10, 'color', [1 0 0]);
% Draws the string "Hello World" in red in the left upper corner
3. showText('Hello World', 'x', 0, 'orientation', 'left');
% Draws the string "Hello World" starts at left side of the monitor
4. showText('Hello World', 'y', 80, 'key');
% Draws the string "Hello World" at position center/bottom and waits for the user to %
press a key.
5. showText('Hello World', 'wrapat', 5)
% Draws the string Hello World on the middle of the screen and wraps it after 5
% characters
~~~
## changeTextSettings ## changeTextSettings
function: changeTextSettings(size, spacing)
**Description**
Use this function to change the text size and the spacing between two text lines on the stimulus presentation window. Settings are global settings until this function is called again.
**Inputs**
~~~
size global text size, default = 35
spacing glob spacing between two lines, default = 1.4
~~~
## showInstructions (human) ## showInstructions (human)
function: showInstructions(source,varargin)
**Description**
Use this function to display instructions or information to a subject. The text is read out of a text file or entered directly. The user has to press a key to continue the program and the screen is cleared automatically.
**Inputs**
~~~
source path for text file or string
~~~
**Inputs-optional**
~~~
‘noKey’ presents the text and doesn't wait for the user input
‘noClear’ presents the text, but the screen isn't cleared after the user pressed a key
‘wrapat’ wraps the text after the given number of characters without wrapping within words
‘color’ text color as RGB vector with values from 0:255
‘size’ changes text size in pixel (only for the current screen, not globally)
‘align’ aligns the text horizontally. The strings 'left', 'center' and 'right' are allowed as arguments
~~~
**Examples**
~~~
1. showInstructions('instruction1.txt')
% displays the text of the given file
2. showInstructions('This is my example text')
% displays the text that is given as string
~~~
## fixationCross ## fixationCross
function: fixationCross(varargin)
**Description**
Draws a white fixations cross on the screen and waits specified time
**Inputs**
~~~
varargin ‘time’ time to wait in seconds
‘size’ size of cross in pixel (default 20)
‘penWidth’ pen width for cross
‘color’ color triplet (default white [255 255 255])
‘dontFlip’ don't flip buffers (advanced users)
~~~
**Examples**
~~~
1. fixationCross(2);
% Presents the fixation cross for 2 seconds
fixationCross(1.5, 'color', [255 0 0]);
% Presents the fixation cross in red for 1.5 seconds
~~~
## plotScale (human) ## plotScale (human)
function: out = plotScale(duration, text, varargin)
**Description**
Use this function to plot a scale on the stimulus presentation window that is highly adjustable.
**Inputs**
~~~
duration the time to wait unless a response is made
text a cell containing a string or character for each
position of the scale. Simple formatting is
allowed: \n is a line break
~~~
**Inputs-optional**
~~~
‘x’ position of scale in X with respect to the center of scale, 0%  left, 100%  right
‘y’ position of scale in Y with respect to the center of scale, 0%  top, 100%  bottom
‘width’ width of scale in percent with respect to screen
‘textSize’ text size in pixel
‘penWidth’ pen width in pixel (for scales)
‘color’ color as RGB triplet
‘noDivision’ plot of the sub division lines is disabled. The text of each element is still plotted!
‘active’ set by default! Sets the scale as active (responses are saved). Only one
active scale per screen! Otherwise results are random!!
‘inactive’ plots scale, but ignores clicks on the screen. Scale is grey to show that
it’s not active. This option includes the dontFlip option! That means the
scale isn't plotted on the screen when calling alone.
‘markText’ marks the text of the given index in a different color. The index defines
the position of the text and has to be a scalar. A second argument is
needed to define the color. Color is represented as RGB triplet.
~~~
**Outputs**
~~~
out a struct containing all possible information:
.x the X position of the point where the user clicked. Zero if the user did not click.
.y the Y position of the point where the user clicked. Zero if the user did not click.
.time response time of the user in seconds
.escape this entry is set to one if ESC was pressed.
.click answer in range from 0  left to 1 right.
Negative values means: click left from scale.
Values bigger than one means: click right from scale
.index index ranging from 1 to <number of text elements> (for an easier analysis)
~~~
**Examples**
~~~
1. out = plotScale(5, {'1', '2', '3', '4', '5'}, 'y', 70, 'color', [255 0 255]);
% Plots a scale in the lower middle of the screen with the values
ranging from 1 to 5. The scale is displayed 5 seconds or until the user responds.
2. out = plotScale(5, {'1', '2', '3', '4', '5'},'penWidth',5,'textSize',50);
% Plots a scale in the middle of the screen with the values
ranging from 1 to 5. The scale is displayed 5 seconds or until the
user responds. The command changes the pen width to 5 and the text size to 50.
~~~
![image](uploads/f1a6a47cb52b282623658fe1736d63d1/image.png)
~~~
3. out = plotScale(inf, {'a','b','c','d','e','f','g'});
% Plots a scale ranging from a to g in the middle of the screen
(default values). The display time is set to infinity. That means the user has to respond.
4. out = plotScale(10, {'Very\nlong\ntext', 'short1', 'short2', 'very long\n again'})
% Example for the usage of new lines (\n) in the text.
5. plotScale(inf, {'a','b','c','d','e','f','g'}, 'y', 70, 'inactive', 'dontFlip', 'color', [128 128 128]);
out = plotScale(inf, {'a','b','c','d','e','f','g'});
% Plots two scales on the screen, but only the first is active.
Plotting the inactive Scale has to be done first (dontFlip)!!!
6. out = plotScale(10, {'a','b','c','d','e','f','g'}, 'markText', [2 5], [255 0 0]);
% Plots a scale in the middle of the screen and the characters b and e are marked in red.
~~~
## startQuestionnaire (human) ## startQuestionnaire (human)
function: out = startQuestionnaire(text, ansText, varargin)
**Description**
This is the main function for questionnaires. It needs at least two arguments. In addition startQuestionnaire allows you to modify several optional parameters.
**Inputs**
~~~
text a cell that contains all questions
ansText a cell that contains the possible answers
~~~
**Inputs-optional**
~~~
varargin ‘mainDiv’ a value in percent that divides the screen vertically into
"question part" and answer part"
‘fontQuest’ font size for the presented questions
‘fontAns’ font size for the possible answers (presented on top of the chart)
‘startX’ start position in percent of the chart on the screen.
‘stopX’ stop position in percent of the chart on the screen.
‘penMain’ pen width in pixel for main question
‘penUL’ pen width in pixel for upper and lower question
‘color’ color triplet that defines the color for the main question
‘colorful’ color triplet that defines the color for the upper and lower question
‘topText’ a text that is presented on top of the questions (if the first
part of the sentence is always the same)
~~~
**Outputs**
~~~
out a struct containing all possible information:
.x x coordinate of every answer click
.y y coordinate of every answer click
.time reaction time for every answer given
.escape changes to ‘1’ if escape was pressed during the experiment (otherwise ‘0’)
.click x coordinate of answer in percent (0= most left possible answer field for
clicking, 100= most right possible answer field for clicking)
.index index of the given answer (‘1’ is first possible answer, ‘2’ is second etc.)
.question question asked
.answer answer given
~~~
**Examples**
~~~
1. out=startQuestionnaire({‘What is blue?’, ‘What is salty?’, ’What is music?’}, {‘taste’,
‘color’, ‘smell’, ‘sound’});
~~~
![image](uploads/863feca79e882da058471f6dba3e0e01/image.png)
## inputTextBox (human) ## inputTextBox (human)
function: [text2display, escape] = inputTextBox(varargin)
**Description**
This function creates a box that allows the user to type a free defined word or text. The input is terminated by pressing enter. The text is available in MATLAB as a string. Use ESC key to exit function.
**Inputs**
~~~
varargin ‘x’ x Position in percent
‘y’ y Position in percent (top is 0, bottom is 100)
‘color’ text color as triplet (RGB)
‘time’ maximum time to wait in seconds (default is 30s)
‘maxSymbols’ maximum number of symbols (determines only the size of the box)
~~~
**Outputs**
~~~
text2display string of text entered
escape set to 1 if ESC was pressed, otherwise 0
~~~
## cleanConfigCache ## cleanConfigCache
function: cleanFontConfigCache
**Description**
This function cleans the font config cache of GStreamer. Call this function if text rendering takes a very long time! Should not be called from within an experiment.