# Saving series in any direction

**URL:** <https://discourse.itk.org/t/saving-series-in-any-direction/7300>\
**Category:** Algorithms\
**Created:** [November 4, 2024, 1:55am UTC](https://discourse.itk.org/t/saving-series-in-any-direction/7300 "2024-11-04T01:55:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhangm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/z/34f0e0/32.png) [@zhangm](https://discourse.itk.org/u/zhangm)\
**Post date:** [November 4, 2024, 1:55am UTC](https://discourse.itk.org/t/saving-series-in-any-direction/7300/1 "2024-11-04T01:55:46Z")

</div>

I have a metaData and a direction matrix, and I want to save the 3D data to a series 2d images according to the matrix. I find there is a function `itkImageSeriesWriter` to save series. But I didn’t find how to change the save direction.  
Any suggestions will be appreciate.

---

<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:** [November 4, 2024, 2:04pm UTC](https://discourse.itk.org/t/saving-series-in-any-direction/7300/2 "2024-11-04T14:04:33Z")

</div>

Hello @zhangm,

One of these examples is probably what you are looking for, [DicomSeriesReadSeriesWrite](https://itk.org/Doxygen/html/Examples_2IO_2DicomSeriesReadSeriesWrite_8cxx-example.html) or [ImageReadDicomSeriesWrite](https://itk.org/Doxygen/html/Examples_2IO_2ImageReadDicomSeriesWrite_8cxx-example.html).

Note that in ITK the metaData is not separate from the image. The matrix you have is likely describing the image’s direction cosine matrix and possibly the origin. ITK takes that information directly from the image so you may need to set them if they are different from what is already set for your 3D image.

---

<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 4, 2024, 2:11pm UTC](https://discourse.itk.org/t/saving-series-in-any-direction/7300/3 "2024-11-04T14:11:28Z")

</div>

If you want your slices to be in particular orientation, you should take a look at `OrientImageFilter`.

---

<div class="post-metadata">

**Author:** ![zhangm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/z/34f0e0/32.png) [@zhangm](https://discourse.itk.org/u/zhangm)\
**Post date:** [November 5, 2024, 1:59am UTC](https://discourse.itk.org/t/saving-series-in-any-direction/7300/4 "2024-11-05T01:59:21Z")

</div>

Thank you for the suggestions from @zivy and @dzenanz .  
The matrix I have is a matrix4x4 used for `vtkImageSlice` to get a single slice. As your suggestions, I first used `OrientImageFilter` to change the direction of the data, and next used `ImageSeriesWriter` to save series.
