micro-manager / pymmcore

Python bindings for MMCore, Micro-Manager's device control layer
https://pypi.org/project/pymmcore/
GNU Lesser General Public License v2.1
32 stars 8 forks source link

getMultiROI appears broken in pymmcore swig #78

Closed tlambert03 closed 10 months ago

tlambert03 commented 10 months ago

the core void CMMCore::getMultiROI method populates 4 std::vector<unsigned>& with ROI info. The swig conversion doesn't appear to be working?

In [4]: core.getMultiROI([],[],[],[])
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[4], line 1
----> 1 core.getMultiROI([],[],[],[])

TypeError: in method 'CMMCore_getMultiROI', argument 2 of type 'std::vector< unsigned int,std::allocator< unsigned int > > &'
marktsuchida commented 10 months ago

Yep. Vector of unsigned is not mentioned in pymmcore_swig.i, so this probably never worked.

If I add the one-liner

     %template(LongVector)   vector<long>;
+    %template(UnsignedVector)   vector<unsigned>;
     %template(DoubleVector) vector<double>;

Then the following works.

xs = pymmcore.UnsignedVector()
ys = pymmcore.UnsignedVector()
ws = pymmcore.UnsignedVector()
hs = pymmcore.UnsignedVector()
core = pymmcore.CMMCore()
core.getMultiROI(xs, ys, ws, hs)

UnsignedVector converts to list with list(xs), etc.

Do you think this would be a good enough fix to wrap in pymmcore-plus?

tlambert03 commented 10 months ago

sure, can do