Error using Screen- DrawDots

7 次查看(过去 30 天)
Irmak
Irmak 2023-10-23
回答: hailing 2023-10-28
Hello, when I try to run the PychToolBox experiment code below (on MATLAB R2023b), I receive the following error:
Error using Screen
Usage:
[minSmoothPointSize, maxSmoothPointSize, minAliasedPointSize, maxAliasedPointSize] = Screen('DrawDots', windowPtr,
xy [,size] [,color] [,center] [,dot_type][, lenient]);
Error in spaital_temporal (line 153)
Screen('DrawDots', wptr, TargetLocGrid, TargetSize, [255 255 255], []);
I can't figure out what I do wrong. Can anyone help me out with it?
% clean start:)
clear all
close all
clc
%% SpatioTemporal Replication proejct
KbName('UnifyKeyNames'); % keyboard
Experimenter = -3;
Participant = -3;
Scanner = -3;
%% Subject information
subName = input('Subject Initials: ', 's');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% directory setting
genDir = '/Users/irmakergin/Desktop/yeshurun2003_rescue/data';
functions = '/Users/irmakergin/Desktop/yeshurun2003_rescue/data/_FUNC';
cd(functions)
%addpath(genpath(fullfile(genDir,'_FUNC')));
dataDir = fullfile(genDir,'_DATA','behavior',subName);
if ~exist(dataDir) && ~strcmp(subName,'tes'), mkdir(dataDir); end
datas = getAllFiles(dataDir,'*.mat',1); %function didn't work
runN=length(datas)+1;
dataName = fullfile(dataDir,sprintf('exp1_%s_%d',subName,length(datas)+1));
%% screen setting
bdgcol = 128;
Screen('Preference', 'SkipSyncTests', 1);
ScreenNum = max(Screen('Screens'));
[wptr,rect]=Screen('OpenWindow',ScreenNum,[0 0 0]);
Screen('BlendFunction', wptr, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
% Screen('HideCursorHelper', wptr);
[cx, cy] = RectCenter(rect);
ifi = 1/85;
Screen('TextSize',wptr, 40);
% Screen('HideCursorHelper', wptr);
[cx, cy] = RectCenter(rect);
ifi = 1/85;
Screen('TextSize',wptr, 40);
%% experiment matrix design
fixaSz = 5;
totalTrial=864;
cond=[0,1]; % 1: cued 0: uncued
loc=[1:6];
type=[1,2]; % 1: single disk, 2: two disks
ISI_base=[1,2,3];
iteration=3; % this should be 12
[cueing,tarType,tarLoc,ISI]= ...
BalanceFactors(iteration,1,cond,type,loc,ISI_base);
trialNum=1:length(cueing);
emat=[cueing,tarType,tarLoc,ISI];
if ~strcmp(subName,'tes'),save(dataName,'emat');end
%% experiment loop
Screen('DrawText',wptr,'start',cx/1.1,cy,[255 255 255]);
Screen('Flip',wptr);
scanPulse = 0;
while scanPulse ~= 1
[keyIsDown, ~, keyCode] = KbCheck(Participant);
% [keyIsDown, ~, keyCode] = PsychHID('KbCheck');
if keyIsDown
if keyCode(KbName('s'))
scanPulse = 1;
break;
end
end
WaitSecs(0.005);
end
TargetSize=deg2pixel(3);
% penWidth=round(deg2pixel(0.3));
penWidth=6;
% 0 3 6 9 13 16
ecc_vars=[0,deg2pixel(3), deg2pixel(6),deg2pixel(9),deg2pixel(13),deg2pixel(16)];
signSelect=[-1,1];
response=[];
%Time in frames
SOA=round(0.094/ifi);
fixLen=round(1/ifi);
allList=[];
for tr=1:length(emat)
%cueing,tarType,tarLoc,ISI
emat(tr,:)
tList=[9 10 11]; tLength1=tList(randperm(3,1));
tISI_list=[1,2,3]; tISI=tISI_list(emat(tr,4));
tLength2=4;
TargetLocGrid=[cx+(ecc_vars(emat(tr,3))*signSelect(round(rand)+1)), cy];
TargetLocGrid=round(TargetLocGrid);
%fixation
for iter = 1:fixLen
Screen('FillOval',wptr,255*[0,0,1],[cx-fixaSz,cy-fixaSz,cx+fixaSz,cy+fixaSz]);
Screen('Flip',wptr);
end
% cue
if emat(tr,1) ==1
for iter = 1:fixLen
Screen('DrawLine', wptr,255*[0,1,0], round(TargetLocGrid(1)-deg2pixel(1)),...
round(cy-deg2pixel(0.5)-TargetSize/2), round(TargetLocGrid(1)+deg2pixel(1)), round(cy-deg2pixel(0.5)-TargetSize/2), penWidth);
Screen('Flip',wptr);
end
else
for iter = 1:fixLen
Screen('DrawLine', wptr,255*[0,1,0], ...
cx-(rect(3)/2),...
round(cy-deg2pixel(0.5)-TargetSize/2), ...
cx+(rect(3)/2),...
round(cy-deg2pixel(0.5)-TargetSize/2),...
penWidth);
Screen('DrawLine', wptr,255*[0,1,0], ...
cx-(rect(3)/2),...
round(cy+deg2pixel(0.5)+TargetSize/2),...
cx+(rect(3)/2), ...
round(cy+deg2pixel(0.5)+TargetSize/2),...
penWidth);
Screen('Flip',wptr);
end
end
% SOA
for iter = 1:SOA % 94 ms
% Screen('FillOval',wptr,255*[0,0,1],[cx-fixaSz,cy-fixaSz,cx+fixaSz,cy+fixaSz]);
Screen('Flip',wptr);
end
Screen('Flip',wptr);
% Target
%
% tLength1=100;
% tLength2=100;
if emat(tr,2) ==1
for iter = 1:tLength1
Screen('DrawDots', wptr, TargetLocGrid, TargetSize, [255 255 255], [], 2);
% Screen('DrawDots', wptr, [dotXpos dotYpos], dotSizePix, dotColor, [], 2);
Screen('Flip',wptr);
end
elseif emat(tr,2)==2
for on=1:tLength2
Screen('DrawDots', wptr, TargetLocGrid, TargetSize, [255 255 255], [], 2);
Screen('Flip',wptr);
end
for gap=1:tISI
Screen('FillRect', wptr, [0 0 0]);
Screen('Flip',wptr);
end
for off=1:tLength2
Screen('DrawDots', wptr, TargetLocGrid, TargetSize, [255 255 255], [], 2);
Screen('Flip',wptr);
end
end
Screen('Flip',wptr);
% RT_S=GetSecs;
scanPulse = 0;
while scanPulse ~= 1
response(tr,1)=9; t1=GetSecs;
[keyIsDown, ~, keyCode] = KbCheck(Participant);
% [keyIsDown, ~, keyCode] = PsychHID('KbCheck');
if keyIsDown
if keyCode(KbName('1!'))
response(tr,1) = 1;
response(tr,2)=GetSecs-t1 ;
break;
end
if keyCode(KbName('2@'))
response(tr,1) = 2;
response(tr,2)=GetSecs-t1 ;
break;
end
end
end
RT_E=GetSecs;
% RTs=RT_E-RT_S;
allList=[allList; tr emat(tr,:) response(tr,:)];
save(dataName,'emat','response','allList');
end
%put accuracy
allList(:,end+1)= allList(:,3) == allList(:,6)
WaitSecs(1);
sca;

回答(2 个)

Walter Roberson
Walter Roberson 2023-10-23
TargetLocGrid=[cx+(ecc_vars(emat(tr,3))*signSelect(round(rand)+1)), cy];
Notice that uses [A,B] . Unless something in the one of the two expressions is an empty variable, the result is going to be multiple columns with the y in the second column
[cx, cy] = RectCenter(rect);
so cy is a scalar. And since you cannot [A,B] together a column vector with more than one row and a scalar, in order for TargetLocGrid not to have produced a computation error, the variable must now be a 1 x N vector, probably 1 x 2
Screen('DrawDots', wptr, TargetLocGrid, TargetSize, [255 255 255], [], 2);
And the variable is passed in the xy slot.
xyis a two-row vector containing the x and y
coordinates of the dot centers, relative to “center” (default center is [0 0]).
So xy must have two rows. But your TargetLocGrid only has one row.
The semantics is that the xy should have a row of x coordinates of pixel centers and a row of y coordinates of pixel centers, and that TargetSize should be a vector of corresponding dot sizes. If you are only drawing one pixel then that would mean that the xy should be a 2 x 1 column vector, not a 1 x 2 row vector.
  3 个评论
Walter Roberson
Walter Roberson 2023-10-23
TargetLocGrid=[cx+(ecc_vars(emat(tr,3))*signSelect(round(rand)+1)); cy];
Just change the comma to semi-colon.
Irmak
Irmak 2023-10-23
编辑:Irmak 2023-10-23
Thank you! I already tried that after seeing your comment but it didn’t work, I am still having the same error

请先登录,再进行评论。


hailing
hailing 2023-10-28
I received the same error today. I changed the number 2 into 3, and it just went well again. Maybe you can try this:
Screen('DrawDots', wptr, TargetLocGrid, TargetSize, [255 255 255], [], 3);

类别

Help CenterFile Exchange 中查找有关 Timing and presenting 2D and 3D stimuli 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by