| 1 |
# Biosig Package |
| 2 |
|
| 3 |
Biosig is a toolbox for processing biomedical signals |
| 4 |
like ECG, EEG etc. It can read about 50 different |
| 5 |
data formats including EDF, GDF, BDF, CFS, Heka, ABF, |
| 6 |
HL7aECG, SCP (EN1064), BrainVision, and many more. |
| 7 |
The heavy lifting is done in "libbbiosig" |
| 8 |
the biosig library implemented in C/C++. The |
| 9 |
Python module of Biosig provides an interface between |
| 10 |
libbiosig and Python. Currently, two functions are |
| 11 |
provided, one for reading the data samples, and one |
| 12 |
for extracting the meta information, like event |
| 13 |
table, scaling factors, sampling rates, etc. |
| 14 |
|
| 15 |
|
| 16 |
More information is available at |
| 17 |
- [Biosig project homepage](https://biosig.sourceforge.io) |
| 18 |
- [Biosig wiki page](https://sourceforge.net/p/biosig/wiki/Home/) |
| 19 |
|
| 20 |
# Installation: |
| 21 |
## GNU/Linux (Debian, Ubuntu, and family) |
| 22 |
``` |
| 23 |
sudo apt install python3-biosig |
| 24 |
``` |
| 25 |
or if you want to install in your own venv |
| 26 |
``` |
| 27 |
sudo apt install libbiosig-dev # make sure that libbiosig and its prerequisites are in place |
| 28 |
pip install biosig |
| 29 |
``` |
| 30 |
|
| 31 |
## MacOSX/Homebrew |
| 32 |
``` |
| 33 |
brew install biosig # make sure libbiosig is in place. |
| 34 |
pip install biosig |
| 35 |
``` |
| 36 |
|
| 37 |
## MS-Windows (Python >=3.9,<=3.14) |
| 38 |
``` |
| 39 |
pip install biosig |
| 40 |
``` |
| 41 |
|
| 42 |
## Other *NIX (Linux, Unix) OS |
| 43 |
|
| 44 |
- install libbiosig from source (`configure && make && make install`) |
| 45 |
- `pip install biosig` |
| 46 |
|
| 47 |
# Usage |
| 48 |
``` |
| 49 |
import biosig |
| 50 |
import json |
| 51 |
``` |
| 52 |
## read header/metainformation |
| 53 |
``` |
| 54 |
HDR=json.loads(biosig.header(FILENAME)) |
| 55 |
``` |
| 56 |
## read data |
| 57 |
``` |
| 58 |
DATA=biosig.data(FILENAME) |
| 59 |
``` |
| 60 |
|
| 61 |
## A more elaborate example is this [demo](https://sourceforge.net/p/biosig/code/ci/master/tree/biosig4c++/python/demo2.py "demo2.py") |
| 62 |
|
| 63 |
showing |
| 64 |
- how to load data |
| 65 |
- displaying the traces with matplotlib |
| 66 |
- splitting the traces into sweeps |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
# History |
| 71 |
In the past there were several attempts |
| 72 |
of providing Python support. A first attempt |
| 73 |
using pure python should to be very slow and a |
| 74 |
lot of implementation effort, only some early |
| 75 |
version of GDF has been supported. |
| 76 |
Later, Swig was used for providing a python binding. |
| 77 |
This was reasonable flexible, and the libbiosig |
| 78 |
implementation could be mostly used. Disadvantages |
| 79 |
were the effort to maintain swig.i interface file, |
| 80 |
which is currently most likely broken. Known issues |
| 81 |
are string support, lack of Python3 support. Also this |
| 82 |
attempt is considered deprecated. |
| 83 |
|
| 84 |
The third attempt is using "module extensions". |
| 85 |
Currently, two functions, one for reading the header |
| 86 |
information (in JSON format) and one for reading the |
| 87 |
data samples is provided. |