How to create custom software solutions for the Phenom desktop SEM

By Wouter Arts - Apr 12, 2018

In many cases, the Phenom SEM is used in industrial and academical applications that require repetitive work, such as acquiring a set of images at pre-set locations. In other cases, it is necessary to scan the entire surface of a sample to find a single particle and record its location and dimensions. This kind of workflow can be automated to increase not only throughput but also efficiency and accuracy. Furthermore, because automated scripts always follow the exact same procedure, the results become more repeatable, and the subjective human interpretation is removed.

In this, and many other cases, the Phenom Programming Interface (PPI) can be used to automate this work. In this blog we explain what PPI is and how it can be used to integrate the Phenom SEM into your workflow.

 

The Phenom Programming Interface

The Phenom Programming Interface is a package that enables the Phenom SEM to be controlled through Python. Python is an easy-to-learn programming language that runs scripts without compiling. A script is simply a list of commands that are sent to the Phenom SEM to perform tasks that are typically done by an operator. The PPI package contains a library of all the functions that are necessary to control the Phenom with Python.

The PPI Python scripts run on any PC that is connected to a Phenom through a network. This means that not only can the Phenom SEM be controlled by the computer placed next to it, but also remotely, if it is more convenient for the user. Figure 1 shows the general set-up of the network between the Phenom SEM and the user PC, where PPI is installed to allow Python scripts to be run.

PPI

Fig. 1: Connection between the Phenom PC and the user PC, where PPI is installed.

What can you do with PPI?

PPI can be used for all tasks that are necessary to integrate the Phenom into an automated workflow. In automation, it is important to check and set all settings to their desired values, for instance the beam acceleration voltage or the beam spot size.

In PPI, the current state of the microscope can be queried: from the position of the stage to the current beam settings and working distance. All the steps that are necessary to take high quality and repeatable images are also available in PPI: these steps include functions like autofocus and auto contrast/brightness.

PPI is also fully compatible with many popular image processing tools in Python to process your images and extract the desired results. The combination of PPI with these tools makes it a very powerful tool to integrate the Phenom into your workflow, and to get fast and reliable results.

What does a PPI script look like?

To demonstrate what a PPI script looks like, an example is given in Figure 2. This script assumes that the sample is loaded into the SEM part of the Phenom and completes the following actions:

  • Import PPI into Python
  • Connects to the Phenom
  • Sets the beam settings
  • Automatically focuses and optimizes the contrast and brightness
  • Acquires an image
  • Moves the stage to another position
  • Acquires a second image.

To get the PPI functionalities into Python, the PPI package must be loaded into your Python script. This is done according to the default Python conventions: import PyPhenom as ppi.

Connecting to the Phenom is as simple as creating an object called phenom with the call ppi.Phenom. In this call, the connection to the Phenom is set up and the PPI license is verified. All the other steps are methods of this created object.

The settings that are available in the graphical user interface can be changed with a single command in PPI. For example, in Figure 2 we change the beam settings to 10 kV and the spot size to Image (which is equivalent to 3.3).

The image optimization options are also available in a single call. To bring the image into perfect focus the method SemAutoFocus is available and the contrast and brightness are optimized by using the SemAutoContrastBrightness method.

To acquire a SEM image the method SemAcquireImage is used. In this method the properties of the image must be filled in. In our example, the image is acquired with a resolution of 1024 by 1024 pixels and the image is averaged over 16 frames. The image can be stored on the local drive by using the ppi.Save command.

To move the stage relative to its current position, the ppi.MoveBy command is used. Here the displacement in x-directions and y-directions is given in meters. This means that in our example the stage moves 100 µm to the left and 100 µm down. Once in this new position another image is acquired and saved.

This example shows just how easy and intuitive PPI is. However, PPI is far more powerful and can do a lot more than is shown here. PPI has all the commands that the user interface has and even some more.

 

PPI example

Fig. 2: Example of a simple PPI script

Beyond PPI

Controlling the Phenom with PPI is very powerful and efficient, but PPI has more capabilities than that. The images taken with PPI are compatible with NumPy. NumPy is a Python package for array manipulation and is used in many image processing tools like OpenCV. OpenCV is a widely used library of functions for image processing and image recognition. The combination of PPI and tools like OpenCV allows users to create very advanced scripts that could, for example:

  • Automatically scan the surface of a sample and detect defects;
  • Find a specific object on a sample and image it at high magnification;
  • Determine properties like dimensions of a structure, coverage on a surface, porosity of a sample, and many more.

In Figure 3, you can see an example of how to convert a PPI image to a NumPy array and how to use it in OpenCV. To be able to use NumPy and OpenCV (cv2), they need to be loaded into your Python script in a very similar way to how PPI is loaded. The connection to the Phenom is set up as shown in the previous example.

The image is acquired again with SemAcquireImage and converted to a NumPy array with np.array. Since the image is now in a NumPy format, it can be used in OpenCV. As an example, an edge detection filter called Canny Edge is used here. It simply works by calling it and inserting the filter parameters into the method. The cannyEdge variable now holds an image with the detected edges of the original image.

This example demonstrates that PPI is directly compatible to NumPy and all the packages that use NumPy arrays as input, such as OpenCV. NumPy and OpenCV are very powerful tools and are used for many image processing applications, all the way up to self-driving cars. So, when it comes to how you use it, the only limitation is your imagination.

example-conversion-numpy-array-use-opencv

Fig. 3: Example of conversion to NumPy array and the use of OpenCV

Explore Phenom SEM automation even further

As you can clearly see from these examples, PPI helps integrating your Phenom SEM into your workflow. The compatibility of PPI with many image processing packages enables the users to create tools for in-depth analysis of their samples.

Curious about how a Phenom SEM with PPI can speed up your image acquisition process and sample analysis? Then you’ll find the Phenom Programing Interface specification sheet useful. Download the spec sheet here:

Download your Phenom Programming Interface sheet

P.S. If you don’t have the capacity to create scripts in-house, we have the Phenom Process Automation (PPA) service. It can provide you with a custom-made solution to integrate the Phenom SEM into your workflow. Talk to one of our SEM experts to learn how. 


About the author

Wouter Arts is Application Software Engineer at Thermo Fisher Scientific, the world leader in serving science. He is interested in finding new smart methods to convert images to physical properties using the Phenom desktop SEM. In addition, he develops scripts to help companies in using the Phenom desktop SEM for automated processes.

Press Room | Privacy Policy | Terms of Use | Sitemap