Just an idea.
We can use numpy.frombuffer() to share data between C++ and python (e.g., for ProjDataInMemory). I think all that needs to be done is pass the address of begin to the python level. No idea how to do that with your wrapper, though, @evgueni-ovtchinnikov. Any ideas?
https://github.com/SyneRBI/SIRF/pull/717
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.![]()
@evgueni-ovtchinnikov commented on this pull request.
In src/xSTIR/pSTIR/STIR.py.in:
> + buffer = ? + try_calling(pystir.cSTIR_AcquisitionDataInMemory_get_buffer\ + (self.handle, buffer)) + array = numpy.frombuffer(buffer, dtype=numpy.float32)
I do not see how this can possibly work. However you define buffer, pystir.cSTIR_AcquisitionDataInMemory_get_buffer can only give you an address in memory, but numpy.frombuffer needs to know the size of memory represented by the buffer to be able to handle that memory as numpy array data.
@rijobro commented on this pull request.
In src/xSTIR/pSTIR/STIR.py.in:
> + buffer = ? + try_calling(pystir.cSTIR_AcquisitionDataInMemory_get_buffer\ + (self.handle, buffer)) + array = numpy.frombuffer(buffer, dtype=numpy.float32)
I haven't done it here, but you can give the number of elements with count:
numpy.frombuffer(buffer, dtype=float, count=-1, offset=0)
And obviously we know how many elements our sinogram contains.
@rijobro commented on this pull request.
In src/xSTIR/pSTIR/STIR.py.in:
> + buffer = ? + try_calling(pystir.cSTIR_AcquisitionDataInMemory_get_buffer\ + (self.handle, buffer)) + array = numpy.frombuffer(buffer, dtype=numpy.float32)
The problem is that the first argument to frombuffer should be of type buffer_like (see here). I have no idea how to do this, but the address to the first float in C++ somehow needs to be converted to this buffer_like object in Python. Searching online, it looks like it's possible with SWIG, but I'm not sure how to do it in SIRF's setup.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
resolved by all our asarray() updates
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()