ANIMA  4.0
animaComputeDTIScalarMaps.cxx
Go to the documentation of this file.
2 
3 #include <tclap/CmdLine.h>
4 
5 #include <itkImage.h>
6 #include <itkCommand.h>
7 
9 
10 //Update progression of the process
11 void eventCallback (itk::Object* caller, const itk::EventObject& event, void* clientData)
12 {
13  itk::ProcessObject * processObject = (itk::ProcessObject*) caller;
14  std::cout<<"\033[K\rProgression: "<<(int)(processObject->GetProgress() * 100)<<"%"<<std::flush;
15 }
16 
17 
18 int main(int ac, const char** av)
19 {
20 
21  TCLAP::CmdLine cmd("Compute an ADC, FA, axial Diffusivity, radial diffuisivity image from a DTI volume.\nINRIA / IRISA - VisAGeS/Empenn Team",' ',ANIMA_VERSION);
22 
23  TCLAP::ValueArg<std::string> tensorArg("i",
24  "input",
25  "A tensor image",
26  true,
27  "",
28  "A tensor image",
29  cmd);
30 
31  TCLAP::ValueArg<std::string> adcArg("a",
32  "adcImage",
33  "ADC image",
34  false,
35  "",
36  "ADC image",
37  cmd);
38 
39  TCLAP::ValueArg<std::string> faArg("f",
40  "faImage",
41  "Fa image",
42  false,
43  "",
44  "Fa image",
45  cmd);
46 
47  TCLAP::ValueArg<std::string> axArg("x",
48  "axialImage",
49  "Axial diffusivity image",
50  false,
51  "",
52  "Axial diffusivity image",
53  cmd);
54 
55  TCLAP::ValueArg<std::string> radArg("r",
56  "radialImage",
57  "Radial diffusivity image",
58  false,
59  "",
60  "Radial diffusivity image",
61  cmd);
62 
63  TCLAP::ValueArg<unsigned int> nbpArg("p",
64  "pThread",
65  "Number of thread to use",
66  false,
67  0,
68  "Number of thread to use",
69  cmd);
70 
71  try
72  {
73  cmd.parse(ac,av);
74  }
75  catch (TCLAP::ArgException& e)
76  {
77  std::cerr << "Error: " << e.error() << "for argument " << e.argId() << std::endl;
78  return EXIT_FAILURE;
79  }
80 
81  itk::CStyleCommand::Pointer callback = itk::CStyleCommand::New();
82  callback->SetCallback(eventCallback);
83 
84  typedef itk::VectorImage<double, 3> TensorImageType;
85  typedef itk::Image<double, 3> OutputsImageType;
86 
87  typedef anima::DTIScalarMapsImageFilter<3> FilterType;
88 
89  FilterType::Pointer filter = FilterType::New();
90  filter->SetInput(anima::readImage<TensorImageType>(tensorArg.getValue()));
91 
92  if(nbpArg.getValue())
93  filter->SetNumberOfWorkUnits(nbpArg.getValue());
94 
95  filter->AddObserver(itk::ProgressEvent(), callback );
96  filter->Update();
97 
98  std::cout << std::endl;
99 
100  try
101  {
102  if(adcArg.getValue() != "")
103  anima::writeImage<OutputsImageType>(adcArg.getValue(), filter->GetADCImage());
104  if(faArg.getValue() != "")
105  anima::writeImage<OutputsImageType>(faArg.getValue(), filter->GetFAImage());
106  if(axArg.getValue() != "")
107  anima::writeImage<OutputsImageType>(axArg.getValue(), filter->GetAxialDiffusivityImage());
108  if(radArg.getValue() != "")
109  anima::writeImage<OutputsImageType>(radArg.getValue(), filter->GetRadialDiffusivityImage());
110  }
111  catch( itk::ExceptionObject & err )
112  {
113  std::cerr << "Itk cannot write output, be sure to use a valid extension..." << std::endl;
114  std::cerr << err << std::endl;
115  return EXIT_FAILURE;
116  }
117 
118  return EXIT_SUCCESS;
119 }// end of main
void eventCallback(itk::Object *caller, const itk::EventObject &event, void *clientData)
int main(int ac, const char **av)
Applies an variance filter to an image.