Skip to content

CLI & Batch Processing

The command line runs the same processing as the plugin, driven by a YAML config file. It is the code that the plugin starts in the background. Use it for servers, automated workflows and batch jobs, or to repeat a run that you set up in the plugin.

The easy way: copy the command from the plugin

You do not need to build the command yourself. Set up a run in the plugin, then click the 📋 Copy Run Command button in the bottom bar.

  1. The plugin writes your current settings to output_dir/last_run_config.yml.
  2. It finds the right Python interpreter and script path for your system, whatever the QGIS version or install location.
  3. It copies the complete command to the clipboard, ready to paste into a terminal or a script.

The saved last_run_config.yml is a good starting point for your own configs. Every option is described in the Configuration Reference.

Run it yourself

Pick how you installed MOBI-DIC. The scripts and the Python environment are different, the arguments are the same.

After installing the plugin in QGIS, the scripts and the Python environment are ready. Set two variables once per terminal session, then use them in every command.

PY=~/.slf-dic/.pixi/envs/default/bin/python3
SCRIPTS=~/Library/Application\ Support/QGIS/QGIS3/profiles/default/python/plugins/slfdic/_dic_scripts
PY=~/.slf-dic/.pixi/envs/default/bin/python3
SCRIPTS=~/.local/share/QGIS/QGIS3/profiles/default/python/plugins/slfdic/_dic_scripts
set PY=%USERPROFILE%\.slf-dic\.pixi\envs\default\python.exe
set SCRIPTS=%APPDATA%\QGIS\QGIS3\profiles\default\python\plugins\slfdic\_dic_scripts

QGIS 4 and finding the path

With QGIS 4, replace QGIS3 in the path with QGIS4. If you are unsure where your profile folder is, open the QGIS Python console and run QgsApplication.qgisUserDatabaseFilePath(). The plugins folder is a sibling of that file.

Then run a script with your config:

"$PY" "$SCRIPTS/run_dic4dem_processing.py" --config /path/to/config_dic4dem.yml
"%PY%" "%SCRIPTS%\run_dic4dem_processing.py" --config C:\path\to\config_dic4dem.yml

With the pipeline-only build, the scripts are in the slf-dic-python/ folder of the unzipped package, and pixi manages the environment.

cd /path/to/mobi-dic/slf-dic-python
pixi run python run_dic4dem_processing.py --config config_dic4dem.yml

Using conda instead of pixi

Replace pixi run python with the Python of your conda environment, for example conda run -n mobi-dic python.

The three processing scripts

Choose the script for your mode. All three take the same --config argument.

Mode Script Config file of the package
DEM run_dic4dem_processing.py config_dic4dem.yml
Ortho run_dic4optical_processing.py config_dic4optical.yml
Camera run_dic4webcam_processing.py config_dic4webcam.yml

Use an absolute path for --config

A relative path is resolved against the folder of the script, not against your current folder. Use the full path of your config file to be sure which file is read.

The config controls all processing parameters, see the Configuration Reference.

Standalone post-processing scripts

The plugin's Post-process existing results section runs these two scripts. You can also run them directly, for example in a script. The commands use the PY and SCRIPTS variables from above, or pixi run python in a pipeline-only package.

Coherence filter

run_coherence_filter_standalone.py re-runs the coherence filter on an existing HDF5 result file, so you can adjust thresholds or write the outputs again without repeating the correlation.

"$PY" "$SCRIPTS/run_coherence_filter_standalone.py" \
  --hdf5 /path/to/DIC_result.h5 \
  [--Key value ...]
"%PY%" "%SCRIPTS%\run_coherence_filter_standalone.py" ^
  --hdf5 C:\path\to\DIC_result.h5 ^
  [--Key value ...]

Any further --Key value pair is passed on as a parameter of the filter. The outputs are given as paths, for example --MaxMagnitude 3.0 --OutputGpkg /path/to/filtered.gpkg --OutputPlot /path/to/plot.png. The parameters are described on the Post-process and Outlier Filtering pages.

Neighbour filter

run_neighbour_filter_standalone.py filters a sparse DIC GeoPackage by comparing each vector with its nearest neighbours in magnitude and direction.

"$PY" "$SCRIPTS/run_neighbour_filter_standalone.py" \
  --gpkg /path/to/DIC_sparse.gpkg \
  [--output /path/to/filtered.gpkg] \
  [--MagField xy|xyz] \
  [--MagThresh 10.0] \
  [--DirThresh 15.0] \
  [--NNeighbours 4] \
  [--MaxDist 50.0] \
  [--Iterations 1] \
  [--RealTime 0]
"%PY%" "%SCRIPTS%\run_neighbour_filter_standalone.py" ^
  --gpkg C:\path\to\DIC_sparse.gpkg ^
  [--output C:\path\to\filtered.gpkg] ^
  [--MagField xy] ^
  [--MagThresh 10.0] ^
  [--DirThresh 15.0] ^
  [--NNeighbours 4] ^
  [--MaxDist 50.0] ^
  [--Iterations 1] ^
  [--RealTime 0]
Argument Default What it does
--gpkg (required) The sparse GeoPackage from the DIC run.
--output auto The output path. By default <input>_neighbour.gpkg.
--MagField xy The magnitude field to compare: xy (2D) or xyz (3D).
--MagThresh 10.0 The largest allowed magnitude difference between neighbours, in map units or pixels.
--DirThresh 15.0 The largest allowed azimuth difference between neighbours, in degrees.
--NNeighbours 4 The number of nearest neighbours to compare.
--MaxDist 50.0 The largest search distance for neighbours, in map units or pixels.
--Iterations 1 The number of filter passes.
--RealTime 0 1 removes rejected points at once, so later checks in the same pass skip them. It depends on the order of the points and is slower.

Logs

Every run writes a log file named <timestamp>_<run_tag>_log.txt into its run folder in the output directory. The log lists all parameter values, the timing of the windows and any warnings. A batch run with several resolutions or window sizes also writes a combined log, <timestamp>_processing_log.txt, in the batch_processing_logs folder of the output directory.