I am trying to add some metadata to a nifti file, but for some reason
none of the tags ever get written out. Here is how I am writing the
metadata:<br><br><div>---------------------------------------------- <br>
itk::MetaDataDictionary dict = measImage->GetMetaDataDictionary();<br> itk::EncapsulateMetaData<double>(dict, "TemporalResolution", 2.0);<br> itk::EncapsulateMetaData<unsigned int>(dict, "NumSections", series);<br>
itk::EncapsulateMetaData<unsigned int>(dict, "TimeDim", 3);<br> itk::EncapsulateMetaData<unsigned int>(dict, "SectionDim", 0);<br> //fill in mapping of Section Index to number section number i+5 <br>
for(int i=0 ; i<series ; i++ ) {<br> ostringstream oss;<br> oss.str("");<br> oss << "MapIndex " << i;<br> itk::EncapsulateMetaData<unsigned int>(dict, oss.str(), i+5);<br>
}<br> measImage->SetMetaDataDictionary(dict);<br> <br>#ifdef TEST<br> itk::EncapsulateMetaData<string>(dict, "0010|0040", "M");<br>#endif //TEST<br> <br>#define TEST<br>#ifdef TEST<br>
unsigned int tmp1000;<br> dict = measImage->GetMetaDataDictionary();<br> itk::ExposeMetaData<unsigned int>(dict, "TimeDim", tmp1000);<br> cout << "TimeDim " << tmp1000 << endl;;<br>
dict.Print(cout);<br>#endif<br><br>and I write the file with:<br>-----------------------------------------------------------------------<br> writer->SetFileName("out.nii"); <br> writer->SetInput(measImage);<br>
writer->Update();<br>-----------------------------------------------------------------------<br><br>When
I used ExposeMetaData/Print, all the metadata gets dumped fine. But if
I then write the image, then load the file, and use Print(), none of it gets printed. In fact I
am relatively sure that the data isn't getting written, since a call like this:<br>
$ cat out.nii | strings | less<br>doesn't
give me any of the tags, which, unless the tags are somehow encoded, it
should. Is there a trick to adding metadata to nifti headers?<br><br>Thanks,<br><br>-Micah Chambers<br><font color="#888888"></font></div>