[Insight-users] itk - Expectation Maximization (small bug and unnecessary lines of code)

Ricardo Ferrari ricardo.jose.ferrari at gmail.com
Wed Feb 20 13:30:40 EST 2013


Dear itk-developers,

Studying and debugging a few itk classes related to the expectation
maximization, I have noticed the following: (a) in the file
itkGaussianMixtureModelComponent.hxx there are some unnecessary lines of
codes (b) in the file itkExpectationMaximizationMixtureModelEstimator.hxx
there is a small bug - the class variable m_TerminationCode is always set
to NOT_CONVERGED.

Please take a look on the pieces of code I have copied bellow.

Best wishes,
Ricardo

PS: I would still be very grateful if somebody could guide me when
extending the EM algorithm to deal with t-student mixture components.


/// *************************************************************
///             UNNECESSARY LINES OF CODE
/// *************************************************************
///
/// File: itkGaussianMixtureModelComponent.hxx
///
/// *************************************************************


//  typename TSample::ConstIterator iter = this->GetSample()->Begin();
//  typename TSample::ConstIterator end =  this->GetSample()->End();

//  typename TSample::MeasurementVectorType measurements;

  // why these lines???
//  while ( iter != end )
//    {
//    measurements = iter.GetMeasurementVector();
//    ++iter;
//    }



/// *************************************************************
///             SMALL BUG CORRECTION
/// *************************************************************
///
/// File: itkExpectationMaximizationMixtureModelEstimator.hxx
///
/// *************************************************************


template< class TSample >
void
ExpectationMaximizationMixtureModelEstimator< TSample >
::GenerateData()
{
  m_Proportions = m_InitialProportions;

  int iteration = 0;
  m_CurrentIteration = 0;

  ///
  /// The following line was move from the end of this function
  /// to here. The way it was before, the m_TerminationCode variable
  /// was always set to NOT_CONVERGED
  ///
  m_TerminationCode = NOT_CONVERGED;

  while ( iteration < m_MaxIteration )
  {
    m_CurrentIteration = iteration;
    if ( this->CalculateDensities() )
    {
      this->UpdateComponentParameters();
      this->UpdateProportions();
    }
    else
    {
      m_TerminationCode = CONVERGED;
      break;
    }
    ++iteration;
  }

}

-- 
---------
Ricardo J. Ferrari, Ph.D. - Assistant Professor
Federal University of São Carlos
Rod. Washington Luís, Km 235
Caixa Postal 676 - 13565-905 São Carlos-SP - Brazil
Work Phone: +55 (16) 3306-6607  ;  Fax: +55 (16) 3351-8233
http://www.dc.ufscar.br/
---------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130220/6b0fe5a8/attachment.htm>


More information about the Insight-users mailing list