[Insight-developers] Integrating the New Statistics framework into ITK

Bill Lorensen bill.lorensen at gmail.com
Thu Apr 9 14:27:44 EDT 2009


Is everything that is in Statistics (at least functionally) available
in the new Statistics? For example, I don't see the Distributions in
the new Statistics.

Bill

On Thu, Apr 9, 2009 at 2:19 PM, Karthik Krishnan
<karthik.krishnan at kitware.com> wrote:
> On Sat, Apr 4, 2009 at 3:37 PM, Bill Lorensen <bill.lorensen at gmail.com>
> wrote:
>>
>> Why not 2 directories with separate namespaces.
>> Why not leave Statistics with its current namespace and do something
>> like StatisticsV2 for the new one.
>
> A significant bit of user code written to use the statistics framework will
> stay the same. This will not be possible if we put the new classes in a new
> namespace. Besides, is there something to be gained from placing them in a
> separate namespace ? Only one of them will be compiled / installed since the
> filenames are the same.
>
> Migration to the new framework should, for a user expend the least amount of
> work.
>
> I think from developer feedback, Option A has the widest support. Is that
> the general consensus ?
> Thanks
> --
> karthik
>
>>
>>
>> On Sat, Apr 4, 2009 at 12:05 PM, Karthik Krishnan
>> <karthik.krishnan at kitware.com> wrote:
>> > I forgot to mention the reason for giving you 2 options. I've tried to
>> > weigh
>> > both the options below :
>> >
>> > Option A  vs B
>> > ---------------------
>> >
>> > 1. Code duplication:
>> >
>> >     With A, if a file remains unchanged, it has to be duplicated
>> >     (and maintained, at least as long as Bill is around) in both
>> >     directories.
>> >
>> >     With B, we have to worry only about the classes which need
>> >     refactoring. Even refactoried files, where changes are minimal,
>> >     you can even code of the form:
>> >
>> >       namespace Statistics{
>> >         class Blah {
>> >            #ifdef ITK_USE_DEPRECATED_STAT
>> >               void SetInputSample( ListSampleType * );
>> >            #else
>> >               void SetInput( ListSampleType * );
>> >            #endif
>> >          }
>> >        }
>> >
>> >
>> > 2. Code separation and readability
>> >
>> >     A separates the classes clearly in two directories. The statistics
>> >     library will be devoid of ugly ifdefs. If we decide to drop the
>> >     deprecated version at some point, we simply have to terminate
>> >     a directory.
>> >
>> >     We can do the same with Option B, in a less obvious way, by
>> >     separating the classes in two files, for instance :
>> >
>> >       File StatistiitkSample.h:
>> >          #include "StatisticsDeprecated/itkSample.h"
>> >          #include "StatisticsNew/itkSample.h"
>> >
>> >       File StatisticsDeprecated/itkSample.h
>> >          namespace StatisticsDeprecated
>> >           {
>> >           class Sample : public Object { ... }
>> >           }
>> >
>> >       File StatisticsNew/itkSample.h
>> >          namespace StatisticsNew
>> >           {
>> >           class Sample : public DataObject { ... }
>> >           }
>> >
>> >
>> > 3. Surprises
>> >
>> >   With A there are no surprises. I suspect that with B, using
>> >   anonymized namespaces etc, in several translation units,
>> >   some compiler might scream ? I tried to verify it with minimal
>> >   C++ code on gcc4.3, but I feel uneasy about it.
>> >
>> >
>> > Please let us know your thoughts.
>> > Regards
>> > --
>> > karthik
>> >
>> > On Sat, Apr 4, 2009 at 11:57 AM, Karthik Krishnan
>> > <karthik.krishnan at kitware.com> wrote:
>> >>
>> >> Hello:
>> >>
>> >> As you may know, the ITK statistics framework have been revamped. The
>> >> new
>> >> framework follows ITK pipeline mechanics, removes redundant classes and
>> >> provides a consistent API. The new classes are not backwards
>> >> compatible. For
>> >> details, please visit
>> >>
>> >>
>> >>
>> >> http://www.itk.org/Wiki/Proposals:Refactoring_Statistics_Framework_2007_Migration_Users_Guide
>> >>
>> >> We would like to integrate the new statistics framework into ITK. Given
>> >> that there are numerous API changes, to keep things backward
>> >> compatible, we
>> >> are considering taking one of the following approaches :
>> >>
>> >>
>> >> --------------
>> >> Option A
>> >>
>> >> - Rename the existing Statistics/ directory in ITK to
>> >> StatisticsDeprecated/
>> >>
>> >> - Create a parallel directory Statistics/ containing the new classes.
>> >>
>> >> - Add an ITK_USE_DEPRECATED_STATITSTICS_FRAMEWORK option at configure
>> >> time
>> >> to toggle between the usage of the deprecated and the new framework.
>> >> The
>> >> option will cause (a) the right directory to be compiled (b) headers
>> >> from
>> >> there right directory to be installed (c) the right directory to be
>> >> added to
>> >> the include dirs.
>> >>
>> >> - All existing code in the toolkit using the statistics framework will
>> >> be
>> >> ifdef'ed to work with both the new and the old framework. For instance
>> >> :
>> >>
>> >> #ifdef ITK_USE_DEPRECATED_STATISTICS_FRAMEWORK
>> >>   calculator = Statistics::CovarianceCalculator< ListSampleType
>> >> >::New();
>> >>   calculator->SetInputSample(sample);
>> >>   calculator->Update();
>> >> #else
>> >>   filter = Statistics::CovarianceFilter< ListSampleType >::New();
>> >>   filter->SetInput( sampleGenerator->GetOutput() );
>> >>   filter->Update();
>> >> #endif
>> >>
>> >>
>> >> --------------------------------------------------
>> >>
>> >> Option B
>> >>
>> >> - Keep all files in a single directory but use two different
>> >> namespaces.
>> >>
>> >> For instance the file itkSample.h would look like :
>> >>
>> >> namespace itk
>> >>   {
>> >>   namespace StatisticsDeprecated
>> >>     {
>> >>     class Sample : public Object { ... }
>> >>     }
>> >>
>> >>   namespace StatisticsNew
>> >>     {
>> >>     class Sample : public DataObject { ... }
>> >>     }
>> >>   }
>> >>
>> >> - The ITK_USE_DEPRECATED_STATITSTICS_FRAMEWORK option redefines the
>> >> unused
>> >> namespace to be an anonymous namespace. The used namespace to
>> >> "Statistics".
>> >> For instance :
>> >>
>> >>   #ifdef ITK_USE_DEPRECATED_STATITSTICS_FRAMEWORK
>> >>     #define StatisticsDeprecated Statistics
>> >>     #define StatisticsNew
>> >>   #else
>> >>     #define StatisticsNew Statistics
>> >>     #define StatisticsDeprecated
>> >>   #endif
>> >>
>> >> User code still looks the same :
>> >>
>> >> #ifdef ITK_USE_DEPRECATED_STATISTICS_FRAMEWORK
>> >>   calculator = Statistics::CovarianceCalculator< ListSampleType
>> >> >::New();
>> >>   calculator->SetInputSample(sample);
>> >>   calculator->Update();
>> >> #else
>> >>   filter = Statistics::CovarianceFilter< ListSampleType >::New();
>> >>   filter->SetInput( sampleGenerator->GetOutput() );
>> >>   filter->Update();
>> >> #endif
>> >>
>> >> -----------------------------------------
>> >>
>> >> Any thoughts the developers have on this issue.
>> >>
>> >> We have gathered a wikipage to assemble ideas:
>> >>
>> >> http://www.itk.org/Wiki/Proposals:Refactoring_Statistics_Framework_2007
>> >>
>> >> The refactored code is in the NAMIC sandbox.
>> >>
>> >>
>> >>
>> >> Thanks
>> >> Regards
>> >>
>> >> --
>> >> Karthik Krishnan
>> >> R&D Engineer,
>> >> Kitware Inc.
>> >> Ph: 518 881 4919
>> >> Fax: 518 371 4573
>> >
>> >
>> >
>> > --
>> > Karthik Krishnan
>> > R&D Engineer,
>> > Kitware Inc.
>> > Ph: 518 881 4919
>> > Fax: 518 371 4573
>> >
>> > _______________________________________________
>> > Powered by www.kitware.com
>> >
>> > Visit other Kitware open-source projects at
>> > http://www.kitware.com/opensource/opensource.html
>> >
>> > Please keep messages on-topic and check the ITK FAQ at:
>> > http://www.itk.org/Wiki/ITK_FAQ
>> >
>> > Follow this link to subscribe/unsubscribe:
>> > http://www.itk.org/mailman/listinfo/insight-developers
>> >
>> >
>
>
>
> --
> Karthik Krishnan
> R&D Engineer,
> Kitware Inc.
> Ph: 518 881 4919
> Fax: 518 371 4573
>


More information about the Insight-developers mailing list