10 #include <vtkSmartPointer.h> 12 #include <vtkPolyDataWriter.h> 13 #include <vtkPolyDataReader.h> 14 #include <vtkPolyData.h> 15 #include <vtkPointData.h> 26 char anglecorrection_test_data_dir[]=ANGLECORRECTION_TEST_DATA_DIR;
27 char * newArray =
new char[std::strlen(anglecorrection_test_data_dir)+std::strlen(filename)+1];
28 std::strcpy(newArray,anglecorrection_test_data_dir);
29 std::strcat(newArray,filename);
35 void validateVtkPD(vtkSmartPointer<vtkPolyData> leftHandSide,vtkSmartPointer<vtkPolyData> rightHandSide,
bool shouldBeEqual =
true){
36 unsigned int numberOfPointsRight = rightHandSide->GetNumberOfPoints();
37 unsigned int numberOfPointsLeft = leftHandSide->GetNumberOfPoints();
39 REQUIRE(numberOfPointsLeft==numberOfPointsRight);
41 if(!shouldBeEqual && numberOfPointsLeft!=numberOfPointsRight){
45 bool all_equal =
true;
48 for(
unsigned int i( 0 ); i < numberOfPointsRight; i++ )
50 rightHandSide->GetPoint(i, pointOne);
51 leftHandSide->GetPoint(i, pointTwo);
53 double x = pointOne[0] - pointTwo[0];
54 double y = pointOne[1] - pointTwo[1];
55 double z = pointOne[2] - pointTwo[2];
56 double distance = x*x + y*y + z*z;
57 if( distance > 0.001 ) all_equal=
false;
60 unsigned int numberOfArraysRight = rightHandSide->GetPointData()->GetNumberOfArrays();
61 unsigned int numberOfArraysLeft = leftHandSide->GetPointData()->GetNumberOfArrays();
63 REQUIRE(numberOfArraysLeft==numberOfArraysRight);
65 if(!shouldBeEqual && numberOfArraysLeft!=numberOfArraysRight){
72 for(
int k=0; k < numberOfArraysRight; k++)
74 unsigned int numberRight = rightHandSide->GetPointData()->GetArray(k)->GetDataSize()/ rightHandSide->GetPointData()->GetArray(k)->GetNumberOfComponents();
75 unsigned int numberLeft = leftHandSide->GetPointData()->GetArray(k)->GetDataSize()/ leftHandSide->GetPointData()->GetArray(k)->GetNumberOfComponents();
77 REQUIRE(numberLeft==numberRight);
79 if(!shouldBeEqual && numberLeft!=numberRight){
84 for(
int m=0; m < rightHandSide->GetPointData()->GetArray(k)->GetNumberOfComponents() ; m++){
85 for(
int l=0; l < numberRight ; l++){
86 pointRight= rightHandSide->GetPointData()->GetArray(k)->GetComponent(l,m);
87 pointLeft= leftHandSide->GetPointData()->GetArray(k)->GetComponent(l,m);
88 if( abs(pointRight-pointLeft) > 0.001 ) all_equal=
false;
92 REQUIRE(all_equal== shouldBeEqual);
95 void validateFiles(
const char* filename_a,
const char* filename_b,
bool shouldBeEqual =
true){
96 vtkSmartPointer<ErrorObserver> errorObserver = vtkSmartPointer<ErrorObserver>::New();
98 vtkSmartPointer<vtkPolyDataReader> reader2 = vtkSmartPointer<vtkPolyDataReader>::New();
99 reader2->AddObserver(vtkCommand::ErrorEvent,errorObserver);
100 reader2->SetFileName(filename_b);
103 vtkSmartPointer<vtkPolyDataReader> reader1 = vtkSmartPointer<vtkPolyDataReader>::New();
104 reader1->AddObserver(vtkCommand::ErrorEvent,errorObserver);
105 reader1->SetFileName(filename_a);
108 bool readFilesSuccesfully =
true;
109 if (errorObserver->GetError() ||errorObserver->GetWarning()){
110 readFilesSuccesfully =
false;
115 vtkSmartPointer<vtkPolyData> leftHandSide = reader1->GetOutput();
116 vtkSmartPointer<vtkPolyData> rightHandSide = reader2->GetOutput();
121 void testFlow(
char centerline[],
char image_prefix[],
double Vnyq,
double cutoff,
int nConvolutions,
char true_output[]){
122 const char testFile[] =
"/flowdirection_test_1.vtk";
140 for(
auto &spline: splines)
142 double flow_vel = spline.getIntersections().getEstimatedVelocity();
143 double flow_direction = spline.getIntersections().getEstimatedDirection();
149 void testFlowDirection_FlowVel(
char centerline[],
char image_prefix[],
double Vnyq,
double cutoff,
int nConvolutions,
double *true_flow){
162 TEST_CASE(
"AngleCorrection: Test flow direction estimation 1",
"[angle_correction]")
164 char centerline[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_01_20150527T125724_Angio_1_tsf_cl1.vtk";
165 char image_prefix[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_01_20150527T125724_raw/US-Acq_01_20150527T125724_Velocity_";
168 double cutoff = 0.18;
169 int nConvolutions = 6;
171 char true_output[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/trueOutputAngleCorr/output_flowdirection_test_1.vtk";
173 testFlow(centerline, image_prefix, Vnyq, cutoff, nConvolutions, true_output);
177 TEST_CASE(
"AngleCorrection: Test flow direction estimation 1 unit",
"[angle_correction]")
179 char centerline[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_01_20150527T125724_Angio_1_tsf_cl1.vtk";
180 char image_prefix[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_01_20150527T125724_raw/US-Acq_01_20150527T125724_Velocity_";
183 double cutoff = 0.18;
184 int nConvolutions = 6;
186 double true_flow [1]={-0.465};
194 TEST_CASE(
"AngleCorrection: Test flow direction estimation 2",
"[angle_correction][flow_dir][not_integration]")
196 char centerline[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_02_20150527T125751_Angio_1_tsf_cl1.vtk";
197 char image_prefix[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_02_20150527T125751/US-Acq_02_20150527T125751_Velocity_";
200 double cutoff = 0.18;
201 int nConvolutions = 6;
204 char true_output[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/trueOutputAngleCorr/output_flowdirection_test_2.vtk";
206 testFlow(centerline, image_prefix, Vnyq, cutoff, nConvolutions, true_output);
211 TEST_CASE(
"AngleCorrection: Test flow direction estimation 3",
"[angle_correction][not_integration][flow_dir][not_apple]")
213 char centerline[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_03_20150527T130026_Angio_1_tsf_cl1.vtk";
214 char image_prefix[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_03_20150527T130026/US-Acq_03_20150527T130026_Velocity_";
217 double cutoff = 0.18;
218 int nConvolutions = 6;
221 char true_output[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/trueOutputAngleCorr/output_flowdirection_test_3.vtk";
223 testFlow(centerline, image_prefix, Vnyq, cutoff, nConvolutions, true_output);
228 TEST_CASE(
"AngleCorrection: Test flow direction estimation 4",
"[angle_correction][not_integration][flow_dir]")
230 char centerline[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_04_20150527T130043_Angio_1_tsf_cl1.vtk";
231 char image_prefix[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_04_20150527T130043/US-Acq_04_20150527T130043_Velocity_";
234 double cutoff = 0.18;
235 int nConvolutions = 6;
238 char true_output[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/trueOutputAngleCorr/output_flowdirection_test_4.vtk";
240 testFlow(centerline, image_prefix, Vnyq, cutoff, nConvolutions, true_output);
245 TEST_CASE(
"AngleCorrection: Test flow direction estimation 5",
"[angle_correction][not_integration][flow_dir]")
247 char centerline[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_05_20150527T130229_Angio_1_tsf_cl1.vtk";
248 char image_prefix[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_05_20150527T130229/US-Acq_05_20150527T130229_Velocity_";
251 double cutoff = 0.18;
252 int nConvolutions = 6;
255 char true_output[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/trueOutputAngleCorr/output_flowdirection_test_5.vtk";
257 testFlow(centerline, image_prefix, Vnyq, cutoff, nConvolutions, true_output);
262 TEST_CASE(
"AngleCorrection: Test flow direction estimation 5 unit",
"[angle_correction][flow_dir]")
264 char centerline[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_05_20150527T130229_Angio_1_tsf_cl1.vtk";
265 char image_prefix[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_05_20150527T130229/US-Acq_05_20150527T130229_Velocity_";
268 double cutoff = 0.18;
269 int nConvolutions = 6;
271 double true_flow [2]={-0.933,0.239};
279 TEST_CASE(
"AngleCorrection: Test flow direction estimation 6",
"[angle_correction][not_integration][flow_dir]")
281 char centerline[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_06_20150527T130329_Angio_1_tsf_cl1.vtk";
282 char image_prefix[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_06_20150527T130329/US-Acq_06_20150527T130329_Velocity_";
285 double cutoff = 0.18;
286 int nConvolutions = 6;
289 char true_output[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/trueOutputAngleCorr/output_flowdirection_test_6.vtk";
291 testFlow(centerline, image_prefix, Vnyq, cutoff, nConvolutions, true_output);
296 TEST_CASE(
"AngleCorrection: Test flow direction estimation 7, aliasing",
"[angle_correction][not_integration][aliasing][not_apple]")
298 char centerline[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_07_20150527T130532_Angio_1_tsf_cl1.vtk";
299 char image_prefix[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_07_20150527T130532/US-Acq_07_20150527T130532_Velocity_";
302 double cutoff = 0.18;
303 int nConvolutions = 6;
306 char true_output[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/trueOutputAngleCorr/output_flowdirection_test_7.vtk";
308 testFlow(centerline, image_prefix, Vnyq, cutoff, nConvolutions, true_output);
313 TEST_CASE(
"AngleCorrection: Test flow direction estimation 8, aliasing",
"[angle_correction][not_integration][aliasing]")
315 char centerline[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_08_20150527T130558_Angio_1_tsf_cl1.vtk";
316 char image_prefix[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_08_20150527T130558/US-Acq_08_20150527T130558_Velocity_";
319 double cutoff = 0.18;
320 int nConvolutions = 6;
323 char true_output[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/trueOutputAngleCorr/output_flowdirection_test_8.vtk";
325 testFlow(centerline, image_prefix, Vnyq, cutoff, nConvolutions, true_output);
329 TEST_CASE(
"AngleCorrection: Test flow direction estimation 8, aliasing, unit",
"[angle_correction][aliasing]")
331 char centerline[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_08_20150527T130558_Angio_1_tsf_cl1.vtk";
332 char image_prefix[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_08_20150527T130558/US-Acq_08_20150527T130558_Velocity_";
335 double cutoff = 0.18;
336 int nConvolutions = 6;
338 double true_flow [1]={0.403};
345 TEST_CASE(
"AngleCorrection: Test flow direction estimation 9, cross movement",
"[angle_correction][not_integration]")
347 char centerline[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_09_20150527T131009_Angio_1_tsf_cl1.vtk";
348 char image_prefix[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_09_20150527T131009/US-Acq_09_20150527T131009_Velocity_";
351 double cutoff = 0.18;
352 int nConvolutions = 6;
355 char true_output[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/trueOutputAngleCorr/output_flowdirection_test_9.vtk";
357 testFlow(centerline, image_prefix, Vnyq, cutoff, nConvolutions, true_output);
361 TEST_CASE(
"AngleCorrection: Test flow direction estimation 10, cross movement",
"[angle_correction]")
363 char centerline[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_10_20150527T131055_Angio_1_tsf_cl1.vtk";
364 char image_prefix[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_10_20150527T131055/US-Acq_10_20150527T131055_Velocity_";
367 double cutoff = 0.18;
368 int nConvolutions = 6;
371 char true_output[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/trueOutputAngleCorr/output_flowdirection_test_10.vtk";
373 testFlow(centerline, image_prefix, Vnyq, cutoff, nConvolutions, true_output);
378 TEST_CASE(
"AngleCorrection: Test Invalid parameters",
"[angle_correction]")
381 char centerline[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/NonExisting.vtk";
382 char image_prefix[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_10_20150527T131055/US-Acq_10_20150527T131055_Velocity_";
385 double cutoff = 0.18;
386 int nConvolutions = 6;
387 double uncertainty_limit = 0.5;
388 double minArrowDist = 1.0;
397 char centerline2[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_10_20150527T131055_Angio_1_tsf_cl1.vtk";
398 char image_prefix2[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_10_20150527T131055/US-NonExisting";
403 char centerline3[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_10_20150527T131055_Angio_1_tsf_cl1.vtk";
404 char image_prefix3[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_10_20150527T131055/US-Acq_10_20150527T131055_Velocity_";
429 uncertainty_limit = 0;
434 uncertainty_limit = -0.5;
439 uncertainty_limit = 0.5;
457 TEST_CASE(
"AngleCorrection: Test several runs",
"[angle_correction][not_integration]")
459 char centerline[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_10_20150527T131055_Angio_1_tsf_cl1.vtk";
460 char image_prefix[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_10_20150527T131055/US-Acq_10_20150527T131055_Velocity_";
463 double cutoff = 0.18;
464 int nConvolutions = 6;
465 double uncertainty_limit = 0.5;
466 double minArrowDist = 1.0;
469 char centerline2[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_06_20150527T130329_Angio_1_tsf_cl1.vtk";
470 char image_prefix2[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_06_20150527T130329/US-Acq_06_20150527T130329_Velocity_";
472 double Vnyq2 = 0.312;
473 double cutoff2 = 0.18;
474 int nConvolutions2 = 6;
476 const char* filename_a =
"/flowdirection_test_11_a.vtk";
477 const char* filename_b =
"/flowdirection_test_11_b.vtk";
564 TEST_CASE(
"AngleCorrection: Test several runs cl pointer input",
"[angle_correction][not_integration][not_apple]")
567 char centerline[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_10_20150527T131055_Angio_1_tsf_cl1.vtk";
568 char image_prefix[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_10_20150527T131055/US-Acq_10_20150527T131055_Velocity_";
571 double cutoff = 0.18;
572 int nConvolutions = 6;
573 double uncertainty_limit = 0.5;
574 double minArrowDist = 1.0;
576 vtkSmartPointer<vtkPolyDataReader> clReader1 = vtkSmartPointer<vtkPolyDataReader>::New();
579 vtkSmartPointer<vtkPolyData> vpd_centerline1 = clReader1->GetOutput();
580 const char* filename_a =
"/flowdirection_test_11_a.vtk";
581 const char* filename_b =
"/flowdirection_test_11_b.vtk";
586 angleCorr.
setInput(vpd_centerline1,
appendTestFolder(image_prefix), Vnyq, cutoff, nConvolutions, uncertainty_limit,minArrowDist);
601 angleCorr.
setInput(vpd_centerline1,
appendTestFolder(image_prefix), Vnyq, cutoff, nConvolutions, uncertainty_limit,minArrowDist);
613 angleCorr.
setInput(vpd_centerline1,
appendTestFolder(image_prefix), Vnyq, cutoff, nConvolutions, uncertainty_limit,minArrowDist);
621 angleCorr.
setInput(vpd_centerline1,
appendTestFolder(image_prefix), Vnyq, cutoff, nConvolutions, uncertainty_limit,minArrowDist);
629 angleCorr.
setInput(vpd_centerline1,
appendTestFolder(image_prefix), Vnyq, cutoff, nConvolutions, uncertainty_limit,minArrowDist);
637 angleCorr.
setInput(vpd_centerline1,
appendTestFolder(image_prefix), Vnyq, cutoff, nConvolutions, uncertainty_limit,minArrowDist);
645 angleCorr.
setInput(vpd_centerline1,
appendTestFolder(image_prefix), Vnyq, cutoff, nConvolutions, uncertainty_limit,minArrowDist);
653 angleCorr.
setInput(vpd_centerline1,
appendTestFolder(image_prefix), Vnyq, cutoff, nConvolutions, uncertainty_limit,minArrowDist);
660 angleCorr.
setInput(vpd_centerline1,
appendTestFolder(image_prefix), Vnyq, cutoff, nConvolutions, uncertainty_limit,minArrowDist);
661 vpd_centerline1=vtkSmartPointer<vtkPolyData>::New();
668 vpd_centerline1=vtkSmartPointer<vtkPolyData>::New();
678 TEST_CASE(
"AngleCorrection: Benchmark",
"[angle_correction][Benchmark]")
681 double run_time = 0.0;
686 char centerline1[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_01_20150527T125724_Angio_1_tsf_cl1.vtk";
687 char image_prefix1[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_01_20150527T125724_raw/US-Acq_01_20150527T125724_Velocity_";
688 double Vnyq1 = 0.312;
689 double cutoff1 = 0.18;
690 int nConvolutions1 = 6;
698 char centerline2[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_02_20150527T125751_Angio_1_tsf_cl1.vtk";
699 char image_prefix2[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_02_20150527T125751/US-Acq_02_20150527T125751_Velocity_";
700 double Vnyq2 = 0.312;
701 double cutoff2 = 0.18;
702 int nConvolutions2 = 6;
709 char centerline3[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_03_20150527T130026_Angio_1_tsf_cl1.vtk";
710 char image_prefix3[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_03_20150527T130026/US-Acq_03_20150527T130026_Velocity_";
711 double Vnyq3 = 0.312;
712 double cutoff3 = 0.18;
713 int nConvolutions3 = 6;
720 char centerline4[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_04_20150527T130043_Angio_1_tsf_cl1.vtk";
721 char image_prefix4[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_04_20150527T130043/US-Acq_04_20150527T130043_Velocity_";
722 double Vnyq4 = 0.312;
723 double cutoff4 = 0.18;
724 int nConvolutions4 = 6;
731 char centerline5[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_05_20150527T130229_Angio_1_tsf_cl1.vtk";
732 char image_prefix5[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_05_20150527T130229/US-Acq_05_20150527T130229_Velocity_";
733 double Vnyq5 = 0.312;
734 double cutoff5 = 0.18;
735 int nConvolutions5 = 6;
742 char centerline6[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_06_20150527T130329_Angio_1_tsf_cl1.vtk";
743 char image_prefix6[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_06_20150527T130329/US-Acq_06_20150527T130329_Velocity_";
744 double Vnyq6 = 0.312;
745 double cutoff6 = 0.18;
746 int nConvolutions6 = 6;
753 char centerline7[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_07_20150527T130532_Angio_1_tsf_cl1.vtk";
754 char image_prefix7[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_07_20150527T130532/US-Acq_07_20150527T130532_Velocity_";
755 double Vnyq7 = 0.156;
756 double cutoff7 = 0.18;
757 int nConvolutions7 = 6;
764 char centerline8[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_08_20150527T130558_Angio_1_tsf_cl1.vtk";
765 char image_prefix8[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_08_20150527T130558/US-Acq_08_20150527T130558_Velocity_";
766 double Vnyq8 = 0.156;
767 double cutoff8 = 0.18;
768 int nConvolutions8 = 6;
775 char centerline9[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_09_20150527T131009_Angio_1_tsf_cl1.vtk";
776 char image_prefix9[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_09_20150527T131009/US-Acq_09_20150527T131009_Velocity_";
777 double Vnyq9 = 0.312;
778 double cutoff9 = 0.18;
779 int nConvolutions9 = 6;
787 char centerline10[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_10_20150527T131055_Angio_1_tsf_cl1.vtk";
788 char image_prefix10[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_10_20150527T131055/US-Acq_10_20150527T131055_Velocity_";
789 double Vnyq10 = 0.312;
790 double cutoff10 = 0.18;
791 int nConvolutions10 = 6;
799 run_time = (double) (stop-start)/CLOCKS_PER_SEC;
802 cerr <<
"Run time: " << run_time <<
"\n";
807 TEST_CASE(
"AngleCorrection: Test several runs cl pointer input simple",
"[angle_correction][not_integration][simple]")
810 char centerline[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_10_20150527T131055_Angio_1_tsf_cl1.vtk";
811 char image_prefix[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_10_20150527T131055/US-Acq_10_20150527T131055_Velocity_";
814 double cutoff = 0.18;
815 int nConvolutions = 6;
816 double uncertainty_limit = 0.5;
817 double minArrowDist = 1.0;
819 vtkSmartPointer<vtkPolyDataReader> clReader1 = vtkSmartPointer<vtkPolyDataReader>::New();
822 vtkSmartPointer<vtkPolyData> vpd_centerline1 = clReader1->GetOutput();
823 const char* filename_a =
"/flowdirection_test_11_a.vtk";
824 const char* filename_b =
"/flowdirection_test_11_b.vtk";
829 angleCorr.
setInput(vpd_centerline1,
appendTestFolder(image_prefix), Vnyq, cutoff, nConvolutions, uncertainty_limit,minArrowDist);
844 angleCorr.
setInput(vpd_centerline1,
appendTestFolder(image_prefix), Vnyq, cutoff, nConvolutions, uncertainty_limit,minArrowDist);
855 angleCorr.
setInput(vpd_centerline1,
appendTestFolder(image_prefix), Vnyq, cutoff, nConvolutions, uncertainty_limit,minArrowDist);
864 TEST_CASE(
"AngleCorrection: Test flow direction estimation tumour data",
"[angle_correction][not_integration]")
866 const char* filename_a =
"/flowdirection_test_11_a.vtk";
868 char centerline[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_02_20150625T105554_Angio_1_tsf_cl1.vtk";
869 char image_prefix[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_02_20150625T105554/US-Acq_02_20150625T105554_Velocity_";
873 int nConvolutions = 5;
876 char true_output[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/trueOutputAngleCorr/output_flowdirection_test_tumour.vtk";
878 testFlow(centerline, image_prefix, Vnyq, cutoff, nConvolutions, true_output);
883 double uncertainty_limit = 0;
884 double minArrowDist =2;
895 uncertainty_limit = 0.5;
907 TEST_CASE(
"AngleCorrection: Test flow direction estimation tumour data, unit",
"[angle_correction]")
909 char centerline[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/Images/US_02_20150625T105554_Angio_1_tsf_cl1.vtk";
910 char image_prefix[] =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_02_20150625T105554/US-Acq_02_20150625T105554_Velocity_";
914 int nConvolutions = 5;
918 double uncertainty_limit = 0;
919 double minArrowDist =2;
934 REQUIRE(outSpline.at(0).getTransform());
936 uncertainty_limit = 0.5;
946 vtkSmartPointer<vtkPolyData> out;
951 const char* filename_a =
"/flowdirection_test_11_a.vtk";
954 vtkSmartPointer<ErrorObserver> errorObserver = vtkSmartPointer<ErrorObserver>::New();
956 vtkSmartPointer<vtkPolyDataReader> reader1 = vtkSmartPointer<vtkPolyDataReader>::New();
957 reader1->AddObserver(vtkCommand::ErrorEvent,errorObserver);
961 bool readFilesSuccesfully =
true;
962 if (errorObserver->GetError() ||errorObserver->GetWarning()){
963 readFilesSuccesfully =
false;
968 vtkSmartPointer<vtkPolyData> leftHandSide = reader1->GetOutput();
977 TEST_CASE(
"AngleCorrection: Test error handler",
"[angle_correction]")
979 vtkSmartPointer<ErrorObserver> errorObserver = vtkSmartPointer<ErrorObserver>::New();
982 REQUIRE(!errorObserver->GetError());
983 REQUIRE(!errorObserver->GetWarning());
984 REQUIRE(errorObserver->GetErrorMessage().length()==0);
985 REQUIRE(errorObserver->GetWarningMessage().length()==0);
987 const char* filename_a =
"/2015-05-27_12-02_AngelCorr_tets.cx3/US_Acq/US-Acq_10_20150527T131055/US-NonExisting";
988 vtkSmartPointer<vtkPolyDataReader> reader1 = vtkSmartPointer<vtkPolyDataReader>::New();
989 reader1->AddObserver(vtkCommand::ErrorEvent,errorObserver);
993 REQUIRE(errorObserver->GetError());
994 REQUIRE(!errorObserver->GetWarning());
995 REQUIRE(errorObserver->GetErrorMessage().length()>0);
996 REQUIRE(errorObserver->GetWarningMessage().length()==0);
1000 REQUIRE(!errorObserver->GetError());
1001 REQUIRE(!errorObserver->GetWarning());
1002 REQUIRE(errorObserver->GetErrorMessage().length()==0);
1003 REQUIRE(errorObserver->GetWarningMessage().length()==0);
void setInput(vtkSmartPointer< vtkPolyData > vpd_centerline, const char *image_prefix, double Vnyq, double cutoff, int nConvolutions, double uncertainty_limit=0.0, double minArrowDist=1.0)
void validateFlowDirection_FlowVel(vectorSpline3dDouble splines, double *true_flow)
void testFlow(char centerline[], char image_prefix[], double Vnyq, double cutoff, int nConvolutions, char true_output[])
vector< Spline3D< double > > vectorSpline3dDouble
void writeDirectionToVtkFile(const char *filename)
char * appendTestFolder(const char *filename)
vtkSmartPointer< vtkPolyData > getOutput()
#define REQUIRE_THROWS(expr)
vectorSpline3dDouble getClSpline()
void validateFiles(const char *filename_a, const char *filename_b, bool shouldBeEqual=true)
#define REQUIRE_NOTHROW(expr)
TEST_CASE("AngleCorrection: Test flow direction estimation 1","[angle_correction]")
void testFlowDirection_FlowVel(char centerline[], char image_prefix[], double Vnyq, double cutoff, int nConvolutions, double *true_flow)
void validateVtkPD(vtkSmartPointer< vtkPolyData > leftHandSide, vtkSmartPointer< vtkPolyData > rightHandSide, bool shouldBeEqual=true)