code: def test_deform_streamlines(rng):
      # Create Random deformation field
      deformation_field = rng.standard_normal((200, 200, 200, 3))
      stream2grid = np.array(
          [
              [-0.13152201, -0.52553149, -0.06759869, -0.80014208],
              [1.01579851, 0.19840874, 0.18875411, 0.81826065],
              [-0.07047617, -0.9290094, -0.55623385, 0.55165017],
              [0.0, 0.0, 0.0, 1.0],
          ]
      )
      grid2world = np.array(
          [
              [0.83354727, 1.33876877, 1.0218087, 0.12809569],
              [0.83571344, 0.63824941, 0.20564267, 0.82740437],
              [-0.26574668, -0.66695577, 0.11636694, -0.02620037],
              [0.0, 0.0, 0.0, 1.0],
          ]
      )
      stream2world = np.dot(stream2grid, grid2world)
  
      # Deform streamlines (let two grid spaces be the same for simplicity)
      new_streamlines = deform_streamlines(
          streamlines,
          deformation_field,
          stream2grid,
          grid2world,
          stream2grid,
          grid2world,
      )
  
      # Interpolate displacements onto original streamlines
      streamlines_in_grid = transform_streamlines(
          streamlines, stream2grid
      )
      disps = values_from_volume(
          deformation_field, streamlines_in_grid, np.eye(4)
      )
  
      # Put new_streamlines into world space
      new_streamlines_world = transform_streamlines(
          new_streamlines, stream2world
      )
  
      # Subtract disps from new_streamlines in world space
      orig_streamlines_world = np.subtract(
          np.array(new_streamlines_world, dtype=object),
          np.array(disps, dtype=object),
      )
  
      # Put orig_streamlines_world into voxmm
      orig_streamlines = transform_streamlines(
          orig_streamlines_world, np.linalg.inv(stream2world)
      )
      # All close because of floating pt imprecision
      for o, s in zip(orig_streamlines, streamlines):
          assert_allclose(s, o.astype(np.float32), rtol=1e-6, atol=1e-6)
  
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 11 for calling a global function with example usage: test_deform_streamlines(rng) without return types