Discussion:
[ITK-users] 3D registration with level set motion
CocoM
2017-08-03 13:03:36 UTC
Permalink
Hi everyone,

I'm doing image registration with the example DeformableRegistration5, i.e.
with level set motion. So far I've processed 2D images and it worked fine,
but I am now trying to register 3D images and I get an exception with any 3D
file I have. The exception occurs after triggering the registration filter,
in the function GenerateOutputInformation of the class
itkImageFileReader.hxx. Apparently ITK can't create IO objet for reading the
file (m_ImageIO is NULL).

I'm not sure of what I had to do to adapt this algorithm for 3D. The only
thing I changed is the image dimension defined in the main program. Is there
something more to change? I am working with Dicom 3D images, all the slices
in the same file.

Thanks a lot!

Marie




--
View this message in context: http://itk-insight-users.2283740.n2.nabble.com/3D-registration-with-level-set-motion-tp7590137.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users
CocoM
2017-08-03 13:55:03 UTC
Permalink
It is 3D I checked. Do you know if the two images need to be the same size in
every direction to make it work?



--
View this message in context: http://itk-insight-users.2283740.n2.nabble.com/3D-registration-with-level-set-motion-tp7590137p7590139.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users
CocoM
2017-08-03 14:18:07 UTC
Permalink
I think this works fine now, I had a format problem, thanks. But when
registering two images of different size I get the exception "Inputs do not
occupy the same physical space!". If I go on anyway the registration process
ends normally, but the metric value is huge and never decreases (1e+308).
Plus the output is entirely black. One of my images has 42 slices, the other
one has 43. Maybe that's why?



--
View this message in context: http://itk-insight-users.2283740.n2.nabble.com/3D-registration-with-level-set-motion-tp7590137p7590141.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users
Samuel Gerber
2017-08-03 14:36:00 UTC
Permalink
Hi Marie,

The registration is done in physical space not the image domain, a detailed
description is in Section 3.3 in the itk sotware guide ( https://itk.org/
ITKSoftwareGuide/html/Book2/ITKSoftwareGuide-Book2ch3.html#x26-990003.1 ).

Each image has a mapping from the image domain, i.e your voxel space where
you can index individual pixels, to physical space. If those mappings map
the images into physical space in a way that results in no overlap between
the images you will get the exception you are seeing. The physical space is
determined by:

"One important consequence of this fact is that having the correct image
origin, image pixel size, and image direction is fundamental for the
success of the registration process in ITK, since we need this information
to compute the exact location of each pixel lattice in the physical space;
we must make sure that the correct values for the origin, spacing, and
direction of all fixed, moving and virtual images are provided."

So you might want to check those values for the images you are registering.

-Sam
Post by CocoM
I think this works fine now, I had a format problem, thanks. But when
registering two images of different size I get the exception "Inputs do not
occupy the same physical space!". If I go on anyway the registration process
ends normally, but the metric value is huge and never decreases (1e+308).
Plus the output is entirely black. One of my images has 42 slices, the other
one has 43. Maybe that's why?
--
View this message in context: http://itk-insight-users.22837
40.n2.nabble.com/3D-registration-with-level-set-motion-
tp7590137p7590141.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.kitware.com/products/protraining.php
http://www.itk.org/Wiki/ITK_FAQ
http://public.kitware.com/mailman/listinfo/insight-users
_______________________________________________
Community mailing list
http://public.kitware.com/mailman/listinfo/community
--
Samuel Gerber
R&D Engineer
Kitware, Inc.
--
Samuel Gerber
R&D Engineer
Kitware, Inc.
CocoM
2017-08-03 15:33:41 UTC
Permalink
Hi Sam,

Thanks a lot for your answer. I think I understand what you mean, and I
checked the spacing, origin and direction of my images. The only difference
is the origin in z. In one case it's -1177, in the other -1188. But the
origins don't need to be the same to get an overlap between images physical
spaces right? With my data, I don't understand why I wouldn't get one ; the
spacings are [0.781 0.781 1], the origins [-200 -200 -1177 or -1188] and the
directions are identity matrix. Why wouldn't it work?

Thanks,
Marie



--
View this message in context: http://itk-insight-users.2283740.n2.nabble.com/3D-registration-with-level-set-motion-tp7590137p7590143.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users
Samuel Gerber
2017-08-03 15:46:43 UTC
Permalink
That looks like there should be enough overlap.

Do you get the exception while the registration is running? In that case it
might be that during the registration the transform pushes the images away
from each other until there is not enough overlap. What kind of optimizer
are you using? You might need to adjust the step size of your optimizer.

-Sam
Post by CocoM
Hi Sam,
Thanks a lot for your answer. I think I understand what you mean, and I
checked the spacing, origin and direction of my images. The only difference
is the origin in z. In one case it's -1177, in the other -1188. But the
origins don't need to be the same to get an overlap between images physical
spaces right? With my data, I don't understand why I wouldn't get one ; the
spacings are [0.781 0.781 1], the origins [-200 -200 -1177 or -1188] and the
directions are identity matrix. Why wouldn't it work?
Thanks,
Marie
--
View this message in context: http://itk-insight-users.
2283740.n2.nabble.com/3D-registration-with-level-set-
motion-tp7590137p7590143.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.kitware.com/products/protraining.php
http://www.itk.org/Wiki/ITK_FAQ
http://public.kitware.com/mailman/listinfo/insight-users
--
Samuel Gerber
R&D Engineer
Kitware, Inc.
CocoM
2017-08-03 16:57:04 UTC
Permalink
No I don't think so, it happens after triggering the registration process
(before any iteration) but just once in the beginning and once in the end.
But actually the deformation field is never updated because the physical
spaces don't match so theoretically it's endless. The exception occurs both
times in the function VerifyInputInformation, called by
UpdateOutputInformation (ProcessObject).

I am not using any optimizer because it's a registration method solving a
PDE iteratively : itkLevelSetMotionRegistrationFilter. It works with a
finite difference resolution scheme, but I can modify the time step,
although I wouldn't really see the point. Any idea?

Thanks,
Marie





--
View this message in context: http://itk-insight-users.2283740.n2.nabble.com/3D-registration-with-level-set-motion-tp7590137p7590145.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users
Samuel Gerber
2017-08-03 17:40:12 UTC
Permalink
I apologize I did not realize you were using a PDE based registration. It
is my understanding that for this approach the images need to match in
physical space, since the filter operates in way that matches pixel by
pixel.

There is a few options:
1. You could limit the output region such that they are both fully
contained in both images. See:
https://itk.org/ITKExamples/src/Core/Common/ApplyAFilterOnlyToASpecifiedRegionOfAnImage/Documentation.html

2. You could pad the smaller image.

3. You could perform an affine registration first and resample the image.

-Sam
Post by CocoM
No I don't think so, it happens after triggering the registration process
(before any iteration) but just once in the beginning and once in the end.
But actually the deformation field is never updated because the physical
spaces don't match so theoretically it's endless. The exception occurs both
times in the function VerifyInputInformation, called by
UpdateOutputInformation (ProcessObject).
I am not using any optimizer because it's a registration method solving a
PDE iteratively : itkLevelSetMotionRegistrationFilter. It works with a
finite difference resolution scheme, but I can modify the time step,
although I wouldn't really see the point. Any idea?
Thanks,
Marie
--
View this message in context: http://itk-insight-users.
2283740.n2.nabble.com/3D-registration-with-level-set-
motion-tp7590137p7590145.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.kitware.com/products/protraining.php
http://www.itk.org/Wiki/ITK_FAQ
http://public.kitware.com/mailman/listinfo/insight-users
--
Samuel Gerber
R&D Engineer
Kitware, Inc.
CocoM
2017-08-04 06:23:47 UTC
Permalink
Thanks a lot, I'm gonna check that!



--
View this message in context: http://itk-insight-users.2283740.n2.nabble.com/3D-registration-with-level-set-motion-tp7590137p7590149.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users
CocoM
2017-08-04 14:19:12 UTC
Permalink
Finally I managed running the algorithm by changing the origin of the moving
image with itkChangeInformationImageFilter. Before that I transformed my
Dicom images into NRRD with DicomSeriesReadImageWrite2. But I got a weird
output for the registration process : the image seems really noisy and is
unsigned int8 instead of int16. Plus the last slices are black. Is there a
special way to write 3D images ? I'm just using the code of
DeformableRegistration5. Or maybe the problem is in the warping step ?

Thanks a lot,
Marie



--
View this message in context: http://itk-insight-users.2283740.n2.nabble.com/3D-registration-with-level-set-motion-tp7590137p7590152.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users
Dženan Zukić
2017-08-04 15:12:47 UTC
Permalink
Hi Marie,

in DeformableRegistration5 you should change typedef of OutputPixelType
from char to short. The "noise" is caused by values over 255 being cast
from short to char.

Regards,
DÅŸenan Zukić, PhD, Senior R&D Engineer, Kitware (Carrboro, N.C.)
Post by CocoM
Finally I managed running the algorithm by changing the origin of the moving
image with itkChangeInformationImageFilter. Before that I transformed my
Dicom images into NRRD with DicomSeriesReadImageWrite2. But I got a weird
output for the registration process : the image seems really noisy and is
unsigned int8 instead of int16. Plus the last slices are black. Is there a
special way to write 3D images ? I'm just using the code of
DeformableRegistration5. Or maybe the problem is in the warping step ?
Thanks a lot,
Marie
--
View this message in context: http://itk-insight-users.
2283740.n2.nabble.com/3D-registration-with-level-set-
motion-tp7590137p7590152.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.kitware.com/products/protraining.php
http://www.itk.org/Wiki/ITK_FAQ
http://public.kitware.com/mailman/listinfo/insight-users
CocoM
2017-08-05 20:00:47 UTC
Permalink
Thanks a lot it's almost working now!

I have another question, about the running time.
I don't know anything about it but I'm surprised by the time needed for the
algorithm to be done. I'm using the example DeformableRegistration5 (level
set PDE solving), but I changed it to use B-spline interpolation. The
running time is huge for 3D ; for 2D it takes a little less than 3 minutes
and for 3D, I need approximately 20 minutes by iteration, so imagine the
time needed by the whole process... My test image is 512x512x43, the
algorithm is multi threads. I'm working on a six years old Asus laptop
(X53S), nothing extraordinary. I couldn't say exactly what my CPU is but
it's a Intel core i5. I know it's not great material but still, I feel like
it's very slow. So could someone tell me if it's normal?

The thing is I didn't change much, so I guess it is, but I wanted to ask
anyway.

Plus, if anyone has any idea to speed up the process, except buying a better
computer, it would be really great!

Thanks a lot,
Marie



--
View this message in context: http://itk-insight-users.2283740.n2.nabble.com/3D-registration-with-level-set-motion-tp7590137p7590155.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users
Dženan Zukić
2017-08-07 02:27:41 UTC
Permalink
Hi Marie,

an obvious thing to ask: are you running it in debug or release mode? The
difference is usually huge.

B-spline registration for your image could take a few minutes - 20 minutes
for a single iteration sounds too long. A classic trick for speeding up
registration is using multi-resolution approach. It usually involves more
code and a lot more testing, though.

Regards,
DÅŸenan Zukić, PhD, Senior R&D Engineer, Kitware (Carrboro, N.C.)
Post by CocoM
Thanks a lot it's almost working now!
I have another question, about the running time.
I don't know anything about it but I'm surprised by the time needed for the
algorithm to be done. I'm using the example DeformableRegistration5 (level
set PDE solving), but I changed it to use B-spline interpolation. The
running time is huge for 3D ; for 2D it takes a little less than 3 minutes
and for 3D, I need approximately 20 minutes by iteration, so imagine the
time needed by the whole process... My test image is 512x512x43, the
algorithm is multi threads. I'm working on a six years old Asus laptop
(X53S), nothing extraordinary. I couldn't say exactly what my CPU is but
it's a Intel core i5. I know it's not great material but still, I feel like
it's very slow. So could someone tell me if it's normal?
The thing is I didn't change much, so I guess it is, but I wanted to ask
anyway.
Plus, if anyone has any idea to speed up the process, except buying a better
computer, it would be really great!
Thanks a lot,
Marie
--
View this message in context: http://itk-insight-users.
2283740.n2.nabble.com/3D-registration-with-level-set-
motion-tp7590137p7590155.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.kitware.com/products/protraining.php
http://www.itk.org/Wiki/ITK_FAQ
http://public.kitware.com/mailman/listinfo/insight-users
CocoM
2017-08-07 10:47:30 UTC
Permalink
Hi Dženan,

Thanks a lot for your answer! I was indeed using debug mode, release mode is
much better : one iteration for 3D takes now 40 seconds.

Cheers,
Marie



--
View this message in context: http://itk-insight-users.2283740.n2.nabble.com/3D-registration-with-level-set-motion-tp7590137p7590159.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kit

Continue reading on narkive:
Loading...