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 anOrthoPanel
, with the associatedCropImageProfile
. It contains controls allowing the user to define a cropping box for the currently selected overlay (if it is anImage
), and “Crop”, “Load”, “Save”, and “Cancel” buttons.-
__init__
(parent, overlayList, displayCtx, frame, ortho)¶ Create a
CropImagePanel
.- Parameters
parent – The
wx
parent object.overlayList – The
OverlayList
instance.displayCtx – The
DisplayContext
instance.frame – The
FSLeyesFrame
instance.ortho – The
OrthoPanel
instance.
-
destroy
()¶ Must be called when this
CropImagePanel
is no longer needed. Removes property listeners and clears references.
-
static
supportedViews
()¶ Overrides
ControlMixin.supportedViews()
. TheCropImagePanel
is only intended to be added toOrthoPanel
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 thisCropImagePanel
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 tofslroi
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.