[Insight-developers] How simple is SimpleITK
Daniel Blezek
Blezek.Daniel at mayo.edu
Wed Jan 26 10:53:01 EST 2011
Hi Gaëtan,
I haven't forgotten about our conversation. 8)
Here is where I got to today:
Python 2.6.4 (r264:75706, Nov 17 2009, 11:52:40)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from SimpleITK import *
>>> image = ReadImage ( '../SimpleITK/Testing/Data/Input/RA-Float.nrrd' )
>>> out = GrayscaleErode ( image )
>>> WriteImage ( out, '/tmp/Garf.nrrd' )
The RecursiveGaussian has many parameters and isn't a simple example:
Image::Pointer RecursiveGaussian ( Image::Pointer image, double Sigma,
bool NormalizeAcrossScale, RecursiveGaussianImageFilter::OrderEnumType
Order, unsigned int Direction );
The code is just about ready to be pushed to SimpleITK.
Cheers,
-dan
On 1/25/11 1:29 PM, "Gaëtan Lehmann" <gaetan.lehmann at jouy.inra.fr> wrote:
>
> Dan,
>
> During the last SimpleITK tcon, I think we've talked about trying to
> generate a set of functions to make the coding style more procedural.
> IIRC, they would
> * hide the filter creation and use of Set and Execute methods
> * be in an sitk name space
> * remove the Filter suffix
>
> That would give something very close to what Bill would like:
>
> sitk::Image::Pointer image = sitk::readImage(inputfilename);
> image = sitk::recursiveGaussian(image, sigma);
> sitk::writeImage(outputfilename);
>
> In c++, there is still the Pointer though, but not in python:
>
> import sitk
> image = sitk.readImage(inputfilename)
> image = sitk.recursiveGaussian(image, sigma)
> sitk.writeImage(outputfilename)
>
> this kind of syntax is OK for a python developer, really.
> There is a lot of code in python libs in procedural style and even
> some functional style.
>
> Gaëtan
>
>
> Le 25 janv. 11 à 19:03, Bill Lorensen a écrit :
>
>> Dan,
>>
>> My example was extreme and meant to be provocative.
>>
>> I like your first approach (without the Pointer)
>> using namespace itk::simple;
>> Image image;
>> image = ImageFileReader ( "Foo" );
>> image = RecursiveGaussian ( image, 2.0 )
>> ImageFileWriter ( image, "Bar" );
>>
>> or even
>> itk::simple::Image image;
>> image = itk::simple::ImageFileReader ( "Foo" );
>> image = itk::simple::RecursiveGaussian ( image, 2.0 )
>> itk::simple::ImageFileWriter ( image, "Bar" );
>>
>> I think the OO pattern is not as simple. Who is the audience, Python
>> and Java developers or biomedical researchers?
>>
>> Sorry I was not in Iowa and won't be in Boston. I hope you have a
>> lively and procutive meeting.
>>
>> Bill
>>
>> On Tue, Jan 25, 2011 at 12:50 PM, Blezek, Daniel J.
>> <Blezek.Daniel at mayo.edu> wrote:
>>> Hi Bill,
>>>
>>> For some reason everyone thinks that SimpleITK is going to look like
>>> Matlab... The plan has been to _enable_ Matlab-like syntax, not
>>> demand
>>> it. We will continue the object oriented pattern, but augment with a
>>> set of procedural calls. So your example code would end up looking
>>> something like this:
>>>
>>>
>>> using namespace itk::simple;
>>> Image::Pointer image;
>>> image = ImageFileReader ( "Foo" );
>>> image = RecursiveGaussian ( image, 2.0 )
>>> ImageFileWriter ( image, "Bar" );
>>>
>>> Or, if you like, this can be all done on one line...
>>>
>>> ImageFileWriter ( RecursiveGaussian ( ImageFileReader ( "Foo" ),
>>> 2.0 ),
>>> "Bar" );
>>>
>>> In the OO pattern:
>>>
>>> image = ImageFileReader().SetFilename ( "Foo" ).Execute()
>>> image = RecursiveGaussion().SetSigma ( 2.0 ).Execute ( image )
>>> ImageFileWriter().SetFilename ( "Bar" ).Execute ( image )
>>>
>>> We are investigating making Execute a static method, so the code
>>> would
>>> look like:
>>>
>>> image = ImageFileReader::Execute ( "Foo" )
>>> image = RecursiveGaussian::Execute ( image, 2.0 )
>>> ImageFileWriter::Execute ( image, "Bar" )
>>>
>>> This has not been checked in, because SWIG does not wrap it
>>> properly. I
>>> am working on this.
>>>
>>> At the Iowa meeting, we decided to take the OO approach, as it was
>>> more
>>> broadly approachable to Python and Java developers.
>>>
>>> -dan
>>>
>>> -----Original Message-----
>>> From: insight-developers-bounces at itk.org
>>> [mailto:insight-developers-bounces at itk.org] On Behalf Of Bill
>>> Lorensen
>>> Sent: Tuesday, January 25, 2011 11:28 AM
>>> To: Insight Developers
>>> Subject: [Insight-developers] How simple is SimpleITK
>>>
>>> Folks,
>>>
>>> I just took a look at the current SimpleITK repo.
>>>
>>> To me it looks like itk without templates and without pipelines.
>>> Simpler indeed. And probably simpler to wrap.
>>>
>>> However, it still is object-oriented, has namespaces, has Pointer's,
>>> still uses set/get methods and still has an Execute method. It is
>>> still
>>> quite ITK-like.
>>>
>>> I thought it would be a bit more procedural and more acceptable to
>>> non-itk(e.g. Matlab) users.
>>>
>>> itksImage image = itksReadImage(inputfilename);
>>> image=itksRecursiveGaussian(image, sigma);
>>> itksWriteImage(outputfilename);
>>>
>>> versus
>>>
>>> itk::simple::Image::Pointer image;
>>> itk::simple::ImageFileReader reader;
>>> reader.SetFileName ( inputFilename);
>>> image = reader.Execute();
>>>
>>> itk::simple::RecursiveGaussianImageFilter gaussian;
>>> gaussian.SetSigma ( gaussian );
>>> image = gaussian.Execute ( image );
>>>
>>> itk::simple::ImageFileWriter writer;
>>> writer.SetFileName ( outputFilename );
>>> writer.Execute ( image );
>>>
>>> Bill
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Kitware offers ITK Training Courses, for more information visit:
>>> http://kitware.com/products/protraining.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
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://kitware.com/products/protraining.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
--
Daniel Blezek, PhD
Medical Imaging Informatics Innovation Center
P 127 or (77) 8 8886
T 507 538 8886
E blezek.daniel at mayo.edu
Mayo Clinic
200 First St. S.W.
Harwick SL-44
Rochester, MN 55905
mayoclinic.org
"It is more complicated than you think." -- RFC 1925
More information about the Insight-developers
mailing list