00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "mitkRigidRegistrationTestPreset.h"
00019 #include "mitkStandardFileLocations.h"
00020 #include "mitkMetricParameters.h"
00021 #include "mitkOptimizerParameters.h"
00022 #include "mitkTransformParameters.h"
00023
00024 namespace mitk {
00025
00026 RigidRegistrationTestPreset::RigidRegistrationTestPreset()
00027 {
00028 m_Name = "";
00029 m_XmlFileName = "mitkRigidRegistrationTestPresets.xml";
00030 }
00031
00032 RigidRegistrationTestPreset::~RigidRegistrationTestPreset()
00033 {
00034 }
00035
00036 bool RigidRegistrationTestPreset::LoadPreset()
00037 {
00038 std::string location1 = MITK_ROOT;
00039 std::string location2 = "/QFunctionalities/QmitkRigidRegistration";
00040 std::string location = location1 + location2;
00041 mitk::StandardFileLocations::GetInstance()->AddDirectoryForSearch(location.c_str(), true);
00042 std::string xmlFileName = mitk::StandardFileLocations::GetInstance()->FindFile("mitkRigidRegistrationTestPresets.xml", "Config");
00043
00044 if (!xmlFileName.empty())
00045 {
00046 m_XmlFileName = xmlFileName;
00047 return LoadPreset(m_XmlFileName);
00048 }
00049 else
00050 return false;
00051 }
00052
00053 bool RigidRegistrationTestPreset::LoadPreset(std::string fileName)
00054 {
00055 if ( fileName.empty() )
00056 return false;
00057
00058 vtkXMLParser::SetFileName( fileName.c_str() );
00059 m_XmlFileName = fileName;
00060
00061 if ( !vtkXMLParser::Parse() )
00062 {
00063 #ifdef INTERDEBUG
00064 MITK_INFO<<"RigidRegistrationTestPreset::LoadPreset xml file cannot parse!"<<std::endl;
00065 #endif
00066 }
00067
00068 return true;
00069
00070 }
00071
00072 void RigidRegistrationTestPreset::StartElement (const char *elementName, const char **atts)
00073 {
00074 std::string elementNameString = elementName;
00075 if ( elementNameString == "preset" )
00076 {
00077 m_Name = ReadXMLStringAttribut( "NAME", atts );
00078 }
00079 else if (elementNameString == "transform")
00080 {
00081 itk::Array<double> transformValues;
00082 transformValues.SetSize(25);
00083 transformValues.fill(0);
00084 std::string transform = ReadXMLStringAttribut( "TRANSFORM", atts );
00085 double trans = atof(transform.c_str());
00086 transformValues[0] = trans;
00087 transformValues = this->loadTransformValues(transformValues, trans, atts);
00088 m_TransformValues[m_Name] = transformValues;
00089 }
00090 else if (elementNameString == "metric")
00091 {
00092 itk::Array<double> metricValues;
00093 metricValues.SetSize(25);
00094 metricValues.fill(0);
00095 std::string metric = ReadXMLStringAttribut( "METRIC", atts );
00096 double met = atof(metric.c_str());
00097 metricValues[0] = met;
00098 metricValues = this->loadMetricValues(metricValues, met, atts);
00099 m_MetricValues[m_Name] = metricValues;
00100 }
00101 else if (elementNameString == "optimizer")
00102 {
00103 itk::Array<double> optimizerValues;
00104 optimizerValues.SetSize(25);
00105 optimizerValues.fill(0);
00106 std::string optimizer = ReadXMLStringAttribut( "OPTIMIZER", atts );
00107 double opt = atof(optimizer.c_str());
00108 optimizerValues[0] = opt;
00109 optimizerValues = this->loadOptimizerValues(optimizerValues, opt, atts);
00110 m_OptimizerValues[m_Name] = optimizerValues;
00111 }
00112 else if (elementNameString == "interpolator")
00113 {
00114 itk::Array<double> interpolatorValues;
00115 interpolatorValues.SetSize(25);
00116 interpolatorValues.fill(0);
00117 std::string interpolator = ReadXMLStringAttribut( "INTERPOLATOR", atts );
00118 double inter = atof(interpolator.c_str());
00119 interpolatorValues[0] = inter;
00120 interpolatorValues = this->loadInterpolatorValues(interpolatorValues);
00121 m_InterpolatorValues[m_Name] = interpolatorValues;
00122 }
00123 }
00124
00125 std::string RigidRegistrationTestPreset::ReadXMLStringAttribut( std::string name, const char** atts )
00126 {
00127 if(atts)
00128 {
00129 const char** attsIter = atts;
00130
00131 while(*attsIter)
00132 {
00133 if ( name == *attsIter )
00134 {
00135 attsIter++;
00136 return *attsIter;
00137 }
00138 attsIter++;
00139 attsIter++;
00140 }
00141 }
00142
00143 return std::string();
00144 }
00145
00146 itk::Array<double> RigidRegistrationTestPreset::getTransformValues(std::string name)
00147 {
00148 return m_TransformValues[name];
00149 }
00150
00151 itk::Array<double> RigidRegistrationTestPreset::getMetricValues(std::string name)
00152 {
00153 return m_MetricValues[name];
00154 }
00155
00156 itk::Array<double> RigidRegistrationTestPreset::getOptimizerValues(std::string name)
00157 {
00158 return m_OptimizerValues[name];
00159 }
00160
00161 itk::Array<double> RigidRegistrationTestPreset::getInterpolatorValues(std::string name)
00162 {
00163 return m_InterpolatorValues[name];
00164 }
00165
00166 std::map<std::string, itk::Array<double> >& RigidRegistrationTestPreset::getTransformValuesPresets()
00167 {
00168 return m_TransformValues;
00169 }
00170
00171 std::map<std::string, itk::Array<double> >& RigidRegistrationTestPreset::getMetricValuesPresets()
00172 {
00173 return m_MetricValues;
00174 }
00175
00176 std::map<std::string, itk::Array<double> >& RigidRegistrationTestPreset::getOptimizerValuesPresets()
00177 {
00178 return m_OptimizerValues;
00179 }
00180
00181 std::map<std::string, itk::Array<double> >& RigidRegistrationTestPreset::getInterpolatorValuesPresets()
00182 {
00183 return m_InterpolatorValues;
00184 }
00185
00186 bool RigidRegistrationTestPreset::save()
00187 {
00188
00189
00190 return false;
00191 }
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218 bool RigidRegistrationTestPreset::newPresets(std::map<std::string, itk::Array<double> > newTransformValues, std::map<std::string, itk::Array<double> > newMetricValues,
00219 std::map<std::string, itk::Array<double> > newOptimizerValues, std::map<std::string, itk::Array<double> > newInterpolatorValues, std::string fileName)
00220 {
00221 if ( !fileName.empty() )
00222 {
00223 m_XmlFileName = fileName;
00224 }
00225 m_TransformValues = newTransformValues;
00226 m_MetricValues = newMetricValues;
00227 m_OptimizerValues = newOptimizerValues;
00228 m_InterpolatorValues = newInterpolatorValues;
00229 return save();
00230 }
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523 itk::Array<double> RigidRegistrationTestPreset::loadTransformValues(itk::Array<double> transformValues, double transform, const char **atts)
00524 {
00525 if (transform == mitk::TransformParameters::TRANSLATIONTRANSFORM || transform == mitk::TransformParameters::SCALETRANSFORM ||
00526 transform == mitk::TransformParameters::SCALELOGARITHMICTRANSFORM || transform == mitk::TransformParameters::VERSORTRANSFORM ||
00527 transform == mitk::TransformParameters::RIGID2DTRANSFORM || transform == mitk::TransformParameters::EULER2DTRANSFORM)
00528 {
00529 std::string useScales = ReadXMLStringAttribut( "USESCALES", atts );
00530 double useSca = atof(useScales.c_str());
00531 transformValues[1] = useSca;
00532 std::string scale1 = ReadXMLStringAttribut( "SCALE1", atts );
00533 double sca1 = atof(scale1.c_str());
00534 transformValues[2] = sca1;
00535 std::string scale2 = ReadXMLStringAttribut( "SCALE2", atts );
00536 double sca2 = atof(scale2.c_str());
00537 transformValues[3] = sca2;
00538 std::string scale3 = ReadXMLStringAttribut( "SCALE3", atts );
00539 double sca3 = atof(scale3.c_str());
00540 transformValues[4] = sca3;
00541 }
00542 else if (transform == mitk::TransformParameters::AFFINETRANSFORM || transform == mitk::TransformParameters::FIXEDCENTEROFROTATIONAFFINETRANSFORM)
00543 {
00544 std::string useScales = ReadXMLStringAttribut( "USESCALES", atts );
00545 double useSca = atof(useScales.c_str());
00546 transformValues[1] = useSca;
00547 std::string scale1 = ReadXMLStringAttribut( "SCALE1", atts );
00548 double sca1 = atof(scale1.c_str());
00549 transformValues[2] = sca1;
00550 std::string scale2 = ReadXMLStringAttribut( "SCALE2", atts );
00551 double sca2 = atof(scale2.c_str());
00552 transformValues[3] = sca2;
00553 std::string scale3 = ReadXMLStringAttribut( "SCALE3", atts );
00554 double sca3 = atof(scale3.c_str());
00555 transformValues[4] = sca3;
00556 std::string scale4 = ReadXMLStringAttribut( "SCALE4", atts );
00557 double sca4 = atof(scale4.c_str());
00558 transformValues[5] = sca4;
00559 std::string scale5 = ReadXMLStringAttribut( "SCALE5", atts );
00560 double sca5 = atof(scale5.c_str());
00561 transformValues[6] = sca5;
00562 std::string scale6 = ReadXMLStringAttribut( "SCALE6", atts );
00563 double sca6 = atof(scale6.c_str());
00564 transformValues[7] = sca6;
00565 std::string scale7 = ReadXMLStringAttribut( "SCALE7", atts );
00566 double sca7 = atof(scale7.c_str());
00567 transformValues[8] = sca7;
00568 std::string scale8 = ReadXMLStringAttribut( "SCALE8", atts );
00569 double sca8 = atof(scale8.c_str());
00570 transformValues[9] = sca8;
00571 std::string scale9 = ReadXMLStringAttribut( "SCALE9", atts );
00572 double sca9 = atof(scale9.c_str());
00573 transformValues[10] = sca9;
00574 std::string scale10 = ReadXMLStringAttribut( "SCALE10", atts );
00575 double sca10 = atof(scale10.c_str());
00576 transformValues[11] = sca10;
00577 std::string scale11 = ReadXMLStringAttribut( "SCALE11", atts );
00578 double sca11 = atof(scale11.c_str());
00579 transformValues[12] = sca11;
00580 std::string scale12 = ReadXMLStringAttribut( "SCALE12", atts );
00581 double sca12 = atof(scale12.c_str());
00582 transformValues[13] = sca12;
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599 std::string useInitializer = ReadXMLStringAttribut( "USEINITIALIZER", atts );
00600 double useIni = atof(useInitializer.c_str());
00601 transformValues[14] = useIni;
00602 std::string useMoments = ReadXMLStringAttribut( "USEMOMENTS", atts );
00603 double useMo = atof(useMoments.c_str());
00604 transformValues[15] = useMo;
00605 }
00606 else if (transform == mitk::TransformParameters::RIGID3DTRANSFORM)
00607 {
00608 std::string useScales = ReadXMLStringAttribut( "USESCALES", atts );
00609 double useSca = atof(useScales.c_str());
00610 transformValues[1] = useSca;
00611 std::string scale1 = ReadXMLStringAttribut( "SCALE1", atts );
00612 double sca1 = atof(scale1.c_str());
00613 transformValues[2] = sca1;
00614 std::string scale2 = ReadXMLStringAttribut( "SCALE2", atts );
00615 double sca2 = atof(scale2.c_str());
00616 transformValues[3] = sca2;
00617 std::string scale3 = ReadXMLStringAttribut( "SCALE3", atts );
00618 double sca3 = atof(scale3.c_str());
00619 transformValues[4] = sca3;
00620 std::string scale4 = ReadXMLStringAttribut( "SCALE4", atts );
00621 double sca4 = atof(scale4.c_str());
00622 transformValues[5] = sca4;
00623 std::string scale5 = ReadXMLStringAttribut( "SCALE5", atts );
00624 double sca5 = atof(scale5.c_str());
00625 transformValues[6] = sca5;
00626 std::string scale6 = ReadXMLStringAttribut( "SCALE6", atts );
00627 double sca6 = atof(scale6.c_str());
00628 transformValues[7] = sca6;
00629 std::string scale7 = ReadXMLStringAttribut( "SCALE7", atts );
00630 double sca7 = atof(scale7.c_str());
00631 transformValues[8] = sca7;
00632 std::string scale8 = ReadXMLStringAttribut( "SCALE8", atts );
00633 double sca8 = atof(scale8.c_str());
00634 transformValues[9] = sca8;
00635 std::string scale9 = ReadXMLStringAttribut( "SCALE9", atts );
00636 double sca9 = atof(scale9.c_str());
00637 transformValues[10] = sca9;
00638 std::string scale10 = ReadXMLStringAttribut( "SCALE10", atts );
00639 double sca10 = atof(scale10.c_str());
00640 transformValues[11] = sca10;
00641 std::string scale11 = ReadXMLStringAttribut( "SCALE11", atts );
00642 double sca11 = atof(scale11.c_str());
00643 transformValues[12] = sca11;
00644 std::string scale12 = ReadXMLStringAttribut( "SCALE12", atts );
00645 double sca12 = atof(scale12.c_str());
00646 transformValues[13] = sca12;
00647 std::string useInitializer = ReadXMLStringAttribut( "USEINITIALIZER", atts );
00648 double useIni = atof(useInitializer.c_str());
00649 transformValues[14] = useIni;
00650 std::string useMoments = ReadXMLStringAttribut( "USEMOMENTS", atts );
00651 double useMo = atof(useMoments.c_str());
00652 transformValues[15] = useMo;
00653 }
00654 else if (transform == mitk::TransformParameters::EULER3DTRANSFORM || transform == mitk::TransformParameters::CENTEREDEULER3DTRANSFORM
00655 || transform == mitk::TransformParameters::VERSORRIGID3DTRANSFORM)
00656 {
00657 std::string useScales = ReadXMLStringAttribut( "USESCALES", atts );
00658 double useSca = atof(useScales.c_str());
00659 transformValues[1] = useSca;
00660 std::string scale1 = ReadXMLStringAttribut( "SCALE1", atts );
00661 double sca1 = atof(scale1.c_str());
00662 transformValues[2] = sca1;
00663 std::string scale2 = ReadXMLStringAttribut( "SCALE2", atts );
00664 double sca2 = atof(scale2.c_str());
00665 transformValues[3] = sca2;
00666 std::string scale3 = ReadXMLStringAttribut( "SCALE3", atts );
00667 double sca3 = atof(scale3.c_str());
00668 transformValues[4] = sca3;
00669 std::string scale4 = ReadXMLStringAttribut( "SCALE4", atts );
00670 double sca4 = atof(scale4.c_str());
00671 transformValues[5] = sca4;
00672 std::string scale5 = ReadXMLStringAttribut( "SCALE5", atts );
00673 double sca5 = atof(scale5.c_str());
00674 transformValues[6] = sca5;
00675 std::string scale6 = ReadXMLStringAttribut( "SCALE6", atts );
00676 double sca6 = atof(scale6.c_str());
00677 transformValues[7] = sca6;
00678 std::string useInitializer = ReadXMLStringAttribut( "USEINITIALIZER", atts );
00679 double useIni = atof(useInitializer.c_str());
00680 transformValues[8] = useIni;
00681 std::string useMoments = ReadXMLStringAttribut( "USEMOMENTS", atts );
00682 double useMo = atof(useMoments.c_str());
00683 transformValues[9] = useMo;
00684 }
00685 else if (transform == mitk::TransformParameters::QUATERNIONRIGIDTRANSFORM || transform == mitk::TransformParameters::SIMILARITY3DTRANSFORM)
00686 {
00687 std::string useScales = ReadXMLStringAttribut( "USESCALES", atts );
00688 double useSca = atof(useScales.c_str());
00689 transformValues[1] = useSca;
00690 std::string scale1 = ReadXMLStringAttribut( "SCALE1", atts );
00691 double sca1 = atof(scale1.c_str());
00692 transformValues[2] = sca1;
00693 std::string scale2 = ReadXMLStringAttribut( "SCALE2", atts );
00694 double sca2 = atof(scale2.c_str());
00695 transformValues[3] = sca2;
00696 std::string scale3 = ReadXMLStringAttribut( "SCALE3", atts );
00697 double sca3 = atof(scale3.c_str());
00698 transformValues[4] = sca3;
00699 std::string scale4 = ReadXMLStringAttribut( "SCALE4", atts );
00700 double sca4 = atof(scale4.c_str());
00701 transformValues[5] = sca4;
00702 std::string scale5 = ReadXMLStringAttribut( "SCALE5", atts );
00703 double sca5 = atof(scale5.c_str());
00704 transformValues[6] = sca5;
00705 std::string scale6 = ReadXMLStringAttribut( "SCALE6", atts );
00706 double sca6 = atof(scale6.c_str());
00707 transformValues[7] = sca6;
00708 std::string scale7 = ReadXMLStringAttribut( "SCALE7", atts );
00709 double sca7 = atof(scale7.c_str());
00710 transformValues[8] = sca7;
00711 std::string useInitializer = ReadXMLStringAttribut( "USEINITIALIZER", atts );
00712 double useIni = atof(useInitializer.c_str());
00713 transformValues[9] = useIni;
00714 std::string useMoments = ReadXMLStringAttribut( "USEMOMENTS", atts );
00715 double useMo = atof(useMoments.c_str());
00716 transformValues[10] = useMo;
00717 }
00718 else if (transform == mitk::TransformParameters::SCALESKEWVERSOR3DTRANSFORM)
00719 {
00720 std::string useScales = ReadXMLStringAttribut( "USESCALES", atts );
00721 double useSca = atof(useScales.c_str());
00722 transformValues[1] = useSca;
00723 std::string scale1 = ReadXMLStringAttribut( "SCALE1", atts );
00724 double sca1 = atof(scale1.c_str());
00725 transformValues[2] = sca1;
00726 std::string scale2 = ReadXMLStringAttribut( "SCALE2", atts );
00727 double sca2 = atof(scale2.c_str());
00728 transformValues[3] = sca2;
00729 std::string scale3 = ReadXMLStringAttribut( "SCALE3", atts );
00730 double sca3 = atof(scale3.c_str());
00731 transformValues[4] = sca3;
00732 std::string scale4 = ReadXMLStringAttribut( "SCALE4", atts );
00733 double sca4 = atof(scale4.c_str());
00734 transformValues[5] = sca4;
00735 std::string scale5 = ReadXMLStringAttribut( "SCALE5", atts );
00736 double sca5 = atof(scale5.c_str());
00737 transformValues[6] = sca5;
00738 std::string scale6 = ReadXMLStringAttribut( "SCALE6", atts );
00739 double sca6 = atof(scale6.c_str());
00740 transformValues[7] = sca6;
00741 std::string scale7 = ReadXMLStringAttribut( "SCALE7", atts );
00742 double sca7 = atof(scale7.c_str());
00743 transformValues[8] = sca7;
00744 std::string scale8 = ReadXMLStringAttribut( "SCALE8", atts );
00745 double sca8 = atof(scale8.c_str());
00746 transformValues[9] = sca8;
00747 std::string scale9 = ReadXMLStringAttribut( "SCALE9", atts );
00748 double sca9 = atof(scale9.c_str());
00749 transformValues[10] = sca9;
00750 std::string scale10 = ReadXMLStringAttribut( "SCALE10", atts );
00751 double sca10 = atof(scale10.c_str());
00752 transformValues[11] = sca10;
00753 std::string scale11 = ReadXMLStringAttribut( "SCALE11", atts );
00754 double sca11 = atof(scale11.c_str());
00755 transformValues[12] = sca11;
00756 std::string scale12 = ReadXMLStringAttribut( "SCALE12", atts );
00757 double sca12 = atof(scale12.c_str());
00758 transformValues[13] = sca12;
00759 std::string scale13 = ReadXMLStringAttribut( "SCALE13", atts );
00760 double sca13 = atof(scale13.c_str());
00761 transformValues[14] = sca13;
00762 std::string scale14 = ReadXMLStringAttribut( "SCALE14", atts );
00763 double sca14 = atof(scale14.c_str());
00764 transformValues[15] = sca14;
00765 std::string scale15 = ReadXMLStringAttribut( "SCALE15", atts );
00766 double sca15 = atof(scale15.c_str());
00767 transformValues[16] = sca15;
00768 std::string useInitializer = ReadXMLStringAttribut( "USEINITIALIZER", atts );
00769 double useIni = atof(useInitializer.c_str());
00770 transformValues[17] = useIni;
00771 std::string useMoments = ReadXMLStringAttribut( "USEMOMENTS", atts );
00772 double useMo = atof(useMoments.c_str());
00773 transformValues[18] = useMo;
00774 }
00775 else if (transform == mitk::TransformParameters::CENTEREDRIGID2DTRANSFORM)
00776 {
00777 std::string useScales = ReadXMLStringAttribut( "USESCALES", atts );
00778 double useSca = atof(useScales.c_str());
00779 transformValues[1] = useSca;
00780 std::string scale1 = ReadXMLStringAttribut( "SCALE1", atts );
00781 double sca1 = atof(scale1.c_str());
00782 transformValues[2] = sca1;
00783 std::string scale2 = ReadXMLStringAttribut( "SCALE2", atts );
00784 double sca2 = atof(scale2.c_str());
00785 transformValues[3] = sca2;
00786 std::string scale3 = ReadXMLStringAttribut( "SCALE3", atts );
00787 double sca3 = atof(scale3.c_str());
00788 transformValues[4] = sca3;
00789 std::string scale4 = ReadXMLStringAttribut( "SCALE4", atts );
00790 double sca4 = atof(scale4.c_str());
00791 transformValues[5] = sca4;
00792 std::string scale5 = ReadXMLStringAttribut( "SCALE5", atts );
00793 double sca5 = atof(scale5.c_str());
00794 transformValues[6] = sca5;
00795 std::string angle = ReadXMLStringAttribut( "ANGLE", atts );
00796 double ang = atof(angle.c_str());
00797 transformValues[7] = ang;
00798 std::string useInitializer = ReadXMLStringAttribut( "USEINITIALIZER", atts );
00799 double useIni = atof(useInitializer.c_str());
00800 transformValues[8] = useIni;
00801 std::string useMoments = ReadXMLStringAttribut( "USEMOMENTS", atts );
00802 double useMo = atof(useMoments.c_str());
00803 transformValues[9] = useMo;
00804 }
00805 else if (transform == mitk::TransformParameters::SIMILARITY2DTRANSFORM)
00806 {
00807 std::string useScales = ReadXMLStringAttribut( "USESCALES", atts );
00808 double useSca = atof(useScales.c_str());
00809 transformValues[1] = useSca;
00810 std::string scale1 = ReadXMLStringAttribut( "SCALE1", atts );
00811 double sca1 = atof(scale1.c_str());
00812 transformValues[2] = sca1;
00813 std::string scale2 = ReadXMLStringAttribut( "SCALE2", atts );
00814 double sca2 = atof(scale2.c_str());
00815 transformValues[3] = sca2;
00816 std::string scale3 = ReadXMLStringAttribut( "SCALE3", atts );
00817 double sca3 = atof(scale3.c_str());
00818 transformValues[4] = sca3;
00819 std::string scale4 = ReadXMLStringAttribut( "SCALE4", atts );
00820 double sca4 = atof(scale4.c_str());
00821 transformValues[5] = sca4;
00822 std::string scale = ReadXMLStringAttribut( "SCALE", atts );
00823 double sca = atof(scale.c_str());
00824 transformValues[6] = sca;
00825 std::string angle = ReadXMLStringAttribut( "ANGLE", atts );
00826 double ang = atof(angle.c_str());
00827 transformValues[7] = ang;
00828 std::string useInitializer = ReadXMLStringAttribut( "USEINITIALIZER", atts );
00829 double useIni = atof(useInitializer.c_str());
00830 transformValues[8] = useIni;
00831 std::string useMoments = ReadXMLStringAttribut( "USEMOMENTS", atts );
00832 double useMo = atof(useMoments.c_str());
00833 transformValues[9] = useMo;
00834 }
00835 else if (transform == mitk::TransformParameters::CENTEREDSIMILARITY2DTRANSFORM)
00836 {
00837 std::string useScales = ReadXMLStringAttribut( "USESCALES", atts );
00838 double useSca = atof(useScales.c_str());
00839 transformValues[1] = useSca;
00840 std::string scale1 = ReadXMLStringAttribut( "SCALE1", atts );
00841 double sca1 = atof(scale1.c_str());
00842 transformValues[2] = sca1;
00843 std::string scale2 = ReadXMLStringAttribut( "SCALE2", atts );
00844 double sca2 = atof(scale2.c_str());
00845 transformValues[3] = sca2;
00846 std::string scale3 = ReadXMLStringAttribut( "SCALE3", atts );
00847 double sca3 = atof(scale3.c_str());
00848 transformValues[4] = sca3;
00849 std::string scale4 = ReadXMLStringAttribut( "SCALE4", atts );
00850 double sca4 = atof(scale4.c_str());
00851 transformValues[5] = sca4;
00852 std::string scale5 = ReadXMLStringAttribut( "SCALE5", atts );
00853 double sca5 = atof(scale5.c_str());
00854 transformValues[6] = sca5;
00855 std::string scale6 = ReadXMLStringAttribut( "SCALE6", atts );
00856 double sca6 = atof(scale6.c_str());
00857 transformValues[7] = sca6;
00858 std::string scale = ReadXMLStringAttribut( "SCALE", atts );
00859 double sca = atof(scale.c_str());
00860 transformValues[8] = sca;
00861 std::string angle = ReadXMLStringAttribut( "ANGLE", atts );
00862 double ang = atof(angle.c_str());
00863 transformValues[9] = ang;
00864 std::string useInitializer = ReadXMLStringAttribut( "USEINITIALIZER", atts );
00865 double useIni = atof(useInitializer.c_str());
00866 transformValues[10] = useIni;
00867 std::string useMoments = ReadXMLStringAttribut( "USEMOMENTS", atts );
00868 double useMo = atof(useMoments.c_str());
00869 transformValues[11] = useMo;
00870 }
00871 return transformValues;
00872 }
00873
00874 itk::Array<double> RigidRegistrationTestPreset::loadMetricValues(itk::Array<double> metricValues, double metric, const char **atts)
00875 {
00876 std::string computeGradient = ReadXMLStringAttribut( "COMPUTEGRADIENT", atts );
00877 double compGra = atof(computeGradient.c_str());
00878 metricValues[1] = compGra;
00879 if (metric == mitk::MetricParameters::MEANSQUARESIMAGETOIMAGEMETRIC || metric == mitk::MetricParameters::NORMALIZEDCORRELATIONIMAGETOIMAGEMETRIC
00880 || metric == mitk::MetricParameters::GRADIENTDIFFERENCEIMAGETOIMAGEMETRIC || metric == mitk::MetricParameters::MATCHCARDINALITYIMAGETOIMAGEMETRIC
00881 || metric == mitk::MetricParameters::KAPPASTATISTICIMAGETOIMAGEMETRIC)
00882 {
00883 }
00884 else if (metric == mitk::MetricParameters::KULLBACKLEIBLERCOMPAREHISTOGRAMIMAGETOIMAGEMETRIC
00885 || metric == mitk::MetricParameters::CORRELATIONCOEFFICIENTHISTOGRAMIMAGETOIMAGEMETRIC
00886 || metric == mitk::MetricParameters::MEANSQUARESHISTOGRAMIMAGETOIMAGEMETRIC
00887 || metric == mitk::MetricParameters::MUTUALINFORMATIONHISTOGRAMIMAGETOIMAGEMETRIC
00888 || metric == mitk::MetricParameters::NORMALIZEDMUTUALINFORMATIONHISTOGRAMIMAGETOIMAGEMETRIC)
00889 {
00890 std::string histogramBins = ReadXMLStringAttribut( "HISTOGRAMBINS", atts );
00891 double histBins = atof(histogramBins.c_str());
00892 metricValues[2] = histBins;
00893 }
00894 else if (metric == mitk::MetricParameters::MATTESMUTUALINFORMATIONIMAGETOIMAGEMETRIC)
00895 {
00896 std::string useSampling = ReadXMLStringAttribut( "USESAMPLING", atts );
00897 double useSamp = atof(useSampling.c_str());
00898 metricValues[2] = useSamp;
00899 std::string spatialSamples = ReadXMLStringAttribut( "SPATIALSAMPLES", atts );
00900 double spatSamp = atof(spatialSamples.c_str());
00901 metricValues[3] = spatSamp;
00902 std::string histogramBins = ReadXMLStringAttribut( "HISTOGRAMBINS", atts );
00903 double histBins = atof(histogramBins.c_str());
00904 metricValues[4] = histBins;
00905 }
00906 else if (metric == mitk::MetricParameters::MEANRECIPROCALSQUAREDIFFERENCEIMAGETOIMAGEMETRIC)
00907 {
00908 std::string lambda = ReadXMLStringAttribut( "LAMBDA", atts );
00909 double lamb = atof(lambda.c_str());
00910 metricValues[2] = lamb;
00911 }
00912 else if (metric == mitk::MetricParameters::MUTUALINFORMATIONIMAGETOIMAGEMETRIC)
00913 {
00914 std::string spatialSamples = ReadXMLStringAttribut( "SPATIALSAMPLES", atts );
00915 double spatSamp = atof(spatialSamples.c_str());
00916 metricValues[2] = spatSamp;
00917 std::string fixedStandardDeviation = ReadXMLStringAttribut( "FIXEDSTANDARDDEVIATION", atts );
00918 double fiStaDev = atof(fixedStandardDeviation.c_str());
00919 metricValues[3] = fiStaDev;
00920 std::string movingStandardDeviation = ReadXMLStringAttribut( "MOVINGSTANDARDDEVIATION", atts );
00921 double moStaDev = atof(movingStandardDeviation.c_str());
00922 metricValues[4] = moStaDev;
00923 std::string useNormalizer = ReadXMLStringAttribut( "USENORMALIZERANDSMOOTHER", atts );
00924 double useNormal = atof(useNormalizer.c_str());
00925 metricValues[5] = useNormal;
00926 std::string fixedSmootherVariance = ReadXMLStringAttribut( "FIXEDSMOOTHERVARIANCE", atts );
00927 double fiSmoVa = atof(fixedSmootherVariance.c_str());
00928 metricValues[6] = fiSmoVa;
00929 std::string movingSmootherVariance = ReadXMLStringAttribut( "MOVINGSMOOTHERVARIANCE", atts );
00930 double moSmoVa = atof(movingSmootherVariance.c_str());
00931 metricValues[7] = moSmoVa;
00932 }
00933 return metricValues;
00934 }
00935
00936 itk::Array<double> RigidRegistrationTestPreset::loadOptimizerValues(itk::Array<double> optimizerValues, double optimizer, const char **atts)
00937 {
00938 std::string maximize = ReadXMLStringAttribut( "MAXIMIZE", atts );
00939 double max = atof(maximize.c_str());
00940 optimizerValues[1] = max;
00941 if (optimizer == mitk::OptimizerParameters::EXHAUSTIVEOPTIMIZER)
00942 {
00943 std::string stepLength = ReadXMLStringAttribut( "STEPLENGTH", atts );
00944 double stepLe = atof(stepLength.c_str());
00945 optimizerValues[2] = stepLe;
00946 std::string numberOfSteps = ReadXMLStringAttribut( "NUMBEROFSTEPS", atts );
00947 double numSteps = atof(numberOfSteps.c_str());
00948 optimizerValues[3] = numSteps;
00949 }
00950 else if (optimizer == mitk::OptimizerParameters::GRADIENTDESCENTOPTIMIZER
00951 || optimizer == mitk::OptimizerParameters::QUATERNIONRIGIDTRANSFORMGRADIENTDESCENTOPTIMIZER)
00952 {
00953 std::string learningRate = ReadXMLStringAttribut( "LEARNINGRATE", atts );
00954 double learn = atof(learningRate.c_str());
00955 optimizerValues[2] = learn;
00956 std::string numberIterations = ReadXMLStringAttribut( "NUMBERITERATIONS", atts );
00957 double numIt = atof(numberIterations.c_str());
00958 optimizerValues[3] = numIt;
00959 }
00960 else if (optimizer == mitk::OptimizerParameters::LBFGSBOPTIMIZER)
00961 {
00962 }
00963 else if (optimizer == mitk::OptimizerParameters::ONEPLUSONEEVOLUTIONARYOPTIMIZER)
00964 {
00965 std::string shrinkFactor = ReadXMLStringAttribut( "SHRINKFACTOR", atts );
00966 double shrink = atof(shrinkFactor.c_str());
00967 optimizerValues[2] = shrink;
00968 std::string growthFactor = ReadXMLStringAttribut( "GROWTHFACTOR", atts );
00969 double growth = atof(growthFactor.c_str());
00970 optimizerValues[3] = growth;
00971 std::string epsilon = ReadXMLStringAttribut( "EPSILON", atts );
00972 double eps = atof(epsilon.c_str());
00973 optimizerValues[4] = eps;
00974 std::string initialRadius = ReadXMLStringAttribut( "INITIALRADIUS", atts );
00975 double initRad = atof(initialRadius.c_str());
00976 optimizerValues[5] = initRad;
00977 std::string numberIterations = ReadXMLStringAttribut( "NUMBERITERATIONS", atts );
00978 double numIt = atof(numberIterations.c_str());
00979 optimizerValues[6] = numIt;
00980 }
00981 else if (optimizer == mitk::OptimizerParameters::POWELLOPTIMIZER)
00982 {
00983 std::string stepLength = ReadXMLStringAttribut( "STEPLENGTH", atts );
00984 double stepLe = atof(stepLength.c_str());
00985 optimizerValues[2] = stepLe;
00986 std::string stepTolerance = ReadXMLStringAttribut( "STEPTOLERANCE", atts );
00987 double stepTo = atof(stepTolerance.c_str());
00988 optimizerValues[3] = stepTo;
00989 std::string valueTolerance = ReadXMLStringAttribut( "VALUETOLERANCE", atts );
00990 double valTo = atof(valueTolerance.c_str());
00991 optimizerValues[4] = valTo;
00992 std::string numberIterations = ReadXMLStringAttribut( "NUMBERITERATIONS", atts );
00993 double numIt = atof(numberIterations.c_str());
00994 optimizerValues[5] = numIt;
00995 }
00996 else if (optimizer == mitk::OptimizerParameters::FRPROPTIMIZER)
00997 {
00998 std::string useFletchReeves = ReadXMLStringAttribut( "USEFLETCHREEVES", atts );
00999 double useFleRe = atof(useFletchReeves.c_str());
01000 optimizerValues[2] = useFleRe;
01001 std::string stepLength = ReadXMLStringAttribut( "STEPLENGTH", atts );
01002 double stepLe = atof(stepLength.c_str());
01003 optimizerValues[3] = stepLe;
01004 std::string numberIterations = ReadXMLStringAttribut( "NUMBERITERATIONS", atts );
01005 double numIt = atof(numberIterations.c_str());
01006 optimizerValues[4] = numIt;
01007 }
01008 else if (optimizer == mitk::OptimizerParameters::REGULARSTEPGRADIENTDESCENTOPTIMIZER)
01009 {
01010 std::string gradientMagnitudeTolerance = ReadXMLStringAttribut( "GRADIENTMAGNITUDETOLERANCE", atts );
01011 double graMagTo = atof(gradientMagnitudeTolerance.c_str());
01012 optimizerValues[2] = graMagTo;
01013 std::string minStepLength = ReadXMLStringAttribut( "MINSTEPLENGTH", atts );
01014 double minStep = atof(minStepLength.c_str());
01015 optimizerValues[3] = minStep;
01016 std::string maxStepLength = ReadXMLStringAttribut( "MAXSTEPLENGTH", atts );
01017 double maxStep = atof(maxStepLength.c_str());
01018 optimizerValues[4] = maxStep;
01019 std::string relaxationFactor = ReadXMLStringAttribut( "RELAXATIONFACTOR", atts );
01020 double relFac = atof(relaxationFactor.c_str());
01021 optimizerValues[5] = relFac;
01022 std::string numberIterations = ReadXMLStringAttribut( "NUMBERITERATIONS", atts );
01023 double numIt = atof(numberIterations.c_str());
01024 optimizerValues[6] = numIt;
01025 }
01026 else if (optimizer == mitk::OptimizerParameters::VERSORTRANSFORMOPTIMIZER || optimizer == mitk::OptimizerParameters::VERSORRIGID3DTRANSFORMOPTIMIZER)
01027 {
01028 std::string gradientMagnitudeTolerance = ReadXMLStringAttribut( "GRADIENTMAGNITUDETOLERANCE", atts );
01029 double graMagTo = atof(gradientMagnitudeTolerance.c_str());
01030 optimizerValues[2] = graMagTo;
01031 std::string minStepLength = ReadXMLStringAttribut( "MINSTEPLENGTH", atts );
01032 double minStep = atof(minStepLength.c_str());
01033 optimizerValues[3] = minStep;
01034 std::string maxStepLength = ReadXMLStringAttribut( "MAXSTEPLENGTH", atts );
01035 double maxStep = atof(maxStepLength.c_str());
01036 optimizerValues[4] = maxStep;
01037 std::string numberIterations = ReadXMLStringAttribut( "NUMBERITERATIONS", atts );
01038 double numIt = atof(numberIterations.c_str());
01039 optimizerValues[5] = numIt;
01040 }
01041 else if (optimizer == mitk::OptimizerParameters::AMOEBAOPTIMIZER)
01042 {
01043 std::string simplexDelta1 = ReadXMLStringAttribut( "SIMPLEXDELTA1", atts );
01044 double simpDel1 = atof(simplexDelta1.c_str());
01045 optimizerValues[2] = simpDel1;
01046 std::string simplexDelta2 = ReadXMLStringAttribut( "SIMPLEXDELTA2", atts );
01047 double simpDel2 = atof(simplexDelta2.c_str());
01048 optimizerValues[3] = simpDel2;
01049 std::string simplexDelta3 = ReadXMLStringAttribut( "SIMPLEXDELTA3", atts );
01050 double simpDel3 = atof(simplexDelta3.c_str());
01051 optimizerValues[4] = simpDel3;
01052 std::string simplexDelta4 = ReadXMLStringAttribut( "SIMPLEXDELTA4", atts );
01053 double simpDel4 = atof(simplexDelta4.c_str());
01054 optimizerValues[5] = simpDel4;
01055 std::string simplexDelta5 = ReadXMLStringAttribut( "SIMPLEXDELTA5", atts );
01056 double simpDel5 = atof(simplexDelta5.c_str());
01057 optimizerValues[6] = simpDel5;
01058 std::string simplexDelta6 = ReadXMLStringAttribut( "SIMPLEXDELTA6", atts );
01059 double simpDel6 = atof(simplexDelta6.c_str());
01060 optimizerValues[7] = simpDel6;
01061 std::string simplexDelta7 = ReadXMLStringAttribut( "SIMPLEXDELTA7", atts );
01062 double simpDel7 = atof(simplexDelta7.c_str());
01063 optimizerValues[8] = simpDel7;
01064 std::string simplexDelta8 = ReadXMLStringAttribut( "SIMPLEXDELTA8", atts );
01065 double simpDel8 = atof(simplexDelta8.c_str());
01066 optimizerValues[9] = simpDel8;
01067 std::string simplexDelta9 = ReadXMLStringAttribut( "SIMPLEXDELTA9", atts );
01068 double simpDel9 = atof(simplexDelta9.c_str());
01069 optimizerValues[10] = simpDel9;
01070 std::string simplexDelta10 = ReadXMLStringAttribut( "SIMPLEXDELTA10", atts );
01071 double simpDel10 = atof(simplexDelta10.c_str());
01072 optimizerValues[11] = simpDel10;
01073 std::string simplexDelta11 = ReadXMLStringAttribut( "SIMPLEXDELTA11", atts );
01074 double simpDel11 = atof(simplexDelta11.c_str());
01075 optimizerValues[12] = simpDel11;
01076 std::string simplexDelta12 = ReadXMLStringAttribut( "SIMPLEXDELTA12", atts );
01077 double simpDel12 = atof(simplexDelta12.c_str());
01078 optimizerValues[13] = simpDel12;
01079 std::string simplexDelta13 = ReadXMLStringAttribut( "SIMPLEXDELTA13", atts );
01080 double simpDel13 = atof(simplexDelta13.c_str());
01081 optimizerValues[14] = simpDel13;
01082 std::string simplexDelta14 = ReadXMLStringAttribut( "SIMPLEXDELTA14", atts );
01083 double simpDel14 = atof(simplexDelta14.c_str());
01084 optimizerValues[15] = simpDel14;
01085 std::string simplexDelta15 = ReadXMLStringAttribut( "SIMPLEXDELTA15", atts );
01086 double simpDel15 = atof(simplexDelta15.c_str());
01087 optimizerValues[16] = simpDel15;
01088 std::string simplexDelta16 = ReadXMLStringAttribut( "SIMPLEXDELTA16", atts );
01089 double simpDel16 = atof(simplexDelta16.c_str());
01090 optimizerValues[17] = simpDel16;
01091 std::string parametersConvergenceTolerance = ReadXMLStringAttribut( "PARAMETERSCONVERGENCETOLERANCE", atts );
01092 double paramConv = atof(parametersConvergenceTolerance.c_str());
01093 optimizerValues[18] = paramConv;
01094 std::string functionConvergenceTolerance = ReadXMLStringAttribut( "FUNCTIONCONVERGENCETOLERANCE", atts );
01095 double funcConv = atof(functionConvergenceTolerance.c_str());
01096 optimizerValues[19] = funcConv;
01097 std::string numberIterations = ReadXMLStringAttribut( "NUMBERITERATIONS", atts );
01098 double numIt = atof(numberIterations.c_str());
01099 optimizerValues[20] = numIt;
01100 }
01101 else if (optimizer == mitk::OptimizerParameters::CONJUGATEGRADIENTOPTIMIZER)
01102 {
01103 }
01104 else if (optimizer == mitk::OptimizerParameters::LBFGSOPTIMIZER)
01105 {
01106 std::string GradientConvergenceTolerance = ReadXMLStringAttribut( "GRADIENTCONVERGENCETOLERANCE", atts );
01107 double graConTo = atof(GradientConvergenceTolerance.c_str());
01108 optimizerValues[2] = graConTo;
01109 std::string lineSearchAccuracy = ReadXMLStringAttribut( "LINESEARCHACCURACY", atts );
01110 double lineSearch = atof(lineSearchAccuracy.c_str());
01111 optimizerValues[3] = lineSearch;
01112 std::string defaultStepLength = ReadXMLStringAttribut( "DEFAULTSTEPLENGTH", atts );
01113 double defStep = atof(defaultStepLength.c_str());
01114 optimizerValues[4] = defStep;
01115 std::string numberIterations = ReadXMLStringAttribut( "NUMBERITERATIONS", atts );
01116 double numIt = atof(numberIterations.c_str());
01117 optimizerValues[5] = numIt;
01118 std::string useTrace = ReadXMLStringAttribut( "USETRACE", atts );
01119 double useTr = atof(useTrace.c_str());
01120 optimizerValues[6] = useTr;
01121 }
01122 else if (optimizer == mitk::OptimizerParameters::SPSAOPTIMIZER)
01123 {
01124 std::string a = ReadXMLStringAttribut( "a", atts );
01125 double a1 = atof(a.c_str());
01126 optimizerValues[2] = a1;
01127 std::string a2 = ReadXMLStringAttribut( "A", atts );
01128 double a3 = atof(a2.c_str());
01129 optimizerValues[3] = a3;
01130 std::string alpha = ReadXMLStringAttribut( "ALPHA", atts );
01131 double alp = atof(alpha.c_str());
01132 optimizerValues[4] = alp;
01133 std::string c = ReadXMLStringAttribut( "c", atts );
01134 double c1 = atof(c.c_str());
01135 optimizerValues[5] = c1;
01136 std::string gamma = ReadXMLStringAttribut( "GAMMA", atts );
01137 double gam = atof(gamma.c_str());
01138 optimizerValues[6] = gam;
01139 std::string tolerance = ReadXMLStringAttribut( "TOLERANCE", atts );
01140 double tol = atof(tolerance.c_str());
01141 optimizerValues[7] = tol;
01142 std::string stateOfConvergenceDecayRate = ReadXMLStringAttribut( "STATEOFCONVERGENCEDECAYRATE", atts );
01143 double stateOfConvergence = atof(stateOfConvergenceDecayRate.c_str());
01144 optimizerValues[8] = stateOfConvergence;
01145 std::string minNumberIterations = ReadXMLStringAttribut( "MINNUMBERITERATIONS", atts );
01146 double minNumIt = atof(minNumberIterations.c_str());
01147 optimizerValues[9] = minNumIt;
01148 std::string numberPerturbations = ReadXMLStringAttribut( "NUMBERPERTURBATIONS", atts );
01149 double numPer = atof(numberPerturbations.c_str());
01150 optimizerValues[10] = numPer;
01151 std::string numberIterations = ReadXMLStringAttribut( "NUMBERITERATIONS", atts );
01152 double numIt = atof(numberIterations.c_str());
01153 optimizerValues[11] = numIt;
01154 }
01155 return optimizerValues;
01156 }
01157
01158 itk::Array<double> RigidRegistrationTestPreset::loadInterpolatorValues(itk::Array<double> interpolatorValues)
01159 {
01160 return interpolatorValues;
01161 }
01162 }