Macros#

Overview#

There are many ways to extend DataLab with new functionality (see Plugins or Remote controlling). The easiest way to do so is by using macros. Macros are small Python scripts that can be executed from the “Macro Panel” in DataLab.

Macro Panel

The Macro Panel in DataLab.#

Macros can be used to automate repetitive tasks, or to create new functionality. As the plugin and remote control system, macros rely on the DataLab high-level API to interact with the application. This means that you can reuse the same code snippets in macros, plugins, and remote control scripts.

Warning

DataLab handles macros as Python scripts. This means that you can use the full power of Python to create your macros. Even though this is a powerful feature, it also means that you should be careful when running macros from unknown sources, as they can potentially harm your system.

See also

The DataLab high-level API is documented in the API section. The plugin system is documented in the Plugins section, and the remote control system is documented in the Remote controlling section.

Main features#

The Macro Panel is a simple interface to:

  • Create new macros, using the “New macro” libre-gui-add button.

  • Rename existing macros, using the “Rename macro” libre-gui-pencil button.

  • Import/export macros from/to files, using the “Import macro” fileopen_py and “Export macro” filesave_py buttons.

  • Execute macros, using the “Run macro” libre-camera-flash-on button.

  • Stop the execution of a macro, using the “Stop macro” libre-camera-flash-off button.

Macros are embedded in the DataLab workspace, so they are saved together with the rest of the data (i.e. with signals and images) when exporting the workspace to a HDF5 file. This means that you can share your macros with other users simply by sharing the workspace file.

Note

Macro are executed in a separate process, so they won’t block the main DataLab application. This means that you can continue working with DataLab while a macro is running and that you can stop a macro at any time using the libre-camera-flash-off button.

Example#

For a detailed example of how to create a macro, see the Prototyping a custom processing pipeline tutorial.