PYME.DSView.arrayViewPanel module

class PYME.DSView.arrayViewPanel.ArrayViewPanel(parent, dstack=None, aspect=1, do=None, voxelsize=None, initial_overlays=[(<class 'PYME.DSView.overlays.ScaleBarOverlay'>, 'Scale Bar'), (<class 'PYME.DSView.overlays.CrosshairsOverlay'>, 'Crosshairs')])

Bases: ScrolledImagePanel

Parameters
parentwx.window

The windows parent

dstacknp.ndarray like object (usually and XYZTCDataSource or subclass), optional

The data to display, ignored if do is specified

dodisplayOptions.DisplayOpts instance, optional

The display settings (gain, scale, colour LUTs etc …). If provided, the dstack parameter is ignored and the data associated with the display settings is used. If not provided a new DisplayOpts instance is created for the passed dstack.

voxelsizePYME.IO.MetaDataHandler.VoxelSize instance, or callable

voxel size in nm. (x, y, z). Specififying a callable here which retuns the image voxelsize rather than the current value at initialisation allows changes to the voxelsize to propagate here if metadata voxelsize is changed.

initial_overlayslist

A list of tuples, [(OverlayClass, display_name)] for overlays to add at initialisation. Overlays can also be added later using the add_overlay() method.

CopyImage(fullImage=True)

Copies the currently displayed image to the clipboard

ExportStackToPNG(filename, fullImage=True)

Save current view to a series of PNG files with z (or t) index as suffix, suitable for use in making a movie via ffmpeg or similar tools

Parameters
filenamestr

fully qualified path, with extension. Note that _%d will be appended to the filename to generate the individual files

fullImagebool, optional

whether to export the full image even if it is clipped in the GUI, by default True

FIXME - make this work with time series / 5D image data model.
GrabImage(fullImage=True)
GrabPNG(filename, fullImage=True)
GrabPNGToBuffer(fullImage=True)

Get PNG data in a buffer (rather than writing directly to file)

Redraw(sender=None, **kwargs)
ResetDataStack(ds)

Make this viewer point at a new data source, whilst keeping all the display options constant / unchanged

SetDataStack(ds)

Make this viewer point at a new data source, resetting all the view options (the viewer will behave as though the new data set was cleanly loaded)

add_overlay(ovl, display_name=None)

Add an overlay.

The overlay should ideally be an object derived from overlays.Overlay and follow the instance outlined in that class, function overlays are also supported in the interim for backwards compatibility.

If using a functional overlay, a display_name must be provided

Parameters
ovloverlays.Overlay instance, optionaly a function or method

The overlay code

display_namestring

a name to use when controlling overlay visibility. Must be provided for function overlays, ignored for instances of the Overlay class (which have a display_name property)

draw_box_pixel_coords(dc, x, y, z, w, h, d)

Draws a box on a given device contect (dc) given 3D co-ordinates in image pixel space.

Usually called from overlays. NOTE: the dc should be the same one that is passed TO the overlay, and which comes from our OnPaint handler, not any arbitrary device context.

draw_cross_pixel_coords(dc, x, y, z, w, h, d)

Draws a cross on a given device contect (dc) given 3D co-ordinates in image pixel space.

Usually called from overlays. NOTE: the dc should be the same one that is passed TO the overlay, and which comes from our OnPaint handler, not any arbitrary device context.

pixel_to_screen_coordinates(x, y)

Return the screen coordinates for a given pixel coordinate, taking view scaling and translation into account

Useful in overlays, etc … to position them correctly on the screen

NOTE: this assumes that slicing has already been accounted for - code calling this should be slice aware, or use pixel_to_screen_coordinates3D() instead

Parameters
xfloat, or np.ndarray

x position(s) in units of image pixels

yfloat, or np.ndarray

y position(s) in units of image pixels

Returns
xfloat or np.ndarray

x position(s) in device context (drawing) coordinates

yfloat or np.ndarray

y position(s) in device context (drawing) coordinates

pixel_to_screen_coordinates3D(x, y, z)

Return the screen coordinates for a given pixel coordinate, taking view scaling, translation and slicing into account

Useful in overlays, etc … to position them correctly on the screen

TODO: change this to a 5D data model with t as well (when we add, e.g. x-t slicing)

Parameters
xfloat, or np.ndarray

x position(s) in units of image pixels

yfloat, or np.ndarray

y position(s) in units of image pixels

zfloat, or np.ndarray

z position(s) in units of image pixels

Returns
xfloat or np.ndarray

x position(s) in device context (drawing) coordinates

yfloat or np.ndarray

y position(s) in device context (drawing) coordinates

property scale

The scaling between image pixels and display pixels

NOTE: this is linear, DisplayOptions.scale is log2(this)

property visible_bounds

The currently visible bounds of the image, in image pixel coordinates [x, y, z, t]

Used to avoid drawing overlays in regions of the image which are not shown.

TODO - make 4D (when we add xt etc …. slicing). Overlays (and especially those in plugins) should be written so they will also work if this method retuns a 4-tuple, [x,y,z,t]

property voxelsize
PYME.DSView.arrayViewPanel.getLUT(cmap)