MPR

MLModule
genre Resample
status stable
author Florian Link
package MeVisLab/Standard
dll MLResample1
definition MLResample1.def
see also MPRPath, OrthoMPR, Reformat

Purpose

The module MPR calculates a multiplanar reformatted image from its input image.

The reformatting requires sampling of the input image, which can be done with different filters. The MPR is optimized (using fixpoint arithmetic) for int8 and int16 types, but has a fallback implementation for the other basic datatypes.

Depending on the Memory Access mode, it uses different strategies to access the input image.

Usage

The MPR outputs a reformatted slice (or a slice stack if the Output Depth parameter is != 1) that is defined by its center world position (Translation) and a Rotation.

The edge length of the reformatted output slices is given by the Field Of View parameter (in mm), the resolution is specified by the Output Size parameter (in pixels).

Example

../../../Modules/ML/MLResample1/mhelp/Images/MPRExample.jpg

Details

The coordinate system of the output image is defined by coordinate vectors wx, wy and wz, denoting the direction of the image's pixel rows and columns and the depth direction, respectively. These vectors are computed from the Rotation parameter R by

(wx, wy, wz) = R (ex, ez, -ey),

where ex, ey and ez are the unit vectors. This definition, especially the swapping of the Y and Z direction, is compatible to the conventions used for Open Inventor draggers, which define the Y-axis as the direction normal. Accordingly, the translation and rotation fields of an Inventor Dragger (e.g. SoJackDragger, SoPlaneDragger) can directly be connected to the fields of an MPR module.

In order to obtain the MPR rotation parameter for a given plane normal, compute:

rotation = SbRotation(SbVec3f(0,1,0), planeNormal);

If three points p1, p2 and p3 on a plane are given, the plane normal can be computed using the cross product:

SbVec3f dir1 = p2-p1;
SbVec3f dir2 = p3-p1;
SbVec3f planeNormal = dir1.cross(dir2);

The voxel-to-world-matrix W of the MPR's output image is computed from the rotation R and the translation T by

W = T R M S D,

where

  • D describes the translation from image center to origin (-sx/2, -sy/2, 0),
  • S describes the voxel size, and
  • M rotates y to z and z to -y.

Here is the corresponding code snippet:

double voxelSize = fieldOfView / outputSize;
dir1 = rotation * vec3(1, 0, 0) * voxelSize;
dir2 = rotation * vec3(0, 0, 1) * voxelSize;
dir3 = rotation * vec3(0, -1, 0) * voxelSize;

vec3 trans = translation - outputSize/2*dir1 - outputSize/2*dir2 - 1/2*dir3;

toWorldMatrix = mat4(dir1, dir2, dir3, trans);
../../../Modules/ML/MLResample1/mhelp/Images/MPRDefinition.jpg

The above figure shows an input image box drawn in world coordinates and an MPR slice that defines an oblique slice within this box.

The center of the slice is given as the Translation parameter, the slice normal is given by the Rotation applied to the negative world Y-axis.

Windows

Default Panel

../../../Modules/ML/MLResample1/mhelp/Images/Screenshots/MPR._default.png

Input Fields

input0

name: input0, type: Image

Input image from which an MPR is computed.

Output Fields

output0

name: output0, type: Image

Provides the MPR image slice (or slice stack if Output Depth > 1).

outputSlice

name: outputSlice, type: SoNode

An Open Inventor scene representing the MPR slice in 3D (see the Inventor parameter section for relevant options).

Parameter Fields

Field Index

Activate clip plane: Bool Field Of View: Float Output Depth: Integer
Alpha: Float Fill Value: Double Output Size: Integer
Aspect Ratio: Float Flip Clip Plane: Bool Plane: Plane
Axial: Trigger Force Upright: Bool Represent Input Slice: Trigger
Blend Mode: Enum Image Color: Color Rotation: Rotation
Border Color: Color Interactive manipulator: Bool Sagittal: Trigger
Clip Plane Offset: Float Interpolation: Enum Slice No.: Integer
Coronal: Trigger Memory Access: Enum Translation: Vector3
Draw axes: Bool On (borderOn): Bool Use Z buffer: Bool
Enable Plane Edit: Bool On (drawImageOn): Bool  

Visible Fields

Rotation

name: rotation, type: Rotation, default: 0 0 1 0

Sets the rotation of the MPR slice, mapping the world X-, Y-, and Z-axes to the MPR image's X-, negative Z-, and Y-axes, respectively.

The easiest way to edit the rotation is to use an OpenInventor dragger and connect its rotation field to this parameter.

Translation

name: translation, type: Vector3, default: 0 0 0

Sets the translation vector to the center of the (first) MPR slice (in world coordinates).

Plane

name: plane, type: Plane, default: 0 0 1 0

Sets the plane containing the first slice of the MPR output image.

Enable Plane Edit

name: enablePlaneEdit, type: Bool, default: FALSE

If checked, the Plane field can be used as an input field.

Incremental modifications of the Plane field are transformed to modifications of the Rotation and Translation parameters.

Fill Value

name: fillValue, type: Double, default: 0, deprecated name: fillvalue

Sets the value used for regions outside of the input image.

Field Of View

name: fieldOfView, type: Float, default: 100

Sets the extent of the MPR slice in the world coordinate system (in mm).

Output Size

name: outputSize, type: Integer, default: 256, minimum: 1

Sets the resolution of the output slice (X,Y) in pixels.

Output Depth

name: outputDepth, type: Integer, default: 1, minimum: 1

Sets the depth (Z size) of the output image.

If set to 1, a single slice is generated. If set to a value > 1, the output image is a stack of MPR's, where the translation defines the center of the first slice.

Aspect Ratio

name: aspectRatio, type: Float, default: 1

Sets the aspect ratio of the MPR.

Values larger than 1.0 produce portrait, smaller than 1.0 landscape output.

Force Upright

name: forceUpright, type: Bool, default: FALSE, deprecated name: useUpVector

If checked, the MPR slice's Y-axis is forced to be close to the world Y-axis (or Z-axis if the MPR slice normal is parallel to the Y-axis).

Slice No.

name: inputSliceNo, type: Integer, default: 0

Sets the slice number to be reproduced by the Represent Input Slice trigger.

Represent Input Slice

name: representInputSlice, type: Trigger

If pressed, Field Of View, Output Size, Aspect Ratio, Translation, and Rotation are being adjusted such that the output exactly matches the input slice number Slice No..

Axial

name: axial, type: Trigger

If pressed, the MPR is set to axial (transversal) orientation.

Sagittal

name: sagittal, type: Trigger

If pressed, the MPR is set to sagittal orientation.

Coronal

name: coronal, type: Trigger

If pressed, the MPR is set to coronal orientation.

Interpolation

name: interpolation, type: Enum, default: Trilinear, deprecated name: Mode

Defines the interpolation used for resampling.

Values:

Title Name Description
Nearest Neighbor NearestNeighbor

No interpolation, picks the nearest input image voxel.

Fastest mode.

Trilinear Trilinear

Trilinear filtering. The 8-voxel-neighborhood is used for linear interpolation.

Slowest mode.

Trilinear Skip Border TrilinearSkipBorder

Same as Trilinear, but all output voxels that depend on a voxel outside of the input image are filled with Fill Value.

Faster than Trilinear.

Memory Access

name: memoryAccess, type: Enum, default: Global, deprecated name: pagedInputImage

Defines how the module accesses the input image.

Values:

Title Name Deprecated Name Description
Paged Paged TRUE

Slower than global, except for small MPR's in large input images. The output MPR is split into tiles that are processed individually. For each tile, the module requests the corresponding 3D region of the input image.

If not enough memory is available, the module falls back to Virtual Volume access.

Global Global FALSE

Fastest, but highest memory cosumption and initialization time. The input image is accessed as a global image (via the ML memory image). This consumes a lot of memory for large datasets.

If not enough memory is available, the module falls back to the Virtual Volume memory access.

Virtual Volume VirtualVolume   Slowest, but works on huge datasets. All pages of the input image are requested via the virtual volume mechanism, thus only small portions of the input image are needed at the same time.

Image Color

name: imageColor, type: Color, default: 1 1 1, deprecated name: baseColor

Sets the color used to display the image data.

Border Color

name: borderColor, type: Color, default: 1 1 1

Sets the color used to draw the slice border.

On (borderOn)

name: borderOn, type: Bool, default: TRUE

Enables/disables the drawing of the slice border.

On (drawImageOn)

name: drawImageOn, type: Bool, default: TRUE

Enables/disables the drawing of the image data.

Interactive manipulator

name: manipulatorOn, type: Bool, default: TRUE

Enables/disablse a 3D manipulator that can be used to translate, rotate and scale the MPR slice in the Inventor scene.

Activate clip plane

name: clipPlaneOn, type: Bool, default: FALSE

Enables/disables a clip plane applied to the Open Inventor scene on one side of the MPR plane.

Flip Clip Plane

name: flipClipPlane, type: Bool, default: FALSE

If checked, the halfspace that is clipped by the clip plane is flipped.

Clip Plane Offset

name: clipPlaneOffset, type: Float, default: 0

Sets an offset to the clip plane in the direction of the MPR slice normal.

Draw axes

name: axesOn, type: Bool, default: FALSE, deprecated name: drawVectors

Enables/disables drawing of the MPR output image coordinate axes.

Alpha

name: alphaFactor, type: Float, default: 1, minimum: 0, maximum: 1

Sets an alpha value used to draw the image data.

Use Z buffer

name: zBuffer, type: Bool, default: TRUE

If disabled, the z buffer is ignored when rendering the slice.

Blend Mode

name: blendMode, type: Enum, default: BLEND_REPLACE

Defines how the slice texture is drawn.

Values:

Title Name
Maximum BLEND_MAXIMUM
Add BLEND_ADD
Minimum BLEND_MINIMUM
Replace BLEND_REPLACE
Reverse Subtract BLEND_REVERSE_SUBTRACT
Subtract BLEND_SUBTRACT
Blend BLEND_BLEND