<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span>Yes, I was trying to change the direction.</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: 'times new roman', 'new york', times, serif; background-color: transparent; font-style: normal; ">But I just used the resampledicom.cxx for input and output and modified the reconstruction part.</div><div><br></div> <div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "> <div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "> <div dir="ltr"> <font size="2" face="Arial"> <hr size="1"> <b><span style="font-weight:bold;">From:</span></b> Bill Lorensen <bill.lorensen@gmail.com><br> <b><span style="font-weight: bold;">To:</span></b> suicheng gu <gusuch@yahoo.com> <br><b><span style="font-weight: bold;">Cc:</span></b> ITK Users
<insight-users@public.kitware.com> <br> <b><span style="font-weight: bold;">Sent:</span></b> Monday, October 8, 2012 12:44 AM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [Insight-users] Unable to write dicom tag using GDCMImageIO<br> </font> </div> <br><div id="yiv1906846542">Please keep replies on the list...<br><br>Why are you resampling? I thought you wanted to change the directions.<br><br><div class="yiv1906846542gmail_quote">On Sun, Oct 7, 2012 at 10:15 AM, suicheng gu <span dir="ltr"><<a rel="nofollow" ymailto="mailto:gusuch@yahoo.com" target="_blank" href="mailto:gusuch@yahoo.com">gusuch@yahoo.com</a>></span> wrote:<br>
<blockquote class="yiv1906846542gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><div style="font-size: 12pt; font-family: 'times new roman', 'new york', times, serif; "><span><div>attached, I just modified the ResampleDICOM.cxx file</div>
<div> </div><div> </div><div> </div><div>// Resample a DICOM study<br>// Usage: ResampleDICOM InputDirectory OutputDirectory<br>// xSpacing ySpacing zSpacing<br>//<br>// Example: ResampleDICOM CT CTResample 0 0 1.5<br>
// will read a series from the CT directory and create a<br>// new series in the CTResample directory. The new series<br>// will have the same x,y spacing as the input series,
but<br>// will have a z-spacing of 1.5.<br>//<br>// Description:<br>// ResampleDICOM resamples a DICOM series with user-specified<br>// spacing. The program outputs a new DICOM series with a series<br>// number set to 1001. All non-private DICOM tags are moved from the input<br>
// series to the output series. The Image Position Patient is adjusted<br>// for each slice to reflect the z-spacing. The number of slices in<br>// the output series may be larger or smaller due to changes in the<br>// z-spacing. To retain the spacing for a given dimension, specify 0.<br>
//<br>// The program progresses as follows:<br>// 1) Read the input series<br>// 2) Resample the series according to the user specified x-y-z<br>// spacing.<br>// 3) Create a MetaDataDictionary for each slice.<br>// 4) Shift data to undo the effect of a rescale intercept by the<br>
// DICOM
reader<br>// 5) Write the new DICOM series<br>//<br> <br>#include "itkVersion.h"<br> <br>#include "itkImage.h"<br>#include "itkMinimumMaximumImageFilter.h"<br> <br>#include "itkGDCMImageIO.h"<br>
#include "itkGDCMSeriesFileNames.h"<br>#include "itkNumericSeriesFileNames.h"<br> <br>#include "itkImageSeriesReader.h"<br>#include "itkImageSeriesWriter.h"<br> <br>#include "itkResampleImageFilter.h"<br>
#include "itkShiftScaleImageFilter.h"<br>#include "itkMetaDataObject.h" <br>#include "itkIdentityTransform.h"<br>#include "itkLinearInterpolateImageFunction.h"<br>#include "itkOrientImageFilter.h" <br>
#include <itksys/SystemTools.hxx><br> <br>#if ITK_VERSION_MAJOR >= 4<br>#include "gdcmUIDGenerator.h"<br>#else<br>#include "gdcm/src/gdcmFile.h"<br>#include "gdcm/src/gdcmUtil.h"<br>
#endif<br> <br>#include <string><br> <br>static void CopyDictionary (itk::MetaDataDictionary
&fromDict,<br> itk::MetaDataDictionary &toDict);<br> <br> <br>int main( int argc, char* argv[] )<br>{<br> // Validate input parameters<br> if( argc < 2 )<br> {<br> std::cerr << "Usage: " <br>
<< argv[0]<br> << " InputDicomDirectory OutputDicomDirectory spacing_x spacing_y spacing_z"<br> << std::endl;<br> return EXIT_FAILURE;<br> }<br> <br>
const unsigned int InputDimension = 3;<br> const unsigned int OutputDimension = 2;<br> <br> typedef signed short
PixelType;<br> <br> typedef itk::Image< PixelType, InputDimension ><br> InputImageType;<br> typedef itk::Image< PixelType, OutputDimension ><br> OutputImageType;<br> typedef itk::ImageSeriesReader< InputImageType ><br>
ReaderType;<br> typedef itk::GDCMImageIO<br> ImageIOType;<br> typedef itk::GDCMSeriesFileNames<br> InputNamesGeneratorType;<br> typedef itk::NumericSeriesFileNames<br> OutputNamesGeneratorType;<br> typedef itk::IdentityTransform< double, InputDimension ><br>
TransformType;<br> typedef itk::LinearInterpolateImageFunction< InputImageType, double ><br> InterpolatorType;<br> typedef itk::ResampleImageFilter< InputImageType, InputImageType ><br> ResampleFilterType;<br>
typedef
itk::ShiftScaleImageFilter< InputImageType, InputImageType ><br> ShiftScaleType;<br> typedef itk::ImageSeriesWriter< InputImageType, OutputImageType ><br> SeriesWriterType;<br> <br>//////////////////////////////////////////////// <br>
// 1) Read the input series<br> <br> ImageIOType::Pointer gdcmIO = ImageIOType::New();<br> InputNamesGeneratorType::Pointer inputNames = InputNamesGeneratorType::New();<br> inputNames->SetInputDirectory( argv[1] );<br>
<br> const ReaderType::FileNamesContainer & filenames = <br> inputNames->GetInputFileNames();<br> <br> ReaderType::Pointer reader = ReaderType::New();<br> <br> reader->SetImageIO( gdcmIO );<br>
reader->SetFileNames( filenames );<br> try<br> {<br> reader->Update();<br> }<br> catch (itk::ExceptionObject &excp)<br> {<br> std::cerr << "Exception thrown while reading the series" << std::endl;<br>
std::cerr << excp << std::endl;<br> return EXIT_FAILURE;<br> }<br> <br>//////////////////////////////////////////////// <br>// 2) Resample the series<br> InterpolatorType::Pointer interpolator = InterpolatorType::New();<br>
<br> TransformType::Pointer transform = TransformType::New();<br> transform->SetIdentity();<br> <br> const InputImageType::SpacingType& inputSpacing =<br> reader->GetOutput()->GetSpacing();<br> const InputImageType::RegionType& inputRegion =<br>
reader->GetOutput()->GetLargestPossibleRegion();<br> const InputImageType::SizeType& inputSize =<br> inputRegion.GetSize();<br> const double inputOrigin[3]={reader->GetOutput()->GetOrigin()[0],reader->GetOutput()->GetOrigin()[1],reader->GetOutput()->GetOrigin()[2]};<br>
// const double outputOrigin[3] = {inputOrigin[0],inputOrigin[1],inputOrigin[2]};</div><div><br> std::cout << "The input series in directory " << argv[1]<br> << " has " << filenames.size() << " files with spacing "<br>
<< inputSpacing<br> << std::endl;<br> <br> // Compute the size of the output. The user specifies a spacing on<br> // the command line. If the spacing
is 0, the input spacing will be<br> // used. The size (# of pixels) in the output is recomputed using<br> // the ratio of the input and output sizes.<br> InputImageType::SpacingType outputSpacing;<br> outputSpacing[0] = inputSpacing[0];<br>
outputSpacing[1] = inputSpacing[2];<br> outputSpacing[2] = inputSpacing[1];<br> <br> bool changeInSpacing = false;<br> for (unsigned int i = 0; i < 3; i++)<br> {<br> if (outputSpacing[i] == 0.0)<br> {<br>
outputSpacing[i] = inputSpacing[i];<br> }<br> else<br> {<br> changeInSpacing = true;<br> }<br> }<br> InputImageType::SizeType outputSize;<br> typedef InputImageType::SizeType::SizeValueType
SizeValueType;<br> outputSize[0] = inputSize[0];<br> outputSize[1] = inputSize[2];<br> outputSize[2] = inputSize[1];</div><div><br> <br> <br>//////////////////////////////////////////////// <br>// 3) Create a MetaDataDictionary for each slice.<br>
<br> // Copy the dictionary from the first image and override slice<br> // specific fields<br> ReaderType::DictionaryRawPointer inputDict = (*(reader->GetMetaDataDictionaryArray()))[0];<br> ReaderType::DictionaryArrayType outputArray;<br>
<br> // To keep the new series in the same study as the original we need<br> // to keep the same study UID. But we need new series and frame of<br> // reference UID's.<br>#if ITK_VERSION_MAJOR >= 4<br> gdcm::UIDGenerator suid;<br>
std::string seriesUID = suid.Generate();<br> gdcm::UIDGenerator fuid;<br> std::string frameOfReferenceUID =
fuid.Generate();<br>#else<br> std::string seriesUID = gdcm::Util::CreateUniqueUID( gdcmIO->GetUIDPrefix());<br> std::string frameOfReferenceUID = gdcm::Util::CreateUniqueUID( gdcmIO->GetUIDPrefix());<br>#endif<br>
std::string studyUID;<br> std::string sopClassUID;<br> itk::ExposeMetaData<std::string>(*inputDict, "0020|000d", studyUID);<br> itk::ExposeMetaData<std::string>(*inputDict, "0008|0016", sopClassUID);<br>
gdcmIO->KeepOriginalUIDOn();<br> <br> for (unsigned int f = 0; f < outputSize[2]; f++)<br> {<br> // Create a new dictionary for this slice<br> ReaderType::DictionaryRawPointer dict = new ReaderType::DictionaryType;<br>
<br> // Copy the dictionary from the first slice<br> CopyDictionary (*inputDict, *dict);<br> <br> // Set the UID's for the study, series, SOP and frame of
reference<br> itk::EncapsulateMetaData<std::string>(*dict,"0020|000d", studyUID);<br> itk::EncapsulateMetaData<std::string>(*dict,"0020|000e", seriesUID);<br> itk::EncapsulateMetaData<std::string>(*dict,"0020|0052", frameOfReferenceUID);<br>
<br> #if ITK_VERSION_MAJOR >= 4<br> gdcm::UIDGenerator sopuid;<br> std::string sopInstanceUID = sopuid.Generate();<br> #else<br> std::string sopInstanceUID = gdcm::Util::CreateUniqueUID( gdcmIO->GetUIDPrefix());<br>
#endif<br> itk::EncapsulateMetaData<std::string>(*dict,"0008|0018", sopInstanceUID);<br> itk::EncapsulateMetaData<std::string>(*dict,"0002|0003", sopInstanceUID);<br> <br> // Change fields that are slice specific<br>
itksys_ios::ostringstream value;<br> value.str("");<br> value << f + 1;<br>
<br> // Image Number<br> itk::EncapsulateMetaData<std::string>(*dict,"0020|0013", value.str());<br> <br> // Series Description - Append new description to current series<br> // description<br> std::string oldSeriesDesc;<br>
itk::ExposeMetaData<std::string>(*inputDict, "0008|103e", oldSeriesDesc);<br> <br> value.str("");<br> value << oldSeriesDesc<br> << ": Resampled with pixel spacing "<br>
<< outputSpacing[0] << ", " <br> << outputSpacing[1] << ", " <br> << outputSpacing[2];<br> // This is an long string and there is a 64 character limit in the <br>
// standard<br> unsigned lengthDesc = value.str().length();<br> <br> std::string seriesDesc( value.str(),
0,<br> lengthDesc > 64 ? 64<br> : lengthDesc);<br> itk::EncapsulateMetaData<std::string>(*dict,"0008|103e", seriesDesc);<br> <br> // Series Number<br> value.str("");<br> value << 1001;<br>
itk::EncapsulateMetaData<std::string>(*dict,"0020|0011", value.str());<br> <br> // Derivation Description - How this image was derived<br> value.str("");<br> for (int i = 0; i < argc; i++)<br>
{<br> value << argv[i] << " ";<br> }<br> value << ": " << ITK_SOURCE_VERSION;<br> <br> lengthDesc = value.str().length();<br> std::string derivationDesc( value.str(), 0,<br>
lengthDesc > 1024 ?
1024<br> : lengthDesc);<br> itk::EncapsulateMetaData<std::string>(*dict,"0008|2111", derivationDesc);<br> <br> // Image orientation<br> value.str("");<br> value<<"1\\0\\0\\0\\0\\1";<br>
itk::EncapsulateMetaData<std::string>(*dict,"0020|0037", value.str()); <br> std::string orientation;<br> itk::ExposeMetaData<std::string>(*dict, "0020|0037", orientation);<br> //std::cout<<orientation<<std::endl;</div>
<div> // Image Position Patient: This is calculated by computing the<br> // physical coordinate of the first pixel in each slice.<br> value.str("");<br> value << inputOrigin[0] << "\\" <<(inputOrigin[1]+outputSpacing[2]*f)<<"\\"<< inputOrigin[2] ;<br>
//std::cout<<"position:
"<<value.str();<br> itk::EncapsulateMetaData<std::string>(*dict,"0020|0032", value.str()); </div><div><br> // Slice Location: For now, we store the z component of the Image<br> // Position Patient.<br>
value.str("");<br> value << inputOrigin[1]+outputSpacing[2]*f;<br> itk::EncapsulateMetaData<std::string>(*dict,"0020|1041", value.str()); <br> </div><div> // Slice Thickness: For now, we store the z spacing<br>
value.str("");<br> value << outputSpacing[2];<br> itk::EncapsulateMetaData<std::string>(*dict,"0018|0050",<br> value.str());<br> // Spacing Between
Slices<br> itk::EncapsulateMetaData<std::string>(*dict,"0018|0088",<br> value.str());</div><div> <br> // Save the dictionary<br> outputArray.push_back(dict);<br> }<br> <br>//////////////////////////////////////////////// <br>
// 4) Shift data to undo the effect of a rescale intercept by the<br>// DICOM reader<br> /*InputImageType::Pointer image = InputImageType::New();<br> image->SetSpacing( outputSpacing );</div><div> InputImageType::IndexType start;<br>
start[0] = 0; <br> start[1] = 0; <br> start[2] = 0; </div><div> InputImageType::RegionType region;<br> region.SetSize( outputSize );<br> region.SetIndex( start );</div><div> image->SetRegions( region
);<br> image->SetOrigin(inputOrigin);</div><div> </div><div> image->Allocate();<br> //image->FillBuffer(0);<br> </div><div> PixelType *ppt = image->GetBufferPointer();<br> for(int z = 0;z<outputSize[2];z++)<br>
{<br> for(int y = 0;y<outputSize[1];y++)<br> {<br> for(int x = 0;x<outputSize[0];x++)<br> {<br> InputImageType::IndexType pixelIndex;<br> pixelIndex[0] = x;<br> pixelIndex[1] = z;<br> pixelIndex[2] = y;<br>
PixelType pt = reader->GetOutput()->GetPixel(pixelIndex);<br> *ppt = pt;<br> ppt ++;<br> }<br> }<br> }*/<br> InputImageType::DirectionType direction;<br> direction(0,0) = 1; <br> direction(0,1) =
0;<br> direction(0,2) = 0;<br> direction(1,0) = 0;<br> direction(1,1) = 1;<br> direction(1,2) = 0;<br> direction(2,0) = 0;<br> direction(2,1) = 0;<br> direction(2,2) = 1;<br> </div><div> //image->SetDirection(direction);</div>
<div> //image->Update();<br> <br> /*<div class="yiv1906846542im"><br>itk::OrientImageFilter<InputImageType,InputImageType>::Pointer orienter =<br> <br>itk::OrientImageFilter<InputImageType,InputImageType>::New();<br> <br>
orienter->UseImageDirectionOn();</div></div><div>orienter->SetDesiredCoordinateOrientationToCoronal();</div><div><div class="yiv1906846542im">orienter->SetInput(reader->GetOutput());<br> <br>orienter->Update();<br></div>
*/</div><div>itk::SpatialOrientation::ValidCoordinateOrientationFlags
fileOrientation;<br> <br>//itk::ExposeMetaData<itk::SpatialOrientation::ValidCoordinateOrientationFlags>(reader->GetOutput()->GetMetaDataDictionary(),itk::ITK_CoordinateOrientation,fileOrientation);<div class="yiv1906846542im">
<br> <br>itk::OrientImageFilter<InputImageType,InputImageType>::Pointer orienter =<br> <br>itk::OrientImageFilter<InputImageType,InputImageType>::New();<br> <br></div>orienter->SetGivenCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_LPS); // deprecated<br>
<br>orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RIP);<div class="yiv1906846542im"><br> <br>orienter->SetInput(reader->GetOutput());<br> <br>orienter->Update();</div></div>
<div><br>//////////////////////////////////////////////// <br>// 5) Write the new DICOM series<br> <br> // Make the output directory and generate the file names.<br> itksys::SystemTools::MakeDirectory( argv[2]
);<br> <br> // Generate the file names<br> OutputNamesGeneratorType::Pointer outputNames = OutputNamesGeneratorType::New();<br> std::string seriesFormat(argv[2]);<br> seriesFormat = seriesFormat + "/" + "IM%d.dcm";<br>
outputNames->SetSeriesFormat (seriesFormat.c_str());<br> outputNames->SetStartIndex (1);<br> outputNames->SetEndIndex (outputSize[2]);<br> </div><div> //itk::MetaDataDictionary & dict1 = gdcmIO->GetMetaDataDictionary();<br>
//itk::EncapsulateMetaData<std::string>(dict1,"0020|0037", "1\\0\\0\\0\\0\\1"); </div><div><br> SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New();<br> seriesWriter->SetInput( orienter->GetOutput() );<br>
seriesWriter->SetImageIO( gdcmIO );<br> seriesWriter->SetFileNames( outputNames->GetFileNames() );<br>
seriesWriter->SetMetaDataDictionaryArray( &outputArray );<br> try<br> {<br> seriesWriter->Update();<br> }<br> catch( itk::ExceptionObject & excp )<br> {<br> std::cerr << "Exception thrown while writing the series " << std::endl;<br>
std::cerr << excp << std::endl;<br> return EXIT_FAILURE;<br> }<br> std::cout << "The output series in directory " << argv[2]<br> << " has " << outputSize[2] << " files with spacing "<br>
<< outputSpacing<br> << std::endl;<br> system("pause");<br> return
EXIT_SUCCESS;<br>}<br> <br>void CopyDictionary (itk::MetaDataDictionary &fromDict, itk::MetaDataDictionary &toDict)<br>{<br> typedef itk::MetaDataDictionary DictionaryType;<br> <br> DictionaryType::ConstIterator itr = fromDict.Begin();<br>
DictionaryType::ConstIterator end = fromDict.End();<br> typedef itk::MetaDataObject< std::string > MetaDataStringType;<br> <br> while( itr != end )<br> {<br> itk::MetaDataObjectBase::Pointer entry = itr->second;<br>
<br> MetaDataStringType::Pointer entryvalue = <br> dynamic_cast<MetaDataStringType *>( entry.GetPointer() ) ;<br> if( entryvalue )<br> {<br> std::string tagkey = itr->first;<br> std::string tagvalue =
entryvalue->GetMetaDataObjectValue();<br> itk::EncapsulateMetaData<std::string>(toDict, tagkey, tagvalue); <br> }<br> ++itr;<br> }<br>}</div></span></div><div><br></div> <div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">
<div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "> <div dir="ltr"> <font face="Arial"><div class="yiv1906846542im"> <div style="margin:5px 0px;padding:0px;border:1px solid rgb(204,204,204);min-height:0px;line-height:0;font-size:0px;">
</div> <b><span style="font-weight:bold;">From:</span></b> Bill Lorensen <<a rel="nofollow" ymailto="mailto:bill.lorensen@gmail.com" target="_blank" href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>><br> <b><span style="font-weight:bold;">To:</span></b> suicheng gu <<a rel="nofollow" ymailto="mailto:gusuch@yahoo.com" target="_blank" href="mailto:gusuch@yahoo.com">gusuch@yahoo.com</a>> <br>
<b><span style="font-weight:bold;">Cc:</span></b> "<a rel="nofollow" ymailto="mailto:insight-users@itk.org" target="_blank" href="mailto:insight-users@itk.org">insight-users@itk.org</a>"
<<a rel="nofollow" ymailto="mailto:insight-users@itk.org" target="_blank" href="mailto:insight-users@itk.org">insight-users@itk.org</a>> <br> </div><b><span style="font-weight:bold;">Sent:</span></b> Sunday, October 7, 2012 8:14 PM<div><div class="yiv1906846542h5"><br> <b><span style="font-weight:bold;">Subject:</span></b> Re: [Insight-users] Unable to write dicom tag using GDCMImageIO<br>
</div></div></font> </div><div><div class="yiv1906846542h5"> <br>
<div>Can you post the entire program please?<br><br><div>On Sat, Oct 6, 2012 at 9:04 PM, suicheng gu <span dir="ltr"><<a rel="nofollow" ymailto="mailto:gusuch@yahoo.com" target="_blank" href="mailto:gusuch@yahoo.com">gusuch@yahoo.com</a>></span> wrote:<br>
<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid;"><div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">
<div><span>I used the following code to obtain the coronal view, but the orientation tag is still 1\0\0\0\1\0</span></div>
<div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; font-style: normal; background-color: transparent; "><span>And one more problem is that some dcm files are with size of 0.</span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; font-style: normal; background-color: transparent; ">
<span></span> </div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; font-style: normal; background-color: transparent; "><span>itk::OrientImageFilter<InputImageType,InputImageType>::Pointer orienter
=<br>itk::OrientImageFilter<InputImageType,InputImageType>::New();<br>orienter->UseImageDirectionOn();</span></div><div><span>orienter->SetDesiredCoordinateOrientationToCoronal();</span></div><div><span>orienter->SetInput(reader->GetOutput());<br>
orienter->Update();</span></div><div><br></div> <div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "> <div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "> <div dir="ltr">
<font face="Arial"><div> <b><span style="font-weight:bold;">From:</span></b> Bill Lorensen <<a rel="nofollow" ymailto="mailto:bill.lorensen@gmail.com" target="_blank" href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>><br>
<b><span style="font-weight:bold;">To:</span></b> suicheng gu <<a rel="nofollow" ymailto="mailto:gusuch@yahoo.com" target="_blank" href="mailto:gusuch@yahoo.com">gusuch@yahoo.com</a>> <br><b><span style="font-weight:bold;">Cc:</span></b>
"<a rel="nofollow" ymailto="mailto:insight-users@itk.org" target="_blank" href="mailto:insight-users@itk.org">insight-users@itk.org</a>" <<a rel="nofollow" ymailto="mailto:insight-users@itk.org" target="_blank" href="mailto:insight-users@itk.org">insight-users@itk.org</a>> <br> </div>
<b><span style="font-weight:bold;">Sent:</span></b> Sunday, October 7, 2012 4:33 AM<div>
<br> <b><span style="font-weight:bold;">Subject:</span></b> Re: [Insight-users] Unable to write dicom tag using GDCMImageIO<br> </div></font> </div> <br>
<div><div>You can use itkOrientImageFilter to change the direction of the volume. Then when you write the IDCOM with itk, the direction cosines will be correct.<br><br></div><div><div>On Sat, Oct 6, 2012 at 11:24 AM, suicheng gu <span dir="ltr"><<a rel="nofollow" ymailto="mailto:gusuch@yahoo.com" target="_blank" href="mailto:gusuch@yahoo.com">gusuch@yahoo.com</a>></span> wrote:<br>
</div><blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid;"><div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">
<div><div><span>Thanks very much.</span></div>
<div style="font-size:16px;font-style:normal;background-color:transparent;"><span style="background-color:transparent;">what I want to do is to reconstruct the coronal and saggittal views and save them as dcm files.</span></div>
<div style="font-size:16px;font-style:normal;background-color:transparent;"><span>I can manually change the direction of the volume data</span></div><div style="font-size:16px;font-style:normal;background-color:transparent;">
If I can't change these tags, can I just create one dictionary? such as the example:
ImageReadDicomSeriesWrite.cxx</div><div style="font-size:16px;font-style:normal;background-color:transparent;"><br></div><div> </div>
</div><div style="font-size:12pt;"><div> </div><div style="font-size:12pt;"><div>
<div> <div dir="ltr"> <font face="Arial"> <b><span style="font-weight:bold;">From:</span></b> Bill Lorensen <<a rel="nofollow" ymailto="mailto:bill.lorensen@gmail.com" target="_blank" href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>><br>
<b><span style="font-weight:bold;">To:</span></b> suicheng gu <<a rel="nofollow" ymailto="mailto:gusuch@yahoo.com" target="_blank" href="mailto:gusuch@yahoo.com">gusuch@yahoo.com</a>> <br><b><span style="font-weight:bold;">Cc:</span></b> "<a rel="nofollow" ymailto="mailto:insight-users@itk.org" target="_blank" href="mailto:insight-users@itk.org">insight-users@itk.org</a>" <<a rel="nofollow" ymailto="mailto:insight-users@itk.org" target="_blank" href="mailto:insight-users@itk.org">insight-users@itk.org</a>> <br>
<b><span style="font-weight:bold;">Sent:</span></b> Saturday, October 6, 2012 11:07 PM<br> <b><span style="font-weight:bold;">Subject:</span></b> Re: [Insight-users] Unable to write dicom tag using GDCMImageIO<br>
</font> </div></div></div><div><div> <br>
<div><div>If I recall, tags that are related to orientation and spacing cannot be changed. You must change the orientation of the data before you write the dicom file. The writer will output the proper tag that goes with the data.<br>
<br></div><div><div>On Sat, Oct 6, 2012 at 5:21 AM, suicheng gu <span dir="ltr"><<a rel="nofollow" ymailto="mailto:gusuch@yahoo.com" target="_blank" href="mailto:gusuch@yahoo.com">gusuch@yahoo.com</a>></span> wrote:<br></div><blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid;">
<div>
<div><div style="font-size:12pt;"><div>Hi,</div><div> </div><div>I was trying to chage the image orientation tag using</div><div>itk::EncapsulateMetaData<std::string>(dict1,"0020|0037", "1\\0\\0\\0\\0\\1"); </div>
<div>But the image orientation was still 1\0\0\0\1\0</div><div> </div><div> </div><div> </div><div>I also tested the provided exmaple: </div><div>InsightToolkit-4.1.0\Examples\IO\DicomImageReadChangeHeaderWrite.cxx</div>
<div>
</div><div>It works for some tags, such as the instance number: DicomImageReadChangeHeaderWrite $infile$ $outfile$ 0020|0013 10</div><div> </div><div>But it failed on the image orientation: DicomImageReadChangeHeaderWrite $infile$ $outfile$ 0020|0037 1\0\0\0\0\1 </div>
<div> </div><div> </div><div> </div><div>Anyone can help?</div><div>Thanks in
advance.</div><span><font color="#888888"><div>Suicheng</div><div> </div></font></span></div></div><br>_____________________________________<br></div>
Powered by <a rel="nofollow" target="_blank" href="http://www.kitware.com/">http://www.kitware.com/</a><div><br>
<br>
Visit other Kitware open-source projects at<br>
<a rel="nofollow" target="_blank" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a rel="nofollow" target="_blank" href="http://www.kitware.com/products/protraining.php">http://www.kitware.com/products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a rel="nofollow" target="_blank" href="http://www.itk.org/Wiki/ITK_FAQ">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a rel="nofollow" target="_blank" href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></div></blockquote></div><div><br><br clear="all"><div><br></div>-- <br>Unpaid intern in BillsBasement at noware dot com<br><br>
</div></div><br><br> </div></div></div> </div> </div></div></blockquote></div><div><br><br clear="all"><br>-- <br>Unpaid intern in BillsBasement at noware dot com<br><br>
</div></div><br><br> </div> </div> </div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Unpaid intern in BillsBasement at noware dot com<br><br>
</div><br><br> </div></div></div> </div> </div></blockquote></div><br><br clear="all"><br>-- <br>Unpaid intern in BillsBasement at noware dot com<br><br>
</div><br><br> </div> </div> </div></body></html>