Table of Contents


stemfind - Finds patterns in STEM images produced by ELDICO system


stemfind [ -h (--help) ] [ --location ] [ -A (--ai) ] [ -b (--scaleBar) ] [ -D (--debug) code ] [ --db FILE ] [ -f (--file) FILE ] [ -F (--force) ] [ --fov FOV ] [ --gx|sx|sz ] [ -i (--invert) ] [ --min MINCOLOR ] [ --max MAXCOLOR ] [ -L (--loglevel) LEVEL ] [ -M (--meshes) ] [ -N (--pin) ] [ -P (--particles) ] [ -R (--reduce) ] [ -r (--results) FILE ] [ -p (--plot) ] [ --png ] [ --pmin SIZE ] [ --pmax SIZE ] [ -x (--x) NX ] [ -y (--y) NY ] [ -Y (--y0) ] [ -s (--size) SIZE ] [ --scale SCALE ] [ --tiff ] [ -u (--update) ] [ -v (--verbose) ] [ -V (--VERSION) ] [ file ]


stemfind is a program to find specific patterns in a STEM image. Currently the program implements particles, alignment pins, grids and meshes. When looking for a particle (default), the program determines the centroid of a blob closest to the vertical center (y=0) or closest to the physical center of the image. For a pin (or needle) the program determines its tip. When using a grid, the program finds meshes in it. When using a mesh, the program tries to locate several particles in it. In either case, the program prints x,y-coordinates as result plus some further stats. The program can produce an output png or tiff file with a cross-marker at the resulting x,y-coordinates. The program accepts TIFF-files as input or plain ASCII data with X*Y pixels.


-A (--ai)
Use AI methods to locate particles. AI should not be used for finding meshes but only particles in a mesh. AI requires availability of a trained model which must be supplied via a configuration file or via the command line. The program makes use of "Segment Anything" supplied by Meta Labs.
-b (--scaleBar)
Burn a small scale bar in upper left corner of image on output
--db MODEL
Model to use when running AI.
-o (--out) NAME
Name of output file. This option is valid only with option --png and only for single image processing.
-f (--file) FILE|DIR
If a single file is given, only this file will be processed. If the argument is a directory, all files with extension ".tiff" and ".report" will be taken.
-h (--help)
Prints a summary of program command line options.
-F (--force)
Force reprocessing even if the TIFF-header already contains an entry with the results.
Program stemfind can be used on a series of STEM images in order to derive missets of goniometer axes GONIO:X, SAMPLE:X and SAMPLE:Z. For the calculation, the direction of the motors matters. With either option --gx, --sx, --sz the direction of the motors can be inverted. To invert the directions of all motors, option --invert (-i) is available.
-x (--x) NX
Horizontal dimension of images.Not required when using TIFF files.
-y (--y) NY
Vertical dimension of images. See -x NX.
-N (--pin)
Try to find the tip of a pin. By default, the program looks for particles.
-M (--meshes)
Try to find the meshes in a grid. The program writes center coordinates of all located meshes into the TIFF file header.
-P (--particles)
Try to find the particles in a mesh. The program writes center coordinates of all located particles into the TIFF file header. This is the default.
Create output file in png format with a marker at the x,y-coordinates of the processing results.
--pmin SIZE
Minimum size of a particle in blob locator. Default: 0.1 um
--pmax SIZE
Maximum size of a particle in blob locator. Default: 4.0 um
-p (--plot)
When processing a series of images, show the results of x,y in a 2D-plot. Requires Python matplotlib to work.
-R (--reduce)
Applies only to AI: reduce the input image to black&white before applying AI methods to locate particle. Default: don’t reduce.
-r (--result) FILE
When processing a series of images, the program will create an ASCII file and write data into that file, that can easily be used by plotting routines. The program write lines with the title and subtitle, followed by an array of x-axis data (PHI position), y-axis data (observed deviations of x from center of image), a fitted line through y-axis data, and a fitted line for x-axis data.
-s (--size) SIZE
Maximum size of particle. Default: 20.0 pixels
--scale SCALE
Factor to apply to all input values. Default: 1.0
Create output file in tiff format with a marker at the x,y-coordinates of the processing results. This option works only when using ".report" files as input files and not tiff files.
-u (--update)
By default, TIFF-headers will be updated with processing results. To turn this off, use option -u.
-v (--verbose)
Increases verbosity level for more program output.
Only show program version and exit.
All remaining arguments are considered to be input-file names. Wildcards allowed.

Input Files

TIFF-files or ASCII ".report" files with STEM data from ELDICO system.

Configuration File

The program reads configuration files from the following locations in the given order (in parenthesis: Windows)
current_working_directory/stemfind.cfg (stemfind.ini)
$HOME/.stemfind.cfg (%HOME%\stemfind.ini)

Entries given in the next available file will override all previous entries. This allows for mixing entries that can be changed by the user with entries set by a system administrator. In section [stemfind], the program accepts the following parameters:

Name of the file containing the trained model when using AI. There is a variety of models that differ in size and complexity. Depending on the choosing model, the processing time and success rate varies. For prractical usage in short time, the small FastSAM-s model already gives good results and it does not seem necessary to go for the larger sized vit_b/l/h models provided by Meta.
Default: sam_db=


Claudio Klein, MarXperts GmbH, Norderstedt, Germany.


© Copyright 2021-2023 Marxperts GmbH, Norderstedt, Germany


MarXperts GmbHPhone: +49 - (40) - 529 884-0
Werkstr. 3 FAX: +49 - (40) - 529 884-20
D-22844 Norderstedt -

Table of Contents