resurfemg


Nameresurfemg JSON
Version 0.3.0 PyPI version JSON
download
home_pageNone
SummaryA package for analysis of respiratory EMG data
upload_time2024-05-27 10:15:09
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseApache-2.0
keywords electromyography emg respiratory python surface emg
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
    <img style="width: 35%; height: 35%" src="https://github.com/resurfemg/resurfemg/blob/main/Logo_rond_tekst.svg">
</p>

[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.6811554.svg)](https://doi.org/10.5281/zenodo.6811554)
[![PyPI](https://img.shields.io/pypi/v/resurfemg.svg)](https://pypi.python.org/pypi/resurfemg/)
[![Sanity](https://github.com/resurfemg/resurfemg/actions/workflows/on-commit.yml/badge.svg)](https://github.com/resurfemg/resurfemg/actions/workflows/on-commit.yml)
[![Sanity](https://github.com/resurfemg/resurfemg/actions/workflows/on-tag.yml/badge.svg)](https://github.com/resurfemg/resurfemg/actions/workflows/on-tag.yml)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/6487/badge)](https://bestpractices.coreinfrastructure.org/projects/6487)
[![fair-software.eu](https://img.shields.io/badge/fair--software.eu-%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F-green)](https://fair-software.eu)
[![status](https://joss.theoj.org/papers/5f08d1f2bb717b7d05762296e37ded3d/status.svg)](https://joss.theoj.org/papers/5f08d1f2bb717b7d05762296e37ded3d)

**ReSurfEMG** is an open source collaborative python library for analysis
of respiratory electromyography (EMG). On the same site as 
the repository for this library we keep [related resources](https://github.com/ReSurfEMG?tab=repositories). 

ReSurfEMG includes a [main code library](https://github.com/ReSurfEMG/ReSurfEMG) where the user can access the code to change various filter and analysis settings directly and/or in our [researcher interface notebooks](https://github.com/ReSurfEMG/ReSurfEMG/tree/main/researcher_interface).
In addition, ReSurfEMG has a [dashboard interface](https://github.com/ReSurfEMG/ReSurfEMG-dashboard) which contains default settings for preprocessing and analysis which can be changed through a graphical (no code) interface. We have some functionality available through a [command line interface](#command-line-interface) as well.

The library was initially
built for surface EMG, however many functions will also work for
invasively measured respiratory EMG.  This library
supports the ongoing research at University of Twente on respiratory
EMG.


### Program files

The core functions of ReSurfEMG are in the folder [resurfemg](https://github.com/ReSurfEMG/ReSurfEMG/tree/main/resurfemg):

-   **cli:** Scripts for the command line interface
-   **config:** Configure all paths for data analysis
-   **data_connector:**  Converter functions for various hardware/software and the TMSisdk lite module
-   **helper_functions:** General functions to support the functions in this repository
-   **machine_learning:** Run machine learning algorithms on arrays
-   **post-processing:** Calculate features from the respiratory data:
      - entropy
      - area under curve
      - time under curve
      - slope
      - peak in breath
      - variability
      - SampEn adapted from nolds package
-   **pre_processing:** Process the raw EMG signal
      - ecg-removal: ICA and gating
      - envelope: RMS and smoothers
      - filtering: cutters, low-, high- and bandpass, notchfilter, computer power loss
-   **visualization:** Show powerspectrum


### Folders and Notebooks

Our [guide to notebooks](https://github.com/ReSurfEMG/ReSurfEMG/blob/main/notebooks_guide.md) is under construction. To look around keep in mind the following distinction on folders:

researcher_interface:
- These are a growing series of interactive notebooks that allow
  researchers to investigate questions about their own EMG data
  - ⚡ Important: in almost all data there will be a time 
  difference between EMG signals and ventilator signals. You can
  pre-process to correct for this lead or lag with the notebook
  called lead_lag_mismatch_upsample.

open_work:
- This folder contains experimental work by core members of the ReSurfEMG
  team (Dr. Eline Mos-Oppersma, Rob Warnaar, Dr. Walter Baccinelli and Dr. Candace Makeda Moore)


### Data sets

The notebooks are configured to run on various datasets.  Contact
Dr. Eline Mos-Oppersma( 📫 e.mos-oppersma@utwente.nl) to discuss any
questions on data configuration for your datasets.

If you want to use a standardized dataset for any purpose we recommend
the data in the ReSurfEMG/synthetic_data repository

[![DOI](https://zenodo.org/badge/635680008.svg)](https://zenodo.org/badge/latestdoi/635680008)

Data there can be used with any respiratory EMG algorithms in any program. Thus that data can function as a benchmarking set to compare algorithms across different programs.


### Configuring (to work with your data)

In order to preprocess and/or to train  models the code needs to be
able to locate the raw data you want it to find.

There are several ways to specify the location of the following
directories:

-   **root_emg_directory:** Special directory.  The rest of the directory layout can
    be derived from its location.
-   **preprocessed:** The directory that will be used by preprocessing
    code to output to.
-   **models:** The directory to output trained models to.

You can store this information persistently in several locations.

1.  In the same directory where you run the script (or the notebook).
    e.g. `./config.json`.
2.  In home directory, e.g. `~/.resurfemg/config.json`.
3.  In global directory, e.g. `/etc/resurfemg/config.json`.

However, we highly recommend you use the home directory.
This file can have this or similar contents:

    {
        "root_emg_directory": "/mnt/data",
        "preprocessed": "/mnt/data/preprocessed",
        "models": "/mnt/data/models",
        "output": "/mnt/data/output",
    }

The file is read as follows: if the files specifies `root_emg_directory`
directory, then the missing entries are assumed to be relative to
the root.  You don't need to specify all entries.

### Test data

You can get test data by extracting it from the Docker image like
this:

``` sh
mkdir -p not_pushed
cd ./not_pushed
docker create --name test-data crabbone/resurfemg-poly5-test-files:latest
docker cp test-data:/ReSurfEMG/tests/not_pushed/. .
docker rm -f test-data
```

### Supported Platforms

ReSurfEMG is a pure Python package. Below is the list of
platforms that should work. Other platforms may work, but have had less extensive testing.
Please note that where
python.org Python stated as supported, it means
that versions 3.9 and 3.10 are supported.

#### AMD64 (x86)

|                             | Linux     | Win       | OSX       |
|:---------------------------:|:---------:|:---------:|:---------:|
| ![p](etc/python-logo.png)   | Supported | Supported   | Unknown   |
| ![a](etc/anaconda-logo.png) | Supported | Supported | Supported |

### Installation for all supported platforms

Installation with Anaconda/conda and/or mamba are the preffered methods.
They are covered in [the "Getting Started" section](#Getting-Started). 
If you wish to install with pip:

1. Create and activate a virtual environment (see developer setup section for more details) 
2. Install ResurfEMG package by running `pip install resurfemg`.


## Getting Started
#### with the recommended Conda setup

How to get the notebooks running?  Assuming the raw data set and
metadata is available. Note for non-conda installations see next sections.

0. Assuming you are using conda for package management:    
  * Make sure you are in no environment:

      ```sh
      conda deactivate
      ```

      _(optional repeat if you are in the base environment)_

      You can build on your
      base environment if you want, or if you want to not use option A, you can go below it (no environment)


1. Option A: Fastest option:
  In a base-like environment with mamba installed, you can install all Python packages required, using `mamba` and the `environment.yml` file. 

  If you do not have mamba installed you can follow instructions [here](https://anaconda.org/conda-forge/mamba)
  


   * The command for Windows/Anaconda/Mamba users can be something like:

     ```sh
     mamba env create -f environment.yml
     ```

Option B: To work with the most current versions with the possibility for development:
  Install all Python packages required, using `conda` and the `environment.yml` file. 


   * The command for Windows/Anaconda users can be something like:

     ```sh
     conda env create -f environment.yml
     ```

   * Linux users can create their own environment by hand (use
     .[dev] as in setup).
    
  Make sure to enter your newly created environment.

Option C: In theory if you want to work, but never develop (i.e. add code), as a conda user
   with a stable (released) version create an empty environment, and install
   there: 


   * Create a blank environment with python pinned to 3.8 (assuming version < 0.1.0):

     ```sh
     conda create -n blank python=3.8
     ```

   * Install within the blank environment
      ```sh
        conda activate blank
        conda install -c conda-forge -c resurfemg resurfemg jupyter ipympl
        ```

2. Open a notebook (we use [Jupyter
   notebooks](https://jupyter.org/try-jupyter/retro/notebooks/?path=notebooks/Intro.ipynb))
   in researcher_interface folder and interactively run the cells.
   You can use the command `jupyter notebook` to open a browser window
   on the folders of notebooks.  Note, if you run with an installed
   library import appropriately. The [basic_emg_analysis](https://github.com/ReSurfEMG/ReSurfEMG/blob/main/researcher_interface/basic_emg_analysis.ipynb) notebook can 
   be used to understand how to use the package. 



## Advanced contributor's setup / "Developer's setup"

We distinguish between people who want to use this library in
their own code and/or analysis and people who also want to develop this library who we call developers, be it as
members of our team or independent contributors.  People who
simply want to use our library need to install the packaged version
from one of the package indexes to which we publish released versions
(eg. PyPI).  This section of the readme is for advanced developers who want to
modify the library code (and possibly contribute their changes back or eventually publish thier own modified fork). NB: you can accomplish modifications of the code, submit PRs and soforth without 
a 'developer's setup' but we feel this setup will make advanced contributions easier.

We have transitioned to a fully Python 3.9+ environment. 
(For older instructions with `venv` please see versions below 0.2.0, and
adapt them if using Windows and/or a different Python version than
Python.org Python. e.g. you may need to use `.venv\Scripts\activate.bat` in
place of `.venv/bin/activate`) 
The instructions below are for our newer versions above 3.0.0. This will create 
a distributable package from the source code, then install it in the currently
active environment.  This will also install development tools we use
s.a. `pytest` and `codestyle` and will also install tools we use for
working with the library, s.a. `jupyter`:


After checking out the source code, create virtual environment.  Both
`conda` and `venv` environments are supported, however, if you are on
Windows, we reccomend using `conda`. 



1. Using Anaconda Python

   ```sh
   conda create -n resurfemg python=3.9
   conda activate resurfemg
   pip install -e .[dev]
   ```

2. Using PyPI Python

# On Linux:
``` sh
python3 -m venv .venv
source .venv/bin/activate
``` 
  
# On Windows:
``` sh
python -m venv .venv
.venv\Scripts\activate.bat
pip install -e .[dev]
```

Now you should have everything necessary to start working on the
source code.  Whenever you make any changes, re-run `pip install -e .[dev]` to
see them applied in your environment.

## Generating documentation

Online documentation can be found at
https://resurfemg.github.io/ReSurfEMG/
or on https://readthedocs.org/ by searching for ReSurfEMG.
Up to date documentation can be generated in command-line as follows
(in bash terminal):

``` sh
python3 -m venv .venv
source .venv/bin/activate
pip install -e .[docs]
python setup.py apidoc
python setup.py build_sphinx
```

If you are working in a VScode command line interface (terminal cmd)
should be more or less something like the following:

This is given with `cmd.exe` in mind:

``` sh
python3 -m venv .venv
.venv\Scripts\activate.bat
pip install -e .[docs]
python setup.py apidoc
python setup.py build_sphinx
```


## Automation

The project comes with several modifications to the typical
default `setup.py`.

At the moment, the support for Anaconda Python is lacking.  The
instructions and the commands listed below will work in Anaconda
installation but due to the difference in management of installed
packages, the project will be installed into base environment
regardless of the currently active one.

The project has a sub-project of a related dashboard.  Dashboard is a GUI that
exposes some of the project's functionality. In the past we kept a a legacy dashboard
in the same repository with ReSurfEMG code but we have deleted it. The
current version of the dashboard into it's own repository:
https://github.com/ReSurfEMG/ReSurfEMG-dashboard


### New commands

Please note that documentation is built using `sphinx` command
for `setuptools`: `setup.py build_sphinx`, but `sphinx` is not
installed as part of development dependencies, rather it is declared
as a dependency of `setup.py` itself.  There are cases when `setup.py`
will not install its own dependencies.  You are advised to install
them manually.

* `setup.py isort` checks that the imports are properly formatted and
  sorted.
* `setup.py apidoc` generates RST outlines necessary to generate
  documentation.

### Testing

The project doesn't include testing data.  It was packaged into a Docker
image which can be found at `crabbone/resurfemg-poly5-test-files:latest`.
This test data was created by taking a signal from equipment, not a human,
and certainly not a patient.

It is possible to run tests in container created from this image.
Alternatively, you may download the image and extract directory
`/ReSurfEMG/tests/not_pushed` into `not_pushed` in the root of the
project and run:

``` sh
python3 -m venv .venv
source .venv/bin/activate
pip install -e .[tests]
pytest
```

Below is a snippet that may help you to run the tests in a container:

``` sh
docker run --rm -v $(pwd):/ci \
    --cap-add=SYS_ADMIN \
    --privileged=true \
    crabbone/resurfemg-poly5-test-files \
    sh -c 'set -xe
        cd /ci
        mkdir -p ./not_pushed/
        mount --bind /ReSurfEMG/tests/not_pushed/ ./not_pushed/
        pytest'
```



## Command-Line Interface

You will be able to preprocess, train and use models using command-line interface.
You can also, in some cases, create files in the correct format for our Dashboard
in a per folder batch process.

Below is an example of how to do that:

This will pre-process (with the alternative_a_pipeline_multi algorithm) the
 Poly5 files in the
`/mnt/data/originals` directory, and output leads 1 and 2 preprocessed.
(Note the \ symbol is simply a line-break and not meant to be included.)

    python -m resurfemg acquire \
           --input /mnt/data/originals \
           --lead 1 --lead 2 \
           --output /mnt/data/preprocessed \
           --preprocessing alternative_a_pipeline_multi \
           

The following will run an ML model over all files:

    python -m resurfemg ml |
            --input /mnt/data/preprocessed \
            --output /mnt/data/ml_output \
            --model  ml_models/finalized_lr_model_in_111.sav \

You can also make synthetic data. To explore this start with
    `python -m resurfemg synth --help`
You can also make from horizontally formated csv files 
that can be read by the dashboard. To explore this start with
    `python -m resurfemg save_np --help`
The help command is also available for ml and acquire.

All long options have short aliases.


✨Copyright 2022 Netherlands eScience Center and U. Twente
Licensed under the Apache License, version 2.0. See LICENSE for details.✨

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "resurfemg",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "Eline Mos-Oppersma <e.oppersma@utwente.nl>, Rob Warnaar <r.s.p.warnaar@utwente.nl>",
    "keywords": "electromyography, EMG, respiratory, Python, surface EMG",
    "author": null,
    "author_email": null,
    "download_url": null,
    "platform": null,
    "description": "<p align=\"center\">\n    <img style=\"width: 35%; height: 35%\" src=\"https://github.com/resurfemg/resurfemg/blob/main/Logo_rond_tekst.svg\">\n</p>\n\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.6811554.svg)](https://doi.org/10.5281/zenodo.6811554)\n[![PyPI](https://img.shields.io/pypi/v/resurfemg.svg)](https://pypi.python.org/pypi/resurfemg/)\n[![Sanity](https://github.com/resurfemg/resurfemg/actions/workflows/on-commit.yml/badge.svg)](https://github.com/resurfemg/resurfemg/actions/workflows/on-commit.yml)\n[![Sanity](https://github.com/resurfemg/resurfemg/actions/workflows/on-tag.yml/badge.svg)](https://github.com/resurfemg/resurfemg/actions/workflows/on-tag.yml)\n[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/6487/badge)](https://bestpractices.coreinfrastructure.org/projects/6487)\n[![fair-software.eu](https://img.shields.io/badge/fair--software.eu-%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F-green)](https://fair-software.eu)\n[![status](https://joss.theoj.org/papers/5f08d1f2bb717b7d05762296e37ded3d/status.svg)](https://joss.theoj.org/papers/5f08d1f2bb717b7d05762296e37ded3d)\n\n**ReSurfEMG** is an open source collaborative python library for analysis\nof respiratory electromyography (EMG). On the same site as \nthe repository for this library we keep [related resources](https://github.com/ReSurfEMG?tab=repositories). \n\nReSurfEMG includes a [main code library](https://github.com/ReSurfEMG/ReSurfEMG) where the user can access the code to change various filter and analysis settings directly and/or in our [researcher interface notebooks](https://github.com/ReSurfEMG/ReSurfEMG/tree/main/researcher_interface).\nIn addition, ReSurfEMG has a [dashboard interface](https://github.com/ReSurfEMG/ReSurfEMG-dashboard) which contains default settings for preprocessing and analysis which can be changed through a graphical (no code) interface. We have some functionality available through a [command line interface](#command-line-interface) as well.\n\nThe library was initially\nbuilt for surface EMG, however many functions will also work for\ninvasively measured respiratory EMG.  This library\nsupports the ongoing research at University of Twente on respiratory\nEMG.\n\n\n### Program files\n\nThe core functions of ReSurfEMG are in the folder [resurfemg](https://github.com/ReSurfEMG/ReSurfEMG/tree/main/resurfemg):\n\n-   **cli:** Scripts for the command line interface\n-   **config:** Configure all paths for data analysis\n-   **data_connector:**  Converter functions for various hardware/software and the TMSisdk lite module\n-   **helper_functions:** General functions to support the functions in this repository\n-   **machine_learning:** Run machine learning algorithms on arrays\n-   **post-processing:** Calculate features from the respiratory data:\n      - entropy\n      - area under curve\n      - time under curve\n      - slope\n      - peak in breath\n      - variability\n      - SampEn adapted from nolds package\n-   **pre_processing:** Process the raw EMG signal\n      - ecg-removal: ICA and gating\n      - envelope: RMS and smoothers\n      - filtering: cutters, low-, high- and bandpass, notchfilter, computer power loss\n-   **visualization:** Show powerspectrum\n\n\n### Folders and Notebooks\n\nOur [guide to notebooks](https://github.com/ReSurfEMG/ReSurfEMG/blob/main/notebooks_guide.md) is under construction. To look around keep in mind the following distinction on folders:\n\nresearcher_interface:\n- These are a growing series of interactive notebooks that allow\n  researchers to investigate questions about their own EMG data\n  - \u26a1 Important: in almost all data there will be a time \n  difference between EMG signals and ventilator signals. You can\n  pre-process to correct for this lead or lag with the notebook\n  called lead_lag_mismatch_upsample.\n\nopen_work:\n- This folder contains experimental work by core members of the ReSurfEMG\n  team (Dr. Eline Mos-Oppersma, Rob Warnaar, Dr. Walter Baccinelli and Dr. Candace Makeda Moore)\n\n\n### Data sets\n\nThe notebooks are configured to run on various datasets.  Contact\nDr. Eline Mos-Oppersma( \ud83d\udceb e.mos-oppersma@utwente.nl) to discuss any\nquestions on data configuration for your datasets.\n\nIf you want to use a standardized dataset for any purpose we recommend\nthe data in the ReSurfEMG/synthetic_data repository\n\n[![DOI](https://zenodo.org/badge/635680008.svg)](https://zenodo.org/badge/latestdoi/635680008)\n\nData there can be used with any respiratory EMG algorithms in any program. Thus that data can function as a benchmarking set to compare algorithms across different programs.\n\n\n### Configuring (to work with your data)\n\nIn order to preprocess and/or to train  models the code needs to be\nable to locate the raw data you want it to find.\n\nThere are several ways to specify the location of the following\ndirectories:\n\n-   **root_emg_directory:** Special directory.  The rest of the directory layout can\n    be derived from its location.\n-   **preprocessed:** The directory that will be used by preprocessing\n    code to output to.\n-   **models:** The directory to output trained models to.\n\nYou can store this information persistently in several locations.\n\n1.  In the same directory where you run the script (or the notebook).\n    e.g. `./config.json`.\n2.  In home directory, e.g. `~/.resurfemg/config.json`.\n3.  In global directory, e.g. `/etc/resurfemg/config.json`.\n\nHowever, we highly recommend you use the home directory.\nThis file can have this or similar contents:\n\n    {\n        \"root_emg_directory\": \"/mnt/data\",\n        \"preprocessed\": \"/mnt/data/preprocessed\",\n        \"models\": \"/mnt/data/models\",\n        \"output\": \"/mnt/data/output\",\n    }\n\nThe file is read as follows: if the files specifies `root_emg_directory`\ndirectory, then the missing entries are assumed to be relative to\nthe root.  You don't need to specify all entries.\n\n### Test data\n\nYou can get test data by extracting it from the Docker image like\nthis:\n\n``` sh\nmkdir -p not_pushed\ncd ./not_pushed\ndocker create --name test-data crabbone/resurfemg-poly5-test-files:latest\ndocker cp test-data:/ReSurfEMG/tests/not_pushed/. .\ndocker rm -f test-data\n```\n\n### Supported Platforms\n\nReSurfEMG is a pure Python package. Below is the list of\nplatforms that should work. Other platforms may work, but have had less extensive testing.\nPlease note that where\npython.org Python stated as supported, it means\nthat versions 3.9 and 3.10 are supported.\n\n#### AMD64 (x86)\n\n|                             | Linux     | Win       | OSX       |\n|:---------------------------:|:---------:|:---------:|:---------:|\n| ![p](etc/python-logo.png)   | Supported | Supported   | Unknown   |\n| ![a](etc/anaconda-logo.png) | Supported | Supported | Supported |\n\n### Installation for all supported platforms\n\nInstallation with Anaconda/conda and/or mamba are the preffered methods.\nThey are covered in [the \"Getting Started\" section](#Getting-Started). \nIf you wish to install with pip:\n\n1. Create and activate a virtual environment (see developer setup section for more details) \n2. Install ResurfEMG package by running `pip install resurfemg`.\n\n\n## Getting Started\n#### with the recommended Conda setup\n\nHow to get the notebooks running?  Assuming the raw data set and\nmetadata is available. Note for non-conda installations see next sections.\n\n0. Assuming you are using conda for package management:    \n  * Make sure you are in no environment:\n\n      ```sh\n      conda deactivate\n      ```\n\n      _(optional repeat if you are in the base environment)_\n\n      You can build on your\n      base environment if you want, or if you want to not use option A, you can go below it (no environment)\n\n\n1. Option A: Fastest option:\n  In a base-like environment with mamba installed, you can install all Python packages required, using `mamba` and the `environment.yml` file. \n\n  If you do not have mamba installed you can follow instructions [here](https://anaconda.org/conda-forge/mamba)\n  \n\n\n   * The command for Windows/Anaconda/Mamba users can be something like:\n\n     ```sh\n     mamba env create -f environment.yml\n     ```\n\nOption B: To work with the most current versions with the possibility for development:\n  Install all Python packages required, using `conda` and the `environment.yml` file. \n\n\n   * The command for Windows/Anaconda users can be something like:\n\n     ```sh\n     conda env create -f environment.yml\n     ```\n\n   * Linux users can create their own environment by hand (use\n     .[dev] as in setup).\n    \n  Make sure to enter your newly created environment.\n\nOption C: In theory if you want to work, but never develop (i.e. add code), as a conda user\n   with a stable (released) version create an empty environment, and install\n   there: \n\n\n   * Create a blank environment with python pinned to 3.8 (assuming version < 0.1.0):\n\n     ```sh\n     conda create -n blank python=3.8\n     ```\n\n   * Install within the blank environment\n      ```sh\n        conda activate blank\n        conda install -c conda-forge -c resurfemg resurfemg jupyter ipympl\n        ```\n\n2. Open a notebook (we use [Jupyter\n   notebooks](https://jupyter.org/try-jupyter/retro/notebooks/?path=notebooks/Intro.ipynb))\n   in researcher_interface folder and interactively run the cells.\n   You can use the command `jupyter notebook` to open a browser window\n   on the folders of notebooks.  Note, if you run with an installed\n   library import appropriately. The [basic_emg_analysis](https://github.com/ReSurfEMG/ReSurfEMG/blob/main/researcher_interface/basic_emg_analysis.ipynb) notebook can \n   be used to understand how to use the package. \n\n\n\n## Advanced contributor's setup / \"Developer's setup\"\n\nWe distinguish between people who want to use this library in\ntheir own code and/or analysis and people who also want to develop this library who we call developers, be it as\nmembers of our team or independent contributors.  People who\nsimply want to use our library need to install the packaged version\nfrom one of the package indexes to which we publish released versions\n(eg. PyPI).  This section of the readme is for advanced developers who want to\nmodify the library code (and possibly contribute their changes back or eventually publish thier own modified fork). NB: you can accomplish modifications of the code, submit PRs and soforth without \na 'developer's setup' but we feel this setup will make advanced contributions easier.\n\nWe have transitioned to a fully Python 3.9+ environment. \n(For older instructions with `venv` please see versions below 0.2.0, and\nadapt them if using Windows and/or a different Python version than\nPython.org Python. e.g. you may need to use `.venv\\Scripts\\activate.bat` in\nplace of `.venv/bin/activate`) \nThe instructions below are for our newer versions above 3.0.0. This will create \na distributable package from the source code, then install it in the currently\nactive environment.  This will also install development tools we use\ns.a. `pytest` and `codestyle` and will also install tools we use for\nworking with the library, s.a. `jupyter`:\n\n\nAfter checking out the source code, create virtual environment.  Both\n`conda` and `venv` environments are supported, however, if you are on\nWindows, we reccomend using `conda`. \n\n\n\n1. Using Anaconda Python\n\n   ```sh\n   conda create -n resurfemg python=3.9\n   conda activate resurfemg\n   pip install -e .[dev]\n   ```\n\n2. Using PyPI Python\n\n# On Linux:\n``` sh\npython3 -m venv .venv\nsource .venv/bin/activate\n``` \n  \n# On Windows:\n``` sh\npython -m venv .venv\n.venv\\Scripts\\activate.bat\npip install -e .[dev]\n```\n\nNow you should have everything necessary to start working on the\nsource code.  Whenever you make any changes, re-run `pip install -e .[dev]` to\nsee them applied in your environment.\n\n## Generating documentation\n\nOnline documentation can be found at\nhttps://resurfemg.github.io/ReSurfEMG/\nor on https://readthedocs.org/ by searching for ReSurfEMG.\nUp to date documentation can be generated in command-line as follows\n(in bash terminal):\n\n``` sh\npython3 -m venv .venv\nsource .venv/bin/activate\npip install -e .[docs]\npython setup.py apidoc\npython setup.py build_sphinx\n```\n\nIf you are working in a VScode command line interface (terminal cmd)\nshould be more or less something like the following:\n\nThis is given with `cmd.exe` in mind:\n\n``` sh\npython3 -m venv .venv\n.venv\\Scripts\\activate.bat\npip install -e .[docs]\npython setup.py apidoc\npython setup.py build_sphinx\n```\n\n\n## Automation\n\nThe project comes with several modifications to the typical\ndefault `setup.py`.\n\nAt the moment, the support for Anaconda Python is lacking.  The\ninstructions and the commands listed below will work in Anaconda\ninstallation but due to the difference in management of installed\npackages, the project will be installed into base environment\nregardless of the currently active one.\n\nThe project has a sub-project of a related dashboard.  Dashboard is a GUI that\nexposes some of the project's functionality. In the past we kept a a legacy dashboard\nin the same repository with ReSurfEMG code but we have deleted it. The\ncurrent version of the dashboard into it's own repository:\nhttps://github.com/ReSurfEMG/ReSurfEMG-dashboard\n\n\n### New commands\n\nPlease note that documentation is built using `sphinx` command\nfor `setuptools`: `setup.py build_sphinx`, but `sphinx` is not\ninstalled as part of development dependencies, rather it is declared\nas a dependency of `setup.py` itself.  There are cases when `setup.py`\nwill not install its own dependencies.  You are advised to install\nthem manually.\n\n* `setup.py isort` checks that the imports are properly formatted and\n  sorted.\n* `setup.py apidoc` generates RST outlines necessary to generate\n  documentation.\n\n### Testing\n\nThe project doesn't include testing data.  It was packaged into a Docker\nimage which can be found at `crabbone/resurfemg-poly5-test-files:latest`.\nThis test data was created by taking a signal from equipment, not a human,\nand certainly not a patient.\n\nIt is possible to run tests in container created from this image.\nAlternatively, you may download the image and extract directory\n`/ReSurfEMG/tests/not_pushed` into `not_pushed` in the root of the\nproject and run:\n\n``` sh\npython3 -m venv .venv\nsource .venv/bin/activate\npip install -e .[tests]\npytest\n```\n\nBelow is a snippet that may help you to run the tests in a container:\n\n``` sh\ndocker run --rm -v $(pwd):/ci \\\n    --cap-add=SYS_ADMIN \\\n    --privileged=true \\\n    crabbone/resurfemg-poly5-test-files \\\n    sh -c 'set -xe\n        cd /ci\n        mkdir -p ./not_pushed/\n        mount --bind /ReSurfEMG/tests/not_pushed/ ./not_pushed/\n        pytest'\n```\n\n\n\n## Command-Line Interface\n\nYou will be able to preprocess, train and use models using command-line interface.\nYou can also, in some cases, create files in the correct format for our Dashboard\nin a per folder batch process.\n\nBelow is an example of how to do that:\n\nThis will pre-process (with the alternative_a_pipeline_multi algorithm) the\n Poly5 files in the\n`/mnt/data/originals` directory, and output leads 1 and 2 preprocessed.\n(Note the \\ symbol is simply a line-break and not meant to be included.)\n\n    python -m resurfemg acquire \\\n           --input /mnt/data/originals \\\n           --lead 1 --lead 2 \\\n           --output /mnt/data/preprocessed \\\n           --preprocessing alternative_a_pipeline_multi \\\n           \n\nThe following will run an ML model over all files:\n\n    python -m resurfemg ml |\n            --input /mnt/data/preprocessed \\\n            --output /mnt/data/ml_output \\\n            --model  ml_models/finalized_lr_model_in_111.sav \\\n\nYou can also make synthetic data. To explore this start with\n    `python -m resurfemg synth --help`\nYou can also make from horizontally formated csv files \nthat can be read by the dashboard. To explore this start with\n    `python -m resurfemg save_np --help`\nThe help command is also available for ml and acquire.\n\nAll long options have short aliases.\n\n\n\u2728Copyright 2022 Netherlands eScience Center and U. Twente\nLicensed under the Apache License, version 2.0. See LICENSE for details.\u2728\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "A package for analysis of respiratory EMG data",
    "version": "0.3.0",
    "project_urls": {
        "Changelog": "https://github.com/ReSurfEMG/ReSurfEMG/blob/main/CHANGELOG.md",
        "Documentation": "https://resurfemg.github.io/ReSurfEMG/",
        "Homepage": "https://github.com/ReSurfEMG",
        "Issues": "https://github.com/ReSurfEMG/ReSurfEMG/issues",
        "Repository": "https://github.com/ReSurfEMG/ReSurfEMG"
    },
    "split_keywords": [
        "electromyography",
        " emg",
        " respiratory",
        " python",
        " surface emg"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "747dafd35182264228b538cf3123c45d5afed87da8b9f90c1b7c1f45595edbd7",
                "md5": "20eaa16c76d3ce2394846dafb41c2ceb",
                "sha256": "e9c87a8bd4d19cb194a2aecfd301834dbe285e53d02a771635143b849034e9b5"
            },
            "downloads": -1,
            "filename": "resurfemg-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "20eaa16c76d3ce2394846dafb41c2ceb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 52707,
            "upload_time": "2024-05-27T10:15:09",
            "upload_time_iso_8601": "2024-05-27T10:15:09.911181Z",
            "url": "https://files.pythonhosted.org/packages/74/7d/afd35182264228b538cf3123c45d5afed87da8b9f90c1b7c1f45595edbd7/resurfemg-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-27 10:15:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ReSurfEMG",
    "github_project": "ReSurfEMG",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "resurfemg"
}
        
Elapsed time: 0.75357s