DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
SHCoefficientsToSphericalFunctionSamples.cxx
Go to the documentation of this file.
1 
11 #include "utl.h"
13 #include "SHCoefficientsToSphericalFunctionSamplesCLP.h"
14 
15 #include "itkFunctors.h"
17 
21 int
22 main (int argc, char const* argv[])
23 {
24  // GenerateCLP
25  PARSE_ARGS;
26 
27  typedef double TScalarType;
28  typedef utl::NDArray<TScalarType,2> MatrixType;
29  typedef itk::VectorImage<TScalarType,3> ImageType;
30 
31  ImageType::Pointer inputImage = ImageType::New();
32  itk::ReadVectorImage(_InputSHFile, inputImage);
33 
34  unsigned shDim = inputImage->GetNumberOfComponentsPerPixel();
35  unsigned shRank = utl::DimToRankSH(shDim);
36 
37  utl_shared_ptr<MatrixType> grad = utl::ReadGrad<TScalarType>(_dataOrientationsFile, DIRECTION_NODUPLICATE, CARTESIAN_TO_CARTESIAN);
38  utl_shared_ptr<MatrixType> basisMatrix = utl::ComputeSHMatrix(shRank, *grad, CARTESIAN_TO_SPHERICAL);
39 
40  if (_Debug)
41  std::cout << "basisMatrix: \n" << *basisMatrix;
42 
44  FilterType::Pointer filter = FilterType::New();
45 
46  filter->SetInput(inputImage);
47  filter->SetConstantMatrix(*basisMatrix);
48  filter->Update();
49 
50  ImageType::Pointer outputImage, sfImage;
51  sfImage = filter->GetOutput();
52  if (std::fabs(_Power-1.0)>1e-10)
53  {
55  p0.SetArgument(_Power);
57  itk::UnaryVectorOPImage<ImageType, ImageType>(sfImage, outputImage, pp);
58  }
59  else
60  outputImage = sfImage;
61 
62  itk::SaveImage(outputImage, _OutputFile);
63 
64  return 0;
65 }
NDArray is a N-Dimensional array class (row-major, c version)
Definition: utlFunctors.h:131
helper functions specifically used in dmritool
void ReadVectorImage(const std::string &filename, SmartPointer< VectorImage< PixelType, 3 > > &image, const std::string &printInfo="Reading Image:")
Definition: utl.h:66
bool SaveImage(const SmartPointer< ImageType > &image, const std::string &filename, const std::string &printInfo="Writing Image:")
Definition: utlITK.h:157
int DimToRankSH(const int dimm)
Definition: utlDMRI.h:182
std::shared_ptr< NDArray< T, 2 > > ComputeSHMatrix(const unsigned int rank, const NDArray< T, 2 > &grad, const int mode)
Definition: utl.h:171
int main(int argc, char const *argv[])
calculate samples of a spherical function from its SH coefficients
void SetArgument(TArgument arg)
Definition: itkFunctors.h:118
In each vxoel, multiply the input vector by a matrix.