Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

4D Indexing / Casting #19

Closed
gattia opened this issue Feb 26, 2016 · 4 comments
Closed

4D Indexing / Casting #19

gattia opened this issue Feb 26, 2016 · 4 comments

Comments

@gattia
Copy link
Contributor

gattia commented Feb 26, 2016

This was a little bit of a goose chase where there seemed to be lots of road blocks preventing me from visualizing the 4D data created from groupwise registration. There are potentially a couple of issues here... or its just me.

When trying to visualize I tried to use indexing to get each individual volume from the 4D image but was unable to index the 4D data in the same way that I index 3D data.
participantOne = resultImage[:,:,:,0]. The error is simply

invalid index

Then, as an alternate solution, I tried to use extractor = sitk.ExtractImageFilter() and it also threw an error

ERROR: Pixel type: 16-bit signed integer is not supported in 4D by N3itk6simple18ExtractImageFilterE or SimpleITK compiled with SITK_4D_IMAGES set to OFF.

The error indicates it is because of the data type (but maybe this is because the image is 4D, I know this was the case with JoinSeries) - my SimpleElastix was built with 4D ON. To try and resolve this and see if it was truly the data type, I tried to cast the resultImage to something else using UInt16ResultImage = sitk.Cast(resultImage, sitk.sitkUInt16) and this didn't work (again maybe because it's 4D?).

So, to test if it was the 4D or the pixel-type, I went back to the images before the groupwise registration and to see if I could cast them to a different type before the registration, assuming this carried through to the post registration. I am able to cast these, but the elastix groupwise registration seems like it won't work on anything except the original image (it's a short). It indicated that this error was again due to the pixel type and that this could be changed either in the cmake or in the elastix parameters.

ERROR:
FixedImageType: 4D float
MovingImageType: 4D float
elastix was not compiled with this combination of ImageTypes!
You have two options to solve this:

  1. Add the combination to the CMake parameters ELASTIX_IMAGE_nD_PIXELTYPES and ELASTIX_IMAGE_DIMENSIONS, re-cmake and re-compile.
  2. Change the parameters FixedInternalImagePixelType and/or MovingInternalImagePixelType in the elastix parameter file.

ERROR:
Something went wrong in the ComponentDatabase
Errors occurred!

So, based on this, I tried to alter the paramtermap for 'groupwise' registration to coincide with the data. I may have been doing this incorrectly. But I tried to alter it to float as is recommended in the Elastix documents using:
groupwiseParameterMap = sitk.GetDefaultParameterMap('groupwise') groupwiseParameterMap['FixedInternalImagePixelType'] = ['float'] groupwiseParameterMap['MovingInternalImagePixelType'] = ['float']
I then used groupwiseParameterMap as the input for elastix.SetParameterMap() and it still gave the same error.

The other alternate for the Elastix groupwise registration is to alter something in the make file but since I built SimpleElastix this wasn't something that I had access too. My next step was to build my own elastix/ITK.

In short. I had issues with:

  1. Indexing 4D images
  2. Casting 4D images
  3. Groupwise registration with anything but short data.
  4. ExtractImageFilter with 4D data
  5. Maybe with setting parameters... though Im not positive if I was doing it correctly.

Sorry for the long post but I thought it was better to be thorough.

Anthony.

@kaspermarstal
Copy link
Member

As you suggest, the issues with casting 4D images and extracting 3D volumes from 4D images is indeed the same as with the JoinSeries filter - it is not supported yet. Will fix this!

Elastix is only compiled with short pixel type for 4D by default. This will be changed in the next version to include all basic pixel types (chars, shorts, ints, unsigned equivalents, float and double).

Indexing for 4D is not supported in SimpleITK and beyond my SWIG skills 😊

@gattia
Copy link
Contributor Author

gattia commented Feb 26, 2016

Thanks for the reply and explaining a bit of why some of the functions don't work. Indexing would be great but is not needed it seems like extracting should yield the same result.

@kaspermarstal
Copy link
Member

Try a doing a git pull. There should now be support for casting 4D images, joining 3D images into 4D images and extracting 3D images from 4D images.

@gattia
Copy link
Contributor Author

gattia commented Mar 3, 2016

Thanks for the update. It works now!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants