DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
ComputeSHCoefficientsOfDWIFromSymmetricTensor.cxx
Go to the documentation of this file.
1 
18 #include "ComputeSHCoefficientsOfDWIFromSymmetricTensorCLP.h"
20 #include "utlCore.h"
21 
22 void
23 DoMain ( std::vector<double>& e1e2, std::vector<double>& bvec, const int shOrder, std::ostream& os, const bool outputAll, const bool nob )
24 {
25  for ( int i = 0; i < bvec.size(); i += 1 )
26  {
27  double b = bvec[i];
28  utl_shared_ptr<utl::NDArray<double,1> > coef = utl::GetSymmetricTensorSHCoef<double>(b, e1e2[0], e1e2[1], shOrder, 0.0, 0.0 );
29  if (!nob)
30  os << b << " ";
31  if (outputAll)
32  {
33  for ( int i = 0; i < coef->Size(); i += 1 )
34  os << (*coef)[i] << " ";
35  }
36  else
37  {
38  for ( int l = 0; l <= shOrder; l += 2 )
39  {
40  int jj = utl::GetIndexSHj(l, 0);
41  os << (*coef)[jj] << " ";
42  }
43  }
44  os << std::endl;
45  }
46 }
47 
53 int
54 main (int argc, char const* argv[])
55 {
56  // GenerateCLP
57  PARSE_ARGS;
58 
59  utlGlobalException(_EigenValuesArg.isSet() && _FAMDArg.isSet(), "only one of --eigenvalues and --famd can be set");
60  utlGlobalException(!_EigenValuesArg.isSet() && !_FAMDArg.isSet(), "need to set one of --eigenvalues and --famd");
61  utlGlobalException(_BValues.size()==0, "need to set --bvalues");
62 
64  if (_EigenValuesArg.isSet())
65  {
66  utlGlobalException(_EigenValues.size()!=2, "wrong size in --eigenvalues");
67  }
68  else
69  {
70  utlGlobalException(_FAMD.size()!=2, "wrong size in --eigenvalues");
71  _EigenValues = utl::GetE1E2FromFAMD(_FAMD[0], _FAMD[1]);
72  }
73 
74  if (_OutputFileArg.isSet())
75  {
76  std::ofstream out;
77  out.open ( _OutputFile.c_str() );
78  DoMain(_EigenValues, _BValues, _SHOrder, out, _OutputAllCoefficientsArg.isSet(), _NoBArg.isSet());
79  out.close();
80  }
81  else
82  DoMain(_EigenValues, _BValues, _SHOrder, std::cout, _OutputAllCoefficientsArg.isSet(), _NoBArg.isSet());
83 
84  return 0;
85 }
std::vector< T > GetE1E2FromFAMD(const T fa, const T meanEigenValue, const bool isE2E3Equal=true)
Definition: utlDMRI.h:235
int GetIndexSHj(const int l, const int m)
Definition: utlDMRI.h:204
void InitializeLUTExp()
int main(int argc, char const *argv[])
Compute SH coefficients of DWI signal in DTI with symmetric tensor (along z-axis).
#define utlGlobalException(cond, expout)
Definition: utlCoreMacro.h:372
void DoMain(std::vector< double > &e1e2, std::vector< double > &bvec, const int shOrder, std::ostream &os, const bool outputAll, const bool nob)