[Insight-users] simpleitk error

Matt McCormick matt.mccormick at kitware.com
Thu Dec 22 14:02:27 EST 2011


Hi Onti,

Great to hear you got it working.

Note that SimpleITK also has an overloaded addition operator.  So, you
can directly add to images.  This has an additional benefit that it
checks equality of image information such as the origin and pixel
spacing.

Matt

On Wed, Dec 21, 2011 at 11:00 PM, Raghuram.O.S.
<raghuramos1987 at gmail.com> wrote:
> I upgraded ipython to 0.12. Now it works. Thanks a lot Matt!
>
>
> On Wed, Dec 21, 2011 at 10:20 PM, Raghuram.O.S. <raghuramos1987 at gmail.com>
> wrote:
>>
>> Hi Matt,
>>
>> I'm using python version 2.6.5. But this was in an ipython console which
>> is on version 0.10 .
>>
>>
>> On Wed, Dec 21, 2011 at 10:02 PM, Matt McCormick
>> <matt.mccormick at kitware.com> wrote:
>>>
>>> Hi Onti,
>>>
>>> What version of Python are you using?  You will need 2.6 or better for
>>> the required buffer protocol.
>>>
>>> Thanks,
>>> Matt
>>>
>>> On Wed, Dec 21, 2011 at 7:44 PM, Raghuram.O.S. <raghuramos1987 at gmail.com>
>>> wrote:
>>> > Hi,
>>> >
>>> > I'm trying to use simpleitk. I need to add two images of same size and
>>> > shape. i'm converting them to numpy arrays and adding to get a final
>>> > numpy
>>> > array. When I try to convert that back to a simpleitk image i get this
>>> > error.
>>> >
>>> > In [11]: imComb_0_2 = sitk.GetImageFromArray(npComb_0_2)
>>> > ERROR: An unexpected error occurred while tokenizing input
>>> > The following traceback may be corrupted or invalid
>>> > The error message is: ('EOF in multi-line statement', (7061, 0))
>>> >
>>> >
>>> > ---------------------------------------------------------------------------
>>> > TypeError                                 Traceback (most recent call
>>> > last)
>>> >
>>> > /home/ros/cpp_code/itkAdd/data/<ipython console> in <module>()
>>> >
>>> >
>>> > /media/sda5/home/ros/softwares/bio/SimpleITK/bin/SimpleITK-build/Wrapping/SimpleITK.pyc
>>> > in GetImageFromArray(arr)
>>> >     146     """Get a SimpleITK Image from a numpy array."""
>>> >     147
>>> > --> 148     return _SimpleITK._GetImageFromArray( arr )
>>> >     149
>>> >     150 class VectorBool(_object):
>>> >
>>> > TypeError: 'numpy.ndarray' does not have the buffer interface
>>> >
>>> > In [12]: imComb_0_2 = sitk.GetImageFromArray(npComb_0_2)
>>> > ERROR: An unexpected error occurred while tokenizing input
>>> > The following traceback may be corrupted or invalid
>>> > The error message is: ('EOF in multi-line statement', (7061, 0))
>>> >
>>> >
>>> > ---------------------------------------------------------------------------
>>> > TypeError                                 Traceback (most recent call
>>> > last)
>>> >
>>> > /home/ros/cpp_code/itkAdd/data/<ipython console> in <module>()
>>> >
>>> >
>>> > /media/sda5/home/ros/softwares/bio/SimpleITK/bin/SimpleITK-build/Wrapping/SimpleITK.pyc
>>> > in GetImageFromArray(arr)
>>> >     146     """Get a SimpleITK Image from a numpy array."""
>>> >     147
>>> > --> 148     return _SimpleITK._GetImageFromArray( arr )
>>> >     149
>>> >     150 class VectorBool(_object):
>>> >
>>> > TypeError: 'numpy.ndarray' does not have the buffer interface
>>> >
>>> >
>>> > Can somebody help me with this? Thank you.
>>> >
>>> > --
>>> > Regards,
>>> > Onti
>>> >
>>> > _____________________________________
>>> > 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://www.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-users
>>> >
>>
>>
>>
>>
>> --
>> Regards,
>> Onti
>
>
>
>
> --
> Regards,
> Onti


More information about the Insight-users mailing list