Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
itkTractsToDWIImageFilter.h
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 #ifndef __itkTractsToDWIImageFilter_h__
17 #define __itkTractsToDWIImageFilter_h__
18 
19 #include <mitkFiberBundle.h>
20 #include <itkVnlForwardFFTImageFilter.h>
21 #include <itkVectorImage.h>
22 #include <cmath>
23 #include <mitkFiberfoxParameters.h>
24 #include <itkTimeProbe.h>
25 #include <mitkRawShModel.h>
27 #include <mitkPointSet.h>
28 
29 namespace itk
30 {
31 
37 template< class PixelType >
38 class TractsToDWIImageFilter : public ImageSource< itk::VectorImage< PixelType, 3 > >
39 {
40 
41 public:
42 
47 
49  typedef itk::Image<double, 4> ItkDoubleImgType4D;
50  typedef itk::Image<double, 3> ItkDoubleImgType;
51  typedef itk::Image<float, 3> ItkFloatImgType;
52  typedef itk::Image<unsigned char, 3> ItkUcharImgType;
54  typedef itk::VectorImage< double, 3 > DoubleDwiType;
55  typedef itk::Matrix<double, 3, 3> MatrixType;
56  typedef itk::Image< double, 2 > SliceType;
57  typedef itk::VnlForwardFFTImageFilter<SliceType>::OutputImageType ComplexSliceType;
58  typedef itk::VectorImage< vcl_complex< double >, 3 > ComplexDwiType;
59  typedef itk::Vector< double,3> DoubleVectorType;
60 
61  itkFactorylessNewMacro(Self)
62  itkCloneMacro(Self)
63  itkTypeMacro( TractsToDWIImageFilter, ImageSource )
64 
66  itkSetMacro( FiberBundle, FiberBundleType )
67  itkSetMacro( InputImage, typename OutputImageType::Pointer )
68  itkSetMacro( UseConstantRandSeed, bool )
69  void SetParameters( FiberfoxParameters<double> param )
70  { m_Parameters = param; }
71 
74  std::vector< ItkDoubleImgType::Pointer > GetVolumeFractions()
75  { return m_VolumeFractions; }
77  { return m_LevelWindow; }
78  itkGetMacro( StatusText, std::string )
79  itkGetMacro( PhaseImage, DoubleDwiType::Pointer )
80  itkGetMacro( KspaceImage, DoubleDwiType::Pointer )
81  itkGetMacro( CoilPointset, mitk::PointSet::Pointer )
82 
83  void GenerateData();
84 
85 protected:
86 
88  virtual ~TractsToDWIImageFilter();
89  itk::Point<float, 3> GetItkPoint(double point[3]);
90  itk::Vector<double, 3> GetItkVector(double point[3]);
91  vnl_vector_fixed<double, 3> GetVnlVector(double point[3]);
92  vnl_vector_fixed<double, 3> GetVnlVector(Vector< float, 3 >& vector);
93  double RoundToNearest(double num);
94  std::string GetTime();
95  bool PrepareLogFile();
96  void PrintToLog(string m, bool addTime=true, bool linebreak=true, bool stdOut=true);
97 
99  DoubleDwiType::Pointer SimulateKspaceAcquisition(std::vector< DoubleDwiType::Pointer >& images);
100 
102  void SimulateExtraAxonalSignal(ItkUcharImgType::IndexType index, double intraAxonalVolume, int g=-1);
103 
105  void SimulateMotion(int g=-1);
106 
108  ItkDoubleImgType::Pointer NormalizeInsideMask(ItkDoubleImgType::Pointer image);
109  void InitializeData();
110  void InitializeFiberData();
111  double InterpolateValue(itk::Point<float, 3> itkP, ItkDoubleImgType::Pointer img);
112 
113  // input
115  FiberBundleType m_FiberBundle;
116  typename OutputImageType::Pointer m_InputImage;
117 
118  // output
119  typename OutputImageType::Pointer m_OutputImage;
120  typename DoubleDwiType::Pointer m_PhaseImage;
121  typename DoubleDwiType::Pointer m_KspaceImage;
123  std::vector< ItkDoubleImgType::Pointer > m_VolumeFractions;
124  std::string m_StatusText;
125 
126  // MISC
127  itk::TimeProbe m_TimeProbe;
130  ofstream m_Logfile;
131  std::string m_MotionLog;
132  std::string m_SpikeLog;
133 
134  // signal generation
135  FiberBundleType m_FiberBundleWorkingCopy;
136  FiberBundleType m_FiberBundleTransformed;
139  ImageRegion<3> m_WorkingImageRegion;
141  std::vector< DoubleDwiType::Pointer > m_CompartmentImages;
142  ItkUcharImgType::Pointer m_TransformedMaskImage;
143  ItkUcharImgType::Pointer m_UpsampledMaskImage;
144  DoubleVectorType m_Rotation;
145  DoubleVectorType m_Translation;
146  std::vector< DoubleVectorType > m_Rotations;
147  std::vector< DoubleVectorType > m_Translations;
148  double m_mmRadius;
154 
155  itk::Statistics::MersenneTwisterRandomVariateGenerator::Pointer m_RandGen;
156 };
157 }
158 
159 #ifndef ITK_MANUAL_INSTANTIATION
161 #endif
162 
163 #endif
void PrintToLog(string m, bool addTime=true, bool linebreak=true, bool stdOut=true)
Superclass of all classes generating Images (instances of class Image) as output. ...
itk::Image< double, 4 > ItkDoubleImgType4D
itk::Image< float, 3 > ItkFloatImgType
void SimulateExtraAxonalSignal(ItkUcharImgType::IndexType index, double intraAxonalVolume, int g=-1)
OutputImageType::Pointer m_InputImage
Generates artificial diffusion weighted image volume from the input fiberbundle using a generic multi...
std::vector< DoubleDwiType::Pointer > m_CompartmentImages
ItkDoubleImgType::Pointer NormalizeInsideMask(ItkDoubleImgType::Pointer image)
ItkUcharImgType::Pointer m_UpsampledMaskImage
helper image for motion simulation
itk::VectorImage< double, 3 > DoubleDwiType
DoubleDwiType::Pointer SimulateKspaceAcquisition(std::vector< DoubleDwiType::Pointer > &images)
STL namespace.
DataCollection - Class to facilitate loading/accessing structured data.
mitk::FiberfoxParameters< double > m_Parameters
Superclass::OutputImageType OutputImageType
itk::Statistics::MersenneTwisterRandomVariateGenerator::Pointer m_RandGen
FiberBundleType m_FiberBundleTransformed
transformed bundle simulating headmotion
The LevelWindow class Class to store level/window values.
std::vector< ItkDoubleImgType::Pointer > m_VolumeFractions
itk::Vector< double, 3 > DoubleVectorType
Data structure which stores a set of points. Superclass of mitk::Mesh.
Definition: mitkPointSet.h:79
FiberBundleType m_FiberBundleWorkingCopy
we work on an upsampled version of the input bundle
Datastructure to manage the Fiberfox signal generation parameters.
itk::Matrix< double, 3, 3 > MatrixType
std::vector< DoubleVectorType > m_Rotations
stores the individual rotation of each volume (needed for k-space simulation to obtain correct freque...
itk::Point< double, 3 > m_WorkingOrigin
itk::Point< float, 3 > GetItkPoint(double point[3])
double InterpolateValue(itk::Point< float, 3 > itkP, ItkDoubleImgType::Pointer img)
Base Class for Fiber Bundles;.
mitk::Image OutputImageType
Some convenient typedefs.
OutputImageType::Pointer m_OutputImage
itk::VectorImage< vcl_complex< double >, 3 > ComplexDwiType
ItkUcharImgType::Pointer m_TransformedMaskImage
copy of mask image (changes for each motion step)
itk::Image< double, 3 > ItkDoubleImgType
ImageSource< itk::VectorImage< PixelType, 3 > > Superclass
mitk::PointSet::Pointer m_CoilPointset
itk::Image< unsigned char, 3 > ItkUcharImgType
std::vector< DoubleVectorType > m_Translations
stores the individual translation of each volume (needed for k-space simulation to obtain correct fre...
vnl_vector_fixed< double, 3 > GetVnlVector(double point[3])
itk::Vector< double, 3 > GetItkVector(double point[3])
std::vector< ItkDoubleImgType::Pointer > GetVolumeFractions()
itk::VnlForwardFFTImageFilter< SliceType >::OutputImageType ComplexSliceType
itk::Vector< double, 3 > m_WorkingSpacing
mitk::FiberBundle::Pointer FiberBundleType
section MAP_FRAME_Mapper_Settings Mapper settings For the mapping of corrected images
void SetParameters(FiberfoxParameters< double > param)
FiberfoxParameters< double > GetParameters()
SmartPointer< const Self > ConstPointer