Yes, of course. I try upload the patch now.<div><br></div><div>Thank you.</div><div><br><div class="gmail_quote">2011/4/15 Bill Lorensen <span dir="ltr"><<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">This is definitely a bug. And it was introduced in itk4.<br>
<br>
Alberto, Can you submit a patch to gerrit? <a href="http://itk.org/Wiki/ITK/Gerrit/Primer" target="_blank">http://itk.org/Wiki/ITK/Gerrit/Primer</a><br>
<br>
I can help you step through this process.<br>
<font color="#888888"><br>
Bill<br>
</font><div><div></div><div class="h5"><br>
On Fri, Apr 15, 2011 at 12:53 PM, Alberto <<a href="mailto:bertorey@gmail.com">bertorey@gmail.com</a>> wrote:<br>
> I only test it on this version.<br>
> I modify the class itkGDCMImageIO on line 711 replacing this code :<br>
> image.SetOrigin(2, 0);<br>
> by the following :<br>
> if( header.FindDataElement( gdcm::Tag(0x0020, 0x0032 ) )){<br>
> const gdcm::DataElement &de = header.GetDataElement( gdcm::Tag(0x0020,<br>
> 0x0032) );<br>
> std::pair<std::string, std::string> s = sf.ToStringPair( de.GetTag() );<br>
> std::string value= s.second;<br>
> sscanf( value.c_str(), "%lf\\%lf\\%lf", &(m_Origin[0]), &(m_Origin[1]),<br>
> &(m_Origin[2]) );<br>
> image.SetOrigin(2, m_Origin[2]);<br>
> }<br>
> and now the Image Patient Position tag is set ok with the correct value of<br>
> z-axis. Could this code be a valid patch for the problem?<br>
> Thank you.<br>
> 2011/4/15 Bill Lorensen <<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>><br>
>><br>
>> I realize that. I was asking Mical.<br>
>><br>
>> Did your code work properly with earlier versions of itk?<br>
>><br>
>> Bill<br>
>><br>
>> On Fri, Apr 15, 2011 at 12:30 PM, Alberto <<a href="mailto:bertorey@gmail.com">bertorey@gmail.com</a>> wrote:<br>
>> > The git version of ITK<br>
>> ><br>
>> > 2011/4/15 Bill Lorensen <<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>><br>
>> >><br>
>> >> What version of itk are you using?<br>
>> >><br>
>> >> On Thu, Apr 14, 2011 at 5:16 AM, Bc. Michal Srna <<a href="mailto:michal@srna.info">michal@srna.info</a>><br>
>> >> wrote:<br>
>> >> > 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" target="_blank">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<br>
>> >> > regarding<br>
>> >> > saving Image Position (origin) for "z" axis. "x,y" are stored well,<br>
>> >> > but<br>
>> >> > "z"<br>
>> >> > 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>
>> >> ><br>
>> >> > reader->GetOutput()->TransformIndexToPhysicalPoint(index, position);<br>
>> >> ><br>
>> >> > value.str("");<br>
>> >> > value << position[0] << "\\" << position[1]<br>
>> >> > <<<br>
>> >> > "\\"<br>
>> >> > << position[2];<br>
>> >> ><br>
>> >> ><br>
>> >> > itk::EncapsulateMetaData<std::string>(*dict,"0020|0032",<br>
>> >> > value.str());<br>
>> >> > //WHY<br>
>> >> > NOT WORKING??<br>
>> >> ><br>
>> >> > position[2] contains the correct value, but I don't know, why is that<br>
>> >> > value<br>
>> >> > 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<br>
>> >> > MetaDataDictionary for see my problem in context.<br>
>> >> ><br>
>> >> > At first it opens original data, from which I read original meta<br>
>> >> > data.<br>
>> >> > Then<br>
>> >> > I modify some parts of those meta data in for cycle creating meta<br>
>> >> > data<br>
>> >> > for<br>
>> >> > each slice.<br>
>> >> ><br>
>> >> > I confirmed, that original data contains correct value of Image<br>
>> >> > Position<br>
>> >> > in<br>
>> >> > "z" axis. But I need to recalculate that value and store new value.<br>
>> >> > Problem<br>
>> >> > is, as I told, that this value is not saved and instead of it, there<br>
>> >> > is<br>
>> >> > just<br>
>> >> > 0.<br>
>> >> ><br>
>> >> > Here is the whole code, spacing[x] is derived from other part of the<br>
>> >> > whole<br>
>> >> > code, I don't want to copy here:<br>
>> >> ><br>
>> >> > /*opening original data for getting meta data dictionry for saving it<br>
>> >> > into<br>
>> >> > output 2D series files*/<br>
>> >> > typedef itk::GDCMImageIO ImageIOType;<br>
>> >> > typedef itk::GDCMSeriesFileNames NamesGeneratorType;<br>
>> >> > typedef itk::ImageSeriesReader< ImageType > ReaderType;<br>
>> >> ><br>
>> >> > ImageIOType::Pointer gdcmIO = ImageIOType::New();<br>
>> >> > ReaderType::Pointer reader = ReaderType::New();<br>
>> >> ><br>
>> >> > NamesGeneratorType::Pointer namesGenerator =<br>
>> >> > NamesGeneratorType::New();<br>
>> >> > namesGenerator->SetInputDirectory( StudyFolderName );<br>
>> >> > const ReaderType::FileNamesContainer & filenames =<br>
>> >> > namesGenerator->GetInputFileNames();<br>
>> >> ><br>
>> >> > reader->SetImageIO( gdcmIO );<br>
>> >> > reader->SetFileNames( filenames );<br>
>> >> ><br>
>> >> > reader->Update();<br>
>> >> ><br>
>> >> > /*creating MetaDataDictionary for each slice*/<br>
>> >> ><br>
>> >> > /*Copy the dictionary from the first image and override<br>
>> >> > slice<br>
>> >> > specific fields*/<br>
>> >> > ReaderType::DictionaryRawPointer inputDictionary =<br>
>> >> > (*(reader->GetMetaDataDictionaryArray()))[0];<br>
>> >> > ReaderType::DictionaryArrayType<br>
>> >> > dictionaryOutputArray;<br>
>> >> ><br>
>> >> > /*To keep the new series in the same study as the<br>
>> >> > original<br>
>> >> > we<br>
>> >> > need 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 =<br>
>> >> > gdcm::Util::CreateUniqueUID(<br>
>> >> > gdcmIO->GetUIDPrefix());<br>
>> >> > std::string frameOfReferenceUID =<br>
>> >> > gdcm::Util::CreateUniqueUID( gdcmIO->GetUIDPrefix());<br>
>> >> > #endif<br>
>> >> > std::string studyUID;<br>
>> >> > std::string sopClassUID;<br>
>> >> > itk::ExposeMetaData<std::string>(*inputDictionary,<br>
>> >> > "0020|000d", studyUID);<br>
>> >> > itk::ExposeMetaData<std::string>(*inputDictionary,<br>
>> >> > "0008|0016", sopClassUID);<br>
>> >> > gdcmIO->KeepOriginalUIDOn();<br>
>> >> ><br>
>> >> > for (unsigned int f = 0; f < size[2]; f++)<br>
>> >> > {<br>
>> >> > // Create a new dictionary for this slice<br>
>> >> > ReaderType::DictionaryRawPointer dict = new<br>
>> >> > ReaderType::DictionaryType;<br>
>> >> ><br>
>> >> > // Copy the dictionary from the first slice<br>
>> >> > CopyDictionary (*inputDictionary, *dict);<br>
>> >> ><br>
>> >> > // Set the UID's for the study, series, SOP and<br>
>> >> > frame<br>
>> >> > of reference<br>
>> >> ><br>
>> >> > itk::EncapsulateMetaData<std::string>(*dict,"0020|000d", studyUID);<br>
>> >> ><br>
>> >> > itk::EncapsulateMetaData<std::string>(*dict,"0020|000e", seriesUID);<br>
>> >> ><br>
>> >> > itk::EncapsulateMetaData<std::string>(*dict,"0020|0052",<br>
>> >> > frameOfReferenceUID);<br>
>> >> ><br>
>> >> > #if ITK_VERSION_MAJOR >= 4<br>
>> >> > gdcm::UIDGenerator sopuid;<br>
>> >> > std::string sopInstanceUID =<br>
>> >> > sopuid.Generate();<br>
>> >> > #else<br>
>> >> > std::string sopInstanceUID =<br>
>> >> > gdcm::Util::CreateUniqueUID( gdcmIO->GetUIDPrefix());<br>
>> >> > #endif<br>
>> >> ><br>
>> >> > itk::EncapsulateMetaData<std::string>(*dict,"0008|0018",<br>
>> >> > sopInstanceUID);<br>
>> >> ><br>
>> >> > itk::EncapsulateMetaData<std::string>(*dict,"0002|0003",<br>
>> >> > 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>
>> >> ><br>
>> >> > itk::EncapsulateMetaData<std::string>(*dict,"0020|0013",<br>
>> >> > value.str());<br>
>> >> ><br>
>> >> > // Series Description - Append new description to<br>
>> >> > current series description<br>
>> >> > std::string oldSeriesDesc;<br>
>> >> ><br>
>> >> > itk::ExposeMetaData<std::string>(*inputDictionary,<br>
>> >> > "0008|103e", oldSeriesDesc);<br>
>> >> ><br>
>> >> > value.str("");<br>
>> >> > value << oldSeriesDesc<br>
>> >> > << spacing[0] << ", "<br>
>> >> > << spacing[1] << ", "<br>
>> >> > << spacing[2];<br>
>> >> ><br>
>> >> > // This is an long string and there is a 64<br>
>> >> > character<br>
>> >> > limit in the standard<br>
>> >> > unsigned lengthDesc = value.str().length();<br>
>> >> ><br>
>> >> > std::string seriesDesc( value.str(), 0,<br>
>> >> > lengthDesc > 64 ? 64<br>
>> >> > : lengthDesc);<br>
>> >> ><br>
>> >> > itk::EncapsulateMetaData<std::string>(*dict,"0008|103e", seriesDesc);<br>
>> >> ><br>
>> >> > // Series Number<br>
>> >> > value.str("");<br>
>> >> > value << 1001;<br>
>> >> ><br>
>> >> > itk::EncapsulateMetaData<std::string>(*dict,"0020|0011",<br>
>> >> > value.str());<br>
>> >> ><br>
>> >> > //Image Position Patient: This is calculated by<br>
>> >> > 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>
>> >> ><br>
>> >> > reader->GetOutput()->TransformIndexToPhysicalPoint(index, position);<br>
>> >> ><br>
>> >> > value.str("");<br>
>> >> > value << position[0] << "\\" << position[1]<br>
>> >> > <<<br>
>> >> > "\\"<br>
>> >> > << position[2];<br>
>> >> ><br>
>> >> ><br>
>> >> > itk::EncapsulateMetaData<std::string>(*dict,"0020|0032",<br>
>> >> > value.str());<br>
>> >> > //WHY<br>
>> >> > NOT WORKING??<br>
>> >> ><br>
>> >> > // Slice Location: For now, we store the z<br>
>> >> > component<br>
>> >> > of<br>
>> >> > the Image Position Patient.<br>
>> >> > value.str("");<br>
>> >> > value << position[2];<br>
>> >> ><br>
>> >> > itk::EncapsulateMetaData<std::string>(*dict,"0020|1041",<br>
>> >> > value.str());<br>
>> >> ><br>
>> >> > // Spacing Between Slices<br>
>> >> > value.str("");<br>
>> >> > value << spacing[2];<br>
>> >> ><br>
>> >> > itk::EncapsulateMetaData<std::string>(*dict,"0018|0088",<br>
>> >> > value.str());<br>
>> >> ><br>
>> >> > // Change specific values<br>
>> >> > //<br>
>> >> > itk::EncapsulateMetaData<std::string>(*dict,<br>
>> >> > "0028|0100", "16" );<br>
>> >> ><br>
>> >> ><br>
>> >> > // Save the dictionary<br>
>> >> > dictionaryOutputArray.push_back(dict);<br>
>> >> > }<br>
>> >> ><br>
>> >> > Thanks guys in advance...<br>
>> >> ><br>
>> >> > --<br>
>> >> > S pozdravem Bc. Michal Srna<br>
>> >> ><br>
>> >> > Fotografické portfolio:<br>
>> >> > <a href="http://michalsrna.cz" target="_blank">http://michalsrna.cz</a><br>
>> >> ><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>
>> >> ><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>
>> ><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>
>> ><br>
><br>
><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>
><br>
</div></div></blockquote></div><br></div>