Hello,<br><br>I have used part of this code to generate MetaDataDictionary:<br><br><a href="http://www.itk.org/Wiki/ITK/Examples/DICOM/ResampleDICOM">http://www.itk.org/Wiki/ITK/Examples/DICOM/ResampleDICOM</a><br><br>Everything works, as I need, but I have just one problem in part regarding saving Image Position (origin) for &quot;z&quot; axis. &quot;x,y&quot; are stored well, but &quot;z&quot; value of Image Position is 0.<br>
<br>Here is that part of the code for saving the Image position:<br><br>                        ImageType::PointType position;<br>                        ImageType::IndexType index;<br>                        index[0] = 0;<br>
                        index[1] = 0;<br>                        index[2] = f;<br>                        reader-&gt;GetOutput()-&gt;TransformIndexToPhysicalPoint(index, position);<br>                        <br>                        value.str(&quot;&quot;);<br>
                        value &lt;&lt; position[0] &lt;&lt; &quot;\\&quot; &lt;&lt; position[1] &lt;&lt; &quot;\\&quot; &lt;&lt; position[2];<br><br>                        itk::EncapsulateMetaData&lt;std::string&gt;(*dict,&quot;0020|0032&quot;, value.str()); //WHY NOT WORKING??<br>
<br>position[2] contains the correct value, but I don&#39;t know, why is that value not saved and instead of that value is stored just 0?<br><br>I think I should add also the whole code for generating my MetaDataDictionary for see my problem in context.<br>
<br>At first it opens original data, from which I read original meta data. Then I modify some parts of those meta data in for cycle creating meta data for each slice. <br><br>I confirmed, that original data contains correct value of Image Position in &quot;z&quot; axis. But I need to recalculate that value and store new value. Problem is, as I told, that this value is not saved and instead of it, there is just 0.<br>
<br>Here is the whole code, spacing[x] is derived from other part of the whole code, I don&#39;t want to copy here:<br><br>/*opening original data for getting meta data dictionry for saving it into output 2D series files*/<br>
            typedef itk::GDCMImageIO ImageIOType;<br>            typedef itk::GDCMSeriesFileNames NamesGeneratorType;<br>            typedef itk::ImageSeriesReader&lt; ImageType &gt; ReaderType;<br><br>            ImageIOType::Pointer gdcmIO = ImageIOType::New();<br>
            ReaderType::Pointer reader = ReaderType::New();<br><br>            NamesGeneratorType::Pointer namesGenerator = NamesGeneratorType::New();<br>            namesGenerator-&gt;SetInputDirectory( StudyFolderName );<br>
            const ReaderType::FileNamesContainer &amp; filenames = namesGenerator-&gt;GetInputFileNames();<br>    <br>            reader-&gt;SetImageIO( gdcmIO );<br>            reader-&gt;SetFileNames( filenames );<br><br>
            reader-&gt;Update();<br>        <br>        /*creating MetaDataDictionary for each slice*/<br>            <br>            /*Copy the dictionary from the first image and override slice specific fields*/<br>                ReaderType::DictionaryRawPointer inputDictionary = (*(reader-&gt;GetMetaDataDictionaryArray()))[0];<br>
                ReaderType::DictionaryArrayType dictionaryOutputArray;<br><br>            /*To keep the new series in the same study as the original we need to keep the same study UID. But we need new series and frame of 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;(*inputDictionary, &quot;0020|000d&quot;, studyUID);<br>
                  itk::ExposeMetaData&lt;std::string&gt;(*inputDictionary, &quot;0008|0016&quot;, sopClassUID);<br>                  gdcmIO-&gt;KeepOriginalUIDOn();<br>                 <br>                for (unsigned int f = 0; f &lt; size[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 (*inputDictionary, *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 description<br>                        std::string oldSeriesDesc;<br>                        itk::ExposeMetaData&lt;std::string&gt;(*inputDictionary, &quot;0008|103e&quot;, oldSeriesDesc);<br>
<br>                        value.str(&quot;&quot;);<br>                        value &lt;&lt; oldSeriesDesc<br>                              &lt;&lt; spacing[0] &lt;&lt; &quot;, &quot; <br>                              &lt;&lt; spacing[1] &lt;&lt; &quot;, &quot; <br>
                              &lt;&lt; spacing[2];<br><br>                    // This is an long string and there is a 64 character limit in the 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>                    //Image Position Patient: This is calculated by computing the physical coordinate of the first pixel in each slice.<br>                        ImageType::PointType position;<br>                        ImageType::IndexType index;<br>
                        index[0] = 0;<br>                        index[1] = 0;<br>                        index[2] = f;<br>                        reader-&gt;GetOutput()-&gt;TransformIndexToPhysicalPoint(index, position);<br>
                        <br>                        value.str(&quot;&quot;);<br>                        value &lt;&lt; position[0] &lt;&lt; &quot;\\&quot; &lt;&lt; position[1] &lt;&lt; &quot;\\&quot; &lt;&lt; position[2];<br>
<br>                        itk::EncapsulateMetaData&lt;std::string&gt;(*dict,&quot;0020|0032&quot;, value.str()); //WHY NOT WORKING??<br><br>                    // Slice Location: For now, we store the z component of the Image Position Patient.<br>
                        value.str(&quot;&quot;);<br>                        value &lt;&lt; position[2];<br>                        itk::EncapsulateMetaData&lt;std::string&gt;(*dict,&quot;0020|1041&quot;, value.str());      <br>
<br>                    // Spacing Between Slices<br>                        value.str(&quot;&quot;);<br>                        value &lt;&lt; spacing[2];<br>                        itk::EncapsulateMetaData&lt;std::string&gt;(*dict,&quot;0018|0088&quot;, value.str());<br>
<br>                    // Change specific values<br>                        //  itk::EncapsulateMetaData&lt;std::string&gt;(*dict, &quot;0028|0100&quot;, &quot;16&quot; );<br><br><br>                    // Save the dictionary<br>
                        dictionaryOutputArray.push_back(dict);<br>                  }<br><br>Thanks guys in advance...<br clear="all"><br>-- <br>S pozdravem Bc. Michal Srna<br><br>Fotografické portfolio:<br><a href="http://michalsrna.cz">http://michalsrna.cz</a><br>