DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
SPFToProfile.cxx
Go to the documentation of this file.
1 
18 #include "utl.h"
19 #include "SPFToProfileCLP.h"
21 #include "itkImage.h"
23 
24 
25 
29 int
30 main (int argc, char const* argv[])
31 {
32 
33  // GenerateCLP
34  PARSE_ARGS;
35 
36  typedef double PrecisionType;
37  typedef itk::VectorImage<PrecisionType, 3> VectorImageType;
38  typedef itk::Image<PrecisionType, 3> ScalarImageType;
39 
40  VectorImageType::Pointer spf=0;
41  ScalarImageType::Pointer maskImage=0;
42  itk::ReadImage<VectorImageType>(_InputSPFFile, spf);
43  if (_MaskFileArg.isSet())
44  itk::ReadImage<ScalarImageType>(_MaskFile, maskImage);
45 
46  ScalarImageType::Pointer mdImage=0, scaleImage=0;
47  if (_MDImageFileArg.isSet())
48  {
49  itk::ReadImage<ScalarImageType>(_MDImageFile, mdImage);
50 
52  ScaleFromMDfilterType::Pointer scaleFromMDfilter = ScaleFromMDfilterType::New();
53  scaleFromMDfilter->SetMD0(_MD0);
54  scaleFromMDfilter->SetTau(_Tau);
55  scaleFromMDfilter->SetIsOriginalBasis(true);
56  scaleFromMDfilter->SetInput(mdImage);
57  scaleFromMDfilter->Update();
58  scaleImage = scaleFromMDfilter->GetOutput();
59  }
60 
62  // FeaturesFromSPFFilterType::Pointer featureFromSPFFilter=NULL;
63 
65  ProfileFromSPFFilterType::Pointer featureFromSPFFilter = ProfileFromSPFFilterType::New();
66  // featureFromSPFFilter = ProfileFromSPFFilterType::New();
67  if (_MaskFileArg.isSet())
68  featureFromSPFFilter->SetMaskImage(maskImage);
69  featureFromSPFFilter->SetSHRank(_SHRank);
70  featureFromSPFFilter->SetRadialRank(_RadialRank);
71  featureFromSPFFilter->SetMD0(_MD0);
72  featureFromSPFFilter->SetTau(_Tau);
73  featureFromSPFFilter->SetBasisScale(_Scale);
74  featureFromSPFFilter->SetBasisType(FeaturesFromSPFFilterType::SPF);
75  if (_MDImageFileArg.isSet())
76  {
77  featureFromSPFFilter->SetScaleImage(scaleImage);
78  }
79  featureFromSPFFilter->SetIsInQSpace(!_rSpaceArg.isSet());
80  if (_OrientationsFileArg.isSet())
81  {
82  ProfileFromSPFFilterType::MatrixPointer grad = utl::ReadGrad<double>(_OrientationsFile, DIRECTION_NODUPLICATE, CARTESIAN_TO_SPHERICAL);
83  featureFromSPFFilter->SetOrientations(grad);
84  }
85  if (_RadiusVectorFileArg.isSet())
86  {
87  ProfileFromSPFFilterType::STDVectorPointer radiusVec(new ProfileFromSPFFilterType::STDVectorType());
88  utl::ReadVector(_RadiusVectorFile, *radiusVec);
89  featureFromSPFFilter->SetRadiusVector(radiusVec);
90  }
91  if (_NumberOfThreads>0)
92  featureFromSPFFilter->SetNumberOfThreads(_NumberOfThreads);
93  if (_DebugArg.isSet())
94  featureFromSPFFilter->DebugOn();
95  featureFromSPFFilter->SetInput(spf);
96  featureFromSPFFilter->SetRadius(_Radius);
97  featureFromSPFFilter->SetIsFourier(_IsFourier);
98  std::cout << "EAP profile estimation starts" << std::endl << std::flush;
99  featureFromSPFFilter->Update();
100  std::cout << "EAP profile estimation ends" << std::endl << std::flush;
101  VectorImageType::Pointer eap = featureFromSPFFilter->GetOutput();
102  itk::SaveImage<VectorImageType>(eap, _OutputFile);
103 
104  return 0;
105 }
helper functions specifically used in dmritool
Calculate DWI/EAP profile from SPF coefficients.
void ReadVector(const std::string &vectorStr, std::vector< T > &vec, const char *cc=" ")
Definition: utlCore.h:1159
int main(int argc, char const *argv[])
DWI/EAP profile (represented by SH basis) converted from SPF coefficients.
itk::VectorImage< ScalarType, 3 > VectorImageType
Definition: 4DImageMath.cxx:30
Compute some features (DWI/EAP profile, ODFs, scalar indices) from SPF coefficients.