code: def quat2euler(q):
      """Return Euler angles corresponding to quaternion `q`
  
      Parameters
      ----------
      q : 4 element sequence
         w, x, y, z of quaternion
  
      Returns
      -------
      z : scalar
         Rotation angle in radians around z-axis (performed first)
      y : scalar
         Rotation angle in radians around y-axis
      x : scalar
         Rotation angle in radians around x-axis (performed last)
  
      Notes
      -----
      It's possible to reduce the amount of calculation a little, by
      combining parts of the ``quat2mat`` and ``mat2euler`` functions, but
      the reduction in computation is small, and the code repetition is
      large.
      """
      # delayed import to avoid cyclic dependencies
      from . import quaternions as nq
  
      return mat2euler(nq.quat2mat(q))
  
file_path: nibabel/nibabel/eulerangles.py
imports: import math
  from functools import reduce
  import numpy
label_desc: Use image node_id 4 for calling a global function with example usage: quat2euler(q) and returns: mat2euler