function [Resp, RT] = showInstruction(slidenum,PTBParams,varargin)
slide_prefix = 'Slide';
slide_type = 'PNG';
required_keys = {};
if nargin > 1
options_used = varargin(1:2:end);
option_specification = varargin(2:2:end);
for i = 1:length(options_used)
switch options_used{i}
case 'SlidePrefix'
slide_prefix = option_specification{i};
case 'SlideType'
slide_type = option_specification{i};
case 'SlidePath'
homepath = option_specification{i};
case 'RequiredKeys'
required_keys = option_specification{i};
end
end
end
InsrxScreen = imread([PTBParams.homepath 'Instructions/' slide_prefix ...
sprintf('%02.0f',slidenum) '.' lower(slide_type)], slide_type);
textureIndex=Screen('MakeTexture',PTBParams.win,InsrxScreen);
imageDims = size(InsrxScreen);
minResizeFactor = min([PTBParams.rect(4)/imageDims(1),PTBParams.rect(3)/...
imageDims(2)]);
xOffset = floor((PTBParams.rect(3) - imageDims(2) * minResizeFactor)/2);
yOffset = floor((PTBParams.rect(4) - imageDims(1) * minResizeFactor)/2);
destRect = [xOffset, ...
yOffset, ...
xOffset + imageDims(2) * minResizeFactor,...
yOffset + imageDims(1) * minResizeFactor];
Screen('DrawTexture',PTBParams.win,textureIndex,[],destRect);
Screen(PTBParams.win,'Flip');
Screen('Close',textureIndex);
[Resp, RT] = collectResponse([],[],required_keys);