schrodinger.analysis.visanalysis.volumedata module

class schrodinger.analysis.visanalysis.volumedata.VolumeData(N=None, resolution=None, origin=None)

Bases: object

The VolumeData class is responsible for handling the underlying storage as well as marrying together the concepts of array-coordinates and world-coordinates. The class itself is a fairly simple aggregation of the Numpy array class (to handle the basic storage and provide a huge library of functionality) and the _VDCoordinateFrame class (to marry up the concept of array-coordinates and world-coordinates).

__init__(N=None, resolution=None, origin=None)

This function creates a new VolumeData object. The object represents a three-dimensional volume with the specified resolution, origin and dimensions.

The underlying _VDCoordinateFrame is exposed via the CoordinateFrame property.

Parameters
  • N (iterable) – The number of array-coordinates along the X, Y and Z axes respectively.

  • resolution (iterable) – The resolution of the X, Y and Z axes respectively. Specified in world-coordinate units

  • origin (iterable) – The origin of the X, Y and Z axes respectively. Specified in world-coordinates

property CoordinateFrame
IsCompatible(vd)

This function can be used to test whether vd is compatible with this VolumeData. Compatible VolumeData objects have compatible coordinate-frames.

Parameters

vd (VolumeData) – The volume-data to be tested for compatibility with this VolumeData

Returns

True if vd is compatible with this VolumeData

Return type

bool

ToArrayCoordinate(world)

Converts the specified world-coordinate to the corresponding array-coordinate.

Parameters

world (iterable) – The world-coordinate to be converted X, Y, Z

Returns

The array-coordinate corresponding to world. This need not be a valid array-coordinate

Return type

iterable

ToArrayCoordinateL(worldCoordinates)

Converts the specified set of world-coordinates to the corresponding array-coordinates.

Parameters

worldCoordinates (iterable) – The set of world-coordinates to be converted

Returns

The array-coordinates corresponding to worldCoordinates

Return type

iterable

ToWorldCoordinate(array)

Converts the specified array-coordinate to the corresponding world-coordinate.

Parameters

array (iterable) – The array-coordinate to be converted X, Y, Z

Returns

The world-coordinate corresponding to array

Return type

iterable

ToWorldCoordinateL(arrayCoordinates)

Converts the specified set of array-coordinates to the corresponding world-coordinates.

Parameters

arrayCoordinates (iterable) – The set of array-coordinates to be converted

Returns

The world-coordinates corresponding to arrayCoordinates

Return type

iterable

InBounds(world)

Tests whether the world-coordinate corresponds to a position that is within the bounds of the array-coordinates.

Parameters

world (iterable) – The world-coordinate to be tested X, Y, Z

Returns

True if the world-coordinate is in bounds.

Return type

bool

ArrayCoordinates()

This function returns an iterator which allows the array-coordinates corresponding to this VolumeData to be traversed. The order of the traversal is not specified. The de-referenced iterator provides an object of the form iterable< int, 3 >, the X, Y and Z array-coordinates.

Returns

Array-coordinate iterator.

Return type

iterator

getAllArrayCoordinates()

This function returns an object of the class iterable< iterable< int, 3 > >. This contains all of the valid array-coordinates. The ordering of entries in this object is guaranteed to be the same as that returned by self.getAllWorldCoordinates().

Returns

The array-coordinates

Return type

iterable

WorldCoordinates()

This function returns an iterator which allows the world-coordinates corresponding to this VolumeData to be traversed. The order of traversal is not specified. The de-referenced iterator provides an object of the form iterable< float, 3 >, the X, Y and Z world-coordinates.

Returns

World-coordinate iterator

Return type

iterator

getAllWorldCoordinates()

This function returns an object of the class iterable< iterable< float, 3 > >. This contains all of the world-coordinates. The ordering of entries in this object is guaranteed to be the same as that returned by self.getAllArrayCoordinates().

Returns

The world-coordinates

Return type

iterable

Coordinates()

This function returns an iterator which allows the array-coordinates and world-coordinates corresponding to this VolumeData to be traversed. The order of traversal is not specified. The de-referenced iterator returns an object of the form tuple< iterable< int, 3 >, iterable< float, 3 > >, the X, Y, Z coordinates of the array and world respectively.

Returns

Array and world-coordinate iterator

Return type

iterator

getData()

This function allows access to the underlying data. The object returned by this function may be used anywhere a Numpy array object would be used. This is the fastest method accessing values from this VolumeData object, however, the access is restricted to valid array-coordinates only.

Returns

The underlying volume-data

Return type

numpy.array

setData(data)

This function allows the underlying data to be set. The function makes a copy of data.

Parameters

data (numpy.array) – The data to be assigned to this VolumeData’s underlying data. The size of this three-dimensional array should be the same as this VolumeData

getAtArrayCoordinate(array, interpolationOrder=0, oobMethod='constant', oobConstant=0.0)

This function is used to retrieve values from this VolumeData object using array-coordinates. The function is capable of retrieving values at invalid array-coordinates using a mixture of interpolation and OOB-handling.

Parameters
  • array (iterable) – The array-coordinates to retrieve. Need not be valid array-coordinates

  • interpolationOrder (int) – The degree of interpolation to use when retrieving the values. 0-5

  • oobMethod (string) – What to do with requests that lie outside of the bounds of this VolumeData object. The options are “constant”, which returns the value of oobConstant. “nearest” which returns the value of the nearest valid point or “wrap”, which effectively tiles the data into an infinite repeating lattice.

  • oobConstant (float) – Of the class float. The value to return if the request is OOB and the oobMethod is “constant”

Returns

The value stored at the requested array-coordinate

Return type

float

getAtArrayCoordinateL(arrayCoordinates, interpolationOrder=0, oobMethod='constant', oobConstant=0.0)

This function can be used to retrieve a large number of values at specified array-coordinates. It is similar to the getAtArrayCoordinate function, however, in this case the array-coordinates are specified as a list rather than a single coordinate.

Parameters
  • arrayCoordinates (iterable) – The array-coordinates whose values are to be retrieved

  • interpolationOrder (int) – The degree of interpolation to use when retrieving the values. 0-5

  • oobMethod (string) – What to do with requests that lie outside of the bounds of this VolumeData object. The options are “constant”, which returns the value of oobConstant. “nearest” which returns the value of the nearest valid point or “wrap”, which effectively tiles the data into an infinite repeating lattice.

  • oobConstant (float) – Of the class float. The value to return if the request is OOB and the oobMethod is “constant”

Returns

The value stored at the requested array-coordinates. The values are returned in an order that is equivalent to arrayCoordinates

Return type

iterable

getAtWorldCoordinate(world, interpolationOrder=0, oobMethod='constant', oobConstant=0.0)

This function is used to retrieve values from this VolumeData object using world-coordinates. The function is capable of retrieving values at any world-coordinate using a mixture of interpolation and OOB-handling

Parameters
  • world (iterable) – The world-coordinates to retrieve

  • interpolationOrder (int) – The degree of interpolation to use when retrieving the values. 0-5

  • oobMethod (string) – What to do with requests that lie outside of the bounds of this VolumeData object. The options are “constant”, which returns the value of oobConstant. “nearest” which returns the value of the nearest valid point or “wrap”, which effectively tiles the data into an infinite repeating lattice.

  • oobConstant (float) – Of the class float. The value to return if the request is OOB and the oobMethod is “constant”

Returns

The value stored at the requested world-coordinate

Return type

float

getAtWorldCoordinateL(worldCoordinates, interpolationOrder=0, oobMethod='constant', oobConstant=0.0)

This function can be used to retrieve a large number of values at specified world-coordinates. It is similar to the getAtWorldCoordinate function, however, in this case the world-coordinates are specified as a list rather than a single coordinate.

Parameters
  • worldCoordinates (iterable) – The world-coordinates whose values are to be retrieved

  • interpolationOrder (int) – The degree of interpolation to use when retrieving the values. 0-5

  • oobMethod (string) – What to do with requests that lie outside of the bounds of this VolumeData object. The options are “constant”, which returns the value of oobConstant. “nearest” which returns the value of the nearest valid point or “wrap”, which effectively tiles the data into an infinite repeating lattice.

  • oobConstant (float) – Of the class float. The value to return if the request is OOB and the oobMethod is “constant”

Returns

The value stored at the requested world-coordinates. The values are returned in an order that is equivalent to worldCoordinates

Return type

iterable