After KbCheck, continue to read the list during 800-1500 msec

Hello,

Here there is a part of my script. I want that after participants push the keyboard, the script continue to read the external list (items) during 800 - 1500 msec (random).

I have try this possibility :

items=textread('HorlogeAlea.txt', '%s');
nItems=length(items); % spécifie la longueur de la liste
tex=zeros(1,nItems);%Textures

Order=randi(length(items)):length(items) % premier stimulus aléatoire, puis suite de la liste

for i=Order
img=imread(items{i});
tex(i)=Screen('MakeTexture', w, img); %Faire les textures
end

cycleRefresh=Screen('GetFlipInterval', w); %Spécifie le cyclerefresh
vbl=Screen(w, 'Flip');

start=GetSecs

for i=Order
Screen('drawtexture', w, tex(i))
vbl=Screen(w, 'Flip', vbl+(2.5*cycleRefresh));
KbCheck;
if KbCheck
while GetSecs-start < 2
GetSecs
[KeyisDown, secs, keyCode, detlaSecs]=KbCheck
if strcmp(KbName(keyCode), 'm')==1
stop=GetSecs
break;
end
end
end
end

The script runs, but without what I ask (certainly, it's not the good way).

Secondly, if I want that Matlab choses between a lot a values from 800 to 1500 msec, do I create a list of value (e.g. timing), and specify GetSecs-start < timing?

Thank you very much,

Emilie
No needs finally -->
That command functions :

Timing = [1,2,3];
TimingAlea=randi(3);
Bla=Timing(TimingAlea)

j = i;
start = GetSecs;
while GetSecs-start < Bla
GetSecs
j = j+1;
img=imread(stimuli{j});
texstim(j)=Screen('MakeTexture', w, img); %Faire les textures
Screen('drawtexture', w, texstim(j)) % Fait apparaitre les textures crées
vbl=Screen(w, 'Flip', vbl+(2.5*cycleRefresh));
end

If that can help somebody, I post it here.

-Emilie


--- In psychtoolbox@yahoogroups.com, "emiliecaspar" <emiliecaspar@...> wrote:
>
> Hello,
>
> Here there is a part of my script. I want that after participants push the keyboard, the script continue to read the external list (items) during 800 - 1500 msec (random).
>
> I have try this possibility :
>
> items=textread('HorlogeAlea.txt', '%s');
> nItems=length(items); % spécifie la longueur de la liste
> tex=zeros(1,nItems);%Textures
>
> Order=randi(length(items)):length(items) % premier stimulus aléatoire, puis suite de la liste
>
> for i=Order
> img=imread(items{i});
> tex(i)=Screen('MakeTexture', w, img); %Faire les textures
> end
>
> cycleRefresh=Screen('GetFlipInterval', w); %Spécifie le cyclerefresh
> vbl=Screen(w, 'Flip');
>
> start=GetSecs
>
> for i=Order
> Screen('drawtexture', w, tex(i))
> vbl=Screen(w, 'Flip', vbl+(2.5*cycleRefresh));
> KbCheck;
> if KbCheck
> while GetSecs-start < 2
> GetSecs
> [KeyisDown, secs, keyCode, detlaSecs]=KbCheck
> if strcmp(KbName(keyCode), 'm')==1
> stop=GetSecs
> break;
> end
> end
> end
> end
>
> The script runs, but without what I ask (certainly, it's not the good way).
>
> Secondly, if I want that Matlab choses between a lot a values from 800 to 1500 msec, do I create a list of value (e.g. timing), and specify GetSecs-start < timing?
>
> Thank you very much,
>
> Emilie
>