code: def test_path_length(rng):
      aoi = np.zeros((20, 20, 20), dtype=bool)
      aoi[0, 0, 0] = 1
  
      # A few tests for basic usage
      x = np.arange(20)
      streamlines = [np.array([x, x, x]).T]
      pl = path_length(streamlines, np.eye(4), aoi)
      expected = x.copy() * np.sqrt(3)
      # expected[0] = np.inf
      npt.assert_array_almost_equal(pl[x, x, x], expected)
  
      aoi[19, 19, 19] = 1
      pl = path_length(streamlines, np.eye(4), aoi)
      expected = np.minimum(expected, expected[::-1])
      npt.assert_array_almost_equal(pl[x, x, x], expected)
  
      aoi[19, 19, 19] = 0
      aoi[1, 1, 1] = 1
      pl = path_length(streamlines, np.eye(4), aoi)
      expected = (x - 1) * np.sqrt(3)
      expected[0] = 0
      npt.assert_array_almost_equal(pl[x, x, x], expected)
  
      z = np.zeros(x.shape, x.dtype)
      streamlines.append(np.array([x, z, z]).T)
      pl = path_length(streamlines, np.eye(4), aoi)
      npt.assert_array_almost_equal(pl[x, x, x], expected)
      npt.assert_array_almost_equal(pl[x, 0, 0], x)
  
      # Only streamlines that pass through aoi contribute to path length so if
      # all streamlines are duds, plm will be all inf.
      aoi[:] = 0
      aoi[0, 0, 0] = 1
      streamlines = []
      for i in range(1000):
          rando = rng.random(size=(100, 3)) * 19 + 0.5
          assert (rando > 0.5).all()
          assert (rando < 19.5).all()
          streamlines.append(rando)
      pl = path_length(streamlines, np.eye(4), aoi)
      npt.assert_array_almost_equal(pl, -1)
  
      pl = path_length(streamlines, np.eye(4), aoi, fill_value=-12.0)
      npt.assert_array_almost_equal(pl, -12.0)
  
imports: import warnings
  import numpy
  import pytest
  from dipy.tracking import metrics
  from dipy.tracking.streamline import transform_streamlines
  from dipy.tracking.utils import connectivity_matrix, density_map, length, ndbincount, reduce_labels, seeds_from_mask, random_seeds_from_mask, target, target_line_based, unique_rows, near_roi, reduce_rois, path_length, _min_at, max_angle_from_curvature, min_radius_curvature_from_angle
  from dipy.tracking._utils import _to_voxel_coordinates
  from dipy.tracking.vox2track import streamline_mapping
  import numpy.testing
  from dipy.testing import assert_true
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 19 for calling a global function with example usage: test_path_length(rng) without return types