MeVisLab Scripting Reference
MLABImageField Class Reference
Inheritance diagram for MLABImageField:
MLABField

Public Slots

Scripting access.


quint64 usedPages ()
 
quint64 usedMemImg ()
 
void clearPages ()
 
void clearMemImg ()
 
void clear ()
 
bool isValid ()
 
int sizeX ()
 
int sizeY ()
 
int sizeZ ()
 
int sizeC ()
 
int sizeT ()
 
int sizeU ()
 
QVariantList size3D ()
 
QVariantList size6D ()
 
const char * dataType ()
 
QVariantList worldToVoxelMatrix ()
 
SbMatrixd worldToVoxelMatrixInventor ()
 
QVariantList voxelToWorldMatrix ()
 
SbMatrixd voxelToWorldMatrixInventor ()
 
QVariantList pageSize6D ()
 
double voxelSizeX ()
 
double voxelSizeY ()
 
double voxelSizeZ ()
 
QVariantList voxelSize ()
 
double voxelVolumeInCubicMillimeters ()
 
double voxelVolumeInMilliliters ()
 
QVariantList mapWorldToVoxel (const QVariantList &vector)
 
SbVec3d mapWorldToVoxel (const SbVec3d &vector)
 
QVariantList mapVoxelToWorld (const QVariantList &vector)
 
SbVec3d mapVoxelToWorld (const SbVec3d &vector)
 
double minValue ()
 
double maxValue ()
 
DICOM Tag access.


QString getDicomTagValueByName (const QString &name)
 
QString getDicomTagValueByKey (const QString &name)
 
QMap< QString, QVariant > getDicomTagByName (const QString &name)
 
QMap< QString, QVariant > getDicomTagByKey (const QString &name)
 
MLABDicomTreegetDicomTree ()
 
MLABDicomTaggetFrameSpecificDicomTag (const QString &name, int z, int t=0, int u=0)
 
MLABDicomTaggetFrameSpecificDicomTagById (int group, int element, int z, int t=0, int u=0)
 
MLABDicomTaggetSharedDicomTag (const QString &name)
 
MLABDicomTaggetSharedDicomTagById (int group, int element)
 
MLPagedImageWrapperimage ()
 
QObject * object ()
 
- Public Slots inherited from MLABField
bool isInventorField ()
 
bool isMLField ()
 
QString getType () const
 
QString getName () const
 
virtual QString stringValue ()
 
virtual QString persistentStringValue ()
 
virtual void setPersistentStringValue (const QString &value)
 
QString truncatedStringValue (int maxChars=80)
 
MLABFieldOwnerowner ()
 
MLABFieldconnectedField ()
 
MLABFieldinputField ()
 
bool isConnected ()
 
bool isConnectedToFieldInSameNetwork ()
 
int outputCount ()
 
MLABFieldoutputField (int index)
 
QList< MLABField * > outputFields ()
 
bool connectFrom (MLABField *field)
 
void disconnect ()
 
void disconnectOutputs ()
 
void disconnectAll ()
 
bool connectFromUndoable (MLABField *field)
 
void disconnectUndoable ()
 
void disconnectOutputsUndoable ()
 
void disconnectAllUndoable ()
 
virtual bool isConnectionPossible (MLABField *field)
 
bool isConnectionInSameNetworkPossible (MLABField *field)
 
bool isInSameNetwork (MLABField *field)
 
virtual QString toolTipInfo ()
 
void setPriority (int aPriority)
 
int priority ()
 
void setProxy (bool flag)
 
bool isProxy ()
 
void setComment (const QString &comment)
 
QString comment ()
 
void setTitle (const QString &title)
 
QString title ()
 
QString fullName () const
 
bool isHidden ()
 
void setHidden (bool flag)
 
bool isIgnored ()
 
void setIgnored (bool flag)
 
bool isFilePath ()
 
void setIsFilePath (bool flag)
 
bool isInterfaceField ()
 
bool isParameterField ()
 
bool isInput ()
 
bool isOutput ()
 
bool isInOut ()
 
QString infoString ()
 
bool isPersistent () const
 
bool isEditable () const
 
bool triggersLoading () const
 
void setTriggersLoading (bool flag)
 

Signals

void valueChanged ()
 

Public Member Functions

void setStringValue (const QString &) override
 
QString stringValueForProfiling () override
 
void touch () override
 

Detailed Description

A field containing an image.

This field offers various methods to access the image size, type, voxel size, and to map between world and voxel coordinates.

Internally this field contains a ML Input/OutputConnector or SoSFMLImage. It can also be a proxy field which forwards all calls to the internal image fields of a MacroModule and does some special things in connect and disconnect (connecting ML to Inventor Fields via multiple proxies etc.).

Member Function Documentation

◆ clear

void MLABImageField::clear ( )
slot

Clears all ML memory.

◆ clearMemImg

void MLABImageField::clearMemImg ( )
slot

Clears ML memory for memory images.

◆ clearPages

void MLABImageField::clearPages ( )
slot

Clears ML memory for paged images.

◆ dataType

const char* MLABImageField::dataType ( )
slot

Returns the data type as a string (as in mlDataTypes.h MLNameFromDataType()), undefined if the image is invalid.

◆ getDicomTagByKey

QMap<QString, QVariant> MLABImageField::getDicomTagByKey ( const QString &  name)
slot

Returns a map that contains information on the tag.

(See getDicomTagByName()) for details.)

◆ getDicomTagByName

QMap<QString, QVariant> MLABImageField::getDicomTagByName ( const QString &  name)
slot

Returns a map that contains information about the tag.

The tag is returned as a dictionary with the following keys: If the "valid" key is set to "1", the tag was found and the following keys are set:

  • valid = (0 or 1, depending if tag was set)
  • vr = Value Representation (two uppercase letters)
  • stringValue = the string value of the tag
  • isString = if the tag is a string tag
  • isNumeric = if the tag is numeric (then values will be set)
  • isInteger = if the tag has integer values
  • value = contains the first numeric value of the tag if isNumeric is true, the stringValue otherwise
  • values = contains the numeric values of the tag if isNumeric is true, not set otherwise

Example:

f = ctx.field("somemodule.output0")
tag = f.getDicomTagByName("PatientName")
if tag["valid"]:
MLAB.log(f'PatientName is {tag["stringValue"]}')
# numeric tags
tag = f.getDicomTagByName("SliceThickness")
if tag["valid"]:
MLAB.log(f'SliceThickness is {tag["value"]}')
# multi value tag
tag = f.getDicomTagByName("ImagePositionPatient")
if tag["valid"]:
MLAB.log(f'ImagePositionPatient is {tag["values"]}')
Access to all global functions and objects of MLAB.
Definition: mlabGlobalScriptAccess.h:81
void log(const QString &text)
Logs the given text to the console.

This is a legacy interface and it is probably easier to call MLABDicomTree::getTag() on the return value of getDicomTree().

◆ getDicomTagValueByKey

QString MLABImageField::getDicomTagValueByKey ( const QString &  name)
slot

Returns the string value of a DICOM tag, name is given as key (group,element) with AT naming conventions.

Example:

f = ctx.field("somemodule.output0")
value = f.getDicomTagValueByKey("(0008,0081)")

◆ getDicomTagValueByName

QString MLABImageField::getDicomTagValueByName ( const QString &  name)
slot

Returns the string value of a DICOM tag.

Example:

f = ctx.field("somemodule.output0")
value = f.getDicomTagValueByKey("PatientsName")

◆ getDicomTree

MLABDicomTree* MLABImageField::getDicomTree ( )
slot

Returns the DICOM tree of the current image (or NULL if not existing).

◆ getFrameSpecificDicomTag

MLABDicomTag* MLABImageField::getFrameSpecificDicomTag ( const QString &  name,
int  z,
int  t = 0,
int  u = 0 
)
slot

Returns the DICOM tag specific for the given slice (by name).

This might also return tags from within the PerFrameFunctionalGroupsSequence of enhanced multi-frame DICOM data.

◆ getFrameSpecificDicomTagById

MLABDicomTag* MLABImageField::getFrameSpecificDicomTagById ( int  group,
int  element,
int  z,
int  t = 0,
int  u = 0 
)
slot

Returns the DICOM tag specific for the given slice (by group and element ID).

This might also return tags from within the PerFrameFunctionalGroupsSequence of enhanced multi-frame DICOM data.

◆ getSharedDicomTag

MLABDicomTag* MLABImageField::getSharedDicomTag ( const QString &  name)
slot

Returns a DICOM tag shared by all slices (by name).

This might also return tags from within the SharedFunctionalGroupsSequence of enhanced multi-frame DICOM data.

◆ getSharedDicomTagById

MLABDicomTag* MLABImageField::getSharedDicomTagById ( int  group,
int  element 
)
slot

Returns a DICOM tag shared by all slices (by group and element ID).

This might also return tags from within the SharedFunctionalGroupsSequence of enhanced multi-frame DICOM data.

◆ image

MLPagedImageWrapper* MLABImageField::image ( )
slot

Get access to the extended ML image API (the returned object is either a MLPagedImageWrapper or NULL).

This method only returns an image if the underlying ML image is a valid image (in case of handleInput() redirection, this might also be a DummyImage, you can detect this with isGlobalDummyImage(). NOTE: The returned object is automatically set to NULL when the input image changes, thus you should not keep a reference to it in Python, instead ask this field for image() whenever you need access to the image.

◆ isValid

bool MLABImageField::isValid ( )
slot

Returns whether there is a valid image available.

◆ mapVoxelToWorld [1/2]

QVariantList MLABImageField::mapVoxelToWorld ( const QVariantList &  vector)
slot

Maps the vector from voxel to world coordinates of the current image.

Parameters
vectoris set as an array with three double values.
Returns
is an array with three double values.

◆ mapVoxelToWorld [2/2]

SbVec3d MLABImageField::mapVoxelToWorld ( const SbVec3d &  vector)
slot

The same for the Inventor vector type SbVec3d.

◆ mapWorldToVoxel [1/2]

QVariantList MLABImageField::mapWorldToVoxel ( const QVariantList &  vector)
slot

Maps the vector from world to voxel coordinates of the current image.

Parameters
vectoris set as an array with three double values.
Returns
is an array with three double values.

Scripting example:

vector = ctx.field("input0").size3D()
result = ctx.field("input0").mapVoxelToWorld(vector)
for i in range(0,3):
MLAB.log(i + ":" + result[i])

◆ mapWorldToVoxel [2/2]

SbVec3d MLABImageField::mapWorldToVoxel ( const SbVec3d &  vector)
slot

The same for the Inventor vector type SbVec3d.

Use this import to use SbVec3d:

from Inventor.base import SbVec3d

◆ maxValue

double MLABImageField::maxValue ( )
slot

Returns the max value of the image (may not be the real max value of the data).

◆ minValue

double MLABImageField::minValue ( )
slot

Returns the min value of the image (may not be the real min value of the data).

◆ object

QObject* MLABImageField::object ( )
inlineslot

See image().

◆ pageSize6D

QVariantList MLABImageField::pageSize6D ( )
slot

Returns the page size.

◆ setStringValue()

void MLABImageField::setStringValue ( const QString &  )
inlineoverridevirtual

Sets the value of the field as a string value.

Reimplemented from MLABField.

◆ size3D

QVariantList MLABImageField::size3D ( )
slot

Returns the size as an array with 3 int values.

Scripting example:

size = ctx.field("input0").size3D()
MLAB.log("x " + size[0] + " y " + size[1] + " z " + size[2])

◆ size6D

QVariantList MLABImageField::size6D ( )
slot

Returns the size as an array with 6 int values.

Scripting example:

size = ctx.field("input0").size6D()
for i in range(0,6):
MLAB.log(i + ":" + size[i])

◆ sizeC

int MLABImageField::sizeC ( )
slot

Returns the c size in voxels.

◆ sizeT

int MLABImageField::sizeT ( )
slot

Returns the t size in voxels.

◆ sizeU

int MLABImageField::sizeU ( )
slot

Returns the u size in voxels.

◆ sizeX

int MLABImageField::sizeX ( )
slot

Returns the x size in voxels.

◆ sizeY

int MLABImageField::sizeY ( )
slot

Returns the y size in voxels.

◆ sizeZ

int MLABImageField::sizeZ ( )
slot

Returns the z size in voxels.

◆ stringValueForProfiling()

QString MLABImageField::stringValueForProfiling ( )
inlineoverridevirtual

Returns the string value used for profiling, default returns the string value.

NOTE: be careful on how you re-implement this method in subclasses, since we don't want the profiling to cause side effects, e.g. changing the state of an ML image.

Reimplemented from MLABField.

◆ touch()

void MLABImageField::touch ( )
overridevirtual

Forces a notify to all observers without changing the value of the field.

Reimplemented from MLABField.

◆ usedMemImg

quint64 MLABImageField::usedMemImg ( )
slot

Returns bytes used for a memory image.

◆ usedPages

quint64 MLABImageField::usedPages ( )
slot

Returns bytes used for a paged image.

◆ valueChanged

void MLABImageField::valueChanged ( )
signal

Signal that is emitted when the field's value changes.

◆ voxelSize

QVariantList MLABImageField::voxelSize ( )
slot

Returns the voxel size as an array with 3 double values.

Scripting example:

vsize = ctx.field("input0").voxelSize()
for i in range(0,3):
MLAB.log(i + ":" + vsize[i])

◆ voxelSizeX

double MLABImageField::voxelSizeX ( )
slot

Returns the x voxel size.

◆ voxelSizeY

double MLABImageField::voxelSizeY ( )
slot

Returns the y voxel size.

◆ voxelSizeZ

double MLABImageField::voxelSizeZ ( )
slot

Returns the z voxel size.

◆ voxelToWorldMatrix

QVariantList MLABImageField::voxelToWorldMatrix ( )
slot

Returns the voxel-to-world matrix (as [][] array).

◆ voxelToWorldMatrixInventor

SbMatrixd MLABImageField::voxelToWorldMatrixInventor ( )
slot

Returns the voxel-to-world matrix as Inventor array.

◆ voxelVolumeInCubicMillimeters

double MLABImageField::voxelVolumeInCubicMillimeters ( )
slot

Returns the volume of a single voxel in cubic millimeters (mm3).

This returns the correct volume for sheared datasets and calculates fabs( inImg->getVoxelToWorldMatrix().det() ).

◆ voxelVolumeInMilliliters

double MLABImageField::voxelVolumeInMilliliters ( )
slot

Returns the volume of a single voxel in milliliters (ml).

This returns the correct volume for sheared datasets and calculates fabs( inImg->getVoxelToWorldMatrix().det() ) / 1000.

◆ worldToVoxelMatrix

QVariantList MLABImageField::worldToVoxelMatrix ( )
slot

Returns the world-to-voxel matrix (as [][] array).

◆ worldToVoxelMatrixInventor

SbMatrixd MLABImageField::worldToVoxelMatrixInventor ( )
slot

Returns the world-to-voxel matrix as Inventor array.