NeuroNetMem / PythonPlugin

A plugin for open-ephys enabling the insertion of Cython into the open-ephys signal chain.
11 stars 17 forks source link

PythonPlugin

A plugin for open-ephys enabling the insertion of Cython (Python code translated to C and compiled) into the open-ephys signal chain. Most of the Cython peculiarities are dealt with by a wrapper code, so that essentially usual, "pure" Python code may be used. A tutorial on how to write a python module can be found below. Example modules can be found under the python-modules directory.

Installation Instruction

Compile from source code

The Plugin is organized so that it can be compiled as much as possible outside of the main open-ephys source tree. Under Linux, a symlink to the Source/Plugins directory is however necessary. A recent Python version is required. The Plugin needs to link to a recent enough version of Python. Development work was done with a recent Anaconda Python distribution, supporting python 3.5 to 3.7. Windows users must use python 3.6 (see below).

To compile the plugin, extract in a folder just outside the Open Ephys plugin-GUI source tree e.g.

$ ls src
plugin-GUI/
PythonPlugin/
etc...

The rest of the procedure is system dependent

Linux

The script build-linux.sh should detect the version and location of the python installation automatically. It will use the one of the executable that is at the top of the PATH, so make sure that the shell you are running it from is properly configured

Under Ubuntu 16.04 and later:

To compile the python modules you will need (at least) Cython and numpy which may be installed by

pip install cython
pip install numpy

MacOSX

Windows

  1. From the Start menu, start typing "environment" and then select "Edit environment variables for your account"
  2. Click "New..." to create a new variable. Enter CONDA_HOME as the name and the path to your Python 3.6 root folder as the value. For example, if you are using a conda environment called oeEnv, this would be something like C:\Users\your_username\Anaconda3\envs\oeEnv. Do not use a trailing slash. Click OK twice to save.
  3. Restart Visual Studio completely if you have it open. Open the Plugins solution and select Project > Rescan Solution to make sure the PYTHON_HOME_NAME macro gets updated.

Usage

Create New Module Directory and Framework Code

Compilation

Currently, only Cython version 0.28.2 is supported. Recently downloaded or upgraded versions of Anaconda will come with version 0.29.2, which will cause the application to crash upon loading a python module. To avoid this, create a virtual enviroment with the correct versions of python and cython by running:

conda create -n oeEnv python=3.6 cython=0.28.2

To activate the enviroment on Linux or Mac:

source activate oeEnv

To activate the enviroment on Windows:

activate oeEnv

For more information on virtual enviroments, please click here.

Load Python Module in Open Ephys

alt text