Select Git revision
surface3D_combine.m 44.87 KiB
% The objective here is to recalculate the geometrical parameters of cells
% segmented in a 2D projected map using a 3D mesh. Desired geometrical
% parameters are area, orientation, ratio (length-width), curvature
%
% V2D - vertex of the cell contour in the 2D segmentation
% V3D - vertex of the mesh
%
%{
Steps:
1) Input parameter
2) Load 2D segmentation (and double check parameters)
3) Load 3D segmentation
4) Recreate the cellular surface contour using a marching square method
5) Find which faces of the mesh are relevant for which cell of the
projected seg (based on the polygon surface of the cell)
6) Calculate the surface of each cell (projected and real)
7) Finding bellaiche sides and mesh faces connections
8) Finding bellaiche contour and mesh faces connections
9) Clear over and under covered cells
10) Deproject both the cell contour and the edges on the mesh
11) Recalculate the fit to ellipse
12) Create a table output
13) Saving output
14) Display final maps
%}
function surface3D_combine(doDispBell, doDispMesh, doDispOverlay, voxSize,...
maxTiffImSize, maxFaces, outputFolder, segLoc, curveLoc)
tic
close all
PARAMS = {};
%%%%%%%%%%%%%%%%%%%%%% PARAMETERS %%%%%%%%%%%%%%%%%%%%%%
PARAMS.softVersion = 'surface3D_combine_v0p1p0.m';
if nargin == 0
fprintf('Using default input parameters\n');
PARAMS.doDispBell = false; % display the 2D segmentation
PARAMS.doDispMesh = false; % display the 3D mesh
PARAMS.doDispOverlay = false; % display the overlayed 2D seg and 3D mesh
PARAMS.doDispErrorEllipse = true; % display the cells with an ellipse fit error
% Define axial step size (in um)
PARAMS.imSettings.axPixSize = 0.5; % axial voxel size (in um)
PARAMS.imSettings.latPixSize = 0.2; % lateral voxel size (in um)
PARAMS.maxTiffImSize = 40000; % Limit the input image size when using an elevation map (in pix)
PARAMS.maxFaces = 300; % If need be, reduce the maximum number of faces for the mesh
% initialize input and output
outputFolder = '';
segLoc = '';
curveLoc = '';
% DEV ONLY
outputFolder = '/media/sherbert/Data/Projects/Own_Project/Deproj/LValon/output/';
segLoc = '/media/sherbert/Data/Projects/Own_Project/Deproj/LValon/input/GT_SegmentationResults-labels-1.tif';
curveLoc = '/media/sherbert/Data/Projects/Own_Project/Deproj/LValon/input/LValonMultiC_elevMap_T1.tif';
elseif nargin == 9
fprintf('Using GUI input parameters\n');
% Displays inputs
PARAMS.doDispBell = doDispBell; % display the 2D segmentation
PARAMS.doDispMesh = doDispMesh; % display the 3D mesh
PARAMS.doDispOverlay = doDispOverlay; % display the overlayed 2D seg and 3D mesh