code: def reg_func(figname, static_mask=None, moving_mask=None):
      """Convenience function for registration using a pipeline.
      Uses variables in global scope, except for static_mask and moving_mask.
      """
  
      pipeline = [translation, rigid]
  
      xformed_img, reg_affine = affine_registration(
          moving,
          static,
          moving_affine=moving_affine,
          static_affine=static_affine,
          nbins=32,
          metric="MI",
          pipeline=pipeline,
          level_iters=level_iters,
          sigmas=sigmas,
          factors=factors,
          static_mask=static_mask,
          moving_mask=moving_mask,
      )
  
      regtools.overlay_slices(
          static, xformed_img, None, 2, "Static", "Transformed", figname
      )
  
file_path: dipy/doc/examples/affine_registration_masks.py
imports: from os.path import join
  import numpy
  import matplotlib.pyplot
  from dipy.viz import regtools
  from dipy.data import fetch_stanford_hardi
  from dipy.io.image import load_nifti
  from dipy.align.imaffine import AffineMap, MutualInformationMetric, AffineRegistration
  from dipy.align.transforms import TranslationTransform3D, RigidTransform3D
  from dipy.align import affine_registration, translation, rigid, register_series
label_desc: Use image node_id 1 for calling a global function with example usage: reg_func(figname, static_mask, moving_mask) without return types