Skip to content

⚠️ You are viewing an outdated version of the documentation. For the most recent release, please refer to the latest version.

plotemg

Description

This module contains all the functions used to visualise the content of the imported EMG file, the MUs properties or to save figures.


showgoodlayout(tight_layout=True, despined=False)

Despine and show plots with a good layout.

This function is called by the various plot functions contained in the library but can also be used by the user to quickly adjust the layout of custom plots.

PARAMETER DESCRIPTION
tight_layout

If true (default), plt.tight_layout() is applied to the figure.

TYPE: bool DEFAULT: True

despined

False: left and bottom is not despined (standard plotting).

True: all the sides are despined.

2yaxes Only the top is despined. This is used to show y axes both on the right and left side at the same time.

TYPE: bool or str {"2yaxes"} DEFAULT: False


plot_emgsig(emgfile, channels, addrefsig=False, timeinseconds=True, figsize=[20, 15], showimmediately=True, tight_layout=True)

Plot the RAW_SIGNAL. Single or multiple channels.

Up to 12 channels (a common matrix row) can be easily observed togheter, but more can be plotted.

PARAMETER DESCRIPTION
emgfile

The dictionary containing the emgfile.

TYPE: dict

channels

The channel (int) or channels (list of int) to plot. The list can be passed as a manually-written list or with: channels=[*range(0, 13)]. We need the " * " operator to unpack the results of range into a list. channels is expected to be with base 0 (i.e., the first channel in the file is the number 0).

TYPE: int or list

addrefsig

If True, the REF_SIGNAL is plotted in front of the signal with a separated y-axes.

TYPE: bool DEFAULT: True

timeinseconds

Whether to show the time on the x-axes in seconds (True) or in samples (False).

TYPE: bool DEFAULT: True

figsize

Size of the figure in centimeters [width, height].

TYPE: list DEFAULT: [20, 15]

showimmediately

If True (default), plt.show() is called and the figure showed to the user. It is useful to set it to False when calling the function from the GUI.

TYPE: bool DEFAULT: True

tight_layout

If True (default), the plt.tight_layout() is called and the figure's layout is improved. It is useful to set it to False when calling the function from the GUI.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
fig

TYPE: pyplot `~.figure.Figure`

See also
  • plot_differentials : plot the differential derivation of the RAW_SIGNAL by matrix column.

Examples:

Plot channels 0 to 12 and overlay the reference signal.

>>> import openhdemg.library as emg
>>> emgfile = emg.askopenfile(filesource="OTB", otb_ext_factor=8)
>>> emg.plot_emgsig(
...     emgfile=emgfile,
...     channels=[*range(0,13)],
...     addrefsig=True,
...     timeinseconds=True,
...     figsize=[20, 15],
... )


plot_differentials(emgfile, differential, column='col0', addrefsig=False, timeinseconds=True, figsize=[20, 15], showimmediately=True, tight_layout=True)

Plot the differential derivation of the RAW_SIGNAL by matrix column.

Both the single and the double differencials can be plotted. This function is used to plot also the sorted RAW_SIGNAL.

PARAMETER DESCRIPTION
emgfile

The dictionary containing the original emgfile.

TYPE: dict

differential

The dictionary containing the differential derivation of the RAW_SIGNAL.

TYPE: dict

column

The matrix column to plot. Options are usyally "col0", "col1", "col2", "col3", "col4". but might change based on the size of the matrix used.

TYPE: str {"col0", "col1", "col2", "col3", "col4", ...} DEFAULT: "col0"

addrefsig

If True, the REF_SIGNAL is plotted in front of the signal with a separated y-axes.

TYPE: bool DEFAULT: True

timeinseconds

Whether to show the time on the x-axes in seconds (True) or in samples (False).

TYPE: bool DEFAULT: True

figsize

Size of the figure in centimeters [width, height].

TYPE: list DEFAULT: [20, 15]

showimmediately

If True (default), plt.show() is called and the figure showed to the user. It is useful to set it to False when calling the function from the GUI.

TYPE: bool DEFAULT: True

tight_layout

If True (default), the plt.tight_layout() is called and the figure's layout is improved. It is useful to set it to False when calling the function from the GUI.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
fig

TYPE: pyplot `~.figure.Figure`

See also
  • diff : calculate single differential of RAW_SIGNAL on matrix rows.
  • double_diff : calculate double differential of RAW_SIGNAL on matrix rows.
  • plot_emgsig : pot the RAW_SIGNAL. Single or multiple channels.

Examples:

Plot the differential derivation of the first matrix column (col0).

>>> import openhdemg.library as emg
>>> emgfile = emg.askopenfile(filesource="OTB", otb_ext_factor=8)
>>> sorted_rawemg = emg.sort_rawemg(
>>>     emgfile=emgfile,
>>>     code="GR08MM1305",
>>>     orientation=180,
>>> )
>>> sd=emg.diff(sorted_rawemg=sorted_rawemg)
>>> emg.plot_differentials(
...     emgfile=emgfile,
...     differential=sd,
...     column="col0",
...     addrefsig=False,
...     timeinseconds=True,
...     figsize=[20, 15],
...     showimmediately=True,
... )


plot_refsig(emgfile, ylabel='MVC', timeinseconds=True, figsize=[20, 15], showimmediately=True, tight_layout=True)

Plot the REF_SIGNAL.

The REF_SIGNAL is usually expressed as % MVC for submaximal contractions or as Kilograms (Kg) or Newtons (N) for maximal contractions, but any value can be plotted.

PARAMETER DESCRIPTION
emgfile

The dictionary containing the emgfile.

TYPE: dict

ylabel

The unit of measure to show on the Y axis.

TYPE: str DEFAULT: "MVC"

timeinseconds

Whether to show the time on the x-axes in seconds (True) or in samples (False).

TYPE: bool DEFAULT: True

figsize

Size of the figure in centimeters [width, height].

TYPE: list DEFAULT: [20, 15]

showimmediately

If True (default), plt.show() is called and the figure showed to the user. It is useful to set it to False when calling the function from the GUI.

TYPE: bool DEFAULT: True

tight_layout

If True (default), the plt.tight_layout() is called and the figure's layout is improved. It is useful to set it to False when calling the function from the GUI.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
fig

TYPE: pyplot `~.figure.Figure`

Examples:

Plot the reference signal.

>>> import openhdemg.library as emg
>>> emgfile = emg.askopenfile(filesource="OTB", otb_ext_factor=8)
>>> emg.plot_refsig(emgfile=emgfile)

Change Y axis label and show time in samples.

>>> import openhdemg.library as emg
>>> emgfile = emg.askopenfile(filesource="OTB", otb_ext_factor=8)
>>> emg.plot_refsig(
>>>     emgfile=emgfile,
>>>     ylabel="Custom unit e.g., N or kg",
>>>     timeinseconds=False,
>>> )


plot_mupulses(emgfile, munumber='all', linewidths=0.5, addrefsig=True, timeinseconds=True, figsize=[20, 15], showimmediately=True, tight_layout=True)

Plot all the MUPULSES (binary representation of the firings time).

PARAMETER DESCRIPTION
emgfile

The dictionary containing the emgfile.

TYPE: dict

munumber

all IPTS of all the MUs is plotted.

Otherwise, a single MU (int) or multiple MUs (list of int) can be specified. The list can be passed as a manually-written list or with: munumber=[*range(0, 12)]. We need the " * " operator to unpack the results of range into a list. munumber is expected to be with base 0 (i.e., the first MU in the file is the number 0).

TYPE: (str, int or list) DEFAULT: "all"

linewidths

The width of the vertical lines representing the MU firing.

TYPE: float DEFAULT: 0.5

addrefsig

If True, the REF_SIGNAL is plotted in front of the MUs pulses with a separated y-axes.

TYPE: bool DEFAULT: True

timeinseconds

Whether to show the time on the x-axes in seconds (True) or in samples (False).

TYPE: bool DEFAULT: True

figsize

Size of the figure in centimeters [width, height].

TYPE: list DEFAULT: [20, 15]

showimmediately

If True (default), plt.show() is called and the figure showed to the user. It is useful to set it to False when calling the function from the GUI.

TYPE: bool DEFAULT: True

tight_layout

If True (default), the plt.tight_layout() is called and the figure's layout is improved. It is useful to set it to False when calling the function from the GUI.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
fig

TYPE: pyplot `~.figure.Figure`

See also
  • plot_ipts : plot the MUs impulse train per second (IPTS).
  • plot_idr : plot the instantaneous discharge rate.

Examples:

Plot MUs pulses based on recruitment order and overlay the reference signal.

>>> import openhdemg.library as emg
>>> emgfile = emg.askopenfile(filesource="OTB", otb_ext_factor=8)
>>> emg.plot_mupulses(
...     emgfile=emgfile,
...     linewidths=0.5,
...     order=True,
...     addrefsig=True,
...     timeinseconds=True,
...     figsize=[20, 15],
...     showimmediately=True,
... )


plot_ipts(emgfile, munumber='all', addrefsig=False, timeinseconds=True, figsize=[20, 15], showimmediately=True, tight_layout=True)

Plot the IPTS (decomposed source).

IPTS is the non-binary representation of the MUs firing times.

PARAMETER DESCRIPTION
emgfile

The dictionary containing the emgfile.

TYPE: dict

munumber

all IPTS of all the MUs is plotted.

Otherwise, a single MU (int) or multiple MUs (list of int) can be specified. The list can be passed as a manually-written list or with: munumber=[*range(0, 12)]. We need the " * " operator to unpack the results of range into a list. munumber is expected to be with base 0 (i.e., the first MU in the file is the number 0).

TYPE: (str, int or list) DEFAULT: "all"

timeinseconds

Whether to show the time on the x-axes in seconds (True) or in samples (False).

TYPE: bool DEFAULT: True

figsize

Size of the figure in centimeters [width, height].

TYPE: list DEFAULT: [20, 15]

showimmediately

If True (default), plt.show() is called and the figure showed to the user. It is useful to set it to False when calling the function from the GUI.

TYPE: bool DEFAULT: True

tight_layout

If True (default), the plt.tight_layout() is called and the figure's layout is improved. It is useful to set it to False when calling the function from the GUI.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
fig

TYPE: pyplot `~.figure.Figure`

See also
  • plot_mupulses : plot the binary representation of the firings.
  • plot_idr : plot the instantaneous discharge rate.
Notes

munumber = "all" corresponds to: munumber = [*range(0, emgfile["NUMBER_OF_MUS"])]

Examples:

Plot IPTS of all the MUs and overlay the reference signal.

>>> import openhdemg.library as emg
>>> emgfile = emg.askopenfile(filesource="OTB", otb_ext_factor=8)
>>> emg.plot_ipts(
...     emgfile=emgfile,
...     munumber="all",
...     addrefsig=True,
...     timeinseconds=True,
...     figsize=[20, 15],
...     showimmediately=True,
... )

Plot IPTS of two MUs.

>>> import openhdemg.library as emg
>>> emgfile = emg.askopenfile(filesource="OTB", otb_ext_factor=8)
>>> emg.plot_ipts(
...     emgfile=emgfile,
...     munumber=[1, 3],
...     addrefsig=False,
...     timeinseconds=True,
...     figsize=[20, 15],
...     showimmediately=True,
... )


plot_idr(emgfile, munumber='all', addrefsig=True, timeinseconds=True, figsize=[20, 15], showimmediately=True, tight_layout=True)

Plot the instantaneous discharge rate (IDR).

PARAMETER DESCRIPTION
emgfile

The dictionary containing the emgfile.

TYPE: dict

munumber

all IDR of all the MUs is plotted.

Otherwise, a single MU (int) or multiple MUs (list of int) can be specified. The list can be passed as a manually-written list or with: munumber=[*range(0, 12)]. We need the " * " operator to unpack the results of range into a list. munumber is expected to be with base 0 (i.e., the first MU in the file is the number 0).

TYPE: (str, int or list) DEFAULT: "all"

addrefsig

If True, the REF_SIGNAL is plotted in front of the MUs IDR with a separated y-axes.

TYPE: bool DEFAULT: True

timeinseconds

Whether to show the time on the x-axes in seconds (True) or in samples (False).

TYPE: bool DEFAULT: True

figsize

Size of the figure in centimeters [width, height].

TYPE: list DEFAULT: [20, 15]

showimmediately

If True (default), plt.show() is called and the figure showed to the user. It is useful to set it to False when calling the function from the GUI.

TYPE: bool DEFAULT: True

tight_layout

If True (default), the plt.tight_layout() is called and the figure's layout is improved. It is useful to set it to False when calling the function from the GUI.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
fig

TYPE: pyplot `~.figure.Figure`

See also
  • plot_mupulses : plot the binary representation of the firings.
  • plot_ipts : plot the impulse train per second (IPTS).
Notes

munumber = "all" corresponds to munumber = [*range(0, emgfile["NUMBER_OF_MUS"])]

Examples:

Plot IDR of all the MUs and overlay the reference signal.

>>> import openhdemg.library as emg
>>> emgfile = emg.askopenfile(filesource="OTB", otb_ext_factor=8)
>>> emg.plot_idr(
...     emgfile=emgfile,
...     munumber="all",
...     addrefsig=True,
...     timeinseconds=True,
...     figsize=[20, 15],
...     showimmediately=True,
... )

Plot IDR of two MUs.

>>> import openhdemg.library as emg
>>> emgfile = emg.askopenfile(filesource="OTB", otb_ext_factor=8)
>>> emg.plot_idr(
...     emgfile=emgfile,
...     munumber=[1, 3],
...     addrefsig=False,
...     timeinseconds=True,
...     figsize=[20, 15],
...     showimmediately=True,
... )


plot_smoothed_dr(emgfile, smoothfits, munumber='all', addidr=True, stack=True, addrefsig=True, timeinseconds=True, figsize=[20, 15], showimmediately=True, tight_layout=True)

Plot the smoothed discharge rate.

PARAMETER DESCRIPTION
emgfile

The dictionary containing the emgfile.

TYPE: dict

smoothfits

Smoothed discharge rate estimates aligned in time. Columns should contain the smoothed discharge rate for each MU.

TYPE: DataFrame

munumber

all IDR of all the MUs is plotted.

Otherwise, a single MU (int) or multiple MUs (list of int) can be specified. The list can be passed as a manually-written list or with: munumber=[*range(0, 12)]. We need the " * " operator to unpack the results of range into a list. munumber is expected to be with base 0 (i.e., the first MU in the file is the number 0).

TYPE: (str, int or list) DEFAULT: "all"

addidr

Whether to show also the IDR behind the smoothed DR line.

TYPE: bool DEFAULT: True

stack

Whether to stack multiple MUs. If False, all the MUs smoothed DR will be plotted on the same line.

TYPE: bool DEFAULT: True

addrefsig

If True, the REF_SIGNAL is plotted in front of the MUs IDR with a separated y-axes.

TYPE: bool DEFAULT: True

timeinseconds

Whether to show the time on the x-axes in seconds (True) or in samples (False).

TYPE: bool DEFAULT: True

figsize

Size of the figure in centimeters [width, height].

TYPE: list DEFAULT: [20, 15]

showimmediately

If True (default), plt.show() is called and the figure showed to the user. It is useful to set it to False when calling the function from the GUI.

TYPE: bool DEFAULT: True

tight_layout

If True (default), the plt.tight_layout() is called and the figure's layout is improved. It is useful to set it to False when calling the function from the GUI.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
fig

TYPE: pyplot `~.figure.Figure`

See also
  • compute_svr : Fit MU discharge rates with Support Vector Regression, nonlinear regression.
Notes

munumber = "all" corresponds to: munumber = [*range(0, emgfile["NUMBER_OF_MUS"])]

Examples:

Smooth MUs DR using Support Vector Regression.

>>> import openhdemg.library as emg
>>> import pandas as pd
>>> emgfile = emg.emg_from_samplefile()
>>> emgfile = emg.sort_mus(emgfile=emgfile)
>>> svrfits = emg.compute_svr(emgfile)

Plot the stacked smoothed DR of all the MUs and overlay the IDR and the reference signal.

>>> smoothfits = pd.DataFrame(svrfits["gensvr"]).transpose()
>>> emg.plot_smoothed_dr(
>>>     emgfile,
>>>     smoothfits=smoothfits,
>>>     munumber="all",
>>>     addidr=True,
>>>     stack=True,
>>>     addrefsig=True,
>>> )


plot_muaps(sta_dict, title='MUAPs from STA', figsize=[20, 15], showimmediately=True, tight_layout=False)

Plot MUAPs obtained from STA from one or multiple MUs.

PARAMETER DESCRIPTION
sta_dict

dict containing STA of the specified MU or a list of dicts containing STA of specified MUs. If a list is passed, different MUs are overlayed. This is useful for visualisation of MUAPs during tracking or duplicates removal.

TYPE: dict or list

title

Title of the plot.

TYPE: str DEFAULT: "MUAPs from STA"

figsize

Size of the figure in centimeters [width, height].

TYPE: list DEFAULT: [20, 15]

showimmediately

If True (default), plt.show() is called and the figure showed to the user. It is useful to set it to False when calling the function from the GUI.

TYPE: bool DEFAULT: True

tight_layout

If True (default), the plt.tight_layout() is called and the figure's layout is improved. It is useful to set it to False when calling the function from the GUI or if the final layout is not correct.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
fig

TYPE: pyplot `~.figure.Figure`

See also
  • sta : computes the spike-triggered average (STA) of every MUs.
  • plot_muap : for overplotting all the STAs and the average STA of a MU.
  • align_by_xcorr : for alignin the STAs of two different MUs.
Notes

There is no limit to the number of MUs and STA files that can be overplotted.

Remember: the different STAs should be matched with same number of electrode, processing (i.e., differential) and computed on the same timewindow.

Examples:

Plot MUAPs of a single MU.

>>> import openhdemg.library as emg
>>> emgfile = emg.askopenfile(filesource="OTB", otb_ext_factor=8)
>>> sorted_rawemg = emg.sort_rawemg(
...     emgfile=emgfile,
...     code="GR08MM1305",
...     orientation=180,
...     dividebycolumn=True,
... )
>>> sta = emg.sta(
...     emgfile=emgfile,
...     sorted_rawemg=sorted_rawemg,
...     firings="all",
...     timewindow=50,
... )
>>> emg.plot_muaps(sta_dict=sta[1])

Plot single differential derivation MUAPs of a single MU.

>>> import openhdemg.library as emg
>>> emgfile = emg.askopenfile(filesource="OTB", otb_ext_factor=8)
>>> sorted_rawemg = emg.sort_rawemg(
...     emgfile=emgfile,
...     code="GR08MM1305",
...     orientation=180,
...     dividebycolumn=True,
... )
>>> sorted_rawemg = emg.diff(sorted_rawemg=sorted_rawemg)
>>> sta = emg.sta(
...     emgfile=emgfile,
...     sorted_rawemg=sorted_rawemg,
...     firings="all",
...     timewindow=50,
... )
>>> emg.plot_muaps(sta_dict=sta[1])

Plot single differential derivation MUAPs of two MUs from the same file.

>>> import openhdemg.library as emg
>>> emgfile = emg.askopenfile(filesource="OTB", otb_ext_factor=8)
>>> sorted_rawemg = emg.sort_rawemg(
...     emgfile=emgfile,
...     code="GR08MM1305",
...     orientation=180,
...     dividebycolumn=True,
... )
>>> sorted_rawemg = emg.diff(sorted_rawemg=sorted_rawemg)
>>> sta = emg.sta(
...     emgfile=emgfile,
...     sorted_rawemg=sorted_rawemg,
...     firings="all",
...     timewindow=50,
... )
>>> emg.plot_muaps(sta_dict=[sta[1], sta[2]])


plot_muap(emgfile, stmuap, munumber, column, channel, channelprog=False, average=True, timeinseconds=True, figsize=[20, 15], showimmediately=True, tight_layout=True)

Plot the MUAPs of a specific matrix channel.

Plot the MUs action potential (MUAPs) shapes with or without average.

PARAMETER DESCRIPTION
emgfile

The dictionary containing the emgfile.

TYPE: dict

stmuap

dict containing a dict of ST MUAPs (pd.DataFrame) for every MUs.

TYPE: dict

munumber

The number of the MU to plot.

TYPE: int

column

The matrix columns. Options are usyally "col0", "col1", "col2", ..., last column.

TYPE: str

channel

The channel of the matrix to plot. This can be the real channel number if channelprog=False (default), or a progressive number (from 0 to the length of the matrix column) if channelprog=True.

TYPE: int

channelprog

Whether to use the real channel number or a progressive number (see channel).

TYPE: bool DEFAULT: False

average

Whether to plot also the MUAPs average obtained by spike triggered average.

TYPE: bool DEFAULT: True

timeinseconds

Whether to show the time on the x-axes in seconds (True) or in samples (False).

TYPE: bool DEFAULT: True

figsize

Size of the figure in centimeters [width, height].

TYPE: list DEFAULT: [20, 15]

showimmediately

If True (default), plt.show() is called and the figure showed to the user. It is useful to set it to False when calling the function from the GUI.

TYPE: bool DEFAULT: True

tight_layout

If True (default), the plt.tight_layout() is called and the figure's layout is improved. It is useful to set it to False when calling the function from the GUI.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
fig

TYPE: pyplot `~.figure.Figure`

See also
  • plot_muaps : Plot MUAPs obtained from STA from one or multiple MUs.
  • st_muap : Generate spike triggered MUAPs of every MUs (as input to this function).

Examples:

Plot all the consecutive MUAPs of a single MU. In this case we are plotting the matrix channel 45 which is placed in column 4 ("col3" as Python numbering is base 0).

>>> import openhdemg.library as emg
>>> emgfile = emg.askopenfile(filesource="OTB", otb_ext_factor=8)
>>> sorted_rawemg = emg.sort_rawemg(
...     emgfile,
...     code="GR08MM1305",
...     orientation=180,
...     dividebycolumn=True,
... )
>>> stmuap = emg.st_muap(
...     emgfile=emgfile,
...     sorted_rawemg=sorted_rawemg,
...     timewindow=50,
... )
>>> emg.plot_muap(
...     emgfile=emgfile,
...     stmuap=stmuap,
...     munumber=1,
...     column="col3",
...     channel=45,
...     channelprog=False,
...     average=False,
...     timeinseconds=True,
...     figsize=[20, 15],
...     showimmediately=True,
... )

To avoid the problem of remebering which channel number is present in which matrix column, we can set channelprog=True and locate the channel with a value ranging from 0 to the length of each column.

>>> import openhdemg.library as emg
>>> emgfile = emg.askopenfile(filesource="OTB", otb_ext_factor=8)
>>> sorted_rawemg = emg.sort_rawemg(
...     emgfile=emgfile,
...     code="GR08MM1305",
...     orientation=180,
...     dividebycolumn=True,
... )
>>> stmuap = emg.st_muap(
...     emgfile=emgfile,
...     sorted_rawemg=sorted_rawemg,
...     timewindow=50,
... )
>>> emg.plot_muap(
...     emgfile=emgfile,
...     stmuap=stmuap,
...     munumber=1,
...     column="col3",
...     channel=5,
...     channelprog=True,
...     average=False,
...     timeinseconds=True,
...     figsize=[20, 15],
...     showimmediately=True,
... )

It is also possible to visualise the spike triggered average of the MU with average=True. In this example the single differential derivation is used.

>>> import openhdemg.library as emg
>>> emgfile = emg.askopenfile(filesource="OTB", otb_ext_factor=8)
>>> sorted_rawemg = emg.sort_rawemg(
...     emgfile=emgfile,
...     code="GR08MM1305",
...     orientation=180,
...     dividebycolumn=True,
... )
>>> sorted_rawemg = emg.diff(sorted_rawemg=sorted_rawemg)
>>> stmuap = emg.st_muap(
...     emgfile=emgfile,
...     sorted_rawemg=sorted_rawemg,
...     timewindow=50,
... )
>>> emg.plot_muap(
...     emgfile=emgfile,
...     stmuap=stmuap,
...     munumber=1,
...     column="col2",
...     channel=6,
...     channelprog=True,
...     average=True,
...     timeinseconds=True,
...     figsize=[20, 15],
...     showimmediately=True,
... )


plot_muaps_for_cv(sta_dict, xcc_sta_dict, title='MUAPs for CV', figsize=[20, 15], showimmediately=True, tight_layout=False)

Visualise MUAPs on which to calculate MUs CV.

Plot MUAPs obtained from the STA of the double differential signal and their paired cross-correlation value.

PARAMETER DESCRIPTION
sta_dict

dict containing the STA of the double-differential derivation of a specific MU.

TYPE: dict

xcc_sta_dict

dict containing the normalised cross-correlation coefficient of the double-differential derivation of a specific MU.

TYPE: dict

title

Title of the plot.

TYPE: str DEFAULT: "MUAPs from STA"

figsize

Size of the figure in centimeters [width, height].

TYPE: list DEFAULT: [20, 15]

showimmediately

If True (default), plt.show() is called and the figure showed to the user. It is useful to set it to False when calling the function from the GUI.

TYPE: bool DEFAULT: True

tight_layout

If True (default), the plt.tight_layout() is called and the figure's layout is improved. It is useful to set it to False when calling the function from the GUI or if the final layout is not correct.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
fig

TYPE: pyplot `~.figure.Figure`

Examples:

Plot the double differential derivation and the XCC of adjacent channels for the first MU (0).

>>> import openhdemg.library as emg
>>> emgfile = emg.askopenfile(filesource="OTB", otb_ext_factor=8)
>>> sorted_rawemg = emg.sort_rawemg(
...     emgfile,
...     code="GR08MM1305",
...     orientation=180,
...     dividebycolumn=True
... )
>>> dd = emg.double_diff(sorted_rawemg)
>>> sta = emg.sta(
...     emgfile=emgfile,
...     sorted_rawemg=dd,
...     firings=[0, 50],
...     timewindow=50,
... )
>>> xcc_sta = emg.xcc_sta(sta)
>>> fig = emg.plot_muaps_for_cv(
...     sta_dict=sta[0],
...     xcc_sta_dict=xcc_sta[0],
...     showimmediately=True,
... )