Package: electromyogram
electromyogramThis 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.A small demo is hostedhere, together with the toolface-projectionfor a projection onto the face.Why use sEMG Intensity Plot?Easy to use: The package provides a straightforward interface, making it accessible for users of all levels of expertise.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.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.FACS: Visualize the Facial Action Coding System at the correct anatomical locations for a more intuitive understanding of the data.Blend Shapes: Many existing blend shape models base their movements on the FACS. We provide a location mapping for commonly used blend shapes models and where they are located on the face to the AU muscle.Potential for extension: While the current focus is on facial muscles, this tool could potentially be extended to analyze other muscle groups.Beyond muscles: The tool can also be used to plot additional facial information, such as oxygen saturation, but this is not officially supported yet.InstallationThe package is available onPyPIand can be installed withpip:pipinstallelectromyogramIf you want to install it locally to add changes, please close the repository and install it withpipin development mode.
We assume you already created a virtual environment and activated it :)gitclone<linktothisrepository>cdelectromyogram
pipinstall-e.QuickstartThis tool is intended to simplify the creation of only the spatial intensity map for surface EMG data.
All the required preprocessing of the data is not part of this package and is likely project-specific.
We assume that the data is given in a dictionary (or pandas table) and the keys are the sensor locations.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.
You can then apply different color maps to the interpolation to create the final plot.
We provide detailed examples inexamples/.importelectromyogramasemg# we assume that the data is given in a dictionary and the keys are the sensor locationsdata_values=dict(...)scheme=emg.Fridlund()# or emg.Kuramoto()# create the interpolationpowermap=emg.interpolate(scheme,data_values,shape=(1024,1024))powermap=emg.colorize(powermap,cmap='viridis')For the colorization, the users can use any color map frommatplotliborpallettable(e.g.,pallettable.scientific.sequential.Imola_20)Surface EMG SchematicsWe currently support the two following schematics for acquiring the EMG data.
If you want to have your own, please open an issue or create a pull request, and we will be happy to add it.Fridlund and Cappacio, 1986Kuramoto et al., 2019Ekman and Friesen - FACSMediapipe BlendshapesIf you want to define your custom scheme, create a new class inherited fromemg.Schematicand implement thelocationsmember. If you support the mirroring of the face, implement thepairs_Landpairs_Rmembers.
Then, use it in theinterpolatefunction, and you are good to go.TodosHandle if not all values are given for a better schematicAdd result imagesAdd a function to draw triangulation onto the 2D canvasAdd a function to draw sensor locations onto the 2D canvasAdd the option to remove the area outside the canonical face modelMake a better interface for the channel names (mapping to defined terms)Add function to create the according colorbar for matplotlib in the correct sizeLicenseMIT LicenseCitationIf you use our work, please cite us:under publication, please wait a bit :)