00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __freMaskedROICoupleController_h
00023 #define __freMaskedROICoupleController_h
00024
00025 #include "freROICoupleController.h"
00026 #include "freROI.h"
00027
00028 #include "itkNearestNeighborInterpolateImageFunction.h"
00029 #include "itkWarpImageFilter.h"
00030
00031 namespace FREE
00032 {
00041 freControllerIDMacro(MaskedROICoupleControllerBase, "MaskedROICoupleBase");
00042 template<unsigned int VImageDimension>
00043 class MaskedROICoupleControllerBase : public ROICoupleControllerBase< ImageMaskedROICouple<VImageDimension> >
00044 {
00045 public:
00046 typedef ImageMaskedROICouple<VImageDimension> ComponentType;
00047 typedef ROICoupleControllerBase<ComponentType> Superclass;
00048
00049 itkTypeMacro(MaskedROICoupleControllerBase, ROICoupleControllerBase);
00050
00051 protected:
00054 MaskedROICoupleControllerBase()
00055 {
00056 this->UpdateControllerID(ControllerID::MaskedROICoupleControllerBase);
00057 this->m_Description = "A couple of masked ROIs (e.g. for registration, only abstrace, not for practical use";
00058 };
00059
00060 virtual void GenerateProfile(CtrlProfile::ControllerProfile& profile,
00061 const SessionComponentCache* pComponentCache,
00062 bool bRegardOldSetup) const
00063 {
00064 Superclass::GenerateProfile(profile, pComponentCache, bRegardOldSetup);
00065 profile.MediaMap().Reset();
00066
00067
00068 profile.Parameters().AddParameter(cParam_ROI_M_MaskFile,Parameter::PVTURI,cParamDsc_ROI_M_MaskFile,1,"",1,false,3);
00069 profile.Parameters().AddParameter(cParam_ROI_M_MaskFileFeedback,Parameter::PVTBool,cParamDsc_ROI_M_MaskFileFeedback,1,"false",1,false,4);
00070 profile.Parameters().AddParameter(cParam_ROI_F_MaskFile,Parameter::PVTURI,cParamDsc_ROI_F_MaskFile,1,"",1,false,3);
00071 profile.Parameters().AddParameter(cParam_ROI_F_MaskFileFeedback,Parameter::PVTBool,cParamDsc_ROI_F_MaskFileFeedback,1,"false",1,false,4);
00072 };
00073
00078 virtual void ActualizeMainComponent(ComponentType* pMainComponent,
00079 SessionComponentCache* pComponentCache,
00080 SessionInfo* pSessionInfo,
00081 const unsigned int& iActLevel) const
00082 {
00083 Superclass::ActualizeMainComponent(pMainComponent,pComponentCache,pSessionInfo,iActLevel);
00084
00085 bool bFeedback;
00086 std::string sMaskFile;
00087
00088 try
00089 {
00090 SessionAccessor::GetParameterValue(pComponentCache,cParam_ROI_M_MaskFile,sMaskFile);
00091 SessionAccessor::GetParameterValue(pComponentCache,cParam_ROI_M_MaskFileFeedback,bFeedback);
00092 }
00093 catchAllNPassMacro("Error while retrieving parameter values.");
00094
00095 if (!pMainComponent->Moving().GetMask())
00096 {
00097 if (sMaskFile!="") pMainComponent->Moving().SetMask(sMaskFile);
00098
00099 if (!pMainComponent->Moving().GetMask())
00100 {
00101 try
00102 {
00103 if (pMainComponent->Moving().GetMask()!=NULL)
00104 {
00105 typedef typename ImageTypes< VImageDimension >::MaskType MaskType;
00106 typedef typename ImageTypes< VImageDimension >::TransformationFieldType TransformationFieldType;
00107 typedef itk::WarpImageFilter< MaskType, MaskType, TransformationFieldType > WarpType;
00108 typedef itk::NearestNeighborInterpolateImageFunction< MaskType, ScalarType > InterpolatorType;
00109
00110 typename WarpType::Pointer warp = WarpType::New();
00111 typename InterpolatorType::Pointer interpolator = InterpolatorType::New();
00112
00113 warp->SetInput(pMainComponent->Moving().GetMask());
00114 warp->SetInterpolator(interpolator);
00115
00116
00117
00118
00119
00120 warp->SetOutputSpacing(pMainComponent->Moving().GetMask()->GetSpacing());
00121 warp->SetOutputOrigin(pMainComponent->Moving().GetMask()->GetOrigin());
00122 warp->SetEdgePaddingValue(0);
00123 warp->Update();
00124
00125 pMainComponent->Moving().SetMask(warp->GetOutput());
00126 };
00127 }
00128 catchAllNPassMacro("Error while actualizing moving mask by warp filter.");
00129 }
00130 }
00131 if (bFeedback) MakeCallback(ccfROIMoving,&(pMainComponent->Moving().GetMaskSmartPointer()),pComponentCache);
00132
00133 try
00134 {
00135 SessionAccessor::GetParameterValue(pComponentCache,cParam_ROI_F_MaskFile,sMaskFile);
00136 SessionAccessor::GetParameterValue(pComponentCache,cParam_ROI_F_MaskFileFeedback,bFeedback);
00137 }
00138 catchAllNPassMacro("Error while retrieving parameter values.");
00139
00140 if (!pMainComponent->Fixed().GetMask())
00141 {
00142 if (sMaskFile!="") pMainComponent->Fixed().SetMask(sMaskFile);
00143 }
00144 if (bFeedback) MakeCallback(ccfROIFixed,&(pMainComponent->Fixed().GetMaskSmartPointer()),pComponentCache);
00145 };
00146 };
00147
00156 freControllerIDMacro(MaskedROICouple2DController, "Masked ROI Couple 2D");
00157 class MaskedROICouple2DController : public MaskedROICoupleControllerBase< 2 >
00158 {
00159 public:
00160 itkTypeMacro(MaskedROICouple2DController, MaskedROICoupleControllerBase);
00161
00162 MaskedROICouple2DController();
00163 };
00164
00173 freControllerIDMacro(MaskedROICouple3DController, "Masked ROI Couple 3D");
00174 class MaskedROICouple3DController : public MaskedROICoupleControllerBase< 3 >
00175 {
00176 public:
00177 itkTypeMacro(MaskedROICouple3DController, MaskedROICoupleControllerBase);
00178
00179 MaskedROICouple3DController();
00180 };
00181
00182 }
00183
00184 #endif