[Insight-users] ExpectationMaximizationMixtureModelEstimator error

smrolfe at u.washington.edu smrolfe at u.washington.edu
Wed Jul 10 19:05:51 EDT 2013


Hello,

I am still working to resolve the error outlined below.  If someone could explain how the WeightedMeanSampleFilter is used in the ExpectationMaximizationMixtureModelEstimator that would help me to understand why I am getting an incorrect total weight of zero. Any help on the funtion or inputs to the WeightedMeanSampleFilter in the estimator would be greatly appreciated.

Thanks,
Sara

On Mon, 1 Jul 2013, smrolfe at u.washington.edu wrote:

> Hello,
>
> I am using the ExpectationMaximizationMixtureModelEstimator filter to estimate a mixture model from a set of observations.  I am closely following the example
> ExpectationMaximizationMixtureModelEstimator_2D.cxx
>
> When I run the program, I am getting the error:
>
> Description: itk::ERROR: WeightedMeanSampleFilter(00000000038A66C0): Total weight was too close to zero. Value = 0
>
> It looks like this filter computes the mean of a set of weighted measurement vectors, but I'm not clear on what might cause the total weight to be zero.  I'd appreciate any thoughts.
> An excerpt of my code is below.
>
> Thanks!
> Sara
>
>
> typedef itk::Array< double > ParametersType;
> typedef itk::Statistics::GaussianMixtureModelComponent< SampleType > ComponentType;
> typedef itk::Statistics::ExpectationMaximizationMixtureModelEstimator< SampleType > EstimatorType;
>
> SampleType::Pointer sample = SampleType::New();
>
> for (int pointIter = 0; pointIter < pointArray[i].size(); pointIter++){ //put all points in current histogram bin in the sample vector
>              sample->PushBack( pointArray[i][pointIter] ); //pointArray[i] is a vector of measurement vectors
> }
> int distributionNumber = initialParameters.meanVectors[i].size();
> int paramNumber = (MeasurementVectorLength)+(MeasurementVectorLength*MeasurementVectorLength);
> ParametersType params( paramNumber );
> std::vector< ParametersType > inputParameters( distributionNumber );
> itk::Array< double > initialProportions(distributionNumber);
>
> for(int j = 0; j < distributionNumber; j++){         // for each distribution in initial estimate
> initialProportions[j] = initialParameters.subHistogram[i][j];   // set initial proportions to the sub-bin size
> for(int k = 0; k < MeasurementVectorLength; k++){ // assign values in distribution parameter matrix
> params[k] = initialParameters.meanVectors[i][j][k];
> }
> int paramCount = MeasurementVectorLength;
> for(int l=0; l < MeasurementVectorLength; l++){
> for(int m=0; m < MeasurementVectorLength; m++){
> params[paramCount] = initialParameters.covarianceMats[i][j][l][m];
> paramCount++;
> }
> }
>
> inputParameters[j] = params; // push parameters for current distribution into parameter vector
> }
>
>
> std::vector< ComponentType::Pointer > components;                       // Create the Gausian model components
> for ( unsigned int k = 0 ; k < distributionNumber ; k++ ){
> components.push_back( ComponentType::New() );
> (components[k])->SetSample( sample );
> (components[k])->SetParameters( inputParameters[k] );
> }
>
> EstimatorType::Pointer estimator = EstimatorType::New();         // set up estimator for bin i
> estimator->SetSample( sample );
> estimator->SetMaximumIteration( 200 );
> estimator->SetInitialProportions( initialProportions );
>
> for ( unsigned int k = 0 ; k < distributionNumber ; k++){
> estimator->AddComponent( (ComponentType::Superclass*)(components[k]).GetPointer() );
> }
>
> try{
> estimator->Update();
> }catch( itk::ExceptionObject & err ){
> std::cerr << "ExceptionObject caught !" << std::endl;
> std::cerr << err << std::endl;
> }
>
>



More information about the Insight-users mailing list