Skip to content
Browse files

Getting f3d object to store and make available completed iterations

  • Loading branch information...
1 parent 2010c62 commit ad5a8fb1bef20cf1115c0f108b75450c5f7d4965 @jonclayden committed Nov 23, 2011
Showing with 35 additions and 0 deletions.
  1. +25 −0 src/_reg_f3d.cpp
  2. +8 −0 src/_reg_f3d.h
  3. +2 −0 src/niftyreg.cpp
View
25 src/_reg_f3d.cpp
@@ -90,6 +90,10 @@ reg_f3d<T>::reg_f3d(int refTimePoint,int floTimePoint)
this->logJointHistogram=NULL;
this->interpolation=1;
+
+#ifdef RNIFTYREG
+ this->completedIterations=NULL;
+#endif
#ifndef NDEBUG
printf("[NiftyReg DEBUG] reg_f3d constructor called\n");
@@ -178,6 +182,12 @@ reg_f3d<T>::~reg_f3d()
if(this->floatingBinNumber!=NULL){delete []this->floatingBinNumber;this->floatingBinNumber=NULL;}
if(this->floatingBinNumber!=NULL){delete []this->activeVoxelNumber;this->activeVoxelNumber=NULL;}
if(this->maxSSD!=NULL){delete []this->maxSSD;this->maxSSD=NULL;}
+
+#ifdef RNIFTYREG
+ if (this->completedIterations != NULL)
+ free(completedIterations);
+#endif
+
#ifndef NDEBUG
printf("[NiftyReg DEBUG] reg_f3d destructor called\n");
#endif
@@ -1764,6 +1774,10 @@ int reg_f3d<T>::Run_f3d()
if( this->Initisalise_f3d() )
return 1;
}
+
+#ifdef RNIFTYREG
+ this->completedIterations = (int *) calloc(levelToPerform, sizeof(int));
+#endif
for(unsigned int level=0; level<this->levelToPerform; level++){
@@ -2044,6 +2058,9 @@ int reg_f3d<T>::Run_f3d()
}
#endif
+#ifdef RNIFTYREG
+ this->completedIterations[level] = this->currentIteration;
+#endif
} // level this->levelToPerform
#ifndef NDEBUG
@@ -2105,4 +2122,12 @@ int reg_f3d<T>::CheckStoppingCriteria(bool convergence)
/* \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ */
/* \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ */
+#ifdef RNIFTYREG
+template<class T>
+int * reg_f3d<T>::GetCompletedIterations()
+{
+ return this->completedIterations;
+}
+#endif
+
#endif
View
8 src/_reg_f3d.h
@@ -88,6 +88,10 @@ class reg_f3d
unsigned int currentIteration;
+#ifdef RNIFTYREG
+ int *completedIterations;
+#endif
+
virtual int AllocateWarped();
virtual int ClearWarped();
virtual int AllocateDeformationField();
@@ -177,6 +181,10 @@ class reg_f3d
virtual int CheckMemoryMB_f3d(){return 0;}
virtual nifti_image *GetWarpedImage();
nifti_image *GetControlPointPositionImage();
+
+#ifdef RNIFTYREG
+ int * GetCompletedIterations();
+#endif
};
#include "_reg_f3d.cpp"
View
2 src/niftyreg.cpp
@@ -621,6 +621,8 @@ f3d_result do_reg_f3d (nifti_image *sourceImage, nifti_image *targetImage, int f
// Run the registration
reg->Run_f3d();
+
+ memcpy(completedIterations, reg->GetCompletedIterations(), nLevels*sizeof(int));
f3d_result result;
result.image = reg->GetWarpedImage();

0 comments on commit ad5a8fb

Please sign in to comment.
Something went wrong with that request. Please try again.