3 #include <itkTimeProbe.h> 8 #include <tclap/CmdLine.h> 10 int main(
int argc,
char **argv)
12 TCLAP::CmdLine cmd(
"INRIA / IRISA - VisAGeS/Empenn Team",
' ',ANIMA_VERSION);
14 TCLAP::ValueArg<std::string> inArg(
"i",
"inputdti",
"DTI volume",
true,
"",
"DTI volume",cmd);
15 TCLAP::ValueArg<std::string> resArg(
"o",
"output",
"Result DWI image",
true,
"",
"result DWI image",cmd);
16 TCLAP::ValueArg<std::string> s0ValueArg(
"s",
"s0",
"S0 of DWI (constant value or image)",
false,
"200",
"S0 of DWI",cmd);
18 TCLAP::ValueArg<std::string> gradsArg(
"g",
"grad",
"Input gradients",
true,
"",
"Input gradients",cmd);
19 TCLAP::ValueArg<std::string> bvalArg(
"b",
"bval",
"Input b-values",
true,
"",
"Input b-values",cmd);
21 TCLAP::ValueArg<unsigned int> nbpArg(
"p",
"numberofthreads",
"Number of threads to run on (default: all cores)",
false,itk::MultiThreaderBase::GetGlobalDefaultNumberOfThreads(),
"number of threads",cmd);
27 catch (TCLAP::ArgException& e)
29 std::cerr <<
"Error: " << e.error() <<
"for argument " << e.argId() << std::endl;
34 typedef FilterType::InputImageType InputImageType;
35 typedef FilterType::Image4DType Image4DType;
37 FilterType::Pointer mainFilter = FilterType::New();
40 GFReaderType gfReader;
42 gfReader.SetBValueBaseString(bvalArg.getValue());
43 gfReader.SetGradientIndependentNormalization(
false);
46 std::vector< std::vector<double> > directions = gfReader.GetGradients();
48 for(
unsigned int i = 0;i < directions.size();++i)
49 mainFilter->AddGradientDirection(i,directions[i]);
51 std::vector <double> mb = gfReader.GetBValues();
52 mainFilter->SetBValuesList(mb);
54 typedef itk::ImageFileReader <FilterType::S0ImageType> S0ImageReaderType;
55 FilterType::S0ImageType::Pointer s0Image;
58 s0Image = anima::readImage <FilterType::S0ImageType> (s0ValueArg.getValue());
59 mainFilter->SetS0Image(s0Image);
61 catch(itk::ExceptionObject &e)
63 mainFilter->SetS0Value(std::stod(s0ValueArg.getValue()));
66 mainFilter->SetInput(anima::readImage <InputImageType> (inArg.getValue()));
67 mainFilter->SetNumberOfWorkUnits(nbpArg.getValue());
69 itk::TimeProbe tmpTimer;
76 catch (itk::ExceptionObject &e)
78 std::cerr << e << std::endl;
84 std::cout <<
"Simulation done in " << tmpTimer.GetTotal() <<
" s" << std::endl;
85 std::cout <<
"Writing result to : " << resArg.getValue() << std::endl;
87 anima::writeImage <Image4DType> (resArg.getValue(), mainFilter->GetOutputAs4DImage());
void SetGradientFileName(std::string fName)
int main(int argc, char **argv)