Optimizing resolution and spacing parameters in Plastimatch DRR

Hi,

I am using Plastimatch DRR module within the SlicerRT extension to create synthetic lateral x-rays from a CT volume. I am trying to produce DRRs with the clearest vertebral margins (minimizing blur due to pixelation and banding artifacts) and I can’t find documentation of the “Spacing” parameter within the “Imager and Image” parameters in Plastmatch materials or 3D Slicer.

I have played around with the “Resolution” and “Spacing” parameters, but I don’t understand the relationship between them. At low values of both, the DRR doesn’t capture enough of the anatomy around the isocenter position and it is pixelated with significant banding artifacts.

Resolution = 120, 120; Spacing = 1, 1

At high values of both, the banding artifacts appear to be absent, but the image is very blurry.

Resolution = 400, 400; Spacing = 8,8

How can I find a balance between these two parameters to achieve the highest image quality?

Resolution is the number of rows and columns in the detector. You probably want to have it at about 2000 to be realistic.

Spacing value refers to the detector pixel size. A realistic value is about 0.1-0.2 mm.

Hi Andras,

Thank you for the prompt and informative response. I applied the settings that you recommended (Resolution = 2000, Spacing = 0.2mm) and the resulting DRR has some banding artifacts. See area around the navel.

Is there a combination of resolution/spacing that would result in the clearest margins of the vertebral bodies, not taking into account practicality?

I believe that I can achieve clearer visualization of the spine by cropping out the surrounding tissues and adjusting the SAD/SID. Before attempting those two avenues, I wanted to optimize resolution and spacing as much as possible.

Thanks,
Andrew

I always use the volume renderer for DRR generation. It is blazing fast (you can render 100+ images per second with a good GPU), by adjusting the cropping ROI and editing the transfer functions you can get very good contrast for the bones. Use the CT-X-ray volume rendering preset and set the view background to black. I find that the image appearance overall is quite to an X-ray or fluoroscopy image.

Thank you for another quick reply.

I have used the CT-X-ray volume rendering for demonstrations, but I am not sure if it will meet my ultimate goal. I am trying to create a simulated XR (PNG, JPEG, or DICOM) in which the pixel coordinates of certain predetermined anatomic landmarks are known. To do this, I am marking the anatomic landmarks and the isocenter for the DRR on a CT or MHA in the Markup module. Then, I am calculating the distance between the isocenter and each of the coordinates in RAS and mapping those distances to the DRR using the center of the DRR as a reference.

Is there a better way of generating a simulated lateral x-ray in which the pixel coordinates of certain anatomic landmarks are known?

Volume rendering is perfect for this. You know the pixel coordinates of anatomic landmarks from the camera parameters. You can even make the landmarks appear in the DRR by enabling Occluded visibility in Markup module (Display / Advanced / 3D Display).

That’s great. Using the “CT-X-ray” preset in the Volume Rendering module, I created a DRR in the blue window. Do you recommend using the “Screenshot” or “ScreenView” tools to create a PNG of the contents of the blue window?

Where can I view the camera parameters? I looked at documentation for the “Cameras” module, but that doesn’t appear to contain the information that I need.

You can try to increase “Threshold below” value (for example set this value to 150). Below that threshold the HU values of CT data will be set to -1000 (air), so some soft tissues can be replaced with air.

The DRR calculation process can be significantly upgraded, if use RTK library for projection calculation.

Thanks, Mikhail, for the suggestion. Two questions:

  1. Is there a 3D Slicer extension that offers the projection calculation capabilities that you are referencing from the RTK Library?
  2. Are you aware of any RTK Library documentation that describes the process to create a DRR?
  1. I don’t know, possibly not. 3D Slicer doesn’t compile ITK with RTK support.

  2. Official documentation only describes classes and methods of the library in C++. I work in C++ most of the time as well. If you familiar with C++ you could look at applications/rtkforwardprojections directory in RTK source. CT data must be a single mha file and projection geometry must be setup for proper forward projection reconstruction. I can send you a C++ example, but it only for Linux.

Here is some examples with python in itk:

  1. Quick start guide — ITKPythonPackage documentation
  2. Creating DRR in RTK with python.

You can also check RTK mailing-list discussions DRR in RTK mailing-list

I forgot to mention that RTK can only increase calculation speed of DRR, any other features like projections of markups must be done (programmed) by the user.

Thanks, Mikahil. I do not have experience working with C++ and have limited experience working in Python, so my options are constrained.

I will check out the Python documentation that you sent as it might be more in reach for me. I appreciate you linking the references!

Hi Andras, do you have a suggestion for how to generate PNG of a DRR using the Volume Rendering module?

You can right-click the 3D viewer, choose Copy image, then paste&save it in Paint or other image viewer software. You can also do it by Python scripting as shown in these examples (hit Ctrl-3 to open the Python console and copy-paste the code snippet).

There are so many tools in 3D Slicer and related libraries that can generate DRRs, all with specific advantages and disadvantages. The right choice depends on what you would like to achieve. What is your end goal with the DRR generation? CT/fluoro registration? What is the target anatomy and clinical procedure?

Thanks, copying the image manually makes sense.

The ultimate goal is to evaluate a novel method for measuring thoracolumbar endplate orientation in sagittal plane radiographs (DR, CR, and EOS). The method must be implemented in custom measurement software.

To accomplish this, the process that I envisioned was to create “ideal” reference points in a CT volume, then hide those points and generate a synthetic lateral XR of the spine. The synthetic lateral XR would then be imported into the custom software that I am using for making endplate measurements and my team would make measurements per the novel protocol. Finally, I would compare the known coordinates of the “ideal” reference points in the DRR to the manually-measured points placed by my team.

It is similar to a process described by Hipp et al. 2022 in a recent publication (pages 9 and 10). They used Plastimatch’s DRR functionality, so I thought that Plastimatch would work for my purposes. Unfortunately, the quality of the DRRs is not representative of normal lumbar x-ray. See image below.

I had a look at DRR Generation module and it creates reasonable image from the CTChest sample data set:

The lateral view generated from CTChest was very soft due to the low resolution of the image. The result was nicer using CTLiver data set.

With “exact” exposure:

With “uniform” exposure:

The “DRR Generation” module is the one that I was using in previous posts. I was able to generate a DRR of reasonable image quality by switching CT series to one with smaller “Image Spacing” (0.77, 0.77, 0.80. vs 0.85, 0.85, 1.0).

Fortunately (or unfortunately) the lack of resolution of the CTs that I was using may have been causing my issues all along.

I have two questions regarding the DRR Generation module:

  1. How can I map the A and S components of the RAS coordinates of a point placed on the CT volume using the Markup module to the P,S or pixel coordinates of the DRR?

    • The DRR isocenter is set to a known LPS coordinate in the CT (ex. approximate center of L3, [-3,-120,380])
    • Therefore the center of the resulting DRR is known in relation to the CT volume
    • If I have the A, S distance from the center of L3 in the CT volume to a landmark of interest, can I transform those values to find the coordinates of the landmark of interest in the DRR?
  2. Would you recommend exporting the DRR as a DICOM by right clicking the DRR volume in the “Data” module, selecting the “Export to DICOM” option, and checking the box for “Export to folder”? I am searching for the optimal method for exporting the DRR without compromising the relationship between the RAS coordinates of the CT volume and the pixel coordinates of the DRR.

Thanks again for all of your help! The documentation and community support for 3D Slicer is exceptional.

It is a simple perspective projection. You can compute the projection matrix as it is done in Plastimatch.

We don’t have a DICOM exporter for DRR (or fluoro) images in Slicer. It would not be hard to add it, but it may be simpler to save the image in a research file format and the DRR parameters in custom fields or in a sidecar file. Spending time with writing a DICOM exporter script may worth it if you will process the data with software that takes advantage of all the DRR parameters stored in these DRR files or for long-term archival or sharing of the images outside your group.

Great, I will dig into the Plastimatch documentation that you linked.

I am probably misunderstanding something, but it appears that I can create a DICOM export of the DRR using the “Data” module. This produces a .dcm file of ~8MB.

Spine DRR export to DICOM

Separately, how can I specify the filename for a DRR in the DRR Generation module when the output format is “pgm” or “pfm”? When “pgm” or “pfm” is selected, I receive the following error:

image

DRR generation standard error:

/Applications/Slicer.app/Contents/Extensions-30893/SlicerRT/lib/Slicer-5.0/cli-modules/plastimatch_slicer_drr: ITK exception caught !

itk::ExceptionObject (0x7fb01f1057c0)

Location: “unknown”

File: /Volumes/D/S/S-0-build/ITK/Modules/IO/ImageBase/include/itkImageFileWriter.hxx

Line: 96

Description: ITK ERROR: ImageFileWriter(0x7fb01f105cb0): No filename was specified

Separately, how can I specify the filename for a DRR in the DRR Generation module when the output format is “pgm” or “pfm”

Use only raw file format, other formats are only for internal plastimatch procedures!