code: def test_volume_registration():
      """Test volume registration."""
      nib = pytest.importorskip("nibabel")
      pytest.importorskip("dipy")
      from dipy.align import resample
  
      T1 = nib.load(fname_t1)
      affine = np.eye(4)
      affine[0, 3] = 10
      T1_resampled = resample(
          moving=T1.get_fdata(),
          static=T1.get_fdata(),
          moving_affine=T1.affine,
          static_affine=T1.affine,
          between_affine=np.linalg.inv(affine),
      )
      for pipeline, cval in zip(
          ("rigids", ("translation", "sdr")), (0.0, "1%")
      ):
          (
              reg_affine,
              sdr_morph,
          ) = mne.transforms.compute_volume_registration(
              T1_resampled, T1, pipeline=pipeline, zooms=10, niter=[5]
          )
          assert_allclose(affine, reg_affine, atol=0.01)
          T1_aligned = mne.transforms.apply_volume_registration(
              T1_resampled, T1, reg_affine, sdr_morph, cval=cval
          )
          r2 = _compute_r2(
              _get_img_fdata(T1_aligned), _get_img_fdata(T1)
          )
          assert 99.9 < r2
      with pytest.raises(ValueError, match="cval"):
          mne.transforms.apply_volume_registration(
              T1_resampled, T1, reg_affine, sdr_morph, cval="bad"
          )
  
      # check that all orders of the pipeline work
      for pipeline_len in range(1, 5):
          for pipeline in itertools.combinations(
              ("translation", "rigid", "affine", "sdr"), pipeline_len
          ):
              _validate_pipeline(pipeline)
              _validate_pipeline(list(pipeline))
  
      with pytest.raises(
          ValueError, match="Steps in pipeline are out of order"
      ):
          _validate_pipeline(("sdr", "affine"))
  
      with pytest.raises(
          ValueError, match="Steps in pipeline should not be repeated"
      ):
          _validate_pipeline(("affine", "affine"))
  
      # test points
      info = read_info(test_fif_fname)
      trans = read_trans(fname)
      info2, trans2 = mne.transforms.apply_volume_registration_points(
          info, trans, T1_resampled, T1, reg_affine, sdr_morph
      )
      assert_allclose(
          trans2["trans"], np.eye(4), atol=0.001
      )  # same before
      ch_pos = info2.get_montage().get_positions()["ch_pos"]
      assert_allclose(
          [ch_pos["EEG 001"], ch_pos["EEG 002"], ch_pos["EEG 003"]],
          [
              [-0.04136687, 0.05402692, 0.09491907],
              [-0.01874947, 0.05656526, 0.09966554],
              [0.00828519, 0.05535511, 0.09869323],
          ],
          atol=0.001,
      )
  
imports: import itertools
  import os
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_almost_equal, assert_array_equal, assert_array_less, assert_equal
  import mne
  from mne import read_trans, write_trans
  from mne.datasets import testing
  from mne.fixes import _get_img_fdata
  from mne.io import read_info
  from mne.transforms import _angle_between_quats, _average_quats, _cart_to_sph, _compute_r2, _euler_to_quat, _find_trans, _find_vector_rotation, _fit_matched_points, _get_trans, _MatchedDisplacementFieldInterpolator, _pol_to_cart, _quat_real, _quat_to_affine, _quat_to_euler, _read_fs_xfm, _sph_to_cart, _topo_to_sph, _validate_pipeline, _write_fs_xfm, apply_trans, combine_transforms, get_ras_to_neuromag_trans, invert_transform, quat_to_rot, rot_to_quat, rotation, rotation3d, rotation3d_align_z_axis, rotation_angles, translation
  from mne.transforms import _SphericalSurfaceWarp
label_desc: Use image node_id 23 for calling a global function with example usage: test_volume_registration() without return types