Image Models

ImageModel

class datavis.models.ImageModel(data=None, location=None)

Base model class that represents 2D or 3D image binary data.

This model is used by several views to display 2D images such as: micrographs, particles, averages or volume 2D slices. It provides access methods to enable visualization of the underlying data.

__init__(data=None, location=None)

Create a new ImageModel, optionally providing data array or location.

Parameters
  • data – An initial numpy array can be provided.

  • location – (index, path) tuple representing the location of the data.

getData()

Return a 2D array-like object (e.g numpy array) containing the image data.

getDim()

Return the dimensions of the model as a tuple:

  • (x, y) for 2D.

  • (x, y, n) for 2D slices.

  • (x, y, z) for 3D volumes.

getLocation()

Return the (index, path) of the image file. It can be None if it does contains any associated location.

getMinMax()

Return the minimum and maximum values of the data (can be None).

setData(data)

Set new underlying data.

Parameters

data – Input 2D array-like object (e.g numpy array).

SlicesModel

class datavis.models.SlicesModel(data=None, location=None)

This model deals with N 2D arrays, usually a 3D volume or a stack of 2D images.

__init__(data=None, location=None)

Create a new ImageModel, optionally providing data array or location.

Parameters
  • data – An initial numpy array can be provided.

  • location – (index, path) tuple representing the location of the data.

getData(i=-1)

Return a 2D array of the slice data.

Parameters

i – Slice index, it should be -1 or in (0, n-1) range. -1 is a special case for returning the whole data array.

Returns

2D array of the requested slice.

getImageModel(i)

Creates an ImageModel representing the slice at index i.

Parameters

i – Slice index, it should be in (0, n-1) range.

Returns

A new ImageModel instance representing the given slice.

VolumeModel

class datavis.models.VolumeModel(data=None, location=None)

Model for 3D volume data.

Data represents a 3D array-like data array. 2D slices can be accessed through 3 axis: AXIS_X, AXIS_Y or AXIS_Z

__init__(data=None, location=None)

Create a new ImageModel, optionally providing data array or location.

Parameters
  • data – An initial numpy array can be provided.

  • location – (index, path) tuple representing the location of the data.

getSliceData(axis, i)

Return a 2D array of the slice data.

Parameters
  • axis – should be AXIS_X, AXIS_Y or AXIS_Z

  • i – should be in (0, axis_n -1).

Returns

2D array of the requested slice in the given axis.

getSliceImageModel(axis, i)

Return an ImageModel for the requested slice in the given axis.

Parameters
  • axis – should be AXIS_X, AXIS_Y or AXIS_Z

  • i – should be in (0, axis_n -1).

Returns

ImageModel instance of the requested slice in the given axis.

getSlicesModel(axis)

Creates a SlicesModel representing the data from a given axis:

Parameters

axis – Should be AXIS_X, AXIS_Y or AXIS_Z

Returns

A new SlicesModel instance.