code: def _perpendicular_directions_temp(v, num=20, half=False):
      """
      Computes a set of perpendicular directions relative to the direction in v.
  
      The perpendicular directions are computed by sampling on a unit
      circumference that is perpendicular to `v`. The computation depends on
      whether the vector is aligned with the x-axis or not.
  
      Parameters
      ----------
      v : array (3,)
          Array containing the three cartesian coordinates of vector v.
      num : int, optional
          Number of perpendicular directions to generate. Default is 20.
      half : bool, optional
          If True, perpendicular directions are sampled on half of the unit
          circumference perpendicular to v, otherwise they are sampled on the
          full circumference. Default is False.
  
      Returns
      -------
      psamples : array (n, 3)
          Array of vectors perpendicular to v.
      """
      v = np.array(v, dtype=np.float64)
      v = v.T
      er = np.finfo(v[0].dtype).eps * 1e3
      if half is True:
          a = np.linspace(0.0, math.pi, num=num, endpoint=False)
      else:
          a = np.linspace(0.0, 2 * math.pi, num=num, endpoint=False)
      cosa = np.cos(a)
      sina = np.sin(a)
      if np.any(abs(v[0] - 1.0) > er):
          sq = np.sqrt(v[1] ** 2 + v[2] ** 2)
          psamples = np.array(
              [
                  -sq * sina,
                  (v[0] * v[1] * sina - v[2] * cosa) / sq,
                  (v[0] * v[2] * sina + v[1] * cosa) / sq,
              ]
          )
      else:
          sq = np.sqrt(v[0] ** 2 + v[2] ** 2)
          psamples = np.array(
              [
                  -(v[2] * cosa + v[0] * v[1] * sina) / sq,
                  sina * sq,
                  (v[0] * cosa - v[2] * v[1] * sina) / sq,
              ]
          )
      return psamples.T
  
imports: import numpy
  import math
  from dipy.core.sphere import disperse_charges, HemiSphere
  from dipy.reconst.utils import cti_design_matrix
  from numpy.testing import assert_array_almost_equal, assert_raises
  from dipy.reconst.tests.test_qti import _anisotropic_DTD, _isotropic_DTD
  from dipy.core.gradients import gradient_table
  import dipy.reconst.qti
  import dipy.reconst.cti
  from dipy.reconst.dti import decompose_tensor, mean_diffusivity
  from dipy.reconst.cti import split_cti_params, ls_fit_cti, multi_gaussian_k_from_c, from_qte_to_cti
  from dipy.reconst.dki import mean_kurtosis, axial_kurtosis, radial_kurtosis, mean_kurtosis_tensor, kurtosis_fractional_anisotropy
label_desc: Use image node_id 3 for calling a global function with example usage: _perpendicular_directions_temp(v, num, half) and returns: psamples