How can I prevent text from appearing in pictures?

I am trying to use MATLAB

Stroop to create a very simple problem where the participants have to decide what color will be printed on the screen. For some reason, words are always truncated no matter how large or small the font is.

enter image description here

I used the following code to set the size of the shape:

h = figure('Position', [1, 1, 1200, 800]);
set(h, 'NumberTitle', 'off', ...
       'Name', 'Stroop Test', ...
       'Color', 'black', ...
       'MenuBar','none', ...
       'ToolBar', 'none');

      

I used the following code to display the actual stimuli of a word:

ht = show_text(h, lang.words(iNoise),...
                'FontSize', 60,...
                'ForegroundColor', lang.colors{iStimul});

      

ADDED:

function handle = show_text(parrent, string, varargin)

parpos = get(parrent, 'Position');
pos = [5 round(parpos(4)/2)-30 parpos(3)-10 60];

handle = uicontrol(parrent,...
    'Style','Text',...
    'BackgroundColor', 'black',...
    'ForegroundColor', 'white',...
    'Position', pos,...
    'FontUnits', 'pixels');

if length(varargin) > 0, set(handle, varargin{:}), end;
fontsize = get(handle, 'FontSize');

[outstring,newpos] = textwrap(handle,string);
height = length(outstring) * 1.1 * fontsize;
pos = [5 round(parpos(4)/2)-round(height/2) parpos(3)-10 height];
set(handle,'String',outstring,'Position', pos);
drawnow;

end

      

If someone can tell me what the problem is, that would be great.

+3


source to share


2 answers


What happens if you offset a variable height

in a function show_text

using more factors like this:

height = length(outstring) * 1.5 * font size;

      



Instead of 1.1

? Or try it 2

.

+1


source


Not a direct answer to your question, but I highly recommend PsychToolbox for this ... There are many problems with using matlab metric for experimentation ...



The problem you are describing is just one of many, and why PsychToolbox, cogent, etc. were written - and they make it easier to code this kind of task.

+1


source







All Articles