function tissue = makeTissueList_skinWorkshop(nm,MU2,PRINTON)
% function tissueProps = makeTissueList_skinWorkshop(nm,PRINTON)
%   Returns the tissue parameters [B S W C M musp500 a b n]
%   and the optical properties [mua mus g musp] at the wavelength nm.
%   --> NOTE: These are estimated tissue parameters, 
%       guided by a rather sparse literature.
%
%   if PRINTON==1, printout parameters and properties. 0=don't.
%
%   USES: SpectralLIBMUmm.mat (All properties in [1/mm].)
%
%   Tissue Parameters:
%   tissue.B = blood content (volume fraction) B=1 -> 150 g.HGb/liter
%   tissue.S = hemoglobin oxygen saturation of mixed arterio-venous blood.
%   tissue.W = water content
%   tissue.C = carotenoids (scales absorption spectrum)
%   tissue.M = melanosome volume fraction
%   tissue.a = reduced scattering at 500 nm: mus*(1-g)@500nm
%   tissue.b = scattering power
%   tissue.n = refractive index mismatch at surface (n_tissue/n_air)
%
%   Tissue Optical properties:
%   tissue.mua = absorption coefficient [cm^-1]
%   tissue.mus = scattering coefficient [cm^-1]
%   tissue.g   = anisotropy of scatter [dimensionless]
%   tissue.musp = reduced scattering coeff. [cm^-1] = mus*(1-g)
%%%%

% Prior to calling function, do this:
% load SpectralLIBMUmmWorkshop.mat % --> nmLIB(701,1). MU(701,6) [cm^-1]
% MU(:,1) = muaoxy of whole blood (150 g HGb/liter)
% MU(:,2) = muadeoxy of whole blood
% MU(:,3) = muawater
% MU(:,4) = muacarotenoids
% MU(:,5) = mua of interior of a cutaneous melanosome
% MU(:,6) = muafat
% 
% Interpolate
% MU2 = interp1(nmLIB,MU,nm); %cm^-1

CC = 0.0; % Carotenoids (scales carotenoid absorption)

%% Create tissueList

j=1;
tissue(j).name  = 'epidermis';
B       = 0;    % blood volume fraction
S       = 0;    % oxygen saturation
W       = 0.65; % water content
C       = CC; % carotenoids ([a.u.] scale the absorption spectrum)
M       = 0.02; % melanosome volume fraction
a       = 2.0;   % scattering strength = mus(1-g)@500nm
b       = 1.5; % scattering power
gg      = 0.9;  % anisotropy of scatter
musp    = a*(nm/500).^-b;       % reduced scattering coeff.
X       = [B*S B*(1-S) W C M]';   % scalars
tissue(j).mua = MU2(:,1:5)*X;   % absorption coeff.
tissue(j).mus = musp/(1-gg);    % scattering coeff.
tissue(j).g   = gg;             % anisotropy of scatter
%
tissue(j).B     = B;
tissue(j).S     = S;
tissue(j).W     = W;
tissue(j).C     = C;
tissue(j).M     = M;
tissue(j).a     = a;
tissue(j).b 	= b;
tissue(j).n     = 1.4;

j = 2;
tissue(j).name = 'pap.dermis';
B       = 0.0001; 
S       = 0.75;
W       = 0.60;
C       = CC; % carotenoids ([a.u.] scale the absorption spectrum)
M       = 0;
a       = 3.0;
b       = 2;
gg      = 0.90;
musp    = a*(nm/500).^-b;
X       = [B*S B*(1-S) W C M]';   % scalars
tissue(j).mua = MU2(:,1:5)*X;   % absorption coeff.
tissue(j).mus = musp/(1-gg);
tissue(j).g   = gg;
%
tissue(j).B     = B;
tissue(j).S     = S;
tissue(j).W     = W;
tissue(j).C     = C;
tissue(j).M     = M;
tissue(j).a     = a;
tissue(j).b 	= b;
tissue(j).n    	= 1.4;

j=3;
tissue(j).name  = 'plexus';
B       = 0.003;
S       = 0.75;
W       = 0.60;
C       = CC; % carotenoids ([a.u.] scale the absorption spectrum)
M       = 0;
a       = 3.0;
b       = 2;
gg      = 0.80;
musp    = a*(nm/500).^-b;
X       = [B*S B*(1-S) W C M]';   % scalars
tissue(j).mua = MU2(:,1:5)*X;   % absorption coeff.
tissue(j).mus = musp/(1-gg);
tissue(j).g   = gg;
%
tissue(j).B     = B;
tissue(j).S     = S;
tissue(j).W     = W;
tissue(j).C     = C;
tissue(j).M     = M;
tissue(j).a     = a;
tissue(j).b 	= b;
tissue(j).n   	= 1.4;

j = 4;
tissue(j).name = 'ret.dermis';
B       = 0.0005; 
S       = 0.75;
W       = 0.55;
C       = CC; % carotenoids ([a.u.] scale the absorption spectrum)
M       = 0;
a       = 2.0;
fray    = 0.62;
b       = 2;
gg      = 0.80;
musp    = a*(nm/500).^-b;
X       = [B*S B*(1-S) W C M]';   % scalars
tissue(j).mua = MU2(:,1:5)*X;   % absorption coeff.
tissue(j).mus = musp/(1-gg);
tissue(j).g   = gg;
%
tissue(j).B     = B;
tissue(j).S     = S;
tissue(j).W     = W;
tissue(j).C     = C;
tissue(j).M     = M;
tissue(j).a     = a;
tissue(j).b 	= b;
tissue(j).n    	= 1.4;

%%%%%%%%%%%%%%%%
j=5;
tissue(j).name  = 'air';
tissue(j).mua   = 0.0001; % Negligible absorption yet still tracks, 
tissue(j).mus   = 100.0;    % but take steps in air
tissue(j).g     = 1.0;    % and don't scatter.
%
tissue(j).B     = 0;
tissue(j).S     = 0;
tissue(j).W     = 0;
tissue(j).C     = 0;
tissue(j).M     = 0;
tissue(j).a     = 0;
tissue(j).b 	= 0;
tissue(j).n    	= 1.0;

j=6;
tissue(j).name  = 'water';
tissue(j).mua   = MU2(:,3);
tissue(j).mus   = 100;   % Take steps in water,
tissue(j).g     = 1.0;  % but don't scatter.
%
tissue(j).B     = 0;
tissue(j).S     = 0;
tissue(j).W     = 1;
tissue(j).C     = 0;
tissue(j).M     = 0;
tissue(j).a     = 0;
tissue(j).b 	= 0;
tissue(j).n    	= 1.33;

j=7;
tissue(j).name  = 'blood';
B       = 1.00;
S       = 0.75;
W       = 0.95;
C       = CC; % carotenoids ([a.u.] scale the absorption spectrum)
M       = 0;
a       = 1.0;
b       = 1.0;
gg      = 0.90;
musp    = a*(nm/500).^-b;
X       = [B*S B*(1-S) W C M]';   % scalars
tissue(j).mua = MU2(:,1:5)*X;   % absorption coeff.
tissue(j).mus = musp/(1-gg);
tissue(j).g   = gg;
%
tissue(j).B     = B;
tissue(j).S     = S;
tissue(j).W     = W;
tissue(j).C     = C;
tissue(j).M     = M;
tissue(j).a     = a;
tissue(j).b     = b;
tissue(j).n    	= 1.4;

j=8;
tissue(j).name  = 'basal layer';
B       = 0;
S       = 0;
W       = 0.75;
C       = CC; % carotenoids ([a.u.] scale the absorption spectrum)
M       = 3*tissue(1).M;
a       = 2.0;
b       = 1.45;
gg      = 0.9;
musp    = a*(nm/500).^-b;
X       = [B*S B*(1-S) W C M]';   % scalars
tissue(j).mua = MU2(:,1:5)*X;   % absorption coeff.
tissue(j).mus = musp/(1-gg);
tissue(j).g   = gg;
%
tissue(j).B     = B;
tissue(j).S     = S;
tissue(j).W     = W;
tissue(j).C     = C;
tissue(j).M     = M;
tissue(j).a     = a;
tissue(j).b 	= b;
tissue(j).n    	= 1.4;



%%
if PRINTON
    fprintf('wavelength = %0.0f nm\n',nm)
    disp('---- tissue Parameters----')
    disp(sprintf('\t%15s\t%s\t%s\t%s\t%s\t%s\t%s\t%s',...
        'tissue','B','S','W','C','M','a','b'))
    for i=1:length(tissue)
        disp(sprintf('%d\t%15s\t%0.4f\t%0.3f\t%0.3f\t%0.3f\t%0.3f\t%0.2f\t%0.3f\t%0.3f',...
            i,tissue(i).name, tissue(i).B, tissue(i).S,tissue(i).W,...
            tissue(i).C,tissue(i).M,tissue(i).a, tissue(i).b))
    end
    disp(' ')

    disp('---- tissue Optical Properties ------')
    disp(sprintf('\t%15s\t%10s\t%s\t%s\t%s\t%s','tissue','mua','mus','g','musp','n'))
    for i=1:length(tissue)
        disp(sprintf('%d\t%15s\t%10.5f\t%0.1f\t%0.3f\t%0.1f\t%0.2f',...
            i,tissue(i).name, tissue(i).mua,tissue(i).mus,tissue(i).g,...
            tissue(i).mus*(1-tissue(i).g),tissue(i).n))
    end
    disp(' ')
end

