fsleyes.controls.atlaspanel

This module provides the AtlasPanel, a FSLeyes control panel which allows the user to browse the FSL atlas images. See the fsleyes package documentation for more details on control panels, and the atlases module for more details on the atlases available in FSL.

class fsleyes.controls.atlaspanel.AtlasPanel(parent, overlayList, displayCtx, frame)[source]

Bases: fsleyes.controls.controlpanel.ControlPanel

An AtlasPanel is a ControlPanel which allows the user to view atlas information, and to browse through the atlases that come shipped with FSL. The AtlasPanel interface is provided by some sub-panels, which are displayed in a fsleyes_widgets.Notebook panel. The AtlasPanel itself provides a number of convenience methods that are used by these sub-panels:

AtlasInfoPanel

Displays information for the current DisplayContext.location from atlases selected by the user.

AtlasOverlayPanel

Allows the user to search through all atlases for specific regions, and to toggle on/off overlays for those regions.

AtlasManagementPanel

Allows the user to add/remove atlases.

Loading atlases

The AtlasPanel class provides the loadAtlas() method, which is used by sub-panels to load atlas images.

Toggling atlas overlays

Both of the sub-panels allow the user to add/remove overlays to/from the OverlayList. The following overlay types can be added:

  • A complete summary LabelAtlas, which is a 3D image where each region has a discrete integer label. These images are added with a Display.overlayType of label.

  • A mask image containing a single region, extracted from a LabelAtlas. These images are added with a Display.overlayType of mask.

  • A 3D image containing the statistic image for a single region, extracted from a StatisticAtlas. These images are added with a Display.overlayType of volume.

The following methods allow these overlays to be toggled on/off, and to query their state:

toggleOverlay

Adds or removes the specified overlay to/from the OverlayList.

getOverlayName

Returns a name to be used for the specified atlas (see the section on atlas names).

getOverlayState

Returns True if the specified atlas overlay is in the OverlayList, False otherwise.

Atlas overlay names

When an atlas overlay is added, its Image.name (and subsequently its Display.name) are set to a name which has the following structure:

atlasID/overlayType/regionName

where:

  • atlasID is the atlas identifier (see the atlases module).

  • overlayType is either label, prob, or stat, depending on whether the overlay is a discrete label image, a probaility image, or a statistic image..

  • regionName is the name of the region, or all if the overlay is a complete LabelAtlas.

_images/atlaspanel_overlay_names.png

This name is used by the AtlasPanel to identify the overlay in the OverlayList.

Warning

If the name of these overlays is changed, the AtlasPanel will not be able to find them in the OverlayList, and the toggleOverlay() and getOverlayState() methods will stop working properly. So don’t change the atlas overlay names!

Locating regions

Finally, the locateRegion() method allows the DisplayContext.location to be moved to the location of a specific region in a specific atlas.

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

Create an AtlasPanel.

Parameters
destroy()[source]

Must be called on when this AtlasPanel is no longer needed.

Calls the destroy methods of the AtlasInfoPanel and AtlasOverlayPanel, and then calls ControlPanel.destroy().

Enable(enable=True)[source]

Enables/disables this AtlasPanel.

Disable()[source]

Disables this AtlasPanel.

enableAtlasPanel(enable=True)[source]

Disables/enables the AtlasPanel which contains this AtlasOverlayPanel. This method is used by OverlayListWidget instances.

This method keeps a count of the number of times that it has been called - the count is increased every time a request is made to disable the AtlasPanel, and decreased on requests to enable it. The AtlasPanel is only enabled when the count reaches 0.

This ugly method solves an awkward problem - the AtlasOverlayPanel disables the AtlasPanel when an atlas overlay is toggled on/off (via an OverlayListWidget), and when an atlas region list is being generated (via the __onAtlasSelect() method). If both of these things occur at the same time, the AtlasPanel could be prematurely re-enabled. This method overcomes this problem.

loadAtlas(atlasID, summary, onLoad=None, onError=None, matchResolution=True)[source]

Loads the atlas image with the specified ID. The atlas is loaded asynchronously (via the idle module), as it can take some time. Use the onLoad argument if you need to do something when the atlas has been loaded.

Parameters
  • onLoad – Optional. A function which is called when the atlas has been loaded, and which is passed the loaded Atlas image.

  • onError – Optional. A function which is called if the atlas loading job raises an error. Passed the Exception that was raised.

  • matchResolution – If True (the default), the version of the atlas with the most suitable resolution, based on the current contents of the OverlayList, is loaded.

See the atlases.loadAtlas() function for details on the other arguments.

getOverlayName(atlasID, labelIdx, summary)[source]

Returns a name to be used for the specified atlas (see the section on atlas names).

Parameters
  • atlasID – Atlas identifier

  • labelIdx – Label index, or None for a complete atlas.

  • summaryTrue corresponds to a label atlas, False to a probabilistic atlas.

getOverlayState(atlasID, labelIdx, summary)[source]

Returns True if the specified atlas overlay is in the OverlayList, False otherwise. See getOverlayName() for details on the arguments.

toggleOverlay(atlasID, labelIdx, summary, onLoad=None, onError=None)[source]

Adds or removes the specified overlay to/from the OverlayList.

Parameters
  • onLoad – Optional function to be called when the overlay has been added/removed.

  • onError – Optional function to be called if an error occurs while loading an overlay.

See getOverlayName() for details on the other arguments.

locateRegion(atlasID, labelIdx)[source]

Moves the DisplayContext.location to the specified region in the specified atlas. See the AtlasDescription class for details on atlas identifiers/label indices.

Parameters
  • atlasID – Atlas identifier

  • labelIdx – Label index

_AtlasPanel__getSuitableResolution(desc, matchResolution=True)

Used by the loadAtlas() method. Determines a suitable atlas resolution to load, based on the current contents of the OverlayList.

_AtlasPanel__overlayListChanged(*a)

Called when the OverlayList changes.

Makes sure that the AtlasOverlayPanel state is up to date - see the AtlasOverlayPanel.setOverlayState() method.

__module__ = 'fsleyes.controls.atlaspanel'