Commit 4003b4ff authored by Christian Poth's avatar Christian Poth
Browse files

Clean up folders.

parent 87e7ff29
function gabor = makeGabor(vis, pars)
% function gabor = makeGabor(vis, pars)
%
% INPUT:
% vis = struct with info on basic visual settings
% pars = gabor parameters
% pars.amp = amplitude (-amp/2:amp/2, 1 = full contrast)
% pars.frq = spatial frequency (cycles/d.v.a)
% pars.ori = orientation (radians, 0 and pi are vertical, pi/2 and 3*pi/2 horizontal)
% pars.pha = phase (radians)
% pars.sig = sd of Gaussian envelope (d.v.a.)
% pars.siz = extent of stimulus from center to border (d.v.a.)
% OUTPUT:
% gabor matrix
%
% Acknowledge help by Martin Rolfs, who provided his code.
%
% Christian Poth, 2019, c.poth@uni-bielefeld.de
% Convert to px-based values.
frq = pars.frq/vis.pxd;
sig = pars.sig*vis.pxd;
siz = pars.siz*vis.pxd;
% Make the gabor.
[X,Y] = meshgrid(-siz:siz,-siz:siz);
grating = pars.amp*cos(X*(2*pi*frq*cos(pars.ori)) + Y*(2*pi*frq*sin(pars.ori))+pars.pha);
gauss = exp(-(X.^2+Y.^2)./(2*sig^2)) ;
gabor = vis.bgColor + vis.maxIncrement * (gauss.*grating);
function mask = makeOriMask(vis, pars)
% function mask = makeOriMask(vis, pars)
%
% INPUT:
% vis = struct with info on basic visual settings
% pars = mask parameters (should match to-be-masked gabor)
% pars.amp = amplitude (-amp/2:amp/2)
% pars.frq = spatial frequency (cycles/d.v.a)
% pars.ori = orientation (radians, 0 and pi are vertical, pi/2 and 3*pi/2 are horizontal)
% pars.pha = phase (radians)
% pars.sig = sd of Gaussian envelope (d.v.a.)
% pars.siz = extent of stimulus from center to border (d.v.a.)
% OUTPUT:
% mask matrix
%
% Acknowledge help by Martin Rolfs.
%
% Christian Poth, 2019, c.poth@uni-bielefeld.de
ori = [0, 180];
frq = pars.frq * [1/2 2];
if ~isfield(pars,'cut')
pars.cut = 1;
end
fNyquist = 0.5;
% Convert to px-based values.
frq = frq/vis.pxd;
sig = pars.sig*vis.pxd;
siz = pars.siz*vis.pxd;
[X,Y] = meshgrid(-siz/2:siz/2,-siz/2:siz/2);
noise = randn(size(X));
ffilter = Bandpass2(size(X,1), frq(1) / fNyquist, frq(2) / fNyquist);
ofilter = OrientationBandpass(size(X,1), ori(1), ori(2));
cfilter = ofilter .* ffilter;
ft = cfilter .* fftshift(fft2(noise));
noise = real(ifft2(ifftshift(ft)));
noise = noise * (1/std(noise(:)));
noise = pars.amp * noise;
% limit contrast range of noise to be able
% to add stimulus without truncation
noise(noise < -pars.cut) = -pars.cut;
noise(noise > pars.cut) = pars.cut;
gauss = exp(-(X.^2+Y.^2)./(2*sig^2)) ;
mask = vis.bgColor + vis.maxIncrement * (gauss .* noise);
function expLog = openLog(saveFolder, fileName, varNames)
%function expLog = openLog(fileName, nLogVar, varNames)
% OUTPUT: Log-file.
% INPUT:
% saveFolder = folder where data shall be saved
% fileName = desired file name
% nLogVar = number of variables to log
% varNames = cell with strings of variable names
%
% Christian Poth, c.poth@uni-bielefeld.de, 2019
if ~exist(fullfile(saveFolder, fileName))
expLog = fopen(fullfile(saveFolder, fileName), 'w');
else
clear all;
clear mex;
clear functions;
close all;
sca;
error(['Do not overwrite data file!'])
end
if expLog == -1
error(['Could not open ' fileName ' for writing'])
end
fprintf(expLog, [repmat('%s\t', 1, size(varNames, 2) - 1) '%s\n'], varNames{:});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment