Commit c0c0ea3928e0d5ca02ce7ee3d4c836cca6aa7ca4
1 parent
19809858
writes 7 features to csv file 1st row - feature name, 2nd row-Gt Features, 3rd row- T features
Showing
1 changed file
with
44 additions
and
11 deletions
Show diff stats
main.cpp
... | ... | @@ -8,6 +8,7 @@ |
8 | 8 | |
9 | 9 | //STIM includes |
10 | 10 | #include <stim/visualization/gl_network.h> |
11 | +#include <stim/biomodels/network.h> | |
11 | 12 | #include <stim/visualization/gl_aaboundingbox.h> |
12 | 13 | #include <stim/parser/arguments.h> |
13 | 14 | #include <stim/visualization/camera.h> |
... | ... | @@ -207,6 +208,46 @@ void compare(float sigma){ |
207 | 208 | std::cout << "FPR: " << FNR << std::endl; |
208 | 209 | } |
209 | 210 | |
211 | +// 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 | +void features(){ | |
213 | + double avgL_t, avgL_gt, avgT_t, avgT_gt, avgB_t, avgB_gt, avgC_t, avgC_gt, avgFD_t, avgFD_gt; | |
214 | + unsigned int e_t, e_gt, b_gt, b_t; | |
215 | + avgL_gt = GT.Lengths(); | |
216 | + avgT_gt = GT.Tortuosities(); | |
217 | + //std::cout<<avgL_gt<<"---average segment length in the ground truth network"<<std::endl; | |
218 | + //std::cout<<avgT_gt<<"---average segment tortuosity in the ground truth network"<<std::endl; | |
219 | + avgL_t = T.Lengths(); | |
220 | + avgT_t = T.Tortuosities(); | |
221 | + //std::cout<<avgL_t<<"---average segment length in the truth network"<<std::endl; | |
222 | + //std::cout<<avgT_t<<"---average segment tortuosity in the truth network"<<std::endl; | |
223 | + avgB_gt = GT.BranchingIndex(); | |
224 | + //std::cout<<avgB_gt<<"---average branching index in the ground truth"<<std::endl; | |
225 | + avgB_t = T.BranchingIndex(); | |
226 | + //std::cout<<avgB_t<<"---average branching index in the truth case"<<std::endl; | |
227 | + avgC_gt = GT.Contractions(); | |
228 | + avgFD_gt = GT.FractalDimensions(); | |
229 | + //std::cout<<avgC_gt<<"---average segment contraction in the ground truth network"<<std::endl; | |
230 | + //std::cout<<avgFD_gt<<"---average segment fractal dimension in the ground truth network"<<std::endl; | |
231 | + avgC_t = T.Contractions(); | |
232 | + avgFD_t = T.FractalDimensions(); | |
233 | + //std::cout<<avgC_t<<"---average segment contraction in the truth network"<<std::endl; | |
234 | + //std::cout<<avgFD_t<<"---average segment fractal dimension in the truth network"<<std::endl; | |
235 | + e_gt = GT.EndP(); | |
236 | + //std::cout<<e_gt<<"---Number of tips in the ground truth"<<std::endl; | |
237 | + e_t = T.EndP(); | |
238 | + //std::cout<<e_t<<"---Number of tips in the truth case"<<std::endl; | |
239 | + b_gt = GT.BranchP(); | |
240 | + //std::cout<<b_gt<<"---Number of branch points in the ground truth"<<std::endl; | |
241 | + b_t = T.BranchP(); | |
242 | + //std::cout<<b_t<<"---Number of branch points in the truth case"<<std::endl; | |
243 | + std::ofstream myfile; | |
244 | + myfile.open ("features.csv"); | |
245 | + myfile << "Length, Tortuosity, Contraction, Fractal Dimension, Branch Points, End points, Branching Index, \n"; | |
246 | + myfile << avgL_gt << "," << avgT_gt << "," << avgC_gt << "," << avgFD_gt << "," << b_gt << "," << e_gt << "," << avgB_gt <<std::endl; | |
247 | + myfile << avgL_t << "," << avgT_t << "," << avgC_t << "," << avgFD_t << "," << b_t << "," << e_t << "," << avgB_t <<std::endl; | |
248 | + myfile.close(); | |
249 | +} | |
250 | + | |
210 | 251 | // Output an advertisement for the lab, authors, and usage information |
211 | 252 | void advertise(){ |
212 | 253 | std::cout<<std::endl<<std::endl; |
... | ... | @@ -243,24 +284,16 @@ int main(int argc, char* argv[]) |
243 | 284 | if(args.nargs() >= 1){ //if at least one network file is specified |
244 | 285 | num_nets = 1; //set the number of networks to one |
245 | 286 | GT.load_obj(args.arg(0)); //load the specified file as the ground truth |
287 | + /*GT.to_txt("Graph.txt");*/ | |
246 | 288 | } |
247 | 289 | |
248 | 290 | if(args.nargs() == 2){ //if two files are specified, they will be displayed in neighboring viewports and compared |
249 | 291 | num_nets = 2; //set the number of networks to two |
250 | 292 | float sigma = args["sigma"].as_float(); //get the sigma value from the user |
251 | - T.load_obj(args.arg(1)); //load the second (test) network | |
252 | - double avgL, avgT; | |
253 | - avgL = GT.Lengths(); | |
254 | - avgT = GT.Tortuosities(); | |
255 | - std::cout<<avgL<<"---average segment length in the ground truth network"<<std::endl; | |
256 | - std::cout<<avgT<<"---average segment tortuosity in the ground truth network"<<std::endl; | |
257 | - avgL = T.Lengths(); | |
258 | - avgT = T.Tortuosities(); | |
259 | - std::cout<<avgL<<"---average segment length in the truth network"<<std::endl; | |
260 | - std::cout<<avgT<<"---average segment tortuosity in the truth network"<<std::endl; | |
293 | + T.load_obj(args.arg(1)); //load the second (test) network | |
294 | + features(); | |
261 | 295 | GT = GT.resample(resample_rate * sigma); //resample both networks based on the sigma value |
262 | 296 | T = T.resample(resample_rate * sigma); |
263 | - | |
264 | 297 | compare(sigma); //run the comparison algorithm |
265 | 298 | } |
266 | 299 | ... | ... |