Introduction to Python Scripting¶
The Python Scripting module bridges the gap between automated image acquisition and custom computer vision algorithms. By executing Python scripts after each image capture event, it enables smart microscopy: dynamic, adaptive workflows that use computational analysis to control microscope hardware.
This feature is constructed upon two core components:
1. The Graphical Interface Module¶
Licensing Requirement
The Custom Scripting software license option is required to use this module.
Located natively within the Inscoper I.S. GUI, the module serves as the bridge between your custom scripts and the acquisition engine. It is found within the multi-dimensional acquisition (MDA) tab, immediately below the standard sequence settings.
-
Automated Settings UI: Upon importing a Python script, the module parses the code to identify all functions (potential entry points). Parameters defined in your Python functions are mapped to graphical controls (e.g.,
boolarguments generate toggle switches,strbecome text fields, enumerations become dropdown lists).- The Image Provider function dictates which acquired images are passed to the Python processing function at any given time point.
- The Processing Function executes the analysis (e.g., computer vision, intensity measurements) and returns the updated values for microscope hardware parameters.
-
Sequence Execution: The system engine triggers these functions as callbacks following each image capture. The Image Provider is invoked first to assess if analysis is needed; if confirmed, the Processing Function runs, adjusting designated hardware parameters, or pushing figures to the interface.
2. The Development Toolkit (inscoper-scripts)¶
Provided as a local package, this toolkit serves as the foundation for your custom script development. It is organized into three categories:
-
Application Collection: A suite of ready-to-use smart microscopy master applications, including modules for:
- Mechanical tracking
- Single-cell population screening/tracking
- Autofocus
- FRAP workflows
-
Structural Templates: Simplified application examples that serve as starting points for generating custom scripts.
-
Utility Sub-modules: A suite of helper libraries containing predefined image providers, ROI objects, and mathematical functions for tracking, measurement, segmentation, and filtering. These utilities simplify interacting with the core software environment, allowing you to display figures in the GUI, manipulate metadata dictionaries, and generate analytical plots.