freMaskedROICoupleController.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   F.R.E.E. - flexible registration evaluation engine
00004   Version:   v.1.0.0
00005   Date:      $Date: 2006/09/01 12:00:00 $
00006   Module:    $RCSfile: freMaskedROICoupleController.h,v $
00007   Language:  C++
00008 
00009 
00010 
00011   Copyright (c) 2007 Ralf o Floca (Department of Medical Informatics,
00012   Institute for Medical Biometry and Informatics, University of Heidelberg,
00013   Germany). All rights reserved.
00014   See FREECopyright.txt or http://www.mi.med.uni-hd.de/free/copyright.htm
00015   for details.
00016 
00017      This software is distributed WITHOUT ANY WARRANTY; without even 
00018      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00019      PURPOSE.  See the above copyright notices for more information.
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     //Parameter info
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                 { //There is no mask loaded yet so try to
00097                         if (sMaskFile!="") pMainComponent->Moving().SetMask(sMaskFile);
00098 
00099                         if (!pMainComponent->Moving().GetMask())
00100                         { //Warp moving mask by interim Transformation
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             //TODO Wenn es den Transformierer gibt, dann muss diese ganze Maskenanpassung raus aus dem
00116             //ActualizeComponent und rein in die ActualizeMedia methode, jetzt erst einmal nur auskommentiert,
00117             //damit man real free kompilieren kann
00118             //                                          warp->SetDeformationField(((RegistrationProcessorBase<VImageDimension>*)pSessionInfo->GetRegistrationProcessor())->GetFinalTransformationField());
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                 { //There is no mask loaded yet so try to
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 } //end of namespace free
00183 
00184 #endif

Generated at Sat Oct 13 16:25:09 2007 for f.r.e.e. - Flexible Registration and Evaluation Engine by doxygen 1.5.3 written by Dimitri van Heesch, © 1997-2000