I am trying to perform a simple task where I read in images with for loop, join them together and write it as a single image. But somehow sitk.JoinSeriesImageFilter does not join the images into a single stack, instead images are processed individually according to for loop.
I tried to make a list of images and then pass it to sitk.JoinSeriesImageFilter but it would not work.
However if I don’t use the for loop and read in individual image manually, it gives the desired outcome.
Can someone tell me what I am missing out?
Here is my code:
for file in sorted(glob.glob(filepath)): #read image_all = sitk.ReadImage(file, imageIO="TIFFImageIO") join = sitk.JoinSeriesImageFilter() joined_image = join.Execute(image_all) #write writer = sitk.ImageFileWriter() writer.SetFileName("test_write.dcm") writer.Execute(joined_image)