# after rotate the reslicecursor, how to get the slice count?

**URL:** https://discourse.vtk.org/t/after-rotate-the-reslicecursor-how-to-get-the-slice-count/1622
**Category:** Support
**Created:** [August 20, 2019, 7:03am UTC](https://discourse.vtk.org/t/after-rotate-the-reslicecursor-how-to-get-the-slice-count/1622 "2019-08-20T07:03:52Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![pingdan](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pingdan](https://discourse.vtk.org/u/pingdan)
#### Post date: [August 20, 2019, 7:03am UTC](https://discourse.vtk.org/t/after-rotate-the-reslicecursor-how-to-get-the-slice-count/1622/1 "2019-08-20T07:03:52Z")

</div>

vtkImagePlaneWidget,vtkResliceCursorWidget,vtkResliceCursor,vtkResliceCursorThickLineRepresentation  
I use these classes to display MPR.when I rotate the reslicecursor with the mouse, we can the see the reslicecursor rotate and the slice changed with the rotation. at this status, if I move the rotated cursor, the slice will changed. but how can I get the slices count after rotating?

 ![1](https://discourse.vtk.org/uploads/default/original/1X/f7e4ffc13ad23d077e728c869b561172142a9f02.png)

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [August 23, 2019, 7:48pm UTC](https://discourse.vtk.org/t/after-rotate-the-reslicecursor-how-to-get-the-slice-count/1622/2 "2019-08-23T19:48:05Z")

</div>

In oblique slices, each pixel has a different slice number, so you need to look up for each physical (L, P, S) position what is the corresponding voxel (I, J, K) position. Typically slice number is value of K coordinate + 1,

---

<div class="post-metadata">

### Author: ![pingdan](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pingdan](https://discourse.vtk.org/u/pingdan)
#### Post date: [August 26, 2019, 2:47am UTC](https://discourse.vtk.org/t/after-rotate-the-reslicecursor-how-to-get-the-slice-count/1622/3 "2019-08-26T02:47:29Z")

</div>

Can you describe this method in detail? or give me some code? thanks a lot.

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [August 26, 2019, 1:32pm UTC](https://discourse.vtk.org/t/after-rotate-the-reslicecursor-how-to-get-the-slice-count/1622/4 "2019-08-26T13:32:41Z")

</div>

These might help in understanding how to convert between physical (LPS, RAS, …) and voxel (IJK) coordinate system:

[https://www.slicer.org/wiki/Coordinate\_systems](https://www.slicer.org/wiki/Coordinate_systems)

[http://nipy.org/nipy/devel/code\_discussions/coordmap\_notes.html](http://nipy.org/nipy/devel/code_discussions/coordmap_notes.html)

---

<div class="post-metadata">

### Author: ![pingdan](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pingdan](https://discourse.vtk.org/u/pingdan)
#### Post date: [August 29, 2019, 8:15am UTC](https://discourse.vtk.org/t/after-rotate-the-reslicecursor-how-to-get-the-slice-count/1622/5 "2019-08-29T08:15:38Z")

</div>

thanks, I have some idea about reslice.

---

<div class="post-metadata">

### Author: ![kimia.af1998](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/k/7ab992/32.png) [@kimia.af1998](https://discourse.vtk.org/u/kimia.af1998)
#### Post date: [December 9, 2019, 12:36pm UTC](https://discourse.vtk.org/t/after-rotate-the-reslicecursor-how-to-get-the-slice-count/1622/6 "2019-12-09T12:36:23Z")

</div>

Hi.  
I want to display my slice number in each surface as you showed with green label.  
I displayed my 2d slices with vtkResliceWidget.  
Can you help me with that?

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [December 9, 2019, 5:42pm UTC](https://discourse.vtk.org/t/after-rotate-the-reslicecursor-how-to-get-the-slice-count/1622/7 "2019-12-09T17:42:26Z")

</div>

For oblique slices, there are no slice numbers because one oblique slice is constructed from hundreds of original slices. You can display something like distance from origin (this is what we do in 3D Slicer), but it’s not that useful. Or you can display slice number at the current slice position, again, not that useful, because you cannot match it to the content displayed on slice-based 2D viewers.

---

<div class="post-metadata">

### Author: ![kimia.af1998](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/k/7ab992/32.png) [@kimia.af1998](https://discourse.vtk.org/u/kimia.af1998)
#### Post date: [December 9, 2019, 6:21pm UTC](https://discourse.vtk.org/t/after-rotate-the-reslicecursor-how-to-get-the-slice-count/1622/8 "2019-12-09T18:21:40Z")

</div>

I only display sagittal coronal and axial not oblique.  
And wants to get current displayed slice number.  
As I saw there is only spacing , origin and extend data we can have from input data.  
How can i do according to your reply?

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [December 9, 2019, 6:27pm UTC](https://discourse.vtk.org/t/after-rotate-the-reslicecursor-how-to-get-the-slice-count/1622/9 "2019-12-09T18:27:40Z")

</div>

VTK does not keep track of original DICOM slice numbers. If you want to make sure you display the correct value then you need to read slice number and image position&orientation for each slice from the original DICOM image and use these information to look up the values. There are no DICOM slice numbers for reformatted (sagittal, coronal) slices. You may use voxel (IJK) coordinates as surrogates - it will give the user a general idea about how many slices are there along that specific axis and which one is the current slice (but this cannot be used to cross-reference with another viewer, because the choice of axis directions are arbitrary).

---

<div class="post-metadata">

### Author: ![kimia.af1998](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/k/7ab992/32.png) [@kimia.af1998](https://discourse.vtk.org/u/kimia.af1998)
#### Post date: [December 9, 2019, 6:36pm UTC](https://discourse.vtk.org/t/after-rotate-the-reslicecursor-how-to-get-the-slice-count/1622/10 "2019-12-09T18:36:58Z")

</div>

Sorry!  
I didn’t understand well.  
I have to change my viewer or use voxels(if yes how)?

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [December 9, 2019, 6:44pm UTC](https://discourse.vtk.org/t/after-rotate-the-reslicecursor-how-to-get-the-slice-count/1622/11 "2019-12-09T18:44:19Z")

</div>

Showing slice number or IJK coordinate in a view is not related to how you render the image. You can determine IJK coordinate from IJKToLPS transform and LPS position of the current slice.

If you want to be able to develop a medical image viewer then you probably need to do a lot more independent study (e.g., read VTK Textbook and ITK Software Guide a few times, study VTK examples and source code of open-source medical image viewers, such as 3D Slicer and MITK). If you just want to develop a system or an application that can import and visualize and edit medical images, segmentations, models, etc. so that you can add your own science/algorithms/ideas to it, then there is no need to spend time with redeveloping everything from scratch but you can build on existing open-source platforms.
