Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
mitkFiberfoxParameters.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 
17 #ifndef _MITK_FiberfoxParameters_H
18 #define _MITK_FiberfoxParameters_H
19 
20 #include <itkImageRegion.h>
21 #include <itkMatrix.h>
24 #include <mitkDataNode.h>
25 #include <mitkRicianNoiseModel.h>
27 #include <mitkImage.h>
29 #include <mitkPlanarEllipse.h>
30 #include <mitkStickModel.h>
31 #include <mitkTensorModel.h>
32 #include <mitkAstroStickModel.h>
33 #include <mitkBallModel.h>
34 #include <mitkDotModel.h>
35 #include <mitkRawShModel.h>
36 #include <boost/property_tree/ptree.hpp>
37 #include <boost/property_tree/xml_parser.hpp>
38 #include <limits>
39 
40 using namespace std;
41 
42 namespace mitk
43 {
44 
47  {
48  public:
49  typedef itk::Image<double, 3> ItkDoubleImgType;
50  typedef itk::Image<unsigned char, 3> ItkUcharImgType;
51  typedef itk::Vector<double,3> GradientType;
52  typedef std::vector<GradientType> GradientListType;
53 
57  COIL_EXPONENTIAL
58  };
59 
60  enum AcquisitionType : int
61  {
63  SpinEcho
64  };
65 
67  : m_AcquisitionType(SignalGenerationParameters::SingleShotEpi)
68  , m_SignalScale(100)
69  , m_tEcho(100)
70  , m_tRep(4000)
71  , m_tLine(1)
72  , m_tInhom(50)
73  , m_ReversePhase(false)
74  , m_PartialFourier(1.0)
75  , m_NoiseVariance(0.001)
76  , m_NumberOfCoils(1)
77  , m_CoilSensitivityProfile(SignalGenerationParameters::COIL_CONSTANT)
78  , m_Bvalue(1000)
79  , m_SimulateKspaceAcquisition(false)
80  , m_AxonRadius(0)
81  , m_DoDisablePartialVolume(false)
82  , m_Spikes(0)
83  , m_SpikeAmplitude(1)
84  , m_KspaceLineOffset(0)
85  , m_EddyStrength(300)
86  , m_Tau(70)
87  , m_CroppingFactor(1)
88  , m_DoAddGibbsRinging(false)
89  , m_DoSimulateRelaxation(true)
90  , m_DoAddMotion(false)
91  , m_DoRandomizeMotion(true)
92  , m_FrequencyMap(NULL)
93  , m_MaskImage(NULL)
94  {
95  m_ImageRegion.SetSize(0, 12);
96  m_ImageRegion.SetSize(1, 12);
97  m_ImageRegion.SetSize(2, 3);
98  m_ImageSpacing.Fill(2.0);
99  m_ImageOrigin.Fill(0.0);
100  m_ImageDirection.SetIdentity();
101  m_Translation.Fill(0.0);
102  m_Rotation.Fill(0.0);
103  SetNumWeightedVolumes(6);
104  }
105 
107  itk::ImageRegion<3> m_CroppedRegion;
108  itk::ImageRegion<3> m_ImageRegion;
109  itk::Vector<double,3> m_ImageSpacing;
110  itk::Point<double,3> m_ImageOrigin;
111  itk::Matrix<double, 3, 3> m_ImageDirection;
112 
115  double m_SignalScale;
116  double m_tEcho;
117  double m_tRep;
118  double m_tLine;
119  double m_tInhom;
125  double m_Bvalue;
127  double m_AxonRadius;
129 
131  unsigned int m_Spikes;
134  double m_EddyStrength;
135  double m_Tau;
141  std::vector< bool > m_MotionVolumes;
142  itk::Vector<double,3> m_Translation;
144  itk::Vector<double,3> m_Rotation;
147 
148  inline void GenerateGradientHalfShell();
149  inline std::vector< int > GetBaselineIndices();
150  inline unsigned int GetFirstBaselineIndex();
151  inline bool IsBaselineIndex(unsigned int idx);
152  inline unsigned int GetNumWeightedVolumes();
153  inline unsigned int GetNumBaselineVolumes();
154  inline unsigned int GetNumVolumes();
155  inline GradientListType GetGradientDirections();
156  inline GradientType GetGradientDirection(unsigned int i);
157 
158  inline void SetNumWeightedVolumes(int numGradients);
159  inline void SetGradienDirections(GradientListType gradientList);
160  inline void SetGradienDirections(mitk::DiffusionPropertyHelper::GradientDirectionsContainerType::Pointer gradientList);
161 
162  protected:
163 
164  unsigned int m_NumGradients;
165  unsigned int m_NumBaseline;
166  GradientListType m_GradientDirections;
167  };
168 
171  {
172  public:
173 
175  {
176  DISTRIBUTE_UNIFORM, // distribute fibers uniformly in the ROIs
177  DISTRIBUTE_GAUSSIAN // distribute fibers using a 2D gaussian
178  };
179 
180  typedef vector< vector< mitk::PlanarEllipse::Pointer > > FiducialListType;
181  typedef vector< vector< unsigned int > > FlipListType;
182 
184  : m_Distribution(DISTRIBUTE_UNIFORM)
185  , m_Density(100)
186  , m_Variance(100)
187  , m_Sampling(1)
188  , m_Tension(0)
189  , m_Continuity(0)
190  , m_Bias(0)
191  {
192  m_Rotation.Fill(0.0);
193  m_Translation.Fill(0.0);
194  m_Scale.Fill(1.0);
195  }
196 
198  unsigned int m_Density;
199  double m_Variance;
200  double m_Sampling;
201  double m_Tension;
202  double m_Continuity;
203  double m_Bias;
207  FlipListType m_FlipList;
208  FiducialListType m_Fiducials;
209  };
210 
213  {
214  public:
216  : m_ResultNode(DataNode::New())
217  , m_ParentNode(NULL)
218  , m_SignalModelString("")
219  , m_ArtifactModelString("")
220  , m_OutputPath("/tmp/")
221  , m_OutputPrefix("fiberfox")
222  , m_CheckOutputVolumeFractionsBox(false)
223  , m_CheckAdvancedSignalOptionsBox(false)
224  , m_CheckAddNoiseBox(false)
225  , m_CheckAddGhostsBox(false)
226  , m_CheckAddAliasingBox(false)
227  , m_CheckAddSpikesBox(false)
228  , m_CheckAddEddyCurrentsBox(false)
229  , m_CheckAddDistortionsBox(false)
230  , m_MotionVolumesBox("random")
231  , m_CheckRealTimeFibersBox(true)
232  , m_CheckAdvancedFiberOptionsBox(false)
233  , m_CheckConstantRadiusBox(false)
234  , m_CheckIncludeFiducialsBox(true)
235  {}
236 
241  string m_OutputPath;
242  string m_OutputPrefix;
244 
246  // image generation
256  // fiber generation
261  };
262 
267  template< class ScalarType = double >
269  {
270  public:
271 
272  typedef itk::Image<double, 3> ItkDoubleImgType;
273  typedef itk::Image<unsigned char, 3> ItkUcharImgType;
275  typedef std::vector< DiffusionModelType* > DiffusionModelListType;
277 
280 
282  template< class OutType >
284  {
286 
287  out.m_FiberGen = m_FiberGen;
288  out.m_SignalGen = m_SignalGen;
289  out.m_Misc = m_Misc;
290 
291  if (m_NoiseModel!=NULL)
292  {
293  if (dynamic_cast<mitk::RicianNoiseModel<ScalarType>*>(m_NoiseModel.get()))
294  out.m_NoiseModel = std::make_shared< mitk::RicianNoiseModel<OutType> >();
295  else if (dynamic_cast<mitk::ChiSquareNoiseModel<ScalarType>*>(m_NoiseModel.get()))
296  out.m_NoiseModel = std::make_shared< mitk::ChiSquareNoiseModel<OutType> >();
297  out.m_NoiseModel->SetNoiseVariance(m_NoiseModel->GetNoiseVariance());
298  }
299 
300  for (unsigned int i=0; i<m_FiberModelList.size()+m_NonFiberModelList.size(); i++)
301  {
302  mitk::DiffusionSignalModel<OutType>* outModel = NULL;
303  mitk::DiffusionSignalModel<ScalarType>* signalModel = NULL;
304  if (i<m_FiberModelList.size())
305  signalModel = m_FiberModelList.at(i);
306  else
307  signalModel = m_NonFiberModelList.at(i-m_FiberModelList.size());
308 
309  if (dynamic_cast<mitk::StickModel<ScalarType>*>(signalModel))
310  outModel = new mitk::StickModel<OutType>(dynamic_cast<mitk::StickModel<ScalarType>*>(signalModel));
311  else if (dynamic_cast<mitk::TensorModel<ScalarType>*>(signalModel))
312  outModel = new mitk::TensorModel<OutType>(dynamic_cast<mitk::TensorModel<ScalarType>*>(signalModel));
313  else if (dynamic_cast<mitk::RawShModel<ScalarType>*>(signalModel))
314  outModel = new mitk::RawShModel<OutType>(dynamic_cast<mitk::RawShModel<ScalarType>*>(signalModel));
315  else if (dynamic_cast<mitk::BallModel<ScalarType>*>(signalModel))
316  outModel = new mitk::BallModel<OutType>(dynamic_cast<mitk::BallModel<ScalarType>*>(signalModel));
317  else if (dynamic_cast<mitk::AstroStickModel<ScalarType>*>(signalModel))
318  outModel = new mitk::AstroStickModel<OutType>(dynamic_cast<mitk::AstroStickModel<ScalarType>*>(signalModel));
319  else if (dynamic_cast<mitk::DotModel<ScalarType>*>(signalModel))
320  outModel = new mitk::DotModel<OutType>(dynamic_cast<mitk::DotModel<ScalarType>*>(signalModel));
321 
322  if (i<m_FiberModelList.size())
323  out.m_FiberModelList.push_back(outModel);
324  else
325  out.m_NonFiberModelList.push_back(outModel);
326  }
327 
328  return out;
329  }
330 
335 
337  DiffusionModelListType m_FiberModelList;
338  DiffusionModelListType m_NonFiberModelList;
339  std::shared_ptr< NoiseModelType > m_NoiseModel;
340 
341  void PrintSelf();
342  void SaveParameters(string filename);
343  void LoadParameters(string filename);
344  template< class ParameterType >
345  ParameterType ReadVal(boost::property_tree::ptree::value_type const& v, std::string tag, ParameterType defaultValue, bool essential=false);
346  std::string m_MissingTags;
347  };
348 }
349 
351 
352 #endif
353 
MiscFiberfoxParameters m_Misc
GUI realted and I/O parameters.
DataNode::Pointer m_ResultNode
Stores resulting image.
double m_Tau
Eddy current decay constant (in ms)
itk::ImageRegion< 3 > m_CroppedRegion
Image size with reduced FOV.
itk::SmartPointer< Self > Pointer
double m_NoiseVariance
Variance of complex gaussian noise.
itk::Image< double, 3 > ItkDoubleImgType
Generates diffusion measurement employing a second rank tensor model: e^(-bg^TDg) ...
itk::Point< double, 3 > m_ImageOrigin
Image origin.
DiffusionSignalModel< ScalarType > DiffusionModelType
itk::Matrix< double, 3, 3 > m_ImageDirection
Image rotation matrix.
DiffusionNoiseModel< ScalarType > NoiseModelType
DiffusionModelListType m_NonFiberModelList
Extra-axonal compartments.
unsigned int m_NumGradients
Number of diffusion-weighted image volumes.
double m_tLine
k-space line readout time (dwell time).
STL namespace.
DataCollection - Class to facilitate loading/accessing structured data.
int m_NumberOfCoils
Number of coils in multi-coil acquisition.
double m_Bvalue
Acquisition b-value.
Generates constant direction independent signal.
Definition: mitkDotModel.h:30
double m_PartialFourier
Partial fourier factor (0.5-1)
itk::Vector< double, 3 > GradientType
std::vector< GradientType > GradientListType
ItkUcharImgType::Pointer m_MaskImage
Signal is only genrated inside of the mask image.
Generates direction independent diffusion measurement employing a scalar diffusion constant d: e^(-bd...
Definition: mitkBallModel.h:30
bool m_ReversePhase
If true, the phase readout direction will be inverted (-y instead of y)
double m_EddyStrength
Strength of eddy current induced gradients in mT/m.
itk::Vector< double, 3 > m_ImageSpacing
Image voxel size.
double m_SignalScale
Scaling factor for output signal (before noise is added).
Abstract class for diffusion signal models.
SignalGenerationParameters m_SignalGen
Signal generation parameters.
The spherical harmonic representation of a prototype diffusion weighted MR signal is used to obtain t...
string m_AfterSimulationMessage
Store messages that are displayed after the simulation has finished (e.g. warnings, automatic parameter adjustments etc.)
unsigned int m_NumBaseline
Number of non-diffusion-weighted image volumes.
Datastructure to manage the Fiberfox signal generation parameters.
FiberGenerationParameters m_FiberGen
Fiber generation parameters.
bool m_DoAddMotion
Enable motion artifacts.
static const std::string filename
itk::Image< unsigned char, 3 > ItkUcharImgType
itk::ImageRegion< 3 > m_ImageRegion
Image size.
double m_AxonRadius
Determines compartment volume fractions (0 == automatic axon radius estimation)
GradientListType m_GradientDirections
Total number of image volumes.
DataNode::Pointer m_ParentNode
Parent node of result node.
Implementation of noise following a chi-squared distribution.
double m_SpikeAmplitude
amplitude of spikes relative to the largest signal intensity (magnitude of complex) ...
AcquisitionType m_AcquisitionType
determines k-space trajectory and maximum echo position(s)
itk::Image< unsigned char, 3 > ItkUcharImgType
FlipListType m_FlipList
contains flags indicating a flip of the 2D fiber x-coordinates (needed to resolve some unwanted fiber...
string m_SignalModelString
Appendet to the name of the result node.
Realizes EPI readout: one echo, maximum intensity in the k-space center, zig-zag trajectory.
bool m_DoSimulateRelaxation
Add T2 relaxation effects.
vector< vector< unsigned int > > FlipListType
itk::Vector< double, 3 > m_Rotation
Maximum rotational motion.
Generates the diffusion signal using an idealised cylinder with zero radius: e^(-bd(ng)²) ...
CoilSensitivityProfile m_CoilSensitivityProfile
Choose between constant, linear or exponential sensitivity profile of the used coils.
double m_CroppingFactor
FOV size in y-direction is multiplied by this factor. Causes aliasing artifacts.
vector< vector< mitk::PlanarEllipse::Pointer > > FiducialListType
bool m_DoAddGibbsRinging
Add Gibbs ringing artifact.
unsigned int m_Spikes
Number of spikes randomly appearing in the image.
bool m_DoDisablePartialVolume
Disable partial volume effects. Each voxel is either all fiber or all non-fiber.
string m_OutputPath
Image is automatically saved to the specified folder after simulation is finished.
itk::Image< double, 3 > ItkDoubleImgType
Implementation of noise following a rician distribution.
DiffusionModelListType m_FiberModelList
Intra- and inter-axonal compartments.
std::shared_ptr< NoiseModelType > m_NoiseModel
If != NULL, noise is added to the image.
Abstract class for diffusion noise models.
bool m_DoRandomizeMotion
Toggles between random and linear motion.
double m_KspaceLineOffset
Causes N/2 ghosts. Larger offset means stronger ghost.
Generates the diffusion signal using a collection of idealised cylinder with zero radius: e^(-bd(ng)²...
string m_ArtifactModelString
Appendet to the name of the result node.
FiberfoxParameters< OutType > CopyParameters()
FiducialListType m_Fiducials
container of the planar ellipses used as fiducials for the fiber generation process ...
bool m_SimulateKspaceAcquisition
Flag to enable/disable k-space acquisition simulation.
std::vector< DiffusionModelType * > DiffusionModelListType
ItkDoubleImgType::Pointer m_FrequencyMap
If != NULL, distortions are added to the image using this frequency map.
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66
std::vector< bool > m_MotionVolumes
with positive numbers, inverted logic with negative numbers.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.