Reading DICOM in ITK, showing with right orientation in VTK

View: New views
2 Messages — Rating Filter:   Alert me  

Reading DICOM in ITK, showing with right orientation in VTK

by Lodron, Gerald :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,
 
I currently succesfully read a 3D dicom file with itk::ImageSeriesReader and write the image into an itk::OrientedImage< signed short, 3 >. After that i convert the image to VTK using the ImageToVTKImageFilte and visualized it. My problem is that the orientation is wrong (the head in the DICOM image is downside, the feets are on the upside). In the DICOM file there should be a Orientation tag which should refer to left/right etc. How can I connect this information so that an arbitrary DICOM image is always displayed correctly (from front side with the head upside)? Here is my current code:

PS: Is there a possibility tho get the data type form the DICOM, currently I always read signed short and i am not sure if this is correct for every dicom.

typedef signed short PixelType;
const unsigned int Dimension = 3;

 
Typedef itk::OrientedImage< PixelType, Dimension > ImageType;
typedef itk::ImageSeriesReader< ImageType > ReaderType;
typedef itk::GDCMImageIO ImageIOType;
typedef itk::ImageToVTKImageFilter<ImageType> ITKVTKConnectorType;
typedef itk::GDCMSeriesFileNames NamesGeneratorType;

ReaderType::Pointer  m_Reader = ReaderType::New();
ImageIOType::Pointer m_DicomIO = ImageIOType::New();
NamesGeneratorType::Pointer m_NameGenerator = NamesGeneratorType::New();
ITKVTKConnectorTypePointer m_Connector = ITKVTKConnectorType::New();

m_Reader->SetImageIO( m_DicomIO );
m_NameGenerator->SetUseSeriesDetails( true );
m_NameGenerator->SetDirectory( path );

Std::vector<std::string> m_strUIDs = m_NameGenerator->GetSeriesUIDs();
Std::string m_strFileNames = m_NameGenerator->GetFileNames(m_strUIDs.at(0) );
m_Reader->SetFileNames( m_strFileNames );
m_Reader->Update();

m_Connector->SetInput(m_Reader->GetOutput());
m_Connector->Update();
vtkImageData* vtkIm = m_Connector->GetOutput();

//Visualization, e.g. image plane widget example
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.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

Re: Reading DICOM in ITK, showing with right orientation in VTK

by Luis Ibanez :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Gerald,

The vtkImageData does not have a representation for image orientation.

Therefore, when you convert an itk::Image or an itk::OrientedImage into
a vtkImageData, you are necessarily loosing that orientation information.

You  could manually grab that information from the itk::Image, and use it
in order to setup the Transform of the actor with which you are visualizing
the image in VTK.

For an example on how to correctly display DICOM images with VTK
you may want to look at the "Image Guided Surgery Toolkit" IGSTK:

In particular,
you may want to look at the following IGSTK classes:

* igstkImageSpatialObject
* igstkImageResliceObjectRepresentation


  Regards,


            Luis


---------------------------------------------------
On Wed, Nov 4, 2009 at 3:07 AM, Lodron, Gerald
<Gerald.Lodron@...> wrote:

> Hello,
>
> I currently succesfully read a 3D dicom file with itk::ImageSeriesReader and write the image into an itk::OrientedImage< signed short, 3 >. After that i convert the image to VTK using the ImageToVTKImageFilte and visualized it. My problem is that the orientation is wrong (the head in the DICOM image is downside, the feets are on the upside). In the DICOM file there should be a Orientation tag which should refer to left/right etc. How can I connect this information so that an arbitrary DICOM image is always displayed correctly (from front side with the head upside)?     Here is my current code:
>
> PS: Is there a possibility tho get the data type form the DICOM, currently I always read signed short and i am not sure if this is correct for every dicom.
>
> typedef signed short            PixelType;
> const unsigned int              Dimension = 3;
>
>
> Typedef itk::OrientedImage< PixelType, Dimension >                      ImageType;
> typedef itk::ImageSeriesReader< ImageType >                             ReaderType;
> typedef itk::GDCMImageIO                                                        ImageIOType;
> typedef itk::ImageToVTKImageFilter<ImageType>                           ITKVTKConnectorType;
> typedef itk::GDCMSeriesFileNames                                                NamesGeneratorType;
>
> ReaderType::Pointer  m_Reader = ReaderType::New();
> ImageIOType::Pointer m_DicomIO = ImageIOType::New();
> NamesGeneratorType::Pointer m_NameGenerator = NamesGeneratorType::New();
> ITKVTKConnectorTypePointer m_Connector = ITKVTKConnectorType::New();
>
> m_Reader->SetImageIO( m_DicomIO );
> m_NameGenerator->SetUseSeriesDetails( true );
> m_NameGenerator->SetDirectory( path );
>
> Std::vector<std::string> m_strUIDs = m_NameGenerator->GetSeriesUIDs();
> Std::string m_strFileNames = m_NameGenerator->GetFileNames(m_strUIDs.at(0) );
> m_Reader->SetFileNames( m_strFileNames );
> m_Reader->Update();
>
> m_Connector->SetInput(m_Reader->GetOutput());
> m_Connector->Update();
> vtkImageData* vtkIm = m_Connector->GetOutput();
>
> //Visualization, e.g. image plane widget example
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.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
>
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.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