Giter VIP home page Giter VIP logo

biosiglive's Introduction

logo DOI badge Actions Status Coverage Status PyPI Downloads

Pyomeca is a python library allowing you to carry out a complete biomechanical analysis; in a simple, logical and concise way.

Pyomeca documentation

See Pyomeca's documentation site.

Example

Pyomeca implements specialized functionalities commonly used in biomechanics. As an example, let's process the electromyographic data contained in this c3d file.

You can follow along without installing anything by using our binder server: Binder

from pyomeca import Analogs

data_path = "../tests/data/markers_analogs.c3d"
muscles = [
    "Delt_ant",
    "Delt_med",
    "Delt_post",
    "Supra",
    "Infra",
    "Subscap",
]
emg = Analogs.from_c3d(data_path, suffix_delimiter=".", usecols=muscles)
emg.plot(x="time", col="channel", col_wrap=3)

svg

emg_processed = (
    emg.meca.band_pass(order=2, cutoff=[10, 425])
    .meca.center()
    .meca.abs()
    .meca.low_pass(order=4, cutoff=5, freq=emg.rate)
    .meca.normalize()
)

emg_processed.plot(x="time", col="channel", col_wrap=3)

svg

import matplotlib.pyplot as plt

fig, axes = plt.subplots(ncols=2, figsize=(10, 4))

emg_processed.mean("channel").plot(ax=axes[0])
axes[0].set_title("Mean EMG activation")

emg_processed.plot.hist(ax=axes[1], bins=50)
axes[1].set_title("EMG activation distribution")

svg

See the documentation for more details and examples.

Features

  • Signal processing routine commonly used in biomechanics such as filters, normalization, onset detection, outliers detection, derivatives, etc.
  • Common matrix manipulation routines implemented such as getting Euler angles to/from a rototranslation matrix, creating a system of axes, setting a rotation or translation, transpose or inverse, etc.
  • Easy reading and writing interface to common files in biomechanics (c3d, csv, xlsx,mat, trc, sto, mot)
  • All of xarray's awesome features

The following illustration shows all of pyomeca's public API. An interactive version is available in the documentation.

api

Installation

Pyomeca itself is a pure Python package, but its dependencies are not. The easiest way to get everything installed is to use conda.

To install pyomeca with its recommended dependencies using the conda command line tool:

conda install -c conda-forge pyomeca

Now that you have installed pyomeca, you should be able to import it:

import pyomeca

Integration with other modules

Pyomeca is designed to work well with other libraries that we have developed:

  • pyosim: interface between OpenSim and pyomeca to perform batch musculoskeletal analyses
  • ezc3d: Easy to use C3D reader/writer in C++, Python and Matlab
  • biorbd: C++ interface and add-ons to the Rigid Body Dynamics Library, with Python and Matlab binders.

Bug reports & questions

Pyomeca is Apache-licensed and the source code is available on GitHub. If any questions or issues come up as you use pyomeca, please get in touch via GitHub issues. We welcome any input, feedback, bug reports, and contributions.

Citing Pyomeca

DOI

If you use pyomeca in your academic work, please consider citing our paper as:

@article{Martinez2020,
  doi = {10.21105/joss.02431},
  url = {https://doi.org/10.21105/joss.02431},
  year = {2020},
  publisher = {The Open Journal},
  volume = {5},
  number = {53},
  pages = {2431},
  author = {Romain Martinez and Benjamin Michaud and Mickael Begon},
  title = {`pyomeca`: An Open-Source Framework for Biomechanical Analysis},
  journal = {Journal of Open Source Software}
}

Please consider citing the xarray project, which pyomeca is based on:

@article{jors-xarray,
title = {Xarray: N-D labeled arrays and datasets in Python},
author = {Joe Hamman and Stephan Hoyer},
year = {2017},
journal = {Journal of Open Research Software}
}

Contributors

Pyomeca is an open-source project created and supported by the S2M lab.

biosiglive's People

Contributors

aceglia avatar pariterre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

biosiglive's Issues

[JOSS REVIEW] Contribution and authorship

The list of authors needs clarification. Three authors are listed in the paper, but only one (or maybe two) author(s) seems to have committed to repository. The command git shortlog --summary yields

107  Amedeo
1  Pariterre
19  aceglia
72  ceglia

Can you please explain the contribution of the other authors?

This is related to openjournals/joss-reviews#5091

[JOSS REVIEW] Problem running `examples/EMG_streaming.py`

When running the EMG_streaming.py example I get the following error

python EMG_streaming.py
Traceback (most recent call last):
  File "/Users/finsberg/local/src/biosiglive/examples/EMG_streaming.py", line 22, in <module>
    from examples.custom_interface import MyInterface
ModuleNotFoundError: No module named 'examples'

Changing the line

from examples.custom_interface import MyInterface

to

from custom_interface import MyInterface

fixes the problem. Perhaps I am doing something wrong?

This is related to openjournals/joss-reviews#5091

[JOSS REVIEW] Fix setup script

I would clean up the setup script so that it is straight forward to install this package without having to read the documentation.

It looks like you have some required dependencies, e.g matplotlib, numpy , scipy. You can read how to specify these in setup.py here: https://setuptools.pypa.io/en/latest/userguide/dependency_management.html#declaring-required-dependency.

For the optional dependencies you should also consider to add these to extras_require, see https://setuptools.pypa.io/en/latest/userguide/dependency_management.html#optional-dependencies

I would also not pin the dependencies to any exact version (like you do in requirements.txt) unless you absolutely need a specific version of a package.
That just makes it hard to combine you library with other libraries. Also, if you specify the dependencies in setup.py, then you don't need the requirements.txt anymore.

It is also not clear to my why you need to have this line

package_data={"": ["*.json"]},

since I could not find any .json files in the repo.

Finally, using a pure setup.py file is considered legacy, and you should consider to use a more modern way of specifying the metadata for your project, e.g using pyproject.toml

This is related to openjournals/joss-reviews#5091

[JOSS REVIEW] Add documentation page

The only documentation I could find about this project is within the README file.

I think this project deserves a proper documentation hosted at e.g GitHub pages or Read the docs. This would make the project much more digestible for more users. Furthermore, you could also host API documentation which you could generate using Sphinx API doc on this page.

On such a documentation page, you should also add separate pages with the examples.

This is related to openjournals/joss-reviews#5091

Update one subplot at the time

For example, in a loop for N muscles, when the condition is respected for one muscle (enough activation), update, else don't update

[JOSS REVIEW] Problem running `examples/custom_interface.py`

When running the custom_interface.py demo I get the following error

custom_interface.py
Traceback (most recent call last):
  File "/Users/finsberg/local/src/biosiglive/examples/custom_interface.py", line 221, in <module>
    print(interface.get_kinematics_from_markers("My markers", get_markers_data=True))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/finsberg/local/src/biosiglive/examples/custom_interface.py", line 201, in get_kinematics_from_markers
    return self.marker_sets[marker_set_idx].get_kinematics(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/finsberg/mambaforge/envs/biosiglive/lib/python3.11/site-packages/biosiglive/interfaces/param.py", line 279, in get_kinematics
    self.kin_data = self.msk_class.compute_inverse_kinematics(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/finsberg/mambaforge/envs/biosiglive/lib/python3.11/site-packages/biosiglive/processing/msk_functions.py", line 94, in compute_inverse_kinematics
    ik = biorbd.InverseKinematics(self.model, markers)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/finsberg/mambaforge/envs/biosiglive/lib/python3.11/site-packages/biorbd/rigid_body.py", line 218, in __init__
    raise ValueError(f"The standard dimension of the NumPy array should be (nb_dim, nb_marker, nb_frame)")
ValueError: The standard dimension of the NumPy array should be (nb_dim, nb_marker, nb_frame)

I installed biosiglive from conda-forge on Mac ARM64.

This is related to openjournals/joss-reviews#5091

MVC Compute module : trial plotting doesn't plot raw data if plotting again after selecting processed or both

When asked which data to plot after a trial or after sating yes to plotting again, if you do not use the "plot raw only" option, it will become impossible to "plot raw only" for this trial and the next ones unless you reload the module.

image

This is a simple fix, the "plot raw only" option was missed in /processing/compute_mvc.py line 357 if statement :

if plot != "c":
    if plot == "p":
        data = processed_data
        legend = ["Processed"]
    elif plot == "b":
        data = [raw_data, processed_data]
        legend = ["Raw data", "Processed"]

just add

elif plot == "pr":
    data = raw_data
    legend = ["Raw data"]

[JOSS REVIEW] Add documentation to each example

I see you have a lot of examples in the examples folder but it is very hard to know what these examples are doing. It would be good to have proper text explaining each example. One way could be to add each example to a separate folder and add readme file in each folder. Another way could by to embed the documentation directly in the python files. In the latter case I would recommend check out jupytext where you can convert the documentation to markdown (or jupyter notebooks), and then you can host the documentation for these examples online (see #6).

This is related to openjournals/joss-reviews#5091

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.