Commit 9e6d89eb998bf0233eded23152c0b91b17cfa8d6
1 parent
d1ab3c93
minor changes with Jack
Showing
1 changed file
with
6 additions
and
17 deletions
Show diff stats
main.cpp
... | ... | @@ -210,39 +210,26 @@ void compare(float sigma){ |
210 | 210 | } |
211 | 211 | |
212 | 212 | // writes features of the networks i.e average segment length, tortuosity, branching index, contraction, fractal dimension, number of end and branch points to a csv file |
213 | -void features(){ | |
213 | +// Pranathi wrote this - saves network features to a CSV file | |
214 | +void features(std::string filename){ | |
214 | 215 | double avgL_t, avgL_gt, avgT_t, avgT_gt, avgB_t, avgB_gt, avgC_t, avgC_gt, avgFD_t, avgFD_gt; |
215 | 216 | unsigned int e_t, e_gt, b_gt, b_t; |
216 | 217 | avgL_gt = GT.Lengths(); |
217 | 218 | avgT_gt = GT.Tortuosities(); |
218 | - //std::cout<<avgL_gt<<"---average segment length in the ground truth network"<<std::endl; | |
219 | - //std::cout<<avgT_gt<<"---average segment tortuosity in the ground truth network"<<std::endl; | |
220 | 219 | avgL_t = T.Lengths(); |
221 | 220 | avgT_t = T.Tortuosities(); |
222 | - //std::cout<<avgL_t<<"---average segment length in the truth network"<<std::endl; | |
223 | - //std::cout<<avgT_t<<"---average segment tortuosity in the truth network"<<std::endl; | |
224 | 221 | avgB_gt = GT.BranchingIndex(); |
225 | - //std::cout<<avgB_gt<<"---average branching index in the ground truth"<<std::endl; | |
226 | 222 | avgB_t = T.BranchingIndex(); |
227 | - //std::cout<<avgB_t<<"---average branching index in the truth case"<<std::endl; | |
228 | 223 | avgC_gt = GT.Contractions(); |
229 | 224 | avgFD_gt = GT.FractalDimensions(); |
230 | - //std::cout<<avgC_gt<<"---average segment contraction in the ground truth network"<<std::endl; | |
231 | - //std::cout<<avgFD_gt<<"---average segment fractal dimension in the ground truth network"<<std::endl; | |
232 | 225 | avgC_t = T.Contractions(); |
233 | 226 | avgFD_t = T.FractalDimensions(); |
234 | - //std::cout<<avgC_t<<"---average segment contraction in the truth network"<<std::endl; | |
235 | - //std::cout<<avgFD_t<<"---average segment fractal dimension in the truth network"<<std::endl; | |
236 | 227 | e_gt = GT.EndP(); |
237 | - //std::cout<<e_gt<<"---Number of tips in the ground truth"<<std::endl; | |
238 | 228 | e_t = T.EndP(); |
239 | - //std::cout<<e_t<<"---Number of tips in the truth case"<<std::endl; | |
240 | 229 | b_gt = GT.BranchP(); |
241 | - //std::cout<<b_gt<<"---Number of branch points in the ground truth"<<std::endl; | |
242 | 230 | b_t = T.BranchP(); |
243 | - //std::cout<<b_t<<"---Number of branch points in the truth case"<<std::endl; | |
244 | 231 | std::ofstream myfile; |
245 | - myfile.open ("features.csv"); | |
232 | + myfile.open (filename.c_str()); | |
246 | 233 | myfile << "Length, Tortuosity, Contraction, Fractal Dimension, Branch Points, End points, Branching Index, \n"; |
247 | 234 | myfile << avgL_gt << "," << avgT_gt << "," << avgC_gt << "," << avgFD_gt << "," << b_gt << "," << e_gt << "," << avgB_gt <<std::endl; |
248 | 235 | myfile << avgL_t << "," << avgT_t << "," << avgC_t << "," << avgFD_t << "," << b_t << "," << e_t << "," << avgB_t <<std::endl; |
... | ... | @@ -273,6 +260,7 @@ int main(int argc, char* argv[]) |
273 | 260 | args.add("help", "prints this help"); |
274 | 261 | args.add("sigma", "force a sigma value to specify the tolerance of the network comparison", "10"); |
275 | 262 | args.add("gui", "display the network or network comparison using OpenGL"); |
263 | + args.add("features", "save features to a CSV file, specify file name"); | |
276 | 264 | |
277 | 265 | args.parse(argc, argv); //parse the user arguments |
278 | 266 | |
... | ... | @@ -292,7 +280,8 @@ int main(int argc, char* argv[]) |
292 | 280 | num_nets = 2; //set the number of networks to two |
293 | 281 | float sigma = args["sigma"].as_float(); //get the sigma value from the user |
294 | 282 | T.load_obj(args.arg(1)); //load the second (test) network |
295 | - features(); | |
283 | + if(args["features"].is_set()) //if the user wants to save features | |
284 | + features(args["features"].as_string()); | |
296 | 285 | GT = GT.resample(resample_rate * sigma); //resample both networks based on the sigma value |
297 | 286 | T = T.resample(resample_rate * sigma); |
298 | 287 | compare(sigma); //run the comparison algorithm | ... | ... |