Fixes to gatan2 / SerialEM plugin - #170
Conversation
…updates by me. Co-authored-by: Jaedong Kang <jdkang0810@gmail.com>
|
@jdkang0810 This PR only concerns changes to the gatan2 camera; I'm still thinking if and how introduce the others. I modified your code quite a bit to match code style, also I'm annoying like that and like short lines and Judging by the state of this code, I doubt we have any active developers relying on |
This PR encapsulates several fixes performed by Jaedong Kang (@jdkang0810) from the Korea Advanced Institute of Science and Technology, who adapted current version of Instamatic to an FEI / Gatan Rio16 setup. The changes were reviewed, refactored, and mostly accepted by me. Text below comes from our e-mail exchange and was written by Jaedong and modified by me.
The changes were performed for Python 3.11+ while using SerialEMCCD/SEMCCD plugin(GMS 3.42) in DigitalMicrograph(DM 3.42.3048), leading to the following communication scheme: Instamatic → CameraGatan2 / GatanSocket → SerialEMCCD/SEMCCD plugin in DigitalMicrograph → Rio16.
Issues and changes
numpy.int_is 64-bit, whereas the Windows C long values expected by the SEMCCD socket protocol are 32-bit. This causes incorrect message lengths and errors such asCommand wrong length: needed=16 numBytes=104. Thus,gatansocket3.pywas modified to explicitly encode integers as 32-bit little-endian (<i4/np.int32).127.0.0.1.SERIALEMCCD_TIMEOUT, 10 seconds by default).camera_gatan2.pywas modified to favor a standard argument namebinsizerather thanbinning, though both are accepted [@jdkang0810 was subtle about it, but I added an explicit warning that use ofbinningis deprecated!].gatansocket3.pywas modified to receive images into a 1D bytearray first, followed by conversion to a uint16 NumPy array, making transfer more robust, particularly for the current Python version and larger Rio16 images.get_moviewas added tocamera_gatan2.pyto better integrate it with new code - Daniel]