fsleyes.controls.cropimagepanel

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.controls.cropimagepanel.CropImagePanel(parent, overlayList, displayCtx, frame, ortho)

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.

__init__(parent, overlayList, displayCtx, frame, ortho)

Create a CropImagePanel.

Parameters
destroy()

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

static supportedViews()

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

_CropImagePanel__cropBoxChanged(*a)

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

_CropImagePanel__deregisterOverlay()

Called by __selectedOverlayChanged(). Deregisters the current overlay.

_CropImagePanel__onCancel(ev=None)

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

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

_CropImagePanel__onCrop(ev)

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

_CropImagePanel__onLoad(ev)

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

_CropImagePanel__onSave(ev)

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

_CropImagePanel__onVolume(ev)

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

_CropImagePanel__overlayNameChanged(*a)

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

_CropImagePanel__registerOverlay(overlay)

Called by __selectedOverlayChanged(). Registers the given overlay.

_CropImagePanel__selectedOverlayChanged(*a)

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

_CropImagePanel__updateSizeLabel()

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

__module__ = 'fsleyes.controls.cropimagepanel'
fsleyes.controls.cropimagepanel.loadCropParameters(filename, overlay)

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.