Proposals:Refactoring Statistics Framework 2007 Migration Users Guide

From KitwarePublic
Jump to navigationJump to search

How To Migrate your code to the New Statistics Framework

Measurement Containers



Class Name Fate Deprecated API New API
Sample Refactored
  • Does not derives from Object anymore, now it derives from DataObject.
  • typedef for InstanceIdentifier was replaced from unsigned long to std::vector<MeasurementVectorType>::size_type
  • Size() method now returns InstanceIdentifier type, before it returned unsigned int, which was inconsistent with the declaration of InstanceIdentifier as unsigned long. The return type of Size() must be the same use for Id of the elements, since it may reach the same maximum number.
  • Removing unnecessary const in identifiers
    • GetMeasurementVector( const InstanceItentifier & id ) is now GetMeasurementVector( InstanceItentifier id )
    • GetFrequency( const InstanceItentifier & id ) is now GetFrequency( InstanceItentifier id )
    • SetMeasurementVectorSize( const MeasurementVectorSizeType s ) is now SetMeasurementVectorSize( MeasurementVectorSizeType s )
  • const-correctness is now enforced.
  • It now derives from DataObject
Subsample Refactored
  • The concept of Indices and InstanceIdentifiers was fixed. InstanceIdentifiers were previously referring to the original Sample, they are now referring to the current Subsample set of measurement vectors.
  • It now derives from its template argument. Before, it was deriving from an explicit itk::Statistics::Sample<> whose template argument MeasurementVector was taken as a trait from the Subsample template argument. The current derivation is more consistent with the notion that the Subsample should behave as the sample from which the instances are taken.
  • FrequencyType GetFrequencyByIndex(int index) const : was removed. This method becomes obsolete when the inconsistencies between index and identifier are removed.
  • InstanceIdentifier GetInstanceIdentifier(int index) const; was removed. This method becomes obsolete when the inconsistencies between index and identifier are removed.
  • Iterators
    • Common
      • GetInstanceIdentifier() now returns the integer distance to the Begin() element. Before it used to return the index of the instance in the real sample.
      • Iterator& operator+(int n) and Iterator& operator-(int n) were removed. The methods were not used, and they were not consistent with other containers. They were also unsafe, given that with Begin() and End() there is no way to verify if an iterator has moved before Begin() or after End() (unless we rely on being aware of the underlying pointer implementation of the Iterators, which would be a violation of the class encapsulation).
      • Constructor ConstIterator(typename InstanceIdentifierHolder::const_iterator iter, const Self* classSample) was made protected, since this constructor must only be called by the Sample owner class.
    • ConstIterator
      • removing Friendship to the Iterator
    • non-const Iterator
      • removing Friendship to the ConstIterator
  • The basic principle followed now in the design of the Subsample class is that the subsample should behave as a sample. That is, a user should be able to use a Subsample class in any algorithm that is expecting a Sample.
  • AddInstance( InsitanceIdentifier Id )
    • Now throws an exception if the Id is larger than the Size of the Sample.
    • Now it calls Modified()
  • Iterators
    • Now the non-const Iterator derives from the ConstIterator
    • Methods declared protected and purposely not implemented
      • Default constructor: This was a safety risk since it contained uninitialized variables
      • The following method are in this category to enforce const correctness. All of them could have offered ways of removing constness without warning
        • Iterator(const Self * sample);
        • Iterator(typename InstanceIdentifierHolder::const_iterator iter, const Self* classSample);
        • Iterator(const ConstIterator & it);
        • ConstIterator& operator=(const ConstIterator& it);
ListSampleBase Deprecated. The class was unecessary, it was providing only a Search() method that should in fact be provided by a process class, not a data container.
  • If you were deriving a class from the itk::Statistics::ListSampleBase, you should now derive directly from the itk::Statistics::Sample class.
  • If you were using the Search() method you can get that functionality now from the (refactored) NeighborhoodSampler filter class. Note that the NeighborhoodSampler now allows users to setup a specific distance metric.
ListSample Refactored
  • It does not derive from the ListSampleBase (since that class was deprecated)
  • The iterators API was updated,
    • const-correctness is now enforced
    • Constructor with instance identifier was moved to the protected section
    • ConstIterator does not refer to the non-const Iterator any more.
    • Method that allowed to convert ConstIterator into non-const Iterators were removed because they were facilitating the violation of const-correctness
  • Various API modifications
    • SearchResultVectorType trait was removed. Search is to be implemented as an external algorithm.
    • Resize( unsigned int ) now is Resize( InstanceIdentifier ) (keeping 64bits in mind)
    • PushBack() before passed the argument by copy, now it passes it as a const reference
    • Size() method used to return unsigned int, now it returns InstanceIdentifier (keeping 64bits in mind)
    • GetMeasurementVector() instance identifier argument is now passed by copy, since it is just a number
    • SetMeasurementVector() now passes InstanceIdentifier by copy, not by const reference
    • SetMeasurement() now passes InstanceIdentifier by copy, not by const reference
    • GetFrequency() now passes InstanceIdentifier by copy, not by const reference
  • GetMeasurementVectorSize() method was removed. The default implementation of the superclass is now functional for this class too.
  • The implementation code of most methods was moved to the .txx file.
  • It derives now from the Sample class directly
  • Iterators
    • ConstIterator use friendship to the ListSample
    • operator-- removed
    • non-const Iterator is no longer a friend of the ConstIterator. Instead it derives from the ConstIterator
    • The following methods were declared but not implemented, in the protected section with the purpose of preventing const-correctness violations
      • Iterator() constructor
      • Iterator(const Self * sample) constructor of non-const iterator from const sample
      • Iterator( typename InternalDataContainerType::const_iterator iter, InstanceIdentifier iid) constructor of non-const iterator from const sample iterator
      • Iterator(const ConstIterator & it) constructor of non-const iterator from ConstIterator
      • ConstIterator& operator=(const ConstIterator& it) Assignment of ConstIterator to non-const Iterator.
    • The followin methods were moved to the protected section, since only the ListSample class (which is a friend) should call them
      • Iterator( typename InternalDataContainerType::iterator iter, InstanceIdentifier iid):ConstIterator( iter, iid )
MembershipSample Refactoring in Progress Luis
  • It does not derive from itk::Sample anymore, instead it derives from DataObject.
Histogram Refactored same name
  • GetIndex() now take the InstanceIdentifier by copy, not as a const reference.
  • Size() doesn't return unsigned int anymore. Instead it returns InstanceIdentifier (64 bits in mind)
  • GetSize() now returns a const reference to the Size object.
  • GetSize( dimension ) : const specifier of the argument was removed (it was useless)
  • GetBinMin( ), GetBinMax(), SetBinMin and SetBinMax()
    • const specifier of the dimension was removed (it was useless)
    • bin number parameter type "unsigned long" was replaced with InstanceIdentifier
  • GetBinMinFromValue( ), GetBinMaxFromValue()
    • const specifier of the dimension was removed (it was useless)
  • GetDimensionMins( ), GetDimensionMaxs()
    • const specifier of the dimension was removed (it was useless)
  • GetHistogramMinFromIndex() and GetHistogramMaxFromIndex()
    • Is now declared const (as any Get method should be)
    • It returns a const reference (it used to return a non-const reference)
  • GetFrequency()
    • const specifier of the InstanceIdentifier was removed (it was useless)
  • SetFrequency( value )
    • const specifier of the FrequencyType value was removed (it was useless)
  • SetFrequency( id, value )
    • const reference specifier of the InstanceIdentifier was removed. It is now passed by copy
    • const specifier of the FrequencyType value was removed (it was useless)
  • IncreaseFrequency( id, value )
    • const reference specifier of the InstanceIdentifier was removed. It is now passed by copy
    • const specifier of the FrequencyType value was removed (it was useless)
  • IncreaseFrequency( index, value )
    • const specifier of the FrequencyType value was removed (it was useless)
  • GetMeasurementVector( id )
    • const specifier of the InstanceIdentifier was removed (it was useless)
  • GetMeasurement( id, dimension )
    • type "const unsigned long" of the id, was replaced with InstanceIdentifier, (const part was removed, it was useless)
    • const specifier of the dimension value was removed (it was useless)
  • GetFrequency( id, dimension )
    • type "const unsigned long" of the id, was replaced with InstanceIdentifier, (const part was removed, it was useless)
    • const specifier of the dimension value was removed (it was useless)
  • Quantile( dimension, value )
  • const specifier of the dimension type was removed (it was useless)
  • const & specifier of the value type was removed (it was useless), value is now passed by copy.
  • SetMeasurementVectorSize()
    • const modified of the argument was removed (it was useless)
  • Iterators
    • non-const Iterator now derives from the ConstIterator
    • SetFrequency() method was removed from the non-const Iterator, and put in the ConstIterator
  • Iterators
    • API now made compliant with the other containers.
    • const correctness is enforced
    • non-const Iterator derives from the ConstIterator
    • Preventing any construction of non-const Iterator from ConstIterators
VariableDimensionHistogram Pending
KdTree Pending

Frequency Containers

Class Name Fate Deprecated API New API
DenseFrequencyContainer
SparseFrequencyContainer

Process Objects

Class Name Fate Deprecated API New API
SampleClassifier
SampleClassifierWithMask

Traits

Class Name Fate Deprecated API New API
MeasurementVectorTraits Refactored (same name)
  • Added Assert() instantiations for comparing length of
    • FixedArray raw pointer, std::vector raw pointer
    • FixedArray reference, std::vector reference
  • Added Assign() method for generalizing the assignment of scalars and vector types
    • Assign() vectorType to vectorType
    • Assign() scalarType to FixedArray< scalarType, 1 >
  • Added trait MeasurementVectorType
    • to be used as MeasurementVectorPixelTraits< PixelType >::MeasurementVectorType
    • This trait generalizes the mechanism for creating a measurement vector using as component type the pixel type of an image
  • Added explicit testing up to 100% code coverage

MeanShift

Class Name Fate Deprecated API New API

Adaptors

Class Name Fate Deprecated API New API
ImageToCoocurrenceListAdaptor UNDECIDED
ImageToListAdaptor Refactored into "ImageToListSampleAdaptor". This class handles images with scalar, fixed size array (itk::FixedArray) and variable length vector (itk::VariableLengthVector) pixel types.
  • The class is not derived from ListSampleBase any more since ListSampleBase has been deprecated
  • The second template parameter ( MeasurementVectorType ) is removed since it is redundant. The measurement vector type is determined from the input Image type using the newly added MeasurementVectorPixelTraits.
  • GetUseBuffer() : This method is renamed as GetUsePointContainer(). The term "buffer" is misleading. This flag is used in the class to differentiate between accessing the pixel value directly from the pixel container or using GetPixel(Index) method after computing the index for the given id using ComputeIndex() method. In addition to the Get method, Set methods have been added as indicated in the new API column.
  • The class derives from ListSample with the measurement vector type determined from the input image type
  • The Iterator and ConstIterator API is modified to be consistent with the iterator and constiterators of the ListSample class.
  • Added SetUsePixelContainer( bool ) : To turn on and off the UsePixelContainer flag.
  • Added UsePixelContainerOn(), UsePixelContainerOff() : convenient methods to turn on/off the UsePixelContainer flag.
ScalarImageToListAdaptor Deprecated ( This class is redundant as the new ImageToListSampleAdaptor also handles scalar images with scalar pixel type. )
JointDomainImageToListAdaptor Refactored into "JointDomainImageToListSampleAdaptor"
  • The class is not derived from the ImageToListSampleAdaptor. This design decision was made due to the new changes in the ImageToListSample adaptor to handle different pixel types ( scalar, Fixed length array, variable length vector).
  • Search() (and helper method ComputeRegion()) methods are removed . This class is not the appropriate place for such functionality.
  • Derives from ListSample
  • Iterator and ConstIterator API added and it is consistent with the ListSample class.
  • Set/GetUsePixelContainer() and UsePixelContainerOn/Off methods added
PointSetToListAdapor Refactored into "PointSetToListSampleAdaptor"
  • The class is not derived from ListSampleBase any more since ListSampleBase has been deprecated
  • The class derives from ListSample with the measurement vector type determined from the point set type.
  • GetPointSet() returns a const PointSet ( constant correctness )
  • GetSize() returns InstanceIdentifer type ( to have a consistent signature with the superclass )
  • The Iterator and ConstIterator API is modified to be consistent with the iterator and constiterators of the ListSample class.

Univariate Distributions

Class Name Fate Deprecated API New API

Algorithms

Class Name Fate Deprecated API New API

Calculators

Class Name Fate Deprecated API New API
MeanCalculator Refactored into MeanFilter
  • SetSample() method replaced with SetInput()
  • GetOutput() method return type modified ( the new signature returns a data object decorator )
  • Derives from ProcessObject and the following methods added to integrate the class into the pipeline
    • SetInput()
    • GetOutput() (returns a data object decorated type of the mean vector )
  • GetMean() (returns the mean vector as it is without any decoration )
WeightedMeanCalculator Refactored into WeightedMeanFilter
  • SetSample() method replaced with SetInput()
  • SetWeights() method input argument modified ( the new signature takes dataobject decorated weight array)
  • SetWeightFunction() method replaced with SetWeightingFunction()
  • GetWeights() method return type modified ( new signature returns a data object decorator of the weight array)
  • GetWeightingFunction() method replaced with GetWeightingFunction()
  • GetOutput() method return type modified ( the new signature returns a data object decorator of the mean )
  • Derives from ProcessObject and the following methods added to integrate the class into the pipeline
    • SetInput()
    • GetOutput() (returns a data object decorated type of the mean vector )
    • SetWeights() (Takes dataObjecte decorated version of weight array type )
    • SetWeightingFunction (Takes dataObject decorated version of weighting function type )
CovarianceCalculator Refactored into CovarianceFilter
  • SetMean() removed ( the mean will always be computed inside the class. Keeping track of mean computed internally and set from outside creates lots of inconsistencies in the pipeline).
  • SetSample() replaced with SetInput()
  • GetOutput() replaced with GetCovarianceMatrixOutput() which returns a decorated version of the covariance matrix
  • Derived from process object and the following methods added to integrate the class into the pipeline
    • SetInput()
    • GetMeanOutput() ( returns a decorated version of the mean vector )
    • GetCovarianceMatrixOutput() ( returns a decorated version of the covariance matrix )
WeightedCovarianceCalculator Refactored into WeightedCovarianceFilter
  • SetSample() method replaced with SetInput()
  • SetWeights() method input argument modified ( the new signature takes dataobject decorated weight array)
  • SetWeightFunction() method replaced with SetWeightingFunction()
  • GetWeights() method return type modified ( new signature returns a data object decorator of the weight array)
  • GetWeightingFunction() method replaced with GetWeightingFunction()
  • Derives from itk::CovarianceFilter and all the methods defined in the CovarianceFilter for pipeline integration (SetInput(), GetMeanOutput(), GetCovarianceMatrixOutput() )should be used
  • SetWeights() (Takes dataObjecte decorated version of weight array type )
  • SetWeightingFunction (Takes dataObject decorated version of weighting function type )
  • GetWeights() returns decorated version of the weight array
  • GetWeightingFunction() returns decorated version of the weighting function
GreyLevelCooccurrenceMatrixTextureCoefficientsCalculator Refactored into HistogramToTextureFeaturesFilter
  • Compute() removed ( Update() method should be used in the new API )
  • SetHistogram() removed ( replaced by SetInput() in the new API )
  • Derives from ProcessObject and the following methods added to integrate it to the pipeline
    • SetInput()
    • GenerateData() ( user should invoke Update() to compute the features )
    • Data object decorated versions of the Get methods for each feature was added.
      • GetEnergyOutput()
      • GetEntropyOutput()
      • GetCorrelationOutput()
      • GetInverseDifferenceMomentOutput()
      • GetInertiaOutput()
      • GetClusterShadeOutput()
      • GetClusterProminenceOutput()
      • GetHaralickCorrelationOutput()
ScalarImageTextureCalculator To be Refactored into ScalarImageToTextureFeaturesFilter


Generators

Class Name Fate Deprecated API New API
ListSampleToHistogramGenerator Refactored into SampleToHistogramFilter
  • It used to derive from Object, now derives from ProcessObject
  • It used to be templated over
    • SampleType and the
    • HistogramMeasurementType
    • Histogram frequency container.
  • Not it is templated over TSample and THistogram
  • SetListSample() removed. Replaced with SetInput()
  • The following member variables were removed and now are managed through Decorated inputs
    • Histogram Size
    • Marginal scale
    • Histogram Mins
    • Histogram Maxs
    • AutoMinMax
  • It derives now from ProcessObject
  • It is now templated over TSample and THistogram types
  • SetInput( const SampleType * )
  • const SampleType * GetInput() const
  • Copy Constructor and Operator=() are declared protected are purposely not implemented in order to enforce the correct use of SmartPointers.
  • MakeOutput() method added, so that the filter is compatible with the DisconnectPipeline() API of the output DataObject.
  • Added DataDecorated Inputs for
    • Histogram Size
    • AutoMinimumMaximum
    • MarginalScale
    • HistogramBinMinimum
    • HistogramBinMaximum
  • Decorated inputs provide
    • Set/Get methods for the decorated type and
    • ONLY Set method for the undecorated type.
    • Get method for undecorated type cannot be provided because their API uses a const reference, and the decorated input may have been a NULL pointer, in which case there is not possible const reference to return.
ImageToListGenerator Refactored into ImageToListSampleFilter
  • GetListSample() replaced with GetOutput()
  • GenerateData() moved to protected interface
  • Integrated with the pipeline
    • GetOutput() added
  • The measurement vector type is determined using MeasurementVectorTraits and hence this adaptor handles scalar, fixed array and variable length vector pixel type
ScalarImageToGreyLevelCooccurrenceMatrixGenerator Refactored into ScalarImageToCooccurrenceMatrixFilter
  • Compute() method removed ( Update() ) should be used instead
  • Derives from Process Object and integrated into the pipeline
    • User should invoke Update() to compute the matrix
    • GetOutput() returns the computed matrix
  • Takes a mask image as well
    • SetMaskImage() added
    • GetMaskImage() added
MaskedScalarImageToGreyLevelCooccurrenceMatrixGenerator Deprecated ( Use ScalarImageToCooccurrenceMatrixFilter instead since this takes a mask image in addition to the input image )

Filters

Class Name Fate Deprecated API New API
ListSampleToHistogramFilter Refactored as SampleToHistogramFilter
  • It used to derive from Object, now derives from ProcessObject
  • It used to expect a ListSample as input, it now takes any class that complies with the Sample API
  • SetListSample() removed. The method SetInput() should be used instead.
  • SetHistogram() removed. The resulting histogram is now obtained from the GetOutput() method, according to a standard Filter API.
  • Update() implementation removed, the default Update() of the superclass ProcessObject() provides the correct functionality.
  • Run() method removed. The method Update() in the superclass provides the equivalent functionality.
  • Member variables removed
    • A pointer to the ListSample. This is now managed by the Input of the ProcessObject.
    • A pointer to the output histogram. This is now manged by the Output of the ProcessObject.
  • In the old API it was expected that the user will
    • Construct an instance of the Histogram class
    • Setup in that histogram all the parameters such as:
      • Histogram Size
      • Histogram bin Minimum
      • Histogram bin Maximum
      • AutoMinMax
  • In the new API this setup is done directly in the filter, since the output object is supposed to be created by the filter, and provided as a const object, therefore the users do not have access to it for applying any modifications.
  • It derives now from ProcessObject
  • SetInput( const SampleType * )
  • const SampleType * GetInput() const
  • const HistogramType * GetOutput() const
  • Copy Constructor and Operator=() are declared protected are purposely not implemented in order to enforce the correct use of SmartPointers.
  • MakeOutput() method added, so that the filter is compatible with the DisconnectPipeline() API of the output DataObject.
  • Added DataDecorated Inputs for
    • Histogram Size
    • AutoMinimumMaximum
    • MarginalScale
    • HistogramBinMinimum
    • HistogramBinMaximum
  • Decorated inputs provide
    • Set/Get methods for the decorated type and
    • ONLY Set method for the undecorated type.
    • Get method for undecorated type cannot be provided because their API uses a const reference, and the decorated input may have been a NULL pointer, in which case there is not possible const reference to return.

Multivariate Density Functions

Class Name Fate Deprecated API New API

Distance Metrics

Class Name Fate Deprecated API New API

Components

Class Name Fate Deprecated API New API

Estimators

Class Name Fate Deprecated API New API