16 #ifndef __itkDiffusionIntravoxelIncoherentMotionReconstructionImageFilter_h
17 #define __itkDiffusionIntravoxelIncoherentMotionReconstructionImageFilter_h
19 #include "itkImageToImageFilter.h"
21 #include "vnl/vnl_vector_fixed.h"
22 #include "vnl/vnl_matrix.h"
23 #include "vnl/algo/vnl_svd.h"
24 #include "itkVectorContainer.h"
25 #include "itkVectorImage.h"
27 #include "itkVectorImage.h"
29 #include "vnl/vnl_least_squares_function.h"
30 #include "vnl/algo/vnl_levenberg_marquardt.h"
31 #include "vnl/vnl_math.h"
33 #define IVIM_CEIL(val,u,o) (val) = \
34 ( (val) < (u) ) ? ( (u) ) : ( ( (val)>(o) ) ? ( (o) ) : ( (val) ) );
51 bvalues.copy_in(x.data_block());
66 vnl_least_squares_function(3, number_of_measurements, no_gradient)
68 N = get_number_of_residuals();
71 void f(
const vnl_vector<double>& x, vnl_vector<double>& fx)
override {
77 for(
int s=0; s<
N; s++)
79 double approx = (1-ef)*exp(-
bvalues[s]*D)+ef*exp(-
bvalues[s]*(D+Dstar));
91 vnl_least_squares_function(2, number_of_measurements, no_gradient)
93 N = get_number_of_residuals();
97 void f(
const vnl_vector<double>& x, vnl_vector<double>& fx)
override {
102 for(
int s=0; s<
N; s++)
119 vnl_least_squares_function(2, number_of_measurements, no_gradient)
121 N = get_number_of_residuals();
124 void f(
const vnl_vector<double>& x, vnl_vector<double>& fx)
override {
129 for(
int s=0; s<
N; s++)
131 double approx = (1-
f) * exp(-
bvalues[s]*D);
142 IVIM_fixd(
unsigned int number_of_measurements,
double D) :
143 vnl_least_squares_function(2, number_of_measurements, no_gradient)
145 N = get_number_of_residuals();
149 void f(
const vnl_vector<double>& x, vnl_vector<double>& fx)
override {
154 for(
int s=0; s<
N; s++)
170 vnl_least_squares_function(1, number_of_measurements, no_gradient)
172 N = get_number_of_residuals();
177 void f(
const vnl_vector<double>& x, vnl_vector<double>& fx)
override {
181 for(
int s=0; s<
N; s++)
201 template<
class TInputPixelType,
202 class TOutputPixelType>
204 public ImageToImageFilter< VectorImage< TInputPixelType, 3 >,
205 Image< TOutputPixelType, 3 > >
252 typedef ImageToImageFilter< VectorImage< TInputPixelType, 3>,
256 itkFactorylessNewMacro(Self)
280 typedef VectorContainer<
unsigned int,
303 void SetCrossPosition(
typename InputImageType::IndexType crosspos){this->m_CrossPosition = crosspos;}
311 if( idx >= m_NumberOfGradientDirections )
313 itkExceptionMacro( <<
"Gradient direction " << idx <<
"does not exist" );
315 return m_GradientDirectionContainer->ElementAt( idx+1 );
321 void PrintSelf(std::ostream& os, Indent indent)
const;
332 double myround(
double number);
338 unsigned int m_NumberOfGradientDirections;
364 int m_NumberIterations;
366 vnl_vector<double> m_tmp_allmeas;
370 typename InputImageType::IndexType m_CrossPosition;
376 #ifndef ITK_MANUAL_INSTANTIATION
380 #endif //__itkDiffusionIntravoxelIncoherentMotionReconstructionImageFilter_h
VectorContainer< unsigned int, GradientDirectionType > GradientDirectionContainerType
void f(const vnl_vector< double > &x, vnl_vector< double > &fx) override
void SetLambda(double lambda)
std::vector< unsigned int > baselineind
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, ThreadIdType)
void SetBValue(double bval)
itk::SmartPointer< Self > Pointer
TInputPixelType InputPixelType
vnl_vector< double > bvals2
void set_bvalues(const vnl_vector< double > &x)
void SetCrossPosition(typename InputImageType::IndexType crosspos)
vnl_vector< double > meas
MeasAndBvals ApplyS0Threshold(vnl_vector< double > &meas, vnl_vector< double > &bvals)
std::vector< double > bvals
ImageToImageFilter< VectorImage< TInputPixelType, 3 >, Image< TOutputPixelType, 3 > > Superclass
void PrintSelf(std::ostream &os, Indent indent) const
void SetFitDStar(bool fit)
std::vector< int > high_indices
vnl_vector< double > measurements
void SetGradientDirections(GradientDirectionContainerType *)
void SetBThres(double bval)
Superclass::OutputImageRegionType OutputImageRegionType
vnl_vector< double > bvalues
vnl_vector< double > bvalues
vnl_vector< double > high_bvalues
void f(const vnl_vector< double > &x, vnl_vector< double > &fx) override
DiffusionIntravoxelIncoherentMotionReconstructionImageFilter Self
~DiffusionIntravoxelIncoherentMotionReconstructionImageFilter()
void SetDStar(double dstar)
SmartPointer< Self > Pointer
itk::VectorImage< float, 3 > VectorImageType
void SetNumberIterations(int num)
IVIM_dstar_only(unsigned int number_of_measurements, double D, double f)
void AfterThreadedGenerateData()
IVIM_fixd(unsigned int number_of_measurements, double D)
void f(const vnl_vector< double > &x, vnl_vector< double > &fx) override
TOutputPixelType OutputPixelType
void BeforeThreadedGenerateData()
IVIM_d_and_f(unsigned int number_of_measurements)
vnl_vector< double > meas1
IVIM_fixdstar(unsigned int number_of_measurements, double DStar)
IVIM_3param(unsigned int number_of_measurements)
vnl_vector< double > meas2
SmartPointer< const Self > ConstPointer
void f(const vnl_vector< double > &x, vnl_vector< double > &fx) override
vnl_vector_fixed< double, 3 > GradientDirectionType
itk::Image< itk::Vector< double, 3 >, 3 > InitialFitImageType
vnl_vector< double > allmeas
void SetS0Thres(double val)
void f(const vnl_vector< double > &x, vnl_vector< double > &fx) override
vnl_vector< double > high_meas
IVIMSnapshot GetSnapshot()
void SetMethod(IVIM_Method method)
vnl_vector< double > bvals
Image< OutputPixelType, 3 > OutputImageType
void SetVerbose(bool verbose)
vnl_vector< double > bvals1
DiffusionIntravoxelIncoherentMotionReconstructionImageFilter()
void set_measurements(const vnl_vector< double > &x)
virtual GradientDirectionType GetGradientDirection(unsigned int idx) const
Superclass::InputImageType InputImageType
vnl_vector< double > meas
std::vector< unsigned int > gradientind