[ITK-users] Lost Patient, Study and Series DICOM tags
Dženan Zukić
dzenanz at gmail.com
Tue Jul 5 09:45:16 EDT 2016
Hi Piotr,
if you want to carry over metadata from input image to output image, you
should save the metadata dictionary in a way similar to this:
itk::MetaDataDictionary metadata;
template< typename TImage >
itk::SmartPointer<TImage> readImage(std::string fileName)
{
typedef itk::ImageFileReader<TImage> ReaderType;
typename ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(fileName.c_str());
try
{
reader->Update();
metadata = reader->GetMetaDataDictionary();
return reader->GetOutput();
}
catch (itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return NULL;
}
}
template< typename TImage >
void writeImage(itk::SmartPointer<TImage> image, std::string fileName)
{
image->SetMetaDataDictionary(metadata); //full metadata
typedef itk::ImageFileWriter<TImage> WriterType;
typename WriterType::Pointer writer = WriterType::New();
writer->SetFileName(fileName.c_str());
writer->SetInput(image);
try
{
writer->Update();
}
catch (itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
}
}
On Tue, Jul 5, 2016 at 2:46 AM, Piotr Piasecki <piotpia124 at student.polsl.pl>
wrote:
> Dear Sir or Madam.
>
> I am a student in Biomedical Engineering at the Silesian University of
> Technology. During my studies I worked with ITK and SimpleITK in C#. I want
> to use them in my current project, but I have an important question. After
> loading and processing a series of .dcm files I lost information about the
> patient and study to which they belong, and that they belong to one series.
> How can I keep this information?
>
> I will be very grateful for any answer.
>
> Best regards.
>
> Peter.
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/insight-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20160705/17a481bf/attachment.html>
More information about the Insight-users
mailing list