DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
SHCoefficientsFit.cxx
Go to the documentation of this file.
1 
12 #include "itkSHCoefficientsFit.h"
13 #include "utl.h"
14 
15 #include "SHCoefficientsFitCLP.h"
17 
21 int
22 main (int argc, char const* argv[])
23 {
24  PARSE_ARGS;
25  utl::LogLevel = _Verbose;
26 
27  utlGlobalException(_SHRank<0, "need to set _SHRank");
28 
29  typedef double PrecisionType;
30  typedef itk::VectorImage<PrecisionType, 3> ImageType;
31  typedef itk::Functor::SHCoefficientsFit<double> FunctorType;
33 
34  ImageType::Pointer sfImage = ImageType::New();
35  itk::ReadImage<ImageType>(_InputFile, sfImage);
36 
37  FunctorType::MatrixPointer grad = utl::ReadGrad<double>(_OrientationFile,DIRECTION_NODUPLICATE, CARTESIAN_TO_CARTESIAN);
38 
39  FunctorType shFit;
40  shFit.SetSHRank(_SHRank);
41  if (_Lambda>0)
42  shFit.SetLambda(_Lambda);
43  shFit.SetOrientations(grad);
44  shFit.SetPower(_Power);
45  shFit.SetLogLevel(utl::LogLevel);
46 
47  typename UnaryFunctorFilterType::Pointer filter = UnaryFunctorFilterType::New();
48 
49  if (_MaskImageFile!="")
50  filter->SetMaskImage(_MaskImageFile);
51  filter->SetInput(sfImage);
52  filter->SetFunctor(shFit);
53 
54  filter->SetDebug(_Verbose>=LOG_DEBUG);
55  filter->SetLogLevel(utl::LogLevel);
56  if (_NumberOfThreads>0)
57  filter->SetNumberOfThreads(_NumberOfThreads);
59  if (_ShowProgressArg.isSet())
60  filter->AddObserver( itk::ProgressEvent(), observer );
61 
62  filter->Update();
63 
64  ImageType::Pointer shImage = filter->GetOutput();
65  itk::SaveImage<ImageType>(shImage, _OutputFile);
66 
67  return 0;
68 }
helper functions specifically used in dmritool
used for debug information. this->GetDebug()
Definition: utlCoreMacro.h:193
fit SH coefficients from spherical function samples.
#define utlGlobalException(cond, expout)
Definition: utlCoreMacro.h:372
Created "10-06-2016.
static int LogLevel
Definition: utlCoreMacro.h:203
int main(int argc, char const *argv[])
fit spherical function samples using SH basis
Implements vector-valued generic operation on one image.