# Data is not in center of slicer views after JumpSlicesToLocation process

**URL:** <https://discourse.slicer.org/t/data-is-not-in-center-of-slicer-views-after-jumpslicestolocation-process/17252>\
**Category:** Development\
**Tags:** python\
**Created:** [April 22, 2021, 12:50pm UTC](https://discourse.slicer.org/t/data-is-not-in-center-of-slicer-views-after-jumpslicestolocation-process/17252 "2021-04-22T12:50:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![luxiaoyang9999](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/luxiaoyang9999/32/9026_2.png) [@luxiaoyang9999](https://discourse.slicer.org/u/luxiaoyang9999)\
**Post date:** [April 22, 2021, 12:50pm UTC](https://discourse.slicer.org/t/data-is-not-in-center-of-slicer-views-after-jumpslicestolocation-process/17252/1 "2021-04-22T12:50:39Z")

</div>

Hi all  
I use the JumpSlicesToLocation to change data in slicer view when mouse position changed, but images in slicer view will not be in view center, how can I solve the problm, this is my code

```
def jumpToCursor(self):
    ras = [0, 0, 0]
    slicer.mrmlScene.GetFirstNodeByClass('vtkMRMLCrosshairNode').GetCursorPositionRAS(ras)
    slicer.modules.markups.logic().JumpSlicesToLocation(ras[0], ras[1], ras[2], slicer.vtkMRMLCrosshairNode.JumpSlice)
    print(ras[1])
shortcut = qt.QShortcut(slicer.util.mainWindow())
shortcut.setKey(qt.QKeySequence("Ctrl+B"))
shortcut.connect('activated()', jumpToCursor)
```

---

<div class="post-metadata">

**Author:** ![luxiaoyang9999](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/luxiaoyang9999/32/9026_2.png) [@luxiaoyang9999](https://discourse.slicer.org/u/luxiaoyang9999)\
**Post date:** [April 22, 2021, 12:57pm UTC](https://discourse.slicer.org/t/data-is-not-in-center-of-slicer-views-after-jumpslicestolocation-process/17252/2 "2021-04-22T12:57:53Z")

</div>

![1619096161(1)](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/0/808dca7d3893647741ff69a816a7159b2772ae63.png)  
here is the screenshot after the code excuted

---

<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:** [April 25, 2021, 3:25pm UTC](https://discourse.slicer.org/t/data-is-not-in-center-of-slicer-views-after-jumpslicestolocation-process/17252/3 "2021-04-25T15:25:48Z")

</div>

You can choose to you can use `CenteredJumpSlice` option if you want the chosen position be centered.

---

<div class="post-metadata">

**Author:** ![luxiaoyang9999](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/luxiaoyang9999/32/9026_2.png) [@luxiaoyang9999](https://discourse.slicer.org/u/luxiaoyang9999)\
**Post date:** [April 26, 2021, 4:06am UTC](https://discourse.slicer.org/t/data-is-not-in-center-of-slicer-views-after-jumpslicestolocation-process/17252/4 "2021-04-26T04:06:15Z")

</div>

I try this, but it seems not to work, I want to get a similiar function like ‘Shift + mouse’ in slicer, and rewrite it. Could you tell me where to rewrite ‘Shift + mouse’ in Python or realize similar function like it?

---

<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:** [April 26, 2021, 4:25am UTC](https://discourse.slicer.org/t/data-is-not-in-center-of-slicer-views-after-jumpslicestolocation-process/17252/5 "2021-04-26T04:25:35Z")

</div>

`CenteredJumpSlice` options works. You can also use this static method of `vtkMRMLSliceNode`:

```
slicer.vtkMRMLSliceNode.JumpAllSlices(slicer.mrmlScene, 2.3, 4.5, 6.7, slicer.vtkMRMLSliceNode.CenteredJumpSlice)

```

If you also want to move the crosshair position then you can call:

```python
crosshairNode = slicer.vtkMRMLCrosshairDisplayableManager.FindCrosshairNode(slicer.mrmlScene)
crosshairNode.SetCrosshairRAS([2.3, 4.5, 6.7])

```
