17 #ifndef DIFFUSIONIMAGETRANSFORMEDCREATIONFILTER_CXX
18 #define DIFFUSIONIMAGETRANSFORMEDCREATIONFILTER_CXX
30 #include <itkResampleImageFilter.h>
31 #include <itkNearestNeighborInterpolateImageFunction.h>
32 #include <itkWindowedSincInterpolateImageFunction.h>
33 #include <itkBSplineInterpolateImageFunction.h>
34 #include <itkLinearInterpolateImageFunction.h>
37 template <
typename TTransformType,
typename ItkImageType>
41 unsigned int interpolator,
46 typedef itk::LinearInterpolateImageFunction< ItkImageType, double > InterpolatorType;
49 typedef itk::NearestNeighborInterpolateImageFunction< ItkImageType, double > NearestNeighborInterpolatorType;
52 typedef itk::WindowedSincInterpolateImageFunction< ItkImageType, 7> WindowedSincInterpolatorType;
55 typedef itk::BSplineInterpolateImageFunction< ItkImageType, double, double> BSplineInterpolatorType;
57 bicubic_interpolator->SetSplineOrder(3);
59 typedef typename itk::ResampleImageFilter< ItkImageType, ItkImageType, double> ResampleImageFilterType;
63 typedef itk::InterpolateImageFunction< ItkImageType, double> InterpolateFunctionBaseType;
64 std::vector< InterpolateFunctionBaseType* > InterpolateFunctionsPool;
66 InterpolateFunctionsPool.push_back( nn_interpolator.GetPointer() );
67 InterpolateFunctionsPool.push_back( linear_interpolator.GetPointer() );
68 InterpolateFunctionsPool.push_back( bicubic_interpolator.GetPointer() );
69 InterpolateFunctionsPool.push_back( sinc_interpolator.GetPointer() );
72 resampler->SetInterpolator( InterpolateFunctionsPool.at( interpolator ) );
75 mitk::CastToItkImage< ItkImageType >( mitk_input, itk_input );
77 resampler->SetInput( itk_input );
78 resampler->SetTransform( transform );
79 resampler->SetReferenceImage( itk_reference );
80 resampler->UseReferenceImageOn();
84 current_resampled->InitializeByItk( resampler->GetOutput() );
85 current_resampled->SetImportChannel( resampler->GetOutput()->GetBufferPointer(),
89 output_target->SetImportVolume( imac.
GetData(),
107 template<
typename TTransformType>
111 this->m_OutputPrefix =
"/tmp/";
114 template<
typename TTransformType>
121 template<
typename TTransformType>
138 template<
typename TTransformType>
146 template<
typename TTransformType>
154 if( m_InternalTransforms.size() != input->GetTimeSteps() )
156 mitkThrow() <<
"Number of transforms" << m_InternalTransforms.size() <<
"differ from number of timesteps" << input->GetTimeSteps();
159 typedef itk::Image< DiffusionPropertyHelper::DiffusionPixelType, 3>
ImageType;
163 resampled_output->Initialize( input );
166 CastToItkImage( this->m_ResamplingReferenceImage, current_itk_reference );
168 unsigned int time_dim = input->GetDimension(3);
169 for(
unsigned int time_idx = 0; time_idx < time_dim; time_idx++ )
173 t_sel->SetInput( input );
174 t_sel->SetTimeNr( time_idx );
176 ResampleImage< TTransformType, ImageType>( current_itk_reference,
178 this->m_InternalTransforms.at(time_idx),
179 this->m_InterpolationLevel,
180 resampled_output, time_idx);
187 creator->SetInput( resampled_output );
188 creator->SetHeaderDescriptor( this->GetTransformedHeaderInformation() );
204 corrector->SetImage( output) ;
205 corrector->CorrectDirections( this->m_RotationMatrices );
207 DPH pHelper( output );
210 m_OutputCache = output;
211 this->SetPrimaryOutput( m_OutputCache );
212 m_OutputCache->Modified();
215 template<
typename TTransformType>
227 auto iter = std::begin( params );
228 while( iter != std::end( params ) )
231 transform->SetParameters( (*iter) );
233 transforms.push_back( transform );
238 this->SetTransforms( transforms );
241 template<
typename TTransformType>
245 if( transforms.empty() )
251 this->m_InternalTransforms.reserve( transforms.size() );
252 std::copy( transforms.begin(), transforms.end(),
253 std::back_inserter(this->m_InternalTransforms ) );
258 for(
auto iter = std::begin(this->m_InternalTransforms); iter != std::end( this->m_InternalTransforms); ++iter)
260 MatrixType A = E * (*iter)->GetMatrix().GetVnlMatrix();
261 this->m_RotationMatrices.push_back( A );
267 #endif // DIFFUSIONIMAGETRANSFORMEDCREATIONFILTER_CXX
const MeasurementFrameType & GetMeasurementFrame() const
static const std::string REFERENCEBVALUEPROPERTYNAME
itk::SmartPointer< Self > Pointer
std::map< unsigned int, std::vector< unsigned int > > BValueMap
The BValueMap contains seperated IndicesVectors for each b value (index for GradientDirectionContaine...
itk::Image< unsigned char, 3 > ImageType
static BValueMap CreateBValueMap(const GradientDirectionsContainerType *gdc, float referenceBValue)
static Pointer New()
Method for creation through the object factory.
Helper class for mitk::Images containing diffusion weighted data.
void * GetData()
Gives full data access.
static const std::string MEASUREMENTFRAMEPROPERTYNAME
const BValueMapType & GetBValueMap() const
void InitializeImage()
Make certain the owned image is up to date with all necessary properties.
mitk::DiffusionPropertyHelper DPH
float GetReferenceBValue() const
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.
GradientDirectionsContainerType::Pointer GetGradientContainer() const
ImageWriteAccessor class to get locked write-access for a particular image part.
static const std::string GRADIENTCONTAINERPROPERTYNAME
static const std::string BVALUEMAPPROPERTYNAME
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.