[ITK] [ITK-users] Lost Patient, Study and Series DICOM tags

Piotr Piasecki piotpia124 at student.polsl.pl
Thu Jul 7 08:35:12 EDT 2016


Hi Dženan,

thank you for your help and for this example. Unfortunately, I have not
found method GetMetaDataDictionary() in SimpleITK in C# (I found only
GetMetaDataKeys() and GetMetaData(string key)). Also, I have not found a
method SetMetaDataDictionary or any other that allows me to assign DICOM
tags.

My short piece of code looks like this:

static public void ReadImage()
        {
            sitk.ImageFileReader reader = new sitk.ImageFileReader();
            reader.SetFileName(@".\DICOM_TEST\original.dcm");
            var image = reader.Execute();

            sitk.ImageFileWriter writer = new sitk.ImageFileWriter();
            writer.SetFileName(@".\DICOM_TEST\modified.dcm");
            writer.Execute(image);
        }

Another problem is that your example describes only loading and saving a
single .dcm file. What if I have to process a whole series of files using
sitk.ImageSeriesReader and sitk.ImageSeriesWriter?

Regards,

Peter.

2016-07-05 15:45 GMT+02:00 Dženan Zukić <dzenanz at gmail.com>:

> 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/community/attachments/20160707/5b5098fe/attachment-0001.html>
-------------- next part --------------
_____________________________________
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


More information about the Community mailing list