Commit f3389b62 authored by Jean-Yves TINEVEZ's avatar Jean-Yves TINEVEZ
Browse files

Plotting routines relying on the new epicell class.

parent d0fe0d60
function hts = add_plot_euler_alpha( ax, epicells )
%ADD_PLOT_EULER_ALPHA Add the tissue plot colored with the 1st euler angle.
angles = vertcat( epicells.euler_angles );
alphas = rad2deg( angles( :, 1 ) );
% Wrap back to 0 - 180º.
neg_alphas = alphas < 0;
alphas( neg_alphas ) = 180 + alphas( neg_alphas );
hts = add_plot_variable( ax, { epicells.boundary }, alphas );
end
function hts = add_plot_euler_beta( ax, epicells )
%ADD_PLOT_EULER_BETA Add the tissue plot colored with the 2nd euler angle.
angles = vertcat( epicells.euler_angles );
betas = rad2deg( angles( :, 2 ) );
% Wrap back to 0 - 90º.
large_betas = betas > 90;
betas( large_betas ) = 180 - betas( large_betas );
hts = add_plot_variable( ax, { epicells.boundary }, betas );
end
function hts = add_plot_euler_gamma( ax, epicells )
%ADD_PLOT_EULER_GAMMA Add the tissue plot colored with the 3rd euler angle.
angles = vertcat( epicells.euler_angles );
gammas = rad2deg( angles( :, 3 ) );
hts = add_plot_variable( ax, { epicells.boundary }, gammas );
end
function hts = add_plot_id( epicells, ax )
%ADD_PLOT_ID Add the epicell ids to the specified plot axes.
n_objects = numel( epicells );
hts = NaN( n_objects, 1 );
for i = 1 : n_objects
o = objects( i );
hts(i ) = text( ax, o.center(1), o.center(2), o.center(3) + 0.5, num2str( o.id ), ...
'HorizontalAlignment', 'center', ...
'VerticalAlignment', 'middle' );
end
end
function [ hsb, ht ] = add_plot_scalebar( ax, epicells, length, units )
%ADD_PLOT_SCALEBAR Add a scale-bar to the plot.
% We used the collection of epicells to determine a sensible position.
POS_RATIO = 0.10; % of width to position the bar
THICKNESS_RATIO = 0.02;
p = vertcat( epicells.boundary );
minp = double( min( p ) );
maxp = double( max( p ) );
rangep = maxp - minp;
xpos = minp(1) + POS_RATIO * rangep( 1 );
ypos = minp(2) - POS_RATIO * rangep( 2 );
thickness = THICKNESS_RATIO * rangep( 2 );
xs = [
xpos % 1
xpos % 2
xpos + length % 3
xpos + length % 4
xpos + length % 5
xpos + length % 6
xpos % 7
xpos % 8
];
ys = [
ypos % 1
ypos + 0.25 * thickness % 2
ypos + 0.25 * thickness % 3
ypos % 4
ypos + thickness % 5
ypos + 0.75 * thickness % 6
ypos + 0.75 * thickness % 7
ypos + thickness % 8
];
zs = repmat( maxp(3), 8, 1 );
hsb = patch( ax, xs, ys, zs, 'k' );
ht = text( mean(xs), min(ys), mean(zs), ...
sprintf('%.0f %s', length, units ), ...
'HorizontalAlignment', 'center', ...
'VerticalAlignment', 'top' );
end
function hts = add_plot_variable( ax, boundaries, values )
%ADD_PLOT_VARIABLE Plots the boundaries as patches, colored by the specified values.
n_objects = numel( boundaries );
hts = NaN( n_objects, 1 );
for i = 1 : n_objects
p = boundaries{ i };
val = values( i );
hts(i ) = patch( ax, p(:,1), p(:,2), p(:,3), val, ...
'LineWidth', 2 );
end
end
function [ hf, ax1, ax2, ax3 ] = plot_fit_plane( epicells )
%PLOT_FIT_PLANE Figure with the local plan orientation for a collection of epicells.
hf = figure( 'Position', [ 1204 20 600 1000 ] );
ax1 = subplot( 3, 1, 1 );
hold on
axis equal
add_plot_euler_alpha( ax1, epicells );
colormap( ax1, 'hsv' )
colorbar(ax1)
ax2 = subplot( 3, 1, 2 );
hold on
axis equal
add_plot_euler_beta( ax2, epicells );
colorbar(ax2)
ax3 = subplot( 3, 1, 3 );
hold on
axis equal
add_plot_euler_gamma( ax3, epicells );
colormap( ax3, 'hsv' )
colorbar(ax3)
add_plot_scalebar( ax3, epicells, 10, 'µm' );
linkaxes( [ ax3 ax2 ax1 ] )
axis( ax1, 'off' )
axis( ax2, 'off' )
axis( ax3, 'off' )
title( ax1, 'Orientation of plane (º)', ...
'FontWeight', 'normal' )
title( ax2, 'Slope of plane (º)' , ...
'FontWeight', 'normal' )
title( ax3, 'Cell main orientation in plane (º)' , ...
'FontWeight', 'normal' )
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment