ERROR with NiftyReg installation
ortegacruzd opened this issue · comments
Hi!
I'm trying to install NiftyReg 1.3.9 on Linux 4.18.0 following the instructions here: http://cmictig.cs.ucl.ac.uk/wiki/index.php/NiftyReg_install.
After running 'ccmake' and generating, I run 'make' and get the following error:
[ 94%] Building CXX object reg-apps/CMakeFiles/reg_tools.dir/reg_tools.cpp.o
/home/t660/t660582/matlab/nifty_reg/reg-apps/reg_tools.cpp: In function ‘int main(int, char**)’:
/home/t660/t660582/matlab/nifty_reg/reg-apps/reg_tools.cpp:223:39: error: narrowing conversion of ‘3’ from ‘int’ to ‘bool’ [-Wnarrowing]
223 | bool boolX[8]={3,1,0,0,0,0,0,0};
| ^
/home/t660/t660582/matlab/nifty_reg/reg-apps/reg_tools.cpp:225:39: error: narrowing conversion of ‘3’ from ‘int’ to ‘bool’ [-Wnarrowing]
225 | bool boolY[8]={3,0,1,0,0,0,0,0};
| ^
/home/t660/t660582/matlab/nifty_reg/reg-apps/reg_tools.cpp:227:39: error: narrowing conversion of ‘3’ from ‘int’ to ‘bool’ [-Wnarrowing]
227 | bool boolZ[8]={3,0,0,1,0,0,0,0};
| ^
make[2]: *** [reg-apps/CMakeFiles/reg_tools.dir/build.make:82: reg-apps/CMakeFiles/reg_tools.dir/reg_tools.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1667: reg-apps/CMakeFiles/reg_tools.dir/all] Error 2
make: *** [Makefile:182: all] Error 2
I'm not sure whether this is related to a mistake I did during the building or due to a bug in the package. I've tried using three different configurations of CMAKE_BUILD_TYPE: Release, RelWithDebInfo and Debug. Have you ever encountered such an error? Do you know how I could solve it?
Thank you so much for your help!
Diana Ortega.
Hi Diana,
It looks like a bug. Older versions of the compiler converted integer 3
to type bool
without complaint, but newer versions of the compiler flag the error. When I encountered this I fixed it (worked around it?) by changing the three problematic lines:
// ...snip...
bool boolX[8]={1,1,0,0,0,0,0,0}; // was {3,1,0,0,0,0,0,0};
reg_gaussianSmoothing(smoothImg,param->smoothValueX,boolX);
bool boolY[8]={1,0,1,0,0,0,0,0}; // was {3,0,1,0,0,0,0,0};
reg_gaussianSmoothing(smoothImg,param->smoothValueY,boolY);
bool boolZ[8]={1,0,0,1,0,0,0,0}; // was {3,0,0,1,0,0,0,0};
reg_gaussianSmoothing(smoothImg,param->smoothValueZ,boolZ);
// ...snip...
This problem is no longer present in the current version 1.5 of NiftyReg.
Hi Douglas,
thanks a lot for the advice. I managed to work around this issue changing the 3s as you suggested.
Is the current NiftyReg version 1.5 the one that is available here on GitHub? I downloaded that one and tried to install it too, but I obtain another error in the 'make' step (copied below). Do you happen to know how I could solve this one?
Thanks again for your help! Best,
Diana.
[ 57%] Building CXX object reg-lib/CMakeFiles/_reg_measure.dir/cpu/_reg_ssd.cpp.o /home/t660/t660582/matlab/niftyreg-github/reg-lib/cpu/_reg_ssd.cpp: In function ‘void GetDiscretisedValueSSD_core3D_2(nifti_image*, float*, int, int, nifti_image*, nifti_image*, int*) [with DTYPE = float]’: /home/t660/t660582/matlab/niftyreg-github/reg-lib/cpu/_reg_ssd.cpp:850:35: error: ‘voxelBlockNumber_t’ not specified in enclosing ‘parallel’ 850 | for(idBlock=0;idBlock<voxelBlockNumber_t;idBlock++) { | ^~~~~~~~~~~~~~~~~~ /home/t660/t660582/matlab/niftyreg-github/reg-lib/cpu/_reg_ssd.cpp:823:9: error: enclosing ‘parallel’ 823 | #pragma omp parallel for default(none) \ | ^~~ /home/t660/t660582/matlab/niftyreg-github/reg-lib/cpu/_reg_ssd.cpp:864:50: error: ‘voxelNumber’ not specified in enclosing ‘parallel’ 864 | voxIndex_t = timeV*voxelNumber + voxIndex; | ^~~~~~~~~~~ /home/t660/t660582/matlab/niftyreg-github/reg-lib/cpu/_reg_ssd.cpp:823:9: error: enclosing ‘parallel’ 823 | #pragma omp parallel for default(none) \ | ^~~ /home/t660/t660582/matlab/niftyreg-github/reg-lib/cpu/_reg_ssd.cpp:865:52: error: ‘voxelBlockNumber’ not specified in enclosing ‘parallel’ 865 | blockIndex_t = timeV*voxelBlockNumber + blockIndex; | ^~~~~~~~~~~~~~~~ /home/t660/t660582/matlab/niftyreg-github/reg-lib/cpu/_reg_ssd.cpp:823:9: error: enclosing ‘parallel’ 823 | #pragma omp parallel for default(none) \ | ^~~ /home/t660/t660582/matlab/niftyreg-github/reg-lib/cpu/_reg_ssd.cpp:937:64: error: ‘label_nD_number’ not specified in enclosing ‘parallel’ 937 | discretisedValue[currentControlPoint * label_nD_number + discretisedIndex] = currentSum; | ^~~~~~~~~~~~~~~ /home/t660/t660582/matlab/niftyreg-github/reg-lib/cpu/_reg_ssd.cpp:823:9: error: enclosing ‘parallel’ 823 | #pragma omp parallel for default(none) \ | ^~~ /home/t660/t660582/matlab/niftyreg-github/reg-lib/cpu/_reg_ssd.cpp: In function ‘void GetDiscretisedValueSSD_core3D_2(nifti_image*, float*, int, int, nifti_image*, nifti_image*, int*) [with DTYPE = double]’: /home/t660/t660582/matlab/niftyreg-github/reg-lib/cpu/_reg_ssd.cpp:850:35: error: ‘voxelBlockNumber_t’ not specified in enclosing ‘parallel’ 850 | for(idBlock=0;idBlock<voxelBlockNumber_t;idBlock++) { | ^~~~~~~~~~~~~~~~~~ /home/t660/t660582/matlab/niftyreg-github/reg-lib/cpu/_reg_ssd.cpp:823:9: error: enclosing ‘parallel’ 823 | #pragma omp parallel for default(none) \ | ^~~ /home/t660/t660582/matlab/niftyreg-github/reg-lib/cpu/_reg_ssd.cpp:864:50: error: ‘voxelNumber’ not specified in enclosing ‘parallel’ 864 | voxIndex_t = timeV*voxelNumber + voxIndex; | ^~~~~~~~~~~ /home/t660/t660582/matlab/niftyreg-github/reg-lib/cpu/_reg_ssd.cpp:823:9: error: enclosing ‘parallel’ 823 | #pragma omp parallel for default(none) \ | ^~~ /home/t660/t660582/matlab/niftyreg-github/reg-lib/cpu/_reg_ssd.cpp:865:52: error: ‘voxelBlockNumber’ not specified in enclosing ‘parallel’ 865 | blockIndex_t = timeV*voxelBlockNumber + blockIndex; | ^~~~~~~~~~~~~~~~ /home/t660/t660582/matlab/niftyreg-github/reg-lib/cpu/_reg_ssd.cpp:823:9: error: enclosing ‘parallel’ 823 | #pragma omp parallel for default(none) \ | ^~~ /home/t660/t660582/matlab/niftyreg-github/reg-lib/cpu/_reg_ssd.cpp:937:64: error: ‘label_nD_number’ not specified in enclosing ‘parallel’ 937 | discretisedValue[currentControlPoint * label_nD_number + discretisedIndex] = currentSum; | ^~~~~~~~~~~~~~~ /home/t660/t660582/matlab/niftyreg-github/reg-lib/cpu/_reg_ssd.cpp:823:9: error: enclosing ‘parallel’ 823 | #pragma omp parallel for default(none) \ | ^~~ make[2]: *** [reg-lib/CMakeFiles/_reg_measure.dir/build.make:95: reg-lib/CMakeFiles/_reg_measure.dir/cpu/_reg_ssd.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:559: reg-lib/CMakeFiles/_reg_measure.dir/all] Error 2 make: *** [Makefile:149: all] Error 2
Hi Diana,
Yes, the latest version on GitHub is version 1.5.68. The last commit to it was made two years ago, so the project appears to be dormant for now.
The compile errors your encountered with version 1.5 are due to changes in the OpenMP's #pragma
syntax. The niftyreg code uses the older OpenMP syntax, which requires a few changes to be compatible with the version of OpenMP used in recent versions of gcc. Here are the code changes I made to fix the errors in files reg-lib/cpu/_reg_mind.cpp
and reg-lib/cpu/_reg_ssd.cpp
to get niftyreg compiling under gcc 10 with OpenMP enabled:
diff --git a/reg-lib/cpu/_reg_mind.cpp b/reg-lib/cpu/_reg_mind.cpp
index 294d21c..e2de37c 100644
--- a/reg-lib/cpu/_reg_mind.cpp
+++ b/reg-lib/cpu/_reg_mind.cpp
@@ -136,7 +136,7 @@ void GetMINDImageDesciptor_core(nifti_image* inputImage,
#if defined (_OPENMP)
#pragma omp parallel for default(none) \
shared(samplingNbr, maskPtr, meanImgDataPtr, \
- MINDImgDataPtr) \
+ MINDImgDataPtr, voxelNumber) \
private(voxelIndex, meanValue, max_desc, descValue, mindIndex)
#endif
for(voxelIndex=0;voxelIndex<voxelNumber;voxelIndex++) {
@@ -296,7 +296,7 @@ void GetMINDSSCImageDesciptor_core(nifti_image* inputImage,
#if defined (_OPENMP)
#pragma omp parallel for default(none) \
shared(lengthDescriptor, samplingNbr, maskPtr, meanImgDataPtr, \
- MINDSSCImgDataPtr) \
+ MINDSSCImgDataPtr, voxelNumber) \
private(voxelIndex, meanValue, max_desc, descValue, mindIndex)
#endif
for(voxelIndex=0;voxelIndex<voxelNumber;voxelIndex++) {
diff --git a/reg-lib/cpu/_reg_ssd.cpp b/reg-lib/cpu/_reg_ssd.cpp
index 98d1e20..7b65154 100755
--- a/reg-lib/cpu/_reg_ssd.cpp
+++ b/reg-lib/cpu/_reg_ssd.cpp
@@ -823,7 +823,7 @@ void GetDiscretisedValueSSD_core3D_2(nifti_image *controlPointGridImage,
#pragma omp parallel for default(none) \
shared(controlPointGridImage, refImage, warImage, grid2img_vox, blockSize, \
padding_value, refBlockValue, mask, refImgPtr, warImgPtr, discretise_radius, \
- discretise_step, discretisedValue) \
+ discretise_step, discretisedValue, voxelBlockNumber_t, voxelNumber, voxelBlockNumber, label_nD_number) \
private(cpx, cpy, cpz, x, y, z, a, b, c, t, currentControlPoint, gridVox, imageVox, \
voxIndex, idBlock, blockIndex, definedValueNumber, tid, \
timeV, voxIndex_t, blockIndex_t, discretisedIndex, currentSum, currentValue)
Alternatively, you could configure cmake to disable OpenMP, but niftyreg will run noticeably more slowly.
One minor "gotcha" I encountered moving from niftyreg 1.3 -> 1.5 was the new reg_aladin
parameter -noSym
, which must be specified to keep performance the same as version 1.3. If you do not specify this param the tool execution time is double what it was in 1.3, as by default calculates both forward and backward transforms.
I hope this helps,
Doug
Hi again,
Wow, inserting the changes you suggested I installed it completely without error! This was amazingly helpful :) Thanks a big lot!!