Commit 87a89bc3 authored by Marc Modat's avatar Marc Modat

corrected an error in reg_measure when using NMI. The warped image was not properly scaled

parent 26bc966d
......@@ -115,6 +115,7 @@ void Usage(char *exec)
printf("\n*** Measure of similarity options:\n");
printf("*** NMI with 64 bins is used expect if specified otherwise\n");
printf("\t--nmi\t\t\tNMI. Used NMI even when one or several other measures are specified.\n");
printf("\t--rbn <int>\t\tNMI. Number of bin to use for the reference image histogram. Identical value for every timepoint.\n");
printf("\t--fbn <int>\t\tNMI. Number of bin to use for the floating image histogram. Identical value for every timepoint.\n");
printf("\t-rbn <tp> <int>\t\tNMI. Number of bin to use for the reference image histogram for the specified time point.\n");
......@@ -319,6 +320,8 @@ int main(int argc, char **argv)
#ifdef _USE_CUDA
bool checkMemory=false;
#endif // _use_CUDA
int refBinNumber=0;
int floBinNumber=0;
/* read the input parameter */
for(int i=1; i<argc; i++)
......@@ -400,29 +403,46 @@ int main(int argc, char **argv)
{
REG->SetSpacing(2,(float)atof(argv[++i]));
}
else if((strcmp(argv[i],"--nmi")==0) )
{
int bin=64;
if(refBinNumber!=0)
bin=refBinNumber;
for(int t=0; t<referenceImage->nt; ++t)
REG->UseNMISetReferenceBinNumber(t,bin);
bin=64;
if(floBinNumber!=0)
bin=floBinNumber;
for(int t=0; t<floatingImage->nt; ++t)
REG->UseNMISetFloatingBinNumber(t,bin);
}
else if((strcmp(argv[i],"-rbn")==0) || (strcmp(argv[i],"-tbn")==0))
{
int tp=atoi(argv[++i]);
int bin=atoi(argv[++i]);
refBinNumber=bin;
REG->UseNMISetReferenceBinNumber(tp,bin);
}
else if((strcmp(argv[i],"--rbn")==0) )
{
int binNumber = atoi(argv[++i]);
int bin = atoi(argv[++i]);
refBinNumber=bin;
for(int t=0; t<referenceImage->nt; ++t)
REG->UseNMISetReferenceBinNumber(t,binNumber);
REG->UseNMISetReferenceBinNumber(t,bin);
}
else if((strcmp(argv[i],"-fbn")==0) || (strcmp(argv[i],"-sbn")==0))
{
int tp=atoi(argv[++i]);
int bin=atoi(argv[++i]);
floBinNumber=bin;
REG->UseNMISetFloatingBinNumber(tp,bin);
}
else if((strcmp(argv[i],"--fbn")==0) )
{
int binNumber = atoi(argv[++i]);
int bin = atoi(argv[++i]);
floBinNumber=bin;
for(int t=0; t<floatingImage->nt; ++t)
REG->UseNMISetFloatingBinNumber(t,binNumber);
REG->UseNMISetFloatingBinNumber(t,bin);
}
else if(strcmp(argv[i], "-ln")==0 || strcmp(argv[i], "--ln")==0)
{
......@@ -544,8 +564,10 @@ int main(int argc, char **argv)
else if(strcmp(argv[i], "--lncc")==0)
{
float stdev = (float)atof(argv[++i]);
for(int t=0; t<referenceImage->nt; ++t)
REG->UseLNCC(t,stdev);
if(stdev!=999999){ // Value specified by the CLI - to be ignored
for(int t=0; t<referenceImage->nt; ++t)
REG->UseLNCC(t,stdev);
}
}
else if(strcmp(argv[i], "-lnccMean")==0)
{
......
......@@ -71,7 +71,7 @@ char xml_f3d[] =
" <longflag>cpp</longflag>\n"
" <description>Control point position image</description>\n"
" <label>Trans. param image</label>\n"
" <default>outputCPP*.nii</default>\n"
" <default>outputCPP.nii</default>\n"
" <channel>output</channel>\n"
" </file>\n"
" <image fileExtensions=\"*.nii,*.nii.gz,*.nrrd,*.png\">"
......@@ -206,6 +206,13 @@ char xml_f3d[] =
" <label>Use SSD</label>\n"
" <default>false</default>\n"
" </boolean>\n"
" <float>\n"
" <name>UseLNCC</name>\n"
" <longflag>lncc</longflag>\n"
" <description>To use the LNCC as a measure of similarity instead of the NMI used by default and set the Gaussian standard deviation</description>\n"
" <label>Use LNCC</label>\n"
" <default>-999999</default>\n"
" </float>\n"
" <boolean>\n"
" <name>Use_KL_divergence</name>\n"
" <longflag>kld</longflag>\n"
......@@ -278,33 +285,6 @@ char xml_f3d[] =
" <element>3</element>\n"
" </integer-enumeration>\n"
" </parameters>\n"
" <parameters advanced=\"true\">\n"
" <label>F3D_sym options</label>\n"
" <description>Flag and argument to use the symmetric registration scheme</description>\n"
" <boolean>\n"
" <name>useSym</name>\n"
" <longflag>sym</longflag>\n"
" <description>Performs a symmetric registration where both, forward and backward transformations are optimised</description>\n"
" <label>Use symmetry</label>\n"
" <default>false</default>\n"
" </boolean>\n"
" <image fileExtensions=\"*.nii,*.nii.gz,*.nrrd,*.png\">"
" <name>floatingMaskImageName</name>\n"
" <longflag>fmask</longflag>\n"
" <description>Floating mask image filename</description>\n"
" <label>Flo. mask</label>\n"
" <default></default>\n"
" <channel>input</channel>\n"
" </image>"
" <float>\n"
" <name>InverseConsistencyPenaltyTermWeight</name>\n"
" <longflag>ic</longflag>\n"
" <description>Weight to apply to the inverse consistency term</description>\n"
" <label>Inv. consis. weight</label>\n"
" <default>0</default>\n"
" </float>\n"
" </parameters>\n"
" <parameters advanced=\"true\">\n"
" <label>F3D2 options</label>\n"
" <description>Flag and argument to use the stationary velocity field parametrisation</description>\n"
......@@ -317,19 +297,12 @@ char xml_f3d[] =
" </boolean>\n"
" <image fileExtensions=\"*.nii,*.nii.gz,*.nrrd,*.png\">"
" <name>floatingMaskImageName</name>\n"
" <longflag>smask</longflag>\n"
" <longflag>fmask</longflag>\n"
" <description>Floating mask image filename</description>\n"
" <label>Flo. mask</label>\n"
" <default></default>\n"
" <channel>input</channel>\n"
" </image>"
" <integer>\n"
" <name>compositionStepNumber</name>\n"
" <longflag>step</longflag>\n"
" <description>Number of composition step to use to perform the velocity field integration</description>\n"
" <label>Comp. step number</label>\n"
" <default>6</default>\n"
" </integer>\n"
" </parameters>\n"
"</executable>"
;
......@@ -298,7 +298,7 @@ int main(int argc, char **argv)
for(int i=0;i<(refImage->nt<warpedFloImage->nt?refImage->nt:warpedFloImage->nt);++i)
nmi_object->SetActiveTimepoint(i);
nmi_object->InitialiseMeasure(refImage,
floImage,
warpedFloImage,
refMask,
warpedFloImage,
NULL,
......@@ -314,7 +314,7 @@ int main(int argc, char **argv)
for(int i=0;i<(refImage->nt<warpedFloImage->nt?refImage->nt:warpedFloImage->nt);++i)
lncc_object->SetActiveTimepoint(i);
lncc_object->InitialiseMeasure(refImage,
floImage,
warpedFloImage,
refMask,
warpedFloImage,
NULL,
......@@ -329,7 +329,7 @@ int main(int argc, char **argv)
for(int i=0;i<(refImage->nt<warpedFloImage->nt?refImage->nt:warpedFloImage->nt);++i)
ssd_object->SetActiveTimepoint(i);
ssd_object->InitialiseMeasure(refImage,
floImage,
warpedFloImage,
refMask,
warpedFloImage,
NULL,
......
......@@ -978,30 +978,30 @@ void reg_base<T>::GetVoxelBasedGradient()
/* \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ */
/* \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ */
template<class T>
void reg_base<T>::UseNMISetFloatingBinNumber(int timepoint, int floBinNumber)
void reg_base<T>::UseNMISetReferenceBinNumber(int timepoint, int refBinNumber)
{
if(this->measure_nmi==NULL)
this->measure_nmi=new reg_nmi;
this->measure_nmi->SetActiveTimepoint(timepoint);
// I am here adding 4 to the specified bin number to accomodate for
// the spline support
this->measure_nmi->SetFloatingBinNumber(floBinNumber+4, timepoint);
this->measure_nmi->SetReferenceBinNumber(refBinNumber+4, timepoint);
#ifndef NDEBUG
reg_print_fct_debug("reg_base<T>::UseNMISetFloatingBinNumber");
reg_print_fct_debug("reg_base<T>::UseNMISetReferenceBinNumber");
#endif
}
/* \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ */
template<class T>
void reg_base<T>::UseNMISetReferenceBinNumber(int timepoint, int refBinNumber)
void reg_base<T>::UseNMISetFloatingBinNumber(int timepoint, int floBinNumber)
{
if(this->measure_nmi==NULL)
this->measure_nmi=new reg_nmi;
this->measure_nmi->SetActiveTimepoint(timepoint);
// I am here adding 4 to the specified bin number to accomodate for
// the spline support
this->measure_nmi->SetReferenceBinNumber(refBinNumber+4, timepoint);
this->measure_nmi->SetFloatingBinNumber(floBinNumber+4, timepoint);
#ifndef NDEBUG
reg_print_fct_debug("reg_base<T>::UseNMISetReferenceBinNumber");
reg_print_fct_debug("reg_base<T>::UseNMISetFloatingBinNumber");
#endif
}
/* \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ */
......
......@@ -1782,7 +1782,7 @@ void reg_voxelCentric2NodeCentric_core(nifti_image *nodeImage,
}
}
}
DTYPE reorientedValue[3];
DTYPE reorientedValue[3]={0,0,0};
reorientedValue[0] =
reorientation.m[0][0] * interpolatedValue[0] +
reorientation.m[0][1] * interpolatedValue[1] +
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment