A python utility for interpreting EMG data
=
- A Terminal: you can use
cmd.exe
but I recommend Git for Windows - Python 2.7.x
- Install python into the default option
C:\Python27
if you can. Then, edit your PATH environment variable to includeC:\Python27
(instructions here).
- Install python into the default option
- Pip for python package management
- Pip is included in the standard python installation on windows. Simply add the
C:\Python27\Scripts
directory to yourPATH
variable (separate directories using a semicolon), and pip should be accessible from the command line.
- Pip is included in the standard python installation on windows. Simply add the
- Python 2.7.x
- Pip for python package management
- First, try this: open a terminal and run the command
sudo easy_install pip
. If this doesn't work, - Download get-pip.py and run the command
sudo python /path/to/get-pip.py
in your terminal.
- First, try this: open a terminal and run the command
=
=
Many of these packages have been archived by Christopher Gohlke in order to be easy to install. For several of these requirements, I'll link to his Unofficial Windows Binaries page. Simply find the package you want, select the correct version based on your architecture (32- or 64-bit) and python version (use "27" or "26" depending on the version of Python you downloaded). For example:
Your Python Version | Your system architecture | You should download |
---|---|---|
2.6.x | 32-bit | numpy‑1.9.2+mkl‑cp26‑none‑win32.whl |
64-bit | numpy‑1.9.2+mkl‑cp26‑none‑win_amd64.whl | |
2.7.x | 32-bit | numpy-1.9.2+mkl-cp27-none-win32.whl |
64-bit | numpy‑1.9.2+mkl‑cp27‑none‑win_amd64.whl |
A wheel is a ZIP-format archive with a specially formatted filename and the .whl extension. More info on python wheels here. Once you download the correct wheel file, use pip in the terminal to install it:
pip install C:\Users\chris\Downloads\numpy‑1.9.2+mkl‑cp27‑none‑win_amd64.whl
- NumPy for numerical computing
- Gohlke's NumPy+MKL packages
- Alternatively, try the most recent supported version 1.9.2 available on the sourceforge page (not much advantage since Gohlke has archived 1.9.2).
- matplotlib for plotting
- Gohlke's matplotlib packages
- Alternatively, the most recent wheels are available on the matplotlib download page (once again the previous link already has 1.4.3 which is sufficient).
- neo for reading electrophysiology data in Python
- Run the command
pip install neo
in your terminal.
- Run the command
=
- NumPy for numerical computing
- Run
sudo pip install numpy
in your terminal.
- Run
- matplotlib for plotting
- Run
sudo pip install matplotlib
in your terminal.
- Run
- neo for reading electrophysiology data in Python
- Run
sudo pip install neo
in your terminal.
- Run
ImportError: cannot import name _thread -- Sometimes the matplotlib install fails on newer versions of OSX. The fix mentioned in the link is:
sudo pip uninstall python-dateutil
sudo pip install python-dateutil==2.2
If you have git available in your command line or terminal, execute:
git clone git://github.com/chrismullins/MEPReader.git
or simply download and extract the tarball from this page.
To run the application, start a terminal, then execute:
python bin/MEPReaderApp.py --help
usage: MEPReaderApp.py [-h] [--version] [-v] [--plot] [--plotDerivative]
[--pairedPulse] -i FILENAME [-o OUTPUT_FILE]
optional arguments:
-h, --help show this help message and exit
--version show program's version number and exit
-v, --verbose increases log verbosity for each occurence.
--plot Plot the signal. Requires matplotlib. (Helps to debug
missed triggers)
--plotDerivative Plot the derivative under the EMG signal. (Helps to
debug missed triggers)
--pairedPulse These are paired pulse data.
-i FILENAME, --inputFile FILENAME
-o OUTPUT_FILE redirect output to a file
The application takes one required argument (the .smr
input file) and can be used to plot the results, write the results to a file in the comma-separated value format (CSV) or both. For example, the command:
python bin/MEPReaderApp.py -i C:/Data/ppTMS_Visit_1/004_CSP000.smr --plot
will open a plot looking something like this:
Use the zoom-to-rectangle tool in the lower left-hand corner to isolate one trigger and the corresponding response. If the script ran correctly, you should see something like this. The green area indicates the window in which the script looks for a min and max response. If any of the annotations for the trigger, min, or max responses are incorrect, open a bug report with the development team (walk over and tell me about it).
This provides a quick way to check whether the script is working incorrectly, or the data are just unusual.