This is a static copy of a profile report

Home

tp_nucimgfeat (202 calls, 65.150 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/tp_nucimgfeat.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
percellparamfunction202
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
146
temp = ml_rotate(img(:,:,k),-t...
172145.203 s69.4%
179
surfmap = tp_surfmap(img,delta...
20210.364 s15.9%
147
img2 = cat( 3, img2, temp );
17212.644 s4.1%
187
spfeat = tp_spcylfeat(surfmap)...
2022.513 s3.9%
209
save(nucfeatfile, ...
2021.272 s2.0%
All other lines  3.154 s4.8%
Totals  65.150 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
ml_rotatefunction172144.992 s69.1%
tp_surfmapfunction20210.344 s15.9%
tp_spcylfeatfunction2022.513 s3.9%
tp_imtightfunction2020.951 s1.5%
ml_majoranglefunction2020.451 s0.7%
num2strfunction6060.270 s0.4%
squeezefunction2020.010 s0.0%
filesepfunction2020 s0%
Self time (built-ins, overhead, etc.)  5.618 s8.6%
Totals  65.150 s100% 
Code Analyzer results
Line numberMessage
68Best practice is for CATCH to be followed by an identifier that gets the error information.
73The value assigned to variable 'downsample' might be unused.
74Best practice is for CATCH to be followed by an identifier that gets the error information.
75The value assigned to variable 'downsample' might be unused.
80Best practice is for CATCH to be followed by an identifier that gets the error information.
86The value assigned to variable 'display' might be unused.
87Best practice is for CATCH to be followed by an identifier that gets the error information.
88The value assigned to variable 'display' might be unused.
130Best practice is for CATCH to be followed by an identifier that gets the error information.
136The value assigned here to 'maxfluo' appears to be unused. Consider replacing it by ~.
160Best practice is for CATCH to be followed by an identifier that gets the error information.
164The value assigned to variable 'error' might be unused.
184Best practice is for CATCH to be followed by an identifier that gets the error information.
200Best practice is for CATCH to be followed by an identifier that gets the error information.
201The first argument of WARNING should be a message identifier. Using a message identifier allows users better control over the message.
Coverage results
[ Show coverage for parent directory ]
Total lines in function226
Non-code lines (comments, blank lines)112
Code lines (lines that can run)114
Code lines that did run49
Code lines that did not run65
Coverage (did run/can run)42.98 %
Function listing
   time   calls  line
1 function [spfeat,surfmap,img] = tp_nucimgfeat( segfile,...
2 method, param,currfile )
3 %TP_NUCIMGFEAT Calculates spline features on a nuclear image
4
5 % Tao Peng
6 %
7 % Copyright (C) 2012-2013 Murphy Lab
8 % Lane Center for Computational Biology
9 % School of Computer Science
10 % Carnegie Mellon University
11 %
12 % March 22, 2012 Added param.downsample so that user can select a
13 % downsampling scale. The default is [5 5 1] which is
14 % the one in the original generative model paper
15 % March 23, 2012 Fixed a bug when getting cellnum from imgdir
16 % March 26, 2012 Added image rotation after preprocessing and well as
17 % removal of blank slices on top and bottom of preprocessed
18 % image
19 % July 23, 2012 R.F. Murphy Add debug code to show steps and final spline
20 % July 26, 2012 I. Cao-Berg If the number of slices in the nuclear image that have
21 % fluorescence is less than 4, then ignore such image
22 % Jan 1, 2013 I. Cao-Berg Plots will be made iff display flag is set to true
23 % May 15, 2013 I. Cao-Berg Updated method to support wildcards
24 %
25 %%
26 % June 7-13 2013 D. Sullivan changed to per-cell type computations. Major
27 % changes include passing a presegmented file
28 % path rather than raw image files and adding a
29 % 'currfile' parameter to track what loop
30 % iteration we are currently on in parallel.
31 % Also passing in a tempdirectory
32 % structure as part of param.
33 %%
34 %
35 % Aug 12, 2013 G. Johnson Corrected save file name. Improved for
36 % readability
37 %
38 % This program is free software; you can redistribute it and/or modify
39 % it under the terms of the GNU General Public License as published
40 % by the Free Software Foundation; either version 2 of the License,
41 % or (at your option) any later version.
42 %
43 % This program is distributed in the hope that it will be useful, but
44 % WITHOUT ANY WARRANTY; without even the implied warranty of
45 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
46 % General Public License for more details.
47 %
48 % You should have received a copy of the GNU General Public License
49 % along with this program; if not, write to the Free Software
50 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
51 % 02110-1301, USA.
52 %
53 % For additional information visit http://murphylab.web.cmu.edu or
54 % send email to murphy@cmu.edu
55
0.02 202 56 temporaryFilesFolder = param.nuctemppath;
57 % temporaryFilesFolder = [ pwd filesep 'temp' filesep 'splines' ];
0.02 202 58 if ~exist( temporaryFilesFolder, 'dir' )
1 59 mkdir( temporaryFilesFolder );
1 60 end
61
202 62 if nargin == 2
63 param = [];
64 end
65
202 66 try
202 67 verbose = param.verbose;
68 catch
69 verbose = false;
70 end
71
202 72 try
202 73 downsample = param.model.downsampling;
74 catch
75 downsample = [5 5 1];
76 end
77
202 78 try
202 79 debug = param.debug;
80 catch
81 debug = false;
82 end
83
84 %icaoberg 1/30/2013
202 85 try
202 86 display = param.display;
87 catch
88 display = false;
89 end
90
91 %icaoberg 5/13/2013
92 % cellnum = param.cellnum;
202 93 cellnum = currfile;
0.02 202 94 param.cellnum = cellnum;
95
0.09 202 96 nucfeatfile = [temporaryFilesFolder filesep 'nuclearfeats' num2str(cellnum) '.mat'];
97
0.21 202 98 if ~exist(nucfeatfile, 'file' )
99 %icaoberg 24/6/2012 updated api change from murphy
100 %[segdna,segcell] = seg_cell_and_nucleus( imgdir, downsample );
202 101 display = false;
0.82 202 102 load(segfile,'segdna','segcell');
103 % [segdna,segcell] = seg_cell_and_nucleus( ...
104 % dna_image_file, ...
105 % cell_image_file, ...
106 % prot_image_file, ...
107 % mask_image_file, ...
108 % downsample, display, param );
109
110 %icaoberg - march 26, 2012 added image rotation
0.12 202 111 img = double(segdna);
112
113 %icaoberg 26/7/2012
0.14 202 114 nnzpixel = squeeze(sum(sum(segdna)));
115
202 116 if length(find(nnzpixel)>0) < 4
117 spfeat = struct([]);
118 surfmap = [];
119 return
120 end
121
122 %icaoberg 06/02/2013
202 123 if debug && display
124 try
125 subplot(2,2,1);
126 for i=1:size(img,3)
127 imshow(img(:,:,i),[0 1])
128 pause(0.1);
129 end
130 catch
131 end
132 end
133
202 134 try
135 % image rotation
0.01 202 136 [maxfluo,supid] = max(nnzpixel);
0.04 202 137 supshape = img(:,:,supid);
0.46 202 138 theta = ml_majorangle(supshape)*180/pi;
0.10 202 139 fprintf(1,'%s\n',['Major angle for XY rotation is ' num2str(theta) '.']);
140
141 %icaoberg 5/15/2013
142 %had to change this snippet because ml_rotate might change the size if
143 %the rotated image
0.01 202 144 img2 = [];
202 145 for k = find(nnzpixel,1):find(nnzpixel,1,'last')
45.20 1721 146 temp = ml_rotate(img(:,:,k),-theta);
2.64 1721 147 img2 = cat( 3, img2, temp );
1721 148 end
202 149 img = img2;
202 150 clear img2;
151
152 %icaoberg 1/30/2013
202 153 if debug && display
154 try
155 subplot(2,2,2);
156 for i=1:size(img,3)
157 imshow(img(:,:,i),[0 1])
158 pause(0.1);
159 end
160 catch
161 end
162 end
163
164 catch error
165 spfeat = [];
166 disp( ['Could not rotate image ' imgdir ]);
167 return
168 end
169
170 % spline surface fitting
0.96 202 171 img = tp_imtight(img);
202 172 switch method
202 173 case 'medsurf'
174 [medplane,height,mask] = tp_imaxisplane(img);
175 [medfeat,heifeat] = tp_medplanefeat(medplane,height,mask);
176 spfeat = struct('medsurf',medfeat,'height',heifeat);
202 177 case 'cylsurf'
202 178 delta = 2*pi/360.;
10.36 202 179 surfmap = tp_surfmap(img,delta);
202 180 if debug && display
181 try
182 subplot(2,2,3);
183 plotcylsurf(surfmap,delta);
184 catch
185 end
186 end
2.51 202 187 spfeat = tp_spcylfeat(surfmap);
188
189
190 %icaoberg 1/30/2013
202 191 if debug && display
192 try
193 subplot(2,2,4);
194 Phi = -pi:delta:pi;
195 H = size(surfmap,1); Z = 0:(1/H):1;
196 [Phi_grid, Z_grid] = meshgrid(Phi,Z);
197 mesh_data = [Z_grid(:), Phi_grid(:)]';
198 nucsurf = reshape(fnval(spfeat,mesh_data),[length(Z),length(Phi)]);
199 plotcylsurf(nucsurf,delta);
200 catch
201 warning( 'Unable to make subplots' );
202 end
203 end
202 204 end
205
0.11 202 206 disp(['Saving spline features for image ' num2str(cellnum)]);
207
208
1.27 202 209 save(nucfeatfile, ...
210 'spfeat', 'surfmap', 'img', 'segfile' );
211 % save([temporaryFilesFolder num2str(cellnum) '.mat'], ...
212 % 'spfeat', 'surfmap', 'img', 'dna_image_file', ...
213 % 'cell_image_file', 'prot_image_file', 'mask_image_file' );
214
215 % save([temporaryFilesFolder filesep 'cell' num2str(cellnum) '.mat'], ...
216 % 'spfeat', 'surfmap', 'img', 'dna_image_file', ...
217 % 'cell_image_file', 'prot_image_file', 'mask_image_file' );
218 %
219 else
220 if verbose
221 fprintf(1,'%s\n',['Spline features found for image ' num2str(cellnum) '.']);
222 end
223 load(nucfeatfile);
224 end
225
202 226 end