Commit 9e6d89eb998bf0233eded23152c0b91b17cfa8d6

Authored by David Mayerich
1 parent d1ab3c93

minor changes with Jack

Showing 1 changed file with 6 additions and 17 deletions   Show diff stats
@@ -210,39 +210,26 @@ void compare(float sigma){ @@ -210,39 +210,26 @@ void compare(float sigma){
210 } 210 }
211 211
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 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 double avgL_t, avgL_gt, avgT_t, avgT_gt, avgB_t, avgB_gt, avgC_t, avgC_gt, avgFD_t, avgFD_gt; 215 double avgL_t, avgL_gt, avgT_t, avgT_gt, avgB_t, avgB_gt, avgC_t, avgC_gt, avgFD_t, avgFD_gt;
215 unsigned int e_t, e_gt, b_gt, b_t; 216 unsigned int e_t, e_gt, b_gt, b_t;
216 avgL_gt = GT.Lengths(); 217 avgL_gt = GT.Lengths();
217 avgT_gt = GT.Tortuosities(); 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 avgL_t = T.Lengths(); 219 avgL_t = T.Lengths();
221 avgT_t = T.Tortuosities(); 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 avgB_gt = GT.BranchingIndex(); 221 avgB_gt = GT.BranchingIndex();
225 - //std::cout<<avgB_gt<<"---average branching index in the ground truth"<<std::endl;  
226 avgB_t = T.BranchingIndex(); 222 avgB_t = T.BranchingIndex();
227 - //std::cout<<avgB_t<<"---average branching index in the truth case"<<std::endl;  
228 avgC_gt = GT.Contractions(); 223 avgC_gt = GT.Contractions();
229 avgFD_gt = GT.FractalDimensions(); 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 avgC_t = T.Contractions(); 225 avgC_t = T.Contractions();
233 avgFD_t = T.FractalDimensions(); 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 e_gt = GT.EndP(); 227 e_gt = GT.EndP();
237 - //std::cout<<e_gt<<"---Number of tips in the ground truth"<<std::endl;  
238 e_t = T.EndP(); 228 e_t = T.EndP();
239 - //std::cout<<e_t<<"---Number of tips in the truth case"<<std::endl;  
240 b_gt = GT.BranchP(); 229 b_gt = GT.BranchP();
241 - //std::cout<<b_gt<<"---Number of branch points in the ground truth"<<std::endl;  
242 b_t = T.BranchP(); 230 b_t = T.BranchP();
243 - //std::cout<<b_t<<"---Number of branch points in the truth case"<<std::endl;  
244 std::ofstream myfile; 231 std::ofstream myfile;
245 - myfile.open ("features.csv"); 232 + myfile.open (filename.c_str());
246 myfile << "Length, Tortuosity, Contraction, Fractal Dimension, Branch Points, End points, Branching Index, \n"; 233 myfile << "Length, Tortuosity, Contraction, Fractal Dimension, Branch Points, End points, Branching Index, \n";
247 myfile << avgL_gt << "," << avgT_gt << "," << avgC_gt << "," << avgFD_gt << "," << b_gt << "," << e_gt << "," << avgB_gt <<std::endl; 234 myfile << avgL_gt << "," << avgT_gt << "," << avgC_gt << "," << avgFD_gt << "," << b_gt << "," << e_gt << "," << avgB_gt <<std::endl;
248 myfile << avgL_t << "," << avgT_t << "," << avgC_t << "," << avgFD_t << "," << b_t << "," << e_t << "," << avgB_t <<std::endl; 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,6 +260,7 @@ int main(int argc, char* argv[])
273 args.add("help", "prints this help"); 260 args.add("help", "prints this help");
274 args.add("sigma", "force a sigma value to specify the tolerance of the network comparison", "10"); 261 args.add("sigma", "force a sigma value to specify the tolerance of the network comparison", "10");
275 args.add("gui", "display the network or network comparison using OpenGL"); 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 args.parse(argc, argv); //parse the user arguments 265 args.parse(argc, argv); //parse the user arguments
278 266
@@ -292,7 +280,8 @@ int main(int argc, char* argv[]) @@ -292,7 +280,8 @@ int main(int argc, char* argv[])
292 num_nets = 2; //set the number of networks to two 280 num_nets = 2; //set the number of networks to two
293 float sigma = args["sigma"].as_float(); //get the sigma value from the user 281 float sigma = args["sigma"].as_float(); //get the sigma value from the user
294 T.load_obj(args.arg(1)); //load the second (test) network 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 GT = GT.resample(resample_rate * sigma); //resample both networks based on the sigma value 285 GT = GT.resample(resample_rate * sigma); //resample both networks based on the sigma value
297 T = T.resample(resample_rate * sigma); 286 T = T.resample(resample_rate * sigma);
298 compare(sigma); //run the comparison algorithm 287 compare(sigma); //run the comparison algorithm