Skip to content

Commit

Permalink
BUG: Fixups for adding 1D FFT classes from ITKUltrasound to ITK
Browse files Browse the repository at this point in the history
- Fix smart pointer references from object factory
- Remove references to OpenCL implementations
- Fix Python name test
  • Loading branch information
tbirdso committed Oct 6, 2021
1 parent 0487709 commit 9332084
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
# include "itkFFTWComplexToComplex1DFFTImageFilter.h"
#endif

#if defined(ITKUltrasound_USE_clFFT)
# include "itkOpenCLComplexToComplex1DFFTImageFilter.h"
#endif

#include "itkMetaDataDictionary.h"
#include "itkMetaDataObject.h"

Expand All @@ -42,13 +38,12 @@ ComplexToComplex1DFFTImageFilter<TInputImage, TOutputImage>::New()
{
Pointer smartPtr = ObjectFactory<Self>::Create();

#ifdef ITKUltrasound_USE_clFFT
if (smartPtr.IsNull())
if (smartPtr.IsNotNull())
{
smartPtr =
dynamic_cast<Self *>(OpenCLComplexToComplex1DFFTImageFilter<TInputImage, TOutputImage>::New().GetPointer());
// Decrement ITK SmartPointer produced from object factory
smartPtr->UnRegister();
}
#endif

#ifdef ITK_USE_FFTWD
if (smartPtr.IsNull())
{
Expand Down
30 changes: 8 additions & 22 deletions Modules/Filtering/FFT/include/itkForward1DFFTImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,10 @@
# include "itkFFTWForward1DFFTImageFilter.h"
#endif

#if defined(ITKUltrasound_USE_clFFT)
# include "itkOpenCLForward1DFFTImageFilter.h"
#endif

#include "itkMetaDataObject.h"

namespace itk
{
#ifdef ITKUltrasound_USE_clFFT
template <typename TSelfPointer, typename TInputImage, typename TOutputImage, typename TPixel>
struct Dispatch_1DRealToComplexConjugate_New
{
static TSelfPointer
Apply()
{
return OpenCLForward1DFFTImageFilter<TInputImage, TOutputImage>::New().GetPointer();
}
};
#else

template <typename TInputImage, typename TOutputImage>
class VnlForward1DFFTImageFilter;

Expand All @@ -59,7 +43,7 @@ struct Dispatch_1DRealToComplexConjugate_New
}
};

# ifdef ITK_USE_FFTWD
#ifdef ITK_USE_FFTWD
template <typename TSelfPointer, typename TInputImage, typename TOutputImage>
struct Dispatch_1DRealToComplexConjugate_New<TSelfPointer, TInputImage, TOutputImage, double>
{
Expand All @@ -69,9 +53,9 @@ struct Dispatch_1DRealToComplexConjugate_New<TSelfPointer, TInputImage, TOutputI
return FFTWForward1DFFTImageFilter<TInputImage, TOutputImage>::New().GetPointer();
}
};
# endif
#endif // ITK_USE_FFTWD

# ifdef ITK_USE_FFTWF
#ifdef ITK_USE_FFTWF
template <typename TSelfPointer, typename TInputImage, typename TOutputImage>
struct Dispatch_1DRealToComplexConjugate_New<TSelfPointer, TInputImage, TOutputImage, float>
{
Expand All @@ -81,9 +65,7 @@ struct Dispatch_1DRealToComplexConjugate_New<TSelfPointer, TInputImage, TOutputI
return FFTWForward1DFFTImageFilter<TInputImage, TOutputImage>::New().GetPointer();
}
};
# endif

#endif // ITKUltrasound_USE_clFFT
#endif // ITK_USE_FFTWF

template <typename TInputImage, typename TOutputImage>
typename Forward1DFFTImageFilter<TInputImage, TOutputImage>::Pointer
Expand All @@ -99,6 +81,10 @@ Forward1DFFTImageFilter<TInputImage, TOutputImage>::New()
TOutputImage,
typename NumericTraits<typename TOutputImage::PixelType>::ValueType>::Apply();
}
else
{
smartPtr->UnRegister();
}

return smartPtr;
}
Expand Down
30 changes: 8 additions & 22 deletions Modules/Filtering/FFT/include/itkInverse1DFFTImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,11 @@
# include "itkFFTWInverse1DFFTImageFilter.h"
#endif

#if defined(ITKUltrasound_USE_clFFT)
# include "itkOpenCLInverse1DFFTImageFilter.h"
#endif

#include "itkMetaDataDictionary.h"
#include "itkMetaDataObject.h"

namespace itk
{
#ifdef ITKUltrasound_USE_clFFT
template <typename TSelfPointer, typename TInputImage, typename TOutputImage, typename TPixel>
struct Dispatch_1DComplexConjugateToReal_New
{
static TSelfPointer
Apply()
{
return OpenCLInverse1DFFTImageFilter<TInputImage, TOutputImage>::New().GetPointer();
}
};
#else

template <typename TSelfPointer, typename TInputImage, typename TOutputImage, typename TPixel>
struct Dispatch_1DComplexConjugateToReal_New
{
Expand All @@ -57,7 +41,7 @@ struct Dispatch_1DComplexConjugateToReal_New
}
};

# ifdef ITK_USE_FFTWD
#ifdef ITK_USE_FFTWD
template <typename TSelfPointer, typename TInputImage, typename TOutputImage>
struct Dispatch_1DComplexConjugateToReal_New<TSelfPointer, TInputImage, TOutputImage, double>
{
Expand All @@ -67,10 +51,10 @@ struct Dispatch_1DComplexConjugateToReal_New<TSelfPointer, TInputImage, TOutputI
return FFTWInverse1DFFTImageFilter<TInputImage, TOutputImage>::New().GetPointer();
}
};
# endif
#endif // ITK_USE_FFTWD


# ifdef ITK_USE_FFTWF
#ifdef ITK_USE_FFTWF
template <typename TSelfPointer, typename TInputImage, typename TOutputImage>
struct Dispatch_1DComplexConjugateToReal_New<TSelfPointer, TInputImage, TOutputImage, float>
{
Expand All @@ -80,9 +64,7 @@ struct Dispatch_1DComplexConjugateToReal_New<TSelfPointer, TInputImage, TOutputI
return FFTWInverse1DFFTImageFilter<TInputImage, TOutputImage>::New().GetPointer();
}
};
# endif

#endif // ITKUltrasound_USE_clFFT
#endif // ITK_USE_FFTWF

template <typename TInputImage, typename TOutputImage>
typename Inverse1DFFTImageFilter<TInputImage, TOutputImage>::Pointer
Expand All @@ -98,6 +80,10 @@ Inverse1DFFTImageFilter<TInputImage, TOutputImage>::New()
TOutputImage,
typename NumericTraits<typename TOutputImage::PixelType>::ValueType>::Apply();
}
else
{
smartPtr->UnRegister();
}

return smartPtr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ VnlForward1DFFTImageFilter<TInputImage, TOutputImage>::GenerateData()
multiThreader->template ParallelizeImageRegionRestrictDirection<TOutputImage::ImageDimension>(
direction,
output->GetRequestedRegion(),
[this, input, output, direction, vectorSize](const typename OutputImageType::RegionType & lambdaRegion) {
[input, output, direction, vectorSize](const typename OutputImageType::RegionType & lambdaRegion) {
using InputIteratorType = ImageLinearConstIteratorWithIndex<InputImageType>;
using OutputIteratorType = ImageLinearIteratorWithIndex<OutputImageType>;
InputIteratorType inputIt(input, lambdaRegion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ VnlInverse1DFFTImageFilter<TInputImage, TOutputImage>::GenerateData()
multiThreader->template ParallelizeImageRegionRestrictDirection<TOutputImage::ImageDimension>(
direction,
output->GetRequestedRegion(),
[this, input, output, direction, vectorSize](const typename OutputImageType::RegionType & lambdaRegion) {
[input, output, direction, vectorSize](const typename OutputImageType::RegionType & lambdaRegion) {
using InputIteratorType = ImageLinearConstIteratorWithIndex<InputImageType>;
using OutputIteratorType = ImageLinearIteratorWithIndex<OutputImageType>;
InputIteratorType inputIt(input, lambdaRegion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
#if defined(ITK_USE_FFTWD) || defined(ITK_USE_FFTWF)
# include "itkFFTWComplexToComplex1DFFTImageFilter.h"
#endif
#if defined(ITKUltrasound_USE_clFFT)
# include "itkOpenCLComplexToComplex1DFFTImageFilter.h"
#endif

template <typename FFTType>
int
Expand Down Expand Up @@ -90,7 +87,6 @@ itkComplexToComplex1DFFTImageFilterTest(int argc, char * argv[])
std::cerr << " 0 default\n";
std::cerr << " 1 VNL\n";
std::cerr << " 2 FFTW\n";
std::cerr << " 3 OpenCL via clFFT\n";
std::cerr << std::flush;
return EXIT_FAILURE;
}
Expand Down Expand Up @@ -122,13 +118,6 @@ itkComplexToComplex1DFFTImageFilterTest(int argc, char * argv[])
return doTest<FFTInverseType>(argv[1], argv[2], argv[3]);
#endif
}
else if (backend == 3)
{
#if defined(ITKUltrasound_USE_clFFT)
using FFTInverseType = itk::OpenCLComplexToComplex1DFFTImageFilter<ComplexImageType, ComplexImageType>;
return doTest<FFTInverseType>(argv[1], argv[2], argv[3]);
#endif
}

std::cerr << "Backend " << backend << " (" << argv[4] << ") not implemented" << std::endl;
return EXIT_FAILURE;
Expand Down
13 changes: 0 additions & 13 deletions Modules/Filtering/FFT/test/itkFFT1DImageFilterTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
# include "itkFFTWForward1DFFTImageFilter.h"
# include "itkFFTWInverse1DFFTImageFilter.h"
#endif
#if defined(ITKUltrasound_USE_clFFT)
# include "itkOpenCLForward1DFFTImageFilter.h"
# include "itkOpenCLInverse1DFFTImageFilter.h"
#endif

template <typename FFTForwardType, typename FFTInverseType>
int
Expand Down Expand Up @@ -89,7 +85,6 @@ itkFFT1DImageFilterTest(int argc, char * argv[])
std::cerr << " 0 default\n";
std::cerr << " 1 VNL\n";
std::cerr << " 2 FFTW\n";
std::cerr << " 3 OpenCL via clFFT\n";
std::cerr << std::flush;
return EXIT_FAILURE;
}
Expand Down Expand Up @@ -126,14 +121,6 @@ itkFFT1DImageFilterTest(int argc, char * argv[])
return doTest<FFTForwardType, FFTInverseType>(argv[1], argv[2]);
#endif
}
else if (backend == 3)
{
#if defined(ITKUltrasound_USE_clFFT)
using FFTForwardType = itk::OpenCLForward1DFFTImageFilter<ImageType, ComplexImageType>;
using FFTInverseType = itk::OpenCLInverse1DFFTImageFilter<ComplexImageType, ImageType>;
return doTest<FFTForwardType, FFTInverseType>(argv[1], argv[2]);
#endif
}

std::cerr << "Backend " << backend << " (" << argv[3] << ") not implemented" << std::endl;
return EXIT_FAILURE;
Expand Down
11 changes: 0 additions & 11 deletions Modules/Filtering/FFT/test/itkForward1DFFTImageFilterTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
#if defined(ITK_USE_FFTWD) || defined(ITK_USE_FFTWF)
# include "itkFFTWForward1DFFTImageFilter.h"
#endif
#if defined(ITKUltrasound_USE_clFFT)
# include "itkOpenCLForward1DFFTImageFilter.h"
#endif

template <typename FFTType>
int
Expand Down Expand Up @@ -89,7 +86,6 @@ itkForward1DFFTImageFilterTest(int argc, char * argv[])
std::cerr << " 0 default\n";
std::cerr << " 1 VNL\n";
std::cerr << " 2 FFTW\n";
std::cerr << " 3 OpenCL via clFFT\n";
std::cerr << std::flush;
return EXIT_FAILURE;
}
Expand Down Expand Up @@ -123,13 +119,6 @@ itkForward1DFFTImageFilterTest(int argc, char * argv[])
return doTest<FFTForwardType>(argv[1], argv[2]);
#endif
}
else if (backend == 3)
{
#if defined(ITKUltrasound_USE_clFFT)
using FFTForwardType = itk::OpenCLForward1DFFTImageFilter<ImageType, ComplexImageType>;
return doTest<FFTForwardType>(argv[1], argv[2]);
#endif
}

std::cerr << "Backend " << backend << " (" << argv[3] << ") not implemented" << std::endl;
return EXIT_FAILURE;
Expand Down
13 changes: 1 addition & 12 deletions Modules/Filtering/FFT/test/itkInverse1DFFTImageFilterTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
#if defined(ITK_USE_FFTWD) || defined(ITK_USE_FFTWF)
# include "itkFFTWInverse1DFFTImageFilter.h"
#endif
#if defined(ITKUltrasound_USE_clFFT)
# include "itkOpenCLInverse1DFFTImageFilter.h"
#endif

template <typename FFTType>
int
Expand Down Expand Up @@ -84,7 +81,6 @@ itkInverse1DFFTImageFilterTest(int argc, char * argv[])
std::cerr << " 0 default\n";
std::cerr << " 1 VNL\n";
std::cerr << " 2 FFTW\n";
std::cerr << " 3 OpenCL via clFFT\n";
std::cerr << std::flush;
return EXIT_FAILURE;
}
Expand All @@ -98,7 +94,7 @@ itkInverse1DFFTImageFilterTest(int argc, char * argv[])
int backend = 0;
if (argc > 3)
{
for (size_t idx = 0; idx < argc; ++idx)
for (size_t idx = 0; idx < static_cast<size_t>(argc); ++idx)
{
std::cout << argv[idx] << std::endl;
}
Expand All @@ -122,13 +118,6 @@ itkInverse1DFFTImageFilterTest(int argc, char * argv[])
return doTest<FFTInverseType>(argv[1], argv[2], argv[3]);
#endif
}
else if (backend == 3)
{
#if defined(ITKUltrasound_USE_clFFT)
using FFTInverseType = itk::OpenCLInverse1DFFTImageFilter<ComplexImageType, ImageType>;
return doTest<FFTInverseType>(argv[1], argv[2], argv[3]);
#endif
}

std::cerr << "Backend " << backend << " (" << argv[4] << ") not implemented" << std::endl;
return EXIT_FAILURE;
Expand Down
3 changes: 3 additions & 0 deletions Wrapping/Generators/Python/Tests/getNameOfClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ def wrongClassName(cl, name):
# method, which return a subclass of the current class
exclude = [
"ForwardFFTImageFilter",
"Forward1DFFTImageFilter",
"InverseFFTImageFilter",
"Inverse1DFFTImageFilter",
"OutputWindow",
"MultiThreaderBase",
"FFTComplexToComplexImageFilter",
"ComplexToComplexFFTImageFilter",
"ComplexToComplex1DImageFilter",
"templated_class",
"HalfHermitianToRealInverseFFTImageFilter",
"RealToHalfHermitianForwardFFTImageFilter",
Expand Down

0 comments on commit 9332084

Please sign in to comment.