Skip to content

Commit

Permalink
COMP: Use modern ITK paradigms
Browse files Browse the repository at this point in the history
Future versions of ITK will deprecate and remove outdated coding
paradigms.  Replace deprecated code with modern coding recommendations.

Use official ITK5.2.0 release with improved backward/forward
compatibility syntax.
  • Loading branch information
hjmjohnson committed Aug 5, 2021
1 parent 61e9501 commit bca6205
Show file tree
Hide file tree
Showing 73 changed files with 201 additions and 200 deletions.
4 changes: 2 additions & 2 deletions Examples/ANTS.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,14 @@ int ANTS( std::vector<std::string> args, std::ostream* /*out_stream = nullptr*/
if( argc == 3 && ( std::stoi( argv[1] ) != '-' || std::stoi( argv[1] ) != 2 || std::stoi( argv[1] ) != 3 ) )
{
itk::ImageIOBase::Pointer fixedImageIO
= itk::ImageIOFactory::CreateImageIO( argv[1], itk::ImageIOFactory::FileModeEnum::ReadMode );
= itk::ImageIOFactory::CreateImageIO( argv[1], itk::IOFileModeEnum::ReadMode );
if( fixedImageIO.IsNull() )
{
std::cerr << "Invalid fixed image: " << argv[1] << std::endl;
return EXIT_FAILURE;
}
itk::ImageIOBase::Pointer movingImageIO
= itk::ImageIOFactory::CreateImageIO( argv[2], itk::ImageIOFactory::FileModeEnum::ReadMode );
= itk::ImageIOFactory::CreateImageIO( argv[2], itk::IOFileModeEnum::ReadMode );
if( movingImageIO.IsNull() )
{
std::cerr << "Invalid moving image: " << argv[2] << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions Examples/ANTSIntegrateVectorField.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ SmoothImage(typename TImage::Pointer image, float sig)
using dgf = itk::DiscreteGaussianImageFilter<TImage, TImage>;
typename dgf::Pointer filter = dgf::New();
filter->SetVariance(sig);
filter->SetUseImageSpacingOn();
filter->SetUseImageSpacing(true);
filter->SetMaximumError(.01f);
filter->SetInput(image);
filter->Update();
Expand Down Expand Up @@ -463,7 +463,7 @@ int ANTSIntegrateVectorField( std::vector<std::string> args, std::ostream* /*out

std::string ifn = std::string(argv[1]);
itk::ImageIOBase::Pointer imageIO =
itk::ImageIOFactory::CreateImageIO(ifn.c_str(), itk::ImageIOFactory::FileModeEnum::ReadMode);
itk::ImageIOFactory::CreateImageIO(ifn.c_str(), itk::IOFileModeEnum::ReadMode);
imageIO->SetFileName(ifn.c_str() );
imageIO->ReadImageInformation();
unsigned int dim = imageIO->GetNumberOfDimensions();
Expand Down
2 changes: 1 addition & 1 deletion Examples/ANTSIntegrateVelocityField.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ int ANTSIntegrateVelocityField( std::vector<std::string> args, std::ostream* /*o
std::cout << " start " << std::endl;
std::string ifn = std::string(argv[1]);
itk::ImageIOBase::Pointer imageIO =
itk::ImageIOFactory::CreateImageIO(ifn.c_str(), itk::ImageIOFactory::FileModeEnum::ReadMode);
itk::ImageIOFactory::CreateImageIO(ifn.c_str(), itk::IOFileModeEnum::ReadMode);
imageIO->SetFileName(ifn.c_str() );
imageIO->ReadImageInformation();
unsigned int dim = imageIO->GetNumberOfDimensions();
Expand Down
4 changes: 2 additions & 2 deletions Examples/ANTSJacobian.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ ComputeJacobian(TDisplacementField* field, char* fnm, char* maskfn, bool uselog
{
typename dgf::Pointer filter = dgf::New();
filter->SetVariance(sig);
filter->SetUseImageSpacingOff();
filter->SetUseImageSpacing(false);
filter->SetMaximumError(.01f);
filter->SetInput(m_FloatImage);
filter->Update();
Expand All @@ -402,7 +402,7 @@ ComputeJacobian(TDisplacementField* field, char* fnm, char* maskfn, bool uselog
{
typename dgf::Pointer filter = dgf::New();
filter->SetVariance(sig);
filter->SetUseImageSpacingOff();
filter->SetUseImageSpacing(false);
filter->SetMaximumError(.01f);
filter->SetInput(temp);
filter->Update();
Expand Down
2 changes: 1 addition & 1 deletion Examples/ANTSUseLandmarkImagesToGetAffineTransform.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ int ANTSUseLandmarkImagesToGetAffineTransform( std::vector<std::string> args, st
// Get the image dimension
std::string fn = std::string(argv[1]);
itk::ImageIOBase::Pointer imageIO =
itk::ImageIOFactory::CreateImageIO(fn.c_str(), itk::ImageIOFactory::FileModeEnum::ReadMode);
itk::ImageIOFactory::CreateImageIO(fn.c_str(), itk::IOFileModeEnum::ReadMode);
imageIO->SetFileName(fn.c_str() );
imageIO->ReadImageInformation();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ int ANTSUseLandmarkImagesToGetBSplineDisplacementField( std::vector<std::string>
// Get the image dimension
std::string fn = std::string(argv[1]);
itk::ImageIOBase::Pointer imageIO =
itk::ImageIOFactory::CreateImageIO(fn.c_str(), itk::ImageIOFactory::FileModeEnum::ReadMode);
itk::ImageIOFactory::CreateImageIO(fn.c_str(), itk::IOFileModeEnum::ReadMode);
imageIO->SetFileName(fn.c_str() );
imageIO->ReadImageInformation();

Expand Down
2 changes: 1 addition & 1 deletion Examples/AddNoiseToImage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ int AddNoiseToImage( std::vector<std::string> args, std::ostream* /*out_stream =
return EXIT_FAILURE;
}
itk::ImageIOBase::Pointer imageIO = itk::ImageIOFactory::CreateImageIO(
filename.c_str(), itk::ImageIOFactory::FileModeEnum::ReadMode );
filename.c_str(), itk::IOFileModeEnum::ReadMode );
dimension = imageIO->GetNumberOfDimensions();
}

Expand Down
2 changes: 1 addition & 1 deletion Examples/Atropos.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1766,7 +1766,7 @@ int Atropos( std::vector<std::string> args, std::ostream* /*out_stream = nullptr
return EXIT_FAILURE;
}
itk::ImageIOBase::Pointer imageIO = itk::ImageIOFactory::CreateImageIO(
filename.c_str(), itk::ImageIOFactory::FileModeEnum::ReadMode );
filename.c_str(), itk::IOFileModeEnum::ReadMode );
dimension = imageIO->GetNumberOfDimensions();
}

Expand Down
6 changes: 3 additions & 3 deletions Examples/AverageImages.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int AverageImages1(unsigned int argc, char *argv[])
// Get the image dimension
const std::string fn = std::string(argv[j]);
typename itk::ImageIOBase::Pointer imageIO =
itk::ImageIOFactory::CreateImageIO(fn.c_str(), itk::ImageIOFactory::FileModeEnum::ReadMode);
itk::ImageIOFactory::CreateImageIO(fn.c_str(), itk::IOFileModeEnum::ReadMode);
imageIO->SetFileName(fn.c_str() );
imageIO->ReadImageInformation();

Expand Down Expand Up @@ -186,7 +186,7 @@ int AverageImages(unsigned int argc, char *argv[])
std::string fn = std::string(argv[j]);
std::cout << " fn " << fn << " " << ImageDimension << " " << NVectorComponents << std::endl;
typename itk::ImageIOBase::Pointer imageIO =
itk::ImageIOFactory::CreateImageIO(fn.c_str(), itk::ImageIOFactory::FileModeEnum::ReadMode);
itk::ImageIOFactory::CreateImageIO(fn.c_str(), itk::IOFileModeEnum::ReadMode);
imageIO->SetFileName( fn.c_str() );
imageIO->ReadImageInformation();

Expand Down Expand Up @@ -319,7 +319,7 @@ int AverageImages( std::vector<std::string> args, std::ostream* /*out_stream = n

const int dim = std::stoi( argv[1] );
itk::ImageIOBase::Pointer imageIO =
itk::ImageIOFactory::CreateImageIO(argv[4], itk::ImageIOFactory::FileModeEnum::ReadMode);
itk::ImageIOFactory::CreateImageIO(argv[4], itk::IOFileModeEnum::ReadMode);
imageIO->SetFileName(argv[4]);
imageIO->ReadImageInformation();
unsigned int ncomponents = imageIO->GetNumberOfComponents();
Expand Down
2 changes: 1 addition & 1 deletion Examples/AverageTensorImages.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int AverageTensorImages(unsigned int argc, char *argv[])
std::string fn = std::string(argv[j]);
std::cout << " fn " << fn << std::endl;
typename itk::ImageIOBase::Pointer imageIO =
itk::ImageIOFactory::CreateImageIO(fn.c_str(), itk::ImageIOFactory::FileModeEnum::ReadMode);
itk::ImageIOFactory::CreateImageIO(fn.c_str(), itk::IOFileModeEnum::ReadMode);
imageIO->SetFileName(fn.c_str() );
imageIO->ReadImageInformation();
for( unsigned int i = 0; i < imageIO->GetNumberOfDimensions(); i++ )
Expand Down
2 changes: 1 addition & 1 deletion Examples/CheckTopology.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ typename TImage::Pointer SmoothImage( typename TImage::Pointer image, float sig
using dgf = itk::DiscreteGaussianImageFilter<ImageType, ImageType>;
typename dgf::Pointer filter = dgf::New();
filter->SetVariance(sig);
filter->SetUseImageSpacingOff();
filter->SetUseImageSpacing(false);
filter->SetMaximumError(.01f);
filter->SetInput(image);
filter->Update();
Expand Down
2 changes: 1 addition & 1 deletion Examples/ConformalMapping.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ SmoothImage( typename TImage::Pointer input, double var)
typename dgf::Pointer filter = dgf::New();
filter->SetVariance(var);
filter->SetMaximumError(.01f);
filter->SetUseImageSpacingOn();
filter->SetUseImageSpacing(true);
filter->SetInput(input);
filter->Update();

Expand Down
2 changes: 1 addition & 1 deletion Examples/ConvertImagePixelType.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ int ConvertImagePixelType( std::vector<std::string> args, std::ostream* /*out_st
std::string fn = std::string(argv[1]);
itk::ImageIOBase::Pointer imageIO =
itk::ImageIOFactory::CreateImageIO(
fn.c_str(), itk::ImageIOFactory::FileModeEnum::ReadMode);
fn.c_str(), itk::IOFileModeEnum::ReadMode);
imageIO->SetFileName(fn.c_str() );
imageIO->ReadImageInformation();

Expand Down
2 changes: 1 addition & 1 deletion Examples/ConvertInputImagePixelTypeToFloat.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ int ConvertInputImagePixelTypeToFloat( std::vector<std::string> args, std::ostre
std::string fn = std::string(argv[1]);
itk::ImageIOBase::Pointer imageIO =
itk::ImageIOFactory::CreateImageIO(
fn.c_str(), itk::ImageIOFactory::FileModeEnum::ReadMode);
fn.c_str(), itk::IOFileModeEnum::ReadMode);
imageIO->SetFileName(fn.c_str() );
imageIO->ReadImageInformation();

Expand Down
28 changes: 14 additions & 14 deletions Examples/ConvertScalarImageToRGB.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -72,67 +72,67 @@ int ConvertScalarImageToRGB( int argc, char *argv[] )

if( colormapString == "red" )
{
rgbfilter->SetColormap( RGBFilterType::ColormapEnumType::Red );
rgbfilter->SetColormap( RGBFilterType::RGBColormapFilterEnum::Red );
}
else if( colormapString == "green" )
{
rgbfilter->SetColormap( RGBFilterType::ColormapEnumType::Green );
rgbfilter->SetColormap( RGBFilterType::RGBColormapFilterEnum::Green );
}
else if( colormapString == "blue" )
{
rgbfilter->SetColormap( RGBFilterType::ColormapEnumType::Blue );
rgbfilter->SetColormap( RGBFilterType::RGBColormapFilterEnum::Blue );
}
else if( colormapString == "grey" )
{
rgbfilter->SetColormap( RGBFilterType::ColormapEnumType::Grey );
rgbfilter->SetColormap( RGBFilterType::RGBColormapFilterEnum::Grey );
}
else if( colormapString == "cool" )
{
rgbfilter->SetColormap( RGBFilterType::ColormapEnumType::Cool );
rgbfilter->SetColormap( RGBFilterType::RGBColormapFilterEnum::Cool );
}
else if( colormapString == "hot" )
{
rgbfilter->SetColormap( RGBFilterType::ColormapEnumType::Hot );
rgbfilter->SetColormap( RGBFilterType::RGBColormapFilterEnum::Hot );
}
else if( colormapString == "spring" )
{
rgbfilter->SetColormap( RGBFilterType::ColormapEnumType::Spring );
rgbfilter->SetColormap( RGBFilterType::RGBColormapFilterEnum::Spring );
}
else if( colormapString == "autumn" )
{
rgbfilter->SetColormap( RGBFilterType::ColormapEnumType::Autumn );
rgbfilter->SetColormap( RGBFilterType::RGBColormapFilterEnum::Autumn );
}
else if( colormapString == "winter" )
{
rgbfilter->SetColormap( RGBFilterType::ColormapEnumType::Winter );
rgbfilter->SetColormap( RGBFilterType::RGBColormapFilterEnum::Winter );
}
else if( colormapString == "copper" )
{
rgbfilter->SetColormap( RGBFilterType::ColormapEnumType::Copper );
rgbfilter->SetColormap( RGBFilterType::RGBColormapFilterEnum::Copper );
}
else if( colormapString == "summer" )
{
rgbfilter->SetColormap( RGBFilterType::ColormapEnumType::Summer );
rgbfilter->SetColormap( RGBFilterType::RGBColormapFilterEnum::Summer );
}
else if( colormapString == "jet" )
{
rgbfilter->SetColormap( RGBFilterType::ColormapEnumType::Jet );
rgbfilter->SetColormap( RGBFilterType::RGBColormapFilterEnum::Jet );
// typedef itk::Function::JetColormapFunction<typename RealImageType::PixelType,
// typename RGBImageType::PixelType> ColormapType;
// typename ColormapType::Pointer colormap = ColormapType::New();
// rgbfilter->SetColormap( colormap );
}
else if( colormapString == "hsv" )
{
rgbfilter->SetColormap( RGBFilterType::ColormapEnumType::HSV );
rgbfilter->SetColormap( RGBFilterType::RGBColormapFilterEnum::HSV );
// typedef itk::Function::HSVColormapFunction<typename RealImageType::PixelType,
// typename RGBImageType::PixelType> ColormapType;
// typename ColormapType::Pointer colormap = ColormapType::New();
// rgbfilter->SetColormap( colormap );
}
else if( colormapString == "overunder" )
{
rgbfilter->SetColormap( RGBFilterType::ColormapEnumType::OverUnder );
rgbfilter->SetColormap( RGBFilterType::RGBColormapFilterEnum::OverUnder );
}
else if( colormapString == "custom" )
{
Expand Down
2 changes: 1 addition & 1 deletion Examples/ConvertToJpg.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ int ConvertToJpg( std::vector<std::string> args, std::ostream* /*out_stream = nu
std::string fn = std::string(argv[1]);
itk::ImageIOBase::Pointer imageIO =
itk::ImageIOFactory::CreateImageIO(
fn.c_str(), itk::ImageIOFactory::FileModeEnum::ReadMode);
fn.c_str(), itk::IOFileModeEnum::ReadMode);
imageIO->SetFileName(fn.c_str() );
imageIO->ReadImageInformation();

Expand Down
2 changes: 1 addition & 1 deletion Examples/CopyImageHeaderInformation.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ int CopyImageHeaderInformation( std::vector<std::string> args, std::ostream* /*o
std::string fn = std::string(argv[1]);
itk::ImageIOBase::Pointer imageIO =
itk::ImageIOFactory::CreateImageIO(
fn.c_str(), itk::ImageIOFactory::FileModeEnum::ReadMode);
fn.c_str(), itk::IOFileModeEnum::ReadMode);
imageIO->SetFileName(fn.c_str() );
imageIO->ReadImageInformation();
unsigned int dim = imageIO->GetNumberOfDimensions();
Expand Down
2 changes: 1 addition & 1 deletion Examples/CreateDTICohort.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ int CreateDTICohort( std::vector<std::string> args, std::ostream* /*out_stream =
return EXIT_FAILURE;
}
itk::ImageIOBase::Pointer imageIO = itk::ImageIOFactory::CreateImageIO(
filename.c_str(), itk::ImageIOFactory::FileModeEnum::ReadMode );
filename.c_str(), itk::IOFileModeEnum::ReadMode );
dimension = imageIO->GetNumberOfDimensions();
}

Expand Down
2 changes: 1 addition & 1 deletion Examples/CreateTiledMosaic.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,7 @@ int CreateTiledMosaic( std::vector<std::string> args, std::ostream* /*out_stream
filename = imageOption->GetFunction( 0 )->GetName();

itk::ImageIOBase::Pointer imageIO = itk::ImageIOFactory::CreateImageIO(
filename.c_str(), itk::ImageIOFactory::FileModeEnum::ReadMode );
filename.c_str(), itk::IOFileModeEnum::ReadMode );
unsigned int dimension = imageIO->GetNumberOfDimensions();

if( dimension == 3 )
Expand Down
2 changes: 1 addition & 1 deletion Examples/DenoiseImage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ int DenoiseImage( std::vector<std::string> args, std::ostream* /*out_stream = nu
return EXIT_FAILURE;
}
itk::ImageIOBase::Pointer imageIO = itk::ImageIOFactory::CreateImageIO(
filename.c_str(), itk::ImageIOFactory::FileModeEnum::ReadMode );
filename.c_str(), itk::IOFileModeEnum::ReadMode );
dimension = imageIO->GetNumberOfDimensions();
}

Expand Down
Loading

0 comments on commit bca6205

Please sign in to comment.