fsleyes.plugins.tools.cropimage

This module provides the CropImagePanel class.

The CropImagePanel is a a FSLeyes control which is used in conjunction with the OrthoCropProfile, allowing the user to crop an image. This module also provides the standalone loadCropParameters() function, for loading cropping parameters from a file.

class fsleyes.plugins.tools.cropimage.CropImageAction(overlayList, displayCtx, ortho)[source]

Bases: fsleyes.actions.togglecontrolpanel.ToggleControlPanelAction

The CropImageAction just toggles a CropImagePanel. It is added under the FSLeyes Tools menu.

static supportedViews()[source]

The CropImageAction is restricted for use with OrthoPanel views.

__init__(overlayList, displayCtx, ortho)[source]

Create CropImageAction.

destroy()[source]

Called when the OrthoPanel that owns this action is closed. Clears references, removes listeners, and calls the base class destroy method.

__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.cropimage'
class fsleyes.plugins.tools.cropimage.CropImagePanel(parent, overlayList, displayCtx, ortho)[source]

Bases: fsleyes.controls.controlpanel.ControlPanel

The CropImagePanel class is a FSLeyes control for use in an OrthoPanel, with the associated CropImageProfile. It contains controls allowing the user to define a cropping box for the currently selected overlay (if it is an Image), and “Crop”, “Load”, “Save”, and “Cancel” buttons.

static supportedViews()[source]

Overrides ControlMixin.supportedViews(). The CropImagePanel is only intended to be added to OrthoPanel views.

static ignoreControl()[source]

Tells FSLeyes not to add the CropImagePanel as an option to the Settings menu. Instead, the CropImageAction is added as an option to the Tools menu.

static profileCls()[source]

Returns the OrthoCropProfile class, which needs to be activated in conjunction with the CropImagePanel.

static defaultLayout()[source]

Returns a dictionary containing layout settings to be passed to ViewPanel.togglePanel.

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

Create a CropImagePanel.

Parameters
destroy()[source]

Must be called when this CropImagePanel is no longer needed. Removes property listeners and clears references.

__registerOverlay(overlay)

Called by __selectedOverlayChanged(). Registers the given overlay.

__deregisterOverlay()

Called by __selectedOverlayChanged(). Deregisters the current overlay.

__overlayNameChanged(*a)

Called when the Display.name of the currently selected overlay changes. Updates the name label.

__selectedOverlayChanged(*a)

Called when the DisplayContext.selectedOverlay changes. Updates labels appropriately.

__updateSizeLabel()

Called by the crop region and volume widget event handlers. Updates a label which displays the current crop region size.

__cropBoxChanged(*a)

Called when the OrthoCropProfile.cropBox changes. Updates labels appropriately.

__onVolume(ev)

Called when the user changes the volume limit, for 4D images. Updates the label which displays the crop region size.

__onLoad(ev)

Called when the Save button is pushed. Prompts the user to select a file to load crop parameters from.

__onSave(ev)

Called when the Save button is pushed. Saves the current crop parameters to a text file.

__onCancel(ev=None)

Called when the Cancel button is pushed. Calls OrthoPanel.togglePanel() - this will result in this CropImagePanel being destroyed.

This method is also called programmatically from the __onCrop() method after the image is cropped.

__onCrop(ev)

Crops the selected image. This is done via a call to copyoverlay.copyImage(). Also calls __onCancel(), to finish cropping.

__module__ = 'fsleyes.plugins.tools.cropimage'
fsleyes.plugins.tools.cropimage.loadCropParameters(filename, overlay)[source]

Load in crop values from a text file assumed to contain fslroi- compatible parameters. Any parameters which may be passed to fslroi are accepted:

fslroi in out tmin tlen
fslroi in out xmin xlen ymin ylen zmin zlen
fslroi in out xmin xlen ymin ylen zmin zlen tmin tlen

Any of the len parameters may be equal to -1, in which case it is interpreted as continuing from the low index

Parameters
  • filename – File to load crop parameters from.

  • overlay – An Image which is the cropping target.

Returns

A sequence of lo, hi crop parameters.