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.FSLeyesPanelThe
LabelGridclass is the inverse of theComponentGrid. It uses aWidgetGridto display the label-component mappings present on theVolumeLabelsinstance associated with anImage. TheImageandVolumeLabelsinstances are specified via thesetOverlay()method.The grid contains one row for each label, and a
TextTagPanelis used to display the components associated with each label. EachTextTagPanelallows the user to add and remove components to/from the corresponding label.-
__init__(parent, overlayList, displayCtx, frame, lut)[source]¶ Create a
LabelGrid.- Parameters
parent – The
wxparent object.overlayList – The
OverlayList.displayCtx – The
DisplayContext.frame – The
FSLeyesFrameinstance.lut – The
LookupTableto be used to colour component tags.
-
destroy()[source]¶ Must be called when this
LabelGridis no longer needed. De-registers various property listeners, and callsFSLeyesPanel.destroy().
-
setOverlay(overlay, volLabels)[source]¶ Set the
Imageshown on thisLabelGrid. A listener is registered with itsVolumeLabels, and its component-label mappings displayed on theWidgetGrid.
-
refreshTags(labels=None)[source]¶ Makes sure that the tags shown on each
TextTagPanelare 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
TextTagPanelexists for every label in theLookupTableand in theVolumeLabelsfor 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 aTextTagPanelneeds to be created.- Returns
Trueif one or more newTextTagPanelwidgets was created (and added to theWidgetGrid),Falseotherwise.
-
_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
VolumeLabelsassociated with the current overlay change. Updates the displayed tags.
-
_LabelGrid__lutChanged(lut, topic, value)¶ Called when the
LookupTablechanges. 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 theTextTagPanelhas the focus.
-
_LabelGrid__onTagAdded(ev)¶ Called when a tag is added to a
TextTagPanel. Adds the corresponding label-component mapping to theVolumeLabelsinstance.
-
_LabelGrid__onTagRemoved(ev)¶ Called when a tag is removed from a
TextTagPanel. Removes the corresponding label-component mapping from theVolumeLabelsinstance.
-
_LabelGrid__onTagSelect(ev)¶ Called when a tag from a
TextTagPanelis selected. Changes the currentNiftiOpts.volumeto the component corresponding to the selected tag.
-
__module__= 'fsleyes.controls.labelgrid'¶
-