[Insight-users] simpleitk error

Matt McCormick matt.mccormick at kitware.com
Wed Dec 21 22:02:43 EST 2011


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
>


More information about the Insight-users mailing list