3 #include <itkTimeProbe.h> 5 #include <itkTransformFileReader.h> 7 #include <tclap/CmdLine.h> 9 int main(
int ac,
const char** av)
12 TCLAP::CmdLine cmd(
"INRIA / IRISA - VisAGeS/Empenn Team",
' ',ANIMA_VERSION);
15 TCLAP::ValueArg<std::string> fixedArg(
"r",
"refimage",
"Fixed image",
true,
"",
"fixed image",cmd);
16 TCLAP::ValueArg<std::string> movingArg(
"m",
"movingimage",
"Moving image",
true,
"",
"moving image",cmd);
18 TCLAP::ValueArg<std::string> fixedSymmetryArg(
"",
"ref-sym",
"Fixed symmetry",
true,
"",
"fixed symmetry",cmd);
19 TCLAP::ValueArg<std::string> movingSymmetryArg(
"",
"moving-sym",
"Moving symmetry",
true,
"",
"moving symmetry",cmd);
21 TCLAP::ValueArg<std::string> outArg(
"o",
"outputimage",
"Output (registered) image",
true,
"",
"output image",cmd);
22 TCLAP::ValueArg<std::string> outputTransformArg(
"O",
"outtransform",
"Output transformation",
false,
"",
"output transform",cmd);
24 TCLAP::ValueArg<unsigned int> metricArg(
"",
"metric",
"Similarity metric (0: mutual information, 1: normalized mutual information, 2: mean squares, default: 2)",
false,2,
"similarity metric",cmd);
25 TCLAP::SwitchArg fastRegArg(
"F",
"fast-reg",
"registration on the central 2D slice only",cmd,
false);
27 TCLAP::ValueArg<unsigned int> optimizerMaxIterationsArg(
"",
"oi",
"Maximum iterations for local optimizer (default: 100)",
false,100,
"maximum local optimizer iterations",cmd);
28 TCLAP::ValueArg<unsigned int> histoSizeArg(
"",
"hs",
"Histogram size for mutual information (default: 128)",
false,128,
"histogram size",cmd);
30 TCLAP::ValueArg<double> translateUpperBoundArg(
"",
"tub",
"Upper bound on translation for bobyqa (in voxels, default: 10)",
false,10,
"Bobyqa translate upper bound",cmd);
31 TCLAP::ValueArg<double> angleUpperBoundArg(
"",
"aub",
"Upper bound on angles for bobyqa (in degrees, default: 180)",
false,180,
"Bobyqa angle upper bound",cmd);
33 TCLAP::ValueArg<unsigned int> numPyramidLevelsArg(
"p",
"pyr",
"Number of pyramid levels (default: 3)",
false,3,
"number of pyramid levels",cmd);
34 TCLAP::ValueArg<unsigned int> numThreadsArg(
"T",
"threads",
"Number of execution threads (default: 0 = all cores)",
false,0,
"number of threads",cmd);
40 catch (TCLAP::ArgException& e)
42 std::cerr <<
"Error: " << e.error() <<
"for argument " << e.argId() << std::endl;
47 typedef itk::Image <double, 3> InputImageType;
49 BridgeType::Pointer matcher = BridgeType::New();
51 matcher->SetReferenceImage(anima::readImage <InputImageType> (fixedArg.getValue()));
52 matcher->SetFloatingImage(anima::readImage <InputImageType> (movingArg.getValue()));
54 matcher->SetResultFile( outArg.getValue() );
55 matcher->SetOutputTransformFile( outputTransformArg.getValue() );
57 matcher->SetMetric( (
Metric) metricArg.getValue() );
58 matcher->SetOptimizerMaximumIterations( optimizerMaxIterationsArg.getValue() );
59 matcher->SetUpperBoundAngle(angleUpperBoundArg.getValue() * M_PI / 180.0);
60 matcher->SetTranslateUpperBound(translateUpperBoundArg.getValue());
61 matcher->SetHistogramSize(histoSizeArg.getValue());
62 matcher->SetNumberOfPyramidLevels( numPyramidLevelsArg.getValue() );
63 matcher->SetFastRegistration(fastRegArg.isSet());
65 if (numThreadsArg.getValue() != 0)
66 matcher->SetNumberOfWorkUnits( numThreadsArg.getValue() );
68 typedef BridgeType::BaseTransformType BaseTransformType;
69 itk::TransformFileReader::Pointer tmpTrRead = itk::TransformFileReader::New();
70 tmpTrRead->SetFileName(fixedSymmetryArg.getValue());
76 itk::TransformFileReader::TransformListType trsfList = *(tmpTrRead->GetTransformList());
77 itk::TransformFileReader::TransformListType::iterator tr_it = trsfList.begin();
79 matcher->SetRefSymmetryTransform (dynamic_cast< BaseTransformType *> ((*tr_it).GetPointer()));
81 catch (itk::ExceptionObject &e)
83 std::cerr <<
"Unable to read reference symmetry transform... " << e << std::endl;
87 tmpTrRead = itk::TransformFileReader::New();
88 tmpTrRead->SetFileName(movingSymmetryArg.getValue());
94 itk::TransformFileReader::TransformListType trsfList = *(tmpTrRead->GetTransformList());
95 itk::TransformFileReader::TransformListType::iterator tr_it = trsfList.begin();
97 matcher->SetFloSymmetryTransform (dynamic_cast< BaseTransformType *> ((*tr_it).GetPointer()));
99 catch (itk::ExceptionObject &e)
101 std::cerr <<
"Unable to read Floating symmetry transform... " << e << std::endl;
105 itk::TimeProbe timer;
113 catch (itk::ExceptionObject &err)
115 std::cerr << err << std::endl;
119 matcher->WriteOutputs();
123 std::cout <<
"Elapsed Time: " << timer.GetTotal() << timer.GetUnit() << std::endl;
int main(int ac, const char **av)