Skip to content

Commit 3efcce7

Browse files
authored
Merge pull request #1 from cvjena/develop
Merge development changes into main branch
2 parents 9cb15ba + 50e616b commit 3efcce7

16 files changed

+389
-68
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ MANIFEST
5454

5555
#jupyter
5656
.ipynb_checkpoints
57-
*.ipynb
5857

5958
# app/data
6059
temp_results

README.md

Lines changed: 54 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,92 @@
11
# electromyogram
22

3-
This is a small python package to create a Electromyogram (EMG) Intensity plots for facial muscles with facial structure.
4-
The current focus is on the solely facial muscles but it could be extended to other muscles, but this is not planned yet.
3+
![Teaser](files/teaser.jpg)
54

6-
We currently support the two following schematics for acquiring the EMG data:
5+
This Python package provides a convenient way to create an Electromyogram (EMG) Intensity plot specifically designed for facial muscles with facial structure. With this tool, you can visualize and analyze the intensity of EMG data collected from various facial muscles.
76

8-
- Fridlund and Cappacio () []
9-
- Kuramoto et al. () []
7+
A small demo is hosted [here](https://semg.inf-cv.uni-jena.de/), together with the tool [face-projection](https://github.com/cvjena/face-projection) for a projection onto the face.
108

11-
## Installation
9+
## Why use sEMG Intensity Plot?
10+
11+
- **Easy to use**: The package provides a straightforward interface, making it accessible for users of all levels of expertise.
12+
- **Visualize muscle activity**: The EMG Intensity plot allows you to visualize the intensity of muscle activity over the face, providing insights into patterns and variations.
13+
- **Designed explicitly for facial** muscles**: The tool focuses on facial muscles, enabling you to study and understand muscle activity in the face, which can be particularly useful in fields like facial expression analysis, neuroscience, and rehabilitation.
14+
- **Potential for extension**: While the current focus is on facial muscles, this tool could potentially be extended to analyze other muscle groups.
15+
- **Beyond muscles**: The tool can also be used to plot additional facial information, such as oxygen saturation, but this is not officially supported yet.
1216

13-
Currently the package is not available on PyPI.
14-
Thus, you have to install it from the source code.
15-
If you want to use the package in a virtual environment, you have to activate it first.
16-
Clone this repository and install it with pip:
17+
## Installation
1718

19+
The package is available on [PyPI](https://pypi.org/project/electromyogram/) and can be installed with `pip`:
20+
1821
```bash
19-
git clone <link to this repository>
20-
cd electromyogram
21-
pip install .
22+
pip install electromyogram
2223
```
2324

24-
It is then available in your python environment, and you can import it with:
25+
If you want to install it locally to add changes, please close the repository and install it with `pip` in development mode.
26+
We assume you already created a virtual environment and activated it :)
2527

26-
```python
27-
import electromyogram
28+
```bash
29+
git clone <link to this repository>
30+
cd electromyogram
31+
pip install -e .
2832
```
2933

3034
## Usage
3135

32-
We predefined the two schematics (Fridlund and Cappacio and Kuramoto et al.) on a 2D canvas.
33-
This canvas is based on the canonical face model used by Google in several of their projects (dominantly in *mediapipe*).
34-
All EMG sensor coordinates are given relatively to this canvas thus arbitrary canvas scaling is possible.
35-
We default to a canvas size of 4096x4096 pixels.
36-
37-
The current process for electromyogram visualization is based on a 2 step method.
38-
First, we create the interpolation of the given EMG values on a 2D canvas for the chosen schematic.
39-
Second, we allow the application of different color maps to the interpolation to create the final plot.
36+
This tool is intended to simplify the creation of only the spatial intensity map for surface EMG data.
37+
All the required preprocessing of the data is not part of this package and is likely project-specific.
38+
We assume that the data is given in a dictionary (or pandas table) and the keys are the sensor locations.
4039

41-
### Example 1: Fridlund and Cappacio
40+
Then, the correct physical interpolation between the sensors is done, and the result is a 2D array of the interpolated values on the canonical face model.
41+
You can then apply different color maps to the interpolation to create the final plot.
42+
Detailed examples with test data can be found in `examples/`.
4243

43-
Our first example is based on the Fridlund and Cappacio schematic.
44-
We assume that the data is given in a dictionary and the keys are the sensor locations.
45-
Note: We only support a subset of the sensors in the Fridlund and Cappacio schematic. (TODO add list of supported sensors)
46-
47-
The following locations are expected and then interpolated:
48-
![Locations ](files/locations_fridlund.png)
4944

5045
```python
5146
import electromyogram as emg
5247

5348
# we assume that the data is given in a dictionary and the keys are the sensor locations
5449
data_values = dict(...)
5550

51+
scheme = emg.Fridlund() # or emg.Kuramoto()
5652
# create the interpolation
57-
interpo = emg.interpolate(emg.Fridlund, data_values)
58-
myogram = emg.colorize(interpo, cmap='viridis')
53+
powermap = emg.interpolate(scheme, data_values, shape=(1024, 1024))
54+
powermap = emg.colorize(powermap, cmap='viridis')
5955
```
6056

61-
### Example 2: Kuramoto et al.
62-
Our second example is based on the Kuramoto et al. schematic.
63-
We assume that the data is given in a dictionary and the keys are the sensor locations.
64-
Note: We only support a subset of the sensors in the Kuramoto et al. schematic. (TODO add list of supported sensors)
57+
For the colorization, the users can use any color map from [matplotlib](https://matplotlib.org/stable/tutorials/colors/colormaps.html) or [pallettable](https://jiffyclub.github.io/palettable/) (e.g., `pallettable.scientific.sequential.Imola_20`)
58+
![Colors](files/colorization.jpg)
6559

66-
The following locations are expected and then interpolated:
67-
![Locations ](files/locations_kuramoto.png)
60+
## Surface EMG Schematics
6861

69-
```python
70-
import electromyogram as emg
62+
We currently support the two following schematics for acquiring the EMG data.
63+
If you want to have your own, please open an issue or create a pull request, and we will be happy to add it.
7164

72-
# we assume that the data is given in a dictionary and the keys are the sensor locations
73-
data_values = dict(...)
74-
# create the interpolation
75-
interpo = emg.interpolate(emg.Kuramoto, data_values)
76-
myogram = emg.colorize(interpo, cmap='viridis')
77-
```
65+
| [Fridlund and Cappacio, 1986](https://pubmed.ncbi.nlm.nih.gov/3809364/) | [Kuramoto et al., 2019](https://onlinelibrary.wiley.com/doi/10.1002/npr2.12059) |
66+
|---|---|
67+
| ![Locations ](files/locations_fridlund.jpg) | ![Locations ](files/locations_kuramoto.jpg) |
68+
69+
If you want to define your own scheme, just create a new class that inherits from `emg.Schematic` and implement the `get_sensor_locations` function.
70+
Then use it in the `interpolate` function, and you are good to go.
7871

7972
## Todos
8073

81-
- [ ] Handle if not all values are given for a schematic better
82-
- [ ] Add result images
74+
- [ ] Handle if not all values are given for a better schematic
75+
- [X] Add result images
76+
- [X] Add a function to draw triangulation onto the 2D canvas
77+
- [ ] Add a function to draw sensor locations onto the 2D canvas
78+
- [X] Add the option to remove the area outside the canonical face model
79+
- [ ] Make a better interface for the channel names
80+
- [ ] Add function to create the according colorbar for matplotlib in the correct size
81+
8382
## License
8483

84+
MIT License
8585

86-
## References
86+
## Citation
8787

88+
If you use our work, please cite us:
8889

89-
## Acknowledgements
90+
```bibtex
91+
under publication, please wait a bit :)
92+
```

examples/data/fridlund.csv

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
,DAO li ,OrbOr li ,Ment li ,Mass li ,Zyg li ,Llsup li ,OrbOc li ,lat Front li ,med Front li ,Corr li ,Deprsup li ,DAO re ,OrbOr re ,Ment re ,Mass re ,Zyg re ,Llsup re ,OrbOc re ,lat Front re ,med Front re ,Corr re ,Deprsup re
2+
angry , 9.87 , 21.85 , 16.80 , 1.41 , 1.10 , 0.00 , 6.89 , 1.31 , 0.93 , 2.44 , 2.74 , 0.00 , 39.11 , 17.33 , 2.04 , 1.63 , 0.00 , 9.51 , 0.71 , 0.82 , 2.27 , 2.07
3+
suprised , 0.85 , 0.79 , 1.21 , 0.46 , 0.45 , 0.61 , 1.56 , 4.71 , 3.51 , 2.26 , 2.93 , 0.73 , 0.80 , 1.12 , 0.51 , 0.52 , 0.92 , 3.01 , 1.67 , 3.95 , 2.65 , 2.46
4+
sad , 0.98 , 1.23 , 28.19 , 0.63 , 0.72 , 3.49 , 2.22 , 3.09 , 6.00 , 7.91 , 7.16 , 1.00 , 1.47 , 28.97 , 0.76 , 0.80 , 2.51 , 3.41 , 1.08 , 6.72 , 8.42 , 7.04
5+
fearful , 8.68 , 0.00 , 11.20 , 0.86 , 0.92 , 1.83 , 1.58 , 0.00 , 5.65 , 3.11 , 2.99 , 4.60 , 11.33 , 6.70 , 1.11 , 0.96 , 2.05 , 4.13 , 1.60 , 6.46 , 3.68 , 3.85
6+
happy , 3.14 , 18.30 , 8.37 , 0.70 , 0.00 , 3.71 , 6.05 , 0.72 , 0.65 , 0.52 , 0.33 , 0.00 , 15.04 , 10.23 , 0.92 , 0.00 , 3.31 , 7.41 , 0.60 , 0.62 , 0.58 , 0.55
7+
distugusted , 2.46 , 8.31 , 4.05 , 0.77 , 0.95 , 1.79 , 7.78 , 3.65 , 2.55 , 10.57 , 8.50 , 1.90 , 6.01 , 3.92 , 0.72 , 0.81 , 1.83 , 8.97 , 0.97 , 2.39 , 10.00 , 8.13

examples/data/kuramoto.csv

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
,E1,E3,E5,E7,E9,E13,E15,E17,E2,E4,E6,E8,E10,E14,E16,E18,E19,E20,E24
3+
angry,4.10,6.05,5.98,4.73,11.44,2.57,2.98,2.76,3.81,4.21,12.49,5.63,10.74,4.04,3.59,3.46,7.97,0.00,5.99
4+
suprised,6.94,6.13,3.45,3.64,5.18,3.27,3.39,3.70,6.29,5.71,3.20,3.41,4.47,3.38,3.36,3.80,4.53,3.75,3.48
5+
sad,5.17,8.45,3.97,4.33,17.21,0.00,4.33,4.54,4.74,5.57,3.67,4.62,17.74,9.39,3.76,4.14,7.13,4.90,5.83
6+
fearful,9.13,9.07,3.77,4.78,0.00,6.87,4.24,6.63,10.26,7.80,3.38,4.67,24.93,6.23,3.90,5.92,5.19,5.09,3.10
7+
happy,1.82,2.55,3.28,3.35,0.00,3.77,3.16,6.41,1.66,2.12,4.39,3.32,0.00,3.07,4.48,7.58,2.25,4.30,2.27
8+
distugusted,8.89,8.90,6.04,5.28,6.39,6.53,4.20,3.76,10.34,7.18,12.29,5.84,5.65,10.30,5.06,4.10,10.73,5.75,9.14

examples/emotions.ipynb

Lines changed: 267 additions & 0 deletions
Large diffs are not rendered by default.

files/colorization.jpg

470 KB
Loading

files/locations_fridlund.jpg

188 KB
Loading

files/locations_fridlund.png

-8.56 KB
Binary file not shown.

files/locations_kuramoto.jpg

187 KB
Loading

files/locations_kuramoto.png

-6.96 KB
Binary file not shown.

0 commit comments

Comments
 (0)