fsleyes.controls.clusterpanel

This module provides the ClusterPanel class, a FSLeyes control panel for viewing cluster results from a FEAT analysis.

class fsleyes.controls.clusterpanel.ClusterPanel(parent, overlayList, displayCtx, frame)[source]

Bases: fsleyes.controls.controlpanel.ControlPanel

The ClusterPanel shows a table of cluster results from the analysis associated with a FEATImage overlay. A ClusterPanel looks something like the following:

_images/clusterpanel.png

The ClusterPanel contains controls which allow the user to:

  • Select the COPE for which cluster results are displayed

  • Add a Z statistic overlay for the currently displayed COPE

  • Add a cluster mask overlay for the currently displayed COPE

  • Navigate to the Z maximum location, Z centre-of-gravity location, or COPE maximum location, for a specific cluster.

When an overlay is selected (detected via the DisplayContext.selectedOverlay property), a ClusterPanel tries to identify the FEAT analysis associated with the overlay. If the overlay is a FEATImage, then no work needs to be done. Otherwise, the ClusterPanel uses functions in the featanalysis module to identify the FEAT directory. Ultimately, a reference to a FEATImage associated with the currently selected overlay is obtained, so the ClusterPanel can retrieve contrast and cluster information.

A ClusterPanel uses a WidgetGrid to display information about the clusters associated with a contrast. Because creating all of the widgets contained in the WidgetGrid is expensive, a ClusterPanel creates (on demand) and caches WidgetGrid instances for all FEATImage overlay and contrasts. This means that when the user changes the currently selected overlay, or the current contrast, the displayed cluster information is updated quickly.

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

Create a ClusterPanel.

Parameters
destroy()[source]

Must be called when this ClusterPanel is no longer needed. Removes some property listeners, and calls ControlPanel.destroy().

__calcMinSize()

Figures out the minimum size that this ClusterPanel should have. Called by __init__().

When the ClusterPanel is created, the COPE combo box is not populated, so has no minimum size. Here, we figure out a good minimum size for it. We can then calculate a good minimum size for the entire panel.

__disable(message)

Disables the ClusterPanel, and displays the given message. Called when the selected overlay is not associated with a FEAT analysis, or when cluster results cannot be displayed for some reason.

__enable()

Enables the ClusterPanel. This amounts to hiding the disabled message panel, and showing the appropriate WidgetGrid for the currently selected overlay / contrast. The appropriate WidgetGrid is assumed to have already been created.

__statSelected(ev=None)

Called when a COPE is selected. Retrieves a cached WidgetGrid, or creates a new one (via the __genClusterGrid() method) which displays information about the clusters associated with the currently selected contrast.

__addZStatsClick(ev)

Called when the Add Z statistics button is pushed. Retrieves the Z statistic image for the current COPE (see the FEATImage.getZStats() method), and adds it as an overlay to the OverlayList.

__addClustMaskClick(ev)

Called when the Add cluster mask button is pushed. Retrieves the cluster mask image for the currewnt contrast (see the FEATImage.getClusterMask() method)

__genClusterGrid(overlay, featImage, contrast, clusters)

Creates and returns a WidgetGrid which contains the given list of clusters, which are related to the given contrast.

Note

This method assumes that the given overlay is an Image which has the same voxel dimensions as, and shares the the same world coordinate system as the featImage.

Parameters
  • overlay – The overlay for which clusters are currently being displayed.

  • featImage – The FEATImage to which the clusters are related.

  • contrast – The (0-indexed) number of the contrast to which the clusters are related.

  • clusters – A sequence of objects, each representing one cluster. See the FEATImage.clusterResults() method.

__overlayListChanged(*a)

Called when the OverlayList changes. Destroys any cached WidgetGrid instances as needed, updates the Add Z statistic and Add cluster mask buttons, in case the user removed them, and calls __selectedOverlayChanged().

__enableOverlayButtons()

Enables/disables the Add Z statistic and Add cluster mask buttons depending on whether the corresponding overlays are in the OverlayList.

__selectedOverlayChanged(*a)

Called when the DisplayContext.selectedOverlay changes, and by the __overlayListChanged() method.

If the newly selected overlay is a FEATImage (or is otherwise associated with a FEAT analysis) which has cluster results, they are loaded in, and displayed on a WidgetGrid.

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