# 2D multiplanar (sagittal) from cross sequence

**URL:** <https://discourse.itk.org/t/2d-multiplanar-sagittal-from-cross-sequence/3861>\
**Category:** Beginner Questions\
**Tags:** nifti, simpleitk, python\
**Created:** [February 12, 2021, 12:09pm UTC](https://discourse.itk.org/t/2d-multiplanar-sagittal-from-cross-sequence/3861 "2021-02-12T12:09:23Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![AmericaBG](https://discourse.itk.org/user_avatar/discourse.itk.org/americabg/32/1925_2.png) [@AmericaBG](https://discourse.itk.org/u/AmericaBG)\
**Post date:** [February 12, 2021, 12:09pm UTC](https://discourse.itk.org/t/2d-multiplanar-sagittal-from-cross-sequence/3861/1 "2021-02-12T12:09:23Z")

</div>

Hi!  
There goes my problem:

I want to obtain 2D sagittal slices from a 3D volume composed of cross images. So far so good.

My problem arrives when I want to resample/reform this sagittal images with a STIR sequence from the same pacient.  
I would like to work with “real dimension” information and no with pixels to achieve this sequences (sag and stir) matching.

I’ve tried with ResampleImageFilter in Python but that’s what I obtain:  
 ![image](https://discourse.itk.org/uploads/default/original/2X/2/243bc85c36b60c84ebdc54fc5482d68ab6c76681.png)

Could you help me please? 🙂  
Thank you very much in advance!

Just to clarify:  
Example of Sagittal image slice  
 ![image](https://discourse.itk.org/uploads/default/original/2X/a/acc2709d23c1d9a9c8161dc60c4acede711b49d5.jpeg)

Example of STIR image from the same subject  
 ![image](https://discourse.itk.org/uploads/default/original/2X/e/e8c14ceb7b1ac876d596fc073376e446ca5a3c84.jpeg)

---

<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:** [February 12, 2021, 2:24pm UTC](https://discourse.itk.org/t/2d-multiplanar-sagittal-from-cross-sequence/3861/2 "2021-02-12T14:24:00Z")

</div>

Hello @AmericaBG,

Welcome to SimpleITK!

To extract a slice from a volume use the slicing operator:

```auto
image[int(image.Width()/2), :, :]
image[:, int(image.GetHeight()/2), :]
image[:, :, int(image.GetDepth()/2)]

```

For display purposes you may want to make the slices isotropic if they aren’t. I recommend going over [the Jupyter notebook dealing with visualization](https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks/blob/master/Python/05_Results_Visualization.ipynb). Also, possibly the [notebook describing resampling](https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks/blob/master/Python/21_Transforms_and_Resampling.ipynb).

I highly recommend skimming the [notebook repository](https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks) (you’ll find reasonable visualization components there) and possibly going over the [online tutorial](https://simpleitk.org/TUTORIAL/).

---

<div class="post-metadata">

**Author:** ![AmericaBG](https://discourse.itk.org/user_avatar/discourse.itk.org/americabg/32/1925_2.png) [@AmericaBG](https://discourse.itk.org/u/AmericaBG)\
**Post date:** [February 12, 2021, 4:11pm UTC](https://discourse.itk.org/t/2d-multiplanar-sagittal-from-cross-sequence/3861/3 "2021-02-12T16:11:36Z")

</div>

Thank you very much @zivy, but I think that my explanation isn’t so good 😅

What I want is, once I have the set of Sag and STIR images, to achieve a type of “mapping” between both images, so that they are referenced in the same “real world” coordinate system, as the images are acquired to the same subject, equipment and session.

I think that with this images I could explain a little bit better.

In this one, we can see in red the sagital image and stir in blu.

 ![image](https://discourse.itk.org/uploads/default/original/2X/5/5c8d9cfe115c7802e7ab934179bb37737cdc5ccb.jpeg)

What I want is achieve this overlap and for that I would have to take into account some transform.

 ![image](https://discourse.itk.org/uploads/default/original/2X/b/be2ec314ef9345f97bf8c47c6832ce69dc2e2e04.jpeg)

I hope I have explained myself better.  
Thank you very much!

---

<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:** [February 12, 2021, 6:19pm UTC](https://discourse.itk.org/t/2d-multiplanar-sagittal-from-cross-sequence/3861/4 "2021-02-12T18:19:00Z")

</div>

Hello @AmericaBG,

Still not 100% sure that I understand what you want:

1. Register, align, two 3D MRI images that are not aligned.
2. Overlay data from one image onto the other and extract a sagital slice of the combined image.

Do you need to do step 1 before step 2, or are your images intrinsically aligned and we don’t need step 1 (transformation between the two is the identity).

Please clarify.

---

<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:** [February 12, 2021, 6:32pm UTC](https://discourse.itk.org/t/2d-multiplanar-sagittal-from-cross-sequence/3861/5 "2021-02-12T18:32:47Z")

</div>

It sounds to me like you want to resample one image into the grid of the other image. That can be achieved with resample example and identity transform, assuming your images are already aligned like in the ITK-SNAP screenshot.

---

<div class="post-metadata">

**Author:** ![AmericaBG](https://discourse.itk.org/user_avatar/discourse.itk.org/americabg/32/1925_2.png) [@AmericaBG](https://discourse.itk.org/u/AmericaBG)\
**Post date:** [February 13, 2021, 9:16am UTC](https://discourse.itk.org/t/2d-multiplanar-sagittal-from-cross-sequence/3861/6 "2021-02-13T09:16:25Z")

</div>

Thank you very much @zivy and @dzenanz for your time and attention!

What I want is what you say @dzenanz .

The only difference is that my sagital slice (256x126) obtained from the 3D axial volume (MxNxn\_slices=256x256x126) isn’t already aligned with the stir image (512x512).

My sagital image:  
 ![image](https://discourse.itk.org/uploads/default/original/2X/0/0fa9d4c965792011aaf5b531c79902cdebff8ba3.jpeg)

I want convert the sagital slice to the space of the stir image to get the result of this image:

 ![image](https://discourse.itk.org/uploads/default/original/2X/b/be2ec314ef9345f97bf8c47c6832ce69dc2e2e04.jpeg)

So, I’m not sure what I have to do (use pixel spacing, space between slices, image position, image orientation information…). I’m too beginner 😣

I appreciate all the help!

All the best.

---

<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:** [February 15, 2021, 5:21pm UTC](https://discourse.itk.org/t/2d-multiplanar-sagittal-from-cross-sequence/3861/7 "2021-02-15T17:21:22Z")

</div>

If you have just one slice, you need 2D-3D registration. If multiple slices, then you need multi-modal 3D registration.

---

<div class="post-metadata">

**Author:** ![AmericaBG](https://discourse.itk.org/user_avatar/discourse.itk.org/americabg/32/1925_2.png) [@AmericaBG](https://discourse.itk.org/u/AmericaBG)\
**Post date:** [February 16, 2021, 1:05pm UTC](https://discourse.itk.org/t/2d-multiplanar-sagittal-from-cross-sequence/3861/8 "2021-02-16T13:05:06Z")

</div>

Thank you all! I’ve solved my problem.  
All I need was to use ‘Resample’ 😅

Now, I’ve my Sagital image resample to the Stir space:  
Resampled Sagital:  
 ![image](https://discourse.itk.org/uploads/default/original/2X/b/bdd44d90f696e50204aa9b6c8891a60228e08a2b.png)  
STIR:  
 ![image](https://discourse.itk.org/uploads/default/original/2X/0/0d22580015c21ecde273f0f30ce666b27a728e04.jpeg)  
Overlay:  
 ![image](https://discourse.itk.org/uploads/default/original/2X/7/70a75bec0baa2f7a690426a542561e529b8dc0bc.jpeg)

I’m trying to do the same with a Sagital mask segmentation, but my result is only black images. (I’m using sitkNearestNeighbor as interpolator)

Have you got any idea about what could be the problem?

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:** [February 16, 2021, 2:07pm UTC](https://discourse.itk.org/t/2d-multiplanar-sagittal-from-cross-sequence/3861/9 "2021-02-16T14:07:41Z")

</div>

You might need to load your mask images as segmentations. If you load it as an intensity image, values of 1 or 2 are black, just not the absolute black as 0. If you drag-drop the mask into ITK-SNAP, use “Load as segmentation” button.

---

<div class="post-metadata">

**Author:** ![AmericaBG](https://discourse.itk.org/user_avatar/discourse.itk.org/americabg/32/1925_2.png) [@AmericaBG](https://discourse.itk.org/u/AmericaBG)\
**Post date:** [February 16, 2021, 2:29pm UTC](https://discourse.itk.org/t/2d-multiplanar-sagittal-from-cross-sequence/3861/10 "2021-02-16T14:29:13Z")

</div>

Yes, thank you @dzenanz, I knew it 😊  
I wanted to say with simpleitk in python.

---

<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:** [February 16, 2021, 2:53pm UTC](https://discourse.itk.org/t/2d-multiplanar-sagittal-from-cross-sequence/3861/11 "2021-02-16T14:53:13Z")

</div>

Is [LabelToRGBImageFilter](https://itk.org/Doxygen/html/classitk_1_1LabelToRGBImageFilter.html) available in SimpleITK? If yes, use it.

---

<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:** [February 16, 2021, 3:08pm UTC](https://discourse.itk.org/t/2d-multiplanar-sagittal-from-cross-sequence/3861/12 "2021-02-16T15:08:05Z")

</div>

Yes. [LabelToRGBImageFilter](https://simpleitk.org/doxygen/v1_0/html/classitk_1_1simple_1_1LabelToRGBImageFilter.html) and [LabelMapToRGBImageFilter](https://simpleitk.org/doxygen/v1_0/html/classitk_1_1simple_1_1LabelMapToRGBImageFilter.html) have been in SimpleITK since before 1.0.

---

<div class="post-metadata">

**Author:** ![AmericaBG](https://discourse.itk.org/user_avatar/discourse.itk.org/americabg/32/1925_2.png) [@AmericaBG](https://discourse.itk.org/u/AmericaBG)\
**Post date:** [February 16, 2021, 3:20pm UTC](https://discourse.itk.org/t/2d-multiplanar-sagittal-from-cross-sequence/3861/13 "2021-02-16T15:20:33Z")

</div>

Thank you very much about your help!

Finally, why I couldn’t see my resampled segmentation is that I was doing the resample with a nii mask that hadn’t the correct header, so the spacing, origin, orientation… weren’t related to the STIR space and the result was wrong.  
 ![image](https://discourse.itk.org/uploads/default/original/2X/e/ed0dbfcae9eae6a5614312d35d18d4e2dd6ee377.png)  
Now is correct, thank you one more time!

All the best!
