Crop

Part 1: Performing a Crop with SimVTK

Necessary Files

Your own files, or:

Optional Files (premade Model files use example files above)

The purpose of this tutorial is to teach you how to perform a simple crop using SimVTK.

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 a vtkImagePermute block (found in the SimVTK ImagingLibrary).

Connect the vtkDataSetReader block to the vtkImagePermute and the vtkImagePermute block to the vtkDataSetWriter block. Simply put, we will read in the .vtk file, perform the specified crop, and write the cropped output as a .vtk file. The vtkDataSetReader and vtkDataSetWriter are chosen as they are the blocks designed to handle the manipulation of .vtk files.

Your workflow should look similar to this:

Now that the proper workflow blocks are connected in sequence, we need to set the parameters accordingly.

Note: This is the same workflow used to crop both the CT and MR datasets. The only difference will be the parameter values as they will be specific to each case, respectively. These values will be clearly defined for each dataset throughout the tutorial.

vtkDataSetReader

The only parameter that needs to be set is the FileName Value to tell Simulink where the model can be found. Double-click the block and change the FileName Parameter pulldown menu to the “As Parameter” option. A text entry field entitled FileName Value will appear directly below the pulldown. The filepath needs to be entered in this field and must be enclosed by single quotes.
For example:

vtkDataSetWriter

This block needs the same parameter change as the Reader with the exception that the FileName Value will be the desired location of the output. This filepath also needs to be enclosed by single quotes. Double-click the block and make the necessary adjustments. For example:

This would create a new file called “CroppedCT.vtk” in the same directory as the model file is found. Ensure that when you are manipulating different modalities, a different output file name is given so previously run workflow outputs are not lost.

vtkImagePermute

Double-click the block and set the AutoCropOutput Parameter to “As Parameter” with an AutoCropOutput Value of 1 to instruct SimVTK that a crop is the desired function. The crop parameters will be supplied next.

Set the OutputExtent Parameter to “As Parameter” with a 6 value vector corresponding to the [Xmin Xmax Ymin Ymax Zmin Zmax] of the desired output. Ensure that the Voxel values are taken and not the World values. For example:

Using the three panes, find the desired Voxel values for Xmin Xmax Ymin Ymax Zmin Zmax.

The parameters found for use in this tutorial were:

  • CT: [139.5 376.5 169.44 357.94 32.85 261.23]
  • MR: [205.5 365.5 133.44 391.44 2.66 114.22]

Set the OutputOrigin Parameter to “As Parameter” with the OutputOrigin Value corresponding to the origin of the file as a 3 value vector [x y z].

Below are the origins for each file, respectively:

  • CT: [-111.3 -116.0 27.125]
  • MR: [60.4610 -102.22 124.062]

Finally, the OutputSpacing Parameter will also need the setting of “As Parameter” with the OutputSpacing Value set to the spacing of the file as a 3 value vector [x y z].

Below are the spacings for each file, respectively:

  • CT: [0.45312 0.45312 0.625]
  • MR: [0.54687 0.54687 0.99999]

One workflow should exist for each modality. When properly set up, the vtkImagePermute block should look similar to this for CT:

And for MR:

Before commencing simulation, ensure that the configuration parameters have been properly set. Refer to the Configuration Parameters page under the Spine Registration menu if needed.

Congratulations! You should now have a newly cropped version of either the MR or CT spinal phantom. If you used the same block parameters as mentioned throughout this tutorial, compare your output to the reference files in the downloads section for confirmation.

> Continue onto the Axial Swap tutorial.

Comments are closed.