function HolidaySnap1();
% HolidaySnap1();
%
% Example of displaying an image.
%
% This script
% - reads an image from a file
% - then shows the image

%%%%%%%%%%%%%%%%%%%%%%%%%
% preliminary stuff
%%%%%%%%%%%%%%%%%%%%%%%%%

% Clear Matlab/Octave window:
clc;

%%%%%%%%%%%%%%%%%%%%%%
% file handling
%%%%%%%%%%%%%%%%%%%%%%

% read stimulus image into matlab matrix 'imdata':
imdata=imread('HolidaySnap1.jpg');

%%%%%%%%%%%%%%%%%%%%%%
% image display
%%%%%%%%%%%%%%%%%%%%%%

% Embed core of code in try ... catch statement. If anything goes wrong
% inside the 'try' block (Matlab error), the 'catch' block is executed to
% clean up, save results, close the onscreen window etc.
try
    % Get screenNumber of stimulation display. We choose the display with
    % the maximum index, which is usually the right one, e.g., the external
    % display on a Laptop:
    screens=Screen('Screens');
    screenNumber=max(screens);
    
    
    % Returns as default the mean gray value of screen:
    gray=GrayIndex(screenNumber); 

    % Open a double buffered fullscreen window on the stimulation screen
    % 'screenNumber' and choose/draw a gray background. 'w' is the handle
    % used to direct all drawing commands to that window - the "Name" of
    % the window. 'wRect' is a rectangle defining the size of the window.
    % See "help PsychRects" for help on such rectangles and useful helper
    % functions:
    [w, wRect]=Screen('OpenWindow',screenNumber, gray);
            
    % Wait for mouse click:
    GetClicks(w);
                
    % Clear screen to background color (our 'gray' as set at the
    % beginning):
    Screen('Flip', w);
        
    % Wait a second before starting trial
    WaitSecs(1.0);                    
                    
    % make texture image out of image matrix 'imdata'
    tex=Screen('MakeTexture', w, imdata);
            
    % Draw texture image to backbuffer. It will be automatically
    % centered in the middle of the display if you don't specify a
    % different destination:
    Screen('DrawTexture', w, tex);
 
    % Show stimulus on screen at next possible display refresh cycle,
    % and record stimulus onset time in 'startrt':
    [VBLTimestamp startrt]=Screen('Flip', w);
            
    % Wait 10 s 
    WaitSecs(10);
   
    % Clear screen to background color 
    Screen('Flip', w);          
   
    % Cleanup - Close window, close files
    % switch Matlab/Octave back to priority 0 -- normal priority:
    Screen('CloseAll');
    fclose('all');
    
    % End of main prg:
    return;
catch
    % catch error: This is executed in case something goes wrong in the
    % 'try' part due to programming error etc.:
    
    % Do same cleanup as at the end of a regular session...
    Screen('CloseAll');
    fclose('all');
    
    % Output the error message that describes the error:
    psychrethrow(psychlasterror);
end % try ... catch ... end %