deproj.m 4.22 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
        %% Conversion between MATLAB objects.
        
31
32
        % Returns the faces and vertices of the junction graph of a instance.
        [ V, F ] = graph_to_VF( obj )
33
        
34
35
36
        % Returns the cells boundary polygons as 3 matrices padded by NaNs.
        [ X, Y, Z ] = to_matrices( obj )

37
38
        %% Generate figures.
        
Jean-Yves TINEVEZ's avatar
Jean-Yves TINEVEZ committed
39
40
        % Figure with the local tissue orientation for a collection of epicells.
        [ hf, ax1, ax2, ax3 ] = figure_tissue_orientation( obj, scale_bar_length )
41
        
Jean-Yves TINEVEZ's avatar
Jean-Yves TINEVEZ committed
42
43
        % Plot the cell elongation and 2D orientation with cells as 2D ellipses.
        [ hf, ax1, ax2 ] = figure_cell_elongation( obj, scale_bar_length )
44
        
45
        % Figure with the local curvaure for a collection of epicells.
Jean-Yves TINEVEZ's avatar
Jean-Yves TINEVEZ committed
46
        [ hf, ax1, ax2, ax3 ] = figure_curvatures( obj, scale_bar_length )
47
        
48
        % Figure with the cells area and perimeter.
Jean-Yves TINEVEZ's avatar
Jean-Yves TINEVEZ committed
49
        [ hf, ax1, ax2 ] = figure_cell_sizes( obj, scale_bar_length )
50
        
51
        % Figure with the error on uncorrected cells area and perimeter.
Jean-Yves TINEVEZ's avatar
Jean-Yves TINEVEZ committed
52
        [ hf, ax1, ax2 ] = figure_distorsions( obj, scale_bar_length )
53
        
54
55
56
57
        %% Helpers.
        % They are public in case of.
        
        % Add the epicell ids to the specified plot axes.
Jean-Yves TINEVEZ's avatar
Jean-Yves TINEVEZ committed
58
        hts = add_plot_ids( obj, ax )
59
60
61
62
        
        % Add a scale-bar to the plot.
        [ hsb, ht ] = add_plot_scalebar( obj, length, ax )
        
Jean-Yves TINEVEZ's avatar
Jean-Yves TINEVEZ committed
63
64
        % Plot the tissue with the cell exact contours, colored by the specified values.
        hts = plot_values_contour( obj, values, ax )
65
        
Jean-Yves TINEVEZ's avatar
Jean-Yves TINEVEZ committed
66
        % Plot the tissue with cells as ellipses, colored by the specified values.
67
        hts = plot_values_ellipse( obj, values, ax )
68
69
70
71
        
        % Plot the tissue with the cell contour approximated by the junctions, colored by the specified values.
        hts = plot_values_junction( obj, values, ax )
        
72
                
73
74
    end
    
75
     %% Public static methods: builders & util.
76
77
    methods ( Access = public, Hidden = false, Static = true )
        
78
        % Returns a deproj object built from segmentation and height-map.
79
80
81
82
83
84
85
86
        obj = from_heightmap( I, ...
            H, ...
            pixel_size, ...
            voxel_depth, ...
            units, ...
            invert_z, ...
            inpaint_zeros, ...
            prune_zeros );
87
        
88
89
90
91
92
93
94
95
96
97
        % 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 )
        
98
99
        % Returns the seismic colormap.
        cmap = cmap_seismic();
100
101
102
        
        % Compute local curvature from the smoothed height-map.
        [ curvMean, curvGauss, curvK1, curvK2 ] = compute_curvatures( H, object_scale, pixel_size, voxel_depth, invert_z )
103
104
        
        % Sort the points of a polygon in clockwise manner.
105
        [ P2, I ] = sort_polygon( P )
106
        
107
108
        % Sort x,y coordinates along a continuous contour.
        P2 = find_countour( P )
109
110
111
112

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

113
114
        % Create a height-map from a mesh.
        [ H, min_y, min_x ] = mesh_to_heightmap( V, pixel_size )
115

116
117
118
119
120
121
122
123
124
125
126
    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 )
        
127
        
128
129
130
    end
end