[Insight-users] Can not change the image orientation (patient), itk 4.2.1

Xiaoping Chen xpchen5871 at gmail.com
Tue Jan 8 10:08:45 EST 2013


I have an source 3D image of MR (sagittal, with image orientation:
0\1\0\0\0\-1) and I’ve created a new 3D image by duplicating it or using it
as a template. Then, I write a 2D DICOM series out. I expect the same image
orientation but instead it is 1\0\0\0\1\0 (axial).  Why?



I tried to override the tag of the DICOM with image orientation:
0\1\0\0\0\-1, it did not work. Then I use itk::OrientImageFilter to change
to coronal but the image orientation tag is still 1\0\0\0\1\0 (axial) even
though the image orientation has changed.



Why can I change the value of the DICOM tag: image orientation (patient)?
I need to match the image orientation (patient) with the real orientation
of the 3D image( the image is sagittal, the head of dicom has to be
sagittal, not axial).



Please help!  Thanks.



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

The code samples



//create a new 3D image from an existing one



ImageType_SignedShort::Pointer ctImage = ImageType_SignedShort::New();

pImage->SetRegions(m_vMRScanClass[0].Reader->GetOutput()->GetRequestedRegion());

pImage->SetSpacing(m_vMRScanClass[0].Reader->GetOutput()->GetSpacing());

pImage->SetDirection(m_vMRScanClass[0].Reader->GetOutput()->GetDirection());

pImage->SetMetaDataDictionary(m_vMRScanClass[0].Reader->GetOutput()->GetMetaDataDictionary());

pImage->Allocate();

pImage->FillBuffer(0);





//duplicate an exsing 3D image

ImageType_SignedShort::Pointer ctImageTest = ImageType_SignedShort::New();

typedef itk::ImageDuplicator< ImageType_SignedShort >  DuplicatorType;

DuplicatorType::Pointer duplicator = DuplicatorType::New();

duplicator->SetInputImage(m_vMRScanClass[0].Reader->GetOutput());

duplicator->Update();

ctImageTest = duplicator->GetOutput();

ctImageTest->FillBuffer(0);





//However, if I write it out as CT image with the following code,



typedef itk::NumericSeriesFileNames             NamesGeneratorType;



ImageIOType::Pointer gdcmIO = ImageIOType::New();



itksys::SystemTools::MakeDirectory( outputDirectory.c_str() );



typedef signed short    PixelType_UnsignedChar;

const unsigned int      OutputDimension = 2;



typedef itk::Image< PixelType_UnsignedChar, OutputDimension >  Image2DType;



typedef itk::ImageSeriesWriter<ImageType_SignedShort, Image2DType >
SeriesWriterType;



NamesGeneratorType::Pointer namesGenerator = NamesGeneratorType::New();



itk::MetaDataDictionary & dict = gdcmIO->GetMetaDataDictionary();



itk::EncapsulateMetaData<std::string>(dict,  "0008|0060", "CT");

itk::EncapsulateMetaData<std::string>(dict,  "0008|0008",
"ORIGINAL\\PRIMARY\\SAGITTAL");



//does not work, why? itk issue?

itk::EncapsulateMetaData<std::string>(dict,  "0020|0037",
"0\\1\\0\\0\\0\\-1 ");



SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New();

seriesWriter->SetInput( inputImage );

seriesWriter->SetImageIO( gdcmIO );

ImageType_SignedShort::RegionType region =
inputImage->GetLargestPossibleRegion();

ImageType_SignedShort::IndexType start = region.GetIndex();

ImageType_SignedShort::SizeType  size  = region.GetSize();

std::string format = outputDirectory;

format += "/image%03d.dcm";

namesGenerator->SetSeriesFormat( format.c_str() );

namesGenerator->SetStartIndex( start[2] );

namesGenerator->SetEndIndex( start[2] + size[2] - 1 );

namesGenerator->SetIncrementIndex( 1 );

seriesWriter->SetFileNames( namesGenerator->GetFileNames() );

try

{

       seriesWriter->Update();

}

catch( itk::ExceptionObject & ex )

{

       std::cerr << ex << std::endl;

       throw ex;

}



The Image orientation (patient) still is 1\0\0\0\1\0 instead of
0\1\0\0\0\-1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130108/d6142b0b/attachment-0001.htm>


More information about the Insight-users mailing list