displayCombinedMap.m~ 4.87 KB
Newer Older
Sebastien Herbert's avatar
Sebastien Herbert committed
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164


function displayCombinedMap(tableOutputDeproj,tableOutputBell,contour3D,outputFolder)
% If not specified, the default display is now in real space (not projected)
% For shape descriptor see publication Zdilla et al. 2016
% Usual call is 
% displayCombinedMap(tableOutputDeproj,tableOutputBell,dataCells.cellContour3D)

% close all

scriptVersion = 'displayCombinedMap_v0p2';

if nargin==3
    outputFolder = uigetdir(pwd,'Select the output folder');
end

cd(outputFolder);

% dataBool.doApical = true;
% dataBool.doNeighbours = true;
% dataBool.doAreaRatioRP = true;
% dataBool.doAreaRatioPB = true;
% dataBool.doPerimeter = true;
% dataBool.doAnisotropy = true;
% dataBool.doCircularity = false; % keep it that way until bug fix!
% dataBool.doRoundness = true;

dataBool.doApical = false;
dataBool.doNeighbours = false;
dataBool.doAreaRatioRP = false;
dataBool.doAreaRatioPB = false;
dataBool.doPerimeter = false;
dataBool.doAnisotropy = false;
dataBool.doCircularity = true;
dataBool.doRoundness = false;


save('displayParameters','scriptVersion','dataBool');

% %% Ask the user for which data to plot => For later...
% prompt = {'Enter the matrix size for x^2:';'Enter the colormap name:'};
% name = 'Please select the variable to display';
% Formats = {};
% Formats(1,1).type   = 'list';
% Formats(1,1).style  = 'listbox';
% Formats(1,1).items  = {'Apical area','Nbr of neighbours','Area ratio (Real/Proj)',...
%     'Area ratio (Proj/Bell)','Perimeter (Real)','Circularity (Real)','Roundness (Real)'};
% Formats(1,1).limits = [0 numel(Formats(1).items)]; % multi-select
% [Answer, Cancelled] = inputsdlg(prompt, name, Formats);

%% Data to plot
% Apical area
if dataBool.doApical
    dataVal = tableOutputDeproj.AreaReal;
    titleFig = 'Cell apical surface area (Real)';
    figName = 'mapApicalArea';
    dispMap(dataVal,titleFig,figName,contour3D);
end

% Nbr of neighbours
if dataBool.doNeighbours
    dataVal = tableOutputDeproj.NbrNeighbours;
    titleFig = 'Nbr of neighbours';
    figName = 'mapNbrNeighbours';
    dispMap(dataVal,titleFig,figName,contour3D);
end

% Area ratio (real vs proj)
if dataBool.doAreaRatioRP
    dataVal = tableOutputDeproj.AreaReal./tableOutputDeproj.AreaProj;
    titleFig = 'Cell apical surface area ratio (Real/Proj)';
    figName = 'mapAreaRatio_RP';
    dispMap(dataVal,titleFig,figName,contour3D);
end
    
% Area ratio (Proj vs Bell)
if dataBool.doAreaRatioPB
    dataVal = tableOutputDeproj.AreaProj./tableOutputBell.AreaBell;
    titleFig = 'Cell apical surface area ratio (Proj/Bell)';
    figName = 'mapAreaRatio_PB';
    dispMap(dataVal,titleFig,figName,contour3D);
end

% Perimeter
if dataBool.doPerimeter
    dataVal = tableOutputDeproj.PerimeterReal;
    titleFig = 'Cell perimeter (Real)';
    figName = 'mapPerimeter';
    dispMap(dataVal,titleFig,figName,contour3D);
end

% Anisotropy (Real) (as calculated by Bellaiche lab: 1-1/elongation)
if dataBool.doAnisotropy
    dataVal = tableOutputDeproj.AnisotropyReal;
    titleFig = 'Cell anisotropy (Real)';
    figName = 'mapAnisotropy';
    dispMap(dataVal,titleFig,figName,contour3D);
end

% Circularity is a shape descriptor that can mathematically indicate the degree of similarity to a perfect circle
if dataBool.doCircularity % Error in the method
    
    dataVal = (4 * pi * area) ./ (Perimeter .^ 2);
    
    dataVal = (4*pi*(tableOutputDeproj.AreaReal) ./ (tableOutputDeproj.PerimeterReal.^2));
    titleFig = 'Cell circularity (Real)';
    figName = 'mapCircularity';
    dispMap(dataVal,titleFig,figName,contour3D);
end

% Roundness is similar to circularity but is insensitive to irregular borders along the perimeter
if dataBool.doRoundness
    dataVal = 4*tableOutputDeproj.AreaReal./(pi*(tableOutputDeproj.semiMajAxReal*2).^2);
    titleFig = 'Cell roundness (Real)';
    figName = 'mapRoundness';
    dispMap(dataVal,titleFig,figName,contour3D);
end

end


function dispMap(dataVal,titleFig,figName,contour3D)
    
    %% Preparing the colormap
    dataRange = max(dataVal)-min(dataVal);
    greyLvlNbr = 200;
    color2plot = round(((dataVal-min(dataVal))/dataRange)*(greyLvlNbr-1)+1);
    fprintf('displaying: %s\n',titleFig);
    dataColor = parula(greyLvlNbr);
    
    %% Plot the figure
    figure
    hold on
    for bioCell = 1:numel(dataVal)
        if isnan(dataVal(bioCell))
            fprintf('Warning: A value was not set properly: skipping cell %d\n',bioCell);
            continue
        else
            fill3(contour3D{bioCell}.VerticesOrdered(:,1),...
                contour3D{bioCell}.VerticesOrdered(:,2),...
                contour3D{bioCell}.VerticesOrdered(:,3),...
                dataColor(color2plot(bioCell),:), ...
                'LineStyle', 'none');
        end
    end
    
    %% Set axes and colorbar
    h = colorbar;
    caxis([min(dataVal) max(dataVal)])
    axis equal
    title(titleFig);
    xlabel('X position (µm)'); ylabel('Y position (µm)');
    zlabel('Z position (µm)');

    savefig(figName)
    
end