Remove duplicated MUs across two different files based on STA.
PARAMETER |
DESCRIPTION |
emgfile1 |
The dictionary containing the first emgfile.
TYPE:
dict
|
emgfile2 |
The dictionary containing the second emgfile.
TYPE:
dict
|
firings |
The range of firings to be used for the STA.
If a MU has less firings than the range, the upper limit
is adjusted accordingly.
all
The STA is calculated over all the firings.
A list can be passed as [start, stop] e.g., [0, 25]
to compute the STA on the first 25 firings.
TYPE:
list or str {"all"}
DEFAULT:
"all"
|
derivation |
Whether to compute the sta on the monopolar signal, or on the single or
double differential derivation.
TYPE:
str {mono, sd, dd}
DEFAULT:
sd
|
timewindow |
Timewindow to compute STA in milliseconds.
TYPE:
int
DEFAULT:
50
|
threshold |
The 2-dimensional cross-correlation minimum value
to consider two MUs to be the same. Ranges 0-1.
TYPE:
float
DEFAULT:
0.9
|
matrixcode |
The code of the matrix used. It can be one of:
GR08MM1305
GR04MM1305
GR10MM0808
Custom order
None
This is necessary to sort the channels in the correct order.
If matrixcode="None", the electrodes are not sorted.
In this case, n_rows and n_cols must be specified.
If "Custom order", the electrodes are sorted based on
custom_sorting_order.
TYPE:
str
DEFAULT:
"GR08MM1305"
|
orientation |
Orientation in degree of the matrix (same as in OTBiolab).
E.g. 180 corresponds to the matrix connection toward the user.
This Parameter is ignored if code=="Custom order" or code=="None".
TYPE:
int {0, 180}
DEFAULT:
180
|
n_rows |
The number of rows of the matrix. This parameter is used to divide the
channels based on the matrix shape. These are normally inferred by the
matrix code and must be specified only if code == None.
TYPE:
None or int
DEFAULT:
None
|
n_cols |
The number of columns of the matrix. This parameter is used to divide
the channels based on the matrix shape. These are normally inferred by
the matrix code and must be specified only if code == None.
TYPE:
None or int
DEFAULT:
None
|
custom_sorting_order |
If code=="Custom order", custom_sorting_order will be used for
channels sorting. In this case, custom_sorting_order must be a list of
lists containing the order of the matrix channels.
Specifically, the number of columns are defined by
len(custom_sorting_order) while the number of rows by
len(custom_sorting_order[0]). np.nan can be used to specify empty
channels. Please refer to the Examples section for the structure of
the custom sorting order.
TYPE:
None or list
DEFAULT:
None
|
custom_muaps |
With this parameter, it is possible to perform MUs tracking on MUAPs
computed with custom techniques. If this parameter is None (default),
MUs tracking is performed on the MUAPs computed via spike triggered
averaging. Otherwise, it is possible to pass a list of 2 dictionaries
containing the MUAPs of the MUs from 2 different files. These
dictionaries should be structured as the output of the sta
function. If custom MUAPs are passed, all the previous parameters
(except for emgfile1 and emgfile2 can be ignored).
If custom MUAPs are provided, these are not aligned by the algorithm,
contrary to what is done for MUAPs obtained via spike triggered
averaging.
TYPE:
None or list
DEFAULT:
None
|
filter |
If true, when the same MU has a match of XCC > threshold with
multiple MUs, only the match with the highest XCC is returned.
TYPE:
bool
DEFAULT:
True
|
multiprocessing |
If True (default) parallel processing will be used to reduce execution
time.
TYPE:
bool
DEFAULT:
True
|
show |
Whether to plot the STA of pairs of MUs with XCC above threshold.
TYPE:
bool
DEFAULT:
False
|
gui |
If True (default) a GUI for the visual inspection and manual selection
of the tracking results will be called.
TYPE:
bool
DEFAULT:
True
|
gui_addrefsig |
If True, the REF_SIGNAL is plotted in front of the IDR with a
separated y-axes. This is used only when gui=True.
TYPE:
bool
DEFAULT:
True
|
gui_csv_separator |
The field delimiter used by the GUI to create the .csv copied to the
clipboard. This is used only when gui=True.
TYPE:
str
DEFAULT:
" "
|
which |
How to remove the duplicated MUs.
munumber
Duplicated MUs are removed from the file with more MUs.
accuracy
The MU with the lowest accuracy is removed.
TYPE:
str {"munumber", "accuracy"}
DEFAULT:
"munumber"
|
RETURNS |
DESCRIPTION |
emgfile1, emgfile2 : dict
|
The original emgfiles without the duplicated MUs.
|
tracking_res
|
The results of the tracking including the MU from file 1,
MU from file 2 and the normalised cross-correlation value (XCC).
If gui=True, an additional column indicating the inclusion/exclusion
of the MUs pairs will also be present in tracking_res.
TYPE:
DataFrame
|
See also
- sta : computes the STA of every MUs.
- norm_twod_xcorr : normalised 2-dimensional cross-correlation of STAs of
two MUs.
- tracking : track MUs across two different files.
Examples:
Remove duplicated MUs between two OPENHDEMG files and inspect the tracking
outcome via a convenient GUI. Then Save the emgfiles without duplicates.
Of the 2 duplicated MUs, the one with the lowest accuracy is removed.
>>> import openhdemg.library as emg
>>> emgfile1 = emg.askopenfile(filesource="OPENHDEMG")
>>> emgfile2 = emg.askopenfile(filesource="OPENHDEMG")
>>> emgfile1, emgfile2, tracking_res = emg.remove_duplicates_between(
... emgfile1,
... emgfile2,
... firings="all",
... derivation="mono",
... timewindow=50,
... threshold=0.9,
... matrixcode="GR08MM1305",
... orientation=180,
... gui=True,
... which="accuracy",
... )
>>> emg.asksavefile(emgfile1)
>>> emg.asksavefile(emgfile2)
Remove duplicated MUs between two OTB files and directly save the emgfiles
without duplicates. The duplicates are removed from the file with
more MUs.
>>> import openhdemg.library as emg
>>> emgfile1 = emg.askopenfile(filesource="OTB", otb_ext_factor=8)
>>> emgfile2 = emg.askopenfile(filesource="OTB", otb_ext_factor=8)
>>> emgfile1, emgfile2, tracking_res = emg.remove_duplicates_between(
... emgfile1,
... emgfile2,
... firings="all",
... derivation="mono",
... timewindow=50,
... threshold=0.9,
... matrixcode="GR08MM1305",
... orientation=180,
... n_rows=None,
... n_cols=None,
... filter=True,
... show=False,
... gui=False,
... which="munumber",
... )
>>> emg.asksavefile(emgfile1)
>>> emg.asksavefile(emgfile2)
Remove duplicated MUs between two files where channels are sorted with a
custom order and directly save the emgfiles without duplicates. Of the 2
duplicated MUs, the one with the lowest accuracy is removed.
>>> import openhdemg.library as emg
>>> import numpy as np
>>> emgfile1 = emg.askopenfile(filesource="CUSTOMCSV")
>>> emgfile2 = emg.askopenfile(filesource="CUSTOMCSV")
>>> custom_sorting_order = [
... [63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51,],
... [38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,],
... [37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25,],
... [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,],
... [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, np.nan,],
... ] # 13 rows and 5 columns
>>> emgfile1, emgfile2, tracking_res = emg.remove_duplicates_between(
... emgfile1,
... emgfile2,
... firings="all",
... derivation="sd",
... timewindow=50,
... threshold=0.9,
... matrixcode="Custom order",
... orientation=180,
... n_rows=None,
... n_cols=None,
... custom_sorting_order=custom_sorting_order,
... filter=True,
... show=False,
... gui=False,
... which="accuracy",
... )
>>> emg.asksavefile(emgfile1)
>>> emg.asksavefile(emgfile2)