Nonrigid image registration in Python

2,953 views
Skip to first unread message

almar...@gmail.com

unread,
Oct 6, 2016, 4:21:32 AM10/6/16
to scikit...@googlegroups.com

Hi,

 

A student recently asked me about (medical) image registration in Python. I had to tell him that there is currently hardly anything like that in Python.

 

I was frustrated enough about this that I decided to turn a piece of code from my PhD work into a usable library. It’s a thin wrapper around the awesome Elastix image registration toolkit. I figure/hope that because its so thin, it won’t need much maintenance, and/or is easy to maintain by others. The code and docs are on Github: https://github.com/almarklein/pyelastix Further, the package is on conda-forge and Pypi.

 

Aside from this announcement, I’d like to propose to put together a list of Python packages that do (nonrigid) image registration. Since efforts in Python-based image registration have only resulted in relatively small and unknown packages, it would be good to have an overview. What would be a good place for this? Maybe a wiki-page on scikit-image’s Gitub repo?

 

Two entries I would add:

-        Kasper Marstal’s SimpleElastix: https://github.com/kaspermarstal/SimpleElastix (also based on Elastix, but compiled against it instead of wrapping the CLI). It’s hard to compile, but Kasper is currently working on putting it on conda-forge.

-        During my PhD I developed PIRT (https://bitbucket.org/almarklein/pirt), which uses Cython. It’s a bit idiosyncratic, so it will need work to make “generally useful”. I don’t have the time to do this, let alone maintain it when people start using it.

 

Regards,

  Almar

jeff witz

unread,
Oct 14, 2016, 6:54:04 AM10/14/16
to scikit-image
Hi,

It seems indeed that there is no solution in python. I have tested SimpleElastix which is clearly great as Elastix is the main OpenSource software for Image Registration and Plastimatch is very efficent too.
SimpleITK is now able to perform Image Registration  (http://insightsoftwareconsortium.github.io/SimpleITK-Notebooks/56_VH_Registration1.html)
The main issue you have with python and image registration is the scalability. For example interpoler for getting the transformation at a non integer coordinate is not efficient in numpy/scipy. The memory limit is reached with 2048x1024 images with griddata with 8Go of Ram for example. It means that there is a lot of work to be done at this level. It seems that you have done work in your project.
Is you multivariate interpolation implementation is scalable ? For example I couldn't apply an elastic transform on image larger than 2048x1024 with scipy. If your able to to so, maybe you should contribute to scipy and improve the interpolation module which is currently the biggest bottleneck for Image Registration.

Image registration is a vast field, you have, global, local elastix, you can use classical metric minimization on a transform or working with demons where the framework is a little bit different.


I think that if you are a simple user SimpleITK and SimpleElastix are not too bad. But if you want to develop techniques it is more complicated

Stefan van der Walt

unread,
Oct 14, 2016, 7:39:19 PM10/14/16
to scikit...@googlegroups.com
Hi Jeff

On Fri, Oct 14, 2016, at 03:54, jeff witz wrote:
Is you multivariate interpolation implementation is scalable ? For example I couldn't apply an elastic transform on image larger than 2048x1024 with scipy. If your able to to so, maybe you should contribute to scipy and improve the interpolation module which is currently the biggest bottleneck for Image Registration.

I'm pretty sure both ndimage and scikit-image can handle larger images than that.  Did you see these fail in practice?

Stéfan


jeff witz

unread,
Oct 17, 2016, 5:15:39 AM10/17/16
to scikit-image
Last time I've tried on skimage I think that I didn't do really understand how it works. As you seem pretty confident, I take a little time to study it. As I often switch between OpenCV and skimage I've performed the coordinate interpolation using both methods. I've also used the scipy.interpolation.griddata which is the only one that I figure out to make work.
As usual OpenCV is  6x faster but skimage perform good even with 4096x4096 images.

I just create a disk and transform it in ellipse using warping function.

For Ndimage, you can find an example of geometric_transform, but it doesn't work for me, map_coordinate is not suited for a full image mapping.
Interpolation_test.py

Stefan van der Walt

unread,
Oct 31, 2016, 5:12:23 PM10/31/16
to jeff witz, scikit-image
Hi Jeff

On Mon, Oct 17, 2016, at 02:15, jeff witz wrote:
For Ndimage, you can find an example of geometric_transform, but it doesn't work for me, map_coordinate is not suited for a full image mapping.

We have accelerated warping implemented for certain kinds of interpolation, but fall back to ndimage for more complicated cases.  Inside the transform module, there are some examples of how we use map_coordinates underneath the hood.  The fast version is implemented in Cython.

Thanks for the new benchmark!

Stéfan

almar...@gmail.com

unread,
Jan 13, 2017, 4:13:01 AM1/13/17
to Stefan van der Walt, scikit-image

The list of Python projects  related to image registration is up!

 

http://pyimreg.github.io/

 

It’s implemented as a single index.md file in a github repo. I filled in the projecs that were mentioned in this thread. If you have more to add, or suggestions for improvement, go ahead and make a PR. I think that the description about skimage’s support for image registration needs some improvement.

 

Regards,

  Almar

--
You received this message because you are subscribed to the Google Groups "scikit-image" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image...@googlegroups.com.
To post to this group, send email to scikit...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/scikit-image/1477948341.1324573.773114217.03CCC86D%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.

 

Stefan van der Walt

unread,
Jan 31, 2017, 7:10:51 PM1/31/17
to scikit...@googlegroups.com
On Fri, Jan 13, 2017, at 01:12, almar...@gmail.com wrote:

The list of Python projects  related to image registration is up!

 

http://pyimreg.github.io/



Best regards
Stéfan

Reply all
Reply to author
Forward
0 new messages