Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
itkRegularizedIVIMReconstructionFilter.txx
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 _itkRegularizedIVIMReconstructionFilter_txx
17 #define _itkRegularizedIVIMReconstructionFilter_txx
18 
19 #include "itkConstShapedNeighborhoodIterator.h"
20 #include "itkNeighborhoodInnerProduct.h"
21 #include "itkImageRegionIterator.h"
22 #include "itkImageRegionConstIterator.h"
23 #include "itkNeighborhoodAlgorithm.h"
24 #include "itkZeroFluxNeumannBoundaryCondition.h"
25 #include "itkOffset.h"
26 #include "itkProgressReporter.h"
27 
28 #include <vector>
29 #include <algorithm>
30 
31 namespace itk
32 {
33 
34  template <class TInputPixel, class TOutputPixel, class TRefPixelType>
35  RegularizedIVIMReconstructionFilter<TInputPixel, TOutputPixel, TRefPixelType>
36  ::RegularizedIVIMReconstructionFilter()
37  {
38  m_Lambda = 1.0;
39  }
40 
41 
42  template <class TInputPixel, class TOutputPixel, class TRefPixelType>
43  void
44  RegularizedIVIMReconstructionFilter<TInputPixel, TOutputPixel, TRefPixelType>
45  ::GenerateData()
46  {
47  // first we cast the input image to match output type
48  typename CastType::Pointer infilter = CastType::New();
49  infilter->SetInput(this->GetInput());
50  infilter->Update();
51  typename OutputImageType::Pointer image = infilter->GetOutput();
52 
53  typename SingleIterationFilterType::Pointer filter;
54  for(int i=0; i<m_NumberIterations; i++)
55  {
56  filter = SingleIterationFilterType::New();
57  filter->SetInput( image.GetPointer() );
58  filter->SetOriginalImage( m_ReferenceImage );
59  filter->SetBValues(m_BValues);
60  filter->SetLambda(m_Lambda);
61  filter->SetNumberOfThreads(this->GetNumberOfThreads());
62  filter->UpdateLargestPossibleRegion();
63  image = filter->GetOutput();
64  std::cout << "Iteration " << i+1 << "/" <<
65  m_NumberIterations << std::endl;
66  }
67 
68  typename OutputImageType::Pointer output = this->GetOutput();
69  output->SetOrigin( image->GetOrigin() ); // Set the image origin
70  output->SetDirection( image->GetDirection() ); // Set the image direction
71  output->SetSpacing(image->GetSpacing());
72  output->SetLargestPossibleRegion( image->GetLargestPossibleRegion() );
73  output->SetBufferedRegion( image->GetLargestPossibleRegion() );
74  output->Allocate();
75 
76  itk::ImageRegionIterator<OutputImageType> oit(
77  output, output->GetLargestPossibleRegion());
78  oit.GoToBegin();
79 
80  itk::ImageRegionConstIterator<OutputImageType> iit(
81  image, image->GetLargestPossibleRegion());
82  iit.GoToBegin();
83 
84  while(!oit.IsAtEnd())
85  {
86  oit.Set(iit.Get());
87  ++iit;
88  ++oit;
89  }
90  }
91 
92 
93  /**
94  * Standard "PrintSelf" method
95  */
96  template <class TInputPixel, class TOutputPixel, class TRefPixelType>
97  void
98  RegularizedIVIMReconstructionFilter<TInputPixel, TOutputPixel, TRefPixelType>
99  ::PrintSelf(
100  std::ostream& os,
101  Indent indent) const
102  {
103  Superclass::PrintSelf( os, indent );
104  }
105 
106 } // end namespace itk
107 
108 #endif