17 #include "itkCommand.h"
31 imageTimeSelector->SetInput(image);
32 imageTimeSelector->SetTimeNr(timePoint);
33 imageTimeSelector->UpdateLargestPossibleRegion();
47 this->m_Registered4DImage = this->m_4DImage->Clone();
51 if (m_TargetMask.IsNotNull())
53 if (m_TargetMask->GetTimeSteps() > 1)
55 mask = GetFrameImage(m_TargetMask, 0);
63 double progressDelta = 1.0 / ((this->m_4DImage->GetTimeSteps() - 1) * 3.0);
67 for (
unsigned int i = 1; i < this->m_4DImage->GetTimeSteps(); ++i)
72 IgnoreListType::iterator finding = std::find(m_IgnoreList.begin(), m_IgnoreList.end(), i);
75 if (finding == m_IgnoreList.end())
80 m_Progress += progressDelta;
81 this->InvokeEvent(::mitk::FrameRegistrationEvent(0,
82 "Registred frame #" +::map::core::convert::toStr(i)));
84 mappedFrame = DoFrameMapping(movingFrame, reg, targetFrame);
86 m_Progress += progressDelta;
87 this->InvokeEvent(::mitk::FrameMappingEvent(0,
88 "Mapped frame #" + ::map::core::convert::toStr(i)));
94 this->m_Registered4DImage->SetVolume(accessor.GetData(), i);
95 this->m_Registered4DImage->GetTimeGeometry()->SetTimeStepGeometry(mappedFrame->GetGeometry(), i);
97 m_Progress += progressDelta;
101 m_Progress += 3 * progressDelta;
104 this->InvokeEvent(::itk::ProgressEvent());
113 if (this->HasOutdatedResult())
118 return m_Registered4DImage;
132 m_IgnoreList.clear();
143 algHelper.
SetData(movingFrame, targetFrame);
148 maskHelper.
SetMasks(NULL, targetMask);
158 targetFrame->
GetGeometry(), !m_AllowUnregPixels, m_ErrorValue, m_InterpolatorType);
164 if (m_Registered4DImage.IsNull())
171 if (m_Registered4DImage->GetMTime() > this->GetMTime())
177 if (m_Algorithm.IsNotNull())
179 if (m_Algorithm->GetMTime() > this->GetMTime())
185 if (m_4DImage.IsNotNull())
187 if (m_4DImage->GetMTime() > this->GetMTime())
193 if (m_TargetMask.IsNotNull())
195 if (m_TargetMask->GetMTime() > this->GetMTime())
207 if (m_4DImage.IsNull())
209 mitkThrow() <<
"Cannot register image. Input 4D image is not set.";
212 if (m_Algorithm.IsNull())
214 mitkThrow() <<
"Cannot register image. Algorithm is not set.";
217 if (m_4DImage->GetTimeSteps() <= 1)
219 mitkThrow() <<
"Cannot register image. Input 4D image must have 2 or more time steps.";
222 for (IgnoreListType::const_iterator pos = this->m_IgnoreList.begin();
223 pos != this->m_IgnoreList.end(); ++pos)
225 if (*pos < 0 || *pos >= m_4DImage->GetTimeSteps())
228 "Cannot register image. Ignore list containes at least one inexistant frame. Invalid frame index: "
void SetAllowImageCasting(bool allowCasting)
map::core::RegistrationBase::Pointer GetRegistration() const
mitk::Image::Pointer GetFrameImage(const mitk::Image *image, mitk::TimePointType timePoint) const
void CheckValidInputs() const
mitk::Image::Pointer DoFrameMapping(const mitk::Image *movingFrame, const RegistrationType *reg, const mitk::Image *targetFrame) const
virtual double GetProgress() const
void SetData(const mitk::BaseData *moving, const mitk::BaseData *target)
RegistrationType::Pointer RegistrationPointer
Image class for storing images.
mitk::ScalarType TimePointType
::map::core::RegistrationBase RegistrationType
bool SetMasks(const mitk::Image *movingMask, const mitk::Image *targetMask)
void SetIgnoreList(const IgnoreListType &il)
MaskedAlgorithmHelper Helper class as an easy bridge to set mitk images as masks for registration alg...
MITKMATCHPOINTREGISTRATION_EXPORT ResultImageType::Pointer map(const InputImageType *input, const RegistrationType *registration, bool throwOnOutOfInputAreaError=false, const double &paddingValue=0, const ResultImageGeometryType *resultGeometry=NULL, bool throwOnMappingError=true, const double &errorValue=0, mitk::ImageMappingInterpolator::Type interpolatorType=mitk::ImageMappingInterpolator::Linear)
ImageReadAccessor class to get locked read access for a particular image part.
mitk::BaseGeometry * GetGeometry(int t=0) const
Return the geometry, which is a TimeGeometry, of the data as non-const pointer.
std::vector< mitk::TimeStepType > IgnoreListType
bool HasOutdatedResult() const
RegistrationPointer DoFrameRegistration(const mitk::Image *movingFrame, const mitk::Image *targetFrame, const mitk::Image *targetMask) const
Image::Pointer GetRegisteredImage()