def test_get_ras_to_neuromag_trans():
 rng = np.random.RandomState(0)
 anterior = [0, 1, 0]
 left = [(-1), 0, 0]
 right = [0.8, 0, 0]
 up = [0, 0, 1]
 rand_pts = rng.uniform((-1), 1, (3, 3))
 pts = np.vstack((anterior, left, right, up, rand_pts))
 (rx, ry, rz, tx, ty, tz) = rng.uniform(((-2) * np.pi), (2 * np.pi), 6)
 trans = np.dot(translation(tx, ty, tz), rotation(rx, ry, rz))
 pts_changed = apply_trans(trans, pts)
 (nas, lpa, rpa) = pts_changed[:3]
 hsp_trans = get_ras_to_neuromag_trans(nas, lpa, rpa)
 pts_restored = apply_trans(hsp_trans, pts_changed)
 err = 'Neuromag transformation failed'
 assert_allclose(pts_restored, pts, atol=1e-06, err_msg=err)

def test_get_ras_to_neuromag_trans ( ) : rng = np . random . RandomState ( 0 ) anterior = [ 0 , 1 , 0 ] left = [ ( - 1 ) , 0 , 0 ] right = [ 0.8 , 0 , 0 ] up = [ 0 , 0 , 1 ] rand_pts = rng . uniform ( ( - 1 ) , 1 , ( 3 , 3 ) ) pts = np . vstack ( ( anterior , left , right , up , rand_pts ) ) ( rx , ry , rz , tx , ty , tz ) = rng . uniform ( ( ( - 2 ) * np . pi ) , ( 2 * np . pi ) , 6 ) trans = np . dot ( translation ( tx , ty , tz ) , rotation ( rx , ry , rz ) ) pts_changed = apply_trans ( trans , pts ) ( nas , lpa , rpa ) = pts_changed [ : 3 ] hsp_trans = get_ras_to_neuromag_trans ( nas , lpa , rpa ) pts_restored = apply_trans ( hsp_trans , pts_changed ) err = 'Neuromag transformation failed' assert_allclose ( pts_restored , pts , atol = 1e-06 , err_msg = err )
test the coordinate transformation from ras to neuromag .