SimpleITK images are either 2D, 3D, or 4D and can have an arbitrary number of channels with a scalar or complex value in each channel.
However, I can’t go much further than to create an empty complex image. If I try to export that image as a numpy array I get the error message
RuntimeError: Images of Complex Pixel types currently are not supported.
I get similar error if I try to create a image from a complex numpy array, or if I try the slicing operators on my complex image.
Will this support be added? Otherwise I think it is a bit misleading to state that SimpleITK support complex values, when all you can do is create an empty complex image.
You are quite right that the complex support for the GetArrayFromImage and GetImageFromArray methods are missing! Can you please create an issue in SimpleITK on Github?
The support for complex images in SimpleITK has focused of course on the Image class, FFTs, image math, image grid operations and of course IO.
Here is quick grok at a list of filters which support complex pixel types in SimpleITK:
AddImageFilter
BinShrinkImageFilter
CastImageFilter
CheckerBoardImageFilter
ComplexToImaginaryImageFilter
ComplexToModulusImageFilter
ComplexToPhaseImageFilter
ComplexToRealImageFilter
CropImageFilter
CyclicShiftImageFilter
DivideImageFilter
ExtractImageFilter
FFTShiftImageFilter
FlipImageFilter
HalfHermitianToRealInverseFFTImageFilter
InverseFFTImageFilter
JoinSeriesImageFilter
LabelMapMaskImageFilter
MaskImageFilter
MirrorPadImageFilter
MultiplyImageFilter
NaryAddImageFilter
PasteImageFilter
PermuteAxesImageFilter
PowImageFilter
RegionOfInterestImageFilter
ShrinkImageFilter
SliceImageFilter
SubtractImageFilter
TernaryAddImageFilter
TileImageFilter
UnaryMinusImageFilter
WrapPadImageFilter
ZeroFluxNeumannPadImageFilter
I did notice that the ResampleImageFilter is not on that list. As I recall not all ITK interpolators worked with complex pixels so it would not be an easy task to add resample support.
Are there filters you tried to use with complex images?
Thanks for the quick reply! I will create an issue on GitHub. Wow, there are quite a few filters that support complex images, I’m pleasantly surprised I tried the MedianImageFilter, and that did not work (maybe not surprisingly, I don’t know how that would work). I also tried the WriteImage filter, and it produced an mhd file pixel type MET_FLOAT with two channels, so I assume that’s in order.
Would it be possible to add the interpolators that do work for complex images, in order to get ResampleImageFilter to work? I think that would be a useful function, even though it would be limited.
The Resample operations would be separable, meaning that you could do the operation twice on the imaginary then the real component of the complex number.
The usage of complex number images have typical been limited to operations related to FFT operations and basic math. I am curious if you have a driving problem, or if you are simply curious of what can be done with complex numbers in SimpleITK?
I’m mostly curious of how SimpleITK handles complex numbers. I work with MRI images, which are complex at their core, so I’m currently exploring what support the SimpleITK image class has for these types of applications.
I recall asking about ResampleImageFilter in ITK itself and complex numbers some time ago and receiving a similar answer about the interpolators (something to do with complex numbers not having a natural ordering). If any support for resampling complex-images could be added to ITK I would be very, very grateful. I regularly have to resample complex-valued images and having to split them into real and imaginary components, resample, and then recombine is highly annoying.