Plastimatch questions

762 views
Skip to first unread message

Erika

unread,
Dec 19, 2011, 6:51:24 AM12/19/11
to Plastimatch
Hi,

I have a couple questions about using plastimatch. I did bspline
registration on dicom files (fixed dicom dir: CT50, moving dicom dir:
CT90).

1) Can I create a difference image using the dicom files in CT50 and
the output dicom files from the registration or does it have to be in
some other format?

2) Can I use the registration results to deform the structure contours
in the dicom RT struct file and if so how?

3) If I have a specific set of points in the fixed image, how do I use
the registration results to find their new location in the moving
image?

thanks

Erika

Gregory Sharp

unread,
Dec 21, 2011, 5:26:44 PM12/21/11
to plast...@googlegroups.com, erika....@gmail.com
On Mon, 19 Dec 2011 03:51:24 -0800 (PST)
Erika <erika....@gmail.com> wrote:

> Hi,
>
> I have a couple questions about using plastimatch. I did bspline
> registration on dicom files (fixed dicom dir: CT50, moving dicom dir:
> CT90).
>
> 1) Can I create a difference image using the dicom files in CT50 and
> the output dicom files from the registration or does it have to be in
> some other format?

Hmm, it looks like the input can be dicom, but the output has to be another
format. So I guess you would have to use two commands like this:

plastimatch diff dicom1 dicom2 tmp.mha
plastimatch convert --input tmp.mha --output-format dicom --output diff

>
> 2) Can I use the registration results to deform the structure contours
> in the dicom RT struct file and if so how?
>

Yep. The command is something like this:

plasmatch warp \
--xf bspline_coefficients.txt \
--input contours_in.dcm \
--output-dicom output_directory

> 3) If I have a specific set of points in the fixed image, how do I use
> the registration results to find their new location in the moving
> image?

The command is something like this:

plastimatch warp \
--xf bspline_coefficients.txt \
--input fixed_locs.fcsv \
--output-pointset warped_fixed.fcsv

Greg
--
Greg Sharp, PhD
Department of Radiation Oncology
Massachusetts General Hospital


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.

Erika

unread,
Dec 22, 2011, 7:04:51 AM12/22/11
to Plastimatch
Hi Dr. Sharp,

Thanks for the reply. I'm still having problems with the warp command
on dicom files.

1) If I apply warp on CT dicom directory and try to output dicom
files to a new directory, I get back exactly the CT input files (i.e.
no warping performed).

2) If I apply warp on CT dicom directory using bspline coeff and
output to .mha, it works. If however, I use bspline_vf, a correct
ouput .mha file seems to be created but plastimatch freezes with
output:

The directory:

C:/Users/Erika/Academic/4D CT Netherlands/VMAT44_CT90_heart_dec19_ins

Contains the following DICOM Series:
1.2.840.113619.2.181.90581109237.5897.1311337976212.1424.2112.5512512

Now reading series:
1.2.840.113619.2.181.90581109237.5897.1311337976212.1424.2112.5512512
Loading xform (C:/Users/Erika/Academic/4D CT registration/
test_heart_usergrp/bsp
line_vf_ct90.mha)
PIH is:
Origin = -250 -250 -167.5
Size = 512 512 128
Spacing = 0.976562 0.976562 2.5
Direction = 1 0 0 0 1 0 0 0 1
Rtds_warp: Warping m_img
plm_warp_itk: xform_to_itk_vf
plm_warp_itk: convert_to_itk
plm_warp_itk: warping...
Rtds_warp: Saving m_img (C:/Users/Erika/Academic/4D CT registration/
test_heart_u
sergrp/heart_ct90_defto50_vf.mha)
Trying to write image to C:/Users/Erika/Academic/4D CT registration/
test_heart_u
sergrp/heart_ct90_defto50_vf.mha
Rtds_warp: Convert ss_img to cxt.
Rtds_warp: Apply dicom_dir.
Rtds_warp: Set geometry from PIH.
Rtds_warp: Set rasterization geometry.
rast_dim = 512 512 127
rast_offset = -261.993 -244.608 -167.5
rast_spacing = 1.0232 1.0232 2.5
Rtds_warp: warp and save ss.
Warp_and_save_ss: m_ss_image->rasterize
Rasterizing...
Converting...
Finished rasterization.
Warp_and_save_ss: m_ss_image->warp
Warping ss_img.
plm_warp_itk: xform_to_itk_vf
Exception running vector resample filter!

itk::ExceptionObject (00BBEEFC)
Location: "class itk::Vector<float,3> *__thiscall
itk::ImportImageContainer<unsi
gned long,class itk::Vector<float,3> >::AllocateElements(unsigned
long) const"
File: c:\users\erika\slicer3d\slicer3-lib\insight\code\common
\itkImportImageCont
ainer.txx
Line: 188
Description: Failed to allocate memory for image.

3) I don't understand what's the difference between using bspline
coefficients versus vector field to warp?

4) When warping RTstruct file using your suggested commands, I'm not
sure it works. I don't have Eclipse at the moment but using Matlab to
do a quick check, I find only 10/18 structures have contours.
Contours for other 8 structures have disappeared. As well, the number
of contours/structure increases by about 50-300%. Whereas for
manually contoured structures, the change in the # of contours/
structure between the 2 phases is only <10% for most structures (lung
up to 25%).

5) For warping points, I'm not familiar with the .fcsv file format.
Could I create a set of points in matlab, save it to a text file and
apply the warp command? If so, would the text files be a single
column of numbers (e.g. x1, y1, z1, x2, y2, z2..etc). Or would it be
easier to read in the vector field to matlab instead using the
readmha.m file provided by plastimatch?

6) If CT50 is my fixed img and CT90 is my moving img, then I would
apply the registration results to CT90 RTstruct to find the deformed
contours in CT50? However, if I apply the registration results to
point locations in CT50, this will give me their new locations in
CT90?


Thanks in advance,

Erika

Gregory Sharp

unread,
Dec 27, 2011, 12:12:18 PM12/27/11
to plast...@googlegroups.com

Hi Erika,

> 1) If I apply warp on CT dicom directory and try to output dicom
> files to a new directory, I get back exactly the CT input files (i.e.
> no warping performed).

I could reproduce this problem. It is a bug. I will try to fix it soon.

> 2) If I apply warp on CT dicom directory using bspline coeff and
> output to .mha, it works. If however, I use bspline_vf, a correct
> ouput .mha file seems to be created but plastimatch freezes with
> output:
>
> The directory:
>
> C:/Users/Erika/Academic/4D CT Netherlands/VMAT44_CT90_heart_dec19_ins
>
> Contains the following DICOM Series:
> 1.2.840.113619.2.181.90581109237.5897.1311337976212.1424.2112.5512512

... <snip>

> Finished rasterization.
> Warp_and_save_ss: m_ss_image->warp
> Warping ss_img.
> plm_warp_itk: xform_to_itk_vf
> Exception running vector resample filter!
>
> itk::ExceptionObject (00BBEEFC)
> Location: "class itk::Vector<float,3> *__thiscall
> itk::ImportImageContainer<unsi
> gned long,class itk::Vector<float,3> >::AllocateElements(unsigned
> long) const"
> File: c:\users\erika\slicer3d\slicer3-lib\insight\code\common
> \itkImportImageCont
> ainer.txx
> Line: 188
> Description: Failed to allocate memory for image.
>

Hmm, this is unusual, but maybe you really are running out of memory?
How much RAM do you have? Can you try closing other processes
on the computer and re-run?

> 3) I don't understand what's the difference between using bspline
> coefficients versus vector field to warp?

The bspline coefficients contain enough information to represent
the vector field, so you can use either one to do the warping.
In most cases the warping result is exactly the same.

Personally I use the bspline coefficients because it saves disk space.
But vector field is better for using with other applications.

> 4) When warping RTstruct file using your suggested commands, I'm not
> sure it works. I don't have Eclipse at the moment but using Matlab to
> do a quick check, I find only 10/18 structures have contours.
> Contours for other 8 structures have disappeared. As well, the number
> of contours/structure increases by about 50-300%. Whereas for
> manually contoured structures, the change in the # of contours/
> structure between the 2 phases is only <10% for most structures (lung
> up to 25%).

The missing structures may be a bug that Karthik just reported, and he
also sent a patch to fix. Can you try this?

I couldn't fully understand the part about extra contours/structures.
Do you mean more extra structures (with names)? Or each structure has
more contours than you expected?

> 5) For warping points, I'm not familiar with the .fcsv file format.
> Could I create a set of points in matlab, save it to a text file and
> apply the warp command? If so, would the text files be a single
> column of numbers (e.g. x1, y1, z1, x2, y2, z2..etc). Or would it be
> easier to read in the vector field to matlab instead using the
> readmha.m file provided by plastimatch?

I think there is a txt file which is also supported.
You can put one landmark on each line, like this:

x1 y1 z1
x2 y2 z2

Using readmha is also good. You just have to map the landmark
positions into the vector field, and add the displacement.

> 6) If CT50 is my fixed img and CT90 is my moving img, then I would
> apply the registration results to CT90 RTstruct to find the deformed
> contours in CT50? However, if I apply the registration results to
> point locations in CT50, this will give me their new locations in
> CT90?

Yes this is correct. Landmarks are the opposite direction
from images.

Erika

unread,
Dec 29, 2011, 4:28:50 AM12/29/11
to Plastimatch
Hi Dr. Sharp.

1) Thanks, let me know when warping dicom to dicom works.

2) The problem disappeared. Maybe it was a memory issue with my
computer.

4) The patch worked. There are no longer any missing structures.
However, warping RTSTRUCTS results in more contours for a given
structure than I expected (up to 3x more). Is that normal? I was
unable to import and visualize the dicom results in Eclipse despite
linking to the right patient so I'll write some visualization
functions in matlab and see how it goes from there. I'll get back to
you later.

3), 5), 6) Thanks very much for your answers. My understanding of
image registration is getting better.

Erika

Erika

unread,
Jan 5, 2012, 6:58:06 AM1/5/12
to Plastimatch
Hi Dr. Sharp or anybody else who knows,

Sorry, I thought I understood your above answer but I'm still a bit
confused.

So if CT50 is my fixed image and CT90 is my moving image, I understand
that applying the registration results to CT90 gives a close
approximation of the CT50 image. And if I have a set of points in
CT50, I can find their location in CT90 by applying the same
registration results.

Where I am confused is for the contours in a dicom file. Why is it
that I apply the registration results to the contour dicom file in
CT90 to get the contours in CT50? Aren't contours in dicom files
stored as points? So shouldn't the deformation of the contours go in
the opposite direction? Or does this have something to do with the
way plastimatch handles dicom structure contours?

thanks

Erika

Paolo Zaffino

unread,
Jan 5, 2012, 8:10:22 AM1/5/12
to plast...@googlegroups.com, erika....@gmail.com
Hi Erika,

I think that you want to map the structures of the "moving" dataset on
the reference system of "fixed" dataset.
I did this task and below you find the type of commands that I executed
(I started registering the two CTs).
Are the contours stored into a dicomRT file?
If yes you can get the mha file/s by this command:

plastimatch convert --input=file_name_dicomRT --interpolation=nn
--output-type=uchar --referenced-ct=ct_directory
--output-prefix=output_directory

In this way you should have the mha file/s with the structure inside (a
mha file per each structure).
These type of contours are stored as white voxel with the black
background (so they are binary images).
Now you can warp one of this structure using this command:

plastimatch warp --input=STRU.mha --xf=vf_or_xf_file --interpolation=nn
--output-type=uchar --output-img=warped_stru.mha

This is just my experience, I don't know if there is a better way to do
this task.
Hope this helps.

Paolo.

Sharp, Gregory C.

unread,
Jan 5, 2012, 11:26:13 AM1/5/12
to plast...@googlegroups.com

Hi Erika,

Just to add a little more background.

You are correct that DICOM-RT structures are contained in points.
More specifically, they are points that lie on the planes of the
CT slices. If you warp the points, you get contours that no
longer lie on a single slice. Therefore, plastimatch converts
the structures into a kind of binary image, warps the image,
then re-extracts the boundary from the image. This ensures
that the new contours can lie on CT slices.

Greg

thanks

Erika

The information in this e-mail is intended only for the person to whom it is

Erika

unread,
Jan 5, 2012, 8:10:56 PM1/5/12
to Plastimatch
Thanks Paolo and Dr. Sharp, your answers were very helpful.

Erika


.
Reply all
Reply to author
Forward
0 new messages