pb_vLookup.m 2.29 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
function cfg = pb_vLookup(cfg,varargin)
% PB_VLOOKUP()
%
% PB_VLOOKUP()  ...
%
% See also ...

% PBToolbox (2018): JJH: j.heckman@donders.ru.nl


   if nargin<1
      cfg = [];
   end

  	%% LED connections
   % [Azimuth (deg) Elevation (deg) LED #]
   % azimuths and elevations were measured by Sebastian Ausili in June 2015
   cfg					= pb_vLSCpositions(cfg);
Jesse Heckman's avatar
Jesse Heckman committed
19 20
   cfg.nstimchan		= 2^6; % number of PLC and MUX channels
   cfg.nspeakers		= 63; % actual number of speakers
21 22 23
   cfg.stimchan		= (1:cfg.nstimchan)-1;

   %% Add missing channels
Jesse Heckman's avatar
Jesse Heckman committed
24
   n                 = size(cfg.lookup,1);
25 26 27 28 29 30 31 32 33
   cfg.lookup			= [cfg.lookup; NaN(cfg.nstimchan-n,3)]; % add missing channel data as NaNs
   sel					= ismember(cfg.stimchan,cfg.lookup(:,3)); % lookup existing channels
   cfg.missingchan		= cfg.stimchan(~sel); % get missing channels
   sel					= isnan(cfg.lookup(:,3)); % search for missing channels in lookup-table
   cfg.lookup(sel,3)	= cfg.missingchan; % put missing channel numbers in lookup-table
   cfg.lookup			= sortrows(cfg.lookup,[3 1 2]); % sort lookup-table by channel number

   %% Speakers

Jesse Heckman's avatar
Jesse Heckman committed
34
   cfg.nMUX          = 4; % 2 multiplexers
35 36 37 38
   cfg.nMUXbit			= 16; % 16 bits per MUX
   cfg.MUXind			= 1:cfg.nMUX;
   cfg.MUXbit			= 1:cfg.nMUXbit;

Jesse Heckman's avatar
Jesse Heckman committed
39
   LookUp(:,1)			= cfg.stimchan; % Stimulus channel 0-63
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
   idx					= LookUp(:,1)+1;
   LookUp(:,2)			= ceil(idx/(2^4));% MUX number
   idx					= mod(idx,2^4);
   idx(idx==0)			= 2^4;
   LookUp(:,3)			= idx; % TDT bit

   %% Combine
   % [PLC-Chan# RP2# MUX# BIT# AZ EL]
   cfg.lookup		= [cfg.lookup(:,3) LookUp(:,2:3) cfg.lookup(:,1)  cfg.lookup(:,2)];
   cfg.lookuplabel = {'Channel' 'MUX' 'Bit' 'Azimuth' 'Elevation'};
   % cfg.lookuplabel = {'Channel' 'RP2' 'MUX' 'Bit' 'Azimuth' 'Elevation'};


   %% Interpolant
   x		= cfg.lookup(:,4);
   y		= cfg.lookup(:,5);
   z		= cfg.lookup(:,1);
   sel		= ~isnan(x);
   x		= x(sel);
   y		= y(sel);
   z		= z(sel);
   cfg.interpolant		= scatteredInterpolant(x,y,z,'nearest');
   
end
 
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % 
%                                                           %
%       Part of Programmeer Beer Toolbox (PBToolbox)        %
%       Written by: Jesse J. Heckman (2018)                 %
%                                                           %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %