Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions Stimuli/makeGratingRC.m
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
% 05/05/24 hn: open new textures only if needed, and close existing
% grating texture if it exists.
% 12/02/25 hn: removed ppd (now using pixel2deg function instead)
% 03/25/26 cmz: check for geometry correction in placing the stim center

% make sure we have all the parameters we need
if ~isfield(ex.stim.vals,'sf_range') || isempty(ex.stim.vals.sf_range)
Expand All @@ -44,7 +45,10 @@

%%
sv = ex.stim.vals; % stimvals


%% adjust stimulus center for geometry correction?
geomCorrect = isfield(ex.setup,"scal");

%%
% include y_offset as a cue towards the correct target for the
% discrimination task, if we have it
Expand Down Expand Up @@ -205,6 +209,9 @@
% pixels and is therefore symmetric around the center of the texture:
visiblesize = 2*texsize+1;

% used for calculations with geometry correction
visiblesizeDeg = visiblesize*dpp;

white = ex.idx.white;
black = ex.idx.black;

Expand Down Expand Up @@ -311,16 +318,24 @@
% Definition of the drawn rectangle on the screen:
% Compute it to be the visible size of the grating, centered on the
% defined stimulus center
left = ppd*sv.x0+ex.fix.PCtr(1)-visiblesize/2;
bottom = ppd*y0+ex.fix.PCtr(2)-visiblesize/2;
dstRect=[left bottom left+visiblesize bottom+visiblesize];
%dstRect=CenterRect(dstRect, screenRect)

if ~geomCorrect
left = ppd*sv.x0+ex.fix.PCtr(1)-visiblesize/2;
bottom = ppd*y0+ex.fix.PCtr(2)-visiblesize/2;
dstRect=[left bottom left+visiblesize bottom+visiblesize];
else
% Find image center and place pixel-defined mask there
[x0Pix,y0Pix] = deg2pixelxy(sv.x0,sv.y0,ex.setup);
left = x0Pix-visiblesize/2;
bottom = y0Pix-visiblesize/2;
dstRect = round([left bottom left+visiblesize bottom+visiblesize]);
end

% compute dstRect if we have a second stimulus
dstRect2 = [];
if isfield(ex.stim.vals,'stim2') & ex.stim.vals.stim2
left = ppd*sv.x02+ex.fix.PCtr(1)-visiblesize/2;
bottom = ppd*sv.y02+ex.fix.PCtr(2)-visiblesize/2;
bottom = ppd*sv.y02+ex.fix.PCtr(2)-visiblesize/2;
dstRect2=[left bottom left+visiblesize bottom+visiblesize];
else ex.stim.vals.stim2 = 0;
end
Expand Down