This is a static copy of a profile report

Home

find_cell_codes (202 calls, 16255.334 sec)
Generated 05-Nov-2014 07:52:31 using cpu time.
function in file /usr0/home/jenkins/workspace/cellorganizer-demo3D11-glnx64/utilities/3D/vesicles/3D/find_cell_codes.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
cellfit_percellfunction202
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
196
cellcodes{k} = ml_parsecell({}...
302915800.005 s97.2%
142
[segdna, segcell] = ml_rescale...
202223.039 s1.4%
159
mask = imclose(mask,se);
303067.914 s0.4%
171
mask = imclose(mask,se);
303067.854 s0.4%
172
mask = imfill(mask,'holes');
303034.868 s0.2%
All other lines  61.655 s0.4%
Totals  16255.334 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
ml_parsecellfunction302915799.724 s97.2%
ml_rescaleImage2Cellfunction202223.039 s1.4%
imclosefunction6060135.718 s0.8%
imfillfunction606069.556 s0.4%
ml_findmainobj2d_bwfunction908910.675 s0.1%
strel>strel.strelsubfunction2023.435 s0.0%
num2strfunction36351.001 s0.0%
repmatfunction4040.170 s0.0%
squeezefunction2020.010 s0.0%
filesepfunction4040.010 s0.0%
Self time (built-ins, overhead, etc.)  11.997 s0.1%
Totals  16255.334 s100% 
Code Analyzer results
Line numberMessage
65Best practice is for CATCH to be followed by an identifier that gets the error information.
150The value assigned to variable 'cellnucheightratio' might be unused.
151The value assigned to variable 'nucbottomslice' might be unused.
162The variable 'crossectionArea' appears to change size on every loop iteration. Consider preallocating for speed.
163The variable 'nucbody' appears to change size on every loop iteration. Consider preallocating for speed.
165The value assigned here to 'maxArea' appears to be unused. Consider replacing it by ~.
165The value assigned to variable 'equatorZ' might be unused.
175The variable 'cellbody' appears to change size on every loop iteration. Consider preallocating for speed.
189To improve performance, use logical indexing instead of FIND.
192The value assigned to variable 'crossectionArea' might be unused.
196The variable 'cellcodes' appears to change size on every loop iteration. Consider preallocating for speed.
215The variable 'cellcodes' appears to change size on every loop iteration. Consider preallocating for speed.
226To improve performance, use logical indexing instead of FIND.
228The value assigned to variable 'obj' might be unused.
229The value assigned to variable 'crossectionArea' might be unused.
234The variable 'cellcodes' appears to change size on every loop iteration. Consider preallocating for speed.
Coverage results
[ Show coverage for parent directory ]
Total lines in function252
Non-code lines (comments, blank lines)167
Code lines (lines that can run)85
Code lines that did run60
Code lines that did not run25
Coverage (did run/can run)70.59 %
Function listing
   time   calls  line
1 function find_cell_codes( dna_image_file, ...
2 cell_image_file, ...
3 prot_image_file, ...
4 mask_image_file, savepath, param,currfile )
5 %FIND_CELL_CODES Calculates cell codes
6
7 % Tao Peng
8 %
9 % Copyright (C) 2011-2013 Murphy Lab
10 % Lane Center for Computational Biology
11 % School of Computer Science
12 % Carnegie Mellon University
13 %
14 % March 12, 2012 Added another preprocessing routine. This routine mimics
15 % the preprocessing from A. Shariff, G. K. Rohde and R. F. Murphy (2010) A
16 % Generative Model of Microtubule Distributions, and Indirect Estimation of
17 % its Parameters from Fluorescence Microscopy Images. Cytometry Part A 77A:457-466.
18 % March 19, 2012 I. Cao-Berg Added Active Countour 3D segmentation
19 % March 22, 2012 I. Cao-Berg Added param.downsample so that user can select a
20 % downsampling scale. The default is [1 1 1] which is
21 % the one in the original generative model paper
22 % March 23, 2012 I. Cao-Berg Fixed a bug when getting cellnum from impath
23 % March 27, 2012 I. Cao-Berg When calling ml_parsecell instead of sending a slice
24 % of the nucleus, now we are sending a z-projection of the nucleus
25 % April 5, 2012 I. Cao-Berg Added new preprocessing method
26 % April 9, 2012 R.F. Murphy Save cell-nucleus height ratio and nuc bottomslice
27 % June 19, 2012 I. Cao-Berg Changed index name in the preprocessing for-loops that had the same
28 % index name as the main loop
29 % July 26, 2012 I. Cao-Berg If the number of slices in the nuclear image that have
30 % fluorescence is less than 4, then ignore such image
31 % May 15, 2013 I. Cao-Berg Updated method to support wildcards
32 % June 4, 2013 D. Sullivan Added check if masks were specified to avoid
33 % index out of bounds code when they're not
34 %
35 %%
36 % June 7-13 2013 D. Sullivan changed to per-cell type computations. Major
37 % changes include passing single files instead
38 % of directories and passing in a tempdirectory
39 % structure as part of param.
40 %%
41 % This program is free software; you can redistribute it and/or modify
42 % it under the terms of the GNU General Public License as published
43 % by the Free Software Foundation; either version 2 of the License,
44 % or (at your option) any later version.
45 %
46 % This program is distributed in the hope that it will be useful, but
47 % WITHOUT ANY WARRANTY; without even the implied warranty of
48 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
49 % General Public License for more details.
50 %
51 % You should have received a copy of the GNU General Public License
52 % along with this program; if not, write to the Free Software
53 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
54 % 02110-1301, USA.
55 %
56 % For additional information visit http://murphylab.web.cmu.edu or
57 % send email to murphy@cmu.edu
58
202 59 if nargin == 2
60 param = [];
61 end
62
202 63 try
202 64 downsample = param.downsample;
65 catch
66 downsample = [5 5 1];
67 end
68
69 %%%%celldirlist = ml_dir([impath '/cell*']);
70 % preprocessingFolder = [ pwd filesep 'temp' filesep 'preprocessing' ];
71 % if ~exist( preprocessingFolder )
72 % mkdir( preprocessingFolder );
73 % end
74 %
75 % dna_image_files = ml_ls( dnaImagesDirectoryPath );
76 % cell_image_files = ml_ls( cellImagesDirectoryPath );
77 % prot_image_files = ml_ls( protImagesDirectoryPath );
78 % mask_image_files = ml_ls( maskImagesDirectoryPath );
79 % celldirlist = ml_dir([preprocessingFolder '/cell*.mat']);
80
81 %D. Sullivan 6/6/13, no longer an issue with refactored code
82 %D. Sullivan 6/4/13 - added check if masks were specified
83 % if isempty(mask_image_file)
84 % no masks specified ignore
85 % masks_specified = 0;
86 % elseif length(mask_image_files)~=length(cell_image_files)
87 % %masks specified, but don't have proper number. No current way to
88 % %register which image gets a mask and which doesn't so ignore
89 % warning('Number of masks specified ~= number of cells specified, ignoring masks');
90 % masks_specified = 0;
91 % else
92 % masks_specified = 1;
93 % end
94 % for i = 1:length(cell_image_files)
95 % param.cellnum = i;
96 % dna_image_file = dna_image_files{i};
97 % cell_image_file = cell_image_files{i};
98 % prot_image_file = prot_image_files{i};
99 % %D. Sullivan 6/4/13 - added check if masks were specified
100 % if masks_specified==1
101 % %mask properly specified, read mask in
102 % mask_image_file = mask_image_files{i};
103 % else
104 % mask_image_file = [];
105 % end
106
0.03 202 107 temporaryResultsFile = [savepath filesep 'cellcodes_' num2str(currfile) '.mat'];
202 108 nucbody = {}; cellbody = {};
0.05 202 109 disp( ['Image:' num2str(currfile)]);
0.11 202 110 if ~exist( temporaryResultsFile, 'file' )
111 % try
112 %icaoberg april 5, 2012
113 %check if preprocessing results exist
114 %%%% cellfile = [ preprocessingFolder filesep 'cell' celldirlist{i}(5:end) '.mat' ];
0.02 202 115 cellfile = [ param.preprocessingFolder filesep 'cell' num2str(currfile) '.mat' ]; %%%%
0.12 202 116 if ~exist( cellfile, 'file' )
117 [segdna,segcell] = seg_cell_and_nucleus( ...
118 dna_image_file, ...
119 cell_image_file, ...
120 prot_image_file, ...
121 mask_image_file, ...
122 downsample, param.display, param );
202 123 else
0.01 202 124 disp('Preprocessed results found.');
1.04 202 125 load( cellfile );
202 126 end
127
128 %icaoberg 26/7/2012
0.12 202 129 nnzpixel = squeeze(sum(sum(segdna)));
130
202 131 if length(find(nnzpixel)>0) < 4
132 disp(['Ignoring image ' num2str(currfile)]);
133 %D. Sullivan 6/6/13 want to return instead of continue now
134 %that this code does one cell at a time.
135 % continue
136 return
137 end
138
139
140 %icaoberg april 5, 2012
202 141 stacknumber = 15;
223.04 202 142 [segdna, segcell] = ml_rescaleImage2Cell( segdna, segcell, stacknumber );
143
144 %fills the empty slices of DNA with the closest
0.17 202 145 z = find(sum(sum(segdna,1),2));
0.08 202 146 segdna(:,:,1:min(z)-1)=repmat(segdna(:,:,min(z)),[1,1,min(z)-1]);
0.12 202 147 segdna(:,:,max(z)+1:end)=repmat(segdna(:,:,max(z)),[1,1,size(segdna,3)-max(z)]);
148
149 %needed for model of nuclear position
202 150 cellnucheightratio = stacknumber/length(z);
202 151 nucbottomslice = (min(z)-1)/stacknumber;
152
153 %preprocess DNA image
3.44 202 154 se = strel('disk',3);
202 155 crossectionArea = [];
156 %icaoberg june 19, 2012 changed index from i to j
202 157 for j=1:1:size(segdna,3)
0.21 3030 158 mask = segdna(:,:,j);
67.91 3030 159 mask = imclose(mask,se);
34.78 3030 160 mask = imfill(mask,'holes');
3.78 3030 161 obj = ml_findmainobj2d_bw(mask);
0.23 3030 162 crossectionArea(j) = nnz(mask);
0.03 3030 163 nucbody{j}=obj;
3030 164 end
0.02 202 165 [maxArea,equatorZ] = max(crossectionArea);
166
167 %preprocess cell image
168 %icaoberg june 19, 2012 changed index from i to j
0.01 202 169 for j=1:1:size(segcell,3)
0.25 3030 170 mask = segcell(:,:,j);
67.85 3030 171 mask = imclose(mask,se);
34.87 3030 172 mask = imfill(mask,'holes');
0.25 3030 173 if ~all(mask(:) == 0)
3.86 3030 174 obj = ml_findmainobj2d_bw(mask);
0.01 3030 175 cellbody{j}=obj;
3030 176 end
177
0.02 3030 178 end
179
202 180 cellcodes = {};
202 181 for k = 1:1:length(cellbody)
1.03 3029 182 disp(['Calculating cell code on stack number: ' num2str(k) ]);
183
0.07 3029 184 method = 0;
0.02 3029 185 if method == 0
186 %calculate projection here
187 %let nucbody become a z-projection and calculate distance according to the projection
3.27 3029 188 mask = sum( segdna, 3 );
0.55 3029 189 mask(find( mask ~= 0)) = 255;
0.59 3029 190 mask = logical( mask );
3.19 3029 191 obj = ml_findmainobj2d_bw(mask);
0.19 3029 192 crossectionArea = nnz(mask);
0.02 3029 193 nucbody = obj;
194
0.01 3029 195 if ~isempty(nucbody)
15800.00 3029 196 cellcodes{k} = ml_parsecell({},cellbody{k},nucbody,...
197 1,size(segdna(:,:,k)),...
198 {'da','nucarea','nuccenter','nucmangle','nuchitpts',...
199 'nuccontour','nucellhitpts','nucdist','nucelldist','nucecc',...
200 'cellarea','cellcenter','cellmangle','cellcontour',...
201 'cellhitpts','celldist','cellecc','nucedge','celledge'},0);
0.03 3028 202 end
203 elseif method == 1
204 %calculate projection here
205 %let nucbody become a z-projection and calculate distance according to the projection
206 % mask = sum( segdna, 3 );
207 % mask(find( mask ~= 0)) = 255;
208 % mask = logical( mask );
209 % obj = ml_findmainobj2d_bw(mask);
210 % crossectionArea = nnz(mask);
211 %nucbody = obj;
212 nuclearbody = nucbody{k};
213
214 if ~isempty(nucbody)
215 cellcodes{k} = ml_parsecell({},cellbody{k},nuclearbody,...
216 1,size(segdna(:,:,k)),...
217 {'da','nucarea','nuccenter','nucmangle','nuchitpts',...
218 'nuccontour','nucellhitpts','nucdist','nucelldist','nucecc',...
219 'cellarea','cellcenter','cellmangle','cellcontour',...
220 'cellhitpts','celldist','cellecc','nucedge','celledge'},0);
221 end
222 elseif method == 2
223 %calculate projection here
224 %let nucbody become a z-projection and calculate distance according to the projection
225 mask = sum( segdna, 3 );
226 mask(find( mask ~= 0)) = 255;
227 mask = logical( mask );
228 obj = ml_findmainobj2d_bw(mask);
229 crossectionArea = nnz(mask);
230 %nucbody = obj;
231 nuclearbody = nucbody{k};
232
233 if ~isempty(nucbody)
234 cellcodes{k} = ml_parsecell({},cellbody{k},nuclearbody,...
235 1,size(segdna(:,:,k)),...
236 {'da','nucarea','nuccenter','nucmangle','nuchitpts',...
237 'nuccontour','nucellhitpts','nucdist','nucelldist','nucecc',...
238 'cellarea','cellcenter','cellmangle','cellcontour',...
239 'cellhitpts','celldist','cellecc','nucedge','celledge'},0);
240 end
241 end
0.01 3028 242 end
243
244 %icaoberg april 5, 2012
3.87 201 245 save(temporaryResultsFile, 'cellcodes', 'equatorZ', 'cellnucheightratio', 'nucbottomslice');
246 % param = rmfield( param, 'cellnum' );
247 % catch
248 % disp( ['Ignoring image ' num2str(i)] );
249 % end
201 250 end
251 % end
201 252 end