1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] How to sort DICOM images in reverse order (by Slice Location) with SimpleITK?

Discussão em 'Python' iniciado por Stack, Setembro 11, 2024.

  1. Stack

    Stack Membro Participativo

    I am new to SimpleITK, so I would really appreciate any help! My question is specific to SimpleITK (not Pydicom).

    I imported CT DICOM slices from a directory and opened them using SimpleITK. The slices are ordered by the slice location. I was wondering if it's possible to reverse the order of the images? I am sure I can do that after getting the image array and manipulating it. But would it be possible to reverse the order before getting the image array?

    Here is the code that I am working with:

    import SimpleITK as sitk

    dir_name = "Directory of the Folder that contains individual DICOM slices"
    reader = sitk.ImageSeriesReader()
    filenames = reader.GetGDCMSeriesFileNames(dir_name)
    reader.SetFileNames(filenames)
    reader.MetaDataDictionaryArrayUpdateOn() # to get metadata
    image_import = reader.Execute()
    image_array = sitk.GetArrayFromImage(image_import) # getting the image array


    I guess I can sort by the reverse order by manipulating image_array, but I was wondering if there is other way which does that beforehand. (I thought the other way would be useful for image registration down the line.)

    Continue reading...

Compartilhe esta Página