Commit 9564d0d1 authored by Joanna Luberadzka's avatar Joanna Luberadzka

AFC experiment for localization

parent b331a830
......@@ -22,19 +22,19 @@ def.ollodir='/media/joanna/daten/user/joanna/Data/my_OLLO/OLLO_data/OLLO2.0_NO/'
def.measurementProcedure = 'transformedUpDown'; % measurement procedure
def.intervalnum = 3; % number of intervals
def.rule = [1 2]; % [up down]-rule: [1 2] = 1-up 2-down
def.varstep = [4 2 1]; % [starting stepsize ... minimum stepsize] of the tracking variable
def.varstep = [8 5 1]; % [starting stepsize ... minimum stepsize] of the tracking variable
def.steprule = -1; % stepsize is changed after each upper (-1) or lower (1) reversal
def.reversalnum = 6; % number of reversals in measurement phase
def.repeatnum = 1; % number of repeatitions of the experiment
% experimental variable (result of procedure yields dependent variable)
def.startvar = 5; % starting value of the tracking variable
def.startvar = 50; % starting value of the tracking variable
def.expvarunit = 'dB'; % unit of the tracking variable
def.expvardescription = 'noise level'; % description of the tracking variable
def.expvardescription = 'signal level'; % description of the tracking variable
% limits for experimental variable
def.minvar = 100; % minimum value of the tracking variable
def.maxvar = 0; % maximum value of the tracking variable
def.minvar = -100; % minimum value of the tracking variable
def.maxvar = 100; % maximum value of the tracking variable
def.terminate = 1; % terminate execution on min/maxvar hit: 0 = warning, 1 = terminate
def.endstop = 3; % Allows x nominal levels higher/lower than the limits before terminating (if def.terminate = 1)
......
......@@ -27,7 +27,7 @@ global work
global setup
% conditions are specified in each run by:
% afc('main','experimentDOA','subject','5deg','female','babble')
% afc('main','experimentDOA','subject','5deg','ollo_female','white')
% Condition 1
switch work.userpar1
......@@ -61,12 +61,12 @@ end
% define the calibration level (assume 90 dB SPL for 0 dB FS)
work.currentCalLevel = 100;
work.currentCalLevel = 90;
setup.level=40;
% define signals in structure setup
% setup.modsine = sin([0:def.intervallen-1]'*2*pi*work.exppar1/def.samplerate);
setup.hannlen = round(0.05*def.samplerate);
setup.window = hannfl(def.intervallen,setup.hannlen,setup.hannlen);
% make a list of files from which one file should be
% randomly chosen in each trial
......@@ -79,7 +79,7 @@ addpath(genpath(def.hrirdir))
% create a cell array which has the same lenght as
% the number of referece angles that we want to test
setup.HRIRs=cell(length(def.exppar1),1)
for k=1:lenght(setup.HRIRs)
for k=1:length(setup.HRIRs)
%load the hrir for the reference angle
setup.HRIRs{k}.hrir_ref=loadHRIR('Anechoic', 80, 0, def.exppar1(k),'in-ear')
%load the hrirs for the angle 5° away from the reference angle
......@@ -88,9 +88,4 @@ for k=1:lenght(setup.HRIRs)
end
% eof
\ No newline at end of file
......@@ -45,43 +45,51 @@ global setup
numberOfFiles = length(setup.waveFiles);
fileToPlay = randi(numberOfFiles, 1);
baseWavFileName = setup.waveFiles(fileToPlay).name;
fullWavFileName = fullfile([def.ollodir, baseWavFileName]);
fullWavFileName = fullfile([setup.filedir, baseWavFileName]);
[sig fssig]=audioread(fullWavFileName);
% resample the signal
[P,Q] = rat(def.samplerate/fssig);
sig=resample(sig,P,Q);
sig_level=work.expvaract;
sig=sig.*10^((sig_level - work.currentCalLevel)/20);
% choose hrir:
% * find which reference angle is currently tested
% * randomly choose +or- 5or10 deg
indx=find(def.exppar==work.exppar1);
hrir_ref=setup.HRIRs{indx}.hrir_ref;
plusorminus=randi(2)
def.exppar1
indx=find(def.exppar1==work.exppar1);
hrir_ref=setup.HRIRs{indx}.hrir_ref.data;
plusorminus=randi(2);
if plusorminus==1
hrir_targ=setup.HRIRs{indx}.hrir_refplus;
hrir_targ=setup.HRIRs{indx}.hrir_refplus.data;
elseif plusorminus==2
hrir_targ=setup.HRIRs{indx}.hrir_refminus;
hrir_targ=setup.HRIRs{indx}.hrir_refminus.data;
end
% convolve signals
sig_ref(1,:)=conv(sig(1,:),hrir_ref(1,:));
sig_ref(2,:)=conv(sig(2,:),hrir_ref(2,:));
sig_targ(1,:)=conv(sig(1,:),hrir_targ(1,:));
sig_targ(2,:)=conv(sig(1,:),hrir_targ(1,:));
sig_ref(1,:)=conv(sig,hrir_ref(:,1));
sig_ref(2,:)=conv(sig,hrir_ref(:,2));
sig_targ(1,:)=conv(sig,hrir_targ(:,1));
sig_targ(2,:)=conv(sig,hrir_targ(:,2));
noise_level=setup.level;
noise=setup.noise.*10^((noise_level - work.currentCalLevel)/20);
%here scale the noise so that it has level according
% to the current tracking variable work.expvaract
% provide 3 randomly cut excerpts of noise
L=length(sig)+length(hrir_targ)-1;
start1=randi(length(noise)-L);
noise1=noise(start1+1:start1+L);
start2=randi(length(noise)-L);
noise2=noise(start2+1:start2+L);
start3=randi(length(noise)-L);
noise3=noise(start3+1:start3+L);
% LEVELS: here scale the noise so that it has level according
% to the current tracking variable work.expvaract
% provide 3 randomly cut excerpts of noise
L=length(sig)+length(hrir_targ)-1;
sig_noise1=noise(randi(length(noise)):randi(length(noise))+L)
sig_noise2=noise(randi(length(noise)):randi(length(noise))+L)
sig_noise3=noise(randi(length(noise)):randi(length(noise))+L)
% tref1 = real(ifft(scut(fft(randn(def.intervallen,1)),1000,4000,def.samplerate))) * 10^((setup.level - work.currentCalLevel)/20);
......@@ -89,12 +97,16 @@ sig_noise3=noise(randi(length(noise)):randi(length(noise))+L)
% tuser = real(ifft(scut(fft(randn(def.intervallen,1)),1000,4000,def.samplerate))) * 10^((setup.level - work.currentCalLevel)/20) .* ... // holds the target signal
% (1 + (10^(work.expvaract/20) * setup.modsine));
tref11=(sig_ref(1,:)+sig_noise1).* setup.window;
tref12=(sig_ref(2,:)+sig_noise1).* setup.window;
tref21=(sig_ref(1,:)+sig_noise2).* setup.window;
tref22=(sig_ref(2,:)+sig_noise2).* setup.window;
tuser1=(sig_targ(1,:)+sig_noise3).* setup.window;
tuser2=(sig_targ(2,:)+sig_noise3).* setup.window;
%window
setup.hannlen = round(0.05*def.samplerate);
setup.window = hannfl(L,setup.hannlen,setup.hannlen)';
tref11=(sig_ref(1,:)+noise1).* setup.window;
tref12=(sig_ref(2,:)+noise1).* setup.window;
tref21=(sig_ref(1,:)+noise2).* setup.window;
tref22=(sig_ref(2,:)+noise2).* setup.window;
tuser1=(sig_targ(1,:)+noise3).* setup.window;
tuser2=(sig_targ(2,:)+noise3).* setup.window;
% pre-, post- and pausesignals (all zeros)
......@@ -105,7 +117,7 @@ pausesig = zeros(def.pauselen,2);
% make required fields in work
work.signal = [tuser1 tuser2 tref11 tref12 tref21 tref22]; % left = right (diotic) first two columns holds the test signal (left right)
work.signal = [tuser1' tuser2' tref11' tref12' tref21' tref22']; % left = right (diotic) first two columns holds the test signal (left right)
work.presig = presig; % must contain the presignal
work.postsig = postsig; % must contain the postsignal
work.pausesig = pausesig; % must contain the pausesignal
......
% specify that subject "exampleArtificialListener" is actually a model
% and disable the response box and sound output etc.
def.modelEnable = 1;
def.afcwinEnable = 1;
def.soundEnable = 1;
def.modelDisplayEnable = 1;
def.modelShowEnable = 0;
def.markpressed = 1;
def.showEnable = 1;
def.showrun = 1;
def.showtrial = 1;
def.showspec = 1;
% eof
% revision 1.00.1 beta, 07/01/04
function response = exampleDOA_detect
global def
global work
global simwork
% we select only the left channels, the model is monaural
simwork.tmpSig = work.signal;
simwork.DOAaz = [];
for i=1:def.intervalnum
simwork.DOAaz(i) = eval([work.vpname '_preproc(simwork.tmpSig(:,2*i-1:2*i))']); % actual sig processing
end
% now select the interval with the maximum standard deviation
[tmp,response] = max(simwork.actStd); % select max power
% if it is another interval than the first, the response is wrong, since in the work.signal always carries the
% signal interval in the first column
if response ~= 1
response = 0;
end
% eof
% revision 1.00.1 beta, 07/01/04
function exampleDOA_init
% this file is used to initialize model parameters
global def
global work
global simwork
% the example model is so simple, there is not much to initialize.
% Some filter coefficients used in example_preproc
% 4-6 kHz four-pole Butterworth Bandpass (missing)
% first-order lowpass filter @ 65 Hz
[simwork.lp_b,simwork.lp_a] = folp(65,def.samplerate);
%eof
% revision 1.00.1 beta, 07/01/04
function response = exampleDOA_main
% the model_main function must return the presentation interval selected by the model
global def
global work
% in this case the example model calls a detect routine for this, which returns 1 if the signal is detected.
detect = eval([work.vpname '_detect']);
% if detected than select the current signal position as the response interval, select a random one from the
% remaining intervals otherwise
switch detect
case 1
response = work.position{work.pvind}(end);
case 0
responseTmp = randperm( def.intervalnum );
response = work.position{work.pvind}(end);
i = 1;
while ( response == work.position{work.pvind}(end) )
response = responseTmp(i);
i = i + 1;
end
end
% the model also displays some info in the matlab workspace window
% might also go to an extra function "example_display"
if ( def.modelDisplayEnable )
if detect == 1
r = 'correct'; % correct response
else
r = 'false'; % false response
end
if ( work.stepnum{work.pvind}(end) == 1 )
disp('starting new run ...');
end
disp(['step ' num2str(work.stepnum{work.pvind}(end)) ' ' r]);
end
% eof
% revision 1.00.1 beta, 07/01/04
function out = exampleDOA_preproc(in)
% in contains one of the 3 intervals presented in the experiment
global def
global work
global simwork
% this is the Viemeister JASA 1979 leaky-integrator model
% 4-6 kHz four-pole Butterworth Bandpass (missing)
% halfwave rectification
tmp = max(in,0);
% first-order lowpass filter @ 65 Hz
tmp = filter(simwork.lp_b, simwork.lp_a, tmp);
% ac-coupled rms = std
out = std(tmp,1);
% that's it
% eof
% [probability DOAazimuth time] = DOASVMloc1(sig,fs)
\ No newline at end of file
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