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 new Image. When invoked, it displays a NewImageDialog 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
__newImage()

Displays a NewImageDialog, then creates a new Image, and adds it to the OverlayList.

If the currently selected overlay is a Nifti, the NewImageDialog 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='139907480299040'>, timeUnits=<MagicMock name='mock.data.constants.NIFTI_UNITS_SEC' id='139907480818288'>, name='new')[source]

Create a new Image with the specified properties.

Parameters
  • shape – Tuple containing the image shape

  • pixdim – Tuple containing the image pixdims

  • dtypenumpy dtype

  • affine(4, 4) numpy array specifying the voxel-to-world affine

  • xyzUnits – 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
  • parentwx parent object

  • shape – Tuple of three initial shape values

  • pixdim – Tuple of three initial pixdim values

  • affine – Initial affine, assumed to be a (4, 4) numpy array

  • dtype – Initial numpy dtype. Must be one of float32, float64, uint8, int16, or int32.

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.

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).