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)[source]

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)[source]

Create a ComponentGrid.

Parameters
destroy()[source]

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

setOverlay(overlay, volLabels, refreshGrid=True)[source]

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)[source]

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.

__deregisterCurrentOverlay()

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

__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.

__recreateTags()

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

__refreshTagOptions()

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

__onTagAdded(ev)

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

__onTagRemoved(ev)

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

__onGridSelect(ev)

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

__volumeChanged(*a)

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

__labelsChanged(volLabels, topic, components)

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

__lutChanged(*a)

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

__annotations__ = {}
__module__ = 'fsleyes.controls.componentgrid'