[Insight-developers] Re: [SCIRUN-USERS] extending ITK support
Gaetan Lehmann
gaetan.lehmann at jouy.inra.fr
Mon Oct 17 07:38:12 EDT 2005
Hi,
The new wrapping process can be used to get informations about wrapped
classes and the template parameters used, but it will not be easy to use
if you need to have the filter parameters (and I think it's the case).
The new itk python module provides some methods to allow to discover
easily the available template parameters: each templated class provides a
dictionary interface which allow to list the available parameters. Also,
it's easy, from a python class, to get the templated class and the
parameters.
And find the methods of an object is still easy in python :-)
An example:
1> import itk
Warning: itkIndent not found
2> itk.MedianImageFilter.keys()
2>
[(<class 'itkImage_2D.itkImageSS2'>, <class 'itkImage_2D.itkImageSS2'>),
(<class 'itkImage_3D.itkImageSS3'>, <class 'itkImage_3D.itkImageSS3'>),
(<class 'itkImage_2D.itkImageUC2'>, <class 'itkImage_2D.itkImageUC2'>),
(<class 'itkImage_2D.itkImageSL2'>, <class 'itkImage_2D.itkImageSL2'>),
(<class 'itkImage_2D.itkImageD2'>, <class 'itkImage_2D.itkImageD2'>),
(<class 'itkImage_2D.itkImageF2'>, <class 'itkImage_2D.itkImageF2'>),
(<class 'itkImage_2D.itkImageUS2'>, <class 'itkImage_2D.itkImageUS2'>),
(<class 'itkImage_3D.itkImageUS3'>, <class 'itkImage_3D.itkImageUS3'>),
(<class 'itkImage_2D.itkImageUL2'>, <class 'itkImage_2D.itkImageUL2'>),
(<class 'itkImage_3D.itkImageSL3'>, <class 'itkImage_3D.itkImageSL3'>),
(<class 'itkImage_3D.itkImageUL3'>, <class 'itkImage_3D.itkImageUL3'>),
(<class 'itkImage_3D.itkImageSC3'>, <class 'itkImage_3D.itkImageSC3'>),
(<class 'itkImage_3D.itkImageF3'>, <class 'itkImage_3D.itkImageF3'>),
(<class 'itkImage_3D.itkImageUC3'>, <class 'itkImage_3D.itkImageUC3'>),
(<class 'itkImage_3D.itkImageD3'>, <class 'itkImage_3D.itkImageD3'>),
(<class 'itkImage_2D.itkImageSC2'>, <class 'itkImage_2D.itkImageSC2'>)]
3> (param, cl) = itk.MedianImageFilter.items()[0]
4> param
4> (<class 'itkImage_2D.itkImageSS2'>, <class 'itkImage_2D.itkImageSS2'>)
5> cl
5> <class 'itkMedianImageFilter.itkMedianImageFilterISS2ISS2'>
the lines above show how to get all the combinaisons of types of a template
and the python class associated to the template and a combinaison of types.
(You will not get all the types above: I have build the python wrappers
with as much types as possible to test everything works fine)
6> itk.template(param[0])
6> (<template itkImage>, (<itkCType signed short>, 2))
7> itk.template(cl)
7>
(<template itkMedianImageFilter>,
(<class 'itkImage_2D.itkImageSS2'>, <class 'itkImage_2D.itkImageSS2'>))
and here we get the template and the combinaison of types from an itk class
Also, get all the classes available in ITK should be easy:
8> [module for module in dir(itk) if not module.startswith("__") and
module[0].isupper() and len(module) > 2]
8>
['AbortCheckEvent',
'AbsImageFilter',
'AbsoluteValueDifferenceImageFilter',
'AcosImageFilter',
...snip...
'WhiteTopHatImageFilter',
'XorImageFilter',
'ZeroCrossingBasedEdgeDetectionImageFilter',
'ZeroCrossingImageFilter']
and get the available methods is still easy in python (after some cleanup):
9> [ method for method in dir(cl.New()) if isinstance(method, str) and
not method.startswith("__") and method[0].isupper()]
9>
['AbortGenerateDataOff',
'AbortGenerateDataOn',
'AddObserver',
'CreateAnother',
'DebugOff',
...snip...
'UpdateOutputInformation',
'UpdateProgress']
Note that I'm talking about the version I'm working on. I still don't know
what will be integrated in the official ITK.
Regards,
Gaetan
On Sun, 16 Oct 2005 04:19:26 +0200, Darby J Van Uitert
<darbyb at sci.utah.edu> wrote:
> Luis,
>
> The ITK XML file does not have to specify anything about a GUI. By
> default, any parameters will be text entry boxes in the module UI. At a
> minimum, the ITK XML file must contain information about how the filter
> is templated, any inputs and outputs, and any parameters. Chapter 8 of
> the SCIRun User Guide
> (http://software.sci.utah.edu/doc/User/Guide/usersguide/srug8.html)
> goes into it in more detail. I would be happy to help in any way I can
> since I helped write the wrapper. Thanks.
>
> -darby j
>
> On Sat, 15 Oct 2005 12:16:45 -0400
> Luis Ibanez <luis.ibanez at kitware.com> wrote:
>> Hi Carlos,
>>
>> We are planning to refactor the wrapping process in ITK,
>> so that wrappers are generated from CMake. I wonder if
>> an XML description can be added as part of this refactoring.
>>
>> If I remember correctly one of the extra information that
>> you need for SCIrun is to have some indication of the GUI
>> widgets that can be associated to filter parameters, along
>> with default values and ranges for those values.
>>
>> Is this still the case ?
>>
>>
>> Regards,
>>
>>
>> Luis
>>
>>
>> -----------------------
>> Carlos Santos wrote:
>>> Dear all,
>>>
>>> I am starting out with both SCIRun and ITK and I am really interested
>>> in incorporating more ITK filters into SCIRun. I found the
>>> documentation about wrapping the filters, distributed with the Insight
>>> Applications package and successfully wrapped the CannyEdgeDetection
>>> filter.
>>>
>>> Now I'd like to automate the generation of XML descriptions for the
>>> filters. Since I've built ITK with python support, I thought of using
>>> python's reflective abilities to discover information about the
>>> filters (like supported methods) and create the descriptors. Probably,
>>> some manual editing would still be necessary after that.
>>>
>>> Before diving into what might be duplicate work, I'd like to know if
>>> there are some other efforts for extending ITK support in SCIRun. Any
>>> comments on the described approach would be wellcome. I would be
>>> willing to contribute back to the SCIRun project any resultant
>>> extension.
>>>
>>> Yours sincerely,
>>> Carlos Santos
>>>
>>> ===========================================================================
>>> == The SCIRun Users mailing list: send email to
>>> majordomo at sci.utah.edu ==
>>> == for more details.
>>> ==
>>> == Please acknowledge use of SCIRun in your papers and
>>> reports: ==
>>> == see http://software.sci.utah.edu/scirun-biopse_citation.bib
>>> ==
>>> ===========================================================================
>>>
>>>
>>
>> ===========================================================================
>> == The SCIRun Users mailing list: send email to
>> majordomo at sci.utah.edu ==
>> == for more details.
>> ==
>> == Please acknowledge use of SCIRun in your papers and
>> reports: ==
>> == see http://software.sci.utah.edu/scirun-biopse_citation.bib
>> ==
>> ===========================================================================
>
> ...........................
> Darby J Van Uitert
> SCI Institute
> University of Utah
> Email: darbyb at sci.utah.edu
> Phone: 301.528.8469
> ...........................
--
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
More information about the Insight-developers
mailing list