17 #ifndef DIFFUSIONKURTOSISRECONSTRUCTIONIMAGEFILTER_H
18 #define DIFFUSIONKURTOSISRECONSTRUCTIONIMAGEFILTER_H
20 #include "itkImageToImageFilter.h"
21 #include "itkVectorImage.h"
26 #include <vnl/algo/vnl_levenberg_marquardt.h>
27 #include <vnl/vnl_least_squares_function.h>
40 public vnl_least_squares_function
45 : vnl_least_squares_function( num_params, num_measurements, g),
58 void initialize( vnl_vector< double >
const& _meas, vnl_vector< double>
const& _bvals )
63 for(
unsigned int i=0; i<
meas.size(); ++i)
90 double upper_bounds[2] = {4e-3, 4 };
110 virtual void f(
const vnl_vector<double> &x, vnl_vector<double> &fx)
112 for (
unsigned int s=0; s < fx.size(); s++ )
114 const double factor = (
meas[s] -
M(x, s) );
118 MITK_DEBUG(
"Fit.x_and_f") << x <<
" | " << fx;
124 double Diff(
double x1,
double x2,
double b)
126 const double quotient = -1. * b * x1 + b*b * x1 * x1 * x2 / 6;
131 return exp(quotient);
135 virtual double M( vnl_vector<double>
const& x,
unsigned int idx )
137 const double bvalue =
bvalues[idx];
139 double result =
Diff( x[0], x[1], bvalue);
142 return meas[0] + result;
144 return meas[0] * result ;
157 for(
unsigned int i=0; i< 2; i++)
173 MITK_DEBUG(
"Fit.Orig.Penalty") << x <<
" || penalty: " << penalty;
204 virtual double M(
const vnl_vector<double> &x,
unsigned int idx)
override
206 const double bvalue =
bvalues[idx];
208 double result =
Diff( x[0], x[1], bvalue);
211 return log( x[2] ) + result;
213 return x[2] * result ;
245 template<
class TInputPixelType,
class TOutputPixelType >
247 public ImageToImageFilter< VectorImage< TInputPixelType, 3>, Image<TOutputPixelType, 3> >
283 typedef ImageToImageFilter< VectorImage< TInputPixelType, 3>,
287 itkFactorylessNewMacro(Self)
305 typedef
mitk::DiffusionPropertyHelper::GradientDirectionsContainerType
433 #ifndef ITK_MANUAL_INSTANTIATION
438 #endif // DIFFUSIONKURTOSISRECONSTRUCTIONIMAGEFILTER_H
TOutputPixelType OutputPixelType
A fitting function handling the unweighted signal b_0 as a fitted parameter.
itk::Image< itk::Vector< double, 3 >, 3 > InitialFitImageType
itk::SmartPointer< Self > Pointer
void SetMaximalBValueUsedForFitting(double max_bvalue)
DiffusionKurtosisReconstructionImageFilter()
void SetFittingScale(FitScale scale)
vnl_vector< double > meas
kurtosis_fit_omit_unweighted(unsigned int number_measurements)
Image< OutputPixelType, 3 > OutputImageType
void SetSmoothingSigma(double sigma)
bool m_ApplyPriorSmoothing
vnl_vector< double > measurements
DataCollection - Class to facilitate loading/accessing structured data.
virtual double M(vnl_vector< double > const &x, unsigned int idx)
vnl_vector_fixed< double, 2 > m_KurtosisBounds
void set_fit_logscale(bool flag)
void initialize(vnl_vector< double > const &_meas, vnl_vector< double > const &_bvals)
virtual double penalty_term(vnl_vector< double > const &x)
TInputPixelType InputPixelType
void SetReferenceBValue(double bvalue)
vnl_vector< double > kurtosis_lower_bounds
kurtosis_fit_lsq_function(unsigned int num_params, unsigned int num_measurements, UseGradient g=no_gradient)
vnl_vector< double > kurtosis_upper_bounds
vnl_vector< double > m_InitialPosition
itk::VectorImage< float, 3 > VectorImageType
void AfterThreadedGenerateData() override
vnl_vector< double > fit_bvalues
vnl_vector_fixed< double, 2 > K_limits
DiffusionKurtosisReconstructionImageFilter Self
mitk::DiffusionPropertyHelper::GradientDirectionsContainerType GradientDirectionContainerType
void GenerateOutputInformation() override
virtual void f(const vnl_vector< double > &x, vnl_vector< double > &fx)
Struct describing a result (and the data) of a Kurtosis model fit.
virtual ~DiffusionKurtosisReconstructionImageFilter()
double Diff(double x1, double x2, double b)
vnl_vector< double > m_BValues
SmartPointer< const Self > ConstPointer
void SetOmitUnweightedValue(bool flag)
ImageToImageFilter< VectorImage< TInputPixelType, 3 >, Image< TOutputPixelType, 3 > > Superclass
Superclass::InputImageType InputImageType
void SetBoundariesForKurtosis(double lower, double upper)
Superclass::OutputImageRegionType OutputImageRegionType
KurtosisSnapshot GetCurrentSnapshot(bool omit_bzero)
vnl_vector< double > fit_measurements
virtual double M(const vnl_vector< double > &x, unsigned int idx) override
KurtosisSnapshot GetSnapshot(const itk::VariableLengthVector< TInputPixelType > &input, vnl_vector< double > bvalues, KurtosisFitConfiguration kf_conf)
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, ThreadIdType threadId) override
FitScale m_ScaleForFitting
itk::Image< short, 3 > MaskImageType
vnl_vector< double > bvalues
void SetImageMask(MaskImageType::Pointer mask)
void SetUseSmoothingPriorToFitting(bool flag)
void set_K_bounds(const vnl_vector_fixed< double, 2 > k_bounds)
void SetGradientDirections(GradientDirectionContainerType::Pointer gradients)
void SetMapOutputRegion(OutputImageRegionType region)
MITKCORE_EXPORT const ScalarType eps
This filter provides the fit of the kurtosis (non-IVIM) signal to the data.
vnl_vector< double > bvalues
MaskImageType::Pointer m_MaskImage
InputImageType::Pointer m_ProcessedInputImage
SmartPointer< Self > Pointer
vnl_vector< unsigned int > weighted_image_indices
OutputImageRegionType m_MapOutputRegion
void SetInitialSolution(const vnl_vector< double > &x0)
kurtosis_fit_lsq_function(unsigned int number_measurements)
KurtosisFitConfiguration()
void BeforeThreadedGenerateData() override