|
1 | 1 | # Python Processor |
2 | 2 |
|
3 | | -A plugin for adding custom Python scripts to the [Open Ephys GUI](https://github.com/open-ephys/plugin-GUI) signal chain. |
| 3 | + |
4 | 4 |
|
5 | | -## Build Notes |
| 5 | +A plugin for running custom Python scripts in a [Open Ephys GUI](https://github.com/open-ephys/plugin-GUI) signal chain. |
6 | 6 |
|
7 | | -So far the build process has only been tested on Windows. The plugin uses [pybind11](https://pybind11.readthedocs.io/en/stable/) to call Python functions from the GUI. Right now it seems to require a version of Python be available on the Windows PATH variable at compile time and at run time. Modules available in sys.path can be imported. |
| 7 | +## Installation |
| 8 | + |
| 9 | +The Python Processor plugin is not included by default in the Open Ephys GUI. To install, use ctrl-P to access the Plugin Installer, browse to the "Processor plugin" plugin, and click the "Install" button. |
8 | 10 |
|
9 | 11 | ## Usage |
10 | 12 |
|
11 | | -You must have numpy installed and available on sys.path in order to run the processor. Each plugin node creates an instance of a user-defined Python class named PyProcessor. Edit the template available in the Modules folder in this repo, then load the .py module using the file dialog in the plugin node. The reload button will reimport the module if you make edits. |
| 13 | +Instructions for using the Python Processor plugin are available [here](https://open-ephys.github.io/gui-docs/User-Manual/Plugins/Python-Processor.html). |
| 14 | + |
| 15 | +## Building from source |
| 16 | + |
| 17 | +First, follow the instructions on [this page](https://open-ephys.github.io/gui-docs/Developer-Guide/Compiling-the-GUI.html) to build the Open Ephys GUI. |
| 18 | + |
| 19 | +**Important:** This plugin is intended for use with the GUI version 0.6.0 and higher. |
| 20 | + |
| 21 | +Be sure to clone the `python-processor` repository into a directory at the same level as the `plugin-GUI`, e.g.: |
| 22 | + |
| 23 | +``` |
| 24 | +Code |
| 25 | +├── plugin-GUI |
| 26 | +│ ├── Build |
| 27 | +│ ├── Source |
| 28 | +│ └── ... |
| 29 | +├── OEPlugins |
| 30 | +│ └── python-processor |
| 31 | +│ ├── Build |
| 32 | +│ ├── Source |
| 33 | +│ └── ... |
| 34 | +``` |
| 35 | +After that, you also need to initialize the [pybind11](https://pybind11.readthedocs.io/en/stable/) submodule required for building the plugin by entering the entering this command inside the python-processor plugin directory. |
| 36 | + |
| 37 | +```bash |
| 38 | +git submodule update --init |
| 39 | +``` |
| 40 | + |
| 41 | +**Note:** Minimum Python version required for building the Python Processor plugin is `3.8`. Refer to the plugin docs to understand how to setup a Conda environment for this. |
| 42 | + |
| 43 | +### Windows |
| 44 | + |
| 45 | +**Requirements:** [Visual Studio](https://visualstudio.microsoft.com/) and [CMake](https://cmake.org/install/) |
| 46 | + |
| 47 | +From the `Build` directory, generate the build files by entering: |
| 48 | + |
| 49 | +```bash |
| 50 | +cmake -G "Visual Studio 17 2022" -A x64 -DPython_ROOT_DIR="path/to/python_home" .. |
| 51 | +``` |
| 52 | + |
| 53 | +Next, launch Visual Studio and open the `OE_PLUGIN_python-processor.sln` file that was just created. Select the appropriate configuration (Debug/Release) and build the solution. |
| 54 | + |
| 55 | +Selecting the `INSTALL` project and manually building it will copy the `.dll` and any other required files into the GUI's `plugins` directory. The next time you launch the GUI from Visual Studio, the Python Processor plugin should be available. |
| 56 | + |
| 57 | + |
| 58 | +### Linux |
| 59 | + |
| 60 | +**Requirements:** [CMake](https://cmake.org/install/) |
| 61 | + |
| 62 | +From the `Build` directory, enter: |
| 63 | + |
| 64 | +```bash |
| 65 | +cmake -G "Unix Makefiles" -DPython_ROOT_DIR="path/to/python_home" .. |
| 66 | +cd Debug |
| 67 | +make -j |
| 68 | +make install |
| 69 | +``` |
| 70 | + |
| 71 | +This will build the plugin and copy the `.so` file into the GUI's `plugins` directory. The next time you launch the GUI compiled version of the GUI, the Python Processor plugin should be available. |
| 72 | + |
| 73 | + |
| 74 | +### macOS |
| 75 | + |
| 76 | +**Requirements:** [Xcode](https://developer.apple.com/xcode/) and [CMake](https://cmake.org/install/) |
| 77 | + |
| 78 | +From the `Build` directory, enter: |
| 79 | + |
| 80 | +```bash |
| 81 | +cmake -G "Xcode" -DPython_ROOT_DIR="path/to/python_home" .. |
| 82 | +``` |
| 83 | + |
| 84 | +Next, launch Xcode and open the `python-processor.xcodeproj` file that now lives in the “Build” directory. |
| 85 | + |
| 86 | +Running the `ALL_BUILD` scheme will compile the plugin; running the `INSTALL` scheme will install the `.bundle` file to `/Users/<username>/Library/Application Support/open-ephys/plugins-api8`. The Python Processor plugin should be available the next time you launch the GUI from Xcode. |
| 87 | + |
| 88 | + |
| 89 | +**Note:** `Python_ROOT_DIR` is the path to the Python installation on your system you want to use. E.g. `${HOME}/miniconda3/envs/ENVNAME`. |
12 | 90 |
|
13 | 91 |
|
14 | 92 |
|
0 commit comments