From ea294214a05f0f7c59d576ad1593f9ed3c11fc01 Mon Sep 17 00:00:00 2001 From: Jean-Yves TINEVEZ <jean-yves.tinevez@pasteur.fr> Date: Thu, 16 Jul 2020 21:13:04 +0200 Subject: [PATCH] Methods to plot the distorsion caused by the projection. --- src/@deproj/add_plot_distorsion_area.m | 12 +++++++ src/@deproj/add_plot_distorsion_perimeter.m | 12 +++++++ src/@deproj/deproj.m | 9 ++++++ src/@deproj/plot_distorsions.m | 36 +++++++++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 src/@deproj/add_plot_distorsion_area.m create mode 100644 src/@deproj/add_plot_distorsion_perimeter.m create mode 100644 src/@deproj/plot_distorsions.m diff --git a/src/@deproj/add_plot_distorsion_area.m b/src/@deproj/add_plot_distorsion_area.m new file mode 100644 index 0000000..66737dc --- /dev/null +++ b/src/@deproj/add_plot_distorsion_area.m @@ -0,0 +1,12 @@ +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 new file mode 100644 index 0000000..c46f72d --- /dev/null +++ b/src/@deproj/add_plot_distorsion_perimeter.m @@ -0,0 +1,12 @@ +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/deproj.m b/src/@deproj/deproj.m index 29c33a1..0bead4f 100644 --- a/src/@deproj/deproj.m +++ b/src/@deproj/deproj.m @@ -37,6 +37,9 @@ classdef deproj % Figure with the cells area and perimeter. [ hf, ax1, ax2 ] = plot_sizes( obj, scale_bar_length ) + % Figure with the error on uncorrected cells area and perimeter. + [ hf, ax1, ax2 ] = plot_distorsions( obj, scale_bar_length ) + %% Helpers. % They are public in case of. @@ -78,6 +81,12 @@ classdef deproj % 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 ) end diff --git a/src/@deproj/plot_distorsions.m b/src/@deproj/plot_distorsions.m new file mode 100644 index 0000000..3eaf8d8 --- /dev/null +++ b/src/@deproj/plot_distorsions.m @@ -0,0 +1,36 @@ +function [ hf, ax1, ax2 ] = plot_distorsions( obj, scale_bar_length ) +%PLOT_DISTORSIONS Figure with the error on uncorrected cells area and perimeter. + + if nargin < 2 + scale_bar_length = 10; + end + + hf = figure( 'Position', [ 1204 20 600 650 ] ); + + ax1 = subplot( 2, 1, 1 ); + hold on + axis equal + add_plot_distorsion_area( obj, ax1 ); + colorbar + + ax2 = subplot( 2, 1, 2 ); + hold on + axis equal + add_plot_distorsion_perimeter( obj, ax2 ); + colorbar + + add_plot_scalebar( obj, scale_bar_length, ax2 ); + + axis( ax1, 'off' ) + axis( ax2, 'off' ) + + title( ax1, 'Error on cell area (%)', ... + 'FontWeight', 'normal', ... + 'Interpreter', 'none' ) + title( ax2, 'Error on cell perimeter (%)', ... + 'FontWeight', 'normal', ... + 'Interpreter', 'none' ) + + linkaxes( [ ax2 ax1 ] ) +end + -- GitLab