How to present two versions of instruction text at random?

6 views (last 30 days)
Hi!
I'm trying to implement a function in my script (for running the Stroop task), that randomly presents either Instruction Text 1 or 2. The script contains 8 pseudorandom sequences for presentation of the words 'purple' and 'orange' in either the colour 'purple' or 'orange'. The 8 sequences stand for 8 runs of scanning. After each sequence (which contains 182 events) I want to present either Instruction Text 1 or 2 to change response mapping (we use a button box). Ideally, the script should present Instruction text 1 for all odd-numbered sequences & Instr.text 2 for all even-numbered sequences.
I already tried some things like mod, repmat, isodd & the following:
respmapping= seq(1:8); if respmapping==seq{2}||seq{4}||s eq{6}||seq{8} InstructText2; else InstructText1;
( error message on this: ??? Undefined function or method 'eq' for input arguments of type 'cell'. Error in ==> StroopScript at 244 if respmapping==seq{2}||seq{4}||seq{6}||seq{8} )
Nothing worked so far since most arguments are for arrays of scalars or cells. It's probably easy, but I got stuck. Could anyone help me?
Here a bit more of my (very long) script:
InstructText1 = ['Press LEFT for COLOUR. Press RIGHT for WORD.\n\n'... 'The task will begin when you press a button.\n\n\n'... 'Name colour or word as fast and\n\n'... 'accurate as possible.']; Screen('TextSize', expWin, 30);
InstructText2 = ['Press RIGHT for COLOUR. Press LEFT for WORD.\n\n'... 'The task will begin when you press a button.\n\n\n'... 'Name colour or word as fast and\n\n'... 'accurate as possible.']; Screen('TextSize', expWin, 30);
for Session=1:nSessions
%make random sequence for aud/vis cues
%cuemodality=zeros(size(seq{Session});
ntrials=sum(seq{Session}>0);
tempcuemodalities=[repmat({'vis'},1,ntrials/2), repmat({'aud'},1,ntrials/2)];
tempcuemodalities=tempcuemodalities(randperm(length(tempcuemodalities)));
cuemodalities=repmat({'null'},1,nEvents);
cuemodalities(seq{Session}>0)=tempcuemodalities;
respmapping= seq(1:8);
if respmapping==seq{2}||seq{4}||seq{6}||seq{8}
InstructText2;
else
InstructText1;
end
%Screen('TextSize', expWin, 24);
%DrawFormattedText(expWin, 'Take a short break', 'center', 'center');
%Screen('Flip', expWin);
Screen('TextSize', expWin, 30);
Screen('Flip', expWin);
DrawFormattedText(expWin, InstructText1, 'center', 'center');
[temp inst_onset]=Screen('Flip', expWin);
KbWait([], 3);
Screen('Flip', expWin);
DrawFormattedText(expWin, InstructText2, 'center', 'center');
[temp inst_onset]=Screen('Flip', expWin);
KbWait([], 3);
% draw fixation cross
Screen('DrawTexture', expWin, fixcross);
Screen('Flip', expWin);
Thanks!

Answers (3)

Sean de Wolski
Sean de Wolski on 12 Oct 2012
Just looking at your error message:
error message on this: ??? Undefined function or method 'eq' for input arguments of type 'cell'.
Which of your cells is a cell array of cells? Apparently one of them is, so even when you extract the first cell level, you retrieve a cell. This would worry me that something wierd was going on if it is not your intention.

Christiane
Christiane on 12 Oct 2012
@ Sean de Wolski: seq is my cell array of cells I guess. Don't know why matlab calls the variable 'eq' though.
  1 Comment
Sean de Wolski
Sean de Wolski on 16 Oct 2012
eq is the MATLAB function equals and is what is called when you use == to test equality.

Sign in to comment.


Matt Tearle
Matt Tearle on 16 Oct 2012
I see several problems. Is seq a cell array of strings or a cell array of cells (or something else)? Either way,
respmapping = seq(1:8);
creates a cell array that's equivalent to the first 8 elements of seq. That is, respmapping is also a cell array. Hence
respmapping ==
is never going to work (regardless of the right-hand side).
Also, you can't do
x == y || z
you have to do
x == y || x == z
I'm also not sure what
InstructText2;
is supposed to do. It looks like InstructText2 is a string variable. In which case, this would just display it to the screen, except the semicolon suppresses the display. So it does nothing.
Finally, if seq is a cell array of strings, use strcmp instead of ==. But the fundamental issue is what you're trying to compare the strings to. I really don't understand what
respmapping= seq(1:8);
is supposed to do.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!