NiBabel

Access a cacophony of neuro-imaging file formats

Previous topic

nibabel.quaternions.mult

Next topic

nibabel.quaternions.norm

Reggie -- the one

nibabel.quaternions.nearly_equivalent

nibabel.quaternions.nearly_equivalent(q1, q2, rtol=1e-05, atol=1e-08)

Returns True if q1 and q2 give near equivalent transforms

q1 may be nearly numerically equal to q2, or nearly equal to q2 * -1 (becuase a quaternion multiplied by -1 gives the same transform).

Parameters:

q1 : 4 element sequence

w, x, y, z of first quaternion

q2 : 4 element sequence

w, x, y, z of second quaternion

Returns:

equiv : bool

True if q1 and q2 are nearly equivalent, False otherwise

Examples

>>> q1 = [1, 0, 0, 0]
>>> nearly_equivalent(q1, [0, 1, 0, 0])
False
>>> nearly_equivalent(q1, [1, 0, 0, 0])
True
>>> nearly_equivalent(q1, [-1, 0, 0, 0])
True