diff --git a/Examples/Atropos.cxx b/Examples/Atropos.cxx index bc0d7ac63..28158c4cb 100644 --- a/Examples/Atropos.cxx +++ b/Examples/Atropos.cxx @@ -206,7 +206,11 @@ AtroposSegmentation(itk::ants::CommandLineParser * parser) for (unsigned int k = 0; k < imageNames.size(); k++) { typename InputImageType::Pointer image; - ReadImage(image, imageNames[k].c_str()); + if (!ReadImage(image, imageNames[k].c_str())) + { + std::cout << "Input prior probability image could not be read: " << imageNames[k] << std::endl; + return EXIT_FAILURE; + } segmenter->SetPriorProbabilityImage(k + 1, image); } } @@ -214,7 +218,11 @@ AtroposSegmentation(itk::ants::CommandLineParser * parser) { using VectorImageType = itk::VectorImage; typename VectorImageType::Pointer image; - ReadImage(image, filename.c_str()); + if (!ReadImage(image, filename.c_str())) + { + std::cout << "Input prior probability image could not be read." << std::endl; + return EXIT_FAILURE; + } if (image->GetNumberOfComponentsPerPixel() != segmenter->GetNumberOfTissueClasses()) { @@ -260,7 +268,11 @@ AtroposSegmentation(itk::ants::CommandLineParser * parser) std::string filename = initializationOption->GetFunction(0)->GetParameter(1); typename LabelImageType::Pointer image; - ReadImage(image, filename.c_str()); + if (!ReadImage(image, filename.c_str())) + { + std::cout << "Input prior label image could not be read." << std::endl; + return EXIT_FAILURE; + } segmenter->SetPriorLabelImage(image); } else @@ -373,7 +385,11 @@ AtroposSegmentation(itk::ants::CommandLineParser * parser) try { typename LabelImageType::Pointer image; - ReadImage(image, maskOption->GetFunction(0)->GetName().c_str()); + if (!ReadImage(image, maskOption->GetFunction(0)->GetName().c_str())) + { + std::cout << "Input mask image could not be read." << std::endl; + return EXIT_FAILURE; + } segmenter->SetMaskImage(image); // Check to see that the labels in the prior label image or the non-zero @@ -600,7 +616,11 @@ AtroposSegmentation(itk::ants::CommandLineParser * parser) imagename = imageOption->GetFunction(n)->GetName(); } typename InputImageType::Pointer image; - ReadImage(image, imagename.c_str()); + if (!ReadImage(image, imagename.c_str())) + { + std::cout << "Input intensity image could not be read." << std::endl; + return EXIT_FAILURE; + } segmenter->SetIntensityImage(count, image); if (imageOption->GetFunction(count)->GetNumberOfParameters() > 1) {