-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunExample.m
More file actions
executable file
·94 lines (68 loc) · 2.43 KB
/
RunExample.m
File metadata and controls
executable file
·94 lines (68 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
%% Example de-projection script.
%% Clear all.
close all
clear
clc
%% Parameters, scripts and files location.
% Add DeProj functions to the path.
addpath('./src')
% Where are the images.
root_folder = 'samples';
% You can provide directly the segmentation results as a mask image, and
% the code below will convert it into a list of objects.
% For this to work, the mask image must be an 'ImageJ' mask, that is: the
% cell contours must be black (pixel value == 0) and the cell interiors
% must be white (pixel value > 0).
mask_filename = 'Segmentation-2.tif';
% The height-map is an image that stores at every pixel the location of the
% plane of interest in the source 3D image. Since the pixel values store
% the index of the plane, we will need to convert it to an elevation in µm
% (see the voxel_depth parameter below).
heightmap_filename = 'HeightMap-2.tif';
% Pixel XY size.
% Physical size of a pixel in X and Y. This will be used to report sizes in
% µm.
pixel_size = 0.183; % µm
units = 'µm';
% Z spacing.
% How many µm bewtween each Z-slices. We need this to convert the
% height-map values, that stores the plane of interest, into µm.
voxel_depth = 1.; % µm
% Try to remove objects that have a Z position equal to 0. Normally this
% value reports objects that are out of the region-of-interest.
prune_zeros = true;
inpaint_zeros = true;
% Invert z for plotting.
invert_z = true;
%% Read files.
% ImageJ mask.
fprintf('Opening mask image: %s\n', mask_filename )
I = imread( fullfile( root_folder, mask_filename ) );
fprintf('Opening height-map image: %s\n', heightmap_filename )
H = imread( fullfile( root_folder, heightmap_filename ) );
%% Create deproj instance.
dpr = deproj.from_heightmap( ...
I, ...
H, ...
pixel_size, ...
voxel_depth, ...
units, ...
invert_z, ...
inpaint_zeros, ...
prune_zeros );
%% Plot morphological parameters.
close all
fprintf( 'Plotting the cell sizes.\n' )
dpr.figure_cell_sizes;
fprintf( 'Plotting the tissue orientation.\n' )
dpr.figure_tissue_orientation;
fprintf( 'Plotting the tissue local curvature.\n' )
dpr.figure_curvatures;
fprintf( 'Plotting the cell elongation and direction.\n' )
dpr.figure_cell_elongation;
fprintf( 'Plotting the impact of projection distorsion.\n' )
dpr.figure_distorsions;
fprintf( 'Plotting the topology figure.\n' )
dpr.figure_topology;
dpr.plot_text( num2cell( vertcat( dpr.epicells.n_neighbors ) ), gca );
fprintf( 'Finished.\n' )