Process Tools
Classification Scripting
23 min
requires amics 5 2 0 or newer amics 5 2 is currently in beta testing the released version of amics is {{version}} and can be found with the most recent beta at the docid\ e1faehd1k20uedqhptzlx page manuals for previous versions of the software can be found at the docid\ d2biwe sybowhhdww0anz page exrternal scripting system amics includes an integrated external scripting system that allows users to extend processing pipelines with their own scripts scripts can be written in any command line compatible language (python, batch, powershell, etc ) and run as part of the amics workflow or as manually triggered actions note this page explains how to set up and organize scripts in the external script library interface setting up the python environment and development best practices are described in a separate section scripting setup in process opening the external scripting library to open the script library open amics navigate to the external tools ribbon tab click on the ribbon panel button labeled manage script library this opens a dialog box that provides a structured interface for managing and configuring custom scripts scripting node types node structure the script library is organized as a tree structure it consists of three node types folder used to organize related scripts or packages package groups one or more scripts and/or folders a package can include a preparation command executed before all scripts in that package script defines the actual executable command and script settings node actions right click on a node to open the context menu add child node (folder, package, script) from the context menu delete a node by pressing delete or using the context menu rename a node by double clicking its label or editing the name property folder node folders serve as containers for organizing other nodes they do not have script specific settings allowed children folders and scripts cannot contain packages unless the parent folder is already inside a package property description name user defined name for the node must be unique within the same parent node node id read only unique identifier used for referencing the node description optional free text note or comment package node a package node defines a group of scripts and the environment or setup command executed before them use this if your scripts require a virtual environment or temporary configuration before execution property description name user defined name for the node must be unique within the same parent node node id read only unique identifier used for referencing the node description optional free text note or comment folder path filesystem path used as the working directory for all scripts in this package prepare cmd line template optional shell command to execute before any scripts in the package script node script nodes define individual executable scripts property description name user defined name for the node must be unique within the same parent node node id read only unique identifier used for referencing the node description optional free text note or comment cmd line template full shell command used to run the script queue amics execution queue (used for load balancing or sequencing) see below exit sign lock file path template if \<exit sign> is set to "lock file", this specifies the expected lock file path priority script execution priority within the queue timeout maximum allowed execution time (in seconds) use 1 to disable timeout affects data check this if the script modifies amics data (e g , segmentation, x ray data) execution manual button for testing the script from the ui shortcut name template label for shortcut button shortcut type type of button big, small, or none shortcut icon path optional path to an icon displayed on the scripts ribbon tab command line template the command line template in amics defines how a script is executed by constructing the full command that amics runs at runtime this allows scripts to dynamically receive input paths and context information from amics, such as result file locations or the associated batch folder syntax and placeholders absolute paths are recommended for the script file to avoid ambiguity the template must be a valid command line that can be executed by the windows shell or command interpreter the command line template can include fixed strings (e g , script names or arguments) and amics defined placeholders that are replaced at runtime the following placeholders are supported placeholder description exaple %msr path% full path to the result file c /results/result mre %mode% execution mode %node name% name of the current script node %pkgc name% name of the parent package node %pkg path% folder path of the parent package %batch out path% path to the batch output folder example python d \exampleinterval1 py i %msr path% when this template is executed by amics, it will replace the placeholder with the actual result file path, yielding a real command such as python d \exampleinterval1 py i c /results/result mre this allows the script to dynamically process whichever result file is currently selected you may include multiple arguments , combining static values and dynamic placeholders python d \run py in %msr path% mode %mode% log %pkg path%\log txt testing using the command line template effectively allows you to pass the correct inputs from amics to your script without hard coding any values, ensuring portability and automation across multiple workflows and machines use the "execution" button on the script node to test your template the lower panel in the dialog shows the name example , which is what the command line will look like after placeholder substitution if execution fails, verify the script path exists and is accessible the python environment (or interpreter for the target script language) is configured on the system path all referenced folders exist and are writable if the script produces output wrap paths in quotes if they may contain spaces "d \my script folder\process py" "%msr path%" node best practaces use folders to organize by use case (e g , image processing, segmentation, post processing) use packages to group scripts that require the same setup (e g , activate the same virtual environment) always test scripts using the execution button before integrating into workflows avoid overlapping node names and shortcut names executing a script scripts may be executed manually from the external tools tab or automatically as part of a workflow shortcuts defined via script nodes appear on the scripts panel apply a script to the open expirement shortcuts are placed on external tools ribbon tab on scripts panel select the shortfut to to apply it to the open expirement file apply a script in a workflow you can attach scripts to batch workflows via the external script usage grid open the (batch processing) workflow designer press the script selection button (second from the right) in the external script dialog, double click icons to toggle script selection confirm to attach selected scripts to this step in the workflow scripts will be executed in the order listed during the workflow step, using their respective configuration scripts must be double clicked to select them for import from this import screen no node properities can be edited queue and script sequienceing scripts are applied in the following order initalization ` is called before start processing of files (i e at the very start) preprocessing executed after load but before any stitching steps best for image processing, stitching, etc postprocessing executed after classifciaiton steps (matching, spectrum tree steps, touch up steps) best for data reduction, particle extraction, cleanup, and other data conditioning before data export final processing step, most often used for custom exports finalization after file is closed mostly used for file copy, push, and archive rarely used
