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)¶ Bases:
fsleyes.panel.FSLeyesPanel
The
LabelGrid
class is the inverse of theComponentGrid
. It uses aWidgetGrid
to display the label-component mappings present on theVolumeLabels
instance associated with anImage
. TheImage
andVolumeLabels
instances are specified via thesetOverlay()
method.The grid contains one row for each label, and a
TextTagPanel
is used to display the components associated with each label. EachTextTagPanel
allows the user to add and remove components to/from the corresponding label.-
__init__
(parent, overlayList, displayCtx, frame, lut)¶ Create a
LabelGrid
.Parameters: - parent – The
wx
parent object. - overlayList – The
OverlayList
. - displayCtx – The
DisplayContext
. - frame – The
FSLeyesFrame
instance. - lut – The
LookupTable
to be used to colour component tags.
- parent – The
-
destroy
()¶ Must be called when this
LabelGrid
is no longer needed. De-registers various property listeners, and callsFSLeyesPanel.destroy()
.
-
setOverlay
(overlay, volLabels)¶ Set the
Image
shown on thisLabelGrid
. A listener is registered with itsVolumeLabels
, and its component-label mappings displayed on theWidgetGrid
.
-
refreshTags
(labels=None)¶ Makes sure that the tags shown on each
TextTagPanel
are consistent with respect to the current state of theVolumeLabels
.Parameters: labels – Labels to refresh. If None
, the tags for every displayed label is refreshed.
-
_LabelGrid__createTags
(labels=None)¶ Makes sure that a
TextTagPanel
exists for every label in theLookupTable
and in theVolumeLabels
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 aTextTagPanel
needs to be created.Returns: True
if one or more newTextTagPanel
widgets was created (and added to theWidgetGrid
),False
otherwise.
-
_LabelGrid__deregisterCurrentOverlay
()¶ Called when the selected overlay changes. De-registers property listeners associated with the previously selected overlay, if necessary.
-
_LabelGrid__labelsChanged
(volLabels, topic, components)¶ Called when the labels in the
VolumeLabels
associated with the current overlay change. Updates the displayed tags.
-
_LabelGrid__lutChanged
(lut, topic, value)¶ Called when the
LookupTable
changes. Adds/removes/updates the displayed labels as needed.
-
_LabelGrid__onGridSelect
(ev)¶ Called when a row is selected in the
WidgetGrid
. Makes sure that the first tag in theTextTagPanel
has the focus.
-
_LabelGrid__onTagAdded
(ev)¶ Called when a tag is added to a
TextTagPanel
. Adds the corresponding label-component mapping to theVolumeLabels
instance.
-
_LabelGrid__onTagRemoved
(ev)¶ Called when a tag is removed from a
TextTagPanel
. Removes the corresponding label-component mapping from theVolumeLabels
instance.
-
_LabelGrid__onTagSelect
(ev)¶ Called when a tag from a
TextTagPanel
is selected. Changes the currentNiftiOpts.volume
to the component corresponding to the selected tag.
-
__module__
= 'fsleyes.controls.labelgrid'¶
-