# From pydicom data format to simpleITK

**URL:** <https://discourse.itk.org/t/from-pydicom-data-format-to-simpleitk/5543>\
**Category:** Beginner Questions\
**Tags:** dicom, simpleitk, python\
**Created:** [December 2, 2022, 12:29pm UTC](https://discourse.itk.org/t/from-pydicom-data-format-to-simpleitk/5543 "2022-12-02T12:29:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Naja](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/fbc32d/32.png) [@Naja](https://discourse.itk.org/u/Naja)\
**Post date:** [December 2, 2022, 12:29pm UTC](https://discourse.itk.org/t/from-pydicom-data-format-to-simpleitk/5543/1 "2022-12-02T12:29:28Z")

</div>

Is there a way for me to load a list of pydicom images straight into simpleITK in python without having to save them locally first?  
I’m working on a auto-segmentation project where I receive two pydicom lists ( one PET and one CT), they are in the format list\<pydicom.dataset.FileDataset\>. The script that runs the auto-segmentation usually takes a PET path and a CT path, but as they aren’t actually saved locally, that’s not a possibility. Is there a way for me to modify the code below, such that it takes the two lists and not two file paths?  
Thank you very much

```auto
    print('Reading PET..')
    reader = sitk.ImageSeriesReader()
    dicom_names = reader.GetGDCMSeriesFileNames(PET_path)
    reader.SetFileNames(dicom_names)
    
    reader.MetaDataDictionaryArrayUpdateOn()
    reader.SetOutputPixelType(sitk.sitkFloat32)
    imagePET = reader.Execute()
    
    print('Reading CT..')
    reader = sitk.ImageSeriesReader()
    dicom_names = reader.GetGDCMSeriesFileNames(CT_path)
    reader.SetFileNames(dicom_names)
    
    reader.MetaDataDictionaryArrayUpdateOn()
    reader.LoadPrivateTagsOn()
    imageCT = reader.Execute()

```

---

<div class="post-metadata">

**Author:** ![dchen](https://discourse.itk.org/user_avatar/discourse.itk.org/dchen/32/34_2.png) [@dchen](https://discourse.itk.org/u/dchen)\
**Post date:** [December 2, 2022, 3:05pm UTC](https://discourse.itk.org/t/from-pydicom-data-format-to-simpleitk/5543/2 "2022-12-02T15:05:00Z")

</div>

Looking at the pydicom docs, it looks like you can convert the pixel data into a numpy array. Then you can use SimpleITK’s GetImageFromArray function to convert the numpy array into a SimpleITK Image. You’d lose any meta-data information though. You’d have to transfer that over yourself.
