This is a static copy of a profile reportHome
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 Name | Function Type | Calls |
img2model | function | 1 |
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
99 | nucfeats{i} = load([param.nuct... | 202 | 0.360 s | 61.0% |  |
133 | nucsurf = reshape(fnval(avgins... | 1 | 0.110 s | 18.6% |  |
97 | disp(['Concatenating spline fe... | 202 | 0.050 s | 8.5% |  |
117 | f_height = ml_estpdf(allheight... | 1 | 0.040 s | 6.8% |  |
118 | f_coef = ml_estpdf(allcoefs,st... | 1 | 0.010 s | 1.7% |  |
All other lines | | | 0.020 s | 3.4% |  |
Totals | | | 0.591 s | 100% | |
Children (called functions)
Function Name | Function Type | Calls | Total Time | % Time | Time Plot |
fnval | function | 1 | 0.100 s | 16.9% |  |
num2str | function | 202 | 0.040 s | 6.8% |  |
ml_estpdf | function | 2 | 0.030 s | 5.1% |  |
ml_dir | function | 1 | 0.010 s | 1.7% |  |
filesep | function | 204 | 0.010 s | 1.7% |  |
meshgrid | function | 1 | 0 s | 0% |  |
Self time (built-ins, overhead, etc.) | | | 0.401 s | 67.8% |  |
Totals | | | 0.591 s | 100% | |
Code Analyzer results
Line number | Message |
48 | Best practice is for CATCH to be followed by an identifier that gets the error information. |
54 | Best practice is for CATCH to be followed by an identifier that gets the error information. |
60 | Best practice is for CATCH to be followed by an identifier that gets the error information. |
104 | The variable 'allcoefs' appears to change size on every loop iteration. Consider preallocating for speed. |
105 | The variable 'allheight' appears to change size on every loop iteration. Consider preallocating for speed. |
108 | The variable 'allknotsx' appears to change size on every loop iteration. Consider preallocating for speed. |
109 | The variable 'allknotsy' appears to change size on every loop iteration. Consider preallocating for speed. |
139 | Best practice is for CATCH to be followed by an identifier that gets the error information. |
157 | The value assigned to variable 'nuclearShapeModel' might be unused. |
Coverage results
[ Show coverage for parent directory ]
Total lines in function | 158 |
Non-code lines (comments, blank lines) | 90 |
Code lines (lines that can run) | 68 |
Code lines that did run | 50 |
Code lines that did not run | 18 |
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');