28 #include <itkImageFileWriter.h>
30 #include <itkComposeImageFilter.h>
40 typedef itk::Image<mitk::DiffusionPropertyHelper::DiffusionPixelType, 3> ImageVolumeType;
41 typedef itk::ComposeImageFilter< ImageVolumeType > ComposeFilterType;
45 t_selector->SetInput( input );
47 for(
unsigned int i=0; i< input->GetTimeSteps(); i++)
49 t_selector->SetTimeNr(i);
55 vec_composer->SetInput( i, singleImageItk );
60 vec_composer->Update();
62 catch(
const itk::ExceptionObject& e)
64 MITK_ERROR <<
"Caught exception while updating compose filter: " << e.what();
68 vector_image->GetPixelContainer()->ContainerManageMemoryOff();
74 : m_ReferenceImage( nullptr )
78 this->SetNumberOfRequiredInputs(1);
79 this->SetNumberOfRequiredOutputs(1);
89 if( reference_image.IsNull() )
91 mitkThrow() <<
"Null-pointer image provided as reference. ";
96 mitkThrow() <<
"The image provided as reference is not a diffusion-weighted image. Cannot proceed. ";
99 this->m_ReferenceImage = reference_image;
105 if( input_image.IsNull() )
107 mitkThrow() <<
"No input specified. Cannot proceed ";
110 if( !( m_HeaderDescriptorSet ^ m_ReferenceImage.IsNotNull() ) )
112 mitkThrow() <<
"Either a header descriptor or a reference diffusion-weighted image have to be provided. Terminating.";
117 if( input_image->GetTimeSteps() > 1 )
119 mitk::Image::Pointer mitkvectorimage = mitk::GrabItkImageMemory<DPH::ImageType>( RemapIntoVectorImage( input_image ));
120 outputForCache->Initialize( mitkvectorimage );
125 outputForCache->Initialize( input_image );
131 float BValue = this->InternalGetBValue();
140 outputForCache->Modified();
145 this->m_HeaderDescriptor = header_descriptor;
146 this->m_HeaderDescriptorSet =
true;
154 if( m_ReferenceImage.IsNotNull() )
158 else if ( m_HeaderDescriptorSet )
160 MeasurementFrame = m_HeaderDescriptor.m_MeasurementFrame;
164 MeasurementFrame(0,0) = 1;
165 MeasurementFrame(0,1) = 0;
166 MeasurementFrame(0,2) = 0;
167 MeasurementFrame(1,0) = 0;
168 MeasurementFrame(1,1) = 1;
169 MeasurementFrame(1,2) = 0;
170 MeasurementFrame(2,0) = 0;
171 MeasurementFrame(2,1) = 0;
172 MeasurementFrame(2,2) = 1;
174 MITK_WARN <<
"Created default measurement frame as non provided ( no reference image or header information provided)";
177 return MeasurementFrame;
185 if( this->m_ReferenceImage )
189 else if ( m_HeaderDescriptorSet )
191 DiffusionVectors = m_HeaderDescriptor.m_GradientDirections;
194 return DiffusionVectors;
202 if( m_ReferenceImage.IsNotNull() )
206 else if ( m_HeaderDescriptorSet )
208 bvalue = m_HeaderDescriptor.m_BValue;
212 MITK_ERROR <<
"No reference image and no header descriptor provided.";
bool IsDiffusionWeightedImage() const
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...
void SetHeaderDescriptor(DiffusionImageHeaderDescriptor header_descriptor)
SetHeaderDescriptor set the information to be used with the dw image.
DiffusionImageCreationFilter()
float InternalGetBValue()
static BValueMap CreateBValueMap(const GradientDirectionsContainerType *gdc, float referenceBValue)
VectorImageType::Pointer RemapIntoVectorImage(mitk::Image::Pointer input)
RemapIntoVectorImage Take a 3d+t image and reinterpret it as vector image.
virtual void GenerateData() override
A version of GenerateData() specific for image processing filters.
static const std::string MEASUREMENTFRAMEPROPERTYNAME
bool m_HeaderDescriptorSet
MeasurementFrameType InternalGetMeasurementFrame()
void SetReferenceImage(mitk::Image::Pointer reference_image)
SetReferenceImage Set a diffusion image as reference, i.e. the header information will be extracted f...
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
~DiffusionImageCreationFilter()
static const std::string GRADIENTCONTAINERPROPERTYNAME
GradientDirectionContainerType::Pointer InternalGetGradientDirections()
static const std::string BVALUEMAPPROPERTYNAME
mitk::DiffusionPropertyHelper::MeasurementFrameType MeasurementFrameType
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.