pyelastix icon indicating copy to clipboard operation
pyelastix copied to clipboard

BufferError: memoryview: underlying buffer is not C-contiguous

Open andersenthomas opened this issue 6 years ago • 5 comments

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

andersenthomas avatar Nov 23 '18 23:11 andersenthomas

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

soupault avatar Sep 04 '19 17:09 soupault

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()

samtzai avatar Apr 01 '20 15:04 samtzai

Closed by #23

almarklein avatar Apr 02 '20 08:04 almarklein

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 [email protected] 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 .

samtzai avatar Apr 02 '20 10:04 samtzai

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.

almarklein avatar Apr 02 '20 12:04 almarklein