# Rendering two NRDD files side to side with different origin, space coordinates and spacing

**URL:** <https://discourse.slicer.org/t/rendering-two-nrdd-files-side-to-side-with-different-origin-space-coordinates-and-spacing/2369>\
**Category:** Support\
**Tags:** python, nrrd\
**Created:** [March 20, 2018, 12:38am UTC](https://discourse.slicer.org/t/rendering-two-nrdd-files-side-to-side-with-different-origin-space-coordinates-and-spacing/2369 "2018-03-20T00:38:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dcantor](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/dcantor/32/782_2.png) [@dcantor](https://discourse.slicer.org/u/dcantor)\
**Post date:** [March 20, 2018, 12:38am UTC](https://discourse.slicer.org/t/rendering-two-nrdd-files-side-to-side-with-different-origin-space-coordinates-and-spacing/2369/1 "2018-03-20T00:38:17Z")

</div>

Hello,

I have two NRRD files:

- T2W (1)
- ADC (2)

When I load these two files in Slicer I can see that slicer automatically positions them in space according to their metadata and performs interpolation. I can tell that because (2) has a larger spacing than (1) and yet I can visualize slices from (2) as I scroll through (1).

I am writing a python script that take these two files and visualize them side to side. I don’t think I need to run registration since I already know the origin, spacing and orientation of each volume (as per their NRRD headers).

So, how can I do this: For each slice in (1) I want to show what would be the corresponding slice in (2)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/f/0f224af8e68b11bdc4e1d2b9805cc656105d20ac.png)

I know that somehow I need to apply an affine transform and do some interpolation in (2) to change coordinates but I am a bit lost.

Since my frame of reference is (1), and say that its affine transform is $T\_1$, perhaps I can apply $T\_1^{-1}$ to (2) to obtain (2) in coordinates with respect to the origin and standard set of basis? But then what? how do I do interpolation? Any help is welcome. Thanks!

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 20, 2018, 7:06pm UTC](https://discourse.slicer.org/t/rendering-two-nrdd-files-side-to-side-with-different-origin-space-coordinates-and-spacing/2369/2 "2018-03-20T19:06:24Z")

</div>

If you do all this in Slicer then you don’t have to worry about any low-level detail. You can set up two slice viewers to show the volumes that you need to see, set the slice plane normals to have the same direction, enable slice link, make it hot-linked (long-click on slice link icon and check the “Hot linked” checkbox).

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/e/2eec7381aaf5941c0c6672df310f56aeaeab6104.png)

---

<div class="post-metadata">

**Author:** ![dcantor](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/dcantor/32/782_2.png) [@dcantor](https://discourse.slicer.org/u/dcantor)\
**Post date:** [March 21, 2018, 9:13pm UTC](https://discourse.slicer.org/t/rendering-two-nrdd-files-side-to-side-with-different-origin-space-coordinates-and-spacing/2369/3 "2018-03-21T21:13:55Z")

</div>

Thanks for the info Andras.

I found a solution using SimpleITK. For those who might run into the same problem, here it is the solution:

> **[resampling with simpleitk](https://discourse.itk.org/t/resampling-with-simpleitk/790)**
>
> Hi iTK! I am new to SimpleITK and I am working in Python. I have a NRRD volume that I want to reslice according to the origin,spacing and dimensions of a second NRRD volume. I am trying to figure this out. Is there a way to do this with SimpleITK...

Regards,

Diego

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 21, 2018, 9:29pm UTC](https://discourse.slicer.org/t/rendering-two-nrdd-files-side-to-side-with-different-origin-space-coordinates-and-spacing/2369/4 "2018-03-21T21:29:59Z")

</div>

It was not clear if you need interactive view or resampling. Resampling is available in “Resample scalar/vector/DWI” module in Slicer.

---

<div class="post-metadata">

**Author:** ![Fernando](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fernando/32/5640_2.png) [@Fernando](https://discourse.slicer.org/u/Fernando)\
**Post date:** [March 21, 2018, 10:59pm UTC](https://discourse.slicer.org/t/rendering-two-nrdd-files-side-to-side-with-different-origin-space-coordinates-and-spacing/2369/5 "2018-03-21T22:59:13Z")

</div>

> [@lassoan](#):
>
> make it hot-linked

What does the hot link exactly do?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 22, 2018, 12:47am UTC](https://discourse.slicer.org/t/rendering-two-nrdd-files-side-to-side-with-different-origin-space-coordinates-and-spacing/2369/6 "2018-03-22T00:47:02Z")

</div>

Hot-link synchronizes pan&zoom between slice views that has the same orientation. It is useful if you need to review multiple volumes side-by-side.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [March 22, 2018, 6:37am UTC](https://discourse.slicer.org/t/rendering-two-nrdd-files-side-to-side-with-different-origin-space-coordinates-and-spacing/2369/7 "2018-03-22T06:37:43Z")

</div>

Also hot-link updates the sync on each pointer move, while regular link only updates when you release the button.

---

<div class="post-metadata">

**Author:** ![Fernando](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fernando/32/5640_2.png) [@Fernando](https://discourse.slicer.org/u/Fernando)\
**Post date:** [March 22, 2018, 8:34am UTC](https://discourse.slicer.org/t/rendering-two-nrdd-files-side-to-side-with-different-origin-space-coordinates-and-spacing/2369/8 "2018-03-22T08:34:31Z")

</div>

> [@lassoan](#):
>
> Hot-link synchronizes pan&zoom between slice views that has the same orientation. It is useful if you need to review multiple volumes side-by-side.

Ok, thanks.

> [@pieper](#):
>
> Also hot-link updates the sync on each pointer move, while regular link only updates when you release the button.

When would one prefer regular link over hot link? If the views are going to be updated anyway, why not update them immediately instead of waiting to release the mouse?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [March 22, 2018, 2:36pm UTC](https://discourse.slicer.org/t/rendering-two-nrdd-files-side-to-side-with-different-origin-space-coordinates-and-spacing/2369/9 "2018-03-22T14:36:54Z")

</div>

> [@Fernando](#):
>
> When would one prefer regular link over hot link? If the views are going to be updated anyway, why not update them immediately instead of waiting to release the mouse?

It’s usually faster to only redraw the window where the mouse is moving and you are usually looking at the window where the mouse is, that’s why hot-link is just an option.
