Potential bug in OughtaFocus code

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Potential bug in OughtaFocus code

BenjaminPelz
Hi everyone,

I've been using the autofocus plugin with OughtaFocus quite a bit lately in
combination with MDAs and realized that there is a potential bug which
causes unwanted stage movement at the end of the MDA. This is present in the
MM 1.4 nightlies as well as in the 2.0 beta nightly.
The bug occurs when you run the autofocus from the normal MM interface and
then move the z-stage before starting the MDA. The autofocusing works
normally during the MDA but at the end of the acquisition the z-stage starts
to move to the position where one manually triggered the autofocus.
Depending how far the position is from the current one, the stage reaches
the position and stops or turns around on the way and goes back to position
which was set before the MDA.
I recreated the problem also with the demo configuration and the 2.0 nightly
(2.0.0-beta3 20170914):
Using the Stage Control plugin I move the z-stage to 100um. I press the
autofocus button in the MM interface and the stage moves to 96.9um. CoreLog:
2017-09-19T14:20:29.616717 tid3324 [IFO,App] OughtaFocus: image=1, t=464,
z=98.09, score=0.10, Tz=1, Ti=104, Tc=48
2017-09-19T14:20:29.616717 tid3324 [dbg,Core] Will start absolute move of Z
to position 96.90983 um

Using the Stage Control plugin I move the z-stage to 50.09um. And run a MDA
with 2 channels and autofocus activated. At the end of the acquisition the
CoreLog reports:
2017-09-19T14:22:39.347750 tid15336 [dbg,App] [AE] END acquire
2017-09-19T14:22:39.347750 tid15336 [dbg,App] [AE] ##### END acquisition
event
2017-09-19T14:22:39.348753 tid15336 [dbg,App] [AE] cleanup
2017-09-19T14:22:39.352766 tid15336 [dbg,App] [AE] <-- (.
org.micromanager.mm/mmc isSequenceRunning)
2017-09-19T14:22:39.353769 tid15336 [dbg,App] [AE] --> false
2017-09-19T14:22:39.358779 tid15336 [dbg,App] [AE] <-- (.
org.micromanager.mm/mmc getSystemStateCache)
2017-09-19T14:22:39.359783 tid15336 [dbg,App] [AE] --> #<Configuration
mmcorej.Configuration@6ce5d155>
2017-09-19T14:22:39.378834 tid15336 [dbg,App] [AE] <-- (.
org.micromanager.mm/mmc waitForDevice "Emission")
2017-09-19T14:22:39.378834 tid15336 [dbg,Core] Waiting for device
Emission...
2017-09-19T14:22:39.378834 tid15336 [dbg,Core] Finished waiting for device
Emission
2017-09-19T14:22:39.380838 tid15336 [dbg,App] [AE] --> nil
2017-09-19T14:22:39.393873 tid15336 [dbg,App] [AE] <-- (.
org.micromanager.mm/mmc setProperty "Emission" "State" "0")
2017-09-19T14:22:39.393873 tid15336 [dbg,Core:dev:Emission] Will set
property "State" to "0"
2017-09-19T14:22:39.393873 tid15336 [dbg,Core:dev:Emission] Did set property
"State" to "0"
2017-09-19T14:22:39.396882 tid15336 [dbg,App] [AE] --> nil
2017-09-19T14:22:39.398886 tid15336 [dbg,App] [AE] <-- (.
org.micromanager.mm/mmc waitForDevice "Z")
2017-09-19T14:22:39.398886 tid15336 [dbg,Core] Waiting for device Z...
2017-09-19T14:22:39.398886 tid15336 [dbg,Core] Finished waiting for device Z
2017-09-19T14:22:39.400891 tid15336 [dbg,App] [AE] --> nil
2017-09-19T14:22:39.404902 tid15336 [dbg,App] [AE] <-- (.
org.micromanager.mm/mmc setProperty "Z" "Position" "96.9098")
2017-09-19T14:22:39.404902 tid15336 [dbg,Core:dev:Z] Will set property
"Position" to "96.9098"
2017-09-19T14:22:39.404902 tid15336 [dbg,Core:dev:Z] Did set property
"Position" to "96.9098"
2017-09-19T14:22:39.405905 tid15336 [dbg,App] [AE] --> nil
2017-09-19T14:22:39.408914 tid15336 [dbg,App] [AE] <-- (.
org.micromanager.mm/mmc waitForDevice "Excitation")
2017-09-19T14:22:39.408914 tid15336 [dbg,Core] Waiting for device
Excitation...
2017-09-19T14:22:39.408914 tid15336 [dbg,Core] Finished waiting for device
Excitation
2017-09-19T14:22:39.409916 tid15336 [dbg,App] [AE] --> nil
2017-09-19T14:22:39.414941 tid15336 [dbg,App] [AE] <-- (.
org.micromanager.mm/mmc setProperty "Excitation" "State" "0")
2017-09-19T14:22:39.414941 tid15336 [dbg,Core:dev:Excitation] Will set
property "State" to "0"
2017-09-19T14:22:39.414941 tid15336 [dbg,Core:dev:Excitation] Did set
property "State" to "0"
2017-09-19T14:22:39.415932 tid15336 [dbg,App] [AE] --> nil
2017-09-19T14:22:39.420945 tid15336 [dbg,App] [AE] <-- (.
org.micromanager.mm/mmc setAutoShutter true)
2017-09-19T14:22:39.421948 tid15336 [dbg,Core] Autoshutter turned on
2017-09-19T14:22:39.421948 tid15336 [dbg,App] [AE] --> nil
2017-09-19T14:22:39.428966 tid15336 [dbg,App] [AE] <-- (.
org.micromanager.mm/mmc getCameraDevice)
2017-09-19T14:22:39.428966 tid15336 [dbg,App] [AE] --> Camera
2017-09-19T14:22:39.436988 tid15336 [dbg,App] [AE] <-- (.
org.micromanager.mm/mmc waitForDevice "Z")
2017-09-19T14:22:39.436988 tid15336 [dbg,Core] Waiting for device Z...
2017-09-19T14:22:39.436988 tid15336 [dbg,Core] Finished waiting for device Z
2017-09-19T14:22:39.438000 tid15336 [dbg,App] [AE] --> nil
2017-09-19T14:22:39.440998 tid15336 [dbg,App] [AE] <-- (.
org.micromanager.mm/mmc setPosition "Z" 50.09016994374947)
2017-09-19T14:22:39.440998 tid15336 [dbg,Core] Will start absolute move of Z
to position 50.09017 um

So at first he sets the old z-position of 96.9098 and afterwards the right
z-position of 50.09um. For our Zeiss microscope this causes real stage
movement in z and resulted in the objective hitting our sample and
destroying it. Looking at the code of OughtaFocus I think that line 170 is
the problem: core.SetSystemState(oldState);
Which apparently is setting an old system state which is not the one at the
beginning of the MDA. I tried commenting out the line and it fixed the
problem but I'm not sure if it will cause any other problems.

Sorry for the long text, it was hard to explain. Can anybody confirm this?

Best
Benjamin



--
Sent from: http://micro-manager.3463995.n2.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general