fsleyes.controls.labelgrid

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

class fsleyes.controls.labelgrid.LabelGrid(parent, overlayList, displayCtx, frame, lut)[source]

Bases: fsleyes.panel.FSLeyesPanel

The LabelGrid class is the inverse of the ComponentGrid. It uses a WidgetGrid to display the label-component mappings present on the VolumeLabels instance associated with an Image. The Image and VolumeLabels instances are specified via the setOverlay() method.

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

__init__(parent, overlayList, displayCtx, frame, lut)[source]

Create a LabelGrid.

Parameters
destroy()[source]

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

setOverlay(overlay, volLabels)[source]

Set the Image shown on this LabelGrid. A listener is registered with its VolumeLabels, and its component-label mappings displayed on the WidgetGrid.

__deregisterCurrentOverlay()

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

__createTags(labels=None)

Makes sure that a TextTagPanel exists for every label in the LookupTable and in the VolumeLabels for the current overlay.

Parameters

labels – If None, this method does what is described above. Otherwise, this must be a list of tuples of (name, display name) specifying labels which are known not to be present, and for which a TextTagPanel needs to be created.

Returns

True if one or more new TextTagPanel widgets was created (and added to the WidgetGrid), False otherwise.

refreshTags(labels=None)[source]

Makes sure that the tags shown on each TextTagPanel are consistent with respect to the current state of the VolumeLabels.

Parameters

labels – Labels to refresh. If None, the tags for every displayed label is refreshed.

__onGridSelect(ev)

Called when a row is selected in the WidgetGrid. Makes sure that the first tag in the TextTagPanel has the focus.

__onTagAdded(ev)

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

__onTagRemoved(ev)

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

__onTagSelect(ev)

Called when a tag from a TextTagPanel is selected. Changes the current NiftiOpts.volume to the component corresponding to the selected tag.

__lutChanged(lut, topic, value)

Called when the LookupTable changes. Adds/removes/updates the displayed labels as needed.

__labelsChanged(volLabels, topic, components)

Called when the labels in the VolumeLabels associated with the current overlay change. Updates the displayed tags.

__module__ = 'fsleyes.controls.labelgrid'