SciKit-Surgery / scikit-surgerycalibration

scikit-surgery-calibration provides algorithms designed for the calibration of surgical instruments

Home Page:http://scikit-surgery.github.io/scikit-surgery/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pivot calibration: erroneous mixing algorithms by recursion

Lecrapouille opened this issue · comments

Hello, I'm not a good Python programmer, but it seems that the pivot_calibration_with_ransac function is calling badly its recursion:

def pivot_calibration(tracking_matrices, configuration=None):

will call

return pivot_calibration_with_ransac(

that will call

def pivot_calibration_with_ransac(tracking_matrices,

that will call

pointer_offset, pivot_location, _ = pivot_calibration(sample)
with implicit configuration=None as parameter that will call

and

return pivot_calibration_aos(tracking_matrices)

but since

the

is not called

I've not traced calls (as noob in Python is this kind of tool exists ?), this is a simple "manual" code review, I may be wrong. I guess you have forgotten to pass configuration in the recursive calls. Finally, your recursive algorithm is complex to understand: I think pivot_calibration_with_ransac shall only call pivot_calibration_with_ransac but not the base function pivot_calibration.

Thanks for raising this. I'm away this week so have assigned @mxochicale to take a look first. @mxochicale can you please take a look? @MattClarkson might be able to help too as I think he was the main author on this.

I've had a look at this now. I think it is confusion caused by our overly complex recursion (which I don't think is actually recursion). My understanding is that pivot_calibration is a wrapper that will call one of three methods (pivot_calibration_aos, pivot_calibration_ransac, or pivot_calibration_sphere_fitting).
pivot_calibration_ransac calls pivot_calibration_aos multiple times to iteratively find an optimal solution (i.e. pivot_calibration_ransac is not meant to call itself (recurse)).
I've clarified that in the code see

pointer_offset, pivot_location, _ = pivot_calibration_aos(sample)
and
pivot_calibration_aos(inlier_matrices)

I hope that makes sense. If so I'll create a pull request for it.

My understanding is that pivot_calibration is a wrapper that will call one of three methods (pivot_calibration_aos, pivot_calibration_ransac, or pivot_calibration_sphere_fitting).

I agree with you.

pivot_calibration_ransac calls pivot_calibration_aos multiple times to iteratively find an optimal solution (i.e. pivot_calibration_ransac is not meant to call itself (recurse)).

I agree with you.

I hope that makes sense. If so I'll create a pull request for it.

The fix looks good to me. Probably you will have to also update unit tests.