Error in 'DrawTexture'
Show older comments
Hi everybody,
I'm quite new to the whole matlab experience and I'm hoping someone can help me out with this.
I'm using a script to convert images to texture/mat files, that has worked before. But when put it in my main script and run it, I get the following error, anybody out there who can help =)?
Thank you so much!
Error in function DrawTexture: Missing argument
Discrepancy between a specified and supplied argument:
Specified Argument Description:
direction: Input
position: 2
presence:forbidden
formats allowed:
double
minimum M: 1
maximum M: 1
minimum N: 1
maximum N: 1
minimum P: 1
maximum P: 1
Provided Argument Description:
direction: Input
position: 2
presence: absent
Error using Screen
Usage:
Screen('DrawTexture', windowPointer, texturePointer [,sourceRect] [,destinationRect] [,rotationAngle] [, filterMode]
[, globalAlpha] [, modulateColor] [, textureShader] [, specialFlags] [, auxParameters]);
Error in encoding_2 (line 219)
Screen('DrawTexture', win, tex(trial_order(trial+1))); %uses loadJPG_as_Texture.m
13 Comments
Walter Roberson
on 6 Sep 2019
I suspect that your win variable is empty
However this is a question about details of psychtoolbox involving things not present in MATLAB itself.
Alix
on 6 Sep 2019
Walter Roberson
on 6 Sep 2019
Are you sure that tex() is returning a texturepointer ? tex() normally returns 1 if it is passed a character vector that is valid latex commands, and returns [] if it is passed anything else (including a character vector that is not valid latex)
Alix
on 7 Sep 2019
Guillaume
on 7 Sep 2019
I didn't know where else to ask this.
Alix
on 7 Sep 2019
Guillaume
on 7 Sep 2019
There's no problem posting your question here and I certainly did not mean to discourage you from doing so. It's just that I don't think that many of us regulars here know much about the toolbox (I've never used it). Walter may be the only one who knows something about it, so I pointed you to a forum where you may have more chance of getting help.
Walter Roberson
on 7 Sep 2019
I have not had the toolbox installed for a while (or rather I have not booted from that old disk in some time.) If you posted the source we would have more chance. At the moment my suspicion is that you have a scope problem and that tex is not what you think it is.
Alix
on 8 Sep 2019
Walter Roberson
on 8 Sep 2019
theDir = [pwd filesep]; % Returns directory where the script is located (pwd = directory where script is in, filesep = slash that corresponds to your computer system) % cd = theDir
dirStim = [theDir 'stim_encoding' filesep]; % folder with stimuli;
% use filesep instead of / for uniformity
% Filename of outputfile
outputfile = [theDir 'DATA' filesep 'PS_Encoding_S' num2str(subjID) '.mat'];
It is recommended that you use fullfile() instead of constructing paths with filesep yourself.
Guillaume
on 8 Sep 2019
None of this is going to help with your error but as Walter said, using fullfile would greatly simplify the start of your code:
dirstim = fullfile(pwd, 'stim_encoding');
outputfile = fullfile(pwd, 'DATA', sprintf('PS_Encoding_S%d.mat'), subjID);
There's also plenty wrong with this block:
%% Make the output list
trialList.SubjID(:,1) = repmat(subjID, 1, p.stimN); %C1: SubjId to be repeated in 1 row for amount of p.stimN
trialList.runNr(:,2) = repmat(runNr, 1, p.stimN); % C2: run Number
trialList.trialNum(:,3) = repmat(1:p.stimN, 1); % C3: write out 1 through last trial Number (1-148)
trialList.trialOrder(:,4) = repmat(trial_order, 1)'; %C4: stim num/order of trials random
% empty counters to be filled in as we move through loop:
trialList.stimOnset(:,5) = zeros(p.stimN, 1); %C5: stim onset
trialList.stimType(:,6) = zeros(p.stimN, 1); %C6: cathegory response/Stimtype
%trialList(:,7) =
trialList.idealOnset(:,8) = p.prePost:p.trialDur:(p.stimN*p.trialDur)+(p.prePost-p.trialDur); %C8: ideal onset
%trialList(:,9)
trialList.RT(:,10) = zeros(p.stimN, 1); %C10: RT
The first line assign to the first column of subjID, the 2nd line to the 2nd column of a completely different variable runNr. The first column of runNr will be filled with 0s and never be used. And so on, RT will have 10 columns, the first 9 filled with 0s and never used.
The repmat are also a bit confusing, the ones that do something create row vectors which are then assigned to column vectors, a bit sloppy, and others are just repmat(x, 1) which are pointless, you just get x. This would be a lot better:
trialList.SubjID = repmat(subjID, p.stimN, 1); %C1: SubjId to be repeated in 1 row for amount of p.stimN
trialList.runNr = repmat(runNr, p.stimN, 1); % C2: run Number
trialList.trialNum = (1:p.stimN)'; % C3: write out 1 through last trial Number (1-148)
trialList.trialOrder = trial_order(:); %C4: stim num/order of trials random
% empty counters to be filled in as we move through loop:
trialList.stimOnset = zeros(p.stimN, 1); %C5: stim onset
trialList.stimType = zeros(p.stimN, 1); %C6: cathegory response/Stimtype
trialList.idealOnset = (0:p.stimN-1)' * p.trialDur + p.prePost; %A simpler way to create your vector
trialList.RT = zeros(p.stimN, 1); %C10: RT
and of course, later when you use the variables, you don't bother with the column index, eg.
timeDif = abs(trialList.stimOnset(trial) - trialList.idealOnset(trial)) %absolute difference between real and ideal onset
Alix
on 8 Sep 2019
Guillaume
on 9 Sep 2019
As it may be helpful for others to know what the solution was, could you post it as an answer and then accept your own answer?
Accepted Answer
More Answers (0)
Categories
Find more on Timing and presenting 2D and 3D stimuli in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!