|
| 1 | +Image acquisition |
| 2 | +================= |
| 3 | + |
| 4 | +The acquisition can become quite cumbersome due to many different cameras from various manufacturers installed on a microscope. |
| 5 | +Here we describe supported / tested cameras and explain how they can be controlled by ``pytemscript`` |
| 6 | + |
| 7 | +List of tested cameras: |
| 8 | + |
| 9 | + * Orius CCD (SC200W (830), SC200B (830)) |
| 10 | + * Ceta 16M |
| 11 | + * Ceta D |
| 12 | + * Falcon 3EC |
| 13 | + * Falcon 4(i) |
| 14 | + * K2 |
| 15 | + * K3 |
| 16 | + |
| 17 | +All methods described below return a 16-bit unsigned integer (equivalent to MRC mode 6) :meth:`~pytemscript.modules.Image` object. |
| 18 | +If movies are being acquired asynchronously, their format can be different. |
| 19 | + |
| 20 | +Standard scripting |
| 21 | +------------------ |
| 22 | + |
| 23 | +Gatan CCD cameras are usually embedded by TFS and can be controlled via standard scripting. This requires both Digital Micrograph |
| 24 | +and TIA to be opened as well as the current camera selected in the Microscope User Interface (CCD/TV camera panel). |
| 25 | + |
| 26 | +.. code-block:: python |
| 27 | +
|
| 28 | + microscope = Microscope() |
| 29 | + acq = microscope.acquisition |
| 30 | + img = acq.acquire_tem_image("BM-Orius", AcqImageSize.FULL, exp_time=1.0, binning=2) |
| 31 | +
|
| 32 | +.. warning:: If you need to change the camera, after doing so in the Microscope interface, you have to reconnect the microscope client since the COM interface needs to be reinitialised. |
| 33 | + |
| 34 | +For Gatan K2/K3 cameras (if they are embedded by TFS), standard scripting can only return unaligned average image, |
| 35 | +there are no options to acquire movies or change the mode (linear/counting). |
| 36 | +You can only modify binning or exposure time. |
| 37 | + |
| 38 | +TecnaiCCD plugin |
| 39 | +---------------- |
| 40 | + |
| 41 | +FEI has created their own plugin for Gatan CCD cameras. The plugin needs to be installed on Gatan PC inside Digital Micrograph. |
| 42 | +Digital Micrograph and TIA need to be opened as well as the current camera selected in the Microscope User Interface (CCD/TV camera panel). |
| 43 | +The advantage of this method over standard scripting is ~20 % speed improvement for both acquisition and image return, because the plugin |
| 44 | +interacts directly with Digital Micrograph and does not return the image to TIA. |
| 45 | + |
| 46 | +.. code-block:: python |
| 47 | +
|
| 48 | + microscope = Microscope(useTecnaiCCD=True) |
| 49 | + acq = microscope.acquisition |
| 50 | + img = acq.acquire_tem_image("BM-Orius", AcqImageSize.FULL, exp_time=1.0, binning=2, use_tecnaiccd=True) |
| 51 | +
|
| 52 | +SerialEMCCD plugin |
| 53 | +------------------ |
| 54 | + |
| 55 | +David Mastronarde has created a SerialEM `plugin <https://github.com/mastcu/SerialEMCCD>`_ to control both Gatan CCDs and advanced cameras like K2 or K3. |
| 56 | +The plugin has to be installed on Gatan PC inside Digital Micrograph, which is normally done during SerialEM installation. |
| 57 | +The connection to the plugin is established via a socket interface created by ``pytemscript`` (same way as Leginon does it). |
| 58 | +Digital Micrograph needs to be opened. SerialEM does not have to be running. |
| 59 | + |
| 60 | +The plugin provides multiple options for movie acquisition, frame alignment etc. |
| 61 | + |
| 62 | +.. warning:: In development, not available yet |
| 63 | + |
| 64 | +Advanced scripting |
| 65 | +------------------ |
| 66 | + |
| 67 | +This scripting interface was developed by TFS for their newer cameras like Ceta and Falcon. |
| 68 | +The currently supported cameras are Ceta 1, Ceta 2, Falcon 3 and Falcon 4(i). |
| 69 | +The interface includes new features like movie acquisition, counting mode, EER format etc. |
| 70 | +Movies are offloaded asynchronously to the storage server, while the returned image is an average (aligned or not). |
| 71 | + |
| 72 | +There's no need to open TIA or select the camera in the microscope interface. |
| 73 | + |
| 74 | +See details for :meth:`~pytemscript.modules.Acquisition.acquire_tem_image` |
| 75 | + |
| 76 | +.. code-block:: python |
| 77 | +
|
| 78 | + microscope = Microscope() |
| 79 | + acq = microscope.acquisition |
| 80 | + img = acq.acquire_tem_image("BM-Falcon", AcqImageSize.FULL, exp_time=5.0, binning=1, electron_counting=True, align_image=True, group_frames=2) |
| 81 | +
|
| 82 | +.. note:: Advanced scripting features like "Camera Electron Counting" and "Camera Dose Fractions" require separate licenses from TFS. |
| 83 | + |
| 84 | +Speed up the acquisition |
| 85 | +------------------------ |
| 86 | + |
| 87 | +By default, ``pytemscript`` will use `AsSafeArray` method to convert the COM image object to a numpy array via standard or advanced scripting. |
| 88 | +Depending on the image size this method can be very slow (several seconds). There's a trick to save the image object to a temporary file |
| 89 | +(`AsFile` COM method) and then read it, which seems to work much faster (up to 3x). However, this requires an extra `imageio` dependency for reading the temporary file. |
| 90 | + |
| 91 | +.. warning:: On some systems, saving to a file can fail with a COM error due to incomplete implementation, so you will have to stick to the default `AsSafeArray` method. |
| 92 | + |
| 93 | +If you want to try this method, add a couple of kwargs to your acquisition command: |
| 94 | + |
| 95 | +.. code-block:: python |
| 96 | +
|
| 97 | + microscope = Microscope() |
| 98 | + acq = microscope.acquisition |
| 99 | + img = acq.acquire_tem_image("BM-Falcon", AcqImageSize.FULL, exp_time=5.0, use_safearray=False, use_asfile=True) |
| 100 | +
|
| 101 | +
|
| 102 | +STEM acquisition |
| 103 | +---------------- |
| 104 | + |
| 105 | +STEM detectors have to be embedded by FEI and selected in the Microscope User Interface (STEM user panel). They are controlled by standard scripting. |
| 106 | + |
| 107 | +.. note:: Be aware that the acquisition starts immediately without waiting for STEM detectors insertion to finish. It's probably better to manually insert them first in the microscope interface. |
0 commit comments