Hi John,<br><br><br>I had the same problem a few days ago.<br>I used gdcm to do what I want.<br><br>The following program print all the DICOM header information you want. You just have to specify the [Group,Element] of the tags.<br>
<br><br><span style="font-family: courier new,monospace;">#include <string.h></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">#include "gdcmStringFilter.h"</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">#include "gdcmReader.h"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">#include "gdcmSequenceOfItems.h"</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">#include "gdcmTesting.h"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">#include "gdcmTag.h"</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">int main(int argc, char *argv[])</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">{</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if( argc == 2 )</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> const char *filename = argv[1];</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> gdcm::StringFilter sf;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> gdcm::Reader r;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> r.SetFileName( filename );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> if( !r.Read() )</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> return 1;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> gdcm::DataSet const& ds = r.GetFile().GetDataSet();</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> sf.SetFile( r.GetFile() );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> int ret = 0;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> gdcm::DataSet::ConstIterator it = ds.Begin();</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> for( ; it != ds.End(); ++it)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> const gdcm::DataElement &ref = *it;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> std::pair<std::string, std::string> s = sf.ToStringPair( ref.GetTag() );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> gdcm::Tag tag = ref.GetTag(); </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> <br> // HERE you select de tags you want....<br><br style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;"> gdcm::Tag seriesDesc(0x0008,0x103e); // =tag of "Series description" => [0008,103E]</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> gdcm::Tag seriesInstUID(0x0020,0x000e); // =tag of "Series Instance UID" => [0020,000E]</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> gdcm::Tag nbSlices(0x0054,0x0081); // =tag of "Number of Slices" => [0054,0081] </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> if(tag == seriesDesc || tag == seriesInstUID || tag == nbSlices){</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> if( !s.second.empty() == 0)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> { </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> std::cout << /*s.first << " -> "*/ tag << " " << s.second << std::endl; </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }}</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return ret;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> return 0;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;"><br><br><br>But to use this program it is necessary to install gdcm (in the same way as ITK)<br><br><br><br>Regards,<br>
<br><br>Stéphane<br style="font-family: courier new,monospace;"><br><br><br><br><div class="gmail_quote">2008/11/5 John Smith <span dir="ltr"><<a href="mailto:af3113@yahoo.com">af3113@yahoo.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><div>Hi,<br><br>Is there a way to retrieve DICOM header information like: Time point (in case of 4D), Patient position, Study description, Protocol, etc. I use for the moment "itkGDCMImageIO", but it looks like I cannot do this job or may be I don't know how to do it. Is there a way to retrieve all of this information via that mentioned class, or do you recommend another class? or there no such a class which does that job at all?<br>
<br>Thanks,<br><br>J.<br></div></div><br>
</div><br>_______________________________________________<br>
Insight-users mailing list<br>
<a href="mailto:Insight-users@itk.org">Insight-users@itk.org</a><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>