def _fit_chpi_pos(coil_dev_rrs, coil_head_rrs, x0):
 from scipy.optimize import fmin_cobyla
 denom = np.sum(((coil_head_rrs - np.mean(coil_head_rrs, axis=0)) ** 2))
 objective = partial(_chpi_objective, coil_dev_rrs=coil_dev_rrs, coil_head_rrs=coil_head_rrs)
 x0 = x0.copy()
 x0[3:] *= 10.0
 x = fmin_cobyla(objective, x0, _unit_quat_constraint, rhobeg=0.001, rhoend=1e-05, disp=False)
 result = objective(x)
 x[3:] /= 10.0
 return (x, (1.0 - (result / denom)))

def _fit_chpi_pos ( coil_dev_rrs , coil_head_rrs , x0 ) : from scipy . optimize import fmin_cobyla denom = np . sum ( ( ( coil_head_rrs - np . mean ( coil_head_rrs , axis = 0 ) ) ** 2 ) ) objective = partial ( _chpi_objective , coil_dev_rrs = coil_dev_rrs , coil_head_rrs = coil_head_rrs ) x0 = x0 . copy ( ) x0 [ 3 : ] *= 10.0 x = fmin_cobyla ( objective , x0 , _unit_quat_constraint , rhobeg = 0.001 , rhoend = 1e-05 , disp = False ) result = objective ( x ) x [ 3 : ] /= 10.0 return ( x , ( 1.0 - ( result / denom ) ) )
fit rotation and translation parameters for chpi coils .