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)[source]¶ Bases:
fsleyes.controls.controlpanel.ControlPanelThe
LocationPanelis a panel which contains controls allowing the user to view and modify theDisplayContext.locationproperty.A
LocationPanelis intended to be contained within aCanvasPanel, and looks something like this:
By default, the
LocationPanelcontains a notebook with two pages:The
LocationInfoPanelcontains information about the currently displayed location, and controls allowing the user to change the location.The
LocationHistoryPanelcontains a list of previously visited locations, and allows the user to revisit those locations.
The history panel is optional - if the
showHistoryparameter to__init__isFalsethen only the information panel will be shown.-
__init__(parent, overlayList, displayCtx, frame, showHistory=False)[source]¶ Creat a
LocationPanel.- Parameters
parent – The
wxparent object, assumed to be aCanvasPanel.overlayList – The
OverlayListinstance.displayCtx – The
DisplayContextinstance.frame – The
FSLeyesFrameinstance.showHistory – Defaults to
False. IfTrue, create and display aLocationHistoryPanel.
-
__module__= 'fsleyes.controls.locationpanel'¶
-
class
fsleyes.controls.locationpanel.LocationInfoPanel(parent, overlayList, displayCtx, frame)[source]¶ Bases:
fsleyes.panel.FSLeyesPanelThe
LocationInfoPanelis a panel which is embedded in theLocationPanel, and which contains controls allowing the user to view and modify theDisplayContext.locationproperty.The
LocationInfoPanelcontains two main sections:A collection of controls which show the current
DisplayContext.locationA
wx.html.HtmlWindowwhich displays information about the currentDisplayContext.locationfor all overlays in theOverlayList.
NIFTI overlays
The
LocationInfoPanelis primarily designed to work withImageoverlays. If theDisplayContext.selectedOverlayis anImage, or has an associated reference image (seeDisplayOpts.referenceImage()), theLocationInfoPanelwill display the currentDisplayContext.locationin both the the voxel coordinates and world coordinates of theImageinstance.Other overlays
If the
DisplayContext.selectedOverlayis not anImage, or does not have an associated reference image, theLocationInfoPanelwill display the currentDisplayContext.locationas-is (i.e. in the display coordinate system); furthermore, the voxel location controls will be disabled.Location updates
The
DISPLAYOPTS_BOUNDSandDISPLAYOPTS_INFOdictionaries contain lists of property names that theLocationInfoPanellistens 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 aNiftioverlay changes, the volume index, and potentially the overlay information, needs to be updated.-
voxelLocation= <MagicMock name='mock.Point()' id='281473494796800'>¶ If the currently selected overlay is a
Imageinstance , this property tracks the currentDisplayContext.locationin voxel coordinates.
-
worldLocation= <MagicMock name='mock.Point()' id='281473494796800'>¶ For
Imageoverlays, this property tracks the currentDisplayContext.locationin the image world coordinates. For other overlay types, this property tracks the current location in display coordinates.
-
__init__(parent, overlayList, displayCtx, frame)[source]¶ Create a
_FSLeyesPanel.- Parameters
overlayList – A
OverlayListinstance.displayCtx – A
DisplayContextinstance.frame – The
FSLeyesFramethat created this_FSLeyesPanel. May beNone.kbFocus – If
True, a keyboard event handler is configured to interceptTabandShift+Tabkeyboard events, to shift focus between a set of child widgets. The child widgets to be included in the navigation can be specified with thesetNavOrder()method.
-
destroy()[source]¶ Must be called when this
LocationInfoPanelis no longer needed. Removes property listeners and callsFSLeyesPanel.destroy().
-
GetMinSize()[source]¶ Returns the minimum size for this
LocationInfoPanel.Under Linux/GTK, the
wx.agw.lib.auilayout manager seems to arbitrarily adjust the minimum sizes of some panels. Therefore, The minimum size of theLocationInfoPanelis calculated in__init__(), and is fixed.
-
_LocationInfoPanel__boundsOptsChanged(*a)¶ Called when a
DisplayOptsproperty associated with the currently selected overlay, and listed in theDISPLAYOPTS_BOUNDSdictionary, changes. Refreshes theLocationInfoPanelinterface 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
DisplayandDisplayOptsinstances associated with the previously registered overlay.
-
_LocationInfoPanel__displayLocationChanged(*a)¶ Called when the
DisplayContext.locationchanges. Propagates the change on to thevoxelLocationandworldLocationproperties.Note
Because the
DisplayContext.location,voxelLocationandworldLocationproperties are all linked through property listeners (seeprops.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__genDisplaySpaceWarning()¶ Generate a warning if images with different orientations and/or fields-of-view are loaded.
-
_LocationInfoPanel__genImageInfo(ovl, opts)¶ Generate an info line for the given
Imageoverlay.
-
_LocationInfoPanel__genMeshInfo(ovl, opts)¶ Generate an info line for the given
Meshoverlay.
-
_LocationInfoPanel__infoOptsChanged(*a)¶ Called when a
DisplayOptsproperty associated with the currently selected overlay, and listed in theDISPLAYOPTS_INFOdictionary, changes. Refreshes theLocationInfoPanelinterface accordingly.
-
_LocationInfoPanel__overlayOrderChanged(*a)¶ Called when the
DisplayContext.overlayOrderchanges, 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 thesourcelocation to thetargetlocation. Valid values for thesourceandtargetare:displayThe
DisplayContext.locationproperty.voxelThe
voxelLocationproperty.worldThe
worldLocationproperty.
-
_LocationInfoPanel__registerOverlay()¶ Registers property listeners with the
DisplayandDisplayOptsinstances associated with the currently selected overlay.
-
_LocationInfoPanel__selectedOverlayChanged(*a)¶ Called when the
DisplayContext.selectedOverlayorOverlayListis changed. Registered with the new overlay, and refreshes theLocationInfoPanelinterface accordingly.
-
_LocationInfoPanel__updateLocationInfo()¶ Called whenever the
DisplayContext.locationchanges. Updates the HTML panel which displays information about all overlays in theOverlayList.
-
_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 itsMeshOpts.vertexDataproperty changes. Updates the volume widget.
-
_LocationInfoPanel__volumeDimChanged(*a)¶ Called when the selected overlay is a
Nifti, and itsNiftiOpts.volumeDimproperty changes. Updates the volume widget.
-
_LocationInfoPanel__voxelLocationChanged(*a)¶ Called when the
voxelLocationchanges. Propagates the change on to theworldLocationandDisplayContext.locationproperties.
-
_LocationInfoPanel__worldLocationChanged(*a)¶ Called when the
worldLocationchanges. Propagates the change on to thevoxelLocationandDisplayContext.locationproperties.
-
__module__= 'fsleyes.controls.locationpanel'¶
-
fsleyes.controls.locationpanel.DISPLAYOPTS_BOUNDS= <MagicMock name='mock.utils.typedict.TypeDict()' id='281473492539520'>¶ Different
DisplayOptstypes have different properties which affect the current overlay bounds. Therefore, when the current overlay changes (as dictated by theDisplayContext.selectedOverlayproperty),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='281473492539520'>¶ Different
DisplayOptstypes 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)[source]¶ Bases:
fsleyes.panel.FSLeyesPanelThe
LocationHistoryPanelis a panel which is embedded in theLocationPanel, and which contains a list of locations previously visited by the user.-
__init__(parent, overlayList, displayCtx, frame, canvasPanel, limit=500)[source]¶ Create a
LocationHistoryPanel.- Parameters
parent – The
wxparent object.overlayList – The
OverlayListinstance.displayCtx – The
DisplayContextinstance.frame – The
FSLeyesFrameinstance.canvasPanel – The
CanvasPanelwhich owns thisLocationHistoryPanel.limit – Maximum number of locations to save before dropping old locations.
-
getHistory()[source]¶ 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
Profileobject.
-
_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.worldLocationaccordingly.
-
_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.profilechanges. Re-registers mouse event listeners with the newProfileobject.
-
_LocationHistoryPanel__registerProfile(profile)¶ Registers a mouse event listener with the given
profile.
-
__module__= 'fsleyes.controls.locationpanel'¶
-
-
fsleyes.controls.locationpanel.loadLocationHistory(filename)[source]¶ 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)[source]¶ Saves the given location
historyto the givenfilename. SeeloadLocationHistory()andLocationHistoryPanel.getHistory().