statismo/statismo — pull request #53 by tom-albrecht (2014-07-04 07:19:36+00:00)
Title: use GetArray(0) instead of GetScalars()

Elastix writes its registration results into the vectors (ds->GetPointData()->GetVectors()) instead of the scalars (ds->GetPointData()->GetScalars()). This results in a null pointer when the scalars are gotten in line 326.

We want a way to treat both cases, scalars and vectors. I propose to use GetArray(0). This gets the first array of the point data, no matter if this is a scalar or vector array.

However, there is one scenario in which this may fail: If the image has several arrays, GetArray(0) may not return the one we actually want. This never happens for .vtk images written by ITK, because they only have one array. But in VTK you can actually add a bunch of arrays (scalars, vectors, tensors etc.) to the PointData, and we do not know if Array(0) is the one we actually want.

I still think this solution is best, because even if we just use GetScalars(), the image may have several scalar arrays and we do not know which one we want and get. So the new solution is only slightly more unsafe. I guess I will add a little warning in the documentation of the representer.