fsleyes.plugins.tools.edittransform¶
This module provides the EditTransformPanel (a.k.a. “Nudge”)
class, a FSLeyes control panel which allows the user to adjust the
voxToWorldMat of an Image overlay.
-
class
fsleyes.plugins.tools.edittransform.EditTransformAction(overlayList, displayCtx, ortho)[source]¶ Bases:
fsleyes.actions.togglecontrolpanel.ToggleControlPanelActionThe
EditTransformActionjust toggles anEditTransformPanel. It is added under the FSLeyes Tools menu.-
static
supportedViews()[source]¶ The
EditTransformActionis restricted for use withOrthoPanelviews.
-
destroy()[source]¶ Called when the
OrthoPanelthat owns this action is closed. Clears references, removes listeners, and calls the base classdestroymethod.
-
__selectedOverlayChanged(*a)¶ Called when the selected overlay changes. Enables/disables this action (and hence the bound Tools menu item) depending on whether the overlay is an image.
-
__module__= 'fsleyes.plugins.tools.edittransform'¶
-
static
-
class
fsleyes.plugins.tools.edittransform.EditTransformPanel(parent, overlayList, displayCtx, ortho)[source]¶ Bases:
fsleyes.controls.controlpanel.ControlPanelThe
EditTransformPanelclass is a FSLeyes control panel which allows the user to adjust thevoxToWorldMatof anImageoverlay.Controls are provided allowing the user to construct a transformation matrix from scales, offsets, and rotations. While the user is adjusting the transformation, the
NiftiOpts.displayXformis used to update the overlay display in real time. When the user clicks the Apply button, the transformation is applied to the image’svoxToWorldMatattribute.This panel also has buttons which allow the user to load/save the transformation matrix - they use functions in the
applyflirtxfmandsaveflirtxfmmodules to load, save, and calculate transformation matrices. When the user loads a matrix, it is used in place of theImage.voxToWorldMattransformation.Note
The effect of editing the transformation will only be visible if the
DisplayContext.displaySpaceis set to'world', or to some image which is not being edited. A warning is shown at the top of the panel if thedisplaySpaceis not set appropriately.-
static
ignoreControl()[source]¶ Tells the FSLeyes plugin system not to add the
EditTransformPanelas an option to the FSLeyes settings menu. Instead, theEditTransformActionaction is added to the tools menu.
-
static
supportedViews()[source]¶ Overrides
ControlMixin.supportedViews(). TheEditTransformPanelis only intended to be added toOrthoPanelviews.
-
static
defaultLayout()[source]¶ Returns a dictionary of arguments to be passed to the
ViewPanel.togglePanel()method when anEditTransformPanelis created.
-
__init__(parent, overlayList, displayCtx, ortho)[source]¶ Create an
EditTransformPanel.- Parameters
parent – The
wxparent object.overlayList – The
OverlayListinstance.displayCtx – The
DisplayContextinstance.ortho – The
OrthoPanelinstance.
-
destroy()[source]¶ Must be called when this
EditTransformPanelis no longer needed. Removes listeners and cleans up references.
-
__registerOverlay(overlay)¶ Called by
__selectedOverlayChanged(). Stores a reference to the givenoverlay.
-
__deregisterOverlay()¶ Called by
__selectedOverlayChanged(). Clears references to the most recently registered overlay.
-
__overlayNameChanged(*a)¶ Called when the
Display.nameof the currently selected overlay changes. Updates the name label.
-
__selectedOverlayChanged(*a)¶ Called when the
DisplayContext.selectedOverlayorOverlayList.overlaysproperties change. If the newly selected overlay is anImage, it is registered, and the transform widgets reset.
-
__formatXform(xform, ctrl)¶ Format the given
xformon the givenwx.StaticTextctrl.
-
__getCurrentXformComponents()¶ Returns the components of the transformation matrix defined by the scale, offset and rotation widgets.
-
__getCurrentXform()¶ Returns the current transformation matrix defined by the scale, offset, and rotation widgets.
-
__xformChanged(ev=None)¶ Called when any of the scale, offset, or rotate widgets are modified. Updates the
NiftiOpts.displayXformfor the overlay currently being edited.
-
__onApply(ev)¶ Called when the Apply button is pushed. Sets the
voxToWorldMatattribute of theImageinstance being transformed.
-
__resetAllOverlays()¶ Resets the
NiftiOpts.displayXformmatrix for all overlays that have been modified, and clears the internal transformation matrix cache.This method is called by
__onReset()and__onCancel().
-
__onReset(ev=None)¶ Called when the Reset button is pushed. Resets the transformation.
-
__onLoadFlirt(ev)¶ Called when the user clicks the Load FLIRT transform button. Prompts the user to choose a FLIRT transformation matrix and reference image, and then applies the transformation.
-
__onSaveFlirt(ev)¶ Called when the user clicks the Save FLIRT button. Saves the current transformation to a FLIRT matrix file.
-
__onCancel(ev=None)¶ Called when the Cancel button is pushed. Resets the
NiftiOpts.displayXformattribute of the overlay being transformed, and then callsOrthoPanel.toggleEditTransformPanel()to close this panel.
-
__module__= 'fsleyes.plugins.tools.edittransform'¶
-
static