0

I'm trying to define an empty ITK image of a certain 3D size on iPython notebook and I'm stuck at defining the so called:

'itkIndex3' index

I've already loaded all python bindings for itk and vtk, and defined the different types (In this case a float 3-D image of size 80 and voxel size 0.5 mm), but still I'm not able to fill it with any value. Here's the code so you can have a look:

# Tools for Biomedical Imaging
import nibabel as nib
import itk
import vtk

start = itk.Index[3]
size = itk.Size[3]
start.Fill(0)

-----------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/home/administrator/<ipython-input-63-8774101ef8fb> in <module>()
      1 start = itk.Index[3]
      2 size = itk.Size[3]
----> 3 start.Fill(0)

Fill() must be called with itkIndex3 instance as first argument (got int instance instead)

Maybe it's a complete stupid question, but I would really appreciate someone to shed some light on which may be the error while defining the 'filling' value.

Thanks in advance!!

-------------------------------------------------------------------
-------------------------------------------------------------------

Hi!, I think I was able to solve the issue with a different approach, I will include the code I used to create the 3D float image for everyone to see it ;)!

nii_PixelType = itk.F    # Read the image, also possible using nibabel
nii_ImageType = itk.Image[nii_PixelType, 3]

def CreateBaseAtlas(total_Size):

    # Created based on the code in:
    # http://www.itk.org/Wiki/ITK/Examples/ImageProcessing/ResampleImageFilter
    image = nii_ImageType.New()
    _start=[0,0,0]
    _size=[total_Size,total_Size,total_Size]
    _region = itk.ImageRegion._3(_start,_size)
    image.SetRegions(_region)
    image.Allocate()
    image.FillBuffer(0)   

    return image

I think the reason it was not working is just because I didn't write it directly as a vector. In ITK they do it in a different way: http://www.itk.org/Wiki/ITK/Examples/ImageProcessing/ResampleImageFilter

Ciller
  • 13
  • 6
  • That error usually means that you're trying to use a class object where you should be using an instance of that class. You can try `start().Fill(0)`, but I don't know anything about ITK. – Thomas K May 31 '13 at 12:21
  • I changed a pair of things and now it seems to be working OK! Thanks for the answer! And check above for the solution! – Ciller May 31 '13 at 12:57

0 Answers0