Menu

FAQ

Alois Schloegl

Q: Where can I find documentation about using Biosig with Matlab or Octave ?

A: The documentation is part of the *.m files, and can be retrieved with
the matlab help function. This help is also exported into html
http://biosig.sourceforge.net/help/index.html

Q: I've installed biosig4octmat. How do I get started ? How do I load data into Matlab/Octave workspace ?

-) for loading data into the matlab workspace, use
sload, or mexSLOAD

The usage of the function can be obtained with
help sload
mexSLOAD (w/o arguments)

or online http://biosig.sourceforge.net/help/biosig/t200/sload.html

-) If you want to load only parts of edf files, you can use
sopen, sread, sclose

Q: I'd like to load and view data, and add annotations. How can I do that ?

A: There are some simple viewer, like sview, and sviewer. However, if
you want a Viewing and Scoring software, I recommend "SigViewer", a
stand-alone executable viewer, without the need of matlab. Sigviewer
uses libbiosig as for loading and importing, and thus can read all data formats supported by Biosig.
Data, events, markers, and annotations etc. can be exported into GDF/EVT files, which can than be read again into
Matlab.

Q: what's the difference between "mexBiosig/mexSLOAD" and "Biosig for Octave and Matlab" (biosig4octmat) ?

A: mexBiosig is mainly about data import and export. mexBiosig provides the mex-functions (mexSLOAD, mexSOPEN, mexSSAVE, physicalunts). In order to install it, you need compiler and developer tools. For some platforms, precompiled binaries are provided.

"Biosig for Octave and Matlab" contain a large number of higher level tools nalyzing biomedical signals, examples are EEG analysis for BCI research, ECG analysis, connectivity analysis etc. The tools are categorized in different subdirectory, e.g. t200 for file I/O, 250 for preprocessing, t300 for feature extraction, t400 for classification, etc. These are written in pure Matlab/Octave code and no compiler is needed.

Q: How to install "mexBiosig/mexSLOAD" in Octave ?

A: First make sure that libbiosig is installed on your platform (from source, apt-get, homebrew), you can just run

pkg install https://pub.ist.ac.at/~schloegl/biosig/prereleases/mexbiosig-2.3.2.src.tar.gz 

The full package of Biosig (including mexBiosig) can be installed with

pkg install https://pub.ist.ac.at/~schloegl/biosig/prereleases/biosig4octave-2.3.2.src.tar.gz 

libbiosig is also part of mxe-octave, and is available in Octave-for-Windows (v5.2.0 or later), and so the command above will also work.

Q: How to install "mexBiosig/mexSLOAD" in Matlab on *nix system ?

A: in order to install mexbiosig for matlab, download and extract the source distribtion, and run the following commands:

   ./configure 
   make -C biosig4c++/mex mex4m

This will generate the mex files in that subdirecory and you can copy these to any place that ins convinient to you

   biosig4c++/mex/*.mex*

Q: How to install "mexBiosig/mexSLOAD" in Matlab on MacOSX?

A: in order to install mexbiosig for matlab, download and extract the source distribtion, and run the following commands:

      # get all dependencies of biosig, and libbiosig
     brew install biosig

     # get repository 
     git clone https://git.code.sf.net/p/biosig/code biosig-code
     cd biosig-code
     # Configure matlab  
     ./configure MATLAB=/Application/MATLAB_R2019a.app/bin/matlab
     make -C biosig4c++  mex4m

This will generate the mex files in that subdirecory and you can copy these to any place that ins convinient to you

    biosig4c++/mex/*.mex*

Q: How to install "Biosig4OctMat" in Matlab or Octave?

A: libbiosig 2.0.4 or later will install "biosig4octmat" in the subdirectory

   $PREFIX/share/biosig/matlab

By default, this is either

   /usr/local/share/biosig/matlab
   /usr/share/biosig/matlab

Alternatively, you can extract the sources into any suitable directory.

In order to use it, you just need to include the various directory path within matlab or octave. Start Matlab (or Octave) and run

   cd /usr/local/share/biosig/matlab
   install

In order to add the path permanenty, run also this command:

   savepath

Using the provided install script add the directory in the correct order to the path, and checks in addition for some recommended tools, that you might want to install as well.

Q: How to install Biosig in Python ?

On recent Debian/Ubuntu, you can do

   sudo apt-get install python3-biosig python3-numpy python3-simplejson

On MacOSX, you can do

   brew install python3
   brew install biosig

On Windows, there is currently no (recommended) solution. See also the FAQ on "Biosing on Windows".

Installing from source, make sure you have, python, and numpy installed. Then just download, and unpack the source and run

   ./configure && make  && sudo make install

If libbiosig (>1.9.2) is available on your system, you can also do

   pip install Biosig

Q: How to use Biosig in Python ?

After installation of Biosig for Python, you can load the header information and the sample values in the following way:

  import biosig
  import json
  HDR=json.loads(biosig.header(FILENAME))
  data=biosig.data(FILENAME) 

A more elaborate example is shown in demo2.py
https://sourceforge.net/p/biosig/code/ci/master/tree/biosig4c++/python/demo2.py?format=raw

Q: How to install and use Biosig in Java ?

In order to make use of Biosig from within Java, the language binding fo Biosig to Java
need to be installed. It can be installed as part of the lnstallation of libbiosig

   ./configure && make && sudo make install

If libbiosig is installed by other means (e.g. apt, etc.), you just need to compile the java language binding in the following way:

   ./configure 
   make -C biosig4c++/java         # install java language binding
   make -C biosig4c++/java test    # run test  

So far this is successfully tested only on GNU/Linux with OpenJDK.

Q: How to install and use Biosig in R ?

In order to make use of Biosig from within R, the language binding fo Biosig to R need to be installed. It can be installed as part of the lnstallation of libbiosig

   ./configure && make && sudo make install

If libbiosig is installed by other means (e.g. apt, etc.), you just can compile it also through

   ./configure 
   make -C biosig4c++/R

An example of using Biosig from within R is provided
https://sourceforge.net/p/biosig/code/ci/master/tree/biosig4c++/R/sload.r

Q: How to install and use Biosig in Mathematica ?

In order to make use of Biosig from Mathematica, the language binding to Mathematica need to be installed. It can be installed as part of the lnstallation of libbiosig

   ./configure && make && sudo make install

If libbiosig is installed by other means (e.g. apt, etc.), you just can compile it also through

   ./configure 
   make -C biosig4c++/mma
   make -C biosig4c++ install_mma 

This will install the biosig module for mathematica in

   $PREFIX/share/biosig/mathematica

It can be used from within Mathematica

    link=Install["/usr/local/share/biosig/mathematica/biosig.exe"]
    ?Sload;
    ?Uload;

Q: Biosig on Windows ?

A: Biosig-tools and Libbiosig require GCC and can be compiled with Mingw, and Cygwin, and can be also used with WSL. Biosig does not compiled with VC++,
The language bindings are more difficult, because not all environments are available in the same way on these platforms.
We are using mingw-cross-environment (MXE) https://github.com/schloegl/mxe for Matlab and Mathematica bindings. The octave bindings are compiled within mxe-octave. The Python bindings for Windows are currently available only on Cygwin.

Q: Is the EDFplus sub-second issue of the start time resolved ?

The sub-second resolution of the start time of EDFplus files is supported in libbiosig 2.0.3 and later, as well as all language bindings that are using this.
A notable exception is SOPEN.M in biosig4octmat, it is recommended to install mexBiosig and and use instead mexSLOAD or mexSOPEN.

Q: How can I read HEKA files ?

A: HEKA files come in two flavours, (i) with an empty or invalid bundle header (a.k.a. HEKA v1, a.k.a. HEKA DAT1), and (ii) with a valid bundle header (a.k.a. HEKA v2, a.k.a. HEKA DAT2). Biosig supports only HEKA files with valid bundle header (a.k.a. HEKA v2, a.k.a. HEKA DAT2).
As a workaround we recommend to open HEKAv1 files again with Patchmaster and save it with the option "Make Bundle File" (see Patchmaster Reference Manual); this will store the file in the "bundled heka format" (a.k.a. HEKA DAT2)

Q: Can I export the header information into JSON format?

A: On the command line, this can be achived easily in any of the following ways:

   save2gdf -JSON <source_file> [<dest_file.json> ]

   save2gdf.exe -JSON <filename> % on Windows command line shell

   biosig_fhir -json <source_file> 

For C/C++ the programming interface is

int fprintf_hdr2json(FILE *stream, HDRTYPE* hdr);
int asprintf_hdr2json(char **str, HDRTYPE* hdr);

A complete example is this one:

#include <biosig.h>
int main(int argc, char *argv[]) {
                 // read file
                char *filename=argv[1];
                HDRTYPE *hdr=sopen(filename, "r", NULL);

               // convert header to json string
                char *jsonstr=NULL;
                asprintf_hdr2json(&jsonstr, hdr);

                //print string
                printf("%s",jsonstr);

                // memory deallocation
                destructHDR(hdr);
}

The interfaces in Biosig for Python, Java and R provide also JSON output of the header information.


Related

Wiki: Home

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.