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.ControlPanelAn
AtlasPanelis aControlPanelwhich allows the user to view atlas information, and to browse through the atlases that come shipped with FSL. TheAtlasPanelinterface is provided by some sub-panels, which are displayed in afsleyes_widgets.Notebookpanel. TheAtlasPanelitself provides a number of convenience methods that are used by these sub-panels:Displays information for the current
DisplayContext.locationfrom atlases selected by the user.Allows the user to search through all atlases for specific regions, and to toggle on/off overlays for those regions.
Allows the user to add/remove atlases.
Loading atlases
The
AtlasPanelclass provides theloadAtlas()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 aDisplay.overlayTypeoflabel.A mask image containing a single region, extracted from a
LabelAtlas. These images are added with aDisplay.overlayTypeofmask.A 3D image containing the statistic image for a single region, extracted from a
StatisticAtlas. These images are added with aDisplay.overlayTypeofvolume.
The following methods allow these overlays to be toggled on/off, and to query their state:
Adds or removes the specified overlay to/from the
OverlayList.Returns a name to be used for the specified atlas (see the section on atlas names).
Returns
Trueif the specified atlas overlay is in theOverlayList,Falseotherwise.Atlas overlay names
When an atlas overlay is added, its
Image.name(and subsequently itsDisplay.name) are set to a name which has the following structure:atlasID/overlayType/regionName
where:
atlasIDis the atlas identifier (see theatlasesmodule).overlayTypeis eitherlabel,prob, orstat, depending on whether the overlay is a discrete label image, a probaility image, or a statistic image..regionNameis the name of the region, orallif the overlay is a completeLabelAtlas.
This name is used by the
AtlasPanelto identify the overlay in theOverlayList.Warning
If the name of these overlays is changed, the
AtlasPanelwill not be able to find them in theOverlayList, and thetoggleOverlay()andgetOverlayState()methods will stop working properly. So don’t change the atlas overlay names!Locating regions
Finally, the
locateRegion()method allows theDisplayContext.locationto be moved to the location of a specific region in a specific atlas.-
__init__(parent, overlayList, displayCtx, frame)[source]¶ Create an
AtlasPanel.- Parameters
parent – The
wxparent object.overlayList – The
OverlayListinstance.displayCtx – The
DisplayContextinstance.frame – The
FSLeyesFrameinstance.
-
destroy()[source]¶ Must be called on when this
AtlasPanelis no longer needed.Calls the
destroymethods of theAtlasInfoPanelandAtlasOverlayPanel, and then callsControlPanel.destroy().
-
enableAtlasPanel(enable=True)[source]¶ Disables/enables the
AtlasPanelwhich contains thisAtlasOverlayPanel. This method is used byOverlayListWidgetinstances.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. TheAtlasPanelis only enabled when the count reaches 0.This ugly method solves an awkward problem - the
AtlasOverlayPaneldisables theAtlasPanelwhen an atlas overlay is toggled on/off (via anOverlayListWidget), and when an atlas region list is being generated (via the__onAtlasSelect()method). If both of these things occur at the same time, theAtlasPanelcould 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
idlemodule), 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
Atlasimage.onError – Optional. A function which is called if the atlas loading job raises an error. Passed the
Exceptionthat was raised.matchResolution – If
True(the default), the version of the atlas with the most suitable resolution, based on the current contents of theOverlayList, 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
Nonefor a complete atlas.summary –
Truecorresponds to a label atlas,Falseto a probabilistic atlas.
-
getOverlayState(atlasID, labelIdx, summary)[source]¶ Returns
Trueif the specified atlas overlay is in theOverlayList,Falseotherwise. SeegetOverlayName()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.locationto the specified region in the specified atlas. See theAtlasDescriptionclass 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 theOverlayList.
-
_AtlasPanel__overlayListChanged(*a)¶ Called when the
OverlayListchanges.Makes sure that the
AtlasOverlayPanelstate is up to date - see theAtlasOverlayPanel.setOverlayState()method.
-
__module__= 'fsleyes.controls.atlaspanel'¶