20 #ifndef __itkSamplingSchemeQSpaceWriter_hxx 21 #define __itkSamplingSchemeQSpaceWriter_hxx 29 template <
class TSamplingType>
37 m_SaveSingleShell =
false;
38 m_SaveAllShellsInOneFile =
true;
42 template <
class TSamplingType>
47 Superclass::PrintSelf(os, indent);
49 os << indent <<
"m_BFile: " << m_BFile << std::endl;
50 os << indent <<
"m_OrientationFile: " << m_OrientationFile << std::endl;
51 os << indent <<
"m_SaveSingleShell: " << m_SaveSingleShell << std::endl;
52 os << indent <<
"m_SaveAllShellsInOneFile: " << m_SaveAllShellsInOneFile << std::endl;
53 m_Sampling->Print(os<< indent <<
"m_Sampling\n");
56 template <
class TSamplingType>
62 utlGlobalException(!m_SaveSingleShell && !m_SaveAllShellsInOneFile,
"need to set m_SaveSingleShell or m_SaveAllShellsInOneFile");
65 if (m_SaveAllShellsInOneFile)
67 typename SamplingType::MatrixPointer orientationMatrix = m_Sampling->GetOrientationsCartesian();
68 std::cout <<
"save all orientations to " << m_OrientationFile << std::endl << std::flush;
69 orientationMatrix->Save(m_OrientationFile);
72 typename SamplingType::STDVectorPointer bVector = m_Sampling->GetBVector();
73 std::cout <<
"save all bValues to " << m_BFile << std::endl << std::flush;
78 if (m_SaveSingleShell)
80 unsigned int numberOfShells = m_Sampling->GetNumberOfShells();
83 typename SamplingType::MatrixPointer orientationMatrix;
84 typename SamplingType::STDVectorPointer bVector;
85 std::string realBFile, realOrientationFile, bExt, orientationExt, bNoExt, orientationNoExt, indexStr;
90 for (
int i = 0; i < numberOfShells; i += 1 )
92 bVector = m_Sampling->GetBVectorInShell(i);
93 if (bVector->size()>0)
97 for (
unsigned int j = 0; j < bVector->size(); j += 1 )
98 sum += bVector->operator[](j);
99 sum /= (double)bVector->size();
100 int meanInt = (int)(sum);
110 realBFile = bNoExt +
"_" + indexStr +
"." + bExt;
112 std::cout <<
"save b values in shell " << i+1 <<
" to " << realOrientationFile << std::endl << std::flush;
114 orientationMatrix = m_Sampling->GetOrientationsCartesianInShell(i);
115 realOrientationFile = orientationNoExt +
"_" + indexStr +
"." + orientationExt;
116 std::cout <<
"save orientations in shell " << i+1 <<
" to " << realOrientationFile << std::endl << std::flush;
117 orientationMatrix->Save(realOrientationFile);
void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
void SaveVector(const VectorType &vv, const int NSize, const std::string &vectorStr, const bool is_save_number=false)
helper functions specifically used in dmritool
std::string ConvertNumberToString(const T value, const int precision=6)
SamplingSchemeQSpaceWriter()
#define utlGlobalException(cond, expout)
void GetFileExtension(const std::string &fileNameAbsolute, std::string &ext, std::string &fileNoExt)