fsleyes.controls.locationpanel

This module provides the LocationPanel class, a FSLeyes control panel which shows information about the current display location.

class fsleyes.controls.locationpanel.LocationPanel(parent, overlayList, displayCtx, frame, showHistory=False)

Bases: fsleyes.controls.controlpanel.ControlPanel

The LocationPanel is a panel which contains controls allowing the user to view and modify the DisplayContext.location property.

A LocationPanel is intended to be contained within a CanvasPanel, and looks something like this:

_images/locationpanel.png

By default, the LocationPanel contains a notebook with two pages:

  • The LocationInfoPanel contains information about the currently displayed location, and controls allowing the user to change the location.
  • The LocationHistoryPanel contains a list of previously visited locations, and allows the user to revisit those locations.

The history panel is optional - if the showHistory parameter to __init__ is False then only the information panel will be shown.

__init__(parent, overlayList, displayCtx, frame, showHistory=False)

Creat a LocationPanel.

Parameters:
destroy()

Must be called when this LocationPanel is no longer needed.

__module__ = 'fsleyes.controls.locationpanel'
class fsleyes.controls.locationpanel.LocationInfoPanel(parent, overlayList, displayCtx, frame)

Bases: fsleyes.panel.FSLeyesPanel

The LocationInfoPanel is a panel which is embedded in the LocationPanel, and which contains controls allowing the user to view and modify the DisplayContext.location property.

The LocationInfoPanel contains two main sections:

NIFTI overlays

The LocationInfoPanel is primarily designed to work with Image overlays. If the DisplayContext.selectedOverlay is an Image, or has an associated reference image (see DisplayOpts.referenceImage()), the LocationInfoPanel will display the current DisplayContext.location in both the the voxel coordinates and world coordinates of the Image instance.

Other overlays

If the DisplayContext.selectedOverlay is not an Image, or does not have an associated reference image, the LocationInfoPanel will display the current DisplayContext.location as-is (i.e. in the display coordinate system); furthermore, the voxel location controls will be disabled.

Location updates

The DISPLAYOPTS_BOUNDS and DISPLAYOPTS_INFO dictionaries contain lists of property names that the LocationInfoPanel listens on for changes, so it knows when the location widgets, and information about the currenty location, need to be refreshed. For example, when the :attr`.NiftiOpts.volume` property of a Nifti overlay changes, the volume index, and potentially the overlay information, needs to be updated.

voxelLocation = <MagicMock name='mock.Point()' id='140655054591984'>

If the currently selected overlay is a Image instance , this property tracks the current DisplayContext.location in voxel coordinates.

worldLocation = <MagicMock name='mock.Point()' id='140655054591984'>

For Image overlays, this property tracks the current DisplayContext.location in the image world coordinates. For other overlay types, this property tracks the current location in display coordinates.

__init__(parent, overlayList, displayCtx, frame)

Create a _FSLeyesPanel.

Parameters:
  • overlayList – A OverlayList instance.
  • displayCtx – A DisplayContext instance.
  • frame – The FSLeyesFrame that created this _FSLeyesPanel. May be None.
  • kbFocus – If True, a keyboard event handler is configured to intercept Tab and Shift+Tab keyboard events, to shift focus between a set of child widgets. The child widgets to be included in the navigation can be specified with the setNavOrder() method.
destroy()

Must be called when this LocationInfoPanel is no longer needed. Removes property listeners and calls FSLeyesPanel.destroy().

GetMinSize()

Returns the minimum size for this LocationInfoPanel.

Under Linux/GTK, the wx.agw.lib.aui layout manager seems to arbitrarily adjust the minimum sizes of some panels. Therefore, The minimum size of the LocationInfoPanel is calculated in __init__(), and is fixed.

DoGetBestClientSize()

Returns the best size for this LocationInfoPanel.

_LocationInfoPanel__boundsOptsChanged(*a)

Called when a DisplayOpts property associated with the currently selected overlay, and listed in the DISPLAYOPTS_BOUNDS dictionary, changes. Refreshes the LocationInfoPanel interface accordingly.

_LocationInfoPanel__calcWorldLabelMinSize()

Calculates the minimum size that the world label (the label which shows the coordinate space of the currently selected overlay) needs. Called by the __init__() method.

The world label displays different things depending on the currently selected overlay. But we want it to be a fixed size. So this method calculates the size of all possible values that the world label will display, and returns the maximum size. This is then used as the minimum size for the world label.

_LocationInfoPanel__deregisterOverlay()

De-registers property listeners with the Display and DisplayOpts instances associated with the previously registered overlay.

_LocationInfoPanel__displayLocationChanged(*a)

Called when the DisplayContext.location changes. Propagates the change on to the voxelLocation and worldLocation properties.

Note

Because the DisplayContext.location, voxelLocation and worldLocation properties are all linked through property listeners (see props.HasProperties.addListener()), we need to be a bit careful to avoid circular updates. Therefore, each of the __displayLocationChanged(), __worldLocationChanged() and __voxelLocationChanged() methods use the __prePropagate(), __propagate(), and __postPropagate() methods to propagate changes between the three location properties.

_LocationInfoPanel__infoOptsChanged(*a)

Called when a DisplayOpts property associated with the currently selected overlay, and listed in the DISPLAYOPTS_INFO dictionary, changes. Refreshes the LocationInfoPanel interface accordingly.

_LocationInfoPanel__overlayOrderChanged(*a)

Called when the DisplayContext.overlayOrder changes, Refreshes the information panel.

_LocationInfoPanel__postPropagate()

Called by the __displayLocationChanged(), __worldLocationChanged() and __voxelLocationChanged() methods.

Re-enables the property listeners that were disabled by the __postPropagate() method.

_LocationInfoPanel__prePropagate()

Called by the __displayLocationChanged(), __worldLocationChanged() and __voxelLocationChanged() methods.

Disables notification of all location property listeners, so circular updates do not occur.

_LocationInfoPanel__propagate(source, target)

Called by the __displayLocationChanged(), __worldLocationChanged() and __voxelLocationChanged() methods. Copies the coordinates from the source location to the target location. Valid values for the source and target are:

display The DisplayContext.location property.
voxel The voxelLocation property.
world The worldLocation property.
_LocationInfoPanel__registerOverlay()

Registers property listeners with the Display and DisplayOpts instances associated with the currently selected overlay.

_LocationInfoPanel__selectedOverlayChanged(*a)

Called when the DisplayContext.selectedOverlay or OverlayList is changed. Registered with the new overlay, and refreshes the LocationInfoPanel interface accordingly.

_LocationInfoPanel__updateLocationInfo()

Called whenever the DisplayContext.location changes. Updates the HTML panel which displays information about all overlays in the OverlayList.

_LocationInfoPanel__updateWidgets()

Called by the __selectedOverlayChanged() and __displayOptsChanged() methods. Enables/disables the voxel/world location and volume controls depending on the currently selected overlay (or reference image).

_LocationInfoPanel__vertexDataChanged(*a)

Called when the selected overlay is a Mesh, and its MeshOpts.vertexData property changes. Updates the volume widget.

_LocationInfoPanel__volumeDimChanged(*a)

Called when the selected overlay is a Nifti, and its NiftiOpts.volumeDim property changes. Updates the volume widget.

_LocationInfoPanel__voxelLocationChanged(*a)

Called when the voxelLocation changes. Propagates the change on to the worldLocation and DisplayContext.location properties.

_LocationInfoPanel__worldLocationChanged(*a)

Called when the worldLocation changes. Propagates the change on to the voxelLocation and DisplayContext.location properties.

__module__ = 'fsleyes.controls.locationpanel'
fsleyes.controls.locationpanel.DISPLAYOPTS_BOUNDS = <MagicMock name='mock.utils.typedict.TypeDict()' id='140655054538120'>

Different DisplayOpts types have different properties which affect the current overlay bounds. Therefore, when the current overlay changes (as dictated by the DisplayContext.selectedOverlay property),the __registerOverlay() method registers property listeners on the properties specified in this dictionary.

fsleyes.controls.locationpanel.DISPLAYOPTS_INFO = <MagicMock name='mock.utils.typedict.TypeDict()' id='140655054538120'>

Different DisplayOpts types have different properties which affect the current overlay location information. Therefore, when the current overlay changes the __registerOverlay() method registers property listeners on the properties specified in this dictionary.

class fsleyes.controls.locationpanel.LocationHistoryPanel(parent, overlayList, displayCtx, frame, canvasPanel, limit=500)

Bases: fsleyes.panel.FSLeyesPanel

The LocationHistoryPanel is a panel which is embedded in the LocationPanel, and which contains a list of locations previously visited by the user.

__init__(parent, overlayList, displayCtx, frame, canvasPanel, limit=500)

Create a LocationHistoryPanel.

Parameters:
  • parent – The wx parent object.
  • overlayList – The OverlayList instance.
  • displayCtx – The DisplayContext instance.
  • frame – The FSLeyesFrame instance.
  • canvasPanel – The CanvasPanel which owns this LocationHistoryPanel.
  • limit – Maximum number of locations to save before dropping old locations.
destroy()

Must be called when this LocationHistoryPanel is no longer needed.

getHistory()

Returns a list containing the currently displayed location history. Each entry in the list is a tuple containing the coordinates, and any comment that the user has addded.

_LocationHistoryPanel__addLocation(worldLoc, comment=None)

Add a location to the location history.

Parameters:
  • worldLoc – Location in world coordinates
  • comment – Comment about the location
_LocationHistoryPanel__deregisterProfile()

De-registers listeners that have previously been registered with a Profile object.

_LocationHistoryPanel__onClear(ev)

Called when the clear button is pushed. Clears the current history.

_LocationHistoryPanel__onListSelect(ev)

Called when a location is selected from the location history list.

Sets the DisplayContext.worldLocation accordingly.

_LocationHistoryPanel__onLoad(ev)

Called when the load button is pushed. Prompts the user to select a file, then loads a history from that file.

_LocationHistoryPanel__onMouseUp(ev, canvas, mouseLoc, canvasLoc)

Called on mouse up events. Adds the mouse location (in the world coordinate system) to the location history list.

_LocationHistoryPanel__onSave(ev)

Called when the save button is pushed. Prompts the user to select a file name, then saves the current history to that file.

_LocationHistoryPanel__profileChanged(*a)

Called when the CanvasPanel.profile changes. Re-registers mouse event listeners with the new Profile object.

_LocationHistoryPanel__registerProfile(profile)

Registers a mouse event listener with the given profile.

__module__ = 'fsleyes.controls.locationpanel'
fsleyes.controls.locationpanel.loadLocationHistory(filename)

Loads a location history from the given filename. A location history file contains one location on each line, where the X, Y, and Z coordinates are separated by a space character. All remaining characters on the line are treated as the location comment. For example:

1.27 4.23 1.63 this is a comment
5.25 2.66 1.23

Returns a list containing the location history, in the same format as that returned by LocationHistoryPanel.getHistory().

fsleyes.controls.locationpanel.saveLocationHistory(history, filename)

Saves the given location history to the given filename. See loadLocationHistory() and LocationHistoryPanel.getHistory().