Project

General

Profile

Microscope Stage can not be moved by Leginon after upgrade

Added by Anchi Cheng over 11 years ago

This is a very interesting problem at UCLA.

History:

  • Microscope computer had python 2.5 installed and Leginon was running on it previously on 2.2 version.
  • Mircoscope has FEI Tomography software installed and running.

Start of the problem:

  • python 2.7 was installed on the same computer and Leginon upgraded along with other prerequisite.

Symptom:

  • Could not move stage position through Leginon nor lower level direct pyscope test python script:
    from pyscope import tecnai
    t = tecnai.Tecnai()
    t.setStagePosition({'x':5e-4})
    t.setStagePosition({'x':0.0}
    

    This script should make the stage move in x direction to 500 um from the center and then move back to 0.

The odd thing was that "image shift" could still be move through Leginon and pyscope, meaning TEM Scripting.

Mystery solved at the end:

During the upgrade, updatecom.py was not run on the computer. Since this is saved under site-packages of the particular python version, the use of python 2.7 instead of python 2.5 means that updatecom.py need to be rerun with python 2.7.


Replies (2)

RE: Microscope Stage can not be moved by Leginon after upgrade - Added by Anchi Cheng over 11 years ago

Here is Jim's pointer that helped to solve the mystery:

....Also, can you
find a file on the Krios computer and send it to us.  The file will be
found in:
C:\Python27\Lib\site-packages\win32com\gen_py\BC0A...py
(I have abbreviated the name, it is a very long name, but is the only .py
file that starts with BC0A in that folder.

That file is generated by updatecom.py for TEMScripting. If it was generated but stage position still did not move, it would mean some definition changed. We would have needed the file sent to us to figure out what has changed in TEMScripting.

RE: Microscope Stage can not be moved by Leginon after upgrade - Added by Jim Pulokas over 11 years ago

Here are some details on why image shift (and other functions) worked but not stage position, and also an idea for avoiding this in the future:

In TEM scripting, the image shift function takes the x and y shift values as arguments. In the stage position function, you have to give it the distance values, but also have to tell it which axes you are moving. Which axes to use are specified using some constants that are defined in TEM scripting. For example, "axisX" is a constant that declares to move the X axis. From python, we cannot use the name of the constant, but have to pass the numerical value of the constant to the function. The mapping of name to value is not known dynamically, but defined in the script that is created in gen_py, and accessed in python using the win32com.client.constants module.

Any other functions that require constants defined in TEM scripting will suffer the same problem if no gen_py script exists. I see several functions in tecnai.py that require constants, but most of them are rarely used, like setting low dose mode, normalizing lenses, etc.

It would be possible to get rid of the requirement to run updatecom.py and generate the gen_py scripts, and instead have each individual pyscope module generate its own gen_py module. So for example when you import tecnai.py, it would then run the makepy.py function that generates the gen_py script. However, the nice thing about doing updatecom.py during installation is that it immediately determines if you are missing the scripting interface for the scope or camera that you have.

    (1-2/2)