# Warning "no valid points..." with Powell optimizer and VersorRigid3DTransform

**URL:** https://discourse.itk.org/t/warning-no-valid-points-with-powell-optimizer-and-versorrigid3dtransform/1161
**Category:** Beginner Questions
**Created:** [July 27, 2018, 8:26pm UTC](https://discourse.itk.org/t/warning-no-valid-points-with-powell-optimizer-and-versorrigid3dtransform/1161 "2018-07-27T20:26:56Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![aharris](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/bcef8e/32.png) [@aharris](https://discourse.itk.org/u/aharris)
#### Post date: [July 27, 2018, 8:26pm UTC](https://discourse.itk.org/t/warning-no-valid-points-with-powell-optimizer-and-versorrigid3dtransform/1161/1 "2018-07-27T20:26:56Z")

</div>

I’m hoping someone can have a look at my code and see where I’m going wrong. I had this warning (“no valid points…” is all I can read in the output window and the scroll bar at the bottom doesn’t function) when I first implemented this registration but the project got corrupted and I wanted to refactor it, and now I can’t remember how I resolved it.

[ImageStitcherV2.h](https://discourse.itk.org/uploads/default/original/1X/ac07f27baa0bd82073babedaa755fd76d70b3b50.h) (4.9 KB)  
[ImageStitcherV2.cpp](https://discourse.itk.org/uploads/default/original/1X/68b05ae72a14adaad45a40996f00dc9f4da8b067.cpp) (9.9 KB)

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [August 3, 2018, 6:08pm UTC](https://discourse.itk.org/t/warning-no-valid-points-with-powell-optimizer-and-versorrigid3dtransform/1161/2 "2018-08-03T18:08:35Z")

</div>

> [@aharris](#):
>
> warning (“no valid points…”

This usually means the images no longer overlap.

An approach to understand what is happening is to resample the moving image at each iteration, and visualize the fixed and moving images together.

---

<div class="post-metadata">

### Author: ![aharris](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/bcef8e/32.png) [@aharris](https://discourse.itk.org/u/aharris)
#### Post date: [August 8, 2018, 6:49pm UTC](https://discourse.itk.org/t/warning-no-valid-points-with-powell-optimizer-and-versorrigid3dtransform/1161/3 "2018-08-08T18:49:48Z")

</div>

This is happening even with identical images, and initial transform set to identity. I think I’m forgetting to set something up in the registration but I haven’t been able to find example code for setting up the Powell optimizer. Any idea where I could find that to see how my parameter settings compare with working code?

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [August 8, 2018, 8:25pm UTC](https://discourse.itk.org/t/warning-no-valid-points-with-powell-optimizer-and-versorrigid3dtransform/1161/4 "2018-08-08T20:25:34Z")

</div>

Here is a code fragment from working code. Optimizer is not used for normal image to image registration, though.

```auto
#ifdef USE_POWELL
		typedef itk::PowellOptimizerv4<double> OptimizerType;
#else
		typedef itk::AmoebaOptimizerv4 OptimizerType;
#endif
		OptimizerType::Pointer optimizer = OptimizerType::New();
		optimizer->SetMetric(cost);
		optimizer->SetDoEstimateScales(false);
		optimizer->SetNumberOfIterations(MaximumNumberOfIterations);

		OptimizerType::ScalesType scales(numberOfParams);
		CostType::ParametersType delta(numberOfParams);
		OptimizerType::ScalesType weights(numberOfParams);
		unsigned i = 0;
        for (; i < numCenters; i++)
		{
			scales[i] = 0.2;
			delta[i] = 0.2;
			weights[i] = 0.1;
		}
        for (; i < total; i++)
		{
			scales[i] = 1.0;
			delta[i] = 1.0;
			weights[i] = 10.0;
		}
		unsigned iStart = i;
		for (; i < numberOfParams; i++)
		{
			scales[i] = Activities[i - iStart] / 100;
			delta[i] = scales[i] * 10;
			weights[i] = 1.0;
		}
		optimizer->SetScales(scales);
		optimizer->SetWeights(weights);

#ifdef USE_POWELL
		optimizer->SetStepTolerance(0.1);
		optimizer->SetStepLength(0.5);
#else //Nelder-Meade initial simplex
		optimizer->SetAutomaticInitialSimplex(false);
		optimizer->SetInitialSimplexDelta(delta);
#endif

		try
		{
			optimizer->StartOptimization();
		}
		catch (itk::ExceptionObject e)
		{
			std::cerr << e << std::endl;
			return EXIT_FAILURE;
		}

		CostType::ParametersType params = optimizer->GetCurrentPosition();
        std::cout << '\n' << optimizer->GetStopConditionDescription() << std::endl << std::endl;
		//std::cout << "\nParams: " << params;
		//std::cout << "\nCost: " << optimizer->GetCurrentMetricValue();
		//std::cout << "\nIterations: " << optimizer->GetCurrentIteration();

```
