# What is the Algorithm and Theory of spin calibration?

**URL:** <https://discourse.slicer.org/t/what-is-the-algorithm-and-theory-of-spin-calibration/15434>\
**Category:** Development\
**Created:** [January 10, 2021, 11:34am UTC](https://discourse.slicer.org/t/what-is-the-algorithm-and-theory-of-spin-calibration/15434 "2021-01-10T11:34:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![timeanddoctor](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/timeanddoctor/32/5839_2.png) [@timeanddoctor](https://discourse.slicer.org/u/timeanddoctor)\
**Post date:** [January 10, 2021, 11:34am UTC](https://discourse.slicer.org/t/what-is-the-algorithm-and-theory-of-spin-calibration/15434/1 "2021-01-10T11:34:02Z")

</div>

I am studing the calibration and researched many publicatioins but get nothing about the spin calibration. I tend to know what is the Algorithm and Math Theory of spin calibration?

---

<div class="post-metadata">

**Author:** ![ungi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ungi/32/78573_2.png) [@ungi](https://discourse.slicer.org/u/ungi)\
**Post date:** [January 10, 2021, 6:12pm UTC](https://discourse.slicer.org/t/what-is-the-algorithm-and-theory-of-spin-calibration/15434/2 "2021-01-10T18:12:36Z")

</div>

@mholden8 implemented it, but haven’t published the algorithm. You can find the implementation in the source code, here: [SlicerIGT/vtkSlicerPivotCalibrationLogic.cxx at master · SlicerIGT/SlicerIGT · GitHub](https://github.com/SlicerIGT/SlicerIGT/blob/master/PivotCalibration/Logic/vtkSlicerPivotCalibrationLogic.cxx)  
It is essentially looking for the axis with least variation in the tool motion during calibration. And adds a few heuristics, e.g. for direction in the axis, it assumes that the position sensor is behind the pointer, not in front.

To explain it to someone with no math background: Calculate the rotation of the tool between two time points. That rotation has an axis direction. Then, record a series of rotations of this tool, and take the average direction of the rotation axes. That will be the final axis of rotation. If you have already computed the tip point, then make sure the pointy tip is pointing away from the tracked position, so you may need to flip the direction in the end.

---

<div class="post-metadata">

**Author:** ![mholden8](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mholden8/32/1112_2.png) [@mholden8](https://discourse.slicer.org/u/mholden8)\
**Post date:** [January 11, 2021, 6:57am UTC](https://discourse.slicer.org/t/what-is-the-algorithm-and-theory-of-spin-calibration/15434/3 "2021-01-11T06:57:33Z")

</div>

In case it helps, here are my notes on the “theory”: [Holden\_SpinCalibration.pdf - Google Drive](https://drive.google.com/file/d/1SUrL72-LJUD73rLYZaZOsJzf9qF0MNc8/view?usp=sharing).

---

<div class="post-metadata">

**Author:** ![timeanddoctor](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/timeanddoctor/32/5839_2.png) [@timeanddoctor](https://discourse.slicer.org/u/timeanddoctor)\
**Post date:** [January 12, 2021, 8:39am UTC](https://discourse.slicer.org/t/what-is-the-algorithm-and-theory-of-spin-calibration/15434/4 "2021-01-12T08:39:24Z")

</div>

Thank you very much.

---

<div class="post-metadata">

**Author:** ![timeanddoctor](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/timeanddoctor/32/5839_2.png) [@timeanddoctor](https://discourse.slicer.org/u/timeanddoctor)\
**Post date:** [January 12, 2021, 8:42am UTC](https://discourse.slicer.org/t/what-is-the-algorithm-and-theory-of-spin-calibration/15434/5 "2021-01-12T08:42:46Z")

</div>

Thank you for helping me find the information I needed

---

<div class="post-metadata">

**Author:** ![timeanddoctor](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/timeanddoctor/32/5839_2.png) [@timeanddoctor](https://discourse.slicer.org/u/timeanddoctor)\
**Post date:** [January 13, 2021, 11:51am UTC](https://discourse.slicer.org/t/what-is-the-algorithm-and-theory-of-spin-calibration/15434/6 "2021-01-13T11:51:44Z")

</div>

I collected a stack of transform data(np.array([matrix][matrix][matrix]…)) and I tend to use this algorithm in 3d slicer to get the transform to calibrate the spin axis.I have tried this but seems not correct.  
calibrationSuccess = slicer.modules.pivotcalibration.logic().ComputeSpinCalibration()  
I donnot know how to set up the input data, or should I use ‘AddToolToReferenceMatrix(…)’ one by one?
