I suggest creating a program that only does what you want to do.<br><br><div class="gmail_quote">On Mon, Oct 8, 2012 at 9:04 AM, suicheng gu <span dir="ltr">&lt;<a href="mailto:gusuch@yahoo.com" target="_blank">gusuch@yahoo.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_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"><div><span>Yes, I was trying to change the direction.</span></div>
<div style="font-style:normal;font-size:16px;background-color:transparent;font-family:&#39;times new roman&#39;,&#39;new york&#39;,times,serif">But I just used the resampledicom.cxx for input and output and modified the reconstruction part.</div>
<div><br></div>  <div style="font-family:&#39;times new roman&#39;,&#39;new york&#39;,times,serif;font-size:12pt"> <div style="font-family:&#39;times new roman&#39;,&#39;new york&#39;,times,serif;font-size:12pt"> <div dir="ltr">
 <font face="Arial"> <hr size="1"><div class="im">  <b><span style="font-weight:bold">From:</span></b> Bill Lorensen &lt;<a href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>&gt;<br> <b><span style="font-weight:bold">To:</span></b> suicheng gu &lt;<a href="mailto:gusuch@yahoo.com" target="_blank">gusuch@yahoo.com</a>&gt; <br>
</div><b><span style="font-weight:bold">Cc:</span></b> ITK Users
 &lt;<a href="mailto:insight-users@public.kitware.com" target="_blank">insight-users@public.kitware.com</a>&gt; <br> <b><span style="font-weight:bold">Sent:</span></b> Monday, October 8, 2012 12:44 AM<div><div class="h5">
<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="h5"> <br><div>Please keep replies on the list...<br>
<br>Why are you resampling? I thought you wanted to change the directions.<br><br><div>On Sun, Oct 7, 2012 at 10:15 AM, suicheng gu <span dir="ltr">&lt;<a rel="nofollow" href="mailto:gusuch@yahoo.com" target="_blank">gusuch@yahoo.com</a>&gt;</span> wrote:<br>

<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-size:12pt;font-family:&#39;times new roman&#39;,&#39;new york&#39;,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 &quot;itkVersion.h&quot;<br> <br>#include &quot;itkImage.h&quot;<br>#include &quot;itkMinimumMaximumImageFilter.h&quot;<br> <br>#include &quot;itkGDCMImageIO.h&quot;<br>

#include &quot;itkGDCMSeriesFileNames.h&quot;<br>#include &quot;itkNumericSeriesFileNames.h&quot;<br> <br>#include &quot;itkImageSeriesReader.h&quot;<br>#include &quot;itkImageSeriesWriter.h&quot;<br> <br>#include &quot;itkResampleImageFilter.h&quot;<br>

#include &quot;itkShiftScaleImageFilter.h&quot;<br>#include &quot;itkMetaDataObject.h&quot; <br>#include &quot;itkIdentityTransform.h&quot;<br>#include &quot;itkLinearInterpolateImageFunction.h&quot;<br>#include &quot;itkOrientImageFilter.h&quot; <br>

#include &lt;itksys/SystemTools.hxx&gt;<br> <br>#if ITK_VERSION_MAJOR &gt;= 4<br>#include &quot;gdcmUIDGenerator.h&quot;<br>#else<br>#include &quot;gdcm/src/gdcmFile.h&quot;<br>#include &quot;gdcm/src/gdcmUtil.h&quot;<br>

#endif<br> <br>#include &lt;string&gt;<br> <br>static void CopyDictionary (itk::MetaDataDictionary
 &amp;fromDict,<br>                     itk::MetaDataDictionary &amp;toDict);<br> <br> <br>int main( int argc, char* argv[] )<br>{<br>  // Validate input parameters<br>  if( argc &lt; 2 )<br>    {<br>    std::cerr &lt;&lt; &quot;Usage: &quot; <br>

              &lt;&lt; argv[0]<br>              &lt;&lt; &quot; InputDicomDirectory OutputDicomDirectory spacing_x spacing_y spacing_z&quot;<br>              &lt;&lt; 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&lt; PixelType, InputDimension &gt;<br>    InputImageType;<br>  typedef itk::Image&lt; PixelType, OutputDimension &gt;<br>    OutputImageType;<br>  typedef itk::ImageSeriesReader&lt; InputImageType &gt;<br>

    ReaderType;<br>  typedef itk::GDCMImageIO<br>    ImageIOType;<br>  typedef itk::GDCMSeriesFileNames<br>    InputNamesGeneratorType;<br>  typedef itk::NumericSeriesFileNames<br>    OutputNamesGeneratorType;<br>  typedef itk::IdentityTransform&lt; double, InputDimension &gt;<br>

    TransformType;<br>  typedef itk::LinearInterpolateImageFunction&lt; InputImageType, double &gt;<br>    InterpolatorType;<br>  typedef itk::ResampleImageFilter&lt; InputImageType, InputImageType &gt;<br>    ResampleFilterType;<br>

  typedef
 itk::ShiftScaleImageFilter&lt; InputImageType, InputImageType &gt;<br>    ShiftScaleType;<br>  typedef itk::ImageSeriesWriter&lt; InputImageType, OutputImageType &gt;<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-&gt;SetInputDirectory( argv[1] );<br>

 <br>  const ReaderType::FileNamesContainer &amp; filenames = <br>                            inputNames-&gt;GetInputFileNames();<br> <br>  ReaderType::Pointer reader = ReaderType::New();<br> <br>  reader-&gt;SetImageIO( gdcmIO );<br>

 
 reader-&gt;SetFileNames( filenames );<br>  try<br>    {<br>    reader-&gt;Update();<br>    }<br>  catch (itk::ExceptionObject &amp;excp)<br>    {<br>    std::cerr &lt;&lt; &quot;Exception thrown while reading the series&quot; &lt;&lt; std::endl;<br>

    std::cerr &lt;&lt; excp &lt;&lt; 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-&gt;SetIdentity();<br> <br>  const InputImageType::SpacingType&amp; inputSpacing =<br>    reader-&gt;GetOutput()-&gt;GetSpacing();<br>  const InputImageType::RegionType&amp; inputRegion =<br>

   
 reader-&gt;GetOutput()-&gt;GetLargestPossibleRegion();<br>  const InputImageType::SizeType&amp; inputSize =<br>    inputRegion.GetSize();<br>  const double inputOrigin[3]={reader-&gt;GetOutput()-&gt;GetOrigin()[0],reader-&gt;GetOutput()-&gt;GetOrigin()[1],reader-&gt;GetOutput()-&gt;GetOrigin()[2]};<br>

 // const double outputOrigin[3] = {inputOrigin[0],inputOrigin[1],inputOrigin[2]};</div><div><br>  std::cout &lt;&lt; &quot;The input series in directory &quot; &lt;&lt; argv[1]<br>            &lt;&lt; &quot; has &quot; &lt;&lt; filenames.size() &lt;&lt; &quot; files with spacing &quot;<br>

            &lt;&lt; inputSpacing<br>            &lt;&lt; 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 &lt; 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-&gt;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&#39;s.<br>#if ITK_VERSION_MAJOR &gt;= 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-&gt;GetUIDPrefix());<br>  std::string frameOfReferenceUID = gdcm::Util::CreateUniqueUID( gdcmIO-&gt;GetUIDPrefix());<br>#endif<br>

  std::string studyUID;<br>  std::string sopClassUID;<br>  itk::ExposeMetaData&lt;std::string&gt;(*inputDict, &quot;0020|000d&quot;, studyUID);<br>  itk::ExposeMetaData&lt;std::string&gt;(*inputDict, &quot;0008|0016&quot;, sopClassUID);<br>

  gdcmIO-&gt;KeepOriginalUIDOn();<br> <br>  for (unsigned int f = 0; f &lt; 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&#39;s for the study, series, SOP  and frame of
 reference<br>  itk::EncapsulateMetaData&lt;std::string&gt;(*dict,&quot;0020|000d&quot;, studyUID);<br>  itk::EncapsulateMetaData&lt;std::string&gt;(*dict,&quot;0020|000e&quot;, seriesUID);<br>  itk::EncapsulateMetaData&lt;std::string&gt;(*dict,&quot;0020|0052&quot;, frameOfReferenceUID);<br>

  <br> #if ITK_VERSION_MAJOR &gt;= 4<br>  gdcm::UIDGenerator sopuid;<br>  std::string sopInstanceUID = sopuid.Generate();<br> #else<br>  std::string sopInstanceUID = gdcm::Util::CreateUniqueUID( gdcmIO-&gt;GetUIDPrefix());<br>

 #endif<br>  itk::EncapsulateMetaData&lt;std::string&gt;(*dict,&quot;0008|0018&quot;, sopInstanceUID);<br>  itk::EncapsulateMetaData&lt;std::string&gt;(*dict,&quot;0002|0003&quot;, sopInstanceUID);<br>  <br>  // Change fields that are slice specific<br>

  itksys_ios::ostringstream value;<br>  value.str(&quot;&quot;);<br>  value &lt;&lt; f + 1;<br> 
 <br>  // Image Number<br>  itk::EncapsulateMetaData&lt;std::string&gt;(*dict,&quot;0020|0013&quot;, value.str());<br>  <br>  // Series Description - Append new description to current series<br>  // description<br>  std::string oldSeriesDesc;<br>

  itk::ExposeMetaData&lt;std::string&gt;(*inputDict, &quot;0008|103e&quot;, oldSeriesDesc);<br>  <br>  value.str(&quot;&quot;);<br>  value &lt;&lt; oldSeriesDesc<br>     &lt;&lt; &quot;: Resampled with pixel spacing &quot;<br>

     &lt;&lt; outputSpacing[0] &lt;&lt; &quot;, &quot; <br>     &lt;&lt; outputSpacing[1] &lt;&lt; &quot;, &quot; <br>     &lt;&lt; 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 &gt; 64 ? 64<br>        : lengthDesc);<br>  itk::EncapsulateMetaData&lt;std::string&gt;(*dict,&quot;0008|103e&quot;, seriesDesc);<br>  <br>  // Series Number<br>  value.str(&quot;&quot;);<br>  value &lt;&lt; 1001;<br>

  itk::EncapsulateMetaData&lt;std::string&gt;(*dict,&quot;0020|0011&quot;, value.str());<br>  <br>  // Derivation Description - How this image was derived<br>  value.str(&quot;&quot;);<br>  for (int i = 0; i &lt; argc; i++)<br>

    {<br>    value &lt;&lt; argv[i] &lt;&lt; &quot; &quot;;<br>    }<br>  value &lt;&lt; &quot;: &quot; &lt;&lt; ITK_SOURCE_VERSION;<br>  <br>  lengthDesc = value.str().length();<br>  std::string derivationDesc( value.str(), 0,<br>

         lengthDesc &gt; 1024 ?
 1024<br>         : lengthDesc);<br>  itk::EncapsulateMetaData&lt;std::string&gt;(*dict,&quot;0008|2111&quot;, derivationDesc);<br>  <br>  // Image orientation<br>  value.str(&quot;&quot;);<br>  value&lt;&lt;&quot;1\\0\\0\\0\\0\\1&quot;;<br>

  itk::EncapsulateMetaData&lt;std::string&gt;(*dict,&quot;0020|0037&quot;, value.str()); <br>  std::string orientation;<br>  itk::ExposeMetaData&lt;std::string&gt;(*dict, &quot;0020|0037&quot;, orientation);<br>  //std::cout&lt;&lt;orientation&lt;&lt;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(&quot;&quot;);<br>  value &lt;&lt; inputOrigin[0] &lt;&lt; &quot;\\&quot; &lt;&lt;(inputOrigin[1]+outputSpacing[2]*f)&lt;&lt;&quot;\\&quot;&lt;&lt; inputOrigin[2] ;<br>

  //std::cout&lt;&lt;&quot;position:
 &quot;&lt;&lt;value.str();<br>  itk::EncapsulateMetaData&lt;std::string&gt;(*dict,&quot;0020|0032&quot;, value.str()); </div><div><br>  // Slice Location: For now, we store the z component of the Image<br>  // Position Patient.<br>

  value.str(&quot;&quot;);<br>  value &lt;&lt; inputOrigin[1]+outputSpacing[2]*f;<br>  itk::EncapsulateMetaData&lt;std::string&gt;(*dict,&quot;0020|1041&quot;, value.str());      <br>  </div><div>  // Slice Thickness: For now, we store the z spacing<br>

  value.str(&quot;&quot;);<br>  value &lt;&lt; outputSpacing[2];<br>  itk::EncapsulateMetaData&lt;std::string&gt;(*dict,&quot;0018|0050&quot;,<br>           value.str());<br>  // Spacing Between
 Slices<br>  itk::EncapsulateMetaData&lt;std::string&gt;(*dict,&quot;0018|0088&quot;,<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-&gt;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-&gt;SetRegions( region
 );<br> image-&gt;SetOrigin(inputOrigin);</div><div> </div><div> image-&gt;Allocate();<br> //image-&gt;FillBuffer(0);<br> </div><div> PixelType *ppt = image-&gt;GetBufferPointer();<br> for(int z = 0;z&lt;outputSize[2];z++)<br>

 {<br>  for(int y = 0;y&lt;outputSize[1];y++)<br>  {<br>   for(int x = 0;x&lt;outputSize[0];x++)<br>   {<br>    InputImageType::IndexType pixelIndex;<br>    pixelIndex[0] = x;<br>    pixelIndex[1] = z;<br>    pixelIndex[2] = y;<br>

    PixelType pt = reader-&gt;GetOutput()-&gt;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-&gt;SetDirection(direction);</div>

<div> //image-&gt;Update();<br> <br> /*<div><br>itk::OrientImageFilter&lt;InputImageType,InputImageType&gt;::Pointer orienter =<br> <br>itk::OrientImageFilter&lt;InputImageType,InputImageType&gt;::New();<br> <br>
orienter-&gt;UseImageDirectionOn();</div></div><div>orienter-&gt;SetDesiredCoordinateOrientationToCoronal();</div><div><div>orienter-&gt;SetInput(reader-&gt;GetOutput());<br> <br>orienter-&gt;Update();<br></div>
*/</div><div>itk::SpatialOrientation::ValidCoordinateOrientationFlags
 fileOrientation;<br> <br>//itk::ExposeMetaData&lt;itk::SpatialOrientation::ValidCoordinateOrientationFlags&gt;(reader-&gt;GetOutput()-&gt;GetMetaDataDictionary(),itk::ITK_CoordinateOrientation,fileOrientation);<div>
<br> <br>itk::OrientImageFilter&lt;InputImageType,InputImageType&gt;::Pointer orienter =<br> <br>itk::OrientImageFilter&lt;InputImageType,InputImageType&gt;::New();<br> <br></div>orienter-&gt;SetGivenCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_LPS); // deprecated<br>

 <br>orienter-&gt;SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RIP);<div><br> <br>orienter-&gt;SetInput(reader-&gt;GetOutput());<br> <br>orienter-&gt;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 + &quot;/&quot; + &quot;IM%d.dcm&quot;;<br>

  outputNames-&gt;SetSeriesFormat (seriesFormat.c_str());<br>  outputNames-&gt;SetStartIndex (1);<br>  outputNames-&gt;SetEndIndex (outputSize[2]);<br> </div><div>  //itk::MetaDataDictionary &amp; dict1 = gdcmIO-&gt;GetMetaDataDictionary();<br>

  //itk::EncapsulateMetaData&lt;std::string&gt;(dict1,&quot;0020|0037&quot;, &quot;1\\0\\0\\0\\0\\1&quot;); </div><div><br> SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New();<br> seriesWriter-&gt;SetInput( orienter-&gt;GetOutput() );<br>

    seriesWriter-&gt;SetImageIO( gdcmIO );<br>    seriesWriter-&gt;SetFileNames( outputNames-&gt;GetFileNames() );<br>   
 seriesWriter-&gt;SetMetaDataDictionaryArray( &amp;outputArray );<br>  try<br>    {<br>    seriesWriter-&gt;Update();<br>    }<br>  catch( itk::ExceptionObject &amp; excp )<br>    {<br>    std::cerr &lt;&lt; &quot;Exception thrown while writing the series &quot; &lt;&lt; std::endl;<br>

    std::cerr &lt;&lt; excp &lt;&lt; std::endl;<br>    return EXIT_FAILURE;<br>    }<br>  std::cout &lt;&lt; &quot;The output series in directory &quot; &lt;&lt; argv[2]<br>            &lt;&lt; &quot; has &quot; &lt;&lt; outputSize[2] &lt;&lt; &quot; files with spacing &quot;<br>

            &lt;&lt; outputSpacing<br>            &lt;&lt; std::endl;<br> system(&quot;pause&quot;);<br>  return
 EXIT_SUCCESS;<br>}<br> <br>void CopyDictionary (itk::MetaDataDictionary &amp;fromDict, itk::MetaDataDictionary &amp;toDict)<br>{<br>  typedef itk::MetaDataDictionary DictionaryType;<br> <br>  DictionaryType::ConstIterator itr = fromDict.Begin();<br>

  DictionaryType::ConstIterator end = fromDict.End();<br>  typedef itk::MetaDataObject&lt; std::string &gt; MetaDataStringType;<br> <br>  while( itr != end )<br>    {<br>    itk::MetaDataObjectBase::Pointer  entry = itr-&gt;second;<br>

 <br>    MetaDataStringType::Pointer entryvalue = <br>      dynamic_cast&lt;MetaDataStringType *&gt;( entry.GetPointer() ) ;<br>    if( entryvalue )<br>      {<br>      std::string tagkey   = itr-&gt;first;<br>      std::string tagvalue =
 entryvalue-&gt;GetMetaDataObjectValue();<br>      itk::EncapsulateMetaData&lt;std::string&gt;(toDict, tagkey, tagvalue); <br>      }<br>    ++itr;<br>    }<br>}</div></span></div><div><br></div>  <div style="font-family:&#39;times new roman&#39;,&#39;new york&#39;,times,serif;font-size:12pt">

 <div style="font-family:&#39;times new roman&#39;,&#39;new york&#39;,times,serif;font-size:12pt"> <div dir="ltr"> <font face="Arial"><div> <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 &lt;<a rel="nofollow" href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>&gt;<br> <b><span style="font-weight:bold">To:</span></b> suicheng gu &lt;<a rel="nofollow" href="mailto:gusuch@yahoo.com" target="_blank">gusuch@yahoo.com</a>&gt; <br>

<b><span style="font-weight:bold">Cc:</span></b> &quot;<a rel="nofollow" href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a>&quot;
 &lt;<a rel="nofollow" href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a>&gt; <br> </div><b><span style="font-weight:bold">Sent:</span></b> Sunday, October 7, 2012 8:14 PM<div><div><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> <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">&lt;<a rel="nofollow" href="mailto:gusuch@yahoo.com" target="_blank">gusuch@yahoo.com</a>&gt;</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:&#39;times new roman&#39;,&#39;new york&#39;,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:&#39;times new roman&#39;,&#39;new york&#39;,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:&#39;times new roman&#39;,&#39;new york&#39;,times,serif;font-size:16px;font-style:normal;background-color:transparent">

<span></span> </div><div style="font-family:&#39;times new roman&#39;,&#39;new york&#39;,times,serif;font-size:16px;font-style:normal;background-color:transparent"><span>itk::OrientImageFilter&lt;InputImageType,InputImageType&gt;::Pointer orienter
 =<br>itk::OrientImageFilter&lt;InputImageType,InputImageType&gt;::New();<br>orienter-&gt;UseImageDirectionOn();</span></div><div><span>orienter-&gt;SetDesiredCoordinateOrientationToCoronal();</span></div><div><span>orienter-&gt;SetInput(reader-&gt;GetOutput());<br>


orienter-&gt;Update();</span></div><div><br></div>  <div style="font-family:&#39;times new roman&#39;,&#39;new york&#39;,times,serif;font-size:12pt"> <div style="font-family:&#39;times new roman&#39;,&#39;new york&#39;,times,serif;font-size:12pt">
 <div dir="ltr">

 <font face="Arial"><div>   <b><span style="font-weight:bold">From:</span></b> Bill Lorensen &lt;<a rel="nofollow" href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>&gt;<br>

 <b><span style="font-weight:bold">To:</span></b> suicheng gu &lt;<a rel="nofollow" href="mailto:gusuch@yahoo.com" target="_blank">gusuch@yahoo.com</a>&gt; <br><b><span style="font-weight:bold">Cc:</span></b>
 &quot;<a rel="nofollow" href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a>&quot; &lt;<a rel="nofollow" href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a>&gt; <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">&lt;<a rel="nofollow" href="mailto:gusuch@yahoo.com" target="_blank">gusuch@yahoo.com</a>&gt;</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:&#39;times new roman&#39;,&#39;new york&#39;,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&#39;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 &lt;<a rel="nofollow" href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>&gt;<br>



 <b><span style="font-weight:bold">To:</span></b> suicheng gu &lt;<a rel="nofollow" href="mailto:gusuch@yahoo.com" target="_blank">gusuch@yahoo.com</a>&gt; <br><b><span style="font-weight:bold">Cc:</span></b> &quot;<a rel="nofollow" href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a>&quot; &lt;<a rel="nofollow" href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a>&gt; <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">&lt;<a rel="nofollow" href="mailto:gusuch@yahoo.com" target="_blank">gusuch@yahoo.com</a>&gt;</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&lt;std::string&gt;(dict1,&quot;0020|0037&quot;, &quot;1\\0\\0\\0\\0\\1&quot;); </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" href="http://www.kitware.com/" target="_blank">http://www.kitware.com/</a><div><br>
<br>
Visit other Kitware open-source projects at<br>
<a rel="nofollow" href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a rel="nofollow" href="http://www.kitware.com/products/protraining.php" target="_blank">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" href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a rel="nofollow" href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">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> </div>  </div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Unpaid intern in BillsBasement at noware dot com<br><br>