deproj.m 5.02 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
34
35
36
        %% 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 )
        
37
38
39
        % Figure with the local curvaure for a collection of epicells.
        [ hf, ax1, ax2, ax3 ] = plot_curvatures( obj, scale_bar_length )
        
40
41
42
        % Figure with the cells area and perimeter.
        [ hf, ax1, ax2 ] = plot_sizes( obj, scale_bar_length )
        
43
44
45
        % Figure with the error on uncorrected cells area and perimeter.
        [ hf, ax1, ax2 ] = plot_distorsions( obj, scale_bar_length )
        
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
        %% 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 )
66
67
        
        %Plots the ellipses, colored by the specified values.
68
        hts = add_ellipse_variable( obj, values, cmap, ax )
69
70
71
72
73
74
75
76
77
78
79
80
        
        % 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 )
81
82
83
84
85
86
        
        % 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 )
87
88
89
90
91
92
        
        % 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 )
93
                
94
95
    end
    
96
     %% Public static methods: builders & util.
97
98
    methods ( Access = public, Hidden = false, Static = true )
        
99
        % Returns a deproj object built from segmentation and height-map.
100
101
102
103
104
105
106
107
        obj = from_heightmap( I, ...
            H, ...
            pixel_size, ...
            voxel_depth, ...
            units, ...
            invert_z, ...
            inpaint_zeros, ...
            prune_zeros );
108
        
109
110
111
112
113
114
115
116
117
118
        % 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 )
        
119
120
        % Returns the seismic colormap.
        cmap = cmap_seismic();
121
122
123
        
        % Compute local curvature from the smoothed height-map.
        [ curvMean, curvGauss, curvK1, curvK2 ] = compute_curvatures( H, object_scale, pixel_size, voxel_depth, invert_z )
124
125
126
127
        
        % Sort the points of a polygon in clockwise manner.
        P2 = sort_polygon( P )
        
128
129
        % Sort x,y coordinates along a continuous contour.
        P2 = find_countour( P )
130
131
132
133

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

134
135
        % Create a height-map from a mesh.
        [ H, min_y, min_x ] = mesh_to_heightmap( V, pixel_size )
136

137
138
139
140
141
142
143
144
145
146
147
    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 )
        
148
        
149
150
151
    end
end