[Insight-users] 4D itkImage to vtkImageData

Antoine DUCHAMPS antoine.duchamps at gmail.com
Tue Apr 14 09:05:14 EDT 2009


Hi Luis,

Thanks for responding. I wonder if there is way of reading a 4D sequence
in *voxel* interleaved mode instead of *volume* interleaved mode. If so,
the image intensities corresponding to different gradient values would
be together in memory and I could make a simple memcpy between itkImage
and vtkImageData buffers ...

Regards,

Antoine   


Le mercredi 08 avril 2009 à 12:03 -0400, Luis Ibanez a écrit :
> Hi Antoine,
> 
> VTK doesn't support 4D images.
> 
> You may have to split it into a series of 3D images.
> 
> What you need then is the ImageReadSeriesWriter example.
> 
> Change the input image type to 4D and the output image
> type to 3D.
> 
> The provide the output file pattern as a name with
> extesion ".vtk".
> 
> You should end up with 60 .vtk files each one
> containing a 3D image.
> 
> 
>     Regards,
> 
> 
>         Luis
> 
> 
> -----------------------
> Antoine DUCHAMPS wrote:
> > Hi All,
> > 
> > I have a 4D DWI sequence 128 x 128 x 41 x 60 in size (xsize x ysize x
> > zsize x number of gradient orientations). I need to read it and convert
> > it to VTKImageData in order to estimate the tensors with slicer. I tried
> > to use itkImageToVTKImageFilter.h as shown in the code below but the
> > resulting vtkImageData contains only one scalar component (see the
> > output of connector -> GetOutput() -> Print(std::cout); ), whereas I
> > would have expected 60 (one for each gradient direction). Is this the
> > expected behavior or I'm doing something wrong? How is coded the 4th
> > dimension?
> > 
> > NOTE: The sequence I'm using for testing is in a single nii file, which
> > is passed as argument in the command line.
> > 
> > Thanks! ,
> > 
> > Antoine
> > 
> > --
> > 
> > #include "itkOrientedImage.h"
> > #include "itkImageFileReader.h"
> > #include "itkImageFileReader.h"
> > #include "itkImageToVTKImageFilter.h"
> > 
> > 
> > int main( int argc, char ** argv )
> > 
> > {
> >   typedef unsigned short      PixelType;
> >   const   unsigned int        Dimension = 4;
> > 
> >   typedef itk::OrientedImage< PixelType, Dimension >   ImageType;
> >   typedef itk::ImageFileReader< ImageType >    ReaderType;
> >   typedef itk::ImageToVTKImageFilter< ImageType > ConnectorType;
> >   
> >   ReaderType::Pointer reader = ReaderType::New();
> >   ConnectorType::Pointer connector = ConnectorType::New();
> >     
> >   reader->SetFileName(argv[1]);
> >   reader->Update();
> >   connector -> SetInput(reader->GetOutput());
> >   connector -> Update();
> >   connector -> GetOutput() -> Print(std::cout);
> > 
> >   return 0;
> > }
> > 
> > 
> > --
> > 
> > vtkImageData (0x1b49ac0)
> >   Debug: Off
> >   Modified Time: 216
> >   Reference Count: 1
> >   Registered Events: (none)
> >   Source: (none)
> >   Information: 0x1b49c30
> >   Data Released: False
> >   Global Release Data: Off
> >   UpdateTime: 217
> >   Release Data: Off
> >   UpdateExtent: Not Initialized
> >   UpdateExtent: 0, 127, 0, 127, 0, 40
> >   Update Number Of Pieces: 1
> >   Update Piece: 0
> >   Update Ghost Level: 0
> >   WholeExtent: 0, 127, 0, 127, 0, 40
> >   ExtentTranslator: (0x1b43de0)
> >   RequestExactExtent: Off
> >    Field Data:
> >     Debug: Off
> >     Modified Time: 196
> >     Reference Count: 1
> >     Registered Events: (none)
> >     Number Of Arrays: 0
> >     Number Of Components: 0
> >     Number Of Tuples: 0
> >   Number Of Points: 671744
> >   Number Of Cells: 645160
> >   Cell Data:
> >     Debug: Off
> >     Modified Time: 203
> >     Reference Count: 1
> >     Registered Events: (none)
> >     Number Of Arrays: 0
> >     Number Of Components: 0
> >     Number Of Tuples: 0
> >     Copy Tuple Flags: ( 1 1 1 1 1 0 1 )
> >     Interpolate Flags: ( 1 1 1 1 1 0 0 )
> >     Pass Through Flags: ( 1 1 1 1 1 1 1 )
> >     Scalars: (none)
> >     Vectors: (none)
> >     Normals: (none)
> >     TCoords: (none)
> >     Tensors: (none)
> >     GlobalIds: (none)
> >     PedigreeIds: (none)
> >   Point Data:
> >     Debug: Off
> >     Modified Time: 215
> >     Reference Count: 1
> >     Registered Events: (none)
> >     Number Of Arrays: 1
> >     Array 0 name = NULL
> >     Number Of Components: 1
> >     Number Of Tuples: 671744
> >     Copy Tuple Flags: ( 1 1 1 1 1 0 1 )
> >     Interpolate Flags: ( 1 1 1 1 1 0 0 )
> >     Pass Through Flags: ( 1 1 1 1 1 1 1 )
> >     Scalars: 
> >       Debug: Off
> >       Modified Time: 212
> >       Reference Count: 1
> >       Registered Events: (none)
> >       Name: (none)
> >       Data type: unsigned short
> >       Size: 671744
> >       MaxId: 671743
> >       NumberOfComponents: 1
> >       Information: 0
> >       Name: (none)
> >       Number Of Components: 1
> >       Number Of Tuples: 671744
> >       Size: 671744
> >       MaxId: 671743
> >       LookupTable: (none)
> >       Array: 0x7f6bebeee010
> >     Vectors: (none)
> >     Normals: (none)
> >     TCoords: (none)
> >     Tensors: (none)
> >     GlobalIds: (none)
> >     PedigreeIds: (none)
> >   Bounds: 
> >     Xmin,Xmax: (-50.1938, 197.853)
> >     Ymin,Ymax: (121.044, 369.091)
> >     Zmin,Zmax: (-100.059, 39.9414)
> >   Compute Time: 0
> >   ScalarType: 5
> >   NumberOfScalarComponents: 1
> >   Spacing: (1.95312, 1.95312, 3.5)
> >   Origin: (-50.1938, 121.044, -100.059)
> >   Dimensions: (128, 128, 41)
> >   Increments: (0, 0, 0)
> >   Extent: (0, 127, 0, 127, 0, 40)
> > 
> >  
> > 
> > 
> > _____________________________________
> > Powered by www.kitware.com
> > 
> > Visit other Kitware open-source projects at
> > http://www.kitware.com/opensource/opensource.html
> > 
> > Please keep messages on-topic and check the ITK FAQ at: http://www.itk.org/Wiki/ITK_FAQ
> > 
> > Follow this link to subscribe/unsubscribe:
> > http://www.itk.org/mailman/listinfo/insight-users
> > 



More information about the Insight-users mailing list