fsleyes.controls.componentgrid

This module provides the ComponentGrid class, which is used by the MelodicClassificationPanel.

class fsleyes.controls.componentgrid.ComponentGrid(parent, overlayList, displayCtx, frame, lut)

Bases: fsleyes.panel.FSLeyesPanel

The ComponentGrid uses a WidgetGrid, and a set of TextTagPanel widgets, to display the component classifications stored in the VolumeLabels object that is associated with an Image (typically a MelodicImage). The Image and VolumeLabels instance is specified via the setOverlay() method.

The grid contains one row for each component, and a TextTagPanel is used to display the labels associated with each component. Each TextTagPanel allows the user to add and remove labels to/from the corresponding component.

See also the LabelGrid class, which displays the same information, but organised by label.

__init__(parent, overlayList, displayCtx, frame, lut)

Create a ComponentGrid.

Parameters:
destroy()

Must be called when this ComponentGrid is no longer needed. De-registers various property listeners, and calls FSLeyesPanel.destroy().

setOverlay(overlay, volLabels, refreshGrid=True)

Sets the Image to display component labels for. The WidgetGrid is re-populated to display the component-label mappings contained in the VolumeLabels instance associated with the overlay.

Parameters:refreshGrid – If True (the default), the WidgetGrid displaying component labels is refreshed. This flag is used internally (see __overlayTypeChanged()).
refreshTags(comps=None)

Clears and refreshes the tags on every TextTagPanel in the grid.

Parameters:comps – Components to refresh. If None, the tags for all components are refreshed.
_ComponentGrid__deregisterCurrentOverlay()

Called when the selected overlay changes. De-registers listeners associated with the previously selected overlay, if necessary.

_ComponentGrid__labelsChanged(volLabels, topic, components)

Called on VolumeLabels notifications. Re-generates the tags shown on every TextTagPanel.

_ComponentGrid__lutChanged(*a)

Called when the LookupTable.labels change. Updates the options on every TextTagPanel.

_ComponentGrid__onGridSelect(ev)

Called when a row is selected on the WidgetGrid. Makes sure that the ‘new tag’ control in the corresponding TextTagPanel is focused.

_ComponentGrid__onTagAdded(ev)

Called when a tag is added to a TextTagPanel. Adds the corresponding component-label mapping to the VolumeLabels instance.

_ComponentGrid__onTagRemoved(ev)

Called when a tag is removed from a TextTagPanel. Removes the corresponding component-label mapping from the VolumeLabels instance.

_ComponentGrid__overlayTypeChanged(*a)

Called when the Display.overlayType of the currently displayed overlay changes. When the type of an overlay changes, a new DisplayOpts instance is created, so we need to re-register various property listeners with this new DisplayOpts instance.

_ComponentGrid__recreateTags()

Called by setOverlay(). Re-creates a TextTagPanel for every component in the Image.

_ComponentGrid__refreshTagOptions()

Updates the options available on each TextTagPanel, from the entries in the melodic classification LookupTable.

_ComponentGrid__volumeChanged(*a)

Called when the NiftiOpts.volume property changes. Selects the corresponding row in the WidgetGrid.

__module__ = 'fsleyes.controls.componentgrid'