draw a grating stimulus with multiple orientations through psychtoolbox

I am trying to draw a grating stimulus in psychtoolbox with multiple orientations randomly (in drift demo, am modifying the code). I have the array with the orientations in random order but when i run it, it does it all at once. what functions should i use so that the grating runs runs with multiple orientations with a waiting time of 1 sec in between the orientations.
this is what i have now:
angle= [0,pi/4,pi/2,3*pi/4, pi, 5*pi/4, 3*pi/2, 7*pi/4];
D = rad2deg(angle);
pause('on')
for i=1:numFrames
phase=(i/numFrames)*2*pi;
% grating
[x,y]=meshgrid(-300:300,-300:300);
% angle=30*pi/180; % 30 deg orientation.
msize = numel(angle);
or= D(randperm(msize, 1))
f=0.09*2*pi; % cycles/pixel
a=cos(or)*f;
b=sin(or)*f;
m=exp(-((x/90).^2)-((y/90).^2)).*sin(a(:,1).*x+b(:,1).*y+phase)

 採用された回答

Walter Roberson
Walter Roberson 2017 年 12 月 27 日

0 投票

pause(1)

9 件のコメント

Anwesha
Anwesha 2017 年 12 月 27 日
its not working with the pause command. all the orientations are running at the same time and not one after the other
Walter Roberson
Walter Roberson 2017 年 12 月 27 日
Difficult to say. You have only posted partial code. You are missing an end statement and you are missing the graphics.
Anwesha
Anwesha 2017 年 12 月 28 日
編集済み: Walter Roberson 2017 年 12 月 28 日
i wil have 8 orientations that should run for 2 secs and a blank period of 1sec. I will also have 5 temporal frequencies. but first i want to run 8 different randomised orientations for 2 sec.
function DriftDemo
white=WhiteIndex(screenNumber);
black=BlackIndex(screenNumber);
gray=round((white+black)/2);
if gray == white
gray=white / 2;
end
inc=white-gray;
w=Screen('OpenWindow',screenNumber, gray);
angle= [0,pi/4,pi/2,3*pi/4, pi, 5*pi/4, 3*pi/2, 7*pi/4];
D = rad2deg(angle);
% pause('on')
for i=1:numFrames
phase=(i/numFrames)*2*pi;
% grating
[x,y]=meshgrid(-300:300,-300:300);
% angle=30*pi/180; % 30 deg orientation.
msize = numel(angle);
or= D(randperm(msize, 1));
f=0.09*2*pi; % cycles/pixel
a=cos(or)*f;
b=sin(or)*f;
m=exp(-((x/90).^2)-((y/90).^2)).*sin(a(:,1).*x+b(:,1).*y+phase);
% m=exp(-((x/90).^2)-((y/90).^2)).*sin(a*x+b*y+phase);
tex(i)=Screen('MakeTexture', w, round(gray+inc*m)); %#ok<AGROW>
end
pause(1)
movieDurationSecs=100;
frameRate=Screen('FrameRate',screenNumber);
if frameRate == 0
frameRate=60;
end
movieDurationFrames=round(movieDurationSecs * frameRate);
movieFrameIndices=mod(0:(movieDurationFrames-1), numFrames) + 1;
priorityLevel=MaxPriority(w);
Priority(priorityLevel);
for i=1:movieDurationFrames
% Draw image:
Screen('DrawTexture', w, tex(movieFrameIndices(i)));
Screen('Flip', w);
end
Priority(0);
Screen('Close');
sca;
catch
Priority(0);
psychrethrow(psychlasterror);
end
Walter Roberson
Walter Roberson 2017 年 12 月 28 日
The pause(1) should be before the end on the line above it.
Anwesha
Anwesha 2017 年 12 月 28 日
still not working...its a jumbled up grating with all orientations
Anwesha
Anwesha 2018 年 1 月 4 日
編集済み: Walter Roberson 2018 年 1 月 4 日
i am trying to call with a function and it works.
function RandomizeOrientations
angle= [0,pi/4,pi/2,3*pi/4, pi, 5*pi/4, 3*pi/2, 7*pi/4];
D = rad2deg(angle);
msize = numel(angle);
for i =1:msize
or= D(randperm(msize, 1));
DriftDemo2(or,1,0.05,1,400)
end
now the problem is that before running a different orientation each time the psychtoolbox closes and starts new.
I would like to run the 8 orientations for example 2mins with an interstimulus interval of 2 secs.. how do i go ahead..
end
Anwesha
Anwesha 2018 年 1 月 5 日
any suggestions??
Walter Roberson
Walter Roberson 2018 年 1 月 5 日
Not from me. I recently got a new computer and have not set up Psychtoolbox on it as doing so is a bit of a nuisance to tie into the retrace properly. It is not a program that I use myself, just something I have encountered enough times over the years to sometimes be able to answer minor questions about.
Anwesha
Anwesha 2018 年 1 月 5 日
no issues, thanks though

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

質問済み:

2017 年 12 月 27 日

コメント済み:

2018 年 1 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by