ANTsX / ANTsRCore

Rcpp bindings for the C++ ANTs library used by the ANTsR package
9 stars 9 forks source link

Blob Detector fails with multi-threading #129

Closed stnava closed 3 years ago

stnava commented 3 years ago

Describe the bug

Multi-threading in the multi scale laplacian blob detector broken.

This commit https://github.com/ANTsX/ANTsRCore/commit/3dd62669850690afa59250e6f38bc68dc7526926 will support debugging. As a temporary measure, I added a file called itkMultiScaleLaplacianBlobDetectorImageFilter2.[h,hxx] to the src directory which is a slightly modified copy of the file itkMultiScaleLaplacianBlobDetectorImageFilter.[h,hxx] in ANTs. This supports quicker turn-around of the build/test cycle but would ultimately be removed if the original ANTs version of the code gets fixed.

I also tried to annotate locations of likely issues with FIXME in the above hxx.

To Reproduce

In .Renviron set ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=1 and run below code.

Do the same thing with ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=2 and we get a segfault.

library(ANTsRCore)
blob2 = scaleSpaceFeatureDetection( max( ri( 1 ) ) - ri( 1 ), 50 )
plot( ri(1), iMath( blob2$blobImage, "GD", 5 ) )

Expected behavior

Either

  1. enforce single-threaded execution in this filter

or

  1. repair the multi-threaded execution
stnava commented 3 years ago

Additional information: https://github.com/blowekamp/itkScaleSpace

stnava commented 3 years ago

@ntustison - this is fixed now but we should probably work these changes back into ants ... will do later.

ntustison commented 3 years ago

Awesome. This is great.