How to make fluid biomotion walkers
3 views (last 30 days)
Show older comments
Hi,
I'm new here and I'm not sure if this is the right forum to post this but here goes.
I'm dealing with a code that displays biomotion point light walkers. However, I have a problem with its fluidity. It's not fluid. It makes a brief stop motion before re-starting its cycle. Can anyone help me on this?
Here is the full code:
(Btw, this code is written on Matlab version 7.6.0.324 (R2008a) using PsychToolbox 2.) ------------------------------------------------------------ clear all; clc; rand('state',sum(100*clock)) wptr = 0; %%%%%%%%%%%%%%%%%%%%%%%%%%%%
load walkers56;
vecty=VectLeftY vectx=VectLeftX starty=StartLeftY startx=StartLeftX
[NumFrames, NumDots, NumMovies] = size(vectx); % 20 12 50
%%%%%%%%%%%%%%%%%%%%%%
DotSz = 7; DotColor = 0; bkgdColor = 127; stimRect = [0 0 1440 900];
FrameX = 158; FrameY = 275; ShiftRad = 30;
NumCycles = 1 StimPerBlock = 4
ifi =120;
%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%% screen('CloseAll')
[w, wRect] = screen(wptr,'OpenWindow', bkgdColor,[],32);
screen(w, 'FillRect', bkgdColor, wRect);
[ctrx, ctry] = RectCenter(stimRect); ctrShiftX = ctrx-FrameX/2; ctrShiftY = ctry-FrameY/2;
fixRect = [0 0 11 11]; fixpt = screen(w, 'OpenOffscreenWindow', bkgdColor, fixRect); screen(fixpt, 'DrawLine', 0, 0, 5, 10, 5); screen(fixpt, 'DrawLine', 0, 5, 0, 5, 10);
for frame = 1:NumFrames stimpt(frame) = screen(w, 'OpenOffscreenWindow', bkgdColor, stimRect); screen('CopyWindow', fixpt, stimpt(frame), fixRect, CenterRect(fixRect, stimRect)); end %for frame
%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%
start = GetSecs;
screen(w, 'FillRect', bkgdColor, wRect); HideCursor; screen('CopyWindow', fixpt, w, fixRect, CenterRect(fixRect, wRect));
posx = startx(1, :, pick)+900; posy = starty(1, :, pick)+320;
posxRight = StartRightX(1, :, pick); posyRight = StartRightY(1, :, pick);
%elseif StimType == 0 & (samediff ==0 | stim == 1)
posx2 = posxRight+1000; posy2 = posyRight+320;
posx3 = posx+200;
posy3 = posy;
for cycle = 1:NumCycles*2 for stim = 1:StimPerBlock trialStart = GetSecs;
% if (samediff ==0 | stim == 1), pick = 1
end
for frame = 1:NumFrames for dot= 1:NumDots
left = posx2(dot) + VectRightX(frame, dot, pick); top = posy2(dot) + VectRightY(frame, dot, pick);
left2=posx3(dot) + vectx(frame, dot, pick);
top2=posy3(dot) + vecty(frame, dot, pick);
left1=posx(dot) + vectx(frame, dot, pick);
top1=posy(dot) + vecty(frame, dot, pick);
screen(stimpt(frame),'FillOval',DotColor, [left1 top1 left1+DotSz top1+DotSz]); screen(stimpt(frame),'FillOval',DotColor, [left2 top2 left2+DotSz top2+DotSz]); screen(stimpt(frame),'FillOval',DotColor, [left top left+DotSz top+DotSz]); end %for dot end %for frame
for frame = 1:NumFrames screen(w,'WaitVBL', 1); screen(w,'WaitVBL', ifi); screen('CopyWindow',stimpt(frame),w,stimRect,CenterRect(stimRect, wRect)); screen(stimpt(frame), 'FillRect', bkgdColor, stimRect); screen('CopyWindow', fixpt, stimpt(frame), fixRect, CenterRect(fixRect, stimRect));
end %for frame & biomotion
% end %for stim end %for cycle
ended_session=GetSecs; session_dur = ended_session - start
screen(w, 'FillRect', bkgdColor, stimRect); screen('CopyWindow', fixpt, w, fixRect, CenterRect(fixRect, wRect));
%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%
for frame = 1:NumFrames screen(stimpt(frame), 'Close') end
screen('CloseAll') % clear -----------------------------------------------------------------------
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!