Run the point selector dialog and return the selected points.
Opens a blocking Qt dialog where the user can select points on a 1D signal
using keyboard and mouse interactions. The dialog ensures the number of
selected points matches the required count (if specified) before closing.
Compared to directly creating a PointSelectorDialog instance, this function
automatically manages the app integration for the user.
Users can move the mouse to track coordinates and press:
- "A" or "a" to add a point at the current cursor location
- "D" or "d" to delete the last selected point
- "Enter" to confirm the selection and close the window
| PARAMETER |
DESCRIPTION |
data
|
1D signal to display for point selection.
This can be anything suitable for matplotlib.axes.Axes.plot.
TYPE:
array - like
|
nclic
|
Number of points to enforce selection before confirming.
Default is -1, which means no limit.
TYPE:
int
DEFAULT:
-1
|
y_label
|
TYPE:
str
DEFAULT:
"Data"
|
title
|
Title shown above the plot.
TYPE:
str
DEFAULT:
"A to select, D to delete, Enter to continue"
|
title_fontsize
|
TYPE:
int or float
DEFAULT:
10
|
title_fontweight
|
Font weight of the title text. This will be passed to
matplotlib.text.Text.set_fontweight.
TYPE:
str
DEFAULT:
"bold"
|
parent
|
Optional Qt parent used when embedding the dialog.
TYPE:
QWidget or None
DEFAULT:
None
|
| RETURNS |
DESCRIPTION |
points
|
A list of Lists containing the [x, y] coordinates of the selected
points.
TYPE:
list of lists
|
Examples:
Free selection of points (no limit)
>>> import numpy as np
>>> from openhdemg.ui import run_point_selector
>>> signal = np.sin(np.linspace(0, 10, 500))
>>> selected_points = run_point_selector(signal, nclic=-1)
>>> print(selected_points)
[[70.22, 0.96], [222.14, -0.95], [314.93, 0.04]]
Select exactly 2 points and print the X coordinates.
>>> import numpy as np
>>> from openhdemg.ui import run_point_selector
>>> signal = np.random.randn(1000)
>>> selected = run_point_selector(signal, nclic=2)
>>> print(f"Start: {selected[0][0]}, End: {selected[1][0]}")
Start: 168.21717572391907, End: 713.5261404204681