deproj.m 5.21 KB
Newer Older
1
2
3
4
5
classdef deproj
    %DEPROJ Manage a collection of epicells.
    
    properties
        epicells
6
        junction_graph
7
8
9
10
        units
    end
    
    methods
11
        function obj = deproj( epicells, junction_graph, units )
12
            obj.epicells = epicells;
13
            obj.junction_graph = junction_graph;
14
15
16
17
18
19
            obj.units = units;
        end
    end
    
    %% Plotting routines.
    methods
20
21
22
23
24
25
        
        %% Exports.
        
        % Export masurements to a table.
        T = to_table( obj )
        
26
27
28
        % Exports results to a spreadsheet file.
        to_file( obj, file_name, include_header )
        
29
30
31
32
33
        %% Conversion between MATLAB objects.
        
        % Returns the faces and vertices of a deproj collection.
        [ V, F ] = to_vertices_and_faces( obj )
        
34
35
36
37
38
39
40
41
        %% Generate figures.
        
        % Figure with the local plan orientation for a collection of epicells.
        [ hf, ax1, ax2, ax3 ] = plot_fit_plane( obj, scale_bar_length )
        
        % Plot the 2D ellipses on the tissue surface.
        [ hf, hc, he ] = plot_fit_ellipse( obj, scale_bar_length )
        
42
43
44
        % Figure with the local curvaure for a collection of epicells.
        [ hf, ax1, ax2, ax3 ] = plot_curvatures( obj, scale_bar_length )
        
45
46
47
        % Figure with the cells area and perimeter.
        [ hf, ax1, ax2 ] = plot_sizes( obj, scale_bar_length )
        
48
49
50
        % Figure with the error on uncorrected cells area and perimeter.
        [ hf, ax1, ax2 ] = plot_distorsions( obj, scale_bar_length )
        
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
        %% 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 )
        
        % 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 )
71
72
        
        %Plots the ellipses, colored by the specified values.
73
        hts = add_ellipse_variable( obj, values, cmap, ax )
74
75
76
77
78
79
80
81
82
83
84
85
        
        % 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 )
        
        % 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 )
86
87
88
89
90
91
        
        % 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 )
92
93
94
95
96
97
        
        % 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 )
98

99
                
100
101
    end
    
102
     %% Public static methods: builders & util.
103
104
    methods ( Access = public, Hidden = false, Static = true )
        
105
        % Returns a deproj object built from segmentation and height-map.
106
107
108
109
110
111
112
113
        obj = from_heightmap( I, ...
            H, ...
            pixel_size, ...
            voxel_depth, ...
            units, ...
            invert_z, ...
            inpaint_zeros, ...
            prune_zeros );
114
        
115
116
117
118
119
120
121
122
123
124
        % Returns a deproj object built from the results of the tool
        % from Yohannes Bellaiche lab.
        obj = from_bellaiche( ...
            cells, ...
            frame, ...
            sides, ...
            vertices, ...
            voxel_depth, ...
            units )
        
125
126
        % Returns the seismic colormap.
        cmap = cmap_seismic();
127
128
129
        
        % Compute local curvature from the smoothed height-map.
        [ curvMean, curvGauss, curvK1, curvK2 ] = compute_curvatures( H, object_scale, pixel_size, voxel_depth, invert_z )
130
131
        
        % Sort the points of a polygon in clockwise manner.
132
        [ P2, I ] = sort_polygon( P )
133
        
134
135
        % Sort x,y coordinates along a continuous contour.
        P2 = find_countour( P )
136
137
138
139

        % Read a PLY file.
        [ V, F, comments ] = ply_read( file_path )

140
141
        % Create a height-map from a mesh.
        [ H, min_y, min_x ] = mesh_to_heightmap( V, pixel_size )
142

143
144
145
146
147
148
149
150
151
152
153
    end
    
    %% Private static methods: utilities.
    methods ( Access = private, Hidden = true, Static = true )
        
        % Returns the Z position of points taken from a height-map.
        z_coords = get_z( P, H, pixel_size, voxel_depth )
        
        % Returns the cells from a BW image with ridges.
        [ objects, junction_graph ] = mask_to_objects( I, downsample )
        
154
        
155
156
157
    end
end