# How to convert coordinates from physical space (xyz) to index space (ijk) by VTK api

**URL:** https://discourse.vtk.org/t/how-to-convert-coordinates-from-physical-space-xyz-to-index-space-ijk-by-vtk-api/3037
**Category:** Support
**Created:** [April 13, 2020, 3:10pm UTC](https://discourse.vtk.org/t/how-to-convert-coordinates-from-physical-space-xyz-to-index-space-ijk-by-vtk-api/3037 "2020-04-13T15:10:32Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![yuhuimoon](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/y/c6cbf5/32.png) [@yuhuimoon](https://discourse.vtk.org/u/yuhuimoon)
#### Post date: [April 13, 2020, 3:10pm UTC](https://discourse.vtk.org/t/how-to-convert-coordinates-from-physical-space-xyz-to-index-space-ijk-by-vtk-api/3037/1 "2020-04-13T15:10:32Z")

</div>

I want to Convert coordinates from physical space (xyz) to index space (ijk).  
In VTK9.0.0, I find **vtkImageData::TransformPhysicalPointToContinuousIndex()** recently added can get what I want. But is there any way to get the result in VTK8.2.0?

---

<div class="post-metadata">

### Author: ![sherinnovation](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/b487fb/32.png) [@sherinnovation](https://discourse.vtk.org/u/sherinnovation)
#### Post date: [October 24, 2020, 10:28pm UTC](https://discourse.vtk.org/t/how-to-convert-coordinates-from-physical-space-xyz-to-index-space-ijk-by-vtk-api/3037/2 "2020-10-24T22:28:05Z")

</div>

Hi,  
I had similar problem and I tried using ITK for this.  
You may try the following python code snippet.  
CAUTION: Please note that the below code is not tested. I am just trying to share what I know.

> ```
> fileNameT1 = str(subjectFolder + "\\structural\\T1.nii")
> # Read T1 data.
> readerT1 = sitk.ImageFileReader()
> readerT1.SetFileName(fileNameT1)
> readerT1.LoadPrivateTagsOn()
> readerT1.ReadImageInformation()
> readerT1.LoadPrivateTagsOn()
> imageT1 = sitk.ReadImage(fileNameT1)
> return imageT1.TransformPhysicalPointToIndex(pt)
> 
> ```

---

<div class="post-metadata">

### Author: ![yuhuimoon](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/y/c6cbf5/32.png) [@yuhuimoon](https://discourse.vtk.org/u/yuhuimoon)
#### Post date: [October 25, 2020, 11:48am UTC](https://discourse.vtk.org/t/how-to-convert-coordinates-from-physical-space-xyz-to-index-space-ijk-by-vtk-api/3037/3 "2020-10-25T11:48:47Z")

</div>

It seems like what I want. I will try it later. Thanks.
