fsleyes.actions.newimage
This module provides the NewImageAction
class, an Action
which allows the user to create a new empty Image
overlay.
- class fsleyes.actions.newimage.NewImageAction(overlayList, displayCtx, frame)[source]
Bases:
fsleyes.actions.base.Action
The
NewImageAction
class allows the user to create a newImage
. When invoked, it displays aNewImageDialog
prompting the user to select the properties of the new image, and then creates a new image accordingly.- __init__(overlayList, displayCtx, frame)[source]
Create a
CopyOverlayAction
.- Parameters
overlayList – The
OverlayList
.displayCtx – The
DisplayContext
.frame – The
FSLeyesFrame
.
- __newImage()
Displays a
NewImageDialog
, then creates a newImage
, and adds it to theOverlayList
.If the currently selected overlay is a
Nifti
, theNewImageDialog
is initialised to the properties of the selected overlay.
- __annotations__ = {}
- __module__ = 'fsleyes.actions.newimage'
- fsleyes.actions.newimage.newImage(shape, pixdim, dtype, affine, xyzUnits=<MagicMock name='mock.data.constants.NIFTI_UNITS_MM' id='140112332272208'>, timeUnits=<MagicMock name='mock.data.constants.NIFTI_UNITS_SEC' id='140112332266832'>, name='new')[source]
Create a new
Image
with the specified properties.- Parameters
shape – Tuple containing the image shape
pixdim – Tuple containing the image pixdims
dtype –
numpy
dtype
affine –
(4, 4)
numpy
array specifying the voxel-to-world affinexyzUnits – Spatial units
timeUnits – Temporal units
- class fsleyes.actions.newimage.NewImageDialog(parent, shape, pixdim, affine, dtype)[source]
Bases:
__main__.docbuilder.run.<locals>.MockClass
The
NewImageDialog
displays a collection of widgets allowing the user to select the data type, shape, dimensions (pixdims), and voxel-to- world affine.- __init__(parent, shape, pixdim, affine, dtype)[source]
Create a
NewImageDialog
.- Parameters
parent –
wx
parent objectshape – Tuple of three initial shape values
pixdim – Tuple of three initial pixdim values
affine – Initial affine, assumed to be a
(4, 4)
numpy
arraydtype – Initial
numpy
dtype. Must be one offloat32
,float64
,uint8
,int16
, orint32
.
- __onLink(ev)
Called when the link checkbox changes. If linking is enabled, calls
__onAffine()
.
- __onPixdim(ev)
Called when any pixdim widget changes. If linking is enabled, reconstructs the affine with the new pixdim values.
- __onAffine(ev)
Called when the affine changes. If linking is enabled, updates the pixdim values from the new affine.
- property linkWidget
Return a reference to the link widget.
- property shapeWidgets
Return a reference to the three shape widgets.
- property pixdimWidgets
Return a reference to the three pixdim widgets.
- property dtypeWidget
Return a reference to the dtype widget.
- property affineWidget
Return a reference to the affine widget.
- property ok
Return a reference to the ok button.
- property cancel
Return a reference to the cancel button.
- property link
Return a tuple containing the current affine-dimension link checkbox value.
- property shape
Return a tuple containing the current shape values.
- property pixdim
Return a tuple containing the current pixdim values.
- property dtype
Return the currently selected data type, as a
numpy.dtype
.
- __annotations__ = {}
- __module__ = 'fsleyes.actions.newimage'
- property affine
Return the current content of the affine grid, as a
numpy
array of shape(4, 4)
.