9 m_NumberOfOutputDirectionalCompartments = 3;
22 m_OutputModel = model->Clone();
28 m_NumberOfOutputDirectionalCompartments = val;
34 m_NumberOfOutputDirectionalCompartments = m_OutputModel->GetNumberOfCompartments() - m_OutputModel->GetNumberOfIsotropicCompartments();
54 itkExceptionMacro(
"Output model not initialized")
56 return m_OutputModel->GetSize();
64 if (m_InputModels.size() != m_InputWeights.size())
65 itkExceptionMacro(
"Not the same number of weights and input models");
67 unsigned int numInputs = m_InputModels.size();
69 double sumWeights = 0;
70 for (
unsigned int i = 0;i < numInputs;++i)
71 sumWeights += m_InputWeights[i];
73 for (
unsigned int i = 0;i < numInputs;++i)
74 m_InputWeights[i] /= sumWeights;
77 unsigned int numIsoCompartments = m_InputModels[0]->GetNumberOfIsotropicCompartments();
81 for (
unsigned int i = 0;i < numIsoCompartments;++i)
83 double outputLogDiffusivity = 0;
84 double outputRadius = 0.0;
85 double sumWeights = 0;
86 for (
unsigned int j = 0;j < numInputs;++j)
88 if (m_InputWeights[j] <= 0)
91 double tmpWeight = m_InputModels[j]->GetCompartmentWeight(i);
96 outputLogDiffusivity += m_InputWeights[j] * std::log(m_InputModels[j]->GetCompartment(i)->GetAxialDiffusivity());
97 outputRadius += m_InputWeights[j] * m_InputModels[j]->GetCompartment(i)->GetTissueRadius();
98 sumWeights += m_InputWeights[j];
103 m_OutputModel->GetCompartment(i)->SetAxialDiffusivity(std::exp(outputLogDiffusivity / sumWeights));
104 m_OutputModel->GetCompartment(i)->SetTissueRadius(outputRadius / sumWeights);
108 unsigned int maxNumOutputCompartments = m_OutputModel->GetNumberOfCompartments() - m_OutputModel->GetNumberOfIsotropicCompartments();
109 unsigned int numOutputCompartments = m_NumberOfOutputDirectionalCompartments;
110 if (numOutputCompartments > maxNumOutputCompartments)
111 numOutputCompartments = maxNumOutputCompartments;
116 for (
unsigned int i = 0;i < numInputs;++i)
118 if (m_InputWeights[i] <= 0)
121 for (
unsigned int j = numIsoCompartments;j < m_InputModels[i]->GetNumberOfCompartments();++j)
123 double tmpWeight = m_InputModels[i]->GetCompartmentWeight(j);
134 if (numInputCompartments <= numOutputCompartments)
136 for (
unsigned int i = 0;i < numInputCompartments;++i)
138 m_OutputModel->GetCompartment(i + numIsoCompartments)->SetCompartmentVector(
m_WorkCompartmentsVector[i]->GetCompartmentVector());
149 if (tensorCompatibility)
162 for (
unsigned int i = 0;i < numInputCompartments;++i)
165 if (tensorCompatibility)
180 for (
unsigned int i = 0;i < numCompartments;++i)
190 for (
unsigned int i = 0;i < numCompartments;++i)
191 for (
unsigned int j = i+1;j < numCompartments;++j)
193 double distValue = 0;
194 for (
unsigned int k = 0;k < 6;++k)
204 itkExceptionMacro(
"No non-tensor distance matrix implemented in public version")
210 unsigned int numIsoCompartments = m_OutputModel->GetNumberOfIsotropicCompartments();
222 for (
unsigned int i = 0;i < numberOfOutputCompartments;++i)
225 double totalWeights = 0;
226 for (
unsigned int j = 0;j < numCompartments;++j)
233 if ((anisoCompartmentType ==
anima::Stick) && (totalWeights == 0.0))
239 totalWeights += weight;
243 if (totalWeights > 0.0)
282 itkExceptionMacro(
"No non-tensor model computation implemented in public version")
void InitializeSigmaFromDistances()
itk::VariableLengthVector< double > m_InternalOutputVector
void SetDataWeights(VectorType &val)
virtual void ComputeOutputNonTensorModel()
virtual void SetCompartmentVector(ModelOutputVectorType &compartmentVector)=0
Set compartment overall description vector, for setting automatically the individual parameters when ...
void SetCMeansAverageType(CMeansAverageType val)
std::vector< double > m_WorkCompartmentWeights
void SetInputData(MatrixType &data)
Input data: matrix of squared distances.
VectorType & GetClassesMembership(unsigned int i)
void SetVerbose(bool verb)
void ComputeTensorDistanceMatrix()
void GetVectorRepresentation(const vnl_matrix< T1 > &tensor, itk::VariableLengthVector< T2 > &vector, unsigned int vecDim=0, bool scale=false)
DiffusionModelCompartmentType
std::vector< std::vector< double > > m_InternalSpectralMemberships
unsigned int GetOutputModelSize()
LECalculatorPointer m_leCalculator
virtual void ComputeNonTensorDistanceMatrix()
void GetTensorFromVectorRepresentation(const itk::VariableLengthVector< T1 > &vector, vnl_matrix< T2 > &tensor, unsigned int tensDim=0, bool scale=false)
vnl_diag_matrix< double > m_InternalWorkEigenValuesInputSticks
vnl_diag_matrix< double > m_InternalWorkEigenValues
void RecomposeTensor(vnl_diag_matrix< T1 > &eigs, vnl_matrix< T1 > &eigVecs, vnl_matrix< T2 > &resMatrix)
Recompose tensor from values extracted using SymmetricEigenAnalysis (vnl_symmetric_eigensystem transp...
MultiCompartmentModel: holds several diffusion compartments, ordered by type It also handles weights ...
void SetNumberOfOutputDirectionalCompartments(unsigned int val)
vnl_matrix< double > m_InternalDistanceMatrix
void SetOutputModel(MCMType *model)
vnl_matrix< double > m_InternalWorkEigenVectors
void SetMaxIterations(unsigned int mIt)
void ResetNumberOfOutputDirectionalCompartments()
std::vector< itk::VariableLengthVector< double > > m_InternalLogTensors
MCMPointer & GetUntouchedOutputModel()
vnl_matrix< double > m_InternalWorkMatrix
std::vector< MCMCompartmentPointer > m_WorkCompartmentsVector
EigenAnalysisType m_InternalEigenAnalyzer
std::vector< double > m_InternalOutputWeights
MCMType::Pointer MCMPointer
void SetNbClass(unsigned int nbC)
void ComputeOutputTensorCompatibleModel()
SpectralClusterType m_InternalSpectralCluster
MCMPointer & GetOutputModel()