Commit a8e4d8ee authored by Jesse Heckman's avatar Jesse Heckman

update write exp

parent adf462fc
%
%% Experiment: C:\DATA\DEFAULT
%
ITI 0 0
Trials 19
Repeats 1
Random 0 % 0=no, 1=per set, 2=all trials
Motor n
Lab 2
% MOD X Y ID INT On On Off Off Event
% edg bit Event Time Event Time
%AX SIG AMP DUR FREQ
% edg bit Event Time Event Time
% Trial: 1
==>
......@@ -59,6 +59,7 @@ function pb_vGenExp_Vis(varargin)
dEl = dEl(sel);
nloc = numel(dAz);
%% Select target positions
% Get targerts.
......
......@@ -43,8 +43,8 @@ function pb_vVestExp(varargin)
BD = 60; % block duration in seconds
%% Sine
block(1).Horizontal = struct('Amplitude', 0, 'Signal', 2, 'Duration', BD, 'Frequency',.3);
block(1).Vertical = struct('Amplitude', 13, 'Signal', 2, 'Duration', BD, 'Frequency',.3);
block(1).Horizontal = struct('Amplitude', 0, 'Signal', 1, 'Duration', 0, 'Frequency',.1);
block(1).Vertical = struct('Amplitude', 0, 'Signal', 1, 'Duration', 0, 'Frequency',.1);
block(2).Horizontal = struct('Amplitude', 0, 'Signal', 2, 'Duration', BD, 'Frequency',.2);
block(2).Vertical = struct('Amplitude', 20, 'Signal', 2, 'Duration', BD, 'Frequency',.2);
......
function pb_vWriteSnd(fid,SND,X,Y,ID,Int,EventOn,Onset,Offset)
% PB_VWRITESND()
%
% PB_VWRITESND() ...
%
% See also ...
% PBToolbox (2019): JJH: j.heckman@donders.ru.nl
% WRITESND(FID,SND,X,Y,ID,INT,EVENTON,ONSET,EVENTOFF,OFFSET)
%
% Write a SND-stimulus line in an exp-file with file identifier FID.
%
% SND - 'SND1' or 'SND2'
% X - SND theta angle
% Y - SND phi number (1-29 and 101-129)
% INT - SND Intensity (0-100)
% EVENTON - The Event that triggers the onset of the SND (0 - start of
% trial)
% ONSET - The Time after the On Event (msec)
% EVENTOFF - The event that triggers the offset of the SND
% OFFSET - The time after the off event (mse)
fprintf(fid,'%s\t%d\t%d\t \t%d\t%d\t%d\t%d\t%d\n',SND,X,Y,ID,Int,EventOn,Onset,Offset);
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2019) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
function pb_vGenexp_defAud
% PB_VGENEXP_DEFAUD()
%
% PB_VGENEXP_DEFAUD() ...
%
% See also ...
% PBToolbox (2019): JJH: j.heckman@donders.ru.nl
%%
close all;
clear hidden;
disp('>> GENERATING EXPERIMENT <<');
expfile = 'defAud.exp'; % file name
datdir = 'DEFAULT';
showexp = true ;
%%
% Select target ranges
maxAbsAz = 55;
maxAbsEl = 35;
% Possible targets
dAz = -50:05:50;
dEl = -30:10:30;
[dAz,dEl] = meshgrid(dAz,dEl);
dAz = dAz(:);
dEl = dEl(:);
sel1 = (abs(dAz)+abs(dEl)) <= maxAbsAz & abs(dEl) <= maxAbsEl;
sel2 = rem(abs(dAz),2)== 0| dEl == 0;
sel = sel1 & sel2;
dAz = dAz(sel);
dEl = dEl(sel);
nloc = numel(dAz);
%% led
%fixled
fixled.bool = true; % do you want a fixation light?
fixled.x = 0;
fixled.y = 0;
fixled.dur = 1000;
fixled.pause = 1000;
%length sound
maxsnd = 200 ;
minsnd = 200 ;
dur = [250];
dur = dur(:) ;
%% 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);
%% plot graphics
figure;
hold on;
plot(dAz,dEl,'.')
hold on
plot(X,Y,'.')
axis([-60 60 -60 60]);
axis square
set(gca,'TickDir','out');
xlabel('Azimuth (deg)');
ylabel('Elevation (deg)');
grid on;
%% intensity and frequency
int = [65]; % these DB intensities?
snd = [1]; % Only Broadband or more?
[X,~,~] = ndgrid(X,int,snd);
[Y,int,snd] = ndgrid(Y,int,snd);
X = X(:);
Y = Y(:);
int = int(:);
snd = snd(:);
%% trails
Sz = size(X);
N = Sz(1); %trails
%%
sndon = 1250;
sndon = repmat(sndon,N,1);
sndon = sndon(:);
ledon = 1000;
ledon = repmat (ledon,N,1);
ledon = ledon(:);
%% Randomize
rnd = randperm(N);
X = round(X(rnd));
Y = round(Y(rnd));
%% vestiular block
block(1).Horizontal = struct('Signal', 1, 'Amplitude', 0, 'Duration', 0, 'Frequency', .1);
block(1).Vertical = struct('Signal', 1, 'Amplitude', 0, 'Duration', 0, 'Frequency', .1);
%% Save data somewhere
writeexp(expfile,datdir,X,Y,snd,int,ledon,sndon,dur,block)%,fixled);
% see below, these are helper functions to write an exp-file line by line / stimulus by stimulus
%% Show the exp-file in Wordpad
% for PCs
if showexp
if ispc
dos(['"C:\Program Files\Windows NT\Accessories\wordpad.exe" ' expfile ' &']);
elseif ismac
system(['open -a TextWrangler ' cd filesep expfile]);
end
end
end
function writeexp(expfile,datdir,X,Y,snd,int,ledon,sndon,dur,block)
% Save known trial-configurations in exp-file
%
%WRITEEXP WRITEEXP(FNAME,DATDIR,THETA,PHI,ID,INT,LEDON,SNDON)
%
% WRITEEXP(FNAME,THETA,PHI,ID,INT,LEDON,SNDON)
%
% Write exp-file with file-name FNAME.
%
%
% See also manual at neural-code.com
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
ntrials = numel(X);
blocksz = length(block);
%% Header of exp-file
ITI = [0 0]; % useless, but required in header
Rep = 1; % we have 0 repetitions, so insert 1...
Rnd = 0; % we randomized ourselves already
Mtr = 'n'; % the motor should be on
writeheader(fid,datdir,ITI,ntrials*Rep,Rep,Rnd,Mtr,'Lab',2); % helper-function
%% Body of exp-file
% Create a trial
for iBlock = 1:blocksz
% Write blocks
pb_vWriteBlock(fid,iBlock);
pb_vWriteSignal(fid,block(iBlock));
for ii = 1:ntrials % each location
writetrl(fid,ii);
writeled(fid,'LED',0,0,5,0,0,0,ledon(ii)); % fixation LED
pb_writesnd(fid,'SND',round(X(ii)),Y(ii),snd(ii),0,0,ledon(ii)+sndon(ii),ledon(ii)+sndon(ii)+dur); % Sound on
end
end
fclose(fid);
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% %
% Part of Programmeer Beer Toolbox (PBToolbox) %
% Written by: Jesse J. Heckman (2019) %
% %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
......@@ -11,19 +11,20 @@ function [n,p] = pb_defsubplot(fig)
% PBToolbox (2018): JJH: j.heckman@donders.ru.nl
figure(fig);
h = flipud(findobj(gcf,'Type','Axes'));
h = pb_fobj(gcf,'Type','Axes');
n = length(h);
p = zeros(1,n);
for i = 1:n
p(i) = length(findobj(h(i),'Type','Line')) + ...
length(findobj(h(i),'Type','FunctionLine')) + ...
length(findobj(h(i),'Type','Bar')) + ...
length(findobj(h(i),'Type','Area')) + ...
length(findobj(h(i),'Type','ErrorBar')) + ...
length(findobj(h(i),'Type','Stem')) + ...
length(findobj(h(i),'Type','Histogram'));
p(i) = length(pb_fobj(h(i),'Type','Line')) + ...
length(pb_fobj(h(i),'Type','FunctionLine')) + ...
length(pb_fobj(h(i),'Type','Bar')) + ...
length(pb_fobj(h(i),'Type','Area')) + ...
length(pb_fobj(h(i),'Type','ErrorBar')) + ...
length(pb_fobj(h(i),'Type','Stem')) + ...
length(pb_fobj(h(i),'Type','Histogram')) + ...
length(pb_fobj(h(i),'Type','Patch'));
end
end
......
......@@ -11,7 +11,7 @@ function [cfn,f] = pb_newfig(cfn, varargin)
if isempty(cfn); cfn = 0; end
units = pb_keyval('units',varargin,'centimeters');
ws = pb_keyval('ws',varargin,'normal');
ws = pb_keyval('ws',varargin,'docked'); % normal
rsz = pb_keyval('resize',varargin,'on');
sz = pb_keyval('size',varargin,[0 0 17 11]);
......@@ -22,7 +22,7 @@ function [cfn,f] = pb_newfig(cfn, varargin)
set(f,'Units',units);
set(f,'Resize',rsz)
if ~strcmp(ws,'Docked'); set(f, 'Position',sz); end
if ~strcmp(ws,'docked'); set(f, 'Position',sz); end
end
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
......
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