diff --git a/RunExample.m b/RunExample.m index 2d7d190104520f3fe37121bfb15f925dba394596..ee71521fb308b52298752b1e3be0702f5ff4b5e3 100755 --- a/RunExample.m +++ b/RunExample.m @@ -71,8 +71,17 @@ dpr = deproj.from_heightmap( ... %% Plot morphological parameters. close all -plot_sizes( dpr ); -plot_fit_plane( dpr ); -plot_fit_ellipse( dpr ); -plot_curvatures( dpr ); -plot_distorsions( dpr ); + +fprintf( 'Plotting the cell sizes.\n' ) +dpr.figure_cell_sizes; + +fprintf( 'Plotting the tissue orientation.\n' ) +dpr.figure_tissue_orientation; + +fprintf( 'Plotting the cell elongation and direction.\n' ) +dpr.figure_cell_elongation; + +fprintf( 'Plotting the impact of projection distorsion.\n' ) +dpr.figure_distorsions; + +fprintf( 'Finished.\n' ) diff --git a/RunExample2.m b/RunExample2.m index 09e9f61b2d8914fd98d3902d018914166d08a235..1c19344a8f15a629c253053834a0e8c43822a350 100755 --- a/RunExample2.m +++ b/RunExample2.m @@ -48,8 +48,17 @@ dpr = deproj.from_bellaiche( ... %% Plot morphological parameters. close all -plot_sizes( dpr ); -plot_fit_plane( dpr ); -plot_fit_ellipse( dpr ); -plot_curvatures( dpr ); -plot_distorsions( dpr ); + +fprintf( 'Plotting the cell sizes.\n' ) +dpr.figure_cell_sizes; + +fprintf( 'Plotting the tissue orientation.\n' ) +dpr.figure_tissue_orientation; + +fprintf( 'Plotting the cell elongation and direction.\n' ) +dpr.figure_cell_elongation; + +fprintf( 'Plotting the impact of projection distorsion.\n' ) +dpr.figure_distorsions; + +fprintf( 'Finished.\n' ) diff --git a/src/@deproj/add_ellipse_variable.m b/src/@deproj/add_ellipse_variable.m deleted file mode 100644 index de2c124174f68c862b822601c8dc4e311e74447b..0000000000000000000000000000000000000000 --- a/src/@deproj/add_ellipse_variable.m +++ /dev/null @@ -1,31 +0,0 @@ -function hts = add_ellipse_variable( obj, values, cmap, ax ) -%ADD_ELLIPSE_VARIABLE Plots the ellipses, colored by the specified values. - - epicells = obj.epicells; - n_objects = numel( epicells ); - hts = NaN( 2 * n_objects, 1 ); - - minv = min( values ); - maxv = max( values ); - - colors = colormap( cmap ); - - if n_objects > 1000, lw = 1; else, lw = 2; end - - idx = @(v) 1 + round( (v - minv)/(maxv - minv) * ( 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 ) = h1; - val = values( i ); - j = idx( val ); - set( [ h1 h2 ], ... - 'Color', colors( j, : ), ... - 'LineWidth', lw ) - end - set( ax, 'CLim', [ minv maxv ] ) -end diff --git a/src/@deproj/add_plot_area.m b/src/@deproj/add_plot_area.m deleted file mode 100644 index e85c011211f80400698edd2ee9fe4d0c502af7f2..0000000000000000000000000000000000000000 --- a/src/@deproj/add_plot_area.m +++ /dev/null @@ -1,9 +0,0 @@ -function hts = add_plot_area( obj, ax ) -%ADD_PLOT_AREA Add the tissue plot colored with the cell area. - - epicells = obj.epicells; - areas = vertcat( epicells.area ); - - hts = add_plot_variable( obj, areas, ax ); -end - diff --git a/src/@deproj/add_plot_curvature_gauss.m b/src/@deproj/add_plot_curvature_gauss.m deleted file mode 100644 index 98343fb26f3d339b70c510745331ed22efb90178..0000000000000000000000000000000000000000 --- a/src/@deproj/add_plot_curvature_gauss.m +++ /dev/null @@ -1,10 +0,0 @@ -function hts = add_plot_curvature_gauss( obj, ax ) -%ADD_PLOT_CURVATURE_GAUSS Add the tissue plot colored with the Gaussian curvature. - - epicells = obj.epicells; - curvs = vertcat( epicells.curvatures ); - gauss_curv = curvs( :, 2 ); - - hts = add_plot_variable( obj, gauss_curv, ax ); -end - diff --git a/src/@deproj/add_plot_curvature_k1.m b/src/@deproj/add_plot_curvature_k1.m deleted file mode 100644 index d8f4cb20f62c953267b7c58ddb5cd520d592f438..0000000000000000000000000000000000000000 --- a/src/@deproj/add_plot_curvature_k1.m +++ /dev/null @@ -1,10 +0,0 @@ -function hts = add_plot_curvature_k1( obj, ax ) -%ADD_PLOT_CURVATURE_K1 Add the tissue plot colored with the first principal curvature. - - epicells = obj.epicells; - curvs = vertcat( epicells.curvatures ); - k1_curv = curvs( :, 3 ); - - hts = add_plot_variable( obj, k1_curv, ax ); -end - diff --git a/src/@deproj/add_plot_curvature_k2.m b/src/@deproj/add_plot_curvature_k2.m deleted file mode 100644 index 7289c32853796c6c6df6f7ff0ab702f7c76b76f1..0000000000000000000000000000000000000000 --- a/src/@deproj/add_plot_curvature_k2.m +++ /dev/null @@ -1,10 +0,0 @@ -function hts = add_plot_curvature_k2( obj, ax ) -%ADD_PLOT_CURVATURE_K2 Add the tissue plot colored with the first principal curvature. - - epicells = obj.epicells; - curvs = vertcat( epicells.curvatures ); - k2_curv = curvs( :, 4 ); - - hts = add_plot_variable( obj, k2_curv, ax ); -end - diff --git a/src/@deproj/add_plot_curvature_mean.m b/src/@deproj/add_plot_curvature_mean.m deleted file mode 100644 index 989a3fe99ea5c2932df0be9d3c47a22d39255945..0000000000000000000000000000000000000000 --- a/src/@deproj/add_plot_curvature_mean.m +++ /dev/null @@ -1,10 +0,0 @@ -function hts = add_plot_curvature_mean( obj, ax ) -%ADD_PLOT_CURVATURE_MEAN Add the tissue plot colored with the mean curvature. - - epicells = obj.epicells; - curvs = vertcat( epicells.curvatures ); - mean_curv = curvs( :, 1 ); - - hts = add_plot_variable( obj, mean_curv, ax ); -end - diff --git a/src/@deproj/add_plot_distorsion_area.m b/src/@deproj/add_plot_distorsion_area.m deleted file mode 100644 index 66737dc1c57b51385c826abf4861f3b597cdcdcf..0000000000000000000000000000000000000000 --- a/src/@deproj/add_plot_distorsion_area.m +++ /dev/null @@ -1,12 +0,0 @@ -function hts = add_plot_distorsion_area( obj, ax ) -%ADD_PLOT_DISTORSION_AREA Add the tissue plot colored with the error on -%cell area caused by the projection. - - epicells = obj.epicells; - areas = vertcat( epicells.area ); - uncorr_areas = vertcat( epicells.uncorrected_area ); - err = 1 - uncorr_areas ./ areas; - - hts = add_plot_variable( obj, 100. * err, ax ); -end - diff --git a/src/@deproj/add_plot_distorsion_perimeter.m b/src/@deproj/add_plot_distorsion_perimeter.m deleted file mode 100644 index c46f72d6fc8f193cc897a7e4de09390b09bf1bc8..0000000000000000000000000000000000000000 --- a/src/@deproj/add_plot_distorsion_perimeter.m +++ /dev/null @@ -1,12 +0,0 @@ -function hts = add_plot_distorsion_perimeter( obj, ax ) -%ADD_PLOT_DISTORSION_PERIMETER Add the tissue plot colored with the error on -%cell perimeter caused by the projection. - - epicells = obj.epicells; - perims = vertcat( epicells.perimeter ); - uncorr_perims = vertcat( epicells.uncorrected_perimeter ); - err = 1 - uncorr_perims ./ perims; - - hts = add_plot_variable( obj, 100. * err, ax ); -end - diff --git a/src/@deproj/add_plot_euler_alpha.m b/src/@deproj/add_plot_euler_alpha.m deleted file mode 100644 index f20cce6291bc921c40a0c4588655a597d6c9c59a..0000000000000000000000000000000000000000 --- a/src/@deproj/add_plot_euler_alpha.m +++ /dev/null @@ -1,14 +0,0 @@ -function hts = add_plot_euler_alpha( obj, ax ) -%ADD_PLOT_EULER_ALPHA Add the tissue plot colored with the 1st euler angle. - - epicells = obj.epicells; - 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( obj, alphas, ax ); -end - diff --git a/src/@deproj/add_plot_euler_beta.m b/src/@deproj/add_plot_euler_beta.m deleted file mode 100644 index 068972326e31a2e5ff877ba63d6ac4e7392fb2cb..0000000000000000000000000000000000000000 --- a/src/@deproj/add_plot_euler_beta.m +++ /dev/null @@ -1,14 +0,0 @@ -function hts = add_plot_euler_beta( obj, ax ) -%ADD_PLOT_EULER_BETA Add the tissue plot colored with the 2nd euler angle. - - epicells = obj.epicells; - 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( obj, betas, ax ); -end - diff --git a/src/@deproj/add_plot_euler_gamma.m b/src/@deproj/add_plot_euler_gamma.m deleted file mode 100644 index 8747535632cf99073df5f52ca0088ba8fed0acfd..0000000000000000000000000000000000000000 --- a/src/@deproj/add_plot_euler_gamma.m +++ /dev/null @@ -1,13 +0,0 @@ -function hts = add_plot_euler_gamma( obj, ax ) -%ADD_PLOT_EULER_GAMMA Add the tissue plot colored with the 3rd euler angle. - - epicells = obj.epicells; - angles = vertcat( epicells.euler_angles ); - gammas = rad2deg( angles( :, 3 ) ); - - neg_gammas = gammas < 0; - gammas( neg_gammas ) = 180 + gammas( neg_gammas ); - - hts = add_plot_variable( obj, gammas, ax ); -end - diff --git a/src/@deproj/add_plot_id.m b/src/@deproj/add_plot_ids.m similarity index 81% rename from src/@deproj/add_plot_id.m rename to src/@deproj/add_plot_ids.m index 847f02f44efb7174013f1aceec9313bd8e34d901..9ac2678072438e7c79c6db511f4795944bd94f16 100644 --- a/src/@deproj/add_plot_id.m +++ b/src/@deproj/add_plot_ids.m @@ -1,5 +1,5 @@ -function hts = add_plot_id( obj, ax ) -%ADD_PLOT_ID Add the epicell ids to the specified plot axes. +function hts = add_plot_ids( obj, ax ) +%ADD_PLOT_IDS Add the epicell ids to the specified plot axes. epicells = obj.epicells; n_objects = numel( epicells ); diff --git a/src/@deproj/add_plot_perimeter.m b/src/@deproj/add_plot_perimeter.m deleted file mode 100644 index 3f0434725193812737db3c6c296a209694cbeea4..0000000000000000000000000000000000000000 --- a/src/@deproj/add_plot_perimeter.m +++ /dev/null @@ -1,9 +0,0 @@ -function hts = add_plot_perimeter( obj, ax ) -%ADD_PLOT_PERIMETER Add the tissue plot colored with the cell perimeter. - - epicells = obj.epicells; - perims = vertcat( epicells.perimeter ); - - hts = add_plot_variable( obj, perims, ax ); -end - diff --git a/src/@deproj/deproj.m b/src/@deproj/deproj.m index ca7d9feada60f18b5adc3379a5d4848684dcf5e4..a9a6cdde6c8d065710428dc8cf7f0535848804bf 100644 --- a/src/@deproj/deproj.m +++ b/src/@deproj/deproj.m @@ -33,69 +33,35 @@ classdef deproj %% Generate figures. - % Figure with the local plan orientation for a collection of epicells. - [ hf, ax1, ax2, ax3 ] = plot_fit_plane( obj, scale_bar_length ) + % Figure with the local tissue orientation for a collection of epicells. + [ hf, ax1, ax2, ax3 ] = figure_tissue_orientation( obj, scale_bar_length ) - % Plot the 2D ellipses on the tissue surface. - [ hf, hc, he ] = plot_fit_ellipse( obj, scale_bar_length ) + % Plot the cell elongation and 2D orientation with cells as 2D ellipses. + [ hf, ax1, ax2 ] = figure_cell_elongation( obj, scale_bar_length ) % Figure with the local curvaure for a collection of epicells. - [ hf, ax1, ax2, ax3 ] = plot_curvatures( obj, scale_bar_length ) + [ hf, ax1, ax2, ax3 ] = figure_curvatures( obj, scale_bar_length ) % Figure with the cells area and perimeter. - [ hf, ax1, ax2 ] = plot_sizes( obj, scale_bar_length ) + [ hf, ax1, ax2 ] = figure_cell_sizes( obj, scale_bar_length ) % Figure with the error on uncorrected cells area and perimeter. - [ hf, ax1, ax2 ] = plot_distorsions( obj, scale_bar_length ) + [ hf, ax1, ax2 ] = figure_distorsions( obj, scale_bar_length ) %% Helpers. % They are public in case of. - % Add the tissue plot colored with the 1st euler angle. - hts = add_plot_euler_alpha( obj, ax ) - - % Add the tissue plot colored with the 2nd euler angle. - hts = add_plot_euler_beta( obj, ax ) - - % Add the tissue plot colored with the 3rd euler angle. - hts = add_plot_euler_gamma( obj, ax ) - % Add the epicell ids to the specified plot axes. - hts = add_plot_id( obj, ax ) + hts = add_plot_ids( obj, ax ) % Add a scale-bar to the plot. [ hsb, ht ] = add_plot_scalebar( obj, length, ax ) - % Plots the boundaries as patches, colored by the specified values. - hts = add_plot_variable( obj, values, ax ) - - %Plots the ellipses, colored by the specified values. - hts = add_ellipse_variable( obj, values, cmap, ax ) - - % Add the tissue plot colored with the mean curvature. - hts = add_plot_curvature_mean( obj, ax ) - - % Add the tissue plot colored with the Gaussian curvature. - hts = add_plot_curvature_gauss( obj, ax ) + % Plot the tissue with the cell exact contours, colored by the specified values. + hts = plot_values_contour( obj, values, ax ) - % Add the tissue plot colored with the first principal curvature. - hts = add_plot_curvature_k1( obj, ax ) - - % Add the tissue plot colored with the second principal curvature. - hts = add_plot_curvature_k2( obj, ax ) - - % Add the tissue plot colored with the cell area. - hts = add_plot_area( obj, ax ) - - % Add the tissue plot colored with the cell perimeter. - hts = add_plot_perimeter( obj, ax ) - - % Add the tissue plot colored with the error on cell area caused by the projection. - hts = add_plot_distorsion_area( obj, ax ) - - % Add the tissue plot colored with the error on cell perimeter caused by the projection. - hts = add_plot_distorsion_perimeter( obj, ax ) - + % Plot the tissue with cells as ellipses, colored by the specified values. + hts = plot_values_ellipse( obj, values, cmap, ax, min_val_col, max_val_col ) end diff --git a/src/@deproj/figure_cell_elongation.m b/src/@deproj/figure_cell_elongation.m new file mode 100644 index 0000000000000000000000000000000000000000..5531b2293f00e52790e99f3f321edce6757858ce --- /dev/null +++ b/src/@deproj/figure_cell_elongation.m @@ -0,0 +1,49 @@ +function [ hf, ax1, ax2 ] = figure_cell_elongation( obj, scale_bar_length ) +%FIGURE_CELL_ORIENTATION Plot the cell elongation and 2D orientation with cells as 2D ellipses. + + if nargin < 2 + scale_bar_length = 10; + end + + hf = figure( 'Position', [ 1204 20 600 650 ] ); + + %% Direction. + + ax1 = subplot( 2, 1, 1 ); + cmap1 = 'hsv'; + colormap( cmap1 ) + hold on + axis equal + + values1 = rad2deg( [ obj.epicells.proj_direction ]' ); + obj.plot_values_ellipse( values1, cmap1, ax1, -90, 90 ); + + axis( ax1, 'off' ) + colorbar( ax1 ) + + title( ax1, 'Main orientation of cell (º)', ... + 'FontWeight', 'normal' ) + + %% Elongation. + + ax2 = subplot( 2, 1, 2 ); + hold on + axis equal + + values2 = [ obj.epicells.eccentricity ]'; + cmap2 = 'parula'; + obj.plot_values_ellipse( values2, cmap2, ax2, 0, 1 ); + + axis( ax2, 'off' ) + colorbar( ax2 ) + + title( ax2, 'Eccentricity', ... + 'FontWeight', 'normal' ) + + + add_plot_scalebar( obj, scale_bar_length, ax2 ); + + + +end + diff --git a/src/@deproj/plot_sizes.m b/src/@deproj/figure_cell_sizes.m similarity index 66% rename from src/@deproj/plot_sizes.m rename to src/@deproj/figure_cell_sizes.m index 61f80ad63169978ff775f2e3354f8769cb99b8fb..7e16d48c0e46147204594ab85763045199eedea7 100644 --- a/src/@deproj/plot_sizes.m +++ b/src/@deproj/figure_cell_sizes.m @@ -1,22 +1,25 @@ -function [ hf, ax1, ax2 ] = plot_sizes( obj, scale_bar_length ) -%PLOT_SIZES Figure with the cells area and perimeter. +function [ hf, ax1, ax2 ] = figure_cell_sizes( obj, scale_bar_length ) +%FIGURE_CELL_SIZES Figure with the cells area and perimeter. if nargin < 2 scale_bar_length = 10; end + epicells = obj.epicells; hf = figure( 'Position', [ 1204 20 600 650 ] ); ax1 = subplot( 2, 1, 1 ); hold on axis equal - add_plot_area( obj, ax1 ); + areas = vertcat( epicells.area ); + obj.plot_values_contour( areas, ax1 ); colorbar ax2 = subplot( 2, 1, 2 ); hold on axis equal - add_plot_perimeter( obj, ax2 ); + perims = vertcat( epicells.perimeter ); + obj.plot_values_contour( perims, ax2 ); colorbar add_plot_scalebar( obj, scale_bar_length, ax2 ); diff --git a/src/@deproj/plot_curvatures.m b/src/@deproj/figure_curvatures.m similarity index 71% rename from src/@deproj/plot_curvatures.m rename to src/@deproj/figure_curvatures.m index 4b5d91cb2b77282c2a887550cc7064b87a2abc3e..c6a2c29d3ed7a490b410a2de2fd6e95bdd64463c 100644 --- a/src/@deproj/plot_curvatures.m +++ b/src/@deproj/figure_curvatures.m @@ -1,26 +1,35 @@ -function [ hf, ax1, ax2, ax3 ] = plot_curvatures( obj, scale_bar_length ) -%PLOT_CURVATURES Figure with the local curvature for a collection of epicells. +function [ hf, ax1, ax2, ax3 ] = figure_curvatures( obj, scale_bar_length ) +%FIGURE_CURVATURES Figure with the local curvature for a collection of epicells. if nargin < 2 scale_bar_length = 10; end - + + epicells = obj.epicells; + curvs = vertcat( epicells.curvatures ); + hf = figure( 'Position', [ 1204 20 600 1000 ] ); ax1 = subplot( 3, 1, 1 ); hold on axis equal - add_plot_curvature_mean( obj, ax1 ); - + + mean_curv = curvs( :, 1 ); + obj.plot_values_contour( mean_curv, ax1 ); + ax2 = subplot( 3, 1, 2 ); hold on axis equal - add_plot_curvature_k1( obj, ax2 ); - + + k1_curv = curvs( :, 3 ); + obj.plot_values_contour( k1_curv, ax2 ); + ax3 = subplot( 3, 1, 3 ); hold on axis equal - add_plot_curvature_k2( obj, ax3 ); + + k2_curv = curvs( :, 4 ); + obj.plot_values_contour( k2_curv, ax3 ); % Collect min & max. cl1 = get( ax1, 'CLim' ); @@ -46,7 +55,7 @@ function [ hf, ax1, ax2, ax3 ] = plot_curvatures( obj, scale_bar_length ) c = colorbar(ax3, 'Location', 'EastOutside' ); c.Label.String = sprintf('Curvature (1/%s)', obj.units ); - add_plot_scalebar( obj, scale_bar_length, ax3 ); + obj.add_plot_scalebar( scale_bar_length, ax3 ); axis( ax1, 'off' ) axis( ax2, 'off' ) diff --git a/src/@deproj/plot_distorsions.m b/src/@deproj/figure_distorsions.m similarity index 55% rename from src/@deproj/plot_distorsions.m rename to src/@deproj/figure_distorsions.m index 3eaf8d87fe21cb84e54144d659a4ce74f84b6a60..fdeeda9e063ce9cab545d0248974c6ebc67c0680 100644 --- a/src/@deproj/plot_distorsions.m +++ b/src/@deproj/figure_distorsions.m @@ -1,4 +1,4 @@ -function [ hf, ax1, ax2 ] = plot_distorsions( obj, scale_bar_length ) +function [ hf, ax1, ax2 ] = figure_distorsions( obj, scale_bar_length ) %PLOT_DISTORSIONS Figure with the error on uncorrected cells area and perimeter. if nargin < 2 @@ -7,19 +7,28 @@ function [ hf, ax1, ax2 ] = plot_distorsions( obj, scale_bar_length ) hf = figure( 'Position', [ 1204 20 600 650 ] ); + epicells = obj.epicells; + ax1 = subplot( 2, 1, 1 ); hold on axis equal - add_plot_distorsion_area( obj, ax1 ); + areas = vertcat( epicells.area ); + uncorr_areas = vertcat( epicells.uncorrected_area ); + err = 1 - uncorr_areas ./ areas; + obj.plot_values_contour( 100. * err, ax1 ); + colorbar ax2 = subplot( 2, 1, 2 ); hold on axis equal - add_plot_distorsion_perimeter( obj, ax2 ); + perims = vertcat( epicells.perimeter ); + uncorr_perims = vertcat( epicells.uncorrected_perimeter ); + err = 1 - uncorr_perims ./ perims; + obj.plot_values_contour( 100. * err, ax2 ); colorbar - add_plot_scalebar( obj, scale_bar_length, ax2 ); + obj.add_plot_scalebar( scale_bar_length, ax2 ); axis( ax1, 'off' ) axis( ax2, 'off' ) diff --git a/src/@deproj/figure_tissue_orientation.m b/src/@deproj/figure_tissue_orientation.m new file mode 100644 index 0000000000000000000000000000000000000000..250d6a9dfcbe6badf5dcb58b3a2ca4cb3614df53 --- /dev/null +++ b/src/@deproj/figure_tissue_orientation.m @@ -0,0 +1,59 @@ +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 + 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 + 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 + 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) + + obj.add_plot_scalebar( scale_bar_length, ax3 ); + 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 + diff --git a/src/@deproj/plot_fit_ellipse.m b/src/@deproj/plot_fit_ellipse.m deleted file mode 100644 index 8438984b82d9b76bb7ddce0a6e597bf121461449..0000000000000000000000000000000000000000 --- a/src/@deproj/plot_fit_ellipse.m +++ /dev/null @@ -1,24 +0,0 @@ -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 - diff --git a/src/@deproj/plot_fit_plane.m b/src/@deproj/plot_fit_plane.m deleted file mode 100644 index c3d488a83f60ff967690ddcdaa98603e44f8dad8..0000000000000000000000000000000000000000 --- a/src/@deproj/plot_fit_plane.m +++ /dev/null @@ -1,45 +0,0 @@ -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. - - if nargin < 2 - scale_bar_length = 10; - end - - hf = figure( 'Position', [ 1204 20 600 1000 ] ); - - ax1 = subplot( 3, 1, 1 ); - hold on - axis equal - add_plot_euler_alpha( obj, ax1 ); - colormap( ax1, 'hsv' ) - colorbar(ax1) - - ax2 = subplot( 3, 1, 2 ); - hold on - axis equal - add_plot_euler_beta( obj, ax2 ); - colorbar(ax2) - - ax3 = subplot( 3, 1, 3 ); - hold on - axis equal - add_plot_euler_gamma( obj, ax3 ); - colormap( ax3, 'hsv' ) - colorbar(ax3) - - add_plot_scalebar( obj, scale_bar_length, ax3 ); - 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 - diff --git a/src/@deproj/add_plot_variable.m b/src/@deproj/plot_values_contour.m similarity index 51% rename from src/@deproj/add_plot_variable.m rename to src/@deproj/plot_values_contour.m index 8bc6800e2dae1287054db483d8f534a2ae1bc32d..c9db1722ee8f0046ee26ff6925ccb3b031df41e5 100644 --- a/src/@deproj/add_plot_variable.m +++ b/src/@deproj/plot_values_contour.m @@ -1,5 +1,13 @@ -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 }; diff --git a/src/@deproj/plot_values_ellipse.m b/src/@deproj/plot_values_ellipse.m new file mode 100644 index 0000000000000000000000000000000000000000..3483fe2602cc9fdad7af33862fe1a528a55ccdde --- /dev/null +++ b/src/@deproj/plot_values_ellipse.m @@ -0,0 +1,70 @@ +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