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 aWidgetGrid
, and a set ofTextTagPanel
widgets, to display the component classifications stored in theVolumeLabels
object that is associated with anImage
(typically aMelodicImage
). TheImage
andVolumeLabels
instance is specified via thesetOverlay()
method.The grid contains one row for each component, and a
TextTagPanel
is used to display the labels associated with each component. EachTextTagPanel
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
parent – The
wx
parent object.overlayList – The
OverlayList
.displayCtx – The
DisplayContext
.frame – The
FSLeyesFrame
instance.lut – The
LookupTable
instance used to colour each label tag.
- destroy()[source]¶
Must be called when this
ComponentGrid
is no longer needed. De-registers various property listeners, and callsFSLeyesPanel.destroy()
.
- setOverlay(overlay, volLabels, refreshGrid=True)[source]¶
Sets the
Image
to display component labels for. TheWidgetGrid
is re-populated to display the component-label mappings contained in theVolumeLabels
instance associated with the overlay.- Parameters
refreshGrid – If
True
(the default), theWidgetGrid
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 newDisplayOpts
instance is created, so we need to re-register various property listeners with this newDisplayOpts
instance.
- __recreateTags()¶
Called by
setOverlay()
. Re-creates aTextTagPanel
for every component in theImage
.
- __refreshTagOptions()¶
Updates the options available on each
TextTagPanel
, from the entries in the melodic classificationLookupTable
.
- __onTagAdded(ev)¶
Called when a tag is added to a
TextTagPanel
. Adds the corresponding component-label mapping to theVolumeLabels
instance.
- __onTagRemoved(ev)¶
Called when a tag is removed from a
TextTagPanel
. Removes the corresponding component-label mapping from theVolumeLabels
instance.
- __onGridSelect(ev)¶
Called when a row is selected on the
WidgetGrid
. Makes sure that the ‘new tag’ control in the correspondingTextTagPanel
is focused.
- __volumeChanged(*a)¶
Called when the
NiftiOpts.volume
property changes. Selects the corresponding row in theWidgetGrid
.
- __labelsChanged(volLabels, topic, components)¶
Called on
VolumeLabels
notifications. Re-generates the tags shown on everyTextTagPanel
.
- __lutChanged(*a)¶
Called when the
LookupTable.labels
change. Updates the options on everyTextTagPanel
.
- __annotations__ = {}¶
- __module__ = 'fsleyes.controls.componentgrid'¶