DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
MeanDiffusivityEstimator.cxx
Go to the documentation of this file.
1 
18 #include "MeanDiffusivityEstimatorCLP.h"
19 #include "utl.h"
21 #include "itkDWIReader.h"
24 // #include "itkSPFScaleFromMeanDiffusivityImageFilter.h"
25 
26 
27 
28 
32 int
33 main (int argc, char const* argv[])
34 {
35  // GenerateCLP
36  PARSE_ARGS;
37 
38  typedef double PrecisionType;
39  typedef itk::VectorImage<PrecisionType, 3> VectorImageType;
40  typedef itk::Image<PrecisionType, 3> ImageType;
41 
42  typedef itk::DWIReader<PrecisionType> DWIReaderType;
44 
45  GHOTFilterType::Pointer ghot = GHOTFilterType::New();
46  typedef GHOTFilterType::MaskImageType MaskImageType;
47  MaskImageType::Pointer maskImage;
48  if (_MaskFileArg.isSet())
49  {
50  itk::ReadImage(_MaskFile, maskImage);
51  ghot->SetMaskImage(maskImage);
52  }
53 
54  DWIReaderType::Pointer reader = DWIReaderType::New();
55  // reader->GetSamplingSchemeQSpace()->SetTau(_Tau);
56  reader->SetConfigurationFile(_InputFile);
57  if (_MaskFileArg.isSet())
58  reader->SetMaskImage(maskImage);
59  reader->Update();
60 
61  ghot->SetInput(reader->GetOutput());
62  ghot->SetSamplingSchemeQSpace(reader->GetSamplingSchemeQSpace());
63  ghot->SetSHRank(_SHRank);
64  ghot->SetRadialRank(_RadialRank);
65  if (_NumberOfThreads>0)
66  ghot->SetNumberOfThreads( _NumberOfThreads );
68  if (_ShowProgressArg.isSet())
69  ghot->AddObserver( itk::ProgressEvent(), observer );
70  if (_DebugArg.isSet())
71  ghot->DebugOn();
72  std::cout << "Estimate MD using GHOT model" << std::endl << std::flush;
73  ghot->Update();
74  std::cout << "DONE" << std::endl << std::flush;
75 
76  // VectorImageType::Pointer outputImage = ghot->GetOutput();
77  // outputImage->Print(std::cout<<"outputImage");
78  // itk::PrintVectorImage<PrecisionType,3>(outputImage, "ghot");
79 
81  MDFromGHOTFilterType::Pointer mdFromGHOT = MDFromGHOTFilterType::New();
82  mdFromGHOT->SetInput(ghot->GetOutput());
83  mdFromGHOT->SetTau(ghot->GetSamplingSchemeQSpace()->GetTau());
84  mdFromGHOT->SetScale(ghot->GetBasisScale());
85  mdFromGHOT->Update();
86  ImageType::Pointer md = mdFromGHOT->GetOutput();
87 
88  // md->Print(std::cout<<"md");
89  // itk::PrintImage<PrecisionType,3>(md, "md");
90  itk::SaveImage(md, _OutputFile);
91 
92 
93  return 0;
94 }
estimate the coefficients in GHOT model, which is used for md image estimation
helper functions specifically used in dmritool
bool SaveImage(const SmartPointer< ImageType > &image, const std::string &filename, const std::string &printInfo="Writing Image:")
Definition: utlITK.h:157
bool ReadImage(const std::string &filename, SmartPointer< ImageType > &image, const std::string &printInfo="Reading Image:")
Definition: utlITK.h:110
int main(int argc, char const *argv[])
estimate mean diffusivity in each voxel
Compute mean diffusivity from GHOT coefficients.
Load gradient file, b values and DWI files (with optional index file)
Definition: itkDWIReader.h:59
itk::VectorImage< ScalarType, 3 > VectorImageType
Definition: 4DImageMath.cxx:30