Hello Everyone,
I am new to using Psychtoolbox and haven't figured out a lot. I figured out how to make a moving dots stimulus with a single set of dots, but what I would like to do is have 2 sets moving in separate directions. I.e. red dot set moving left, green dot set moving diagonal, etc., I can figure out how to generate the second set of dots, but I'm not sure how to get the Screen function to display both simultaneously. Could someone please help and let me know how to append it to my code.
I am on Windows 10
And here is the section of code I am using to generate my display screen:
goodDots = (dots.x-dots.center(1)).^2/(dots.apertureSize(1)/2)^2 + ...
(dots.y-dots.center(2)).^2/(dots.apertureSize(2)/2)^2 < 1;
goodDots2 = (dots.x2-dots.center2(1)).^2/(dots.apertureSize2(1)/2)^2 + ...
(dots.y-dots.center2(2)).^2/(dots.apertureSize2(2)/2)^2 < 1;
%convert from degrees to screen pixels
pixpos.x = angle2pix(display,dots.x)+ display.resolution(1)/2;
pixpos.y = angle2pix(display,dots.y)+ display.resolution(2)/2;
pixpos.x2 = angle2pix(display,dots.x)+ display.resolution(1)/2;
pixpos.y2 = angle2pix(display,dots.y)+ display.resolution(2)/2;
Screen('DrawDots',display.windowPtr,[pixpos.x;pixpos.y], dots.size, dots.color,[0,0],1);
%^-- displays the first set of dots, but need the 2nd group (pixpos.x2, pixpos.y2) displayed simultaneously
%update the dot position
dots.x = dots.x + dx;
dots.y = dots.y + dy;
dots.x2 = dots.x2 + dx2;
dots.y2 = dots.y2 + dy2;
%move the dots that are outside the aperture back one aperture
%width.
dots.x(dots.x<l) = dots.x(dots.x<l) + dots.apertureSize(1);
dots.x(dots.x>r) = dots.x(dots.x>r) - dots.apertureSize(1);
dots.y(dots.y<b) = dots.y(dots.y<b) + dots.apertureSize(2);
dots.y(dots.y>t) = dots.y(dots.y>t) - dots.apertureSize(2);
dots.x2(dots.x<l) = dots.x2(dots.x<l) + dots.apertureSize2(1);
dots.x2(dots.x>r) = dots.x2(dots.x>r) - dots.apertureSize2(1);
dots.y2(dots.y<b) = dots.y2(dots.y<b) + dots.apertureSize2(2);
dots.y2(dots.y>t) = dots.y2(dots.y>t) - dots.apertureSize2(2);
%increment the 'life' of each dot
dots.life = dots.life+1;
%find the 'dead' dots
deadDots = mod(dots.life,dots.lifetime)==0;
%replace the positions of the dead dots to a random location
dots.x(deadDots) = (rand(1,sum(deadDots))-.5)*dots.apertureSize(1) + dots.center(1);
dots.y(deadDots) = (rand(1,sum(deadDots))-.5)*dots.apertureSize(2) + dots.center(2);
dots.x2(deadDots) = (rand(1,sum(deadDots))-.5)*dots.apertureSize2(1) + dots.center2(1);
dots.y2(deadDots) = (rand(1,sum(deadDots))-.5)*dots.apertureSize2(2) + dots.center2(2);
Screen('Flip',display.windowPtr);
I am new to using Psychtoolbox and haven't figured out a lot. I figured out how to make a moving dots stimulus with a single set of dots, but what I would like to do is have 2 sets moving in separate directions. I.e. red dot set moving left, green dot set moving diagonal, etc., I can figure out how to generate the second set of dots, but I'm not sure how to get the Screen function to display both simultaneously. Could someone please help and let me know how to append it to my code.
I am on Windows 10
And here is the section of code I am using to generate my display screen:
goodDots = (dots.x-dots.center(1)).^2/(dots.apertureSize(1)/2)^2 + ...
(dots.y-dots.center(2)).^2/(dots.apertureSize(2)/2)^2 < 1;
goodDots2 = (dots.x2-dots.center2(1)).^2/(dots.apertureSize2(1)/2)^2 + ...
(dots.y-dots.center2(2)).^2/(dots.apertureSize2(2)/2)^2 < 1;
%convert from degrees to screen pixels
pixpos.x = angle2pix(display,dots.x)+ display.resolution(1)/2;
pixpos.y = angle2pix(display,dots.y)+ display.resolution(2)/2;
pixpos.x2 = angle2pix(display,dots.x)+ display.resolution(1)/2;
pixpos.y2 = angle2pix(display,dots.y)+ display.resolution(2)/2;
Screen('DrawDots',display.windowPtr,[pixpos.x;pixpos.y], dots.size, dots.color,[0,0],1);
%^-- displays the first set of dots, but need the 2nd group (pixpos.x2, pixpos.y2) displayed simultaneously
%update the dot position
dots.x = dots.x + dx;
dots.y = dots.y + dy;
dots.x2 = dots.x2 + dx2;
dots.y2 = dots.y2 + dy2;
%move the dots that are outside the aperture back one aperture
%width.
dots.x(dots.x<l) = dots.x(dots.x<l) + dots.apertureSize(1);
dots.x(dots.x>r) = dots.x(dots.x>r) - dots.apertureSize(1);
dots.y(dots.y<b) = dots.y(dots.y<b) + dots.apertureSize(2);
dots.y(dots.y>t) = dots.y(dots.y>t) - dots.apertureSize(2);
dots.x2(dots.x<l) = dots.x2(dots.x<l) + dots.apertureSize2(1);
dots.x2(dots.x>r) = dots.x2(dots.x>r) - dots.apertureSize2(1);
dots.y2(dots.y<b) = dots.y2(dots.y<b) + dots.apertureSize2(2);
dots.y2(dots.y>t) = dots.y2(dots.y>t) - dots.apertureSize2(2);
%increment the 'life' of each dot
dots.life = dots.life+1;
%find the 'dead' dots
deadDots = mod(dots.life,dots.lifetime)==0;
%replace the positions of the dead dots to a random location
dots.x(deadDots) = (rand(1,sum(deadDots))-.5)*dots.apertureSize(1) + dots.center(1);
dots.y(deadDots) = (rand(1,sum(deadDots))-.5)*dots.apertureSize(2) + dots.center(2);
dots.x2(deadDots) = (rand(1,sum(deadDots))-.5)*dots.apertureSize2(1) + dots.center2(1);
dots.y2(deadDots) = (rand(1,sum(deadDots))-.5)*dots.apertureSize2(2) + dots.center2(2);
Screen('Flip',display.windowPtr);
Thank you in advance.