[ITK-users] Exporting DICOM via SimpleITK in Python

Bradley Lowekamp blowekamp at mail.nih.gov
Fri Apr 22 15:16:44 EDT 2016


Hello,

In general writing out a correct DICOM series is not a “Simple” thing to do. And requires a good bit of study into DICOM specifications. The tag in each file need to be correct copied and updated based on how you processed the image and the manipulations done.

I am not a DICOM expert, but the experts I have talked to says is a lot of work and trouble. So this method is not in SimpleITK yet.

Why do you want you output to be DICOM? What were you planning on putting in to the tags for the slices you create?

You don’t need to go to numpy to pad your image. You can use the ConstantPadImageFilter[1] and by using the ITK filter you will maintain correct physical location of you image. That is it will correctly update the origin and offset, based on the operation performed.

HTH,
Brad

[1] http://www.itk.org/SimpleITKDoxygen/html/classitk_1_1simple_1_1ConstantPadImageFilter.html

> On Apr 22, 2016, at 1:09 PM, G <glebber at gmail.com> wrote:
> 
> Good afternoon,
> 
> I am a fairly new SimpleITK user and had a question about modifying and exporting DICOMs using Python.
> 
> If, for example we start off with a 512x512x100 image, I would like to add a buffer zone around it with voxel values of -1000 making it a 600x600x100 image. 
> 
> So for example, I can import the DICOM files:
> 
> import SimpleITK 
> def importDICOM(inputLocation):
>     reader = SimpleITK.ImageSeriesReader()
>     filenamesDICOM = reader.GetGDCMSeriesFileNames(inputLocation)
>     reader.SetFileNames(filenamesDICOM)
>     image = reader.Execute()
>     return image
> 
> And I know that SimpleITK.GetArrayFromImage(image) will return a numpy array that I can manipulate to get said 600x600x100 image. 
> 
> After I have my 600x600x100 image I would need to update the Meta Data gotten from SimpleITK.GetMetaData() and save it back as DICOMs. 
> 
> I know there is a SimpleITK.WriteImage() function, however, there is no SimpleITK.SetMetaData() function so I was wondering what the best procedure would be.
> 
> Grateful for your help,
> Gleb
> _____________________________________
> 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 Insight-users mailing list