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

Luis Ibanez luis.ibanez at kitware.com
Sun Apr 5 07:41:11 EDT 2009


Gatean,

Your suggestion has now been added to the Wiki page as "Option D"

http://www.itk.org/Wiki/Proposals:Refactoring_Statistics_Framework_2007_Transition_Plan#Option_D

   Thanks

        Luis

---------------------------------------------
2009/4/5 Gaëtan Lehmann <gaetan.lehmann at jouy.inra.fr>:
>
> Hi,
>
> There is also a third option:
>
> Option C
>
> - Take advantage of ITK 4.0 to integrate the New Statistics framework as is
>
> The advantages over A and B
>
> - no code duplication at all
> - no surprise
> - no additional cmake option, with all the advantages discussed here some
> time ago, including
>  - cleaner code
>  - easier to test
>  - can't confuse the user
>
> And of course the disadvantage - can't see any other one
>
> - break backward compatibility - should be acceptable if done not so often
> and comes with many enhancements for the user
>
> Regards,
>
> Gaëtan
>
>
>
>
> Le 4 avr. 09 à 23:03, Luis Ibanez a écrit :
>
>> Just to better organize this discussion we are gathering these options
>> in the following Wiki page:
>>
>>
>> http://www.itk.org/Wiki/Proposals:Refactoring_Statistics_Framework_2007_Transition_Plan
>>
>> This page is linked from
>> http://www.itk.org/Wiki/Proposals:Refactoring_Statistics_Framework_2007
>>
>>
>> Please feel free to edit and correct if I missed anything,
>>
>>
>>    Thanks
>>
>>
>>         Luis
>>
>>
>>
>> ----------------------------------------------------------------------------------------------------
>> On Sat, Apr 4, 2009 at 3:46 PM, Bradley Lowekamp <blowekamp at mail.nih.gov>
>> wrote:
>>>
>>> I am not sure how you will be using an anonymous name space such as the
>>> following with what you suggested:
>>> namespace
>>> {
>>> }
>>> I would think you would just need something similar to:
>>> namespace itk
>>>   namespace Statistics
>>>   {
>>> #ifdef ITK_USE_DEPRECATED_STATISTICS_FRAMEWORK
>>>   using namespace ::itk::StatisticsDeprecated;
>>> #else
>>>   using namespace ::itk::StatisticsNew;
>>> #endif
>>>   }
>>> }
>>> If this using is done in a common header file, it might never be known
>>> that
>>> the current Statistics name space was renames, no messy anonymous names
>>> spaces would be used.
>>> I am just not clear of the downside to option B yet.
>>>
>>> On Apr 4, 2009, at 3:05 PM, Karthik Krishnan 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
>>> <ATT00001.txt>
>>>
>>> _______________________________________________
>>> 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
>>>
>>>
>> _______________________________________________
>> 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
>
> --
> Gaëtan Lehmann
> Biologie du Développement et de la Reproduction
> INRA de Jouy-en-Josas (France)
> tel: +33 1 34 65 29 66    fax: 01 34 65 29 09
> http://voxel.jouy.inra.fr  http://www.mandriva.org
> http://www.itk.org  http://www.clavier-dvorak.org
>
>


More information about the Insight-developers mailing list