% drawFigures.m
%   Call after runMCXspectrum_*.m 

%% Show depth-profile of tissue layers
figure(2);clf
%sz0 = get(0,'screensize')/2;
%pos = round([0.129 0.171 0.7 1.6].*sz0([3 4 3 4]));
%set(figure(2),'position',pos)

fz=12; % fontsize for labels

subplot(211)
plot([1:Nz]',squeeze(cfg.vol(Nx/2,Ny/2,:)),'ro-')
hold on
text(1,.15,'air boundary=0 @ iz=1','fontsize',fz)
for i=1:3
    if i==1 % epidermis
        iz1=2;
    else
        iz1=2+sum(nd(1:i-1));
    end
    z1=dxyz*(iz1-1);
    iz2=1+sum(nd(1:i));
    z2=dxyz*(iz2-1);
    s=sprintf('%s %d%s%d (%0.3f %s %0.3f mm)',...
    tissue(i).name,iz1,'\rightarrow',iz2,...
    z1,'\rightarrow',z2);
    text((3+sum(nd(1:i))),i,s,'fontsize',fz)
end
i=4;
iz1=i+sum(nd(1:i-1));
z1=dxyz*(iz1-1);
iz2=i-3+sum(nd(1:i));
z2=dxyz*(iz2);
s=sprintf('%s %d%s%d (%0.3f %s %0.3f mm)',...
tissue(i).name,iz1,'\rightarrow',iz2,...
z1,'\rightarrow',z2);
text(35,i-.2,s,'fontsize',fz)

xlabel('depth pointer, iz')
ylabel('tissue type')
set(gca,'fontsize',16)
axis([0 100 0 5])

%% Show side-view of tissue layers
subplot(212)

Vzx=squeeze(cfg.vol(:,Ny/2,:))';
imagesc([1:Nx]*dxyz,[1:Nz]*dxyz,Vzx)
hold on
text(0.05,0.045,'epidermis','fontsize',14,'color','w')
text(0.05,.15,'papillary dermis','fontsize',14)
text(0.05,0.34,'vascular plexus','fontsize',14)
text(0.05,0.6,'reticular dermis','fontsize',14)

axis equal
colorbar
axis([dxyz 1 dxyz 1])

%% Plot R,T spectra
figure(3);clf
%sz0 = get(0,'screensize')/2;
%pos = round([0.918 0.171 0.700 1.6].*sz0([3 4 3 4]));
%set(figure(3),'position',pos)

subplot(211)
imagesc(Rxy)
axis equal image
xlabel('x [mm]')
ylabel('y [mm]')
title('R(y,x) [mm^{-2}]')
colorbar

subplot(212)
plot(nmm,R,'ro-','linewidth',2)
hold on
plot(nmm,T,'bo-','linewidth',2)
xlabel('Wavelength')
ylabel('R_d, T_t')
title('skin: epi,pap,plx,ret','fontweight','normal')
set(gca,'fontsize',16)
axis([300 1000 0 1])

