Commit 88641c25 authored by mposthuma's avatar mposthuma
Browse files

Made a working exp file gen

Need to correct Az/El and stim values
Use experiment_file_main for further development of experiment script
parent f2ee658c
......@@ -6,38 +6,76 @@ function pb_vGenExp_VisFlash(varargin)
disp(' ...')
cfn = 0;
%General Values
GV.showexp = pb_keyval('showexp',varargin,true);
GV.expfile = pb_keyval('fname',varargin,'MainExp');
GV.datdir = pb_keyval('datdir',varargin,'U:\Documents\BIOLOGIE\STAGE\MATLAB\EXP-files\MainExp');
GV.cdir = pb_keyval('cdir',varargin,userpath);
GV.ITI = pb_keyval('ITI',varargin,[0 0]);
GV.lab = pb_keyval('lab',varargin,5);
GV.stim = pb_keyval('stim',varargin,2);
expfile = 'ExpFile';
datdir = 'U:\Documents\BIOLOGIE\STAGE\MATLAB\EXP-files\MainExp';
cd 'U:\Documents\BIOLOGIE\STAGE\MATLAB\EXP-files\MainExp'
%% Desired azimuth and elevation
% Define hemisphere
% Define hemisphere
%Select target ranges
maxAbsAz = 35;
% Select target ranges
maxAbsAz = 45;
maxAbsEl = 30;
% Possible targets
dAz = -35:05:35;
dEl = -30:10:30;
[dAz,dEl] = meshgrid(dAz,dEl);
dAz = dAz(:);
dEl = dEl(:);
sel1 = (abs(dAz)+abs(dEl)) <= maxAbsAz & abs(dEl) <= maxAbsEl;
sel2 = iseven(dAz) & dEl ~= 0;
sel = sel1 & sel2;
dAz = dAz(sel);
dEl = dEl(sel);
nloc = numel(dAz);
%% Select target positions used in experiment
% Get targets.
targetl = length(dAz);
targetInd = randperm(targetl);
dAz = dAz(sort(targetInd(1:targetl)));
dEl = dEl(sort(targetInd(1:targetl)));
% Possible targets
dAz = -45:05:45; %not correct!
dEl = -35:15:35; %not correct!
% Restrictions in SLCs if needed
dEl = dEl(dEl~=0); % remove elevation = 0
dAz = dAz(dAz>=-35);
dAz = dAz(dAz<=35); %gives 48 stimulus locations
% Make grid
[dAz,dEl] = meshgrid(dAz,dEl);
dAz = dAz(:);
dEl = dEl(:);
sel1 = (abs(dAz)+abs(dEl)) <= maxAbsAz & abs(dEl) <= maxAbsEl;
sel2 = iseven(dAz) | dEl == 0;
sel = sel1 & sel2;
dAz = dAz(sel);
dEl = dEl(sel);
nloc = numel(dAz);
%% Actual azimuth and elevation
% The actual speaker positions are not perfectly aligned with 5 deg
cfg = pb_vLookup(); % sphere positions
channel = cfg.interpolant(dAz',dEl');
X = cfg.lookup(channel+1,4);
Y = cfg.lookup(channel+1,5);
%% Graphics
if GV.showexp
cfn = pb_newfig(cfn);
hold on;
plot(dAz,dEl,'o')
hold on
plot(X,Y,'x')
axis([-60 60 -60 60]);
axis square
set(gca,'TickDir','out');
xlabel('Azimuth (deg)');
ylabel('Elevation (deg)');
pb_nicegraph;
end
%% Stimulus Condition
% FIXATION LED
......@@ -49,24 +87,28 @@ maxAbsEl = 30;
modality = 2; % 2=VISUAL
int = [20 25 30 35 40 45 50]; % w/ [i1, i2, i3...]
dur = 16; % stim duration in ms 2.^(0:7)*.5
dur = 16; % stim duration in ms 2.^(0:7)*.5
col = [1]; % w/ [R,G]
[X,~,~] = ndgrid(X,0,col,int,dur);
[Y,~,col,int,dur] = ndgrid(Y,0,col,int,dur);
% Vectorizer
X = X(:);
Y = Y(:);
int = int(:);
col = col(:);
dur = dur(:);
%% Number and size
N = 48; % number of trials = 48 per block
Sz = size(X);
N = Sz(1); % number of trials
maxtrialdur = max(dur);
maxtrialdur = ceil(maxtrialdur/500)/2;
%% Vestibular blocks
nblocks = 1;
blockdur = 200; % block duration in seconds
bdureff = blockdur-(8*pi); % start & stop
trialsinblock = bdureff / (maxtrialdur+1); % trials per block
......@@ -75,19 +117,23 @@ maxAbsEl = 30;
blockconditions = [];
nblockreps = N/trialsinblock;
block.Horizontal = struct('Amplitude', 0, 'Signal', 1, 'Duration', blockdur, 'Frequency',.16);
block.Horizontal = struct('Amplitude', 0, 'Signal', 1, 'Duration', blockdur, 'Frequency',0);
block.Vertical = struct('Amplitude', 70, 'Signal', 2, 'Duration', blockdur, 'Frequency',1/(2*pi));
end
function writeexp(expfile,datdir,theta,phi,int,dur,block,fixled)
%% Save data somewhere
writeexp(expfile,datdir,X,Y,int,dur,block,fixled,GV);
end
function writeexp(expfile,datdir,theta,phi,int,dur,block,fixled,GV)
% Save known trial-configurations in exp-file
expfile = 'Expfile';
expfile = fcheckext(expfile,'.exp'); % check whether the extension exp is included
fid = fopen(expfile,'wt+'); % this is the way to write date to a new file
nblocks = 1;
ntrials = 30;
trialsz = numel(theta); % number of trials
tdurexp = 2.1 * trialsz + (sum(dur)/1000);
......@@ -100,9 +146,10 @@ end
Rep = 1; % we have 0 repetitions, so insert 1...
Rnd = 0; % we randomized ourselves already
Mtr = 'n'; % the motor should be on
pb_vWriteHeader(fid,datdir,ITI,blocksz,blocksz*trialsz*Rep,Rep,Rnd,Mtr,'Lab',5); % helper-function
pl = randperm(trialsz); % randomize trialorder in blocks
nblocks = 1;
ntrials = 30;
pb_vWriteHeader(fid,nblocks,ntrials,GV); % helper-function
pl = randperm(trialsz); % randomize trialorder in bik heb zlocks
newBlock = true;
totalDur = 0;
......
function WM_vGenExp_loc_ReturnMidStat(varargin)
% PB_VGENEXP_VIS
%
% PB_VGENEXP_VIS(varargin) will generate an EXP-file for a default localization experiment.
% EXP-files are used for the psychophysical experiments at the
% Biophysics Department of the Donders Institute for Brain, Cognition and
% Behavior of the Radboud University Nijmegen, the Netherlands.
%
% See also WRITESND, WRITELED, WRITETRG, GENWAV_DEFAULT, etc
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
function pb_vGenExp_VisFlash(varargin)
%% Initialization
% Clear, empty, default imputs
......@@ -23,10 +12,10 @@ cfn = 0;
showexp = pb_keyval('showexp',varargin,true);
expfile = pb_keyval('fname',varargin,'MainExp');
datdir = pb_keyval('datdir',varargin,'C:\Users\marc_\OneDrive\Documents\Studie\STAGE\MATLAB Code\EXP-files\MainExp');
datdir = pb_keyval('datdir',varargin,'U:\Documents\BIOLOGIE\STAGE\MATLAB\EXP-files\MainExp');
cdir = pb_keyval('cdir',varargin,userpath);
cd 'C:\Users\marc_\OneDrive\Documents\Studie\STAGE\MATLAB Code\EXP-files\MainExp'
cd 'U:\Documents\BIOLOGIE\STAGE\MATLAB\EXP-files\MainExp'
%% Desired azimuth and elevation
......@@ -129,12 +118,12 @@ dur = dur(randp);
BlockDur = 200; % 48*3.125*8*pi + some extra time (for pilot experiment set to 200)
block.Horizontal = struct('Amplitude', 0, 'Signal', 1, 'Duration', BlockDur , 'Frequency',0);
block.Vertical = struct('Amplitude', 70, 'Signal', 1, 'Duration', BlockDur , 'Frequency',1/(2*pi));
block.Vertical = struct('Amplitude', 70, 'Signal', 2, 'Duration', BlockDur , 'Frequency',1/(2*pi));
%% Save data somewhere
% Chunck up data
blocknum = 5; % 1064 trials / 48 trials per block = 23 blocks
blocknum = 1; % 1064 trials / 48 trials per block = 23 blocks
startIdx = 1:38:190; % 266 trials per category
stopIdx = 38:38:190; stopIdx(end+1) = 190; % indexing
......
Markdown is supported
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