# make a set of 3D images into a 4D image

**URL:** <https://discourse.itk.org/t/make-a-set-of-3d-images-into-a-4d-image/2065>\
**Category:** Algorithms\
**Created:** [July 19, 2019, 8:02pm UTC](https://discourse.itk.org/t/make-a-set-of-3d-images-into-a-4d-image/2065 "2019-07-19T20:02:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jrojasUNC](https://discourse.itk.org/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@jrojasUNC](https://discourse.itk.org/u/jrojasUNC)\
**Post date:** [July 19, 2019, 8:02pm UTC](https://discourse.itk.org/t/make-a-set-of-3d-images-into-a-4d-image/2065/1 "2019-07-19T20:02:07Z")

</div>

Hi I am trying to stitch together a series of 100 3D (512, 128, 200) images into a single 4D (512, 128, 200, 100) image using simpleITK. I have tried using the TileImageFilter but I only get an image that is 512, 128, 200 if I set the layout to (1,1,1,0), and the JoinSeriesImageFilter but when I combine the first two images I get a 4D image, which means that when I try to join the combination of the first 2 images with the 3rd image, they don’t have the same dimensionality so the filter fails. Any Ideas?

Thanks,

Juan

---

<div class="post-metadata">

**Author:** ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)\
**Post date:** [July 19, 2019, 8:08pm UTC](https://discourse.itk.org/t/make-a-set-of-3d-images-into-a-4d-image/2065/2 "2019-07-19T20:08:26Z")

</div>

Hello Juan,

You should be able to pass all 100 3D image to `JoinSeriesImageFilter` to create the desired 4D image. Please provide some sample code, if you need further assistance.

---

<div class="post-metadata">

**Author:** ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)\
**Post date:** [July 19, 2019, 8:12pm UTC](https://discourse.itk.org/t/make-a-set-of-3d-images-into-a-4d-image/2065/3 "2019-07-19T20:12:27Z")

</div>

Per Brad’s pointer to the JoinSeriesFilter, below is procedural code to do it:

```auto
import SimpleITK as sitk

img = sitk.Image([512,128,200], sitk.sitkUInt8)
print(img.GetSize())
res = sitk.JoinSeries([img]*3) #join list of three images
print(res.GetSize())

```

---

<div class="post-metadata">

**Author:** ![jrojasUNC](https://discourse.itk.org/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@jrojasUNC](https://discourse.itk.org/u/jrojasUNC)\
**Post date:** [July 19, 2019, 9:55pm UTC](https://discourse.itk.org/t/make-a-set-of-3d-images-into-a-4d-image/2065/4 "2019-07-19T21:55:44Z")

</div>

Thank you, that worked!

Juan
