Hello high tea key,
i am trying to read image and metadata from a folder with the following code.
It succeed to open the image but find no metadata and i sure they are. How can i access to them?
from _main_import vtk, qt, ctk, slicer
from math import *
import numpy as np
from vtk.util import numpy_support
import SimpleITK as sitk
import sitkUtils as su
import math
data_directory = "D:/travail/M2-2020/199200661/test"
series_IDs = sitk.ImageSeriesReader.GetGDCMSeriesIDs(data_directory)
if not series_IDs:
print("ERROR:""+data_directory+"\" does not contain DICOM series.")
sys.exit(1)
for i,series_ID in enumerate(series_IDs):
series_file_names = sitk.ImageSeriesReader.GetGDCMSeriesFileNames(data_directory, series_ID,useSeriesDetails=False) #useSeriesDetails ?
print(series_file_names)
series_reader = sitk.ImageSeriesReader()
series_reader.SetMetaDataDictionaryArrayUpdate(True)
series_reader.SetLoadPrivateTagsOn(True)
series_reader.SetFileNames(series_file_names)
try:
img = series_reader.Execute()
#sitk.Show( img, "Dicom Series" )
print(img.GetSpacing())
print(img.GetSize())
su.PushToSlicer(img, "image_"+series_ID,1)
for k in series_reader.GetMetaDataKeys(0):
v = series_reader.GetMetaData(0,k)
print("({0}) = = \"{1}\"".format(k,v))
except RuntimeError:
print ("--> Fundamental error in image layer, skipping...")