18 #ifndef __itkFeaturesFromSPFImageFilter_hxx 19 #define __itkFeaturesFromSPFImageFilter_hxx 28 template<
class TInputImage,
class TOutputImage >
40 m_ScaleImage=ScalarImageType::New();
46 m_SPFIEstimator=SPFIFilterBaseType::New();
49 template<
class TInputImage,
class TOutputImage >
56 scale = 1.0 / (8*
M_PI*
M_PI*this->m_Tau*this->m_MD0);
57 else if (m_BasisType==DSPF)
58 scale = 2*this->m_Tau*this->m_MD0;
64 template<
class TInputImage,
class TOutputImage >
69 double scale_old = m_BasisScale;
73 this->ComputeScale(
true);
74 itkDebugMacro(
"setting m_BasisScale to " << m_BasisScale);
76 if (scale>0 && std::fabs((scale_old-m_BasisScale)/m_BasisScale)>1e-8)
84 template<
class TInputImage,
class TOutputImage >
89 if( scaleImage != m_ScaleImage )
91 std::cout <<
"Use adaptive scale" << std::endl << std::flush;
92 m_ScaleImage = scaleImage;
98 template<
class TInputImage,
class TOutputImage >
104 typename TInputImage::ConstPointer inputPtr = this->GetInput();
105 utlSAGlobalException(this->m_SPFIEstimator->RankToDim(
false, this->m_RadialRank, this->m_SHRank)!=inputPtr->GetNumberOfComponentsPerPixel())
106 (this->m_RadialRank)(this->m_SHRank)(this->m_SPFIEstimator->RankToDim(
false, this->m_RadialRank, this->m_SHRank))(inputPtr->GetNumberOfComponentsPerPixel()).msg(
"the size of input image is not consistent with the given shRank and radialRank");
109 template<
class TInputImage,
class TOutputImage >
110 typename LightObject::Pointer
114 typename LightObject::Pointer loPtr = Superclass::InternalClone();
119 itkExceptionMacro(<<
"downcast to type " << this->GetNameOfClass()<<
" failed.");
121 rval->m_BasisScale = m_BasisScale;
124 rval->m_SHRank = m_SHRank;
125 rval->m_RadialRank = m_RadialRank;
126 rval->m_ScaleImage = m_ScaleImage;
128 rval->m_IsFourier = m_IsFourier;
129 rval->m_IsInQSpace = m_IsInQSpace;
130 rval->m_Orientations = m_Orientations;
134 rval->m_SPFToFeatureTransform = m_SPFToFeatureTransform;
135 rval->m_BasisType = m_BasisType;
137 rval->m_SPFIEstimator = m_SPFIEstimator->Clone();
138 rval->SetDebug(this->GetDebug());
142 template<
class TInputImage,
class TOutputImage >
147 std::cout <<
"Use " << this->GetNumberOfThreads() <<
" threads!" << std::endl << std::flush;
148 VerifyInputParameters();
151 template<
class TInputImage,
class TOutputImage >
156 if (this->m_BasisType==SPF || this->m_BasisType==DSPF)
159 this->m_SPFIEstimator = SPFIFilterType::New();
161 if (this->m_BasisType==SPF && !this->m_IsFourier)
162 this->m_SPFIEstimator->SetIsOriginalBasis(
true);
164 this->m_SPFIEstimator->SetIsOriginalBasis(
false);
168 template<
class TInputImage,
class TOutputImage >
173 Superclass::PrintSelf(os, indent);
175 <<
"m_Tau = " << m_Tau
176 <<
", m_BasisScalar = " << m_BasisScale
177 <<
", m_MD0 = " << m_MD0
178 <<
", m_SHRank = " << m_SHRank
179 <<
", m_RadialRank = " << m_RadialRank
180 <<
", m_IsInQSpace = " << m_IsInQSpace
181 <<
", m_IsFourier = " << this->m_IsFourier
186 utl::PrintUtlMatrix(*m_SPFToFeatureTransform,
"m_SPFToFeatureTransform",
" ",os << indent);
188 std::cout <<
"m_ScaleImage = " << m_ScaleImage << std::endl << std::flush;
189 if (m_BasisType==SPF)
190 os << indent <<
"Use SPF basis" << std::endl << std::flush;
191 else if (m_BasisType==DSPF)
192 os << indent <<
"Use DSPF basis" << std::endl << std::flush;
193 os << indent <<
"m_SPFIEstimator = " << m_SPFIEstimator << std::endl << std::flush;
void SetScaleImage(const ScalarImagePointer &scaleImage)
helper functions specifically used in dmritool
bool IsImageEmpty(const SmartPointer< ImageType > &image)
void PrintUtlMatrix(const NDArray< T, 2 > &mat, const std::string &str="", const char *separate=" ", std::ostream &os=std::cout)
double ComputeScale(const bool setScale=true)
void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
virtual void SetBasisScale(const double scale)
#define utlSAGlobalException(expr)
LightObject::Pointer InternalClone() const ITK_OVERRIDE
utl_shared_ptr< MatrixType > MatrixPointer
#define utlGlobalException(cond, expout)
FeaturesFromSPFImageFilter()
void BeforeThreadedGenerateData() ITK_OVERRIDE
estimate the coefficients in SPF model
Compute some features (DWI/EAP profile, ODFs, scalar indices) from SPF coefficients.
SmartPointer< Self > Pointer
virtual void VerifyInputParameters() const ITK_OVERRIDE