function log = sd_practice_trial(cfg, Gparams)

log = [];
log.cfg = cfg;
log.onsets = [];

% Presentation position
h_pos = cfg.h_location * deg2pix(Gparams.stim.h_eccentricity,Gparams);     

%% Stimulus presentation

% cue mask
% [cue_mask,~] = transparency_mask(...
%    0.7,...
%    Gparams.stim.imSize,...
%    Gparams.bg,...
%    Gparams);

% cue position
% yPos = (Gparams.ScreenResY-1)/2; 
% xPos = (Gparams.ScreenResX - 1)/2 + h_pos;
% [s1, s2, ~] = size(cue_mask);
% baseRect = [0 0 s1 s2];
% dstRect =  CenterRectOnPointd(baseRect, xPos, yPos);

% present cue
Screen('DrawDots', Gparams.pWindow, [(Gparams.ScreenResX - 1)/2, (Gparams.ScreenResY-1)/2], Gparams.FixDotSize, 191, [], 1);
% Screen('FillRect', Gparams.pWindow, 170, dstRect);
% cuemaskTexture = Screen('MakeTexture', Gparams.pWindow, cue_mask);
% Screen('DrawTexture', Gparams.pWindow, cuemaskTexture , [], dstRect);
time = Screen('Flip', Gparams.pWindow);
log.onsets = [log.onsets, time];

% pre-stimulus fixation
% Screen('DrawDots', Gparams.pWindow, [(Gparams.ScreenResX - 1)/2, (Gparams.ScreenResY-1)/2], Gparams.FixDotSize, 255, [], 1);
% time = Screen('Flip', Gparams.pWindow, time + Gparams.timing.cuedur);  
% log.onsets = [log.onsets, time];

[inducer_stim, ~] = grating(...    
    cfg.stimulus_orientation,...
    Gparams.stim.thetakappa,...
    Gparams.stim.f_spat_mean,...
    Gparams.stim.f_spat_sd,...
    Gparams.stim.rms_contrast,...
    Gparams.stim.mean_grey_value,...
    Gparams.stim.imSize,...
    Gparams); 

% generate transparency mask
[gaussian_window, ~] = transparency_mask(...
    Gparams.stim.window_sd,...
    Gparams.stim.imSize,...
    Gparams.bg,...
    Gparams);

% determine stimulus positions
[s1, s2, ~] = size(inducer_stim);
baseRect = [0 0 s1 s2];

yPos1 = (Gparams.ScreenResY-1)/2;
xPos1 = (Gparams.ScreenResX - 1)/2 + h_pos;
inducer_dstRect =  CenterRectOnPointd(baseRect, xPos1, yPos1);

% display stimuli
gaussTexture = Screen('MakeTexture', Gparams.pWindow, gaussian_window);
inducerTexture = Screen('MakeTexture', Gparams.pWindow, inducer_stim);
Screen('DrawTexture', Gparams.pWindow, inducerTexture, [], inducer_dstRect);
Screen('DrawTexture', Gparams.pWindow, gaussTexture, [], inducer_dstRect);

Screen('DrawDots', Gparams.pWindow, [(Gparams.ScreenResX - 1)/2, (Gparams.ScreenResY-1)/2], Gparams.FixDotSize, 191, [], 1);
time = Screen('Flip', Gparams.pWindow, time + Gparams.timing.sd_cuedur);
log.onsets = [log.onsets, time];


% generate noise masks
% [inducer_noise_mask,~] = mask(...
%    Gparams.mask.sd_smooth,...
%    Gparams.mask.contrast,...
%    Gparams.stim.imSize,...
%    Gparams.bg,...
%    Gparams);


% display mask
% inducer_maskTexture = Screen('MakeTexture', Gparams.pWindow, inducer_noise_mask);
% Screen('DrawTexture', Gparams.pWindow, inducer_maskTexture, [], inducer_dstRect);
% Screen('DrawTexture', Gparams.pWindow, gaussTexture, [], inducer_dstRect);

% Screen('DrawDots', Gparams.pWindow, [(Gparams.ScreenResX - 1)/2, (Gparams.ScreenResY-1)/2], Gparams.FixDotSize, 255, [], 1);
% time = Screen('Flip', Gparams.pWindow, time + Gparams.timing.sd_stimdur);
% log.onsets = [log.onsets, time];

% response delay
Screen('DrawDots', Gparams.pWindow, [(Gparams.ScreenResX - 1)/2, (Gparams.ScreenResY-1)/2], Gparams.FixDotSize, 191, [], 1);
time = Screen('Flip', Gparams.pWindow, time + Gparams.timing.sd_stimdur);
log.onsets = [log.onsets, time];

Screen('DrawDots', Gparams.pWindow, [(Gparams.ScreenResX - 1)/2, (Gparams.ScreenResY-1)/2], Gparams.FixDotSize, 255, [], 1);
time = Screen('Flip', Gparams.pWindow, time + Gparams.timing.sd_responsedelay);
log.onsets = [log.onsets, time];

%% Response

% response - 1 = left; 0 = right
funcfg = [];
funcfg.maxtime = 3;
funcfg.button_mapping = cfg.button_mapping;
log.afc_response = afc_response_ud(funcfg,Gparams);

% feedback when too slow
if isnan(log.afc_response.rt)
    
    % feedback - yellow warning
    Screen('DrawDots', Gparams.pWindow, [(Gparams.ScreenResX - 1)/2, (Gparams.ScreenResY-1)/2], Gparams.FixDotSize, [255 215 0], [], 1);
    time = Screen('Flip', Gparams.pWindow);
    log.onsets = [log.onsets, time];

    % ITI fixation
    Screen('DrawDots', Gparams.pWindow, [(Gparams.ScreenResX - 1)/2, (Gparams.ScreenResY-1)/2], Gparams.FixDotSize, 255, [], 1);
    Screen('Flip', Gparams.pWindow, time + Gparams.timing.warning);
    
else
    
    % feedback - response registered
    Screen('DrawDots', Gparams.pWindow, [(Gparams.ScreenResX - 1)/2, (Gparams.ScreenResY-1)/2], Gparams.FixDotSize, 255, [], 1);
    time = Screen('Flip', Gparams.pWindow);
    log.onsets = [log.onsets, time];
    
    % ITI fixation
    Screen('DrawDots', Gparams.pWindow, [(Gparams.ScreenResX - 1)/2, (Gparams.ScreenResY-1)/2], Gparams.FixDotSize, 255, [], 1);
    Screen('Flip', Gparams.pWindow, time + Gparams.timing.warning);
    
end

%% ITI period
Screen('DrawDots', Gparams.pWindow, [(Gparams.ScreenResX - 1)/2, (Gparams.ScreenResY-1)/2], Gparams.FixDotSize, 255, [], 1);
time = Screen('Flip', Gparams.pWindow);
log.onsets = [log.onsets, time];

Screen('DrawDots', Gparams.pWindow, [(Gparams.ScreenResX - 1)/2, (Gparams.ScreenResY-1)/2], Gparams.FixDotSize, 255, [], 1);
time = Screen('Flip', Gparams.pWindow, time + Gparams.timing.iti);
log.onsets = [log.onsets, time];

%% Clean up from trial

% close textures
% Screen('Close', cuemaskTexture);
Screen('Close', inducerTexture);
Screen('Close', gaussTexture);
% Screen('Close', inducer_maskTexture);


end
