Moving IJ scripts to python native - modules/libraries?

Hi all,

I’ve got a set of very long macros done in ImageJ that I need to move over to python instead. These macros operate on dicom phantom images (2D only, typically int32 data) to do various analysis steps.

I’ve already put together a registration module for this using simpleITK, and now are looking to get the actual “analysis” part done.

So what I’m looking for advice on is what python libraries would be the “best” (ie easy to code, fast, robust) for a couple of typical ImageJ operations. I could code it all by hand, but I’m guessing there are already modules to do it - but I’m not sure which as I’m new to the whole python scene. So what I’d love is people’s thoughts on what’s good to use.

  • “Region” definition, measurement and display - equivalent to the ImageJ region definition tools and “measure”

I need to be able to arbitrarily define “regions” in an image, and the a) take simple measurements over that region (mean value, std dev etc) and b) have that region be easily displayable as an overlay (coloured, vector based if possible, sub-pixel size/location) in an output copy of the image.

By “region” here I need rectangle, ellipse and arbitrary polygon (rectangle/ellipse are not only orthogonal to the axis, but can have rotation).

  • “Wand” region definition, with region “characterisation”

I would like to be able to create a region in an image with a “wand” type IJ tool that takes a point and then grows a region outwards from that based on thresholded pixel values. The region can then be “characterised” in terms of a) it’s centre, it’s centre of mass (weighted centre), is bounding box size and it’s circularity (fitted ellipse, with main/minor lengths and angles) (So IJ measure on a selection)

Take a look at scikit-image. It doesn’t fulfill all your requirements … in particular regions are not vector-based but based on label images. You then have tools such as regionprops that will let you take the measurements you’re interested in. Having label images vs. vector-based regions has some advantages (it is clear which pixels are part of the region) and some disadvantages (no trivial support for overlapping regions).

You might want to have a look at ImagePy too. It offers a gui similar to ImageJ’s one and allow to call any python library. There are a number of built-in tools.
It’s still in Beta version though.

Thanks!

Actually stumbled onto it, and it looks like I’ll go with using it

Thanks - I’ll check it out