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

Dženan Zukić dzenanz at gmail.com
Thu Jul 7 10:11:21 EDT 2016


If SimpleITK does not provide write access to meta-data dictionary, you can
indicate patient, study and series in the filename by specially formatting
it.

Hopefully Brad can provide more useful advice.

Regards

On Thu, Jul 7, 2016 at 9:49 AM, Piotr Piasecki <piotpia124 at student.polsl.pl>
wrote:

> Hello Again
>
> I found the information, that in SimpleITK the MetaDataDictionary
> interface is only part of the Image class. Currently it provides a read
> only interface, with the GetMetaDataKeys(), and GetMetaData(key) methods.
> This get method only returns the type of data in the dictionary converted
> to a string.
>
> The required method would be Image::SetMetaData(key,value). But
> unfortunately I do not see this method, so I think that this is still not
> implemented. The only what I need is to keep information that my files
> belong to one series of images, which belongs to one patient and study (
> not necessarily the same study or series as the original).
>
> Regards.
>
> Peter.
>
>
>
> 2016-07-07 14:45 GMT+02:00 Dženan Zukić <dzenanz at gmail.com>:
>
>> Hi Piotr,
>>
>> instead of ImageReader->GetMetaDataDictionary() call
>> ImageSeriesReader->GetMetaDataDictionary(). Also, the image format you are
>> writing to needs to be able to support metadata (e.g. .mha, .nrrd, DICOM),
>> otherwise the metadata is lost (.nii, .jpg, .bmp etc).
>>
>> But for writing DICOM, the process might be somewhat different from what
>> I described in the first email. Definitely different if you want metadata
>> copied slice for slice from input to output - in this case some metadata
>> needs to be changed anyway, such as flag that this is a derived image and
>> not an original image coming out of a scanner.
>>
>> I suppose that MetaDataDictionary class is not wrapped. You can then loop
>> through all the keys and copy them and their content one by one.
>>
>> Regards
>>
>> On Thu, Jul 7, 2016 at 8:35 AM, Piotr Piasecki <
>> piotpia124 at student.polsl.pl> wrote:
>>
>>> 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/insight-users/attachments/20160707/fa4c42ad/attachment.html>


More information about the Insight-users mailing list