code: def test_syn_registration_flow():
      moving_data, static_data = get_synthetic_warped_circle(40)
      moving_data[..., :10] = 0
      moving_data[..., -1:-11:-1] = 0
      static_data[..., :10] = 0
      static_data[..., -1:-11:-1] = 0
  
      syn_flow = SynRegistrationFlow()
  
      with TemporaryDirectory() as out_dir:
          static_img = nib.Nifti1Image(
              static_data.astype(float), np.eye(4)
          )
          fname_static = pjoin(out_dir, "tmp_static.nii.gz")
          nib.save(static_img, fname_static)
  
          moving_img = nib.Nifti1Image(
              moving_data.astype(float), np.eye(4)
          )
          fname_moving = pjoin(out_dir, "tmp_moving.nii.gz")
          nib.save(moving_img, fname_moving)
  
          positional_args = [fname_static, fname_moving]
  
          # Test the cc metric
          metric_optional_args = {
              "metric": "cc",
              "mopt_sigma_diff": 2.0,
              "mopt_radius": 4,
          }
          optimizer_optional_args = {
              "level_iters": [10, 10, 5],
              "step_length": 0.25,
              "opt_tol": 1e-5,
              "inv_iter": 20,
              "inv_tol": 1e-3,
              "ss_sigma_factor": 0.2,
          }
  
          all_args = dict(
              metric_optional_args, **optimizer_optional_args
          )
          syn_flow.run(*positional_args, out_dir=out_dir, **all_args)
  
          warped_path = syn_flow.last_generated_outputs["out_warped"]
          npt.assert_equal(os.path.isfile(warped_path), True)
          warped_map_path = syn_flow.last_generated_outputs["out_field"]
          npt.assert_equal(os.path.isfile(warped_map_path), True)
  
          # Test the ssd metric
          metric_optional_args = {
              "metric": "ssd",
              "mopt_smooth": 4.0,
              "mopt_inner_iter": 5,
              "mopt_step_type": "demons",
          }
          optimizer_optional_args = {
              "level_iters": [200, 100, 50, 25],
              "step_length": 0.5,
              "opt_tol": 1e-4,
              "inv_iter": 40,
              "inv_tol": 1e-3,
              "ss_sigma_factor": 0.2,
          }
  
          all_args = dict(
              metric_optional_args, **optimizer_optional_args
          )
          syn_flow.run(*positional_args, out_dir=out_dir, **all_args)
  
          warped_path = syn_flow.last_generated_outputs["out_warped"]
          npt.assert_equal(os.path.isfile(warped_path), True)
          warped_map_path = syn_flow.last_generated_outputs["out_field"]
          npt.assert_equal(os.path.isfile(warped_map_path), True)
  
          # Test the em metric
          metric_optional_args = {
              "metric": "em",
              "mopt_smooth": 1.0,
              "mopt_inner_iter": 5,
              "mopt_step_type": "gauss_newton",
          }
          optimizer_optional_args = {
              "level_iters": [200, 100, 50, 25],
              "step_length": 0.5,
              "opt_tol": 1e-4,
              "inv_iter": 40,
              "inv_tol": 1e-3,
              "ss_sigma_factor": 0.2,
          }
  
          all_args = dict(
              metric_optional_args, **optimizer_optional_args
          )
          syn_flow.run(*positional_args, out_dir=out_dir, **all_args)
  
          warped_path = syn_flow.last_generated_outputs["out_warped"]
          npt.assert_equal(os.path.isfile(warped_path), True)
          warped_map_path = syn_flow.last_generated_outputs["out_field"]
          npt.assert_equal(os.path.isfile(warped_map_path), True)
  
imports: from os.path import join
  import os.path
  from tempfile import TemporaryDirectory
  import numpy.testing
  import numpy
  import nibabel
  import pytest
  from dipy.utils.optpkg import optional_package
  from dipy.align.tests.test_imwarp import get_synthetic_warped_circle
  from dipy.align.tests.test_parzenhist import setup_random_transform
  from dipy.align.transforms import regtransforms
  from dipy.data import get_fnames
  from dipy.io.image import save_nifti, load_nifti_data
  from dipy.io.stateful_tractogram import Space, StatefulTractogram
  from dipy.io.streamline import load_tractogram, save_tractogram
  from dipy.tracking.streamline import Streamlines
  from dipy.workflows.align import ImageRegistrationFlow, SynRegistrationFlow, ApplyTransformFlow, ResliceFlow, SlrWithQbxFlow, MotionCorrectionFlow, BundleWarpFlow
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 7 for calling a global function with example usage: test_syn_registration_flow() without return types