# How to convert 4D fMRI images to a series of 3D images?

**URL:** https://discourse.itk.org/t/how-to-convert-4d-fmri-images-to-a-series-of-3d-images/6322
**Category:** Beginner Questions
**Tags:** simpleitk
**Created:** [November 27, 2023, 11:06am UTC](https://discourse.itk.org/t/how-to-convert-4d-fmri-images-to-a-series-of-3d-images/6322 "2023-11-27T11:06:21Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![debapriya](https://discourse.itk.org/letter_avatar_proxy/v4/letter/d/bc79bd/32.png) [@debapriya](https://discourse.itk.org/u/debapriya)
#### Post date: [November 27, 2023, 11:06am UTC](https://discourse.itk.org/t/how-to-convert-4d-fmri-images-to-a-series-of-3d-images/6322/1 "2023-11-27T11:06:21Z")

</div>

Hello,

I am working with the ADHD200 dataset. It consists of anatomical and resting state fMRI images in `NIFTI (nii.gz)` format.

The fMRI images are 4D images. These represent 3D image of the brain over a period of time (time is the fourth dimension). I want to convert these 4D images into a series of 3D images, where each 3D image would represent the brain at a particular time instant.

Is it possible to do this using SimpleITK? Please tell me the process.

---

<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 27, 2023, 2:08pm UTC](https://discourse.itk.org/t/how-to-convert-4d-fmri-images-to-a-series-of-3d-images/6322/2 "2023-11-27T14:08:55Z")

</div>

Hello @debapriya,

Yes, this is easily done:

```auto
import SimpleITK as sitk

# image with 4 timepoints, each timepoint is a 3D image with size 2x2x2 and a constant value
image4d = sitk.JoinSeries([sitk.Image([2]*3, sitk.sitkUInt16)+i for i in range(4)])

#get the i'th 3D image
i=2
image3d = image4d[:,:,:,i]

```
