Skip to main content

A simple BTS MDX file parser based on BeautifulSoup

Project description

.. highlight:: python3

.. image::

.. image::

.. image::
:alt: Windows build status

.. image::
:alt: Documentation Status

.. image::
:alt: Updates

.. image::
:alt: Coverage

A simple BTS MDX file parser and toolkit written in Python based on BeautifulSoup_

* Free software: GNU General Public License v3
* Documentation:

* Compatible with Python 2.7 and 3.4 onwards
* Linux, OSX and Windows support

simplemdx gives access to:

* trial MDXs (marker coordinates, emg channels, etc)
* session and patient MDXs (antropometric data, subject metadata)
* normative ENB files (joint angles normatives, emg normatives, etc)


To load the contents of a trial mdx

.. code:: python

from simplemdx.parser import Parser

a = Parser('myfile.mdx')

Once loaded, metadata can be accessed like:

.. code:: python

label = a.label
date =

It also loads all it's streams, and names them according to their contents. The named streams can be:

* markers
* emg
* static
* cycle


Every stream has its own metadata(such as frequency, start time and number of frames

.. code:: python

a = Parser('myfile.mdx')
m = a.markers # marker stream


Marker streams

Markers can be retrieved from the stream by index or label

.. code:: python

c7 = a.markers['c7']
m = a.markers[0] # The first marker on the stream

or iterated

.. code:: python

for marker in a.markers:

This stream can be converted to an OpenSIM .trc file like this

.. code:: python


By default, it creates a trc file with the same label as the trial mdx and all the included markers.
It is important to note that it will output the largest common chunk of data (the largest interval of time for which all markers are visible). This is to avoid None data in the .trc file. One can restrict the output to certain markers and change the output filename

.. code:: python


As a simple way to inspect the stream, one can plot it

.. code:: python


This will display a simple matplotlib 3D scatter plot with the markers and the references

Data items

The data for the streams inner tags are stored in DataItems. BTS follows an Item/Segment approach for storing most of it. For retrieving a segment of a marker, one can call the data attribute

.. code:: python

c7 = a.markers['c7']
s =

data will return a Segment object, or a list of Segment objects. Each Segment has a list for each coordinate (for a marker example, X, Y and Z) and the Segment's starting frame

.. code:: python

seg =
if isintance(seg,Segment):
print("First frame: {}".format(seg.frame))
print("X data: {}".format(seg.X))

addicionally, data can be retrieved as a continuous stream using datac instead of data. This will merge all segments into one, added a None padding. and return a single Segment starting at frame 0.

.. code:: python

segc = c7.datac
print("X data: {}".format(seg.X))


This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.

.. _Cookiecutter:
.. _`audreyr/cookiecutter-pypackage`:
.. _BeautifulSoup:


0.1.0 (2018-02-27)

* First release on PyPI.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simplemdx-0.1.10.tar.gz (8.6 MB view hashes)

Uploaded Source

Built Distribution

simplemdx-0.1.10-py2.py3-none-any.whl (30.2 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page