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

Revamp plotting methods.

We want to trim the fat.
parent d7f5a8e5
function [ hf, ax1, ax2, ax3 ] = plot_fit_plane( obj, scale_bar_length )
%PLOT_FIT_PLANE Figure with the local plan orientation for a collection of epicells.
function [ hf, ax1, ax2, ax3 ] = figure_tissue_orientation( obj, scale_bar_length )
%FIGURE_ORIENTATION Figure with the local tissue orientation for a collection of epicells.
if nargin < 2
scale_bar_length = 10;
end
epicells = obj.epicells;
angles = vertcat( epicells.euler_angles );
hf = figure( 'Position', [ 1204 20 600 1000 ] );
ax1 = subplot( 3, 1, 1 );
hold on
axis equal
add_plot_euler_alpha( obj, ax1 );
alphas = rad2deg( angles( :, 1 ) );
% Wrap back to 0 - 180º.
neg_alphas = alphas < 0;
alphas( neg_alphas ) = 180 + alphas( neg_alphas );
obj.plot_values_contour( alphas, ax1 );
colormap( ax1, 'hsv' )
colorbar(ax1)
ax2 = subplot( 3, 1, 2 );
hold on
axis equal
add_plot_euler_beta( obj, ax2 );
betas = rad2deg( angles( :, 2 ) );
% Wrap back to 0 - 90º.
large_betas = betas > 90;
betas( large_betas ) = 180 - betas( large_betas );
obj.plot_values_contour( betas, ax2 );
colorbar(ax2)
ax3 = subplot( 3, 1, 3 );
hold on
axis equal
add_plot_euler_gamma( obj, ax3 );
gammas = rad2deg( angles( :, 3 ) );
neg_gammas = gammas < 0;
gammas( neg_gammas ) = 180 + gammas( neg_gammas );
obj.plot_values_contour( gammas, ax3 );
colormap( ax3, 'hsv' )
colorbar(ax3)
add_plot_scalebar( obj, scale_bar_length, ax3 );
obj.add_plot_scalebar( scale_bar_length, ax3 );
linkaxes( [ ax3 ax2 ax1 ] )
axis( ax1, 'off' )
......
function [ hf, he ] = plot_fit_ellipse( obj, scale_bar_length )
%PLOT_FIT_ELLIPSE Plot the 2D ellipses on the tissue surface.
if nargin < 2
scale_bar_length = 10;
end
hf = figure( 'Position', [ 1204 20 600 500 ] );
hold on
axis equal
values = rad2deg( [ obj.epicells.proj_direction ]' );
cmap = 'hsv';
he = add_ellipse_variable( obj, values, cmap, gca );
add_plot_scalebar( obj, scale_bar_length, gca );
axis( gca, 'off' )
colorbar( gca )
title( gca, 'Main orientation of cell (º)', ...
'FontWeight', 'normal' )
end
function hts = add_plot_variable( obj, values, ax )
%ADD_PLOT_VARIABLE Plots the boundaries as patches, colored by the specified values.
function hts = plot_values_contour( obj, values, ax )
%PLOT_VALUES_CONTOUR Plot the tissue with the cell exact contours, colored by the specified values.
%
% INPUTS:
% obj: a deproj object, with N epicells.
% values - a N x 1 array with values to use for coloring.
% ax - the axes to plot in.
%
% OUTPUT:
% a N x 1 array of handles to the cell polygon objects.
epicells = obj.epicells;
boundaries = { epicells.boundary };
......
function hts = plot_values_ellipse( obj, values, cmap, ax, min_val_col, max_val_col )
%PLOT_VALUES_ELLIPSE Plot the tissue with cells as ellipses, colored by the specified values.
%
% INPUTS:
%
% obj: a deproj object, with N epicells.
%
% values - a N x 1 array with values to use for coloring.
%
% cmap - the color-map to use for coloring. Optional, default value id
% the parula colormap.
%
% ax - the axes to plot in. Optional, default is current axes.
%
% min_val_col - min value to generate color. Optional, default is the
% minimal value of the specified values.
%
% max_val_col - max value to generate color. Optional, default is the
% maximal value of the specified values.
%
% OUTPUT:
%
% a 2N x 1 array of handles to the ellipse and major-axis line objects.
%
epicells = obj.epicells;
n_objects = numel( epicells );
hts = NaN( 2 * n_objects, 1 );
minv = min( values );
maxv = max( values );
if nargin < 3
cmap = 'parula';
end
if nargin < 4
ax = gca;
end
if nargin < 5
min_val_col = minv;
end
if nargin < 6
max_val_col = maxv;
end
colors = colormap( ax, cmap );
if n_objects > 1000, lw = 1; else, lw = 2; end
idx = @(v) 1 + round( (v - min_val_col)/(max_val_col - min_val_col) * ( size( colors, 1 ) - 1 ) );
for i = 1 : n_objects
o = epicells( i );
h1 = o.plot_ellipse_3d( 23, ax );
h2 = o.plot_ellipse_3d( 3, ax );
hts( 2 * i - 1 ) = h1;
hts( 2 * i ) = h2;
val = values( i );
j = idx( val );
j = max( [ 1 j ] );
j = min( [ size( colors, 1 ) j ] );
set( [ h1 h2 ], ...
'Color', colors( j, : ), ...
'LineWidth', lw )
end
set( ax, 'CLim', [ min_val_col max_val_col ] )
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