RTK/Examples/MCCBCTReconstruction

From Openrtk
Revision as of 11:52, 25 July 2013 by Srit (talk | contribs)
Jump to navigation Jump to search

RTK provides the necessary tools to reconstruct an image with motion compensation. The implementation is based on two articles that we have published (article 1 and article 2) but only the FDK-based motion-compensated CBCT reconstruction (analytic algorithm in article 1) and without optimization (very slow reconstruction compared to article 2). You should read the articles to understand the basics of the algorithm before trying to use the software.

The algorithm requires a set of projection images with the associated RTK geometry, the respiratory phase of each projection image and the 4D motion vector field over a respiratory cycle in the cone-beam coordinate system. Each piece of data is described in more details below. It is assumed that we have a breathing motion that is cyclic and similar to that described by the vector field. Note that you could modify the code and create your own motion model if you want to, in which case you should probably contact us.

Projection images

This example is illustrated with a set of projection images of the POPI patient. This dataset has been used in the first previously-mentioned article. You can download the projections and the required tables of the Elekta database, FRAME.DBF and IMAGE.DBF, from MIDAS. The dataset is first used to reconstruct a blurry image:

# Convert Elekta database to RTK geometry
rtkelektasynergygeometry \
  -o geometry.rtk \
  -f FRAME.DBF \
  -i IMAGE.DBF \
  -u 1.3.46.423632.141000.1169042526.68

# Reconstruct from all projection images without any motion compensation
rtkfdk \
  -p . \
  -r .*.his \
  -o fdk.mha \
  -g geometry.rtk \
  --hann 0.5 \
  --pad 1.0

# Keep only the field-of-view of the image
rtkfieldofview \
  --reconstruction fdk.mha \
  --output fdk.mha \
  --geometry geometry.rtk \
  --path . \
  --regexp '.*.his'

You should obtain something like that with VV:

Blurred.jpg

Respiratory signal

Deformation vector field

The next piece of data is a 4D deformation vector field that describes a respiratory cycle. Typically, it can be obtained from the 4D planning CT with deformable image registration. Here, I have used Elastix with the new sliding module developed by Vivien Delmon. The registration uses a patient mask (red+green) and a motion mask (red) as described in Jef's publication:

Mm.jpg


The registration can easily be scripted, here with bash:

for i in $(seq -w 0 10 90)
do
  mkdir $i
  elastix -f 50.mhd -m $i.mhd -out $i -labels mm_50.mha -fMask patient_50.mha -p Par0016.multibsplines.lung.sliding.txt
done

Note that the reference frame is phase 50% and it is registered to each phase from 0% to 90%. One subtle step is that the vector field is a displacement vector field, i.e., each vector is the displacement of the point a the location of the arrow. Since I ran the registration on the 4D planning CT, the coordinate system is not that of the cone-beam CT. In order to produce the vector field in the cone-beam coordinate system, I have used the following bash script that combines transformix and several "clitk" tools that are provided along with VV:

# Transform 4x4 matrix that describes the transformation
# from planning CT to CBCT to a vector field
clitkMatrixTransformToVF --like 50.mhd \
                         --input CT_CBCT.mat \
                         --output CT_CBCT.mha

# Inverse transformation remove upper slices that are ouside the planning CT
# CBCT_CT.mat is the inverse of CT_CBCT.mha
clitkMatrixTransformToVF --origin -127.5,-107.5,-127.5 \
                         --spacing 1,1,1 \
                         --size 256,236,256 \
                         --input CBCT_CT.mat \
                         --output CBCT_CT.mha

# Go over each elastix output file, generate the vector field with
# transformix and compose with the two rigid vector fields
for i in $(seq -w 0 10 90)
do
  transformix -in 50.mhd \
              -out $i \
              -tp $i/TransformParameters.0.txt \
              -def all -threads 16
  clitkComposeVF -i CBCT_CT.mha \
                 -j $i/deformationField.mhd \
                 -o $i/deformationField.mhd
  clitkComposeVF -i $i/deformationField.mhd \
                 -j CT_CBCT.mha \
                 -o $i/deformationField.mhd
done

This is a bit complicated and there are probably other ways of doing this. For example, Vivien has resampled the planning CT frames on the CBCT coordinate system before doing the registrations, in which case you do not need to do all this. Just pick one of your choice but you should obtain at the end a 4D vector field that is nicely displayed on top of the fdk.mha file that RTK produce such as this (the vector field is downsampled and displayed with VV):

Vf.gif