MMCorePy Outdated/Bugged Functions? (PI_GCS_2)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

MMCorePy Outdated/Bugged Functions? (PI_GCS_2)

Matt Southall
Greetings Friends!

The lab I work in has been using micromanager for years, but we finally had a need to move things over to python to wrestle some extra control from all our hardware.  I'm the guy doing that now. It's actually gone spectacularly save for one issue. 

I can connect to the MMCore, Serial Port, E-517/E-545 Controller, XYStage and ZStage just fine.  Each of these devices respond to setting changes and initialization. 

I can even move things in X&Y!
Core1.setXYPosition("XYStage",5.0,3.0)
Core1.setXYPosition("XYStage")
>>> [4.99, 3.0]


The Z axis is not as kind
Core1.setPosition("ZStage",5.0)
>>> NotImplementedError: Wrong number of arguments for overloaded function
'CMMCore_getPosition'.
  Possible C/C++ prototypes are:
    setPosition(CMMCore *,char const *,double)
    setPosition(CMMCore *,double)


I'm using the latest 2.0 build, but this seems to be an old problem that is surviving in some nooks and crannies of MMCorePy.  As far as I can see, Egor Zindy gets full credit for tackling this the first time and getting XYPosition working correctly.

In particular I tried some of the same attempted solutions that SteveF did in the first link above using ctype pointers.


Possibly related:  getPosition
Core1.getPosition("ZStage")
>>> CMMError: Error in device "ZStage": Unknown error in device (1)


I noticed that the Zstage has a 'Position' property setting where the XYStage does not, so I did try one more workaround. 
Core1.setProperty("ZStage","Position",5.0)
Core1.getProperty("Zstage","Position")
>>>  0.000
No Luck.

I have a functional relationship with python, but the design of _MMCorePy is a little above me, so I'm not sure I'll be able to follow in the footsteps of solving this one.  Any aid that can be provided on this would be greatly appreciated.

--Matt



_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: MMCorePy Outdated/Bugged Functions? (PI_GCS_2)

nanthony

Hi Matt,

 

I haven’t ever tried to use python the micromanager so there isn’t much I can do to help you. If no one gets back to you with a solution for this your best bet is to follow the instructions here: https://micro-manager.org/wiki/Building_MM_on_Windows#Building_MMCorePy

You can then build a `debug` version of the MMCorePy DLL. This will allow you to step through each line of code in the C++ code for MMcorePy. Once you can determine the exact line where things go wrong you will likely be able to get more help.

 

Hope that helps,

  Nick

 

From: Matt Southall <[hidden email]>
Sent: Wednesday, October 9, 2019 11:24 AM
To: [hidden email]
Subject: [micro-manager-general] MMCorePy Outdated/Bugged Functions? (PI_GCS_2)

 

Greetings Friends!

 

The lab I work in has been using micromanager for years, but we finally had a need to move things over to python to wrestle some extra control from all our hardware.  I'm the guy doing that now. It's actually gone spectacularly save for one issue. 

 

I can connect to the MMCore, Serial Port, E-517/E-545 Controller, XYStage and ZStage just fine.  Each of these devices respond to setting changes and initialization. 

 

I can even move things in X&Y!

Core1.setXYPosition("XYStage",5.0,3.0)

Core1.setXYPosition("XYStage")

>>> [4.99, 3.0]

 

 

The Z axis is not as kind

Core1.setPosition("ZStage",5.0)

>>> NotImplementedError: Wrong number of arguments for overloaded function
'CMMCore_getPosition'.
  Possible C/C++ prototypes are:
    setPosition(CMMCore *,char const *,double)
    setPosition(CMMCore *,double)

 

 

I'm using the latest 2.0 build, but this seems to be an old problem that is surviving in some nooks and crannies of MMCorePy.  As far as I can see, Egor Zindy gets full credit for tackling this the first time and getting XYPosition working correctly.

 

In particular I tried some of the same attempted solutions that SteveF did in the first link above using ctype pointers.

 

 

Possibly related:  getPosition

Core1.getPosition("ZStage")

>>> CMMError: Error in device "ZStage": Unknown error in device (1)

 

 

I noticed that the Zstage has a 'Position' property setting where the XYStage does not, so I did try one more workaround. 

Core1.setProperty("ZStage","Position",5.0)

Core1.getProperty("Zstage","Position")

>>>  0.000

No Luck.

 

I have a functional relationship with python, but the design of _MMCorePy is a little above me, so I'm not sure I'll be able to follow in the footsteps of solving this one.  Any aid that can be provided on this would be greatly appreciated.

 

--Matt

 



_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: MMCorePy Outdated/Bugged Functions? (PI_GCS_2)

Egor Zindy
In reply to this post by Matt Southall
Hi Matt,

sorry, I only have the demo stage to go on with, and quite an outdated version of MM 1.4, so take the following with a fistful of salt before I download the a nightly 2.0 gamma.

So with the demo camera hub / stage, this seems to work:

from __future__ import print_function
import MMCorePy
mmc = MMCorePy.CMMCore()
mmc.loadDevice('Stage', 'DemoCamera', 'DXYStage')
mmc.loadDevice('ZStage', 'DemoCamera', 'DStage')
mmc.initializeAllDevices()

#Uniaxis stage
print(mmc.getPosition('ZStage'))
mmc.setPosition('ZStage',5)
print(mmc.getPosition('ZStage'))

#XY stage
mmc.setXYPosition('Stage',10,10)
x = mmc.getXPosition('Stage')
y = mmc.getYPosition('Stage')
print(x,y)

#Interestingly, this works
mmc.setXYStageDevice('Stage')
print(mmc.getXYStageDevice())

#But this fails but sets the focus stage anyway? Please check at your end, maybe this is another (unrelated) bug we will need to fix in MMCorePy:
mmc.setFocusDevice('ZStage')

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "MMCorePy.py", line 4557, in setFocusDevice
    return _MMCorePy.CMMCore_setFocusDevice(self, *args)
MMCorePy.CMMError: Cannot set Core property Focus to invalid value "ZStage"

#Then try this:
print(mmc.getFocusDevice())

So what does this mean for you? What is the exact line you typed to load the ZStage device? Just so I know which one you're using...

The error you're reporting seems to suggest a conversion issue from a python float/double to a c++ double, possibly in SWIG:

The Z axis is not as kind
Core1.setPosition("ZStage",5.0)
>>> NotImplementedError: Wrong number of arguments for overloaded function
'CMMCore_getPosition'.
  Possible C/C++ prototypes are:
    setPosition(CMMCore *,char const *,double)
    setPosition(CMMCore *,double)

I'll compare whichever device you're trying to use in Python with the code for the democamera / stages

For now, this seems to work but crashes python because i can't initialise the device (really shouldn't do that!):
mmc.loadDevice('XYStage', 'PI_GCS_2', 'PIXYStage')

#crashes python, definitely shouldn't !!!!
mmc.getXYPosition('XYStage')


Then for the Z Stage, none of these work but don't crash Python:
>>> mmc.loadDevice('ZStage', 'PI_GCS_2', 'PIZStage')

>>> mmc.initializeAllDevices()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "MMCorePy.py", line 3467, in initializeAllDevices
    return _MMCorePy.CMMCore_initializeAllDevices(self)
MMCorePy.CMMError: Error in device "ZStage": No controller found with specified
name (112)
>>> mmc.getPosition("ZStage")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "MMCorePy.py", line 6110, in getPosition
    return _MMCorePy.CMMCore_getPosition(self, *args)
MMCorePy.CMMError: Error in device "ZStage": Unknown error in the device (1)
>>> mmc.setPosition("ZStage",5.0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "MMCorePy.py", line 6094, in setPosition
    return _MMCorePy.CMMCore_setPosition(self, *args)
MMCorePy.CMMError: Error in device "ZStage": Unknown error in the device (1)


Anyway, I'll download Nico's 2.0 Gamma https://valelab4.ucsf.edu/~MM/nightlyBuilds/2.0.0-gamma/Windows/https://valelab4.ucsf.edu/~MM/nightlyBuilds/2.0.0-gamma/Windows/ and try all the above with it. If you manage to try any of this at your end first, please report back!

Cheers,
Egor

From: Matt Southall [[hidden email]]
Sent: 09 October 2019 17:23
To: [hidden email]
Subject: [micro-manager-general] MMCorePy Outdated/Bugged Functions? (PI_GCS_2)

Greetings Friends!

The lab I work in has been using micromanager for years, but we finally had a need to move things over to python to wrestle some extra control from all our hardware.  I'm the guy doing that now. It's actually gone spectacularly save for one issue. 

I can connect to the MMCore, Serial Port, E-517/E-545 Controller, XYStage and ZStage just fine.  Each of these devices respond to setting changes and initialization. 

I can even move things in X&Y!
Core1.setXYPosition("XYStage",5.0,3.0)
Core1.setXYPosition("XYStage")
>>> [4.99, 3.0]


The Z axis is not as kind
Core1.setPosition("ZStage",5.0)
>>> NotImplementedError: Wrong number of arguments for overloaded function
'CMMCore_getPosition'.
  Possible C/C++ prototypes are:
    setPosition(CMMCore *,char const *,double)
    setPosition(CMMCore *,double)


I'm using the latest 2.0 build, but this seems to be an old problem that is surviving in some nooks and crannies of MMCorePy.  As far as I can see, Egor Zindy gets full credit for tackling this the first time and getting XYPosition working correctly.

In particular I tried some of the same attempted solutions that SteveF did in the first link above using ctype pointers.


Possibly related:  getPosition
Core1.getPosition("ZStage")
>>> CMMError: Error in device "ZStage": Unknown error in device (1)


I noticed that the Zstage has a 'Position' property setting where the XYStage does not, so I did try one more workaround. 
Core1.setProperty("ZStage","Position",5.0)
Core1.getProperty("Zstage","Position")
>>>  0.000
No Luck.

I have a functional relationship with python, but the design of _MMCorePy is a little above me, so I'm not sure I'll be able to follow in the footsteps of solving this one.  Any aid that can be provided on this would be greatly appreciated.

--Matt



_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general