# Use JoinSeriesImageFilter to append 4D images into 5D

**URL:** <https://discourse.itk.org/t/use-joinseriesimagefilter-to-append-4d-images-into-5d/6324>\
**Category:** Algorithms\
**Created:** [November 29, 2023, 2:10pm UTC](https://discourse.itk.org/t/use-joinseriesimagefilter-to-append-4d-images-into-5d/6324 "2023-11-29T14:10:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cpinter](https://discourse.itk.org/user_avatar/discourse.itk.org/cpinter/32/3683_2.png) [@cpinter](https://discourse.itk.org/u/cpinter)\
**Post date:** [November 29, 2023, 2:10pm UTC](https://discourse.itk.org/t/use-joinseriesimagefilter-to-append-4d-images-into-5d/6324/1 "2023-11-29T14:10:58Z")

</div>

Hi all,

I have a series of 4D images (3D + scalar component) with the same dimensions, scalar type, number of scalar components, and I’d like to append them into a single image (a time or other type of sequence of images) that would be in the end 5D (4D + component). Then I’d like to write the resulting 5D image into file using `ImageFileWriter`.

My question is whether this class can be safely used for this?  
[https://itk.org/Doxygen/html/classitk\_1\_1JoinSeriesImageFilter.html](https://itk.org/Doxygen/html/classitk_1_1JoinSeriesImageFilter.html)

Or if not, what other possibilities do I have within ITK?

This question is related to this thread:

> [@Reading and writing of 5D images - a dimension disappears](https://discourse.itk.org/t/reading-and-writing-of-5d-images-a-dimension-disappears/6210):
>
> Hi all, We’re trying to enable 3D Slicer to read and write vector image sequences (displacement field or velocity field: 3D spatial + component + time = 5 dimensions) into a single file. The format of choice is NRRD, and we thought the most correct way would be to use ITK’s NrrdImageIO (the alternative would be to improve vtkTeemNRRDWriter/Reader, but ITK is a much more core dependency than teem). I started testing the IO with a valid-looking 5D nrrd file that I created using pynrrd. The heade…

Thank you very much!

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [November 29, 2023, 2:46pm UTC](https://discourse.itk.org/t/use-joinseriesimagefilter-to-append-4d-images-into-5d/6324/2 "2023-11-29T14:46:58Z")

</div>

Join series should work. If it does not do exactly what you want, you could go a more manual path: construct a 5D image in memory, then use [PasteImageFilter](https://itk.org/Doxygen/html/classitk_1_1PasteImageFilter.html) to populate it with constituent components.

---

<div class="post-metadata">

**Author:** ![cpinter](https://discourse.itk.org/user_avatar/discourse.itk.org/cpinter/32/3683_2.png) [@cpinter](https://discourse.itk.org/u/cpinter)\
**Post date:** [November 29, 2023, 2:54pm UTC](https://discourse.itk.org/t/use-joinseriesimagefilter-to-append-4d-images-into-5d/6324/3 "2023-11-29T14:54:06Z")

</div>

Thank you very much for the fast answer! I’ll try the join series filter first and if there are problems continue with what you suggested.

---

<div class="post-metadata">

**Author:** ![cpinter](https://discourse.itk.org/user_avatar/discourse.itk.org/cpinter/32/3683_2.png) [@cpinter](https://discourse.itk.org/u/cpinter)\
**Post date:** [November 30, 2023, 2:16pm UTC](https://discourse.itk.org/t/use-joinseriesimagefilter-to-append-4d-images-into-5d/6324/4 "2023-11-30T14:16:56Z")

</div>

Just for the record, it seems that JoinImageSeriesImageFilter does work. If some problem does arise I’ll report here.

Thanks for the help!
