filenames(:,1) = { ...
'imp400_5600___c_-1_-1.mat';...
'imp400_5600___c_-1_0.mat';...
'imp400_5600___c_-1_1.mat';...
'imp400_5600___c_0_-1.mat';...
'imp400_5600___c_0_0.mat';...
'imp400_5600___c_0_1.mat';...
'imp400_5600___c_1_-1.mat';...
'imp400_5600___c_1_0.mat';...
'imp400_5600___c_1_1.mat'}; %...
filenames(:,2) = { ...
'imp400_5600_n_c_-1_-1.mat';...
'imp400_5600_n_c_-1_0.mat';...
'imp400_5600_n_c_-1_1.mat';...
'imp400_5600_n_c_0_-1.mat';...
'imp400_5600_n_c_0_0.mat';...
'imp400_5600_n_c_0_1.mat';...
'imp400_5600_n_c_1_-1.mat';...
'imp400_5600_n_c_1_0.mat';...
'imp400_5600_n_c_1_1.mat'}; % ...
filenames(:,3) = { ...
'imp400_600___c_-1_-1.mat';...
'imp400_600___c_-1_0.mat';...
'imp400_600___c_-1_1.mat';...
'imp400_600___c_0_-1.mat';...
'imp400_600___c_0_0.mat';...
'imp400_600___c_0_1.mat';...
'imp400_600___c_1_-1.mat';...
'imp400_600___c_1_0.mat';...
'imp400_600___c_1_1.mat'}; %...
filenames(:,4) = { ...
'imp400_600_n_c_-1_-1.mat';...
'imp400_600_n_c_-1_0.mat';...
'imp400_600_n_c_-1_1.mat';...
'imp400_600_n_c_0_-1.mat';...
'imp400_600_n_c_0_0.mat';...
'imp400_600_n_c_0_1.mat';...
'imp400_600_n_c_1_-1.mat';...
'imp400_600_n_c_1_0.mat';...
'imp400_600_n_c_1_1.mat'}; %...
filenames(:,5) = { ...
'nos___c_-1_-1.mat';...
'nos___c_-1_0.mat';...
'nos___c_-1_1.mat';...
'nos___c_0_-1.mat';...
'nos___c_0_0.mat';...
'nos___c_0_1.mat';...
'nos___c_1_-1.mat';...
'nos___c_1_0.mat';...
'nos___c_1_1.mat'}; %...
filenames(:,6) = { ...
'nos_n_c_-1_-1.mat';...
'nos_n_c_-1_0.mat';...
'nos_n_c_-1_1.mat';...
'nos_n_c_0_-1.mat';...
'nos_n_c_0_0.mat';...
'nos_n_c_0_1.mat';...
'nos_n_c_1_-1.mat';...
'nos_n_c_1_0.mat';...
'nos_n_c_1_1.mat'}; %...
filenames(:,7) = { ...
'words___c_-1_-1.mat';...
'words___c_-1_0.mat';...
'words___c_-1_1.mat';...
'words___c_0_-1.mat';...
'words___c_0_0.mat';...
'words___c_0_1.mat';...
'words___c_1_-1.mat';...
'words___c_1_0.mat';...
'words___c_1_1.mat'}; %...
filenames(:,8) = { ...
'words_n_c_-1_-1.mat';...
'words_n_c_-1_0.mat';...
'words_n_c_-1_1.mat';...
'words_n_c_0_-1.mat';...
'words_n_c_0_0.mat';...
'words_n_c_0_1.mat';...
'words_n_c_1_-1.mat';...
'words_n_c_1_0.mat';...
'words_n_c_1_1.mat'};
fout = {'hopewb.mat'; ...
'hopewbnos.mat'; ...
'hopenb.mat'; ...
'hopenbnos.mat'; ...
'hopewnb.mat'; ...
'hopewnbnos.mat'; ...
'hopewrd.mat'; ...
'hopewrdnos.mat'};
envparametersexp5_15_2006
pflag =0;
pars.snrtype = 'p';
batar = [0 .1 .2 .3 .4 .5 .6 .7 .8 .9 1]; % Beta values to be tested
trez = 30e-3; % Processing Window Length In seconds
% Room Resolution: Step through cartesion grid for mic and sound source
% plane
rez = .02; % In meters
froom = [-3.25 -3.75 0; 3.25 3.75 3]'; % Opposite Corner Points of room
% All vertcies in image plane
v = [froom(1:2,1), [froom(1,1); froom(2,2)], froom(1:2,2), [froom(1,2); froom(2,1)]];
v = [v; ones(1,4)*mean(fov(3,:))];
gridax = {[fov(1,1):rez:fov(1,2)], [fov(2,1):rez:fov(2,2)], [fov(3,1):rez:fov(3,2)]};
cfreq = [300, 7000]; % Critical frequency range where most signal energy resides
mposperim = mpos;
% Find max distance (delay) over all mic pair, this represents
% and upper bound on all requried relative delays when scanning over
% the FOV
[rm, nm] = size(mposperim);
prs = mposanaly(mposperim,2);
maxmicd = max(prs(:,3));
% Extra delay time in seconds for padding window of data
textra = maxmicd(1)/c;
[posnum, typenum] = size(filenames);
snrs = [1 4 6]; % Selecte particualr SNR values from recorded data
for ktype = 1:typenum
for k = 1:posnum
filenames{k,ktype}
load(['FoamOnly/' filenames{k,ktype}]);
flim = 2*cfreq/fs; % Set frequency limit on PHAT transform
% Initalize performance metric arrays for new file type
if k == 1
tmpr = cell(length(snrs), length(batar)); % Initalize target magnitude array
lerpr =cell(length(snrs), length(batar)); % Initalize position error array
nmpr = cell(length(snrs), length(batar)); % Initalize noise magnitude array for target plus noise frames
stpn = cell(length(snrs), length(batar)); % Initalize mean peak target per channel to rms noise in target frame ratio
nompr = cell(length(snrs), length(batar)); % Initalize noise magnitude array for noise only frames
stpno = cell(length(snrs), length(batar)); % Initalize mean peak target per channel to rms noise in noise only frame ratio
end
% Adjust target locations
if tloc(1) == -1 & tloc(2) == -1
tloc(1) = tloc(1);
tloc(2) = tloc(2) + .15;
elseif tloc(1) == 0 & tloc(2) == -1;
tloc(1) = tloc(1) - .015;
tloc(2) = tloc(2) - .02+.15;
elseif tloc(1) == 1 & tloc(2) == -1
tloc(1) = tloc(1) + 0.015;
tloc(2) = tloc(2) + .15;
elseif tloc(1) == -1 & tloc(2) == 0
tloc(1) = tloc(1) -.01;
tloc(2) = tloc(2) + .15 + .01;
elseif tloc(1) == -1 & tloc(2) == 1
tloc(1) = tloc(1);
tloc(2) = tloc(2) + .15 - .01;
elseif tloc(1) == 0 & tloc(2) == 0
tloc(1) = tloc(1) -.01;
tloc(2) = tloc(2) +.15 -.005;
elseif tloc(1) == 0 & tloc(2) == 1
tloc(1) = tloc(1)-.015;
tloc(2) = tloc(2) + .15 - .01;
elseif tloc(1) == 1 & tloc(2) == 0
tloc(1) = tloc(1)+.02;
tloc(2) = tloc(2)+.15-.04;
elseif tloc(1) == 1 & tloc(2) == 1
tloc(1) = tloc(1)+.015;
tloc(2) = tloc(2)+.15-.015;
end
% Create corresponding time axis
tax = [0:length(y)-1]/fs;
winlen = ceil(fs*trez); % WIndow lenght in samples
wininc = round(fs*trez/2); % WIndow increment in samples
prez = ceil(fs*rez*sqrt(2)/c); % Time duration corresponding to 1 REZ pixel
prez = [300]*prez; % Time interval for power integration (up to TREZ limit)
[rsam, cmics] = size(y); % Get size in samples and mic channels of total mic recordings
seglen = ceil(fs*(textra)) +winlen; % Get total segment lenght to account of max delay differences of potential sounds
tapwin = flattap(seglen,20); % Create a flat window to taper edges
winrec = tapwin*ones(1,cmics); % Extend window to cover array channels
[b,a] = butter(4,cfreq(1)/(2*fs), 'High'); % Filter out room noise
y = filtfilt(b,a,y);
% SNR value loop
for kpn=1:length(snrs)
kp = snrs(kpn) % Assign index to SNR location
% Get indecies for segment corresponding to SNR signal
itax = find(tax >= par.targetb(kp) & tax <= par.targete(kp));
hs = y(itax,:); % Extract segement to identify peaks and window to ensure target is included in processing window
env = abs(hs);
[mv, cmax] = max(max(env)); % Find channel with stronget signal
[mx, rmax] = max(env(:,cmax(1))); % Find sample with strongest peak center window there
sed = rmax(1) - 1 + itax(1) + round(winlen/2); % Initial signal window index
sst = sed - seglen;
if kp > length(par.noiseb)
itax = find(tax >= par.noiseb(end) & tax <= par.noisee(end));
else
itax = find(tax >= par.noiseb(kp) & tax <= par.noisee(kp));
end
nst = itax(1); % Initial signal window index
ned = nst + seglen;
snr = snrarray(y([sst:sed],:),y([nst:ned],:),pars);
snrexp(k,kpn) = 10*log10(snr);
for batak = 1:length(batar)
bata = batar(batak);
% Create Images from RF Perimeter Arr