This Python package provides functions to process and plot biological (EMG) and transducer (force) signals.
This package will be extended over time to include functions to process other types of signals, and improve ease of package installation.
If this code is used to analyse data or generate figures for publication, please cite the code as:
Diong J (2017) Biological and transducer signal processing in Python. DOI: 10.5281/zenodo.438155.
This code is released under the GNU General Public License.
Clone or download this package and navigate to the root directory of the package, then run:
pip install -e .
where the -e
flag is short for --editable
and .
refers to the current directory. Ie. this line will install the current directory in editable mode.
Alternatively (although this practice is not preferred for these reasons), clone or download this package and point Python to the root directory. For example:
import sys
sys.path.append("/home/joanna/Dropbox/Sketchbook/python/")
import biosig
Note, filepaths are specified differently in:
- Linux or Mac:
"/home/joanna/Dropbox/Sketchbook/python/"
- Windows:
"C:\\Users\\joanna\\Dropbox\\Sketchbook\\python\\"
File structure:
- biosig
- emg
- process
- force
- process
- plot
- readin
- spectral
- emg
- matplotlib
- numpy
- os
- scipy
- shutil
- sys
- warnings
Supply a dictionary of names and data values. Read in the raw data, where data are stored in columns in a text file. Remove DC offset, band pass filter the EMG data, and calculate the root-mean-square (RMS) EMG.
import sys
sys.path.append("/home/joanna/Dropbox/Sketchbook/python/")
import biosig
channels = {'force':0, 'emg':1, 'distance':2}
data = biosig.readin.read_data('data.txt', channel=channels)
emg = data['emg']
emg = biosig.emg.process.remove_mean(emg)
emg_filt = biosig.emg.process.filter_bandpass(emg, fq=2000, highpass=30, lowpass=500)
rms_emg = biosig.emg.process.calc_rms(emg, fq=2000, window=50, plot=True)
With thanks to Martin Héroux for contributions to the RMS EMG functions.
Merletti R and Parker P (2004) Electromyography : physiology, engineering, and noninvasive applications. John Wiley & Sons & Wiley InterScience (Online Service); Piscataway, NJ : IEEE Press, Hoboken, NJ.