hello!
First say thanks to Frans for his help, now I can measure Reaction Times!
Said that, I am in troubles now. I want to show a circle moving left
to right, then rebounds and goes back to its initial position. This
cercle can change its colour in a 3 (or 2) different conditions:
before the rebound, after the rebound and whitout colour change
(control condition), so the 3rd isn't a real colour change always is
red in this case.
Subjects are supposed to answer as fast as they can to the rebound
(Reaction Time).
Well, I want to show these conditions randomly, and these condition
trials should appear the same quantity of times; because random
(unless I put thousands of trials) will show more trials for one
condition against another.
Also, I want to put randomly the rebound place, for each trial in each
condition.
Another thing that I am interested is that when I run the script
below, It runs but in a slowly way and interrupted.
I copy my script below. Just say that I've been working from an
another script, for this reason probably there are some words and
variables that doesn't matter.
(I'am working on Windows xp; Pentium 4; 512 MB RAM)
nombre=input('Nombre: ','s');
waitSecs(1); % Give display a moment to recover from the change of
pixelSize
%-------------DEFINICIONES----------------------------------------------
ancho_rec=1024;
alto_rec=400;
pixelSize=16;
noframes=151;
trials=30;
rect=[0 0 ancho_rec alto_rec];
rect2 = CenterRect(rect,windowRect);
rect2(2)=rect2(2)-150;
rect2(4)=rect2(4)-150;
black=BlackIndex(window);
white=WhiteIndex(window);
gray=(black+white)/2;
salto=(ancho_rec+(80))/noframes;
ofset=round(80/(2*salto));
rojo=[255 0 0];
negro=[0 0 0];
verde=[0 255 0];
xx= 80 %rebound
zz= 50 %color change
yy= 100 %return color change
[window,windowRect]=Screen(0,'OpenWindow',[0],[],pixelSize);
%------------ FRAMES BASE -----------------------------------------
ww=SCREEN(window,'OpenOffscreenWindow',[0],rect);
HideCursor;
for t=1:100 % start loop)
c=fix(rand*3)+1
%color change before rebound
if c == 1
for i=1:noframes %i serĂ¡ desde 1 hasta (:) el total numero de frames
w(i)=SCREEN(window,'OpenOffscreenWindow',[0],rect);
if i<=zz
SCREEN(w(i),'FrameOval',verde,[(i-ofset)*salto-40 160
(i-ofset)*salto+40 240],[50]);
elseif i<=xx
SCREEN(w(i),'FrameOval',rojo,[(i-ofset)*salto-40 160
(i-ofset)*salto+40 240],[50]);
elseif i>xx
SCREEN(w(i),'FrameOval',rojo,[(2*xx-i-ofset)*salto-40 160
(2*xx-i-ofset)*salto+40 240],[50]);
end
end
%without color change
elseif c == 2
for i=1:noframes %i serĂ¡ desde 1 hasta (:) el total numero de frames
w(i)=SCREEN(window,'OpenOffscreenWindow',[0],rect);
if i<=zz
SCREEN(w(i),'FrameOval',rojo,[(i-ofset)*salto-40 160
(i-ofset)*salto+40 240],[50]);
elseif i<=xx
SCREEN(w(i),'FrameOval',rojo,[(i-ofset)*salto-40 160
(i-ofset)*salto+40 240],[50]);
elseif i>xx
SCREEN(w(i),'FrameOval',rojo,[(2*xx-i-ofset)*salto-40 160
(2*xx-i-ofset)*salto+40 240],[50]);
end
end
%color change after rebound
elseif c == 3
for i=1:noframes
w(i)=SCREEN(window,'OpenOffscreenWindow',[0],rect);
if i<=xx
SCREEN(w(i),'FrameOval',verde,[(i-ofset)*salto-40 160
(i-ofset)*salto+40 240],[50]);
elseif i<=yy
SCREEN(w(i),'FrameOval',verde,[(2*xx-i-ofset)*salto-40 160
(2*xx-i-ofset)*salto+40 240],[50]);
elseif i>xx
SCREEN(w(i),'FrameOval',rojo,[(2*xx-i-ofset)*salto-40 160
(2*xx-i-ofset)*salto+40 240],[50]);
end
end
end
loop={
'for i=[1:xx];'
'Screen(window,''WaitBlanking'');'
'Screen(''CopyWindow'',w(i),window, rect,rect2);'
'end;'
};
priorityLevel=MaxPriority(0,'WaitBlanking','KbCheck');
i=0;Screen('Screens'); % Make sure all Rushed variables and functions
are in memory.
Rush(loop,priorityLevel);
st= GetSecs;
loop={
'for i=[xx+1:ceil(noframes)];'
'Screen(window,''WaitBlanking'');'
'[keyIsDown,secs,keyCode] = KbCheck;'
'if keyIsDown ==1;'
'j=[(secs-st)*1000];'
'end;'
'Screen(''CopyWindow'',w(i),window, rect,rect2);'
'end;'
};
priorityLevel=MaxPriority(0,'WaitBlanking','KbCheck');
i=0;Screen('Screens'); % Make sure all Rushed variables and functions
are in memory.
Rush(loop,priorityLevel);
j
fprintf( 'RT: %.1f ms.\n', j);
ch=getchar;
if ch == 'h'
break
end
sound(.5*sin([1:.2:30]*5));
pause(.75)
vec1(100)=ch;
%save data in a txt
end
fid = fopen('RTdatap.txt','w');
fprintf(fid,'%f\t%f\n',j);
fclose(fid);
SCREEN('CloseAll');
ShowCursor;
----------
Thank you in advance
Xavier R.
First say thanks to Frans for his help, now I can measure Reaction Times!
Said that, I am in troubles now. I want to show a circle moving left
to right, then rebounds and goes back to its initial position. This
cercle can change its colour in a 3 (or 2) different conditions:
before the rebound, after the rebound and whitout colour change
(control condition), so the 3rd isn't a real colour change always is
red in this case.
Subjects are supposed to answer as fast as they can to the rebound
(Reaction Time).
Well, I want to show these conditions randomly, and these condition
trials should appear the same quantity of times; because random
(unless I put thousands of trials) will show more trials for one
condition against another.
Also, I want to put randomly the rebound place, for each trial in each
condition.
Another thing that I am interested is that when I run the script
below, It runs but in a slowly way and interrupted.
I copy my script below. Just say that I've been working from an
another script, for this reason probably there are some words and
variables that doesn't matter.
(I'am working on Windows xp; Pentium 4; 512 MB RAM)
nombre=input('Nombre: ','s');
waitSecs(1); % Give display a moment to recover from the change of
pixelSize
%-------------DEFINICIONES----------------------------------------------
ancho_rec=1024;
alto_rec=400;
pixelSize=16;
noframes=151;
trials=30;
rect=[0 0 ancho_rec alto_rec];
rect2 = CenterRect(rect,windowRect);
rect2(2)=rect2(2)-150;
rect2(4)=rect2(4)-150;
black=BlackIndex(window);
white=WhiteIndex(window);
gray=(black+white)/2;
salto=(ancho_rec+(80))/noframes;
ofset=round(80/(2*salto));
rojo=[255 0 0];
negro=[0 0 0];
verde=[0 255 0];
xx= 80 %rebound
zz= 50 %color change
yy= 100 %return color change
[window,windowRect]=Screen(0,'OpenWindow',[0],[],pixelSize);
%------------ FRAMES BASE -----------------------------------------
ww=SCREEN(window,'OpenOffscreenWindow',[0],rect);
HideCursor;
for t=1:100 % start loop)
c=fix(rand*3)+1
%color change before rebound
if c == 1
for i=1:noframes %i serĂ¡ desde 1 hasta (:) el total numero de frames
w(i)=SCREEN(window,'OpenOffscreenWindow',[0],rect);
if i<=zz
SCREEN(w(i),'FrameOval',verde,[(i-ofset)*salto-40 160
(i-ofset)*salto+40 240],[50]);
elseif i<=xx
SCREEN(w(i),'FrameOval',rojo,[(i-ofset)*salto-40 160
(i-ofset)*salto+40 240],[50]);
elseif i>xx
SCREEN(w(i),'FrameOval',rojo,[(2*xx-i-ofset)*salto-40 160
(2*xx-i-ofset)*salto+40 240],[50]);
end
end
%without color change
elseif c == 2
for i=1:noframes %i serĂ¡ desde 1 hasta (:) el total numero de frames
w(i)=SCREEN(window,'OpenOffscreenWindow',[0],rect);
if i<=zz
SCREEN(w(i),'FrameOval',rojo,[(i-ofset)*salto-40 160
(i-ofset)*salto+40 240],[50]);
elseif i<=xx
SCREEN(w(i),'FrameOval',rojo,[(i-ofset)*salto-40 160
(i-ofset)*salto+40 240],[50]);
elseif i>xx
SCREEN(w(i),'FrameOval',rojo,[(2*xx-i-ofset)*salto-40 160
(2*xx-i-ofset)*salto+40 240],[50]);
end
end
%color change after rebound
elseif c == 3
for i=1:noframes
w(i)=SCREEN(window,'OpenOffscreenWindow',[0],rect);
if i<=xx
SCREEN(w(i),'FrameOval',verde,[(i-ofset)*salto-40 160
(i-ofset)*salto+40 240],[50]);
elseif i<=yy
SCREEN(w(i),'FrameOval',verde,[(2*xx-i-ofset)*salto-40 160
(2*xx-i-ofset)*salto+40 240],[50]);
elseif i>xx
SCREEN(w(i),'FrameOval',rojo,[(2*xx-i-ofset)*salto-40 160
(2*xx-i-ofset)*salto+40 240],[50]);
end
end
end
loop={
'for i=[1:xx];'
'Screen(window,''WaitBlanking'');'
'Screen(''CopyWindow'',w(i),window, rect,rect2);'
'end;'
};
priorityLevel=MaxPriority(0,'WaitBlanking','KbCheck');
i=0;Screen('Screens'); % Make sure all Rushed variables and functions
are in memory.
Rush(loop,priorityLevel);
st= GetSecs;
loop={
'for i=[xx+1:ceil(noframes)];'
'Screen(window,''WaitBlanking'');'
'[keyIsDown,secs,keyCode] = KbCheck;'
'if keyIsDown ==1;'
'j=[(secs-st)*1000];'
'end;'
'Screen(''CopyWindow'',w(i),window, rect,rect2);'
'end;'
};
priorityLevel=MaxPriority(0,'WaitBlanking','KbCheck');
i=0;Screen('Screens'); % Make sure all Rushed variables and functions
are in memory.
Rush(loop,priorityLevel);
j
fprintf( 'RT: %.1f ms.\n', j);
ch=getchar;
if ch == 'h'
break
end
sound(.5*sin([1:.2:30]*5));
pause(.75)
vec1(100)=ch;
%save data in a txt
end
fid = fopen('RTdatap.txt','w');
fprintf(fid,'%f\t%f\n',j);
fclose(fid);
SCREEN('CloseAll');
ShowCursor;
----------
Thank you in advance
Xavier R.