profile: Profile tool for PlotWidget#

This module provides tools to get profiles on plot data.

It provides:

The profile package is divided into several sub-modules.

manager module#

This module provides a manager to compute and display profiles.

ProfileManager class#

class ProfileManager(parent=None, plot=None, roiManager=None)[source]#

Bases: QObject

Base class for profile management tools

Parameters:
setSingleProfile(enable)[source]#

Enable or disable the single profile mode.

In single mode, the manager enforce a single ROI at the same time. A new one will remove the previous one.

If this mode is not enabled, many ROIs can be created, and many profile windows will be displayed.

isSingleProfile()[source]#

Returns true if the manager is in a single profile mode.

Return type:

bool

createProfileAction(profileRoiClass, parent=None)[source]#

Create an action from a class of ProfileRoi

Parameters:
  • profileRoiClass (core.ProfileRoiMixIn) – A class of a profile ROI

  • parent (qt.QObject) – The parent of the created action.

Return type:

qt.QAction

createClearAction(parent)[source]#

Create an action to clean up the plot from the profile ROIs.

Parameters:

parent (qt.QObject) – The parent of the created action.

Return type:

qt.QAction

createImageActions(parent)[source]#

Create actions designed for image items. This actions created new ROIs.

Parameters:

parent (qt.QObject) – The parent of the created action.

Return type:

List[qt.QAction]

createScatterActions(parent)[source]#

Create actions designed for scatter items. This actions created new ROIs.

Parameters:

parent (qt.QObject) – The parent of the created action.

Return type:

List[qt.QAction]

createScatterSliceActions(parent)[source]#

Create actions designed for regular scatter items. This actions created new ROIs.

This ROIs was designed to use the input data without interpolation, like you could do with an image.

Parameters:

parent (qt.QObject) – The parent of the created action.

Return type:

List[qt.QAction]

createImageStackActions(parent)[source]#

Create actions designed for stack image items. This actions created new ROIs.

This ROIs was designed to create both profile on the displayed image and profile on the full stack (2D result).

Parameters:

parent (qt.QObject) – The parent of the created action.

Return type:

List[qt.QAction]

createEditorAction(parent)[source]#

Create an action containing GUI to edit the selected profile ROI.

Parameters:

parent (qt.QObject) – The parent of the created action.

Return type:

qt.QAction

setItemType(image=False, scatter=False)[source]#

Set the item type to use and select the active one.

Parameters:
  • image (bool) – Image item are allowed

  • scatter (bool) – Scatter item are allowed

setProfileWindowClass(profileWindowClass)[source]#

Set the class which will be instantiated to display profile result.

setActiveItemTracking(tracking)[source]#

Enable/disable the tracking of the active item of the plot.

Parameters:

tracking (bool) – Tracking mode

setDefaultColorFromCursorColor(enabled)[source]#

Enabled/disable the use of the colormap cursor color to display the ROIs.

If set, the manager will update the color of the profile ROIs using the current colormap cursor color from the selected item.

clearProfile()[source]#

Clear the associated ROI profile

hasPendingOperations()[source]#

Returns true if a thread is still computing or displaying a profile.

Return type:

bool

requestUpdateAllProfile()[source]#

Request to update the profile of all the managed ROIs.

requestUpdateProfile(profileRoi)[source]#

Request to update a specific profile ROI.

Parameters:

profileRoi (ProfileRoiMixIn) –

setPlotItem(item)[source]#

Set the plot item focused by the profile manager.

Parameters:

item (Item) – A plot item

getDefaultColor(item)[source]#

Returns the default ROI color to use according to the given item.

Parameters:

item (Item) – AN item

Return type:

qt.QColor

getPlotItem()[source]#

Returns the item focused by the profile manager.

Return type:

Item

getPlotWidget()[source]#

The plot associated to the profile manager.

Return type:

PlotWidget

getCurrentRoi()[source]#

Returns the currently selected ROI, else None.

Return type:

core.ProfileRoiMixIn

getRoiManager()[source]#

Returns the used ROI manager

Return type:

RegionOfInterestManager

createProfileWindow(plot, roi)[source]#

Create a new profile window.

Parameters:
  • roi (ProfileRoiMixIn) – The plot containing the raw data

  • roi – A managed ROI

Return type:

~ProfileWindow

initProfileWindow(profileWindow, roi)[source]#

This function is called just after the profile window creation in order to initialize the window location.

Parameters:

profileWindow (~ProfileWindow) – The profile window to initialize.

clearProfileWindow(profileWindow)[source]#

Called when a profile window is not anymore needed.

By default the window will be closed. But it can be inherited to change this behavior.

ProfileWindow class#

class ProfileWindow(parent=None, backend=None)[source]#

Bases: QMainWindow

Display a computed profile.

The content can be described using setRoiProfile() if the source of the profile is a profile ROI, and setProfile() for the data content.

sigClose#

Emitted by closeEvent() (e.g. when the window is closed through the window manager’s close icon).

prepareWidget(roi)[source]#

Called before the show to prepare the window to use with a specific ROI.

createPlot1D(parent, backend)[source]#

Inherit this function to create your own plot to render 1D profiles. The default value is a Plot1D.

Parameters:
  • parent – The parent of this widget or None.

  • backend – The backend to use for the plot. See PlotWidget for the list of supported backend.

Return type:

PlotWidget

createPlot2D(parent, backend)[source]#

Inherit this function to create your own plot to render 2D profiles. The default value is a Plot2D.

Parameters:
  • parent – The parent of this widget or None.

  • backend – The backend to use for the plot. See PlotWidget for the list of supported backend.

Return type:

PlotWidget

getPlot1D(init=True)[source]#

Return the current plot used to display curves and create it if it does not yet exists and init is True. Else returns None.

getPlot2D(init=True)[source]#

Return the current plot used to display image and create it if it does not yet exists and init is True. Else returns None.

closeEvent(self, a0: QCloseEvent | None)[source]#
setRoiProfile(roi)[source]#

Set the profile ROI which it the source of the following data to display.

Parameters:

roi (ProfileRoiMixIn) – The profile ROI data source

clear()[source]#

Clear the window profile

getProfile()[source]#

Returns the profile data which is displayed

setProfile(data)[source]#

Setup the window to display a new profile data.

This method dispatch the result to a specific method according to the data type.

Parameters:

data – Computed data profile

editors module#

This module provides editors which are used to custom profile ROI properties.

ProfileRoiEditorAction class#

class ProfileRoiEditorAction(parent=None)[source]#

Bases: QWidgetAction

Action displaying GUI to edit the selected ROI.

Parameters:

parent (qt.QWidget) – Parent widget

createWidget(parent)[source]#

Inherit the method to create a new editor

deleteWidget(widget)[source]#

Inherit the method to delete an editor

setRoiManager(roiManager)[source]#

Connect this action to a ROI manager.

Parameters:

roiManager (RegionOfInterestManager) – A ROI manager

setProfileRoi(roi)[source]#

Set a profile ROI to edit.

Parameters:

roi (ProfileRoiMixIn) – A profile ROI

getRoiProfile()[source]#

Returns the edited profile ROI.

Return type:

ProfileRoiMixIn

getEditorClass(roi)[source]#

Returns the editor class to use according to the ROI.

core module#

This module define core objects for profile tools.

ProfileRoiMixIn class#

class ProfileRoiMixIn(parent=None)[source]#

Bases: object

Base mix-in for ROI which can be used to select a profile.

This mix-in have to be applied to a RegionOfInterest in order to be usable by a ProfileManager.

ITEM_KIND = None#

Define the plot item which can be used with this profile ROI

sigProfilePropertyChanged#

Emitted when a property of this profile have changed

sigPlotItemChanged#

Emitted when the plot item linked to this profile have changed

invalidateProfile()[source]#

Must be called by the implementation when the profile have to be recomputed.

invalidateProperties()[source]#

Must be called when a property of the profile have changed.

getPlotItem()[source]#

Returns the plot item used by this profile

Return type:

~silx.gui.plot.items.Item

getProfileManager()[source]#

Returns the profile manager connected to this ROI.

Return type:

ProfileManager

getProfileWindow()[source]#

Returns the windows associated to this ROI, else None.

Return type:

ProfileWindow

setProfileWindow(profileWindow)[source]#

Associate a window to this ROI. Can be None.

Parameters:

profileWindow (ProfileWindow) – A main window to display the profile.

computeProfile(item)[source]#

Compute the profile which will be displayed.

This method is not called from the main Qt thread, but from a thread pool.

Parameters:

item (Download Windows installer) – A plot item

Return type:

Download Windows installer

CurveProfileData class#

class CurveProfileData(coords, profile, title, xLabel, yLabel)[source]#

Bases: NamedTuple

coords: Download Windows installer#

Alias for field number 0

profile: Download Windows installer#

Alias for field number 1

title: Download Windows installer#

Alias for field number 2

xLabel: Download Windows installer#

Alias for field number 3

yLabel: Download Windows installer#

Alias for field number 4

ImageProfileData class#

class ImageProfileData(coords, profile, title, xLabel, yLabel, colormap)[source]#

Bases: NamedTuple

coords: Download Windows installer#

Alias for field number 0

profile: Download Windows installer#

Alias for field number 1

title: Download Windows installer#

Alias for field number 2

xLabel: Download Windows installer#

Alias for field number 3

yLabel: Download Windows installer#

Alias for field number 4

colormap: Download Windows installer#

Alias for field number 5

ScatterProfileToolBar module#

This module profile tools for scatter plots.

ScatterProfileToolBar#

class ScatterProfileToolBar(parent=None, plot=None)[source]#

Bases: ProfileToolBar

QToolBar providing scatter plot profiling tools

Parameters:
  • parent – See QToolBar.

  • plotPlotWidget on which to operate.

rois module#

This module define ROIs for profile tools.

Inheritance diagram of silx.gui.plot.tools.profile.rois