Mean of Complex Vector Image

Hi,

I need to take the average (mean) of a complex-valued vector image (i.e. the output should also be a complex vector). I am trying to do this with itk::StatisticsImageFilter, however, I am getting the following compile error:

  typedef typename vnl_numeric_traits<T>::abs_t abs_t;
                   ^
/usr/local/include/ITK-4.13/vnl/vnl_vector.h:300:20: note: in instantiation of template class 'vnl_c_vector<itk::VariableLengthVector<std::__1::complex<double> > >' requested here
  typedef typename vnl_c_vector<T>::abs_t abs_t;
                   ^
/usr/local/include/ITK-4.13/itkArray.h:50:42: note: in instantiation of template class 'vnl_vector<itk::VariableLengthVector<std::__1::complex<double> > >' requested here
class ITK_TEMPLATE_EXPORT Array : public vnl_vector< TValue >
                                         ^
/usr/local/include/ITK-4.13/itkStatisticsImageFilter.h:173:27: note: in instantiation of template class 'itk::Array<itk::VariableLengthVector<std::__1::complex<double> > >' requested here
  Array< RealType >       m_ThreadSum;
                          ^
../Source/Utils/qi_coil_combine.cpp:111:27: note: in instantiation of template class 'itk::StatisticsImageFilter<itk::VectorImage<std::__1::complex<float>, 3> >' requested here
        auto stats = itk::StatisticsImageFilter<QI::VectorVolumeXF>::New();
                          ^
/usr/local/include/ITK-4.13/vnl/vnl_numeric_traits.h:38:27: note: template is declared here
class VNL_TEMPLATE_EXPORT vnl_numeric_traits;

I assume this is because someone assumed no-one would be crazy enough to want a complex-vector mean, and so the required traits aren’t defined. Is it possible for me to define them myself and if so where?

Thanks.

Hello Tobias,

The StatisticsImageFilter does not work with ImageVectors, Images of Vectors or complex pixel types, much less ImageVectors of complex. This is because the filter computes the Minimum and Maximum, and those listed image type’s pixels types do not form an ordered set, that is the less than operator has not meaning for vectors or complex types.

One could argue that there should be two Statistics filters, one for pixels of ordered set and one for un-ordered, because Mean, Sum, and Variance could still have meaning.

Brad

2 Likes

Thanks Brad. Yes, some kind of “Reduce Region” filter that applies a single function (e.g. sum) might be useful. Variance might be a bit tricky.

Can you think of any other filters that might help me in the mean-time? Getting just the sum would do. As always I’m in a rush.

Would just manually using an ImageRegionIterator with accumulation work for you?

1 Like

Yes - that’s essentially what I ended up doing. Thanks!