# Setting an MNI origo to a volume

**URL:** <https://discourse.slicer.org/t/setting-an-mni-origo-to-a-volume/16164>\
**Category:** Support\
**Tags:** coordinates\
**Created:** [February 23, 2021, 5:43pm UTC](https://discourse.slicer.org/t/setting-an-mni-origo-to-a-volume/16164 "2021-02-23T17:43:56Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Kalman](https://avatars.discourse-cdn.com/v4/letter/k/59ef9b/32.png) [@Kalman](https://discourse.slicer.org/u/Kalman)\
**Post date:** [February 26, 2021, 3:45pm UTC](https://discourse.slicer.org/t/setting-an-mni-origo-to-a-volume/16164/5 "2021-02-26T15:45:39Z")

</div>

Dear Andras,

Thank you very much for your help and the detailed answer, it’s the function I needed!

Still I found some interesting issues regarding which I would like to ask your opinion.  
When I first used the shortcut-code, the position of the cursor was out of the volume:

 ![volume_out](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/d/2d9b3b4d7537d9deff211c2e0b97eb32eeb35725.jpeg)

My colleague - who is more expert in programming - found that there is a difference in the qform/sform space, which causes this alteration. I share here the links he sent me in this topic:

- [Inconsistent qform / sform on image write · Issue #1318 · MRtrix3/mrtrix3 · GitHub](https://github.com/MRtrix3/mrtrix3/issues/1318)
- [Inconsistent qform /sform on nifti image - MRtrix3 Community](https://community.mrtrix.org/t/inconsistent-qform-sform-on-nifti-image/1663)
- [Nifti file sform and Slicer image origin seem to disagree](https://discourse.slicer.org/t/nifti-file-sform-and-slicer-image-origin-seem-to-disagree/7711)

Finally he found that if he runs this code below in FSL, then afterwards the shortcut works well on the new volume:

> fslorient -copysform2qform sample\_file.nii

 ![volume_in](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/8/287abc20b7b16a600fd78afe00aab659a424aa16.jpeg)

.  
**A question** : Is there a way that this modification (qform/sform reset) can be done in the Slicer (without having FSL and the required Linux environment)?

Also to share with the community - maybe some could have the same question - Adam made a little modification in the script you’ve sent (as for some reason an error message was received on its initial run), and now everything displayed correctly just as you have said:

```
def onMouseMoved(observer,eventid):
  mniToWorldTransformNode = getNode('LinearTransform_3') # replace this by the name of your actual transform
  worldToMniTransform = vtk.vtkGeneralTransform()
  mniToWorldTransformNode.GetTransformToWorld(worldToMniTransform)
  ras=[0,0,0]
  mni=[0,0,0]    
  crosshairNode.GetCursorPositionRAS(ras)
  worldToMniTransform.TransformPoint(ras, mni)
  _ras = "; ".join([str(k) for k in ras])
  _mni = "; ".join([str(k) for k in mni])
  slicer.util.showStatusMessage(f"RAS={_ras} MNI={_mni}")

crosshairNode=slicer.util.getNode('Crosshair')
observationId = crosshairNode.AddObserver(slicer.vtkMRMLCrosshairNode.CursorPositionModifiedEvent, onMouseMoved)

```

 ![MNI](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/1/d12d372e618a2deed2b9af49f95f0b0347e6e496.jpeg)

I will try the transformations, and if any question rises, I’ll let you know.

---

_[View the full topic](https://discourse.slicer.org/t/setting-an-mni-origo-to-a-volume/16164)._
