2 #include <tclap/CmdLine.h> 4 #include <itkImageFileReader.h> 5 #include <itkImageFileWriter.h> 8 #include <itkTimeProbe.h> 10 int main(
int argc,
char **argv)
12 TCLAP::CmdLine cmd(
"INRIA / IRISA - VisAGeS/Empenn Team",
' ',ANIMA_VERSION);
14 TCLAP::ValueArg<std::string> t2Arg(
"l",
"t2",
"List of T2 relaxometry images",
true,
"",
"T2 relaxometry images",cmd);
15 TCLAP::ValueArg<std::string> maskArg(
"m",
"maskname",
"Computation mask",
false,
"",
"computation mask",cmd);
17 TCLAP::ValueArg<std::string> t1MapArg(
"",
"t1",
"T1 map",
false,
"",
"T1 map",cmd);
19 TCLAP::ValueArg<std::string> resT2Arg(
"o",
"out-t2",
"Result T2 image",
true,
"",
"result T2 image",cmd);
20 TCLAP::ValueArg<std::string> resM0Arg(
"O",
"out-m0",
"Result M0 image",
false,
"",
"result M0 image",cmd);
22 TCLAP::ValueArg<double> trArg(
"",
"tr",
"Repetition time for T2 relaxometry (default: 5000)",
false,5000,
"repetition time",cmd);
23 TCLAP::ValueArg<double> upperBoundT2Arg(
"u",
"upper-bound-t2",
"T2 value upper bound (default: 5000)",
false,5000,
"T2 value upper bound",cmd);
25 TCLAP::ValueArg<double> echoSpacingArg(
"e",
"echo-spacing",
"Spacing between two successive echoes (default: 10)",
false,10,
"Spacing between echoes",cmd);
26 TCLAP::ValueArg<double> backgroundSignalThresholdArg(
"t",
"signal-thr",
"Background signal threshold (default: 10)",
false,10,
"Background signal threshold",cmd);
28 TCLAP::ValueArg<unsigned int> numOptimizerIterArg(
"",
"opt-iter",
"Maximal number of optimizer iterations (default: 2000)",
false,2000,
"Maximal number of optimizer iterations",cmd);
29 TCLAP::ValueArg<double> optimizerStopConditionArg(
"",
"opt-stop",
"Optimizer stopping threshold (default: 1.0e-4)",
false,1.0e-4,
"Optimizer stopping threshold",cmd);
31 TCLAP::ValueArg<unsigned int> nbpArg(
"T",
"numberofthreads",
"Number of threads to run on (default : all cores)",
false,itk::MultiThreaderBase::GetGlobalDefaultNumberOfThreads(),
"number of threads",cmd);
37 catch (TCLAP::ArgException& e)
39 std::cerr <<
"Error: " << e.error() <<
"for argument " << e.argId() << std::endl;
43 typedef itk::Image <double,3> InputImageType;
44 typedef InputImageType OutputImageType;
46 typedef itk::ImageFileReader <InputImageType> InputImageReaderType;
47 typedef itk::ImageFileWriter <OutputImageType> OutputImageWriterType;
49 FilterType::Pointer mainFilter = FilterType::New();
52 anima::setMultipleImageFilterInputsFromFileName<InputImageType,FilterType>(t2Arg.getValue(),mainFilter);
54 mainFilter->SetTRValue(trArg.getValue());
55 mainFilter->SetEchoSpacing(echoSpacingArg.getValue());
57 mainFilter->SetMaximumOptimizerIterations(numOptimizerIterArg.getValue());
58 mainFilter->SetOptimizerStopCondition(optimizerStopConditionArg.getValue());
60 mainFilter->SetT2UpperBoundValue(upperBoundT2Arg.getValue());
62 if (t1MapArg.getValue() !=
"")
64 InputImageReaderType::Pointer t1MapRead = InputImageReaderType::New();
65 t1MapRead->SetFileName(t1MapArg.getValue().c_str());
68 mainFilter->SetT1Map(t1MapRead->GetOutput());
71 if (maskArg.getValue() !=
"")
73 typedef itk::ImageFileReader < itk::Image <unsigned char, 3> > itkMaskReader;
74 itkMaskReader::Pointer maskRead = itkMaskReader::New();
75 maskRead->SetFileName(maskArg.getValue().c_str());
78 mainFilter->SetComputationMask(maskRead->GetOutput());
81 mainFilter->SetAverageSignalThreshold(backgroundSignalThresholdArg.getValue());
82 mainFilter->SetNumberOfWorkUnits(nbpArg.getValue());
84 itk::TimeProbe tmpTime;
91 std::cout <<
"Total computation time: " << tmpTime.GetTotal() << std::endl;
93 OutputImageWriterType::Pointer resultT2Writer = OutputImageWriterType::New();
94 resultT2Writer->SetFileName(resT2Arg.getValue().c_str());
95 resultT2Writer->SetUseCompression(
true);
96 resultT2Writer->SetInput(mainFilter->GetOutput(0));
98 resultT2Writer->Update();
100 if (resM0Arg.getValue() !=
"")
102 OutputImageWriterType::Pointer resultM0Writer = OutputImageWriterType::New();
103 resultM0Writer->SetFileName(resM0Arg.getValue().c_str());
104 resultM0Writer->SetUseCompression(
true);
105 resultM0Writer->SetInput(mainFilter->GetOutput(1));
107 resultM0Writer->Update();
int main(int argc, char **argv)