Leginon with Gatan K2
Added by Bob Grassucci over 12 years ago
Does Leginon work with the Gatan K2 Summit direct electron detector camera? Thanks.
Bob
Replies (19)
RE: Leginon with Gatan K2 - Added by Anchi Cheng over 12 years ago
We got this question in the last few weeks a lot : ) It must be close to the delivery time.
We've just started getting information on the needed documentation and SDK from Gatan. We do plan to add the K2 to the set of Leginon compatible cameras and will let you know as soon as we have some idea of how long this might take (as we do not have one of our own it will take some off-site testing).
Anchi
RE: Leginon with Gatan K2 - Added by Bob Grassucci over 12 years ago
Ours was just delivered and once it is installed we would be happy to have you visit and do any testing you need.
Bob
RE: Leginon with Gatan K2 - Added by Bob Grassucci about 12 years ago
How are things going with getting Leginon operational with the K2 cameras? Please let us know if there is anything we can do to help out on our end. Thanks.
Bob
RE: Leginon with Gatan K2 - Added by Jim Pulokas about 12 years ago
The summer travels are over, so this gets bumped to top priority now. I have a way to test it here using a K2 simulation, and I will let you know when I have something for you to test on the real thing.
Jim
RE: Leginon with Gatan K2 - Added by Bob Grassucci about 12 years ago
Great! We look forward to trying it out. Thanks again
Bob
RE: Leginon with Gatan K2 - Added by Bob Grassucci about 12 years ago
Hi Jim,
Do you have something for us to test yet? Any sort of time frame you can estimate would be helpful. Thanks.
Bob
RE: Leginon with Gatan K2 - Added by Jim Pulokas about 12 years ago
We are working on adapting the SerialEM plugin for the K2 to be used by Leginon. If all goes well, we may have it ready within a week. I will keep you posted.
Jim
RE: Leginon with Gatan K2 - Added by Jim Pulokas about 12 years ago
Bob,
I wonder if you can test something for me. We are trying out two different Gatan plugins, one from SerialEM and one from UCSF. I am starting with the one from UCSF and getting an error when trying it with K2 simulation. I am hoping that the real camera may work better.
To try it out...
The UCSF plugin dll is attached here. Copy it to c:\Program Files\Gatan\Plugins\. Then open a command line (cmd.exe) and register the dll. If you are not logged in as an administrator, be sure to right click cmd.exe and "run as administrator". Then register with the following commands:
cd c:\Program Files\Gatan\Plugins regsvr32 UcsfCCD.dllThat should respond with a message of success. Now install the 64 bit versions of Python and the Python win32 extention (I link to python 2.7, but use whatever version you want):
- http://python.org/ftp/python/2.7.3/python-2.7.3.amd64.msi
- http://sourceforge.net/projects/pywin32/files/pywin32/Build%20217/pywin32-217.win-amd64-py2.7.exe/download
Again, make sure you are installing the amd64 versions.
Not sure if a reboot is really necessary at this point, but it can't hurt.
Now test if python can talk to the UCSF plugin. Start DM and make sure you can acquire an image from the K2 with that, then leave DM running for the python test. Open a python command line (or save to a python script) and try the following, or modified to your own preference as far as camera configuration:
from win32com.client import Dispatch cam = Dispatch('UcsfCCD.GatanCamera') cam.BinningX = 1 cam.BinningY = 1 cam.Exposure = 0.2 cam.ImageTop = 0 cam.ImageLeft = 0 cam.ImageBottom = 1024 cam.ImageRight = 1024 image = cam.AcquireRawImage()It works for me in the simulator until the last line, AcquireRawImage fails with no description of why. Can you get it to acquire an image?
Thanks,
Jim
UcsfCCD.dll (277 KB) UcsfCCD.dll | DigitalMicrograph plugin from UCSF |
RE: Leginon with Gatan K2 - Added by Bob Grassucci about 12 years ago
Hi Jim,
I did the install as you requested and tried running a python command as you wrote. I am attaching snapshot of error setting ImageBottom and ImageBottom.
Bob
PythonError.jpg (84.3 KB) PythonError.jpg | Pyhton Error |
RE: Leginon with Gatan K2 - Added by Bob Grassucci about 12 years ago
Hi Jim,
I noticed I had a typo in my previous attempt. I edited the script and tried to run it. It crashed DM and I was forced to close and reopen DM.
Bob
RE: Leginon with Gatan K2 - Added by Bob Grassucci about 12 years ago
Hi Jim,
I ran the script line by line and it crashes DM on the last line
image = cam.AcquireRawImage()
I am attaching a screen shot of the python command window.
Please let me know if you have anything else to test.
Bob
PythonError2.jpg (115 KB) PythonError2.jpg |
RE: Leginon with Gatan K2 - Added by Jim Pulokas about 12 years ago
Bob,
I have a small example plugin for you to test. Here is the procedure:
- be sure to have Python (64 bit version) already installed
- install the attached comtypes python package
- unzip it (note for the next step: it creates a comtypes folder inside a comtypes folder)
- open windows command terminal and install comtypes
cd [location where you unzipped comtypes, should be a setup.py inside it] C:\python27\python.exe setup.py install
- copy the attached plugin, COMExamplePlugIn.dll, into C:\Program Files\Gatan\Plugins\
- As administrator, open windows command terminal and register the plugin:
regsvr32 C:\Program Files\Gatan\Plugins\COMExamplePlugIn.dll
- Start DigitalMicrograph and be sure you can acquire an image from K2.
- copy the attached python script, comexample.py, to the Desktop or anywhere and run it.
If it successfully acquires an image, it will give you a very short output that says
acquired image size 512x512 press enter to quit.
If it fails to give that message and just quits with no message, copy comexample.py to C:\python27\Lib\site-packages\, then import it directly into a python command line and test:
import comexample comexample.test()That will hopefully allow you to see any exceptions that are raised.
Let me know how that works.
Jim
comtypes-0.6.2.zip (147 KB) comtypes-0.6.2.zip | comtypes python package | ||
COMExamplePlugIn.dll (324 KB) COMExamplePlugIn.dll | COM example plugin DLL for DigitalMicrograph | ||
comexample.py (747 Bytes) comexample.py | python script to test comtypes communication to example plugin |
RE: Leginon with Gatan K2 - Added by Bob Grassucci about 12 years ago
Hi Jim,
I tried the setup.py install and got an error. See attached screen shot. What next?
Bob
PythonError3.jpg (107 KB) PythonError3.jpg |
RE: Leginon with Gatan K2 - Added by Jim Pulokas about 12 years ago
Our K2 install is delayed until next week, but I have made progress on getting an image from the simulation.
Sorry to keep leading you in different directions, but we are going to go back to the UcsfCCD.dll trial from a few messages ago. I have modified UcsfCCD.dll, so please copy the attached UcsfCCD.dll to the plugins folder as descibed previously (overwrite or remove the old one). Also register again with regsvr32 as described.
Next, install the two additional attachments: numpy and NumpySafeArray
Now start or restart DigitalMicrograph and try the following test from python, similar to the previous test, with some additional lines:
from win32com.client import Dispatch import NumpySafeArray.NumpySafeArray cam = Dispatch('UcsfCCD.GatanCamera') cam.BinningX = 1 cam.BinningY = 1 cam.Exposure = 0.2 cam.ImageTop = 0 cam.ImageLeft = 0 cam.ImageBottom = 1024 cam.ImageRight = 1024 NumpySafeArray.NumpySafeArray.call(cam, 'AcquireRawImage')
If sucessful, you should see an image array returned from the final command.
UcsfCCD.dll (240 KB) UcsfCCD.dll | UcsfCCD.dll, modified to work with comarray | ||
numpy-unoptimized-1.6.2.win-amd64-py2.7.exe (2.48 MB) numpy-unoptimized-1.6.2.win-amd64-py2.7.exe | numpy 64 bit version | ||
NumpySafeArray-1.0.0.win-amd64-py2.7.exe (224 KB) NumpySafeArray-1.0.0.win-amd64-py2.7.exe | package to get safearray into numpy array |
RE: Leginon with Gatan K2 - Added by Bob Grassucci about 12 years ago
Hi Jim,
I got a new error. It can not seem to find NumpySafeArray.NumpySafeArray
I have attached a screen shot.
Bob
PythonError4.jpg (238 KB) PythonError4.jpg |
RE: Leginon with Gatan K2 - Added by Bob Grassucci about 12 years ago
Here is some additional information showing:
1. Python Path
2. Installed shared library
3. That it cannot be imported (says: not found)
PythonError4add.jpg (394 KB) PythonError4add.jpg |
RE: Leginon with Gatan K2 - Added by Jim Pulokas about 12 years ago
Sorry... my hacked together packages require some tweaking. Find the installed python module, C:\Python27\Lib\site-packages\NumpySafeArray\NumpySafeArray.pyd and copy it up one level in the the site-packages folder. Then remove the NumpySafeArray folder. The python script will then be easier: just import and use NumpySafeArray instead of NumpySafeArray.NumpySafeArray.
RE: Leginon with Gatan K2 - Added by Bob Grassucci about 12 years ago
Hi Jim,
We added a print statement to the script and got the following but no image. See screen capture. Progress?
Bob and Rob
Python_Print.jpg (215 KB) Python_Print.jpg |
RE: Leginon with Gatan K2 - Added by Jim Pulokas about 12 years ago
You will not see the image, but that is an image array coming out of the camera. Definitely good news. I am working on the final pyscope module so you will be able to try this from Leginon and then see the images.
Jim