code: def test_cluster_confidence():
      mysl = np.array([np.arange(10)] * 3, "float").T
  
      # a short streamline (<20 mm) should raise an error unless override=True
      test_streamlines = Streamlines()
      test_streamlines.append(mysl)
      assert_raises(ValueError, cluster_confidence, test_streamlines)
      cci = cluster_confidence(test_streamlines, override=True)
  
      # two identical streamlines should raise an error
      test_streamlines = Streamlines()
      test_streamlines.append(mysl, cache_build=True)
      test_streamlines.append(mysl)
      test_streamlines.finalize_append()
      assert_raises(ValueError, cluster_confidence, test_streamlines)
  
      # 3 offset collinear streamlines
      test_streamlines = Streamlines()
      test_streamlines.append(mysl, cache_build=True)
      test_streamlines.append(mysl + 1)
      test_streamlines.append(mysl + 2)
      test_streamlines.finalize_append()
  
      cci = cluster_confidence(test_streamlines, override=True)
  
      assert_almost_equal(cci[0], cci[2])
      assert_true(cci[1] > cci[0])
  
      # 3 parallel streamlines
      mysl = np.zeros([10, 3])
      mysl[:, 0] = np.arange(10)
      mysl2 = mysl.copy()
      mysl2[:, 1] = 1
      mysl3 = mysl.copy()
      mysl3[:, 1] = 2
      mysl4 = mysl.copy()
      mysl4[:, 1] = 4
      mysl5 = mysl.copy()
      mysl5[:, 1] = 5000
  
      test_streamlines_p1 = Streamlines()
      test_streamlines_p1.append(mysl, cache_build=True)
      test_streamlines_p1.append(mysl2)
      test_streamlines_p1.append(mysl3)
      test_streamlines_p1.finalize_append()
      test_streamlines_p2 = Streamlines()
      test_streamlines_p2.append(mysl, cache_build=True)
      test_streamlines_p2.append(mysl3)
      test_streamlines_p2.append(mysl4)
      test_streamlines_p2.finalize_append()
      test_streamlines_p3 = Streamlines()
      test_streamlines_p3.append(mysl, cache_build=True)
      test_streamlines_p3.append(mysl2)
      test_streamlines_p3.append(mysl3)
      test_streamlines_p3.append(mysl5)
      test_streamlines_p3.finalize_append()
  
      cci_p1 = cluster_confidence(test_streamlines_p1, override=True)
      cci_p2 = cluster_confidence(test_streamlines_p2, override=True)
  
      # test relative distance
      assert_array_equal(cci_p1, cci_p2 * 2)
  
      # test simple cci calculation
      expected_p1 = np.array(
          [1.0 / 1 + 1.0 / 2, 1.0 / 1 + 1.0 / 1, 1.0 / 1 + 1.0 / 2]
      )
      expected_p2 = np.array(
          [1.0 / 2 + 1.0 / 4, 1.0 / 2 + 1.0 / 2, 1.0 / 2 + 1.0 / 4]
      )
      assert_array_equal(expected_p1, cci_p1)
      assert_array_equal(expected_p2, cci_p2)
  
      # test power variable calculation (dropoff with distance)
      cci_p1_pow2 = cluster_confidence(
          test_streamlines_p1, power=2, override=True
      )
  
      expected_p1_pow2 = np.array(
          [
              np.power(1.0 / 1, 2) + np.power(1.0 / 2, 2),
              np.power(1.0 / 1, 2) + np.power(1.0 / 1, 2),
              np.power(1.0 / 1, 2) + np.power(1.0 / 2, 2),
          ]
      )
  
      assert_array_equal(cci_p1_pow2, expected_p1_pow2)
  
      # test max distance (ignore distant sls)
      cci_dist = cluster_confidence(
          test_streamlines_p3, max_mdf=5, override=True
      )
  
      expected_cci_dist = np.concatenate([cci_p1, np.zeros(1)])
      assert_array_equal(cci_dist, expected_cci_dist)
  
imports: import warnings
  import types
  import numpy
  from numpy.linalg import norm
  import numpy.testing
  from dipy.testing.memory import get_type_refcount
  from dipy.testing import assert_arrays_equal
  from dipy.testing.decorators import set_random_number_generator
  from dipy.testing import assert_true
  from numpy.testing import assert_array_equal, assert_array_almost_equal, assert_raises, assert_allclose, assert_almost_equal, assert_equal
  from dipy.tracking.streamlinespeed import compress_streamlines, length, set_number_of_points
  from dipy.tracking.streamline import Streamlines
  from dipy.tracking.streamline import relist_streamlines, unlist_streamlines, center_streamlines, transform_streamlines, select_random_set_of_streamlines, select_by_rois, orient_by_rois, orient_by_streamline, values_from_volume, deform_streamlines, cluster_confidence
label_desc: Use image node_id 24 for calling a global function with example usage: test_cluster_confidence() without return types