almarklein / pyelastix

Thin wrapper around elastix - a toolbox for rigid and nonrigid registration of images
MIT License
103 stars 31 forks source link

BufferError: memoryview: underlying buffer is not C-contiguous #14

Open andersenthomas opened 5 years ago

andersenthomas commented 5 years ago

I'm getting "BufferError: memoryview: underlying buffer is not C-contiguous" when running pyelastix.register on two numpy arrays. Any ideas?

soupault commented 5 years ago

Try to use numpy.ascontiguousarray beforehand - https://docs.scipy.org/doc/numpy/reference/generated/numpy.ascontiguousarray.html. We need to sanitize the inputs, anyway.

samtzai commented 4 years ago

Even if you use np.ascontigousarray beforehand, you can get that error on writing the data file, specially for huge images. pyelastix code should convert the array into contigous before writting the image back:#

Write data file f = open(fname_raw, 'wb') try: f.write(im.data) except: f.write(np.ascontiguousarray(im.data)) finally: f.close()

almarklein commented 4 years ago

Closed by #23

samtzai commented 4 years ago

Thanks Almar,

Remember that you still need to make the input arrays contiguous. I only updated the output array

On Thu, Apr 2, 2020, 10:00 AM Almar Klein notifications@github.com wrote:

Closed #14 https://github.com/almarklein/pyelastix/issues/14.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/almarklein/pyelastix/issues/14#event-3191019531, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF5BPMGT6ZNVP4KROVTHSJ3RKRA3VANCNFSM4GGEW7MA .

almarklein commented 4 years ago

Remember that you still need to make the input arrays contiguous. I only updated the output array

Thanks for the clearification @samtzai! Let's re-open.