[ITK] [ITK-users] Lost Patient, Study and Series DICOM tags
Yaniv, Ziv Rafael (NIH/NLM/LHC) [C]
zivrafael.yaniv at nih.gov
Thu Jul 7 10:43:39 EDT 2016
Hello Peter,
We are actually working on adding the set method for the upcoming release, which will be out shortly. One issue that we do want to point out, which likely you are aware of but just in case, you have to indicate in the Image Type tag ( (0008,0008) that this is a derived image. Please see the DICOM standard (http://dicom.nema.org/medical/dicom/current/output/pdf/part03.pdf), section C.7.6.1.1.2 for the details.
regards
Ziv
From: Piotr Piasecki <piotpia124 at student.polsl.pl<mailto:piotpia124 at student.polsl.pl>>
Date: Thursday, July 7, 2016 at 9:49 AM
To: Dženan Zukić <dzenanz at gmail.com<mailto:dzenanz at gmail.com>>, Bradley Lowekamp <brad at lowekamp.net<mailto:brad at lowekamp.net>>, "insight-users at itk.org<mailto:insight-users at itk.org>" <insight-users at itk.org<mailto:insight-users at itk.org>>
Subject: Re: [ITK-users] Lost Patient, Study and Series DICOM tags
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<mailto: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<mailto: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 describesonly 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<mailto: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<mailto: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<http://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/b7070345/attachment.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