ITK icon indicating copy to clipboard operation
ITK copied to clipboard

Problems with the python wrapping of ShapePriorMAPCostFunction

Open bpaniagua opened this issue 6 years ago • 3 comments

Description

There seems to be a problem using the ShapePriorMAPCostFunction class in python.

When assigning the mean and stddev vectors and then printing the cost function object, those arrays seem to be empty. This assignment does not create a problem in C++. The test here uses the ShapePriorMAPCostFunction and it works perfectly.

Steps to Reproduce

In python, I create a ShapePriorMAPCostFunction in the following way:

costfunction=itk.ShapePriorMAPCostFunction[ImageType, InputPixelType].New()
weights=itk.FixedArray[itk.D,4]()
weights[0] =  1.0  # weight for contour fit term
weights[1] =  20.0 # weight for image fit term
weights[2] =  1.0  # weight for shape prior term
weights[3] =  1.0  # weight for pose prior term
costfunction.SetWeights(weights)
mean=itk.Array[itk.D](pca.GetNumberOfShapeParameters())
mean.Fill(0.0)
stddev=itk.Array[itk.D](pca.GetNumberOfShapeParameters())
stddev.Fill(1.0)
costfunction.SetShapeParameterMeans(mean)
costfunction.SetShapeParameterStandardDeviations(stddev)

I try to use this costfunction object in a GeodesicActiveContourShapePriorLevelSetImage filter, and when I update the filter I get the following error:

RuntimeError: /work/standalone-x64-build/ITKs/Modules/Segmentation/LevelSets/include/itkShapePriorMAPCostFunction.hxx:187: itk::ERROR: ShapePriorMAPCostFunction(0x9675fa0): ShapeParameterMeans does not have at least 3 number of elements.

When I print the costfunction object I created in the way I described I see this information:

ShapePriorMAPCostFunction (0x9675fa0) RTTI typeinfo: itk::ShapePriorMAPCostFunction<itk::Image<float, 2u>, float> Reference Count: 3 Modified Time: 8414 Debug: Off Object Name: Observers: none ShapeFunction: 0x982d9f0 ActiveRegion: 0x982d9a0 FeatureImage: 0x91f1f80 ShapeParameterMeans: [] ShapeParameterStandardDeviations: [] Weights: [1, 20, 1, 1]

Note that despite having assigned the mean and stddev vectors, they seem to be empty in the costfunction object.

If I try to access the costfunction variable by print costfunction.GetShapeParameterMeans() I get the following information:

swig_name ([])

Expected behavior

I expect my filter to have the same behavior than the C++ code. It doesnt.

Reproducibility

100%

Versions

I run my jupyter notebook with precompiled itk python packages from last week (05/10/2019)

Environment

I am running this in a python jupyter notebook.

Additional Information

N/A

bpaniagua avatar May 15 '19 13:05 bpaniagua

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Nov 23 '19 10:11 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

stale[bot] avatar Aug 22 '20 18:08 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

stale[bot] avatar Apr 16 '22 10:04 stale[bot]