  function [density, mtype] = xray_read_dens_yl(mtype, varargin)
%|function [density, mtype] = xray_read_dens_yl(mtype, [options])
%|
%| Read densities for  given material type(s).
%| 
%| in
%|	mtype			'aluminum', 'copper', ...
%|				(optionally can be a cell array of several)
%| option
%|	'units'		cm | mm	default: cm
%| out
%|	density			g/cm^3, scalar, or vector if mtype is cell array
%|
%| Copyright 2004-05-1, Jeff Fessler, University of Michigan

% default is to show example
if nargin < 1, help(mfilename), error(mfilename), end
if streq(mtype, 'test'), xray_read_dens_test, return, end

arg.units = 'cm';
arg = vararg_pair(arg, varargin);

if iscell(mtype)
	for ll=1:length(mtype)
		density(ll) = xray_read_dens_yl(mtype{ll}, 'units', arg.units);
	end
return
end

% densities, all in g/cm^3
% http://www.flukebiomedical.com/RMS/productManuals/76-430-1.pdf

switch mtype
case 'aluminum'
	density = 2.7;
case 'bone'
	% http://physics.nist.gov/PhysRefData/XrayMassCoef/tab2.html
	density = 1.92; % cortical bone value
case 'boron'
	density = 2.34; % http://en.wikipedia.org/wiki/Boron
case 'carbon-graphite'
	density = 1.78; % from catsim 3.2 materials/graphite
case 'cesium'
	density = 1.93; % http://en.wikipedia.org/wiki/Cesium
case 'copper'
	density = 0.92;
case 'csi'
	density = 4.51;
case 'gadolinium'
	density = 7.9;
case 'iodine'
	density = 4.93;
case 'iron'
	density = 7.874; % http://en.wikipedia.org/wiki/Iron
case 'lead'
	density = 11.34;
case 'water'
	density = 1;
case 'polyethylene'
	density = 0.950;
case {'lexan', 'polycarbonate'} % C16 H14 O3
	density = 1.190;
case 'polystyrene'
	density = 1.050;
case {'acrylic', 'pmma', 'plexiglass', 'lucite'}
	density = 1.19; % http://en.wikipedia.org/wiki/Acrylic_glass
case 'teflon'
	density = 2.214;
case 'titanium'   
    density = 4.53; % from catsim 3.2 materials/ti
case 'molybdenum'
    density = 10.28;  % added by Yong Long, 2011-03-04
case 'air'
    density = 0;  % added by Yong Long, 2011-03-04    
case 'adipose'
    density = 0.9;  %google, 0.95 from Elbakri:03:sfs
case 'blood'
    density = 1.06;  %from  Elbakri:03:sfs  
case 'lung'
    density = 1.05;  %from  Elbakri:03:sfs     
case 'muscle'
    density = 1.05;  %from  Elbakri:03:sfs      
case 'omnipaque300'
    density = 1.349;  %omnipaque document from GE healthcare (google it!)      
otherwise
	error('unknown material density "%s"', mtype)
end

switch arg.units
case 'mm'
	density = density / 1000;
case 'cm'
	;
otherwise
	fail('bad units "%s"', arg.units)
end


%
% example usage
%
function xray_read_dens_test
mtype = {'aluminum', 'copper', 'lead', 'lexan'}
density = xray_read_dens(mtype)
