00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "mitkRigidRegistrationPreset.h"
00019 #include "mitkStandardFileLocations.h"
00020 #include "mitkMetricParameters.h"
00021 #include "mitkOptimizerParameters.h"
00022 #include "mitkTransformParameters.h"
00023
00024 namespace mitk {
00025
00026 RigidRegistrationPreset::RigidRegistrationPreset()
00027 {
00028 m_Name = "";
00029 m_XmlFileName = "mitkRigidRegistrationPresets.xml";
00030 }
00031
00032 RigidRegistrationPreset::~RigidRegistrationPreset()
00033 {
00034 }
00035
00036 bool RigidRegistrationPreset::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 mitk::StandardFileLocations::GetInstance()->AddDirectoryForSearch("/bin", true);
00043 std::string xmlFileName = mitk::StandardFileLocations::GetInstance()->FindFile("mitkRigidRegistrationPresets.xml", "Config");
00044
00045 if (!xmlFileName.empty())
00046 {
00047 m_XmlFileName = xmlFileName;
00048 return LoadPreset(m_XmlFileName);
00049 }
00050 else
00051 return false;
00052 }
00053
00054 bool RigidRegistrationPreset::LoadPreset(std::string fileName)
00055 {
00056 if ( fileName.empty() )
00057 return false;
00058
00059 vtkXMLParser::SetFileName( fileName.c_str() );
00060 m_XmlFileName = fileName;
00061
00062 if ( !vtkXMLParser::Parse() )
00063 {
00064 #ifdef INTERDEBUG
00065 MITK_INFO<<"RigidRegistrationPreset::LoadPreset xml file cannot parse!"<<std::endl;
00066 #endif
00067 }
00068
00069 return true;
00070
00071 }
00072
00073 void RigidRegistrationPreset::StartElement (const char *elementName, const char **atts)
00074 {
00075 std::string elementNameString = elementName;
00076 if ( elementNameString == "preset" )
00077 {
00078 m_Name = ReadXMLStringAttribut( "NAME", atts );
00079 }
00080 else if (elementNameString == "transform")
00081 {
00082 itk::Array<double> transformValues;
00083 transformValues.SetSize(25);
00084 transformValues.fill(0);
00085 std::string transform = ReadXMLStringAttribut( "TRANSFORM", atts );
00086 double trans = atof(transform.c_str());
00087 transformValues[0] = trans;
00088 transformValues = this->loadTransformValues(transformValues, trans, atts);
00089 m_TransformValues[m_Name] = transformValues;
00090 }
00091 else if (elementNameString == "metric")
00092 {
00093 itk::Array<double> metricValues;
00094 metricValues.SetSize(25);
00095 metricValues.fill(0);
00096 std::string metric = ReadXMLStringAttribut( "METRIC", atts );
00097 double met = atof(metric.c_str());
00098 metricValues[0] = met;
00099 metricValues = this->loadMetricValues(metricValues, met, atts);
00100 m_MetricValues[m_Name] = metricValues;
00101 }
00102 else if (elementNameString == "optimizer")
00103 {
00104 itk::Array<double> optimizerValues;
00105 optimizerValues.SetSize(25);
00106 optimizerValues.fill(0);
00107 std::string optimizer = ReadXMLStringAttribut( "OPTIMIZER", atts );
00108 double opt = atof(optimizer.c_str());
00109 optimizerValues[0] = opt;
00110 optimizerValues = this->loadOptimizerValues(optimizerValues, opt, atts);
00111 m_OptimizerValues[m_Name] = optimizerValues;
00112 }
00113 else if (elementNameString == "interpolator")
00114 {
00115 itk::Array<double> interpolatorValues;
00116 interpolatorValues.SetSize(25);
00117 interpolatorValues.fill(0);
00118 std::string interpolator = ReadXMLStringAttribut( "INTERPOLATOR", atts );
00119 double inter = atof(interpolator.c_str());
00120 interpolatorValues[0] = inter;
00121 interpolatorValues = this->loadInterpolatorValues(interpolatorValues);
00122 m_InterpolatorValues[m_Name] = interpolatorValues;
00123 }
00124 }
00125
00126 std::string RigidRegistrationPreset::ReadXMLStringAttribut( std::string name, const char** atts )
00127 {
00128 if(atts)
00129 {
00130 const char** attsIter = atts;
00131
00132 while(*attsIter)
00133 {
00134 if ( name == *attsIter )
00135 {
00136 attsIter++;
00137 return *attsIter;
00138 }
00139 attsIter++;
00140 attsIter++;
00141 }
00142 }
00143
00144 return std::string();
00145 }
00146
00147 itk::Array<double> RigidRegistrationPreset::getTransformValues(std::string name)
00148 {
00149 return m_TransformValues[name];
00150 }
00151
00152 itk::Array<double> RigidRegistrationPreset::getMetricValues(std::string name)
00153 {
00154 return m_MetricValues[name];
00155 }
00156
00157 itk::Array<double> RigidRegistrationPreset::getOptimizerValues(std::string name)
00158 {
00159 return m_OptimizerValues[name];
00160 }
00161
00162 itk::Array<double> RigidRegistrationPreset::getInterpolatorValues(std::string name)
00163 {
00164 return m_InterpolatorValues[name];
00165 }
00166
00167 std::map<std::string, itk::Array<double> >& RigidRegistrationPreset::getTransformValuesPresets()
00168 {
00169 return m_TransformValues;
00170 }
00171
00172 std::map<std::string, itk::Array<double> >& RigidRegistrationPreset::getMetricValuesPresets()
00173 {
00174 return m_MetricValues;
00175 }
00176
00177 std::map<std::string, itk::Array<double> >& RigidRegistrationPreset::getOptimizerValuesPresets()
00178 {
00179 return m_OptimizerValues;
00180 }
00181
00182 std::map<std::string, itk::Array<double> >& RigidRegistrationPreset::getInterpolatorValuesPresets()
00183 {
00184 return m_InterpolatorValues;
00185 }
00186
00187 bool RigidRegistrationPreset::save()
00188 {
00189
00190
00191 return false;
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
00219 bool RigidRegistrationPreset::newPresets(std::map<std::string, itk::Array<double> > newTransformValues, std::map<std::string, itk::Array<double> > newMetricValues,
00220 std::map<std::string, itk::Array<double> > newOptimizerValues, std::map<std::string, itk::Array<double> > newInterpolatorValues, std::string fileName)
00221 {
00222 if ( !fileName.empty() )
00223 {
00224 m_XmlFileName = fileName;
00225 }
00226 m_TransformValues = newTransformValues;
00227 m_MetricValues = newMetricValues;
00228 m_OptimizerValues = newOptimizerValues;
00229 m_InterpolatorValues = newInterpolatorValues;
00230 return save();
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
00524 itk::Array<double> RigidRegistrationPreset::loadTransformValues(itk::Array<double> transformValues, double transform, const char **atts)
00525 {
00526 if (transform == mitk::TransformParameters::TRANSLATIONTRANSFORM || transform == mitk::TransformParameters::SCALETRANSFORM ||
00527 transform == mitk::TransformParameters::SCALELOGARITHMICTRANSFORM || transform == mitk::TransformParameters::VERSORTRANSFORM ||
00528 transform == mitk::TransformParameters::RIGID2DTRANSFORM || transform == mitk::TransformParameters::EULER2DTRANSFORM)
00529 {
00530 std::string useScales = ReadXMLStringAttribut( "USESCALES", atts );
00531 double useSca = atof(useScales.c_str());
00532 transformValues[1] = useSca;
00533 std::string scale1 = ReadXMLStringAttribut( "SCALE1", atts );
00534 double sca1 = atof(scale1.c_str());
00535 transformValues[2] = sca1;
00536 std::string scale2 = ReadXMLStringAttribut( "SCALE2", atts );
00537 double sca2 = atof(scale2.c_str());
00538 transformValues[3] = sca2;
00539 std::string scale3 = ReadXMLStringAttribut( "SCALE3", atts );
00540 double sca3 = atof(scale3.c_str());
00541 transformValues[4] = sca3;
00542 }
00543 else if (transform == mitk::TransformParameters::AFFINETRANSFORM || transform == mitk::TransformParameters::FIXEDCENTEROFROTATIONAFFINETRANSFORM)
00544 {
00545 std::string useScales = ReadXMLStringAttribut( "USESCALES", atts );
00546 double useSca = atof(useScales.c_str());
00547 transformValues[1] = useSca;
00548 std::string scale1 = ReadXMLStringAttribut( "SCALE1", atts );
00549 double sca1 = atof(scale1.c_str());
00550 transformValues[2] = sca1;
00551 std::string scale2 = ReadXMLStringAttribut( "SCALE2", atts );
00552 double sca2 = atof(scale2.c_str());
00553 transformValues[3] = sca2;
00554 std::string scale3 = ReadXMLStringAttribut( "SCALE3", atts );
00555 double sca3 = atof(scale3.c_str());
00556 transformValues[4] = sca3;
00557 std::string scale4 = ReadXMLStringAttribut( "SCALE4", atts );
00558 double sca4 = atof(scale4.c_str());
00559 transformValues[5] = sca4;
00560 std::string scale5 = ReadXMLStringAttribut( "SCALE5", atts );
00561 double sca5 = atof(scale5.c_str());
00562 transformValues[6] = sca5;
00563 std::string scale6 = ReadXMLStringAttribut( "SCALE6", atts );
00564 double sca6 = atof(scale6.c_str());
00565 transformValues[7] = sca6;
00566 std::string scale7 = ReadXMLStringAttribut( "SCALE7", atts );
00567 double sca7 = atof(scale7.c_str());
00568 transformValues[8] = sca7;
00569 std::string scale8 = ReadXMLStringAttribut( "SCALE8", atts );
00570 double sca8 = atof(scale8.c_str());
00571 transformValues[9] = sca8;
00572 std::string scale9 = ReadXMLStringAttribut( "SCALE9", atts );
00573 double sca9 = atof(scale9.c_str());
00574 transformValues[10] = sca9;
00575 std::string scale10 = ReadXMLStringAttribut( "SCALE10", atts );
00576 double sca10 = atof(scale10.c_str());
00577 transformValues[11] = sca10;
00578 std::string scale11 = ReadXMLStringAttribut( "SCALE11", atts );
00579 double sca11 = atof(scale11.c_str());
00580 transformValues[12] = sca11;
00581 std::string scale12 = ReadXMLStringAttribut( "SCALE12", atts );
00582 double sca12 = atof(scale12.c_str());
00583 transformValues[13] = sca12;
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600 std::string useInitializer = ReadXMLStringAttribut( "USEINITIALIZER", atts );
00601 double useIni = atof(useInitializer.c_str());
00602 transformValues[14] = useIni;
00603 std::string useMoments = ReadXMLStringAttribut( "USEMOMENTS", atts );
00604 double useMo = atof(useMoments.c_str());
00605 transformValues[15] = useMo;
00606 }
00607 else if (transform == mitk::TransformParameters::RIGID3DTRANSFORM)
00608 {
00609 std::string useScales = ReadXMLStringAttribut( "USESCALES", atts );
00610 double useSca = atof(useScales.c_str());
00611 transformValues[1] = useSca;
00612 std::string scale1 = ReadXMLStringAttribut( "SCALE1", atts );
00613 double sca1 = atof(scale1.c_str());
00614 transformValues[2] = sca1;
00615 std::string scale2 = ReadXMLStringAttribut( "SCALE2", atts );
00616 double sca2 = atof(scale2.c_str());
00617 transformValues[3] = sca2;
00618 std::string scale3 = ReadXMLStringAttribut( "SCALE3", atts );
00619 double sca3 = atof(scale3.c_str());
00620 transformValues[4] = sca3;
00621 std::string scale4 = ReadXMLStringAttribut( "SCALE4", atts );
00622 double sca4 = atof(scale4.c_str());
00623 transformValues[5] = sca4;
00624 std::string scale5 = ReadXMLStringAttribut( "SCALE5", atts );
00625 double sca5 = atof(scale5.c_str());
00626 transformValues[6] = sca5;
00627 std::string scale6 = ReadXMLStringAttribut( "SCALE6", atts );
00628 double sca6 = atof(scale6.c_str());
00629 transformValues[7] = sca6;
00630 std::string scale7 = ReadXMLStringAttribut( "SCALE7", atts );
00631 double sca7 = atof(scale7.c_str());
00632 transformValues[8] = sca7;
00633 std::string scale8 = ReadXMLStringAttribut( "SCALE8", atts );
00634 double sca8 = atof(scale8.c_str());
00635 transformValues[9] = sca8;
00636 std::string scale9 = ReadXMLStringAttribut( "SCALE9", atts );
00637 double sca9 = atof(scale9.c_str());
00638 transformValues[10] = sca9;
00639 std::string scale10 = ReadXMLStringAttribut( "SCALE10", atts );
00640 double sca10 = atof(scale10.c_str());
00641 transformValues[11] = sca10;
00642 std::string scale11 = ReadXMLStringAttribut( "SCALE11", atts );
00643 double sca11 = atof(scale11.c_str());
00644 transformValues[12] = sca11;
00645 std::string scale12 = ReadXMLStringAttribut( "SCALE12", atts );
00646 double sca12 = atof(scale12.c_str());
00647 transformValues[13] = sca12;
00648 std::string useInitializer = ReadXMLStringAttribut( "USEINITIALIZER", atts );
00649 double useIni = atof(useInitializer.c_str());
00650 transformValues[14] = useIni;
00651 std::string useMoments = ReadXMLStringAttribut( "USEMOMENTS", atts );
00652 double useMo = atof(useMoments.c_str());
00653 transformValues[15] = useMo;
00654 }
00655 else if (transform == mitk::TransformParameters::EULER3DTRANSFORM || transform == mitk::TransformParameters::CENTEREDEULER3DTRANSFORM
00656 || transform == mitk::TransformParameters::VERSORRIGID3DTRANSFORM)
00657 {
00658 std::string useScales = ReadXMLStringAttribut( "USESCALES", atts );
00659 double useSca = atof(useScales.c_str());
00660 transformValues[1] = useSca;
00661 std::string scale1 = ReadXMLStringAttribut( "SCALE1", atts );
00662 double sca1 = atof(scale1.c_str());
00663 transformValues[2] = sca1;
00664 std::string scale2 = ReadXMLStringAttribut( "SCALE2", atts );
00665 double sca2 = atof(scale2.c_str());
00666 transformValues[3] = sca2;
00667 std::string scale3 = ReadXMLStringAttribut( "SCALE3", atts );
00668 double sca3 = atof(scale3.c_str());
00669 transformValues[4] = sca3;
00670 std::string scale4 = ReadXMLStringAttribut( "SCALE4", atts );
00671 double sca4 = atof(scale4.c_str());
00672 transformValues[5] = sca4;
00673 std::string scale5 = ReadXMLStringAttribut( "SCALE5", atts );
00674 double sca5 = atof(scale5.c_str());
00675 transformValues[6] = sca5;
00676 std::string scale6 = ReadXMLStringAttribut( "SCALE6", atts );
00677 double sca6 = atof(scale6.c_str());
00678 transformValues[7] = sca6;
00679 std::string useInitializer = ReadXMLStringAttribut( "USEINITIALIZER", atts );
00680 double useIni = atof(useInitializer.c_str());
00681 transformValues[8] = useIni;
00682 std::string useMoments = ReadXMLStringAttribut( "USEMOMENTS", atts );
00683 double useMo = atof(useMoments.c_str());
00684 transformValues[9] = useMo;
00685 }
00686 else if (transform == mitk::TransformParameters::QUATERNIONRIGIDTRANSFORM || transform == mitk::TransformParameters::SIMILARITY3DTRANSFORM)
00687 {
00688 std::string useScales = ReadXMLStringAttribut( "USESCALES", atts );
00689 double useSca = atof(useScales.c_str());
00690 transformValues[1] = useSca;
00691 std::string scale1 = ReadXMLStringAttribut( "SCALE1", atts );
00692 double sca1 = atof(scale1.c_str());
00693 transformValues[2] = sca1;
00694 std::string scale2 = ReadXMLStringAttribut( "SCALE2", atts );
00695 double sca2 = atof(scale2.c_str());
00696 transformValues[3] = sca2;
00697 std::string scale3 = ReadXMLStringAttribut( "SCALE3", atts );
00698 double sca3 = atof(scale3.c_str());
00699 transformValues[4] = sca3;
00700 std::string scale4 = ReadXMLStringAttribut( "SCALE4", atts );
00701 double sca4 = atof(scale4.c_str());
00702 transformValues[5] = sca4;
00703 std::string scale5 = ReadXMLStringAttribut( "SCALE5", atts );
00704 double sca5 = atof(scale5.c_str());
00705 transformValues[6] = sca5;
00706 std::string scale6 = ReadXMLStringAttribut( "SCALE6", atts );
00707 double sca6 = atof(scale6.c_str());
00708 transformValues[7] = sca6;
00709 std::string scale7 = ReadXMLStringAttribut( "SCALE7", atts );
00710 double sca7 = atof(scale7.c_str());
00711 transformValues[8] = sca7;
00712 std::string useInitializer = ReadXMLStringAttribut( "USEINITIALIZER", atts );
00713 double useIni = atof(useInitializer.c_str());
00714 transformValues[9] = useIni;
00715 std::string useMoments = ReadXMLStringAttribut( "USEMOMENTS", atts );
00716 double useMo = atof(useMoments.c_str());
00717 transformValues[10] = useMo;
00718 }
00719 else if (transform == mitk::TransformParameters::SCALESKEWVERSOR3DTRANSFORM)
00720 {
00721 std::string useScales = ReadXMLStringAttribut( "USESCALES", atts );
00722 double useSca = atof(useScales.c_str());
00723 transformValues[1] = useSca;
00724 std::string scale1 = ReadXMLStringAttribut( "SCALE1", atts );
00725 double sca1 = atof(scale1.c_str());
00726 transformValues[2] = sca1;
00727 std::string scale2 = ReadXMLStringAttribut( "SCALE2", atts );
00728 double sca2 = atof(scale2.c_str());
00729 transformValues[3] = sca2;
00730 std::string scale3 = ReadXMLStringAttribut( "SCALE3", atts );
00731 double sca3 = atof(scale3.c_str());
00732 transformValues[4] = sca3;
00733 std::string scale4 = ReadXMLStringAttribut( "SCALE4", atts );
00734 double sca4 = atof(scale4.c_str());
00735 transformValues[5] = sca4;
00736 std::string scale5 = ReadXMLStringAttribut( "SCALE5", atts );
00737 double sca5 = atof(scale5.c_str());
00738 transformValues[6] = sca5;
00739 std::string scale6 = ReadXMLStringAttribut( "SCALE6", atts );
00740 double sca6 = atof(scale6.c_str());
00741 transformValues[7] = sca6;
00742 std::string scale7 = ReadXMLStringAttribut( "SCALE7", atts );
00743 double sca7 = atof(scale7.c_str());
00744 transformValues[8] = sca7;
00745 std::string scale8 = ReadXMLStringAttribut( "SCALE8", atts );
00746 double sca8 = atof(scale8.c_str());
00747 transformValues[9] = sca8;
00748 std::string scale9 = ReadXMLStringAttribut( "SCALE9", atts );
00749 double sca9 = atof(scale9.c_str());
00750 transformValues[10] = sca9;
00751 std::string scale10 = ReadXMLStringAttribut( "SCALE10", atts );
00752 double sca10 = atof(scale10.c_str());
00753 transformValues[11] = sca10;
00754 std::string scale11 = ReadXMLStringAttribut( "SCALE11", atts );
00755 double sca11 = atof(scale11.c_str());
00756 transformValues[12] = sca11;
00757 std::string scale12 = ReadXMLStringAttribut( "SCALE12", atts );
00758 double sca12 = atof(scale12.c_str());
00759 transformValues[13] = sca12;
00760 std::string scale13 = ReadXMLStringAttribut( "SCALE13", atts );
00761 double sca13 = atof(scale13.c_str());
00762 transformValues[14] = sca13;
00763 std::string scale14 = ReadXMLStringAttribut( "SCALE14", atts );
00764 double sca14 = atof(scale14.c_str());
00765 transformValues[15] = sca14;
00766 std::string scale15 = ReadXMLStringAttribut( "SCALE15", atts );
00767 double sca15 = atof(scale15.c_str());
00768 transformValues[16] = sca15;
00769 std::string useInitializer = ReadXMLStringAttribut( "USEINITIALIZER", atts );
00770 double useIni = atof(useInitializer.c_str());
00771 transformValues[17] = useIni;
00772 std::string useMoments = ReadXMLStringAttribut( "USEMOMENTS", atts );
00773 double useMo = atof(useMoments.c_str());
00774 transformValues[18] = useMo;
00775 }
00776 else if (transform == mitk::TransformParameters::CENTEREDRIGID2DTRANSFORM)
00777 {
00778 std::string useScales = ReadXMLStringAttribut( "USESCALES", atts );
00779 double useSca = atof(useScales.c_str());
00780 transformValues[1] = useSca;
00781 std::string scale1 = ReadXMLStringAttribut( "SCALE1", atts );
00782 double sca1 = atof(scale1.c_str());
00783 transformValues[2] = sca1;
00784 std::string scale2 = ReadXMLStringAttribut( "SCALE2", atts );
00785 double sca2 = atof(scale2.c_str());
00786 transformValues[3] = sca2;
00787 std::string scale3 = ReadXMLStringAttribut( "SCALE3", atts );
00788 double sca3 = atof(scale3.c_str());
00789 transformValues[4] = sca3;
00790 std::string scale4 = ReadXMLStringAttribut( "SCALE4", atts );
00791 double sca4 = atof(scale4.c_str());
00792 transformValues[5] = sca4;
00793 std::string scale5 = ReadXMLStringAttribut( "SCALE5", atts );
00794 double sca5 = atof(scale5.c_str());
00795 transformValues[6] = sca5;
00796 std::string angle = ReadXMLStringAttribut( "ANGLE", atts );
00797 double ang = atof(angle.c_str());
00798 transformValues[7] = ang;
00799 std::string useInitializer = ReadXMLStringAttribut( "USEINITIALIZER", atts );
00800 double useIni = atof(useInitializer.c_str());
00801 transformValues[8] = useIni;
00802 std::string useMoments = ReadXMLStringAttribut( "USEMOMENTS", atts );
00803 double useMo = atof(useMoments.c_str());
00804 transformValues[9] = useMo;
00805 }
00806 else if (transform == mitk::TransformParameters::SIMILARITY2DTRANSFORM)
00807 {
00808 std::string useScales = ReadXMLStringAttribut( "USESCALES", atts );
00809 double useSca = atof(useScales.c_str());
00810 transformValues[1] = useSca;
00811 std::string scale1 = ReadXMLStringAttribut( "SCALE1", atts );
00812 double sca1 = atof(scale1.c_str());
00813 transformValues[2] = sca1;
00814 std::string scale2 = ReadXMLStringAttribut( "SCALE2", atts );
00815 double sca2 = atof(scale2.c_str());
00816 transformValues[3] = sca2;
00817 std::string scale3 = ReadXMLStringAttribut( "SCALE3", atts );
00818 double sca3 = atof(scale3.c_str());
00819 transformValues[4] = sca3;
00820 std::string scale4 = ReadXMLStringAttribut( "SCALE4", atts );
00821 double sca4 = atof(scale4.c_str());
00822 transformValues[5] = sca4;
00823 std::string scale = ReadXMLStringAttribut( "SCALE", atts );
00824 double sca = atof(scale.c_str());
00825 transformValues[6] = sca;
00826 std::string angle = ReadXMLStringAttribut( "ANGLE", atts );
00827 double ang = atof(angle.c_str());
00828 transformValues[7] = ang;
00829 std::string useInitializer = ReadXMLStringAttribut( "USEINITIALIZER", atts );
00830 double useIni = atof(useInitializer.c_str());
00831 transformValues[8] = useIni;
00832 std::string useMoments = ReadXMLStringAttribut( "USEMOMENTS", atts );
00833 double useMo = atof(useMoments.c_str());
00834 transformValues[9] = useMo;
00835 }
00836 else if (transform == mitk::TransformParameters::CENTEREDSIMILARITY2DTRANSFORM)
00837 {
00838 std::string useScales = ReadXMLStringAttribut( "USESCALES", atts );
00839 double useSca = atof(useScales.c_str());
00840 transformValues[1] = useSca;
00841 std::string scale1 = ReadXMLStringAttribut( "SCALE1", atts );
00842 double sca1 = atof(scale1.c_str());
00843 transformValues[2] = sca1;
00844 std::string scale2 = ReadXMLStringAttribut( "SCALE2", atts );
00845 double sca2 = atof(scale2.c_str());
00846 transformValues[3] = sca2;
00847 std::string scale3 = ReadXMLStringAttribut( "SCALE3", atts );
00848 double sca3 = atof(scale3.c_str());
00849 transformValues[4] = sca3;
00850 std::string scale4 = ReadXMLStringAttribut( "SCALE4", atts );
00851 double sca4 = atof(scale4.c_str());
00852 transformValues[5] = sca4;
00853 std::string scale5 = ReadXMLStringAttribut( "SCALE5", atts );
00854 double sca5 = atof(scale5.c_str());
00855 transformValues[6] = sca5;
00856 std::string scale6 = ReadXMLStringAttribut( "SCALE6", atts );
00857 double sca6 = atof(scale6.c_str());
00858 transformValues[7] = sca6;
00859 std::string scale = ReadXMLStringAttribut( "SCALE", atts );
00860 double sca = atof(scale.c_str());
00861 transformValues[8] = sca;
00862 std::string angle = ReadXMLStringAttribut( "ANGLE", atts );
00863 double ang = atof(angle.c_str());
00864 transformValues[9] = ang;
00865 std::string useInitializer = ReadXMLStringAttribut( "USEINITIALIZER", atts );
00866 double useIni = atof(useInitializer.c_str());
00867 transformValues[10] = useIni;
00868 std::string useMoments = ReadXMLStringAttribut( "USEMOMENTS", atts );
00869 double useMo = atof(useMoments.c_str());
00870 transformValues[11] = useMo;
00871 }
00872 return transformValues;
00873 }
00874
00875 itk::Array<double> RigidRegistrationPreset::loadMetricValues(itk::Array<double> metricValues, double metric, const char **atts)
00876 {
00877 std::string computeGradient = ReadXMLStringAttribut( "COMPUTEGRADIENT", atts );
00878 double compGra = atof(computeGradient.c_str());
00879 metricValues[1] = compGra;
00880 if (metric == mitk::MetricParameters::MEANSQUARESIMAGETOIMAGEMETRIC || metric == mitk::MetricParameters::NORMALIZEDCORRELATIONIMAGETOIMAGEMETRIC
00881 || metric == mitk::MetricParameters::GRADIENTDIFFERENCEIMAGETOIMAGEMETRIC || metric == mitk::MetricParameters::MATCHCARDINALITYIMAGETOIMAGEMETRIC
00882 || metric == mitk::MetricParameters::KAPPASTATISTICIMAGETOIMAGEMETRIC)
00883 {
00884 }
00885 else if (metric == mitk::MetricParameters::KULLBACKLEIBLERCOMPAREHISTOGRAMIMAGETOIMAGEMETRIC
00886 || metric == mitk::MetricParameters::CORRELATIONCOEFFICIENTHISTOGRAMIMAGETOIMAGEMETRIC
00887 || metric == mitk::MetricParameters::MEANSQUARESHISTOGRAMIMAGETOIMAGEMETRIC
00888 || metric == mitk::MetricParameters::MUTUALINFORMATIONHISTOGRAMIMAGETOIMAGEMETRIC
00889 || metric == mitk::MetricParameters::NORMALIZEDMUTUALINFORMATIONHISTOGRAMIMAGETOIMAGEMETRIC)
00890 {
00891 std::string histogramBins = ReadXMLStringAttribut( "HISTOGRAMBINS", atts );
00892 double histBins = atof(histogramBins.c_str());
00893 metricValues[2] = histBins;
00894 }
00895 else if (metric == mitk::MetricParameters::MATTESMUTUALINFORMATIONIMAGETOIMAGEMETRIC)
00896 {
00897 std::string useSampling = ReadXMLStringAttribut( "USESAMPLING", atts );
00898 double useSamp = atof(useSampling.c_str());
00899 metricValues[2] = useSamp;
00900 std::string spatialSamples = ReadXMLStringAttribut( "SPATIALSAMPLES", atts );
00901 double spatSamp = atof(spatialSamples.c_str());
00902 metricValues[3] = spatSamp;
00903 std::string histogramBins = ReadXMLStringAttribut( "HISTOGRAMBINS", atts );
00904 double histBins = atof(histogramBins.c_str());
00905 metricValues[4] = histBins;
00906 }
00907 else if (metric == mitk::MetricParameters::MEANRECIPROCALSQUAREDIFFERENCEIMAGETOIMAGEMETRIC)
00908 {
00909 std::string lambda = ReadXMLStringAttribut( "LAMBDA", atts );
00910 double lamb = atof(lambda.c_str());
00911 metricValues[2] = lamb;
00912 }
00913 else if (metric == mitk::MetricParameters::MUTUALINFORMATIONIMAGETOIMAGEMETRIC)
00914 {
00915 std::string spatialSamples = ReadXMLStringAttribut( "SPATIALSAMPLES", atts );
00916 double spatSamp = atof(spatialSamples.c_str());
00917 metricValues[2] = spatSamp;
00918 std::string fixedStandardDeviation = ReadXMLStringAttribut( "FIXEDSTANDARDDEVIATION", atts );
00919 double fiStaDev = atof(fixedStandardDeviation.c_str());
00920 metricValues[3] = fiStaDev;
00921 std::string movingStandardDeviation = ReadXMLStringAttribut( "MOVINGSTANDARDDEVIATION", atts );
00922 double moStaDev = atof(movingStandardDeviation.c_str());
00923 metricValues[4] = moStaDev;
00924 std::string useNormalizer = ReadXMLStringAttribut( "USENORMALIZERANDSMOOTHER", atts );
00925 double useNormal = atof(useNormalizer.c_str());
00926 metricValues[5] = useNormal;
00927 std::string fixedSmootherVariance = ReadXMLStringAttribut( "FIXEDSMOOTHERVARIANCE", atts );
00928 double fiSmoVa = atof(fixedSmootherVariance.c_str());
00929 metricValues[6] = fiSmoVa;
00930 std::string movingSmootherVariance = ReadXMLStringAttribut( "MOVINGSMOOTHERVARIANCE", atts );
00931 double moSmoVa = atof(movingSmootherVariance.c_str());
00932 metricValues[7] = moSmoVa;
00933 }
00934 return metricValues;
00935 }
00936
00937 itk::Array<double> RigidRegistrationPreset::loadOptimizerValues(itk::Array<double> optimizerValues, double optimizer, const char **atts)
00938 {
00939 std::string maximize = ReadXMLStringAttribut( "MAXIMIZE", atts );
00940 double max = atof(maximize.c_str());
00941 optimizerValues[1] = max;
00942 if (optimizer == mitk::OptimizerParameters::EXHAUSTIVEOPTIMIZER)
00943 {
00944 std::string stepLength = ReadXMLStringAttribut( "STEPLENGTH", atts );
00945 double stepLe = atof(stepLength.c_str());
00946 optimizerValues[2] = stepLe;
00947 std::string numberOfSteps = ReadXMLStringAttribut( "NUMBEROFSTEPS", atts );
00948 double numSteps = atof(numberOfSteps.c_str());
00949 optimizerValues[3] = numSteps;
00950 }
00951 else if (optimizer == mitk::OptimizerParameters::GRADIENTDESCENTOPTIMIZER
00952 || optimizer == mitk::OptimizerParameters::QUATERNIONRIGIDTRANSFORMGRADIENTDESCENTOPTIMIZER)
00953 {
00954 std::string learningRate = ReadXMLStringAttribut( "LEARNINGRATE", atts );
00955 double learn = atof(learningRate.c_str());
00956 optimizerValues[2] = learn;
00957 std::string numberIterations = ReadXMLStringAttribut( "NUMBERITERATIONS", atts );
00958 double numIt = atof(numberIterations.c_str());
00959 optimizerValues[3] = numIt;
00960 }
00961 else if (optimizer == mitk::OptimizerParameters::LBFGSBOPTIMIZER)
00962 {
00963 }
00964 else if (optimizer == mitk::OptimizerParameters::ONEPLUSONEEVOLUTIONARYOPTIMIZER)
00965 {
00966 std::string shrinkFactor = ReadXMLStringAttribut( "SHRINKFACTOR", atts );
00967 double shrink = atof(shrinkFactor.c_str());
00968 optimizerValues[2] = shrink;
00969 std::string growthFactor = ReadXMLStringAttribut( "GROWTHFACTOR", atts );
00970 double growth = atof(growthFactor.c_str());
00971 optimizerValues[3] = growth;
00972 std::string epsilon = ReadXMLStringAttribut( "EPSILON", atts );
00973 double eps = atof(epsilon.c_str());
00974 optimizerValues[4] = eps;
00975 std::string initialRadius = ReadXMLStringAttribut( "INITIALRADIUS", atts );
00976 double initRad = atof(initialRadius.c_str());
00977 optimizerValues[5] = initRad;
00978 std::string numberIterations = ReadXMLStringAttribut( "NUMBERITERATIONS", atts );
00979 double numIt = atof(numberIterations.c_str());
00980 optimizerValues[6] = numIt;
00981 }
00982 else if (optimizer == mitk::OptimizerParameters::POWELLOPTIMIZER)
00983 {
00984 std::string stepLength = ReadXMLStringAttribut( "STEPLENGTH", atts );
00985 double stepLe = atof(stepLength.c_str());
00986 optimizerValues[2] = stepLe;
00987 std::string stepTolerance = ReadXMLStringAttribut( "STEPTOLERANCE", atts );
00988 double stepTo = atof(stepTolerance.c_str());
00989 optimizerValues[3] = stepTo;
00990 std::string valueTolerance = ReadXMLStringAttribut( "VALUETOLERANCE", atts );
00991 double valTo = atof(valueTolerance.c_str());
00992 optimizerValues[4] = valTo;
00993 std::string numberIterations = ReadXMLStringAttribut( "NUMBERITERATIONS", atts );
00994 double numIt = atof(numberIterations.c_str());
00995 optimizerValues[5] = numIt;
00996 }
00997 else if (optimizer == mitk::OptimizerParameters::FRPROPTIMIZER)
00998 {
00999 std::string useFletchReeves = ReadXMLStringAttribut( "USEFLETCHREEVES", atts );
01000 double useFleRe = atof(useFletchReeves.c_str());
01001 optimizerValues[2] = useFleRe;
01002 std::string stepLength = ReadXMLStringAttribut( "STEPLENGTH", atts );
01003 double stepLe = atof(stepLength.c_str());
01004 optimizerValues[3] = stepLe;
01005 std::string numberIterations = ReadXMLStringAttribut( "NUMBERITERATIONS", atts );
01006 double numIt = atof(numberIterations.c_str());
01007 optimizerValues[4] = numIt;
01008 }
01009 else if (optimizer == mitk::OptimizerParameters::REGULARSTEPGRADIENTDESCENTOPTIMIZER)
01010 {
01011 std::string gradientMagnitudeTolerance = ReadXMLStringAttribut( "GRADIENTMAGNITUDETOLERANCE", atts );
01012 double graMagTo = atof(gradientMagnitudeTolerance.c_str());
01013 optimizerValues[2] = graMagTo;
01014 std::string minStepLength = ReadXMLStringAttribut( "MINSTEPLENGTH", atts );
01015 double minStep = atof(minStepLength.c_str());
01016 optimizerValues[3] = minStep;
01017 std::string maxStepLength = ReadXMLStringAttribut( "MAXSTEPLENGTH", atts );
01018 double maxStep = atof(maxStepLength.c_str());
01019 optimizerValues[4] = maxStep;
01020 std::string relaxationFactor = ReadXMLStringAttribut( "RELAXATIONFACTOR", atts );
01021 double relFac = atof(relaxationFactor.c_str());
01022 optimizerValues[5] = relFac;
01023 std::string numberIterations = ReadXMLStringAttribut( "NUMBERITERATIONS", atts );
01024 double numIt = atof(numberIterations.c_str());
01025 optimizerValues[6] = numIt;
01026 }
01027 else if (optimizer == mitk::OptimizerParameters::VERSORTRANSFORMOPTIMIZER || optimizer == mitk::OptimizerParameters::VERSORRIGID3DTRANSFORMOPTIMIZER)
01028 {
01029 std::string gradientMagnitudeTolerance = ReadXMLStringAttribut( "GRADIENTMAGNITUDETOLERANCE", atts );
01030 double graMagTo = atof(gradientMagnitudeTolerance.c_str());
01031 optimizerValues[2] = graMagTo;
01032 std::string minStepLength = ReadXMLStringAttribut( "MINSTEPLENGTH", atts );
01033 double minStep = atof(minStepLength.c_str());
01034 optimizerValues[3] = minStep;
01035 std::string maxStepLength = ReadXMLStringAttribut( "MAXSTEPLENGTH", atts );
01036 double maxStep = atof(maxStepLength.c_str());
01037 optimizerValues[4] = maxStep;
01038 std::string numberIterations = ReadXMLStringAttribut( "NUMBERITERATIONS", atts );
01039 double numIt = atof(numberIterations.c_str());
01040 optimizerValues[5] = numIt;
01041 }
01042 else if (optimizer == mitk::OptimizerParameters::AMOEBAOPTIMIZER)
01043 {
01044 std::string simplexDelta1 = ReadXMLStringAttribut( "SIMPLEXDELTA1", atts );
01045 double simpDel1 = atof(simplexDelta1.c_str());
01046 optimizerValues[2] = simpDel1;
01047 std::string simplexDelta2 = ReadXMLStringAttribut( "SIMPLEXDELTA2", atts );
01048 double simpDel2 = atof(simplexDelta2.c_str());
01049 optimizerValues[3] = simpDel2;
01050 std::string simplexDelta3 = ReadXMLStringAttribut( "SIMPLEXDELTA3", atts );
01051 double simpDel3 = atof(simplexDelta3.c_str());
01052 optimizerValues[4] = simpDel3;
01053 std::string simplexDelta4 = ReadXMLStringAttribut( "SIMPLEXDELTA4", atts );
01054 double simpDel4 = atof(simplexDelta4.c_str());
01055 optimizerValues[5] = simpDel4;
01056 std::string simplexDelta5 = ReadXMLStringAttribut( "SIMPLEXDELTA5", atts );
01057 double simpDel5 = atof(simplexDelta5.c_str());
01058 optimizerValues[6] = simpDel5;
01059 std::string simplexDelta6 = ReadXMLStringAttribut( "SIMPLEXDELTA6", atts );
01060 double simpDel6 = atof(simplexDelta6.c_str());
01061 optimizerValues[7] = simpDel6;
01062 std::string simplexDelta7 = ReadXMLStringAttribut( "SIMPLEXDELTA7", atts );
01063 double simpDel7 = atof(simplexDelta7.c_str());
01064 optimizerValues[8] = simpDel7;
01065 std::string simplexDelta8 = ReadXMLStringAttribut( "SIMPLEXDELTA8", atts );
01066 double simpDel8 = atof(simplexDelta8.c_str());
01067 optimizerValues[9] = simpDel8;
01068 std::string simplexDelta9 = ReadXMLStringAttribut( "SIMPLEXDELTA9", atts );
01069 double simpDel9 = atof(simplexDelta9.c_str());
01070 optimizerValues[10] = simpDel9;
01071 std::string simplexDelta10 = ReadXMLStringAttribut( "SIMPLEXDELTA10", atts );
01072 double simpDel10 = atof(simplexDelta10.c_str());
01073 optimizerValues[11] = simpDel10;
01074 std::string simplexDelta11 = ReadXMLStringAttribut( "SIMPLEXDELTA11", atts );
01075 double simpDel11 = atof(simplexDelta11.c_str());
01076 optimizerValues[12] = simpDel11;
01077 std::string simplexDelta12 = ReadXMLStringAttribut( "SIMPLEXDELTA12", atts );
01078 double simpDel12 = atof(simplexDelta12.c_str());
01079 optimizerValues[13] = simpDel12;
01080 std::string simplexDelta13 = ReadXMLStringAttribut( "SIMPLEXDELTA13", atts );
01081 double simpDel13 = atof(simplexDelta13.c_str());
01082 optimizerValues[14] = simpDel13;
01083 std::string simplexDelta14 = ReadXMLStringAttribut( "SIMPLEXDELTA14", atts );
01084 double simpDel14 = atof(simplexDelta14.c_str());
01085 optimizerValues[15] = simpDel14;
01086 std::string simplexDelta15 = ReadXMLStringAttribut( "SIMPLEXDELTA15", atts );
01087 double simpDel15 = atof(simplexDelta15.c_str());
01088 optimizerValues[16] = simpDel15;
01089 std::string simplexDelta16 = ReadXMLStringAttribut( "SIMPLEXDELTA16", atts );
01090 double simpDel16 = atof(simplexDelta16.c_str());
01091 optimizerValues[17] = simpDel16;
01092 std::string parametersConvergenceTolerance = ReadXMLStringAttribut( "PARAMETERSCONVERGENCETOLERANCE", atts );
01093 double paramConv = atof(parametersConvergenceTolerance.c_str());
01094 optimizerValues[18] = paramConv;
01095 std::string functionConvergenceTolerance = ReadXMLStringAttribut( "FUNCTIONCONVERGENCETOLERANCE", atts );
01096 double funcConv = atof(functionConvergenceTolerance.c_str());
01097 optimizerValues[19] = funcConv;
01098 std::string numberIterations = ReadXMLStringAttribut( "NUMBERITERATIONS", atts );
01099 double numIt = atof(numberIterations.c_str());
01100 optimizerValues[20] = numIt;
01101 }
01102 else if (optimizer == mitk::OptimizerParameters::CONJUGATEGRADIENTOPTIMIZER)
01103 {
01104 }
01105 else if (optimizer == mitk::OptimizerParameters::LBFGSOPTIMIZER)
01106 {
01107 std::string GradientConvergenceTolerance = ReadXMLStringAttribut( "GRADIENTCONVERGENCETOLERANCE", atts );
01108 double graConTo = atof(GradientConvergenceTolerance.c_str());
01109 optimizerValues[2] = graConTo;
01110 std::string lineSearchAccuracy = ReadXMLStringAttribut( "LINESEARCHACCURACY", atts );
01111 double lineSearch = atof(lineSearchAccuracy.c_str());
01112 optimizerValues[3] = lineSearch;
01113 std::string defaultStepLength = ReadXMLStringAttribut( "DEFAULTSTEPLENGTH", atts );
01114 double defStep = atof(defaultStepLength.c_str());
01115 optimizerValues[4] = defStep;
01116 std::string numberIterations = ReadXMLStringAttribut( "NUMBERITERATIONS", atts );
01117 double numIt = atof(numberIterations.c_str());
01118 optimizerValues[5] = numIt;
01119 std::string useTrace = ReadXMLStringAttribut( "USETRACE", atts );
01120 double useTr = atof(useTrace.c_str());
01121 optimizerValues[6] = useTr;
01122 }
01123 else if (optimizer == mitk::OptimizerParameters::SPSAOPTIMIZER)
01124 {
01125 std::string a = ReadXMLStringAttribut( "a", atts );
01126 double a1 = atof(a.c_str());
01127 optimizerValues[2] = a1;
01128 std::string a2 = ReadXMLStringAttribut( "A", atts );
01129 double a3 = atof(a2.c_str());
01130 optimizerValues[3] = a3;
01131 std::string alpha = ReadXMLStringAttribut( "ALPHA", atts );
01132 double alp = atof(alpha.c_str());
01133 optimizerValues[4] = alp;
01134 std::string c = ReadXMLStringAttribut( "c", atts );
01135 double c1 = atof(c.c_str());
01136 optimizerValues[5] = c1;
01137 std::string gamma = ReadXMLStringAttribut( "GAMMA", atts );
01138 double gam = atof(gamma.c_str());
01139 optimizerValues[6] = gam;
01140 std::string tolerance = ReadXMLStringAttribut( "TOLERANCE", atts );
01141 double tol = atof(tolerance.c_str());
01142 optimizerValues[7] = tol;
01143 std::string stateOfConvergenceDecayRate = ReadXMLStringAttribut( "STATEOFCONVERGENCEDECAYRATE", atts );
01144 double stateOfConvergence = atof(stateOfConvergenceDecayRate.c_str());
01145 optimizerValues[8] = stateOfConvergence;
01146 std::string minNumberIterations = ReadXMLStringAttribut( "MINNUMBERITERATIONS", atts );
01147 double minNumIt = atof(minNumberIterations.c_str());
01148 optimizerValues[9] = minNumIt;
01149 std::string numberPerturbations = ReadXMLStringAttribut( "NUMBERPERTURBATIONS", atts );
01150 double numPer = atof(numberPerturbations.c_str());
01151 optimizerValues[10] = numPer;
01152 std::string numberIterations = ReadXMLStringAttribut( "NUMBERITERATIONS", atts );
01153 double numIt = atof(numberIterations.c_str());
01154 optimizerValues[11] = numIt;
01155 }
01156 return optimizerValues;
01157 }
01158
01159 itk::Array<double> RigidRegistrationPreset::loadInterpolatorValues(itk::Array<double> interpolatorValues)
01160 {
01161 return interpolatorValues;
01162 }
01163 }