dataObject

class itom.dataObject

dataObject([dims [, dtype=’uint8’[, continuous = 0][, data = valueOrSequence]]]) -> constructor to get a new dataObject.

Parameters :

dims : {List of Integer}, optional

‘dims’ is list indicating the size of each dimension, e.g. [2,3] is a matrix with 2 rows and 3 columns. If not given, an empty data object is created.

dtype : {str}, optional

‘dtype’ is the data type of each element, possible values: ‘int8’,’uint8’,...,’int32’,’uint32’,’float32’,’float64’,’complex64’,’complex128’

continuous : {str}, optional

‘continuous’ [0|1] defines whether the data block should be continuously allocated in memory [1] or in different smaller blocks [0] (recommended for huge matrices).

data : {str}, optional

‘data’ is a single value or a sequence with the same amount of values than the data object. The values from data will be assigned to the new data object (filled row by row).

Returns :

dataObject {dataObject} :

Notes

The itom.dataObject contains a n-dimensional matrix and corresponding meta-data. It has a direct c++-representation for the python-c++ interface. The n-dimensional matrix can have different element types. Recently the following types are supported:

  • Integer-type (int8, uint8, int16, uint16, int32, uint32),
  • Floating-type (float32, float64 (=> double)),
  • Complex-type (complex64 (2x float32), complex128 (2x float64)).

Warning ‘uint32’ is not fully openCV-compatible and hence causes instability!

In order to handle huge matrices, the data object can divide one matrix into subparts in memory. Each subpart (called matrix-plane) is two-dimensional and covers data of the last two dimensions. In c++-context each of these matrix-planes is of type cv::Mat_<type> and can be used with every operator given by the openCV-framework (version 2.3.1 or higher).

The dimensions of the matrix are structured descending. So if we assume to have a n-dimensional matrix A, where each dimension has its size s_i, the dimensions order is n, .., z, y, x and the corresponding sizes of A are [s_n, s_(n-1), s_(n-2), ..., s_y, s_x].

In order to make the data object compatible to continuously organized data structures, like numpy-arrays, it is also possible to have all matrix-planes in one data-block in memory (not recommended for huge matrices). Nevertheless, the indicated data structure with the two-dimensional sub-matrix-planes is still existing. The data organization is equal to the one of open-cv, hence, two-dimensional matrices are stored row-by-row (C-style)...

Deep Copy, Shallow Copy and ROI

It is possible to set a n-dimensional region of interest (ROI) to each matrix, the virtual dimensions, which will be delivered if the user asks for the matrix size. To avoid copy operations where possible a simple =_Operator will also make a shallow copy of the object. Shallow copies share the same data (elements and meta data) with the original object, hence manipulations of one object will affect the original object and all shallow copies.

The opposite a deep copy of a dataObject (by sourceObject.copy()) creates a complete mew matrix with own meta data object.

Example:

#Create an object 
dObj = dataObject([5, 10, 10], 'int8')

# Make a shallow copy 
dObjShallow = dObj 

# Make a shallow copy on ROI
dObjROI = dObj[1, :, :] 

# Set the value of element [1, 0, 0] to 0
dObj[1, 0, 0] = 0

# Make a deep copy of the dObjROI
dObjROICopy = dObjROI.copy()

# Set the value of dObjROICopy element [0, 0, 0] to 127 without effecting other objects
dObjROICopy[0, 0, 0] = 127

Constructor The function dataObject([dims [, dtype=’uint8’[, continuous = 0][, data = valueOrSequence]]]) creates a new itom-dataObject filled with undefined data. If no parameters are given, an uninitilized DataObject (dims = 0, no sizes) is created.

As second possibility you can also use the copy-constructor ‘dataObject(AnyArray)’, where AnyArray must be any array-like structure which is parsable by the numpy-interface.

Further static methods for object construction are dataObject.zeros(..), dataObject.ones(..), dataObject.rand(..), dataObject.randN(..) and dataObject.eye(..).

addToProtocol([newLine]) → Appends a protocol line to the protocol. ROIs are added automatically.
Parameters :

newLine : {str}

The text to be added to the protocol.

Notes

Appends a protocol line to the protocol. The current ROIs of the dataObject are added automatically. Also a new line is added automatically to the protocol. The content of the protocol can be addressed by ‘dataObject.tags[‘protocol’]’

adj() -> Adjugate all elements (inline)

Notes

doctodo

adjugate() → Return the adjugate, element-wise

Notes

doctodo

adjustROI()

Notes

doctodo

astype() → todo

Notes

doctodo

conj() → complex-conjugates all elements of this dataObject (inline).
Returns :doctodo :

Notes

Every value of this dataObject is replaced by its complex-conjugate value. If the data type of this dataObject is no complex data type, a TypeError is raised.

conjugate() → returns a copy of this dataObject where every element is complex-conjugated.
Returns :copy of this dataObject :

Notes

If the data type of this dataObject is no complex data type, a TypeError is raised.

copy(region_only=0) → todo
Parameters :regionOnly : {}, optional

Notes

doctodo

data() → prints the content of the dataObject in a readable form.

Notes

When calling this method, the complete content of the dataObject is printed to the standard output stream.

deleteTag(key) → Delete the tag specified by key.
Parameters :

key : {str}

the name of the tag to be deleted

Notes

Remove a tag from the tag space the tag space.

div() → a.div(b) returns element wise division of a./b and returns result
Parameters :doctodo :
Returns :doctodo :

Notes

doctodo

existTag(key) → return 1 if tag exists, else return 0.
Parameters :

key : {str}

the name of the tag

Returns :

checkExists : {bool}

Notes

Checks if a specific tag already exists and return the result as a boolean value.

static eye([dims[, dtype='uint8'[, continuous = 0]]]) → creates a 2D, square, eye-matrix.
Parameters :

size : {int},

the size of the square matrix (single value)

dtype : {str}, optional

‘dtype’ is the data type of each element, possible values: ‘int8’,’uint8’,...,’int32’,’uint32’,’float32’,’float64’,’complex64’,’complex128’

Returns :

The dataObject : {dataObject}

Notes

Static method for creating a two-dimensional, square, eye-matrix of type itom-dataObject.

getTagListSize() → returns the number of tags in tag map

Notes

doctodo

locateROI() → todo

Notes

locateROI returns a tuple with two elements. The first is a list with the original sizes of this matrix, the second is a list with the offset for each axe in order to get from the original first element to the first element in the given ROI

makeContinuous() → return continuous representation of dataObject (if not continuous yet, else returns shallow copy of original data object
Returns :doctodo :

Notes

doctodo

mul() → a.mul(b) returns element wise multiplication of a*b and returns result
Parameters :doctodo :

Notes

doctodo

name() → prints the content of the dataObject in a readable form.

Notes

doctodo

static ones([dims[, dtype='uint8'[, continuous = 0]]]) → creates new dataObject filled with ones.
Parameters :

dims : {List of Integer}

‘dims’ is list indicating the size of each dimension, e.g. [2,3] is a matrix with 2 rows and 3 columns

dtype : {str}, optional

‘dtype’ is the data type of each element, possible values: ‘int8’,’uint8’,...,’int32’,’float32’,’float64’,’complex64’,’complex128’

continuous : {str}, optional

‘continuous’ [0|1] defines whether the data block should be continuously allocated in memory [1] or in different smaller blocks [0] (recommended for huge matrices).

Returns :

The dataObject : {dataObject}

Notes

Creates a new itom-dataObject filled with ones.

static rand([dims[, dtype='uint8'[, continuous = 0]]]) → creates new dataObject filled with uniform distributed random values.
Parameters :

dims : {List of Integer}

‘dims’ is list indicating the size of each dimension, e.g. [2,3] is a matrix with 2 rows and 3 columns.

dtype : {str}, optional

‘dtype’ is the data type of each element, possible values: ‘int8’,’uint8’,...,’int32’,’float32’,’float64’,’complex64’,’complex128’

continuous : {str}, optional

‘continuous’ [0|1] defines whether the data block should be continuously allocated in memory [1] or in different smaller blocks [0] (recommended for huge matrices).

Returns :

The dataObject : {dataObject}

Notes

Creates a new itom-dataObject filled with uniform distributed random numbers. In case of an integer type, the uniform noise is from min<ObjectType>(inclusiv) to max<ObjectType>(inclusiv). For floating point types, the noise is between 0(inclusiv) and 1(exclusiv).

static randN([dims[, dtype='uint8'[, continuous = 0]]]) → creates new dataObject filled with gaussian distributed random values.
Parameters :

dims : {List of Integer}

‘dims’ is list indicating the size of each dimension, e.g. [2,3] is a matrix with 2 rows and 3 columns.

dtype : {str}, optional

‘dtype’ is the data type of each element, possible values: ‘int8’,’uint8’,...,’int32’, ‘float32’,’float64’,’complex64’,’complex128’

continuous : {str}, optional

‘continuous’ [0|1] defines whether the data block should be continuously allocated in memory [1] or in different smaller blocks [0] (recommended for huge matrices).

Returns :

The dataObject : {dataObject}

Notes

Creates a new itom-dataObject filled with gaussian distributed random numbers. In case of an integer type, the gausian noise mean value is (max+min)/2.0 and the standard deviation is (max-min/)6.0 to max. For floating point types, the noise mean value is 0 and the standard deviation is 1.0/3.0.

reshape(newSizes) → Returns reshaped shallow copy of data object
Returns :reshaped shallow copy of data object :

Notes

Not implemented yet.

setAxisDescription([axisNum[, axisDescription]]) → Set the description of the specified axis.
Parameters :

axisNum : {int}

The addressed axis

axisDescription : {str}

New axis description

Notes

Set the axis description (e.g. intensity) of axisNum

setAxisOffset([axisNum[, axisOffset]]) → Set the offset of the specified axis.
Parameters :

axisNum : {int}

The addressed axis

axisOffset : {double}

New axis offset in [px]

Notes

Set the axis offset in [px] of axisNum to axisOffset, Unit-Coordinate = ( px-Coordinate - Offset)* Scale

setAxisScale([axisNum[, axisScale]]) → Set the scale of the specified axis.
Parameters :

axisNum : {int}

The addressed axis

axisScale : {double}

New axis scale in [unit / px]

Notes

Set the axis scale in [unit / px] of axisNum to axisScale, Unit-Coordinate = ( px-Coordinate - Offset)* Scale

setAxisUnit([axisNum[, axisUnit]]) → Set the unit of the specified axis.
Parameters :

axisNum : {int}

The addressed axis

axisUnit : {str}

New axis unit

Notes

Set the axis unit (e.g. mm) of axisNum

setTag(key, tagvalue) → Set the value of tag specified by key.
Parameters :

key : {str}

the name of the tag to set

tagvalue : {str or double}

the new value of the tag, either string or double value

Notes

Set the value of a tag within the meta data tagspace. If tag does not exist, it is created. Do NOT use ‘special character’ within the tag key because they are not XML-save.

size([index]) → returns the size of this dataObject (tuple of the sizes in all dimensions or size in dimension indicated by optional value index).
Parameters :index : {PyDataObject}, optional

Notes

doctodo

squeeze() → returns a squeezed shallow copy (if possible) of this data object.
Returns :

ShallowCopy : {dataObject}

At least 2D or more object with all dimensions bigger than 1 expept the x/y-Dimension.

Notes

This method removes every dimension with size equal to 1. Take care, that none of the last two dimensions is considered by this squeeze-command. The squeezed return value is a shallow copy of the original dataObject and hence changes in its values will also change the original data set. (This command is equal to numpy.squeeze)

tolist() → returns nested list of content of data object

Notes

doctodo

trans() → returns transposed matrix
Returns :doctodo :

Notes

doctodo

static zeros([dims[, dtype='uint8'[, continuous = 0]]]) → creates new dataObject filled with zeros.
Parameters :

dims : {List of Integer}

‘dims’ is list indicating the size of each dimension, e.g. [2,3] is a matrix with 2 rows and 3 columns

dtype : {str}, optional

‘dtype’ is the data type of each element, possible values: ‘int8’,’uint8’,...,’int32’,’uint32’,’float32’,’float64’,’complex64’,’complex128’

continuous : {str}, optional

‘continuous’ [0|1] defines whether the data block should be continuously allocated in memory [1] or in different smaller blocks [0] (recommended for huge matrices).

Returns :

The dataObject : {dataObject}

Notes

Creates a new itom-dataObject filled with zeros.

axisDescriptions

tuple containing the axis descriptions.

This attribute gives access to the internal axis descriptions expressed as a tuple strings. One entry for each object dimensions is due. This tuple is readonly, but you can either set an entire new tuple or change specific elements using the method setAxisDescription(index,value)

setter: Tuple of double value with size equal object dims.

getter: Readonly tuple of double value with size equal object dims.

Notes

{tuple of str} : ReadWrite

axisOffsets

tuple containing the axis offsets [px].

This attribute gives access to the internal axis offsets [px] expressed as a tuple double values. One entry for each object dimensions is due. This tuple is readonly, but you can either set an entire new tuple or change specific elements using the method setAxisOffset(index,value).

Definition: Unit-Coordinate = ( px-Coordinate - Offset)* Scale setter: Tuple of double value with size equal object dims.

getter: Readonly tuple of double value with size equal object dims.

Notes

{tuple of double} : ReadWrite

axisScales

tuple containing the axis scales [unit/px].

This attribute gives access to the internal axis scales [unit/px] expressed as a tuple double values. One entry for each object dimensions is due. This tuple is readonly, but you can either set an entire new tuple or change specific elements using the method setAxisScale(index,value)

Definition: Unit-Coordinate = ( px-Coordinate - Offset)* Scale setter: Tuple of double value with size equal object dims. getter: Readonly tuple of double value with size equal object dims.

Notes

{tuple of double} : ReadWrite

axisUnits

tuple containing the axis units.

This attribute gives access to the internal axis units expressed as a tuple strings. One entry for each object dimensions is due. This tuple is readonly, but you can either set an entire new tuple or change

specific elements using the method setAxisUnit(index,value)

setter: Tuple of double value with size equal object dims.

getter: Readonly tuple of double value with size equal object dims.

Notes

{tuple of str} : ReadWrite

base

base object

continuous

true if matrix is continuously organized, else false. If matrix is continuously organized this function returns true, else false. If true, the whole matrix is allocated in one huge block in memory, hence, this data object can be transformed into a numpy representation (npDataObject) without reallocating memory. Notes —– {bool} : ReadOnly

dims

number of dimensions of this data object Notes —– {int} : ReadOnly

dtype

get type string of data in this data object This attribute returns the dataObject-Type as a string. This type string has one of these values: ‘uint8’, ‘int8’, ‘uint16’, ‘int16’, ‘uint32’, ‘int32’, ‘float32’, ‘float64’, ‘complex64’, ‘complex128’

Notes

{str} : ReadOnly

metaDict

new dictionary with all tags inside

Notes

{dict} : ReadOnly

tags

tag dictionary for this data object.

By this attribute you get access to the read-only tag dictionary or you can set an entire new dictionary. You can add single elements using the method setTag(key,value) or you can delete tags using deleteTag(key). The value of the tags can be either numeric or string values. Do NOT use ‘special character’ within the tag key because they are not XML-save. setter: The dataObject dictionary is filled with the entries in ‘newDictionary’. getter: A readonly dictionary with all Metadata-Tags of the dataObject.

Notes

{bool} : ReadWrite

value

get/set the values within the ROI as a one-dimensional tuple.

This method gets or sets the values within the ROI. If this attribute is called by means of a getter, a tuple is returned which is created by iterating through the values of the data object (row-wise). In the same way of iterating, the values are set to the data object if you provide a tuple of the size of the data object or its ROI, respectively.

Example

b = dataObject[1,1:10,1,1].value
# or for the first value 
b = dataObject[1,1:10,1,1].value[0]
# The elements of the tuple are adressed with b[idx].
valueDescription

value unit description.

Notes

{str} : ReadWrite

valueOffset

value offset [default: 0.0].

Notes

{float???} : ReadOnly

valueScale

value scale [default: 1.0].

Notes

{float???} : ReadWrite

valueUnit

value unit string.

Notes

{str} : ReadWrite

xyRotationalMatrix

Access the 3x3 rotational matrix in the dataObject tagspace

This attribute gives access to the xyRotationalMatrix in the metaData-Tagspace. The getter method retuns a 3x3-Array deepcopied from the internal matrix, Implemented to offer compability to x3p format.

Notes

{3x3 array of doubles} : ReadWrite

Previous topic

ui-elements (GUI)

Next topic

npDataObject

This Page