VTK image IO and direction matrix

Hi all,

In 2010 @blowekamp contributed a VTK Image IO module available here. I’m looking through the current incarnation and, unlike the ‘spacing’ and ‘origin’ information, can’t find where the direction is read in. Am I missing something?

Thanks,
Nick

1 Like

There has been some effort towards supporting image direction in VTK, but no released version supports it. Therefore, it is not supported by VTK image format.

Reference to the conversation about supporting Direction in the VTK forums: https://discourse.vtk.org/t/proposal-to-add-orientation-to-vtkimagedata-feedback-wanted/120

1 Like

Thanks @dzenanz and @phcerdan—very helpful.

I guess this follow-up question is more for the ITK community but since some algorithms in ITK assume the existence of a direction, wouldn’t it be important for something like a warning to be provided in reading in a VTK image instead of simply assigning the identity matrix?

Nick

Should the same warning be issued for PNG, BMP etc formats? Such a warning would probably not be very useful.

I would disagree about the utility of such a warning (for any format) for the same reasons but I’m certainly fine with whatever the community decides.

It may be that the application should warn when the format or particular image format does not support direction, spacing or origin. However, there is not current way to know if the ImageIO or file has those informations.

It could be a useful feature for the ImageIO to report if it used the default meta-data or if it is provided by the file.

Hi @blowekamp,

Just to clarify, I’m not advocating for any particular change. Now that I know this about the vtk image file format, I’ll simply work around this issue. I guess I’m more surprised than anything. It seems like, as a community, we’ve had this understood stringency with respect to the physical consistency of images and other objects. For example, I’m thinking of the check that you put in, if I remember correctly, the ImageToImageFilter where consistency in spacing, origin, and direction is strictly enforced. I also remember from the old insight-users list where Luis cautioned somebody about using the ChangeImageInformationFilter and advocated (paraphrasing) “you should think about it first, then grab a cup of coffee, and think about it some more.”

If the community doesn’t think a warning is good idea, or if changing the ImageIO to explicitly set some sort of flag (as you mention) is not a good option, there are other possibilities. For example, assigning the direction to be identity is completely arbitrary. But it’s not only arbitrary, it’s perhaps the most common set of values for that variable. So not only is the information changed from an unknown quantity to an arbitrary value, that arbitrary value has a greater likelihood of bypassing the check that you put in. An alternative to a warning or flag could be to simply assign a random rotation (and/or random spacing, origin, etc.) when that field is not specified.

Again, I’m not attached to any particular solution (including the status quo). Just thought I’d clarify a bit with some additional thoughts.

Nick

1 Like

Hi @ntustison ,
you really hit a big nail on the head here!

IMHO it should not be a warning but an error :wink: in case you are planing to do anything in world/real space. Run algos, co-register and/or combine multimodalities (very common these days).

HOWEVER it is fine if you just do image analysis!

What I mean, it is fine finding a lession in image space but not if you plan to send that information to a surgical navigator!

One way to go around is to force images in 1x1x1 axis aligned world space then perform transformation in according to space information from the image header.

Certainly, any file format not supporting orientation (too many) should be banned from the medical field asap.

Just my 2cts, I think this is especially true when saving an image with an IO that does not support saving direction information. I am personally less worried about this at reading time since everytime I read an image, the same information (identity matrix) is added automatically.

1 Like

This make since to me, too.

Warning when information is being lost when saving images is the bare minimal which should occour.

I use ITK for microscopy image analysis where the direction cosine matrix is almost always identity. But here we struggle with preserving the xyz image spacing, never mind the origin.