<br>Hi Dev,<br><br><br>One of the many Great Things about Open Source<br>is that you can see how things are implemented.     :-)<br><br><br>Open the file:<br><br>     Insight/Code/IO/itkGDCMImageIO.cxx <br><br>Note the command <br>
<br>     #if GDCM_MAJOR_VERSION &lt; 2<br><br>in line 1318.<br><br>and its corresponding #else and #endif in lines<br>1841 and 2229 respectively.<br><br><br>Then got to lines 1944-1952<br><br>      else if( key == ITK_Origin )<br>
        {<br>        typedef Array&lt; double &gt; DoubleArrayType;<br>        DoubleArrayType originArray;<br>        ExposeMetaData&lt; DoubleArrayType &gt;( dict, key, originArray );<br>        m_Origin[0] = originArray[0];<br>
        m_Origin[1] = originArray[1];<br>        m_Origin[2] = originArray[2];<br>        }<br><br>and lines 1984-1986:<br><br>  image.SetOrigin(0, m_Origin[0] );<br>  image.SetOrigin(1, m_Origin[1] );<br>  image.SetOrigin(2, m_Origin[2] );<br>
<br><br>That will  show you that, in summary, when using GDCM 2.0<br>the position (&quot;origin&quot;) of the image, is not taken from the <br>DICOM tag: 0x0020,0x0032 , but from the image content<br>specified in <br><br>
                    image-&gt;GetOrigin().<br><br><br>The behavior that you described in your email:<br><br>      Using the origin provided by the user <br>      in the tag 0x0020,0x0032) <br><br><br>only happens when you use a GDCM version &lt; 2,<br>
as you can verify in the lines 1473-1492:<br><br><br>  // In the case where user specifically set the Image Position (Patient) either<br>  // directly or indirectly using SetMetaDataDictionaryArray, we should not try<br>  // to override it&#39;s input<br>
  if( !header-&gt;GetValEntry(0x0020,0x0032 ) )<br>    {<br>    str.str(&quot;&quot;);<br>    str &lt;&lt; m_Origin[0] &lt;&lt; &quot;\\&quot; &lt;&lt; m_Origin[1] &lt;&lt; &quot;\\&quot;;<br><br>    if( m_Origin.size() == 3 )<br>
      {<br>      str &lt;&lt; m_Origin[2];<br>      }<br>    else // We are coming from the default SeriesWriter which is passing us a 2D image<br>      // therefore default to a Z position = 0, this will make the image at least valid<br>
      // if not correct<br>      {<br>      str &lt;&lt; 0.;<br>      }<br>    header-&gt;InsertValEntry(str.str(),0x0020,0x0032); // Image Position (Patient)<br>    }<br><br><br>These lines above are only used when <br><br>
      #if GDCM_MAJOR_VERSION &lt; 2<br><br><br>Therefore, <br>The safest way of changing the image origin <br>is actually by using the:<br><br><br>      itkChangeInformationImageFilter<br><a href="http://www.itk.org/Doxygen/html/classitk_1_1ChangeInformationImageFilter.html">http://www.itk.org/Doxygen/html/classitk_1_1ChangeInformationImageFilter.html</a><br>
<br><br>Please note however, that changing the origin of <br>an image is a very dramatic action, particularly if<br>you are dealing with DICOM image, and that you<br>must have a *very strong* justification for doing so.<br>
<br><br>In general changing the image parameters by hand,<br>is a dangerous thing to do.<br><br><br>Please let us know if you have other questions.<br><br><br> Enjoy the Freedom to understand <br> how Software Works   :-)<br>
<br><br> Enjoy Open Source !<br><br><br>          Luis<br><br><br>--------------------------------------------------------------------------<br><div class="gmail_quote">On Fri, Apr 16, 2010 at 5:15 AM, dev hurmex <span dir="ltr">&lt;<a href="mailto:dev@hurmex.fi">dev@hurmex.fi</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;">Hi,<div>
<br></div><div>I use ITK 3.16 + GDCM2.</div><div><br></div><div>I write a volume as DICOM series. I set the image position (tag(0020,0032)) before writing.</div>
<div>Why the writer (itk::ImageSeriesWriter ) changes it during writing process?</div><div><br></div><div>How the image position compute inside ITK or GDCM?</div></span>
<br>_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a 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 href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a 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 href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br>