Part 3: Mirroring/Flipping an Axis with SimVTK
Your own files, or:
- axesSwapMR.vtk.zip (7.75 MB)
Optional Files (premade Model files use example files above)
- AxisMirror.mdl.zip (6 KB)
The purpose of this tutorial is to teach you how to mirror axis of a volume using SimVTK in the event your two volumes are not in the same orientation. In this tutorial, the MR volume will be reoriented to match the axes of the CT volume. As an example, compare CroppedCT.vtk to AxesSwapMR.vtk from our downloads section (click to enlarge):
The Z axis needs to be mirrored in the MR to match that of the CT. Evidence of this has been highlighted with circles on the above image.
In Simulink, create a new model. Three blocks will be necessary:
- a vtkDataSetReader block (found in the SimVTK IOLibrary)
- a vtkDataSetWriter block (also in the SimVTK IOLibrary)
- and an vtkImageFlip block (found in the SimVTK ImagingLibrary).
Connect the vtkDataSetReader block to the vtkImageFlip and the vtkImageFlip block to the vtkDataSetWriter block. Since we are using .vtk files, we will use the vtkDataSetReader and vtkDataSetWriter blocks in this tutorial.
Exactly like the previous tutorials, we will read in the .vtk file, perform the specified mirroring, and write the mirrored output as a .vtk file.
Your workflow should look similar to this:
The vtkDataSetReader and vtkDataSetWriter blocks will not be discussed here as they are used in the same manner as outlined in the Crop tutorial. For instructions on proper configuration of the blocks, please see the Crop tutorial.
Double-click the vtkImageFlip block and change the FilteredAxis Parameter (not Axes) from the “Use Default” setting to “As Parameter”. The FilteredAxis Value text entry field takes an integer as a value. The integer corresponds to the desired axis to be flipped. Just like the swapping of axes mentioned in the previous tutorial, 0 corresponds to X, 1 to Y, and 2 to Z. In this example, we wish to flip the Z axis so a 2 will be the FilteredAxis Value. When properly configured, your vtkImageFlip block should look like this:
Once these parameters have been adjusted, click OK. The workflow is now ready to be run. After ensuring that you have set an appropriate output filename and that the configuration parameters have been set accordingly, click play in the toolbar and wait for the noise indicating completion is heard.
Congratulations! You have completed the tutorial!
> Continue onto the Translation tutorial.