This is a static copy of a profile report

Home

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

Parents (calling functions)

Function NameFunction TypeCalls
img2modelfunction1
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
99
nucfeats{i} = load([param.nuct...
2020.360 s61.0%
133
nucsurf = reshape(fnval(avgins...
10.110 s18.6%
97
disp(['Concatenating spline fe...
2020.050 s8.5%
117
f_height = ml_estpdf(allheight...
10.040 s6.8%
118
f_coef = ml_estpdf(allcoefs,st...
10.010 s1.7%
All other lines  0.020 s3.4%
Totals  0.591 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
fnvalfunction10.100 s16.9%
num2strfunction2020.040 s6.8%
ml_estpdffunction20.030 s5.1%
ml_dirfunction10.010 s1.7%
filesepfunction2040.010 s1.7%
meshgridfunction10 s0%
Self time (built-ins, overhead, etc.)  0.401 s67.8%
Totals  0.591 s100% 
Code Analyzer results
Line numberMessage
48Best practice is for CATCH to be followed by an identifier that gets the error information.
54Best practice is for CATCH to be followed by an identifier that gets the error information.
60Best practice is for CATCH to be followed by an identifier that gets the error information.
104The variable 'allcoefs' appears to change size on every loop iteration. Consider preallocating for speed.
105The variable 'allheight' appears to change size on every loop iteration. Consider preallocating for speed.
108The variable 'allknotsx' appears to change size on every loop iteration. Consider preallocating for speed.
109The variable 'allknotsy' appears to change size on every loop iteration. Consider preallocating for speed.
139Best practice is for CATCH to be followed by an identifier that gets the error information.
157The value assigned to variable 'nuclearShapeModel' might be unused.
Coverage results
[ Show coverage for parent directory ]
Total lines in function158
Non-code lines (comments, blank lines)90
Code lines (lines that can run)68
Code lines that did run50
Code lines that did not run18
Coverage (did run/can run)73.53 %
Function listing
   time   calls  line
1 function model = train_nuc_shape_model( nucfeats, savepath,param )
2 % Train nuclear shape model using 3D HeLa cell nuclei images
3
4 % Author: Tao Peng
5 %
6 % Copyright (C) 2011-2013 Murphy Lab
7 % Lane Center for Computational Biology
8 % School of Computer Science
9 % Carnegie Mellon University
10 %
11 % July 23, 2012 R.F. Murphy Add debug code to show average shape
12 % July 26, 2012 I. Cao-Berg Added a statement where it returns an empty model
13 % when the spline features are empty
14 % August 2, 2012 I. Cao-Berg Added debugging statement that prints a message
15 % if spline features calculation is not successful
16 % Jan 30, 2013 I. Cao-Berg Display of plots will happen if debug and
17 % display flags are both true
18 % Jan 1, 2013 I. Cao-Berg Updated method to use display according to
19 % verbose flag
20 % Jan 6, 2013 I. Cao-Berg Fixed bug in verbose, debug and display flags
21 % May 15, 2013 I. Cao-Berg Updated method to support wildcards
22 %
23 % This program is free software; you can redistribute it and/or modify
24 % it under the terms of the GNU General Public License as published
25 % by the Free Software Foundation; either version 2 of the License,
26 % or (at your option) any later version.
27 %
28 % This program is distributed in the hope that it will be useful, but
29 % WITHOUT ANY WARRANTY; without even the implied warranty of
30 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 % General Public License for more details.
32 %
33 % You should have received a copy of the GNU General Public License
34 % along with this program; if not, write to the Free Software
35 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
36 % 02110-1301, USA.
37 %
38 % For additional information visit http://murphylab.web.cmu.edu or
39 % send email to murphy@cmu.edu
40
1 41 if nargin == 1
42 param = [];
43 end
44
45 %icaoberg 06/02/2013
1 46 try
1 47 verbose = param.verbose;
48 catch
49 verbose = true;
50 end
51
1 52 try
1 53 debug = param.debug;
54 catch
55 debug = false;
56 end
57
1 58 try
1 59 display = param.display;
60 catch
61 display =false;
62 end
63
64 %%%%%%%%%%%%%%%%%%
65 %Moved to img2model
66 % spfeat = gmm_allnucspfeat( 'cylsurf', ...
67 % dnaimgdir, ...
68 % cellimgdir, ...
69 % protimgdir, ...
70 % param );
71 %
1 72 allcoefs = [];
1 73 allknotsx = [];
1 74 allknotsy = [];
1 75 allheight = [];
76
77 % %icaoberg 26/7/2012
78 % if isempty( spfeat )
79 % model = struct([]);
80 % %icaoberg 2/8/2012
81 % if debug
82 % warning( 'Spline features cell array is empty. Exiting method.' );
83 % end
84 %
85 % return
86 % end
87 %%%%%%%%%%
88
89 %D. Sullivan 6/5/13
90 %Load the preprocessed nucimage features
1 91 if ~isa(nucfeats,'cell')
0.01 1 92 nucfeats = ml_dir([nucfeats filesep '*.mat']);
1 93 end
94
95
1 96 for i = 1:length(nucfeats)
0.05 202 97 disp(['Concatenating spline features from image ' num2str(i) ] );
202 98 if ~isa(nucfeats{i},'struct')
0.36 202 99 nucfeats{i} = load([param.nuctemppath filesep nucfeats{i}]);
202 100 end
202 101 u = (nucfeats{i}.spfeat.coefs(:,1) + nucfeats{i}.spfeat.coefs(:,end))/2;
202 102 nucfeats{i}.spfeat.coefs(:,1) = u;
202 103 nucfeats{i}.spfeat.coefs(:,end) = [];
202 104 allcoefs = [allcoefs nucfeats{i}.spfeat.coefs(:)];
0.01 202 105 allheight = [allheight;nucfeats{i}.spfeat.height];
106 % --------------------------------------- %
107 % To verify the constant knots assumption %
202 108 allknotsx = [allknotsx;nucfeats{i}.spfeat.knots{1}];
202 109 allknotsy = [allknotsy;nucfeats{i}.spfeat.knots{2}];
110 % --------------------------------------- %
202 111 end
1 112 allcoefs = allcoefs';
113
114
115
1 116 disp( 'Train nuclear shape model...' ); tic;
0.04 1 117 f_height = ml_estpdf(allheight,struct('name','norm'));
0.01 1 118 f_coef = ml_estpdf(allcoefs,struct('name','mvn'));
119
1 120 if debug
1 121 delta = 2*pi/360.;
122
1 123 averagecoef = reshape(f_coef.mu,size(nucfeats{1}.spfeat.coefs));
1 124 averagecoef(:,end+1) = averagecoef(:,1);
1 125 avginstance = nucfeats{i}.spfeat;
1 126 avginstance.coefs = averagecoef;
1 127 H = round(f_height.mu);
128
1 129 Phi = -pi:delta:pi;
1 130 Z = 0:(1/H):1;
1 131 [Phi_grid, Z_grid] = meshgrid(Phi,Z);
1 132 mesh_data = [Z_grid(:), Phi_grid(:)]';
0.11 1 133 nucsurf = reshape(fnval(avginstance,mesh_data),[length(Z),length(Phi)]);
134
1 135 if display
136 try
137 figure
138 plotcylsurf(nucsurf,delta);
139 catch
140 if verbose; disp('Unable to display figure'); end
141 end
142 end
1 143 end
144
1 145 toc
146
1 147 disp( 'Creating structure...' );
1 148 model = struct('name','spsurf',...
149 'surface',struct('form','B-',...
150 'nknots_phi',5,'constknot_phi',[.25 .375 .5 .625 .75],...
151 'nknots_h',1,'constknot_h',0.5,...
152 'number',[4 9],...
153 'order',[3 4],...
154 'stat',f_coef),...
155 'height',struct('stat',f_height));
156
1 157 nuclearShapeModel = model;
1 158 save([savepath filesep 'nuc_model.mat'],'nuclearShapeModel');